Prev: 38465 Up: Map Next: 38601
38575: Visit Room
Used by the routine at EnterRoom.
Marks a room as having been visited, by setting its bit in the table of visited rooms at VisitedRooms. The table has one bit for each room, 8 rooms to a byte. The bit to set is worked out from the room ID and written into the SET instruction at 38598 (self modifying code), which then sets it.
Input
A The room ID
Create an offset in BC.
VisitRoom 38575 LD C,A Keep the room ID in C.
38576 SRL C Divide by 8.
38578 SRL C
38580 SRL C
38582 LD B,0 B=0.
38584 LD HL,24128 HL=VisitedRooms + BC.
38587 ADD HL,BC
Work out the bit to set, which is the bottom three bits of the room ID.
38588 RLCA Multiply by 8.
38589 RLCA
38590 RLCA
38591 AND %00111000 Keep only bits 3-5.
38593 OR %11000110 Set bits 1-2, 6-7. This makes the second byte of the instruction SET n,(HL) for the bit.
38595 LD (38599),A Write this value to 38599, which updates the bit to set.
38598 SET 0,(HL) Set the bit to mark the room as having been visited.
38600 RET Return.
View the equivalent code in;
Prev: 38465 Up: Map Next: 38601