![]() |
Routines |
Prev: 41748 | Up: Map | Next: 42012 |
Handles displaying the exits available for the current room.
|
||||
Handler_RoomExits | 41786 | PUSH IX | Stash IX, HL, DE and BC on the stack. | |
41788 | PUSH HL | |||
41789 | PUSH DE | |||
41790 | PUSH BC | |||
41791 | LD A,(48077) | Jump to Handler_RoomExits_1 if *Count_RoomsWithImages is set to zero. | ||
41794 | OR A | |||
41795 | JR Z,Handler_RoomExits_1 | |||
The version of the game being played DOES have graphics, so continue.
|
||||
41797 | LD A,(41222) | Fetch *CurrentRoom and load it into A. | ||
41800 | LD HL,48019 | Fetch the address of the table from Table_RoomsWithImages. | ||
41803 | LD BC,(48077) | Fetch the count of the number of rooms in the table from *Count_RoomsWithImages. | ||
41807 | CPIR | Search to see if the current room ID is in the table. | ||
41809 | 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.
|
||||
41811 | LD A,(48077) | Calculate the index of the current room in the table. | ||
41814 | INC C | |||
41815 | SUB C | |||
41816 | LD B,A | |||
41817 | XOR A | A=0. | ||
41818 | OR E | Set the bits from E. | ||
41819 | JR NZ,Handler_RoomExits_0 | Jump to Handler_RoomExits_0 if C is not equal to E. | ||
41821 | LD HL,41128 | HL=41128. | ||
41824 | LD A,B | A=B. | ||
41825 | CALL 41396 | Call 41396. | ||
41828 | LD C,A | C=A. | ||
41829 | AND (HL) | Merge the bits from *HL. | ||
41830 | JR NZ,Handler_RoomExits_1 | Jump to Handler_RoomExits_1 if C is not equal to *HL. | ||
41832 | LD A,(HL) | A=*HL. | ||
41833 | OR C | Set the bits from C. | ||
41834 | LD (HL),A | Write A to *HL. | ||
Handler_RoomExits_0 | 41835 | CALL ClearLines | Call ClearLines. | |
41838 | LD HL,48038 | HL=48038. | ||
41841 | LD E,B | E=B. | ||
41842 | LD D,0 | D=0. | ||
41844 | ADD HL,DE | HL+=DE. | ||
41845 | LD A,(HL) | A=*HL. | ||
41846 | CALL Handler_Images | Call Handler_Images. | ||
Handler_RoomExits_1 | 41849 | CALL ClearLines | Call ClearLines. | |
41852 | CALL SetDefaultScreenPosition | Call SetDefaultScreenPosition. | ||
41855 | CALL 42031 | Call 42031. | ||
41858 | CALL GetRoomPointer | Call GetRoomPointer. | ||
41861 | LD D,H | Store this in DE for later. | ||
41862 | LD E,L | |||
Count the number of exits in the room data.
|
||||
41863 | LD B,6 | Set an "exits" counter in B of 6. | ||
41865 | LD C,0 | Initialise C to 0 to count the number of valid exits. | ||
41867 | XOR A | Set A to 0 which is used just for the comparison. | ||
RoomExitsCount_Loop | 41868 | CP (HL) | Does this room have an exit? | |
41869 | JR Z,RoomExitsCount_Skip | Jump to RoomExitsCount_Skip if this room doesn't have an exit for this position. | ||
41871 | INC C | Increment the valid exits count by one. | ||
RoomExitsCount_Skip | 41872 | INC HL | Move to the next byte of room data. | |
41873 | 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.
|
||||
41875 | OR C | Jump to RoomExits_YouCanSee if no exits were found | ||
41876 | JR Z,RoomExits_YouCanSee | |||
41878 | LD A,C | Jump to RoomMultipleExits if more than 1 exit was found. | ||
41879 | CP 1 | |||
41881 | JR NZ,RoomMultipleExits | |||
Only one exit was found:
Print " There is an exit ".
|
||||
41883 | LD HL,7 | HL=Messaging_ThereIsAnExit. | ||
41886 | CALL PrintCompressedString | Call PrintCompressedString. | ||
41889 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
41890 | LD L,E | |||
41891 | LD IX,41289 | Set a pointer in IX to Table_Directions. | ||
41895 | XOR A | Set A to 0 which is used just for the comparison. | ||
41896 | 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 | 41898 | INC HL | Move to the next byte of room data. | |
41899 | INC IX | Increment the direction name table pointer by two. | ||
41901 | INC IX | |||
RoomCheckForExit | 41903 | CP (HL) | Jump to RoomCheckForExit_Loop if the current exit isn't a valid exit. | |
41904 | JR Z,RoomCheckForExit_Loop | |||
41906 | LD L,(IX+0) | Get the direction name from the direction name table. | ||
41909 | LD H,(IX+1) | |||
41912 | CALL PrintCompressedString | Call PrintCompressedString to print the direction name. | ||
41915 | JR RoomExits_PrintFullStop | Jump to RoomExits_PrintFullStop. | ||
More than one exit was found:
Print " There are exits:-".
|
||||
RoomMultipleExits | 41917 | LD HL,6 | HL=Messaging_ThereAreExits. | |
41920 | CALL PrintCompressedStringAndNewline | Call PrintCompressedStringAndNewline. | ||
41923 | LD H,D | Retrieve the room data pointer and load it into HL. | ||
41924 | LD L,E | |||
41925 | LD IX,41289 | Set a pointer in IX to Table_Directions. | ||
41929 | XOR A | Set A to 0 which is used just for the comparison. | ||
41930 | 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 | 41932 | EX DE,HL | Switch back the DE and HL registers. | |
RoomCheckForExits_Loop | 41933 | INC HL | Move to the next byte of room data. | |
41934 | INC IX | Increment the direction name table pointer by two. | ||
41936 | INC IX | |||
RoomCheckForExits | 41938 | CP (HL) | Jump to RoomCheckForExits_Loop if the current exit isn't a valid exit. | |
41939 | JR Z,RoomCheckForExits_Loop | |||
41941 | EX DE,HL | Temporarily store the room data pointer in DE. | ||
41942 | LD L,(IX+0) | Get the direction name from the direction name table. | ||
41945 | LD H,(IX+1) | |||
41948 | CALL PrintCompressedString | Call PrintCompressedString to print the direction name. | ||
41951 | DEC C | Decrease the valid exits count by one. | ||
41952 | LD A,C | Jump to RoomExits_PrintFullStop if there are no more exits to process. | ||
41953 | CP 1 | |||
41955 | JR C,RoomExits_PrintFullStop | |||
41957 | JR Z,RoomExits_PrintAmpersand | Jump to RoomExits_PrintAmpersand if there is only one exit left to process. | ||
Print a comma character: ",".
|
||||
41959 | LD A,44 | A=44. | ||
41961 | CALL PrintCharacter | Call PrintCharacter. | ||
41964 | XOR A | Reset A back to 0 for the comparison. | ||
41965 | JR RoomExits_Initialise | Jump to RoomExits_Initialise to continue processing. | ||
Print " & ".
|
||||
RoomExits_PrintAmpersand | 41967 | LD HL,5 | HL=Messaging_Ampersand. | |
41970 | CALL PrintCompressedString | Call PrintCompressedString. | ||
41973 | XOR A | A=0. | ||
41974 | JR RoomExits_Initialise | Jump to RoomExits_Initialise. | ||
Print ".".
|
||||
RoomExits_PrintFullStop | 41976 | LD A,46 | A=46. | |
41978 | CALL PrintCharacter | Call PrintCharacter. | ||
Print a newline.
|
||||
41981 | LD A,13 | A=13. | ||
41983 | CALL PrintCharacter | Call PrintCharacter. | ||
Are there any objects here?
|
||||
RoomExits_YouCanSee | 41986 | LD A,(41222) | A=*CurrentRoom. | |
41989 | CALL CheckRoomObjects | Call CheckRoomObjects. | ||
41992 | JR NZ,RoomExits_Return | Jump to RoomExits_Return if no objects were found at this location. | ||
Print " You can see:-".
|
||||
41994 | LD HL,4 | HL=Messaging_YouCanSee. | ||
41997 | CALL PrintCompressedStringAndNewline | Call PrintCompressedStringAndNewline. | ||
Print the objects at this location.
|
||||
42000 | LD A,(41222) | A=*CurrentRoom. | ||
42003 | CALL PrintObjects | Call PrintObjects. | ||
RoomExits_Return | 42006 | POP BC | Restore BC, DE, HL and IX from the stack. | |
42007 | POP DE | |||
42008 | POP HL | |||
42009 | POP IX | |||
42011 | RET | Return. | ||
View the equivalent code in;
|
Prev: 41748 | Up: Map | Next: 42012 |