Prev: 49663 Up: Map Next: 49770
49694: Handler: Display Room Image
Used by the routines at LoadTape, 61268 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 1 If the image should be displayed, 0 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 49694 LD A,(48430) Jump to Handler_RoomExits if *Count_RoomsWithImages is set to zero.
49697 OR A
49698 JR Z,Handler_RoomExits
The version of the game being played DOES have graphics, so continue.
49700 LD A,(48331) Fetch *CurrentRoom and load it into A.
49703 LD HL,(48404) Fetch the address of the table from *Pointer_RoomsWithImages.
49706 LD BC,(48430) Fetch the count of the number of rooms in the table from *Count_RoomsWithImages.
49710 CPIR Search to see if the current room ID is in the table.
49712 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.
49714 LD A,(48430) Calculate the index of the current room in the table.
49717 INC C
49718 SUB C
49719 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.
49720 XOR A Jump to DisplayRoomImage if E was set to 1 (Display the image).
49721 OR E
49722 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").
49724 LD HL,48220 HL=Table_RoomImagesAlreadySeen.
49727 LD A,C Copy the room image index into A.
Only two bytes hold the data for all 12 rooms with images so first - find the correct byte which references this room.
FindAlreadySeenByte_Loop 49728 CP 8 Jump to FoundAlreadySeenByte if the room index is less than 8.
49730 JR C,FoundAlreadySeenByte
49732 SUB 8 Subtract 8 (number of bits in a byte) from the room index.
49734 INC HL Increment the "image already seen" table pointer by one.
49735 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 49737 LD B,A Copy the "image already seen" byte into B.
49738 INC B Increment B by one to get the correct number of shifts.
49739 LD D,0 Start with all bits clear in D.
AlreadySeenBitShift_Loop 49741 RL D Rotate 1 bit left into position.
49743 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.
49745 LD A,(HL) Fetch the current room flag.
49746 AND D If the room image has already been seen ... jump to Handler_RoomExits.
49747 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.
49749 LD A,(HL) Merge the set room bit with the room flags and write the result back to the room flag byte.
49750 OR D
49751 LD (HL),A
Finally! Display the room image.
DisplayRoomImage 49752 PUSH BC Temporarily stash BC on the stack.
49753 CALL ClearScreen Call ClearScreen.
49756 POP BC Restore BC from the stack.
49757 LD IX,(48406) Fetch the address of the table from *Pointer_RoomImage.
49761 LD E,C Load the location image index into E.
49762 CALL GetTableEntry Call GetTableEntry.
49765 LD DE,49770 Push Handler_RoomExits onto the stack so that the next return will go on to show the room exits.
49768 PUSH DE
49769 JP (HL) Jump to the routine pointed to by *HL to display the room image.
Prev: 49663 Up: Map Next: 49770