Prev: 9CC6 Up: Map Next: 9D41
9D23: Visit Room
Used by the routines at EnterRoomBelow and InitialiseGame.
Marks the room that an actor is in as having been visited, by setting its bit in the bitmap at VisitedRooms (the bitmap holds one bit for each of the 0100 rooms). This uses self-modifying code: the second byte of the "SET n,(HL)" instruction at 9D3E is overwritten to select the bit.
Input
IX Actor record
Work out which byte of the bitmap holds the bit for the room.
VisitRoom 9D23 LD A,(IX+$01) Fetch the room of the actor.
9D26 LD C,A Stash the room in C.
9D27 RRCA Divide the room by 08 (each byte of the bitmap holds the bits for 08 rooms).
9D28 RRCA
9D29 RRCA
9D2A AND %00011111 Keep only bits 0-4.
9D2C LD L,A Use it as the offset into the visited rooms bitmap.
9D2D LD H,$00
Work out which bit of that byte is needed and modify the instruction.
9D2F LD A,C Fetch the room.
9D30 RLCA Multiply by 08 so that the low three bits of the room are in bits 3-5.
9D31 RLCA
9D32 RLCA
9D33 AND %00111000 Keep only the bit number (bits 3-5).
9D35 OR %11000110 Set bits 1-2, 6-7 (to make the second byte of "SET n,(HL)").
9D37 LD ($9D3F),A Write this into the second byte of the instruction at 9D3E.
Set the bit.
9D3A LD BC,$96BF Add the start of the visited rooms bitmap at VisitedRooms to the offset.
9D3D ADD HL,BC
9D3E SET 0,(HL) Set the bit for the room in the bitmap.
9D40 RET Return.
View the equivalent code in;
Prev: 9CC6 Up: Map Next: 9D41