![]() |
Routines |
| Prev: 6763 | Up: Map | Next: 6892 |
|
Draw the current location, its exits and the objects that are here.
|
||||
| Handler_DisplayRoom | 678A | PUSH DE | Remember whether the caller asked for the picture. | |
| 678B | CALL ClearScreen | Call ClearScreen to clear the screen. | ||
| 678E | POP DE | Restore that request. | ||
| 678F | LD A,($62CA) | Fetch how many rooms have a picture. | ||
| 6792 | OR A | No room has a picture. | ||
| 6793 | JR Z,Handler_DisplayRoom_Step4 | |||
| 6795 | LD A,($6223) | Fetch the current room. | ||
| 6798 | LD HL,($62CC) | Fetch the list of rooms that have a picture. | ||
| 679B | LD BC,($62CA) | Fetch how many rooms have a picture. | ||
| 679F | CPIR | Find this room in the list of pictures. | ||
| 67A1 | JR NZ,Handler_DisplayRoom_Step4 | This room has no picture. | ||
| 67A3 | LD A,($62CA) | Fetch how many rooms have a picture. | ||
| 67A6 | INC C | Recover this room's slot in the picture list. | ||
| 67A7 | SUB C | |||
| 67A8 | LD C,A | |||
| 67A9 | XOR A | A nonzero request draws the picture even when it has been seen. | ||
| 67AA | OR E | |||
| 67AB | JR NZ,Handler_DisplayRoom_Step2 | Skip the seen-flag test when the picture was requested again. | ||
| 67AD | LD HL,$6213 | Check whether this room's picture has been shown. | ||
| 67B0 | LD A,C | The picture slot selects its seen flag. | ||
| Handler_DisplayRoom_Loop1 | 67B1 | CP $08 | Jump to Handler_DisplayRoom_Step1 when the picture slot is below 08, in this flag byte. | |
| 67B3 | JR C,Handler_DisplayRoom_Step1 | |||
| 67B5 | SUB $08 | Move to the next flag byte while the slot is past this one. | ||
| 67B7 | INC HL | |||
| 67B8 | JR Handler_DisplayRoom_Loop1 | Continue at Handler_DisplayRoom_Loop1 to test the next picture-seen flag. | ||
| Handler_DisplayRoom_Step1 | 67BA | LD B,A | Build the bit that belongs to this picture. | |
| 67BB | INC B | |||
| 67BC | LD D,$00 | |||
| Handler_DisplayRoom_Loop2 | 67BE | RL D | Shift that bit into place. | |
| 67C0 | DJNZ Handler_DisplayRoom_Loop2 | Repeat until the bit lines up with this picture. | ||
| 67C2 | LD A,(HL) | Read the seen flags for these pictures. | ||
| 67C3 | AND D | See whether this picture has already been shown. | ||
| 67C4 | JR NZ,Handler_DisplayRoom_Step4 | Skip the picture when it has already been shown. | ||
| 67C6 | LD A,(HL) | Remember that this picture has now been shown. | ||
| 67C7 | OR D | |||
| 67C8 | LD (HL),A | |||
| Handler_DisplayRoom_Step2 | 67C9 | LD A,$08 | Start the picture on text row 08. | |
| 67CB | LD ($629B),A | |||
| 67CE | LD HL,$620F | The display flags record the room picture. | ||
| 67D1 | SET 0,(HL) | Remember to wait for a key once the picture is drawn. | ||
| 67D3 | LD IX,($62CE) | Fetch the room-picture handlers. | ||
| 67D7 | LD E,C | The picture slot selects its drawing routine. | ||
| 67D8 | CALL GetTableEntry | Call GetTableEntry to look up the table entry. | ||
| Handler_DisplayRoom_Step3 | 67DB | LD DE,$67E0 | Draw the picture, then continue with the room text. | |
| 67DE | PUSH DE | |||
| 67DF | JP (HL) | |||
| Handler_DisplayRoom_Step4 | 67E0 | CALL SetScreenPosition | Call SetScreenPosition to move the cursor to the stored row. | |
| 67E3 | LD A,$18 | Continue the description on text row 18. | ||
| 67E5 | LD ($629B),A | |||
| 67E8 | LD A,($6223) | Fetch the current room. | ||
| 67EB | LD IX,($62D0) | Fetch the room-description table. | ||
| 67EF | LD E,A | The current room selects its description. | ||
| 67F0 | CALL GetTableEntry | Call GetTableEntry to look up the table entry. | ||
| 67F3 | CALL PrintStringAndANewline | Print the room description and start a new line. | ||
| 67F6 | LD HL,$620F | The display flags record a picture waiting for a key. | ||
| 67F9 | BIT 0,(HL) | No picture is waiting for a key. | ||
| 67FB | JR Z,Handler_DisplayRoom_Step5 | |||
| 67FD | RES 0,(HL) | The picture no longer waits for a key. | ||
| 67FF | CALL GetUserInput | Call GetUserInput to wait for a keypress. | ||
| Handler_DisplayRoom_Step5 | 6802 | CALL GetRoomPointer | Call GetRoomPointer to find the exit record. | |
| 6805 | LD D,H | There are six exits to count. | ||
| 6806 | LD E,L | |||
| 6807 | LD B,$06 | |||
| 6809 | LD C,$00 | |||
| 680B | XOR A | A zero byte means that direction is closed. | ||
|
Count the open exits so they can be listed.
|
||||
| Handler_DisplayRoom_Loop3 | 680C | CP (HL) | Count this exit when it is open. | |
| 680D | JR Z,Handler_DisplayRoom_Step6 | |||
| 680F | INC C | |||
| Handler_DisplayRoom_Step6 | 6810 | INC HL | Move on to the next direction. | |
| 6811 | DJNZ Handler_DisplayRoom_Loop3 | |||
| 6813 | OR C | See whether any exit is open. | ||
| 6814 | JR Z,Handler_DisplayRoom_Step12 | Skip the exit list when the room has none. | ||
| 6816 | LD A,C | One open exit uses the singular wording. | ||
| 6817 | CP $01 | More than one open exit uses the plural line. | ||
| 6819 | JR NZ,Handler_DisplayRoom_Step8 | |||
| 681B | LD HL,$6347 | Print There is an exit on the same line. | ||
| 681E | CALL PrintString | |||
| 6821 | LD H,D | Return to the exit record and the direction names. | ||
| 6822 | LD L,E | |||
| 6823 | LD IX,$646D | |||
| 6827 | XOR A | |||
| 6828 | JR Handler_DisplayRoom_Step7 | |||
| Handler_DisplayRoom_Loop4 | 682A | INC HL | Skip a closed exit and its direction name. | |
| 682B | INC IX | |||
| 682D | INC IX | |||
| Handler_DisplayRoom_Step7 | 682F | CP (HL) | Keep skipping while this exit is closed. | |
| 6830 | JR Z,Handler_DisplayRoom_Loop4 | |||
| 6832 | LD L,(IX+$00) | Read the name of this open exit. | ||
| 6835 | LD H,(IX+$01) | |||
| 6838 | CALL PrintString | Call PrintString to print the message. | ||
| 683B | JR Handler_DisplayRoom_Step11 | Continue at Handler_DisplayRoom_Step11 to end the list of exits. | ||
| Handler_DisplayRoom_Step8 | 683D | LD HL,$6334 | Print There are exits:-. | |
| 6840 | CALL PrintStringAndANewline | |||
| 6843 | LD H,D | Return to the exit record and the direction names. | ||
| 6844 | LD L,E | |||
| 6845 | LD IX,$646D | |||
| 6849 | XOR A | |||
| 684A | JR Handler_DisplayRoom_Step9 | |||
| Handler_DisplayRoom_Loop5 | 684C | EX DE,HL | Hold the exit record while the next name is printed. | |
| Handler_DisplayRoom_Loop6 | 684D | INC HL | Skip a closed exit and its direction name. | |
| 684E | INC IX | |||
| 6850 | INC IX | |||
| Handler_DisplayRoom_Step9 | 6852 | CP (HL) | Keep skipping while this exit is closed. | |
| 6853 | JR Z,Handler_DisplayRoom_Loop6 | |||
| 6855 | EX DE,HL | Bring the exit record back after printing a name. | ||
| 6856 | LD L,(IX+$00) | Read the name of this open exit. | ||
| 6859 | LD H,(IX+$01) | |||
| 685C | CALL PrintString | Call PrintString to print the message. | ||
| 685F | DEC C | One fewer exit name remains. | ||
| 6860 | LD A,C | |||
| 6861 | CP $01 | Finish the list when no exit name remains. | ||
| 6863 | JR C,Handler_DisplayRoom_Step11 | |||
| 6865 | JR Z,Handler_DisplayRoom_Step10 | The last remaining exit is joined with "and". | ||
| 6867 | LD A,$2C | Separate these exit names with a comma. | ||
| 6869 | CALL PrintCharacter | Call PrintCharacter to print the character. | ||
| 686C | XOR A | Prepare to test the next exit. | ||
| 686D | JR Handler_DisplayRoom_Loop5 | Continue at Handler_DisplayRoom_Loop5 to name another open exit. | ||
| Handler_DisplayRoom_Step10 | 686F | LD HL,$6330 | Print & on the same line. | |
| 6872 | CALL PrintString | |||
| 6875 | XOR A | Prepare to test the next exit. | ||
| 6876 | JR Handler_DisplayRoom_Loop5 | Continue at Handler_DisplayRoom_Loop5 to name the last open exit. | ||
| Handler_DisplayRoom_Step11 | 6878 | LD HL,$646B | Print .. | |
| 687B | CALL PrintStringAndANewline | |||
| Handler_DisplayRoom_Step12 | 687E | LD A,($6223) | Fetch the current room. | |
| 6881 | CALL IsObjectPresent | Call IsObjectPresent to see whether anything is in the room. | ||
| 6884 | RET NZ | Return when the room is empty. | ||
| 6885 | LD HL,$6321 | Print You can see:-. | ||
| 6888 | CALL PrintStringAndANewline | |||
| 688B | LD A,($6223) | Fetch the current room. | ||
| 688E | CALL PrintObjects | Call PrintObjects to list the objects here. | ||
| 6891 | RET | Return. | ||
| Prev: 6763 | Up: Map | Next: 6892 |