Prev: AB97 Up: Map Next: AC02
ABB6: Handler: Display Room Image
Used by the routines at LoadTape, EB10 and Action_Look.
Determines if the current room has an image relating to it, and if it does - it jumps to the routine to display it.
Input
E 01 If the image should be displayed, 00 if it should be skipped
The game can also load without any graphics at all, so bail if there's nothing needed to do here.
Handler_DisplayRoomImage ABB6 LD A,($A7EC) Jump to Handler_RoomExits if *Count_RoomsWithImages is set to zero.
ABB9 OR A
ABBA JR Z,Handler_RoomExits
The version of the game being played DOES have graphics, so continue.
ABBC LD A,($A7C3) Fetch *CurrentRoom and load it into A.
ABBF LD HL,($A7CE) Fetch the address of the table from *Pointer_RoomsWithImages.
ABC2 LD BC,($A7EC) Fetch the count of the number of rooms in the table from *Count_RoomsWithImages.
ABC6 CPIR Search to see if the current room ID is in the table.
ABC8 JR NZ,Handler_RoomExits Jump to Handler_RoomExits if the current room ID does not appear in the table.
The current room does have an image associated with it.
ABCA LD A,($A7EC) Calculate the index of the current room in the table.
ABCD INC C
ABCE SUB C
ABCF LD C,A
The E register is used as a flag to indicate that the room image should not be displayed, e.g. after the player has requested to view their inventory and have seen the room image already when they entered the location.
ABD0 XOR A Jump to DisplayRoomImage if E was set to 01 (Display the image).
ABD1 OR E
ABD2 JR NZ,DisplayRoomImage
The game also maintains a table of "already seen room images" so the player doesn't have to view an image for a room they've already been in.
The player can view it manually by typing "LOOK" (or just "L").
ABD4 LD HL,$A774 HL=Table_RoomImagesAlreadySeen.
ABD7 LD A,C Copy the room image index into A.
Only two bytes hold the data for all 0C rooms with images so first - find the correct byte which references this room.
FindAlreadySeenByte_Loop ABD8 CP $08 Jump to FoundAlreadySeenByte if the room index is less than 08.
ABDA JR C,FoundAlreadySeenByte
ABDC SUB $08 Subtract 08 (number of bits in a byte) from the room index.
ABDE INC HL Increment the "image already seen" table pointer by one.
ABDF JR FindAlreadySeenByte_Loop Jump back to FindAlreadySeenByte_Loop.
Now the correct byte has been found, check the appropriate bit.
Create a mask with a single bit set corresponding to this rooms position (0-7) in the byte.
FoundAlreadySeenByte ABE1 LD B,A Copy the "image already seen" byte into B.
ABE2 INC B Increment B by one to get the correct number of shifts.
ABE3 LD D,$00 Start with all bits clear in D.
AlreadySeenBitShift_Loop ABE5 RL D Rotate 1 bit left into position.
ABE7 DJNZ AlreadySeenBitShift_Loop Decrease the shift counter by one and loop back to AlreadySeenBitShift_Loop until the bit is in the correct position.
Test the bit held in D against the room flag.
ABE9 LD A,(HL) Fetch the current room flag.
ABEA AND D If the room image has already been seen ... jump to Handler_RoomExits.
ABEB JR NZ,Handler_RoomExits
The room image hasn't already been seen, so update the bit to indicate that the player will have viewed it for the next time this routine runs.
ABED LD A,(HL) Merge the set room bit with the room flags and write the result back to the room flag byte.
ABEE OR D
ABEF LD (HL),A
Finally! Display the room image.
DisplayRoomImage ABF0 PUSH BC Temporarily stash BC on the stack.
ABF1 CALL ClearScreen Call ClearScreen.
ABF4 POP BC Restore BC from the stack.
ABF5 LD IX,($A7D0) Fetch the address of the table from *Pointer_RoomImage.
ABF9 LD E,C Load the location image index into E.
ABFA CALL GetTableEntry Call GetTableEntry.
ABFD LD DE,$AC02 Push Handler_RoomExits onto the stack so that the next return will go on to show the room exits.
AC00 PUSH DE
AC01 JP (HL) Jump to the routine pointed to by *HL to display the room image.
Prev: AB97 Up: Map Next: AC02