![]()  | 
Routines | 
| Prev: A314 | Up: Map | Next: A41C | 
| 
 
Handles displaying the exits available for the current room.
 
 | 
||||
| Handler_RoomExits | A33A | PUSH IX | Stash IX, HL, DE and BC on the stack. | |
| A33C | PUSH HL | |||
| A33D | PUSH DE | |||
| A33E | PUSH BC | |||
| A33F | LD A,($BBCD) | Jump to Handler_RoomExits_1 if *Count_RoomsWithImages is set to zero. | ||
| A342 | OR A | |||
| A343 | JR Z,Handler_RoomExits_1 | |||
| 
 
The version of the game being played DOES have graphics, so continue.
 
 | 
||||
| A345 | LD A,($A106) | Fetch *CurrentRoom and load it into A. | ||
| A348 | LD HL,$BB93 | Fetch the address of the table from Table_RoomsWithImages. | ||
| A34B | LD BC,($BBCD) | Fetch the count of the number of rooms in the table from *Count_RoomsWithImages. | ||
| A34F | CPIR | Search to see if the current room ID is in the table. | ||
| A351 | JR NZ,Handler_RoomExits_1 | Jump to Handler_RoomExits_1 if the current room ID does not appear in the table. | ||
| 
 
The current room does have an image associated with it.
 
 | 
||||
| A353 | LD A,($BBCD) | Calculate the index of the current room in the table. | ||
| A356 | INC C | |||
| A357 | SUB C | |||
| A358 | LD B,A | |||
| A359 | XOR A | A=00. | ||
| A35A | OR E | Set the bits from E. | ||
| A35B | JR NZ,Handler_RoomExits_0 | Jump to Handler_RoomExits_0 if C is not equal to E. | ||
| A35D | LD HL,$A0A8 | HL=A0A8. | ||
| A360 | LD A,B | A=B. | ||
| A361 | CALL $A1B4 | Call A1B4. | ||
| A364 | LD C,A | C=A. | ||
| A365 | AND (HL) | Merge the bits from *HL. | ||
| A366 | JR NZ,Handler_RoomExits_1 | Jump to Handler_RoomExits_1 if C is not equal to *HL. | ||
| A368 | LD A,(HL) | A=*HL. | ||
| A369 | OR C | Set the bits from C. | ||
| A36A | LD (HL),A | Write A to *HL. | ||
| Handler_RoomExits_0 | A36B | CALL ClearLines | Call ClearLines. | |
| A36E | LD HL,$BBA6 | HL=BBA6. | ||
| A371 | LD E,B | E=B. | ||
| A372 | LD D,$00 | D=00. | ||
| A374 | ADD HL,DE | HL+=DE. | ||
| A375 | LD A,(HL) | A=*HL. | ||
| A376 | CALL Handler_Images | Call Handler_Images. | ||
| Handler_RoomExits_1 | A379 | CALL ClearLines | Call ClearLines. | |
| A37C | CALL SetDefaultScreenPosition | Call SetDefaultScreenPosition. | ||
| A37F | CALL $A42F | Call A42F. | ||
| A382 | CALL GetRoomPointer | Call GetRoomPointer. | ||
| A385 | LD D,H | Store this in DE for later. | ||
| A386 | LD E,L | |||
| 
 
Count the number of exits in the room data.
 
 | 
||||
| A387 | LD B,$06 | Set an "exits" counter in B of 06. | ||
| A389 | LD C,$00 | Initialise C to 00 to count the number of valid exits. | ||
| A38B | XOR A | Set A to 00 which is used just for the comparison. | ||
| RoomExitsCount_Loop | A38C | CP (HL) | Does this room have an exit? | |
| A38D | JR Z,RoomExitsCount_Skip | Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position. | ||
| A38F | INC C | Increment the valid exits count by one. | ||
| RoomExitsCount_Skip | A390 | INC HL | Move to the next byte of room data. | |
| A391 | 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.
 
 | 
||||
| A393 | OR C | Jump to RoomExits_YouCanSee if no exits were found | ||
| A394 | JR Z,RoomExits_YouCanSee | |||
| A396 | LD A,C | Jump to RoomMultipleExits if more than 01 exit was found. | ||
| A397 | CP $01 | |||
| A399 | JR NZ,RoomMultipleExits | |||
| 
 
Only one exit was found:
 
Print " There is an exit ".
 
 | 
