![]() |
Routines |
| Prev: 46111 | Up: Map | Next: 46339 |
|
Used by the routine at HandlerDisplayRoomImage.
Print the exits that leave the current room.
|
||||
| HandlerDisplayRoomExits | 46187 | CALL ClearScreen | Call ClearScreen to clear the screen. | |
| 46190 | LD A,24 | Set up the printing position. | ||
| 46192 | CALL PrintRoomDescription | |||
| 46195 | CALL GetRoomPointer | Call GetRoomPointer which loads HL with the room data pointer. | ||
| 46198 | LD D,H | Store this in DE for later. | ||
| 46199 | LD E,L | |||
|
Count the number of exits in the room data.
|
||||
| 46200 | LD B,6 | Set an "exits" counter in B of 6. | ||
| 46202 | LD C,0 | Initialise C to 0 to count the number of valid exits. | ||
| 46204 | XOR A | Set A to 0 which is used just for the comparison. | ||
| RoomExitsCount_Loop | 46205 | CP (HL) | Does this room have an exit? | |
| 46206 | JR Z,RoomExitsCount_Skip | Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position. | ||
| 46208 | INC C | Increment the valid exits count by one. | ||
| RoomExitsCount_Skip | 46209 | INC HL | Move to the next byte of room data. | |
| 46210 | 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.
|
||||
| 46212 | OR C | Jump to RoomExits_YouCanSee if no exits were found. | ||
| 46213 | JR Z,RoomExits_YouCanSee | |||
| 46215 | LD A,C | Jump to RoomMultipleExits if more than 1 exit was found. | ||
| 46216 | CP 1 | |||
| 46218 | JR NZ,RoomMultipleExits | |||
|
Only one exit was found:
|
||||
| 46220 | LD HL,44980 | Print " There is an exit ". | ||
| 46223 | CALL PrintString | |||
| 46226 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
| 46227 | LD L,E | |||
| 46228 | LD IX,45528 | Set a pointer in IX to Table_DirectionNames. | ||
| 46232 | XOR A | Set A to 0 which is used just for the comparison. | ||
| 46233 | 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 | 46235 | INC HL | Move to the next byte of room data. | |
| 46236 | INC IX | Increment the direction name table pointer by two. | ||
| 46238 | INC IX | |||
| RoomCheckForExit | 46240 | CP (HL) | Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit. | |
| 46241 | JR Z,RoomCheckForExit_Loop | |||
| 46243 | LD L,(IX+0) | Get the direction name from the direction name table. | ||
| 46246 | LD H,(IX+1) | |||
| 46249 | CALL PrintString | Call PrintString to print the direction name. | ||
| 46252 | JR RoomExits_PrintFullStop | Finish the exit sentence. | ||
|
More than one exit was found:
|
||||
| RoomMultipleExits | 46254 | LD HL,44961 | Print " There are exits:-" and start a new line. | |
| 46257 | CALL PrintStringAndANewline | |||
| 46260 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
| 46261 | LD L,E | |||
| 46262 | LD IX,45528 | Set a pointer in IX to Table_DirectionNames. | ||
| 46266 | XOR A | Set A to 0 which is used just for the comparison. | ||
| 46267 | 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 | 46269 | 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 | 46270 | INC HL | Move to the next byte of room data. | |
| 46271 | INC IX | Increment the direction name table pointer by two. | ||
| 46273 | INC IX | |||
| RoomCheckForExits | 46275 | CP (HL) | Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit. | |
| 46276 | JR Z,RoomCheckForExits_Loop | |||
| 46278 | EX DE,HL | Temporarily store the room data pointer in DE. | ||
| 46279 | LD L,(IX+0) | Get the direction name from the direction name table. | ||
| 46282 | LD H,(IX+1) | |||
| 46285 | CALL PrintString | Call PrintString to print the direction name. | ||
| 46288 | DEC C | Decrease the valid exits count by one. | ||
| 46289 | LD A,C | Jump to RoomExits_PrintFullStop if there are no more exits to process. | ||
| 46290 | CP 1 | |||
| 46292 | JR C,RoomExits_PrintFullStop | |||
| 46294 | JR Z,RoomExits_PrintAmpersand | Jump to RoomExits_PrintAmpersand if there is only one exit left to process. | ||
|
Print a comma character: "
,".
|
||||
| 46296 | LD A,44 | Print a comma between the exit names. | ||
| 46298 | CALL PrintCharacter | Call PrintCharacter to print the character. | ||
| 46301 | XOR A | Reset A back to 0 for the comparison. | ||
| 46302 | JR RoomExits_Initialise | Jump back to RoomExits_Initialise to continue processing. | ||
| RoomExits_PrintAmpersand | 46304 | LD HL,44957 | Print " & ". | |
| 46307 | CALL PrintString | |||
| 46310 | XOR A | Reset A back to 0 for the comparison. | ||
| 46311 | JR RoomExits_Initialise | Jump to RoomExits_Initialise to continue processing. | ||
| RoomExits_PrintFullStop | 46313 | LD HL,45323 | Print "." and start a new line. | |
| 46316 | CALL PrintStringAndANewline | |||
|
Are there any objects here?
|
||||
| RoomExits_YouCanSee | 46319 | LD A,(44749) | Read the current room into A. | |
| 46322 | CALL CheckRoomObjects | Call CheckRoomObjects to see which objects are in the room. | ||
| 46325 | RET NZ | Return if no objects were found at this location. | ||
| 46326 | LD HL,44942 | Print " You can see:-" and start a new line. | ||
| 46329 | CALL PrintStringAndANewline | |||
|
Print the objects at this location.
|
||||
| 46332 | LD A,(44749) | Read the current room into A. | ||
| 46335 | CALL PrintObjects | Call PrintObjects to list the objects here. | ||
| 46338 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 46111 | Up: Map | Next: 46339 |