Prev: 43958 Up: Map Next: 44186
44034: Handler: Display Room Exits
Used by the routine at Handler_DisplayRoomImage.
Handles displaying the exits available for the current room.
Handler_RoomExits 44034 CALL ClearScreen Call ClearScreen.
44037 LD A,24 Set up the printing position.
44039 CALL Print_RoomDescription
44042 CALL GetRoomPointer Call GetRoomPointer which loads HL with the room data pointer.
44045 LD D,H Store this in DE for later.
44046 LD E,L
Count the number of exits in the room data.
44047 LD B,6 Set an "exits" counter in B of 6.
44049 LD C,0 Initialise C to 0 to count the number of valid exits.
44051 XOR A Set A to 0 which is used just for the comparison.
RoomExitsCount_Loop 44052 CP (HL) Does this room have an exit?
44053 JR Z,RoomExitsCount_Skip Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position.
44055 INC C Increment the valid exits count by one.
RoomExitsCount_Skip 44056 INC HL Move to the next byte of room data.
44057 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.
44059 OR C Jump to RoomExits_YouCanSee if no exits were found.
44060 JR Z,RoomExits_YouCanSee
44062 LD A,C Jump to RoomMultipleExits if more than 1 exit was found.
44063 CP 1
44065 JR NZ,RoomMultipleExits
Only one exit was found:
Print " There is an exit ".
44067 LD HL,43178 HL=Messaging_ThereIsAnExit.
44070 CALL PrintString Call PrintString.
44073 LD H,D Retrieve the room data pointer and load it into HL.
44074 LD L,E
44075 LD IX,43746 Set a pointer in IX to Table_Directions.
44079 XOR A Set A to 0 which is used just for the comparison.
44080 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 44082 INC HL Move to the next byte of room data.
44083 INC IX Increment the direction name table pointer by two.
44085 INC IX
RoomCheckForExit 44087 CP (HL) Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit.
44088 JR Z,RoomCheckForExit_Loop
44090 LD L,(IX+0) Get the direction name from the direction name table.
44093 LD H,(IX+1)
44096 CALL PrintString Call PrintString to print the direction name.
44099 JR RoomExits_PrintFullStop Jump to RoomExits_PrintFullStop.
More than one exit was found:
Print " There are exits:-".
RoomMultipleExits 44101 LD HL,43159 HL=Messaging_ThereAreExits.
44104 CALL PrintStringAndNewline Call PrintStringAndNewline.
44107 LD H,D Retrieve the room data pointer and load it into HL.
44108 LD L,E
44109 LD IX,43746 Set a pointer in IX to Table_Directions.
44113 XOR A Set A to 0 which is used just for the comparison.
44114 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 44116 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 44117 INC HL Move to the next byte of room data.
44118 INC IX Increment the direction name table pointer by two.
44120 INC IX
RoomCheckForExits 44122 CP (HL) Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit.
44123 JR Z,RoomCheckForExits_Loop
44125 EX DE,HL Temporarily store the room data pointer in DE.
44126 LD L,(IX+0) Get the direction name from the direction name table.
44129 LD H,(IX+1)
44132 CALL PrintString Call PrintString to print the direction name.
44135 DEC C Decrease the valid exits count by one.
44136 LD A,C Jump to RoomExits_PrintFullStop if there are no more exits to process.
44137 CP 1
44139 JR C,RoomExits_PrintFullStop
44141 JR Z,RoomExits_PrintAmpersand Jump to RoomExits_PrintAmpersand if there is only one exit left to process.
Print a comma character: ",".
44143 LD A,44 A=44.
44145 CALL PrintCharacter Call PrintCharacter.
44148 XOR A Reset A back to 0 for the comparison.
44149 JR RoomExits_Initialise Jump back to RoomExits_Initialise to continue processing.
Print " & ".
RoomExits_PrintAmpersand 44151 LD HL,43155 HL=Messaging_Ampersand.
44154 CALL PrintString Call PrintString.
44157 XOR A Reset A back to 0 for the comparison.
44158 JR RoomExits_Initialise Jump to RoomExits_Initialise to continue processing.
Print ".".
RoomExits_PrintFullStop 44160 LD HL,43541 HL=Messaging_FullStop.
44163 CALL PrintStringAndNewline Call PrintStringAndNewline.
Are there any objects here?
RoomExits_YouCanSee 44166 LD A,(42947) A=*CurrentRoom.
44169 CALL CheckRoomObjects Call CheckRoomObjects.
44172 RET NZ Return if no objects were found at this location.
Print " You can see:-".
44173 LD HL,43140 HL=Messaging_YouCanSee.
44176 CALL PrintStringAndNewline Call PrintStringAndNewline.
Print the objects at this location.
44179 LD A,(42947) A=*CurrentRoom.
44182 CALL PrintObjects Call PrintObjects.
44185 RET Return.
Prev: 43958 Up: Map Next: 44186