![]() |
Routines |
Prev: C21E | Up: Map | Next: C302 |
Used by the routine at Handler_DisplayRoomImage.
Handles displaying the exits available for the current room.
|
||||
Handler_RoomExits | C26A | CALL ClearScreen | Call ClearScreen. | |
C26D | LD A,$18 | Set up the printing position. | ||
C26F | CALL Print_RoomDescription | |||
C272 | CALL GetRoomPointer | Call GetRoomPointer which loads HL with the room data pointer. | ||
C275 | LD D,H | Store this in DE for later. | ||
C276 | LD E,L | |||
Count the number of exits in the room data.
|
||||
C277 | LD B,$06 | Set an "exits" counter in B of 06. | ||
C279 | LD C,$00 | Initialise C to 00 to count the number of valid exits. | ||
C27B | XOR A | Set A to 00 which is used just for the comparison. | ||
RoomExitsCount_Loop | C27C | CP (HL) | Does this room have an exit? | |
C27D | JR Z,RoomExitsCount_Skip | Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position. | ||
C27F | INC C | Increment the valid exits count by one. | ||
RoomExitsCount_Skip | C280 | INC HL | Move to the next byte of room data. | |
C281 | 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.
|
||||
C283 | OR C | Jump to RoomExits_YouCanSee if no exits were found. | ||
C284 | JR Z,RoomExits_YouCanSee | |||
C286 | LD A,C | Jump to RoomMultipleExits if more than 01 exit was found. | ||
C287 | CP $01 | |||
C289 | JR NZ,RoomMultipleExits | |||
Only one exit was found:
Print "
There is an exit ".
|
||||
C28B | LD HL,$BDEC | HL=Messaging_ThereIsAnExit. | ||
C28E | CALL PrintString | Call PrintString. | ||
C291 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
C292 | LD L,E | |||
C293 | LD IX,$BFE2 | Set a pointer in IX to Table_Directions. | ||
C297 | XOR A | Set A to 00 which is used just for the comparison. | ||
C298 | 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 | C29A | INC HL | Move to the next byte of room data. | |
C29B | INC IX | Increment the direction name table pointer by two. | ||
C29D | INC IX | |||
RoomCheckForExit | C29F | CP (HL) | Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit. | |
C2A0 | JR Z,RoomCheckForExit_Loop | |||
C2A2 | LD L,(IX+$00) | Get the direction name from the direction name table. | ||
C2A5 | LD H,(IX+$01) | |||
C2A8 | CALL PrintString | Call PrintString to print the direction name. | ||
C2AB | JR RoomExits_PrintFullStop | Jump to RoomExits_PrintFullStop. | ||
More than one exit was found:
Print "
There are exits:-".
|
||||
RoomMultipleExits | C2AD | LD HL,$BDD9 | HL=Messaging_ThereAreExits. | |
C2B0 | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
C2B3 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
C2B4 | LD L,E | |||
C2B5 | LD IX,$BFE2 | Set a pointer in IX to Table_Directions. | ||
C2B9 | XOR A | Set A to 00 which is used just for the comparison. | ||
C2BA | 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 | C2BC | 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 | C2BD | INC HL | Move to the next byte of room data. | |
C2BE | INC IX | Increment the direction name table pointer by two. | ||
C2C0 | INC IX | |||
RoomCheckForExits | C2C2 | CP (HL) | Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit. | |
C2C3 | JR Z,RoomCheckForExits_Loop | |||
C2C5 | EX DE,HL | Temporarily store the room data pointer in DE. | ||
C2C6 | LD L,(IX+$00) | Get the direction name from the direction name table. | ||
C2C9 | LD H,(IX+$01) | |||
C2CC | CALL PrintString | Call PrintString to print the direction name. | ||
C2CF | DEC C | Decrease the valid exits count by one. | ||
C2D0 | LD A,C | Jump to RoomExits_PrintFullStop if there are no more exits to process. | ||
C2D1 | CP $01 | |||
C2D3 | JR C,RoomExits_PrintFullStop | |||
C2D5 | JR Z,RoomExits_PrintAmpersand | Jump to RoomExits_PrintAmpersand if there is only one exit left to process. | ||
Print a comma character: "
, ".
|
||||
C2D7 | LD A,$2C | A=2C. | ||
C2D9 | CALL PrintCharacter | Call PrintCharacter. | ||
C2DC | XOR A | Reset A back to 00 for the comparison. | ||
C2DD | JR RoomExits_Initialise | Jump back to RoomExits_Initialise to continue processing. | ||
Print " & ".
|
||||
RoomExits_PrintAmpersand | C2DF | LD HL,$BDD5 | HL=Messaging_Ampersand. | |
C2E2 | CALL PrintString | Call PrintString. | ||
C2E5 | XOR A | Reset A back to 00 for the comparison. | ||
C2E6 | JR RoomExits_Initialise | Jump to RoomExits_Initialise to continue processing. | ||
Print ".".
|
||||
RoomExits_PrintFullStop | C2E8 | LD HL,$BF29 | HL=Messaging_FullStop. | |
C2EB | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
Are there any objects here?
|
||||
RoomExits_YouCanSee | C2EE | LD A,($BCCB) | A=*CurrentRoom. | |
C2F1 | CALL CheckRoomObjects | Call CheckRoomObjects. | ||
C2F4 | RET NZ | Return if no objects were found at this location. | ||
Print "
You can see:-".
|
||||
C2F5 | LD HL,$BDC6 | HL=Messaging_YouCanSee. | ||
C2F8 | CALL PrintStringAndNewline | Call PrintStringAndNewline. | ||
Print the objects at this location.
|
||||
C2FB | LD A,($BCCB) | A=*CurrentRoom. | ||
C2FE | CALL PrintObjects | Call PrintObjects. | ||
C301 | RET | Return. |
Prev: C21E | Up: Map | Next: C302 |