![]() |
Routines |
| Prev: 5FC5 | Up: Map | Next: 5FE7 |
|
Used by the routine at PopulateRoomBuffer.
Sets the room data pointer for the current room.
The room data is stored as a series of blocks from Room01, separated by 00 terminators. This routine scans through the data to find the block matching the *CurrentRoom.
|
||||
| FindRoomData | 5FC6 | LD A,($5FC5) | D=*CurrentRoom. | |
| 5FC9 | LD D,A | |||
| 5FCA | LD E,$01 | E=01 (start searching from room 01). | ||
| 5FCC | CP E | Return if the current room is 01 (the data pointer already defaults to the first room). | ||
| 5FCD | RET Z | |||
|
Scan through the room data blocks. Each block is terminated by 00 so count terminators to find the Nth room.
|
||||
| 5FCE | LD HL,$83AA | HL=83AA (start of room data + 01 for no real reason). | ||
| FindRoomData_ScanLoop | 5FD1 | LD A,(HL) | A=*HL. | |
| 5FD2 | INC HL | Advance the data pointer. | ||
| 5FD3 | OR A | Jump to FindRoomData_FoundTerminator if a 00 terminator was found. | ||
| 5FD4 | JR Z,FindRoomData_FoundTerminator | |||
| 5FD6 | JR FindRoomData_ScanLoop | Jump to FindRoomData_ScanLoop to keep scanning. | ||
|
Found a block terminator so check if we've reached the target room.
|
||||
| FindRoomData_FoundTerminator | 5FD8 | INC E | Increment the room counter in E. | |
| 5FD9 | LD A,E | Jump to Raise_Table_Error if the room counter has exceeded 11 (maximum number of rooms/room not found). | ||
| 5FDA | CP $11 | |||
| 5FDC | JR NC,Raise_Table_Error | |||
| 5FDE | CP D | Jump to FindRoomData_Found if the room counter matches the target room number. | ||
| 5FDF | JR Z,FindRoomData_Found | |||
| 5FE1 | JR FindRoomData_ScanLoop | Otherwise, jump to FindRoomData_ScanLoop to keep scanning. | ||
|
The target room was found so store the pointer to its data.
|
||||
| FindRoomData_Found | 5FE3 | LD ($5FC3),HL | Write HL to *PointerRoomData. | |
| 5FE6 | RET | Return. | ||
| Prev: 5FC5 | Up: Map | Next: 5FE7 |