home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 86 / asm / source / routines / getdirec.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  714 b   |  39 lines

  1. ;Get Direction
  2. ;
  3. ;By Mikel Blanchard
  4. ;Copyright (c) 1998
  5. ;Macross Software
  6. ;
  7. ;http://MacrossSoftware.home.ml.org/
  8. ;
  9. ;Input: BC = (x,y) for character
  10. ;    DE = (x,y) for enemy character
  11. ;Ouput: A = Direction the enemy should walk according to the table
  12. ;    NW   N   NE 
  13. ;      0  1  2
  14. ;    W 3  4  5 E
  15. ;      6  7  8
  16. ;    SW   S   SE
  17. ;
  18. ;    (4 = same location, ie you're dead.)
  19. ;
  20. GetDirec:
  21. ld a,b
  22.  cp d          ; Check horizontal position
  23.  ld l,0
  24.  jr c,CheckVert   ; True if YouX < EnemyX
  25.  ld l,1           ; Not inc l...
  26.  jr z,CheckVert   ; True if YouX = EnemyX
  27.  inc l 
  28. CheckVert:
  29.  ld a,c
  30.  cp e
  31.  ld h,0
  32.  jr c,CheckDone   ; True if YouY < EnemyY
  33.  ld h,3
  34.  jr z,CheckDone   ; True if YouX = EnemyY
  35.  ld h,6
  36. CheckDone:
  37.  ld a,l
  38.  add a,h
  39.  ret