![]() |
Routines |
| Prev: 48783 | Up: Map | Next: 48998 |
|
Used by the routine at SelectNextTile.
Finds the tile record for the position of the object using FindTileRecord, works out where the object is within the tile and stores it in ScratchValues to 52797 and counts the tiles that it overlaps (up to four) in TileNumber.
|
||||
| FindTilesOverlapped | 48871 | LD BC,(49025) | Fetch the word at 49025 into BC. | |
| 48875 | LD DE,(49023) | Fetch the word at TilePosition into DE. | ||
| 48879 | CALL FindTileRecord | Call FindTileRecord. | ||
| 48882 | LD A,(49023) | The tile position. | ||
| 48885 | LD C,A | C=A. | ||
| 48886 | LD A,(23596) | The segment screen column. | ||
| 48889 | LD B,A | B=A. | ||
| 48890 | LD A,C | A=C. | ||
| 48891 | ADD A,24 | Add 24 to A. | ||
| 48893 | ADD A,B | A gains B. | ||
| 48894 | LD E,B | E=B. | ||
| 48895 | JR NC,FindTilesOverlapped_Horizontal | Jump to FindTilesOverlapped_Horizontal if the carry flag is clear. | ||
| 48897 | LD B,A | B=A. | ||
| 48898 | LD A,(23581) | The tiles still to test. | ||
| 48901 | AND A | Jump to FindTilesOverlapped_Right if A is not zero. | ||
| 48902 | JR NZ,FindTilesOverlapped_Right | |||
| 48904 | LD A,B | A=B. | ||
| 48905 | LD (23594),A | The object reaches into the next column. | ||
| 48908 | LD A,1 | A=1. | ||
| 48910 | LD (58395),A | Update the slope direction. | ||
| FindTilesOverlapped_Right | 48913 | LD A,232 | A=232. | |
| 48915 | SUB C | Subtract C from A. | ||
| 48916 | LD E,A | E=A. | ||
| FindTilesOverlapped_Horizontal | 48917 | LD A,E | A=E. | |
| 48918 | LD (52797),A | The horizontal edge in the tile. | ||
| 48921 | LD A,C | A=C. | ||
| 48922 | LD (52794),A | The horizontal position in the tile. | ||
| 48925 | LD A,(49025) | The vertical position. | ||
| 48928 | LD C,A | C=A. | ||
| 48929 | LD A,(23597) | The segment screen row. | ||
| 48932 | LD B,A | B=A. | ||
| 48933 | LD A,C | A=C. | ||
| 48934 | SUB 23 | Subtract 23 from A. | ||
| 48936 | SUB B | Subtract B from A. | ||
| 48937 | LD E,B | E=B. | ||
| 48938 | JR NC,FindTilesOverlapped_Vertical | Jump to FindTilesOverlapped_Vertical if the carry flag is clear. | ||
| 48940 | LD B,A | B=A. | ||
| 48941 | LD A,(23581) | The tiles still to test. | ||
| 48944 | AND A | Jump to FindTilesOverlapped_Up if A is not zero. | ||
| 48945 | JR NZ,FindTilesOverlapped_Up | |||
| 48947 | LD A,B | A=B. | ||
| 48948 | NEG | Negate A. | ||
| 48950 | LD (23595),A | The object reaches into the zone above. | ||
| FindTilesOverlapped_Up | 48953 | LD A,C | A=C. | |
| 48954 | SUB 23 | Subtract 23 from A. | ||
| 48956 | LD E,A | E=A. | ||
| FindTilesOverlapped_Vertical | 48957 | LD A,E | A=E. | |
| 48958 | LD (52796),A | The vertical edge in the tile. | ||
| 48961 | LD A,C | A=C. | ||
| 48962 | LD (52795),A | The vertical position in the tile. | ||
| 48965 | LD A,(23581) | The tiles still to test. | ||
| 48968 | AND A | Return if A is not zero. | ||
| 48969 | RET NZ | |||
| 48970 | LD B,1 | B=1. | ||
| 48972 | LD A,(23594) | The object reaches into the next column. | ||
| 48975 | AND A | Jump to FindTilesOverlapped_Count if A is zero. | ||
| 48976 | JR Z,FindTilesOverlapped_Count | |||
| 48978 | INC B | Advance B. | ||
| 48979 | LD A,(23595) | The object reaches into the zone above. | ||
| 48982 | AND A | Jump to FindTilesOverlapped_Count if A is zero. | ||
| 48983 | JR Z,FindTilesOverlapped_Count | |||
| 48985 | INC B | Advance B. | ||
| FindTilesOverlapped_Count | 48986 | LD A,(23595) | The object reaches into the zone above. | |
| 48989 | AND A | Jump to FindTilesOverlapped_Return if A is zero. | ||
| 48990 | JR Z,FindTilesOverlapped_Return | |||
| 48992 | INC B | Advance B. | ||
| FindTilesOverlapped_Return | 48993 | LD A,B | A=B. | |
| 48994 | LD (23581),A | Update the tiles still to test. | ||
| 48997 | RET | Return. | ||
| Prev: 48783 | Up: Map | Next: 48998 |