Prev: B41F Up: Map Next: B503
B46B: Handler: Display Room Exits
Used by the routine at HandlerDisplayRoomImage.
Print the exits that leave the current room.
HandlerDisplayRoomExits B46B CALL ClearScreen Call ClearScreen to clear the screen.
B46E LD A,$18 Set up the printing position.
B470 CALL PrintRoomDescription
B473 CALL GetRoomPointer Call GetRoomPointer which loads HL with the room data pointer.
B476 LD D,H Store this in DE for later.
B477 LD E,L
Count the number of exits in the room data.
B478 LD B,$06 Set an "exits" counter in B of 06.
B47A LD C,$00 Initialise C to 00 to count the number of valid exits.
B47C XOR A Set A to 00 which is used just for the comparison.
RoomExitsCount_Loop B47D CP (HL) Does this room have an exit?
B47E JR Z,RoomExitsCount_Skip Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position.
B480 INC C Increment the valid exits count by one.
RoomExitsCount_Skip B481 INC HL Move to the next byte of room data.
B482 DJNZ RoomExitsCount_Loop Decrease the exits counter by one and loop back to RoomExitsCount_Loop until all the exits have been checked.
Process the exits count result.
B484 OR C Jump to RoomExits_YouCanSee if no exits were found.
B485 JR Z,RoomExits_YouCanSee
B487 LD A,C Jump to RoomMultipleExits if more than 01 exit was found.
B488 CP $01
B48A JR NZ,RoomMultipleExits
Only one exit was found:
B48C LD HL,$AFB4 Print " There is an exit ".
B48F CALL PrintString
B492 LD H,D Retrieve the room data pointer and load it into HL.
B493 LD L,E
B494 LD IX,$B1D8 Set a pointer in IX to Table_DirectionNames.
B498 XOR A Set A to 00 which is used just for the comparison.
B499 JR RoomCheckForExit Start at the north exit.
Move both the pointers to the next item of data (increment by two for the direction name table pointer as it contains addresses).
RoomCheckForExit_Loop B49B INC HL Move to the next byte of room data.
B49C INC IX Increment the direction name table pointer by two.
B49E INC IX
RoomCheckForExit B4A0 CP (HL) Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit.
B4A1 JR Z,RoomCheckForExit_Loop
B4A3 LD L,(IX+$00) Get the direction name from the direction name table.
B4A6 LD H,(IX+$01)
B4A9 CALL PrintString Call PrintString to print the direction name.
B4AC JR RoomExits_PrintFullStop Finish the exit sentence.
More than one exit was found:
RoomMultipleExits B4AE LD HL,$AFA1 Print " There are exits:-" and start a new line.
B4B1 CALL PrintStringAndANewline
B4B4 LD H,D Retrieve the room data pointer and load it into HL.
B4B5 LD L,E
B4B6 LD IX,$B1D8 Set a pointer in IX to Table_DirectionNames.
B4BA XOR A Set A to 00 which is used just for the comparison.
B4BB JR RoomCheckForExits Start at the north exit.
So as not to corrupt the pointer to the room data (as HL is also used when printing), it's temporarily held in DE.
RoomExits_Initialise B4BD EX DE,HL Bring the room data pointer back into HL.
Move both the pointers to the next item of data (increment by two for the direction name table pointer as it contains addresses).
RoomCheckForExits_Loop B4BE INC HL Move to the next byte of room data.
B4BF INC IX Increment the direction name table pointer by two.
B4C1 INC IX
RoomCheckForExits B4C3 CP (HL) Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit.
B4C4 JR Z,RoomCheckForExits_Loop
B4C6 EX DE,HL Temporarily store the room data pointer in DE.
B4C7 LD L,(IX+$00) Get the direction name from the direction name table.
B4CA LD H,(IX+$01)
B4CD CALL PrintString Call PrintString to print the direction name.
B4D0 DEC C Decrease the valid exits count by one.
B4D1 LD A,C Jump to RoomExits_PrintFullStop if there are no more exits to process.
B4D2 CP $01
B4D4 JR C,RoomExits_PrintFullStop
B4D6 JR Z,RoomExits_PrintAmpersand Jump to RoomExits_PrintAmpersand if there is only one exit left to process.
Print a comma character: ",".
B4D8 LD A,$2C Print a comma between the exit names.
B4DA CALL PrintCharacter Call PrintCharacter to print the character.
B4DD XOR A Reset A back to 00 for the comparison.
B4DE JR RoomExits_Initialise Jump back to RoomExits_Initialise to continue processing.
RoomExits_PrintAmpersand B4E0 LD HL,$AF9D Print " & ".
B4E3 CALL PrintString
B4E6 XOR A Reset A back to 00 for the comparison.
B4E7 JR RoomExits_Initialise Jump to RoomExits_Initialise to continue processing.
RoomExits_PrintFullStop B4E9 LD HL,$B10B Print "." and start a new line.
B4EC CALL PrintStringAndANewline
Are there any objects here?
RoomExits_YouCanSee B4EF LD A,($AECD) Read the current room into A.
B4F2 CALL CheckRoomObjects Call CheckRoomObjects to see which objects are in the room.
B4F5 RET NZ Return if no objects were found at this location.
B4F6 LD HL,$AF8E Print " You can see:-" and start a new line.
B4F9 CALL PrintStringAndANewline
Print the objects at this location.
B4FC LD A,($AECD) Read the current room into A.
B4FF CALL PrintObjects Call PrintObjects to list the objects here.
B502 RET Return.
Prev: B41F Up: Map Next: B503