home *** CD-ROM | disk | FTP | other *** search
- ;Get Direction
- ;
- ;By Mikel Blanchard
- ;Copyright (c) 1998
- ;Macross Software
- ;
- ;http://MacrossSoftware.home.ml.org/
- ;
- ;Input: BC = (x,y) for character
- ; DE = (x,y) for enemy character
- ;Ouput: A = Direction the enemy should walk according to the table
- ; NW N NE
- ; 0 1 2
- ; W 3 4 5 E
- ; 6 7 8
- ; SW S SE
- ;
- ; (4 = same location, ie you're dead.)
- ;
- GetDirec:
- ld a,b
- cp d ; Check horizontal position
- ld l,0
- jr c,CheckVert ; True if YouX < EnemyX
- ld l,1 ; Not inc l...
- jr z,CheckVert ; True if YouX = EnemyX
- inc l
- CheckVert:
- ld a,c
- cp e
- ld h,0
- jr c,CheckDone ; True if YouY < EnemyY
- ld h,3
- jr z,CheckDone ; True if YouX = EnemyY
- ld h,6
- CheckDone:
- ld a,l
- add a,h
- ret