| The Hobbit (v1.0) | Routines |
| Prev: 9B04 | Up: Map | Next: 9B25 |
|
Returns the address of the record for room number A (0-79) from the room pointer table at B8D0. Numbers of $50 (80) and above are not rooms; for those, A is set to 0 and the routine returns with the Z flag set.
|
||||||||||||
| 9B0C | CP $50 | Is the room number 80 or higher (not a real room)? | ||||||||||
| 9B0E | JR C,$9B12 | No, it is a real room: go and find its record | ||||||||||
| 9B10 | XOR A | Not a real room: return 0, with Z set, so the caller knows there is no such room | ||||||||||
| 9B11 | RET | |||||||||||
| 9B12 | PUSH DE | Save DE for the caller | ||||||||||
| 9B13 | LD DE,$B8D0 | HL will point into the room pointer table, which starts here | ||||||||||
| 9B16 | PUSH HL | Save HL for the caller | ||||||||||
| 9B17 | LD L,A | HL = the room number... | ||||||||||
| 9B18 | LD H,$00 | |||||||||||
| 9B1A | ADD HL,HL | ...doubled, because each room has a 2-byte entry in the table | ||||||||||
| 9B1B | ADD HL,DE | HL = the address of this room's entry in the pointer table | ||||||||||
| 9B1C | LD E,(HL) | DE = the room's record address, read from the table (low byte)... | ||||||||||
| 9B1D | INC HL | |||||||||||
| 9B1E | LD D,(HL) | ...then the high byte | ||||||||||
| 9B1F | PUSH DE | Move that address onto the stack for a moment... | ||||||||||
| 9B20 | POP IX | ...so it can be popped straight into IX, the register the rest of the game expects a room record in | ||||||||||
| 9B22 | POP HL | Restore the caller's HL | ||||||||||
| 9B23 | POP DE | Restore the caller's DE | ||||||||||
| 9B24 | RET | |||||||||||
| Prev: 9B04 | Up: Map | Next: 9B25 |