Prev: ABB6 Up: Map Next: AC9A
AC02: Handler: Display Room Exits
Used by the routine at Handler_DisplayRoomImage.
Handles displaying the exits available for the current room.
Handler_RoomExits AC02 CALL ClearScreen Call ClearScreen.
AC05 LD A,$18 Set up the printing position.
AC07 CALL Print_RoomDescription
AC0A CALL GetRoomPointer Call GetRoomPointer which loads HL with the room data pointer.
AC0D LD D,H Store this in DE for later.
AC0E LD E,L
Count the number of exits in the room data.
AC0F LD B,$06 Set an "exits" counter in B of 06.
AC11 LD C,$00 Initialise C to 00 to count the number of valid exits.
AC13 XOR A Set A to 00 which is used just for the comparison.
RoomExitsCount_Loop AC14 CP (HL) Does this room have an exit?
AC15 JR Z,RoomExitsCount_Skip Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position.
AC17 INC C Increment the valid exits count by one.
RoomExitsCount_Skip AC18 INC HL Move to the next byte of room data.
AC19 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.
AC1B OR C Jump to RoomExits_YouCanSee if no exits were found.
AC1C JR Z,RoomExits_YouCanSee
AC1E LD A,C Jump to RoomMultipleExits if more than 01 exit was found.
AC1F CP $01
AC21 JR NZ,RoomMultipleExits
Only one exit was found:
Print " There is an exit ".
AC23 LD HL,$A8AA HL=Messaging_ThereIsAnExit.
AC26 CALL PrintString Call PrintString.
AC29 LD H,D Retrieve the room data pointer and load it into HL.
AC2A LD L,E
AC2B LD IX,$AAE2 Set a pointer in IX to Table_Directions.
AC2F XOR A Set A to 00 which is used just for the comparison.
AC30 JR RoomCheckForExit Jump to RoomCheckForExit.
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 AC32 INC HL Move to the next byte of room data.
AC33 INC IX Increment the direction name table pointer by two.
AC35 INC IX
RoomCheckForExit AC37 CP (HL) Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit.
AC38 JR Z,RoomCheckForExit_Loop
AC3A LD L,(IX+$00) Get the direction name from the direction name table.
AC3D LD H,(IX+$01)
AC40 CALL PrintString Call PrintString to print the direction name.
AC43 JR RoomExits_PrintFullStop Jump to RoomExits_PrintFullStop.
More than one exit was found:
Print " There are exits:-".
RoomMultipleExits AC45 LD HL,$A897 HL=Messaging_ThereAreExits.
AC48 CALL PrintStringAndNewline Call PrintStringAndNewline.
AC4B LD H,D Retrieve the room data pointer and load it into HL.
AC4C LD L,E
AC4D LD IX,$AAE2 Set a pointer in IX to Table_Directions.
AC51 XOR A Set A to 00 which is used just for the comparison.
AC52 JR RoomCheckForExits Jump to RoomCheckForExits.
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 AC54 EX DE,HL Switch back the DE and HL registers.
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 AC55 INC HL Move to the next byte of room data.
AC56 INC IX Increment the direction name table pointer by two.
AC58 INC IX
RoomCheckForExits AC5A CP (HL) Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit.
AC5B JR Z,RoomCheckForExits_Loop
AC5D EX DE,HL Temporarily store the room data pointer in DE.
AC5E LD L,(IX+$00) Get the direction name from the direction name table.
AC61 LD H,(IX+$01)
AC64 CALL PrintString Call PrintString to print the direction name.
AC67 DEC C Decrease the valid exits count by one.
AC68 LD A,C Jump to RoomExits_PrintFullStop if there are no more exits to process.
AC69 CP $01
AC6B JR C,RoomExits_PrintFullStop
AC6D JR Z,RoomExits_PrintAmpersand Jump to RoomExits_PrintAmpersand if there is only one exit left to process.
Print a comma character: ",".
AC6F LD A,$2C A=2C.
AC71 CALL PrintCharacter Call PrintCharacter.
AC74 XOR A Reset A back to 00 for the comparison.
AC75 JR RoomExits_Initialise Jump back to RoomExits_Initialise to continue processing.
Print " & ".
RoomExits_PrintAmpersand AC77 LD HL,$A893 HL=Messaging_Ampersand.
AC7A CALL PrintString Call PrintString.
AC7D XOR A Reset A back to 00 for the comparison.
AC7E JR RoomExits_Initialise Jump to RoomExits_Initialise to continue processing.
Print ".".
RoomExits_PrintFullStop AC80 LD HL,$AA15 HL=Messaging_FullStop.
AC83 CALL PrintStringAndNewline Call PrintStringAndNewline.
Are there any objects here?
RoomExits_YouCanSee AC86 LD A,($A7C3) A=*CurrentRoom.
AC89 CALL CheckRoomObjects Call CheckRoomObjects.
AC8C RET NZ Return if no objects were found at this location.
Print " You can see:-".
AC8D LD HL,$A884 HL=Messaging_YouCanSee.
AC90 CALL PrintStringAndNewline Call PrintStringAndNewline.
Print the objects at this location.
AC93 LD A,($A7C3) A=*CurrentRoom.
AC96 CALL PrintObjects Call PrintObjects.
AC99 RET Return.
Prev: ABB6 Up: Map Next: AC9A