![]() |
Routines |
| Prev: 49042 | Up: Map | Next: 49086 |
|
Used by the routines at TestCellInDirection, SpawnEnemies, MoveLeft, MoveUp, MoveRight, MoveDown and UseActionKey_Up.
Finds a cell of the map from its column and row, and tests whether it is empty. The address of the cell is also stored. The routine returns with all of the registers kept, apart from A and the flags.
|
||||||||||||||||
| FindMapCell | 49047 | PUSH DE | Save DE and HL. | |||||||||||||
| 49048 | PUSH HL | |||||||||||||||
| 49049 | LD E,D | Move the column into E and the row into D. | ||||||||||||||
| 49050 | LD D,H | |||||||||||||||
| 49051 | JR FindMapCell_Find | Jump to find the cell. | ||||||||||||||
|
This entry point is used by the routines at MainLoop and AddMapCells.
This entry point takes the column in E and the row in D.
|
||||||||||||||||
| FindMapCell_ColumnRow | 49053 | PUSH DE | Save DE and HL. | |||||||||||||
| 49054 | PUSH HL | |||||||||||||||
| FindMapCell_Find | 49055 | LD (38444),DE | Store the column and the row. | |||||||||||||
| 49059 | XOR A | Clear the high part of the cell offset. | ||||||||||||||
| 49060 | SRL D | Divide the row by four, keeping the bits that come out in the top of A. | ||||||||||||||
| 49062 | RRA | |||||||||||||||
| 49063 | SRL D | |||||||||||||||
| 49065 | RRA | |||||||||||||||
| 49066 | OR E | Combine them with the column, to give the low byte of the offset of the cell, as there are 64 cells in each row. | ||||||||||||||
| 49067 | LD E,A | |||||||||||||||
| 49068 | LD HL,50453 | Add the offset to the address of the map. | ||||||||||||||
| 49071 | ADD HL,DE | |||||||||||||||
| 49072 | LD (38446),HL | Store the address of the cell. | ||||||||||||||
| 49075 | LD A,(HL) | Fetch the type of the cell, which is in the lower four bits, and jump if it is zero. | ||||||||||||||
| 49076 | AND 15 | |||||||||||||||
| 49078 | JR Z,FindMapCell_Empty | |||||||||||||||
| FindMapCell_Return | 49080 | POP HL | Restore HL and DE. | |||||||||||||
| 49081 | POP DE | |||||||||||||||
| 49082 | RET | Return. | ||||||||||||||
| FindMapCell_Empty | 49083 | XOR A | Mark the cell as empty and jump. | |||||||||||||
| 49084 | JR FindMapCell_Return | |||||||||||||||
| Prev: 49042 | Up: Map | Next: 49086 |