Prev: B400 Up: Map Next: B46B
B41F: Handler: Display Room Image
Used by the routines at LoadFromTape, Handler_ShowNewRoom and Action_Look.
Show the picture for the current room when that room has one.
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.
HandlerDisplayRoomImage B41F LD A,($AEF6) Jump to HandlerDisplayRoomExits if the picture-room count is set to zero.
B422 OR A
B423 JR Z,HandlerDisplayRoomExits
The version of the game being played DOES have graphics, so continue.
B425 LD A,($AECD) Fetch the current room and load it into A.
B428 LD HL,($AED8) Fetch the address of the table from the rooms-with-images pointer.
B42B LD BC,($AEF6) Fetch the count of the number of rooms in the table from the picture-room count.
B42F CPIR Search to see if the current room ID is in the table.
B431 JR NZ,HandlerDisplayRoomExits Jump to HandlerDisplayRoomExits if the current room ID does not appear in the table.
The current room does have an image associated with it.
B433 LD A,($AEF6) Read the picture-room count into A.
B436 INC C Turn the picture search into this room's image index.
B437 SUB C
B438 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.
B439 XOR A Jump to DisplayRoomImage if E was set to 01 (Display the image).
B43A OR E
B43B 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").
B43D LD HL,$AE7E Point HL at the room-image-seen flags.
B440 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 B441 CP $08 Jump to FoundAlreadySeenByte if the room index is less than 08.
B443 JR C,FoundAlreadySeenByte
B445 SUB $08 Move this room into the next flag byte.
B447 INC HL Increment the "image already seen" table pointer by one.
B448 JR FindAlreadySeenByte_Loop Jump back to FindAlreadySeenByte_Loop until the flag byte for this room is found.
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 B44A LD B,A Copy the "image already seen" byte into B.
B44B INC B Include a shift for bit 0.
B44C LD D,$00 Start with all bits clear in D.
AlreadySeenBitShift_Loop B44E RL D Slide this room's bit into place.
B450 DJNZ AlreadySeenBitShift_Loop
Test the bit held in D against the room flag.
B452 LD A,(HL) Fetch the current room flag.
B453 AND D If the room image has already been seen ... jump to HandlerDisplayRoomExits.
B454 JR NZ,HandlerDisplayRoomExits
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.
B456 LD A,(HL) Merge the set room bit with the room flags and write the result back to the room flag byte.
B457 OR D
B458 LD (HL),A
Finally! Display the room image.
DisplayRoomImage B459 PUSH BC Call ClearScreen to clear the screen, keeping the location image index in C.
B45A CALL ClearScreen
B45D POP BC
B45E LD IX,($AEDA) Fetch the address of the table from the room-image jump pointer.
B462 LD E,C Load the location image index into E.
B463 CALL GetTableEntry Call GetTableEntry to look up the table entry.
B466 LD DE,$B46B Push HandlerDisplayRoomExits onto the stack so that the next return will go on to show the room exits.
B469 PUSH DE
B46A JP (HL) Jump to the routine pointed to by *HL to display the room image.
View the equivalent code in;
Prev: B400 Up: Map Next: B46B