||||
| A39B | LD HL,$0007 | HL=Messaging_ThereIsAnExit. | ||
| A39E | CALL PrintCompressedString | Call PrintCompressedString. | ||
| A3A1 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
| A3A2 | LD L,E | |||
| A3A3 | LD IX,$A149 | Set a pointer in IX to Table_Directions. | ||
| A3A7 | XOR A | Set A to 00 which is used just for the comparison. | ||
| A3A8 | 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 | A3AA | INC HL | Move to the next byte of room data. | |
| A3AB | INC IX | Increment the direction name table pointer by two. | ||
| A3AD | INC IX | |||
| RoomCheckForExit | A3AF | CP (HL) | Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit. | |
| A3B0 | JR Z,RoomCheckForExit_Loop | |||
| A3B2 | LD L,(IX+$00) | Get the direction name from the direction name table. | ||
| A3B5 | LD H,(IX+$01) | |||
| A3B8 | CALL PrintCompressedString | Call PrintCompressedString to print the direction name. | ||
| A3BB | JR RoomExits_PrintFullStop | Jump to RoomExits_PrintFullStop. | ||
| 
 
More than one exit was found:
 
Print " There are exits:-".
 
 | 
||||
| RoomMultipleExits | A3BD | LD HL,$0006 | HL=Messaging_ThereAreExits. | |
| A3C0 | CALL PrintCompressedStringAndNewline | Call PrintCompressedStringAndNewline. | ||
| A3C3 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
| A3C4 | LD L,E | |||
| A3C5 | LD IX,$A149 | Set a pointer in IX to Table_Directions. | ||
| A3C9 | XOR A | Set A to 00 which is used just for the comparison. | ||
| A3CA | 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 | A3CC | EX DE,HL | Switch back the DE and HL registers. | |
| RoomCheckForExits_Loop | A3CD | INC HL | Move to the next byte of room data. | |
| A3CE | INC IX | Increment the direction name table pointer by two. | ||
| A3D0 | INC IX | |||
| RoomCheckForExits | A3D2 | CP (HL) | Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit. | |
| A3D3 | JR Z,RoomCheckForExits_Loop | |||
| A3D5 | EX DE,HL | Temporarily store the room data pointer in DE. | ||
| A3D6 | LD L,(IX+$00) | Get the direction name from the direction name table. | ||
| A3D9 | LD H,(IX+$01) | |||
| A3DC | CALL PrintCompressedString | Call PrintCompressedString to print the direction name. | ||
| A3DF | DEC C | Decrease the valid exits count by one. | ||
| A3E0 | LD A,C | Jump to RoomExits_PrintFullStop if there are no more exits to process. | ||
| A3E1 | CP $01 | |||
| A3E3 | JR C,RoomExits_PrintFullStop | |||
| A3E5 | JR Z,RoomExits_PrintAmpersand | Jump to RoomExits_PrintAmpersand if there is only one exit left to process. | ||
| 
 
Print a comma character: ",".
 
 | 
||||
| A3E7 | LD A,$2C | A=2C. | ||
| A3E9 | CALL PrintCharacter | Call PrintCharacter. | ||
| A3EC | XOR A | Reset A back to 00 for the comparison. | ||
| A3ED | JR RoomExits_Initialise | Jump to RoomExits_Initialise to continue processing. | ||
| 
 
Print " & ".
 
 | 
||||
| RoomExits_PrintAmpersand | A3EF | LD HL,$0005 | HL=Messaging_Ampersand. | |
| A3F2 | CALL PrintCompressedString | Call PrintCompressedString. | ||
| A3F5 | XOR A | A=00. | ||
| A3F6 | JR RoomExits_Initialise | Jump to RoomExits_Initialise. | ||
| 
 
Print ".".
 
 | 
||||
| RoomExits_PrintFullStop | A3F8 | LD A,$2E | A=2E. | |
| A3FA | CALL PrintCharacter | Call PrintCharacter. | ||
| 
 
Print a newline.
 
 | 
||||
| A3FD | LD A,$0D | A=0D. | ||
| A3FF | CALL PrintCharacter | Call PrintCharacter. | ||
| 
 
Are there any objects here?
 
 | 
||||
| RoomExits_YouCanSee | A402 | LD A,($A106) | A=*CurrentRoom. | |
| A405 | CALL CheckRoomObjects | Call CheckRoomObjects. | ||
| A408 | JR NZ,RoomExits_Return | Jump to RoomExits_Return if no objects were found at this location. | ||
| 
 
Print " You can see:-".
 
 | 
||||
| A40A | LD HL,$0004 | HL=Messaging_YouCanSee. | ||
| A40D | CALL PrintCompressedStringAndNewline | Call PrintCompressedStringAndNewline. | ||
| 
 
Print the objects at this location.
 
 | 
||||
| A410 | LD A,($A106) | A=*CurrentRoom. | ||
| A413 | CALL PrintObjects | Call PrintObjects. | ||
| RoomExits_Return | A416 | POP BC | Restore BC, DE, HL and IX from the stack. | |
| A417 | POP DE | |||
| A418 | POP HL | |||
| A419 | POP IX | |||
| A41B | RET | Return. | ||
| 
 
View the equivalent code in; 
 
 | 
||||
| Prev: A314 | Up: Map | Next: A41C |