Prev: 9641 Up: Map Next: 96C9
96AF: 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, 08 rooms to a byte. The bit to set is worked out from the room ID and written into the SET instruction at 96C6 (self modifying code), which then sets it.
Input
A The room ID
Create an offset in BC.
VisitRoom 96AF LD C,A Keep the room ID in C.
96B0 SRL C Divide by 08.
96B2 SRL C
96B4 SRL C
96B6 LD B,$00 B=00.
96B8 LD HL,$5E40 HL=VisitedRooms + BC.
96BB ADD HL,BC
Work out the bit to set, which is the bottom three bits of the room ID.
96BC RLCA Multiply by 08.
96BD RLCA
96BE RLCA
96BF AND %00111000 Keep only bits 3-5.
96C1 OR %11000110 Set bits 1-2, 6-7. This makes the second byte of the instruction SET n,(HL) for the bit.
96C3 LD ($96C7),A Write this value to 96C7, which updates the bit to set.
96C6 SET 0,(HL) Set the bit to mark the room as having been visited.
96C8 RET Return.
View the equivalent code in;
Prev: 9641 Up: Map Next: 96C9