![]() |
Routines |
| Prev: 9C20 | Up: Map | Next: 9C76 |
|
Used by the routines at SendProgramPacket, MoveSpark, MoveDestroyer, FindSectorEnergy, MoveProgramPacket and UseActionKey_Up.
Finds the sector that an entity is in. The nine sectors are numbered from 00 for the top left to 08 for the bottom right.
|
||||||||||||
| FindSector | 9C5E | LD A,(IX+$02) | Fetch the X cell of the entity. | |||||||||
| 9C61 | AND $30 | Keep the sector column, which is a multiple of 10... | ||||||||||
| 9C63 | LD E,A | ...in E. | ||||||||||
| 9C64 | LD A,(IX+$04) | Fetch the Y cell of the entity. | ||||||||||
| 9C67 | AND $30 | Keep the sector row... | ||||||||||
| 9C69 | XOR $30 | ...and turn it round, as the first row of sectors is at the bottom of the map... | ||||||||||
| 9C6B | SUB $10 | ...and make it a multiple of 10 from 00 to 20, from the top. | ||||||||||
| 9C6D | LD D,A | Keep the sector row. | ||||||||||
| 9C6E | ADD A,E | Add the column. | ||||||||||
| 9C6F | RRCA | Halve it... | ||||||||||
| 9C70 | ADD A,D | ...and add the row, so that the result is three times the row plus the column, multiplied by 08. | ||||||||||
| 9C71 | RRCA | Shift down by three... | ||||||||||
| 9C72 | RRCA | |||||||||||
| 9C73 | RRCA | |||||||||||
| 9C74 | LD D,A | ...to give the sector number. | ||||||||||
| 9C75 | RET | Return. | ||||||||||
| Prev: 9C20 | Up: Map | Next: 9C76 |