![]()  | 
Routines | 
| Prev: 49694 | Up: Map | Next: 49922 | 
| 
 
Used by the routine at Handler_DisplayRoomImage.
 
Handles displaying the exits available for the current room.
 
 | 
||||
| Handler_RoomExits | 49770 | CALL ClearScreen | Call ClearScreen. | |
| 49773 | LD A,24 | Set up the printing position. | ||
| 49775 | CALL Print_RoomDescription | |||
| 49778 | CALL GetRoomPointer | Call GetRoomPointer which loads HL with the room data pointer. | ||
| 49781 | LD D,H | Store this in DE for later. | ||
| 49782 | LD E,L | |||
| 
 
Count the number of exits in the room data.
 
 | 
||||
| 49783 | LD B,6 | Set an "exits" counter in B of 6. | ||
| 49785 | LD C,0 | Initialise C to 0 to count the number of valid exits. | ||
| 49787 | XOR A | Set A to 0 which is used just for the comparison. | ||
| RoomExitsCount_Loop | 49788 | CP (HL) | Does this room have an exit? | |
| 49789 | JR Z,RoomExitsCount_Skip | Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position. | ||
| 49791 | INC C | Increment the valid exits count by one. | ||
| RoomExitsCount_Skip | 49792 | INC HL | Move to the next byte of room data. | |
| 49793 | 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.
 
 | 
||||
| 49795 | OR C | Jump to RoomExits_YouCanSee if no exits were found. | ||
| 49796 | JR Z,RoomExits_YouCanSee | |||
| 49798 | LD A,C | Jump to RoomMultipleExits if more than 1 exit was found. | ||
| 49799 | CP 1 | |||
| 49801 | JR NZ,RoomMultipleExits | |||
| 
 
Only one exit was found:
 
Print "
There is an exit ".
 
 | 
||||
| 49803 | LD HL,48620 | HL=Messaging_ThereIsAnExit. | ||
| 49806 | CALL PrintString | Call PrintString. | ||
| 49809 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
| 49810 | LD L,E | |||
| 49811 | LD IX,49122 | Set a pointer in IX to Table_Directions. | ||
| 49815 | XOR A | Set A to 0 which is used just for the comparison. | ||
| 49816 | 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 | 49818 | INC HL | Move to the next byte of room data. | |
| 49819 | INC IX | Increment the direction name table pointer by two. | ||
| 49821 | INC IX | |||
| RoomCheckForExit | 49823 | CP (HL) | Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit. | |
| 49824 | JR Z,RoomCheckForExit_Loop | |||
| 49826 | LD L,(IX+0) | Get the direction name from the direction name table. | ||
| 49829 | LD H,(IX+1) | |||
| 49832 | CALL PrintString | Call PrintString to print the direction name. | ||
| 49835 | JR RoomExits_PrintFullStop | Jump to RoomExits_PrintFullStop. | ||
| 
 
More than one exit was found:
 
Print "
There are exits:-".
 
 | 
||||
| RoomMultipleExits | 49837 | LD HL,48601 | HL=Messaging_ThereAreExits. | |
| 49840 | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
| 49843 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
| 49844 | LD L,E | |||
| 49845 | LD IX,49122 | Set a pointer in IX to Table_Directions. | ||
| 49849 | XOR A | Set A to 0 which is used just for the comparison. | ||
| 49850 | 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 | 49852 | 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 | 49853 | INC HL | Move to the next byte of room data. | |
| 49854 | INC IX | Increment the direction name table pointer by two. | ||
| 49856 | INC IX | |||
| RoomCheckForExits | 49858 | CP (HL) | Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit. | |
| 49859 | JR Z,RoomCheckForExits_Loop | |||
| 49861 | EX DE,HL | Temporarily store the room data pointer in DE. | ||
| 49862 | LD L,(IX+0) | Get the direction name from the direction name table. | ||
| 49865 | LD H,(IX+1) | |||
| 49868 | CALL PrintString | Call PrintString to print the direction name. | ||
| 49871 | DEC C | Decrease the valid exits count by one. | ||
| 49872 | LD A,C | Jump to RoomExits_PrintFullStop if there are no more exits to process. | ||
| 49873 | CP 1 | |||
| 49875 | JR C,RoomExits_PrintFullStop | |||
| 49877 | JR Z,RoomExits_PrintAmpersand | Jump to RoomExits_PrintAmpersand if there is only one exit left to process. | ||
| 
 
Print a comma character: " 
,".
 | 
||||
| 49879 | LD A,44 | A=44. | ||
| 49881 | CALL PrintCharacter | Call PrintCharacter. | ||
| 49884 | XOR A | Reset A back to 0 for the comparison. | ||
| 49885 | JR RoomExits_Initialise | Jump back to RoomExits_Initialise to continue processing. | ||
| 
 
Print " & ".
 
 | 
||||
| RoomExits_PrintAmpersand | 49887 | LD HL,48597 | HL=Messaging_Ampersand. | |
| 49890 | CALL PrintString | Call PrintString. | ||
| 49893 | XOR A | Reset A back to 0 for the comparison. | ||
| 49894 | JR RoomExits_Initialise | Jump to RoomExits_Initialise to continue processing. | ||
| 
 
Print ".".
 
 | 
||||
| RoomExits_PrintFullStop | 49896 | LD HL,48937 | HL=Messaging_FullStop. | |
| 49899 | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
| 
 
Are there any objects here?
 
 | 
||||
| RoomExits_YouCanSee | 49902 | LD A,(48331) | A=*CurrentRoom. | |
| 49905 | CALL CheckRoomObjects | Call CheckRoomObjects. | ||
| 49908 | RET NZ | Return if no objects were found at this location. | ||
| 
 
Print "
You can see:-".
 
 | 
||||
| 49909 | LD HL,48582 | HL=Messaging_YouCanSee. | ||
| 49912 | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
| 
 
Print the objects at this location.
 
 | 
||||
| 49915 | LD A,(48331) | A=*CurrentRoom. | ||
| 49918 | CALL PrintObjects | Call PrintObjects. | ||
| 49921 | RET | Return. | ||
| Prev: 49694 | Up: Map | Next: 49922 |