![]() |
Routines |
| Prev: 26467 | Up: Map | Next: 26770 |
|
Draw the current location, its exits and the objects that are here.
|
||||
| Handler_DisplayRoom | 26506 | PUSH DE | Remember whether the caller asked for the picture. | |
| 26507 | CALL ClearScreen | Call ClearScreen to clear the screen. | ||
| 26510 | POP DE | Restore that request. | ||
| 26511 | LD A,(25290) | Fetch how many rooms have a picture. | ||
| 26514 | OR A | No room has a picture. | ||
| 26515 | JR Z,Handler_DisplayRoom_Step4 | |||
| 26517 | LD A,(25123) | Fetch the current room. | ||
| 26520 | LD HL,(25292) | Fetch the list of rooms that have a picture. | ||
| 26523 | LD BC,(25290) | Fetch how many rooms have a picture. | ||
| 26527 | CPIR | Find this room in the list of pictures. | ||
| 26529 | JR NZ,Handler_DisplayRoom_Step4 | This room has no picture. | ||
| 26531 | LD A,(25290) | Fetch how many rooms have a picture. | ||
| 26534 | INC C | Recover this room's slot in the picture list. | ||
| 26535 | SUB C | |||
| 26536 | LD C,A | |||
| 26537 | XOR A | A nonzero request draws the picture even when it has been seen. | ||
| 26538 | OR E | |||
| 26539 | JR NZ,Handler_DisplayRoom_Step2 | Skip the seen-flag test when the picture was requested again. | ||
| 26541 | LD HL,25107 | Check whether this room's picture has been shown. | ||
| 26544 | LD A,C | The picture slot selects its seen flag. | ||
| Handler_DisplayRoom_Loop1 | 26545 | CP 8 | Jump to Handler_DisplayRoom_Step1 when the picture slot is below 8, in this flag byte. | |
| 26547 | JR C,Handler_DisplayRoom_Step1 | |||
| 26549 | SUB 8 | Move to the next flag byte while the slot is past this one. | ||
| 26551 | INC HL | |||
| 26552 | JR Handler_DisplayRoom_Loop1 | Continue at Handler_DisplayRoom_Loop1 to test the next picture-seen flag. | ||
| Handler_DisplayRoom_Step1 | 26554 | LD B,A | Build the bit that belongs to this picture. | |
| 26555 | INC B | |||
| 26556 | LD D,0 | |||
| Handler_DisplayRoom_Loop2 | 26558 | RL D | Shift that bit into place. | |
| 26560 | DJNZ Handler_DisplayRoom_Loop2 | Repeat until the bit lines up with this picture. | ||
| 26562 | LD A,(HL) | Read the seen flags for these pictures. | ||
| 26563 | AND D | See whether this picture has already been shown. | ||
| 26564 | JR NZ,Handler_DisplayRoom_Step4 | Skip the picture when it has already been shown. | ||
| 26566 | LD A,(HL) | Remember that this picture has now been shown. | ||
| 26567 | OR D | |||
| 26568 | LD (HL),A | |||
| Handler_DisplayRoom_Step2 | 26569 | LD A,8 | Start the picture on text row 8. | |
| 26571 | LD (25243),A | |||
| 26574 | LD HL,25103 | The display flags record the room picture. | ||
| 26577 | SET 0,(HL) | Remember to wait for a key once the picture is drawn. | ||
| 26579 | LD IX,(25294) | Fetch the room-picture handlers. | ||
| 26583 | LD E,C | The picture slot selects its drawing routine. | ||
| 26584 | CALL GetTableEntry | Call GetTableEntry to look up the table entry. | ||
| Handler_DisplayRoom_Step3 | 26587 | LD DE,26592 | Draw the picture, then continue with the room text. | |
| 26590 | PUSH DE | |||
| 26591 | JP (HL) | |||
| Handler_DisplayRoom_Step4 | 26592 | CALL SetScreenPosition | Call SetScreenPosition to move the cursor to the stored row. | |
| 26595 | LD A,24 | Continue the description on text row 24. | ||
| 26597 | LD (25243),A | |||
| 26600 | LD A,(25123) | Fetch the current room. | ||
| 26603 | LD IX,(25296) | Fetch the room-description table. | ||
| 26607 | LD E,A | The current room selects its description. | ||
| 26608 | CALL GetTableEntry | Call GetTableEntry to look up the table entry. | ||
| 26611 | CALL PrintStringAndANewline | Print the room description and start a new line. | ||
| 26614 | LD HL,25103 | The display flags record a picture waiting for a key. | ||
| 26617 | BIT 0,(HL) | No picture is waiting for a key. | ||
| 26619 | JR Z,Handler_DisplayRoom_Step5 | |||
| 26621 | RES 0,(HL) | The picture no longer waits for a key. | ||
| 26623 | CALL GetUserInput | Call GetUserInput to wait for a keypress. | ||
| Handler_DisplayRoom_Step5 | 26626 | CALL GetRoomPointer | Call GetRoomPointer to find the exit record. | |
| 26629 | LD D,H | There are six exits to count. | ||
| 26630 | LD E,L | |||
| 26631 | LD B,6 | |||
| 26633 | LD C,0 | |||
| 26635 | XOR A | A zero byte means that direction is closed. | ||
|
Count the open exits so they can be listed.
|
||||
| Handler_DisplayRoom_Loop3 | 26636 | CP (HL) | Count this exit when it is open. | |
| 26637 | JR Z,Handler_DisplayRoom_Step6 | |||
| 26639 | INC C | |||
| Handler_DisplayRoom_Step6 | 26640 | INC HL | Move on to the next direction. | |
| 26641 | DJNZ Handler_DisplayRoom_Loop3 | |||
| 26643 | OR C | See whether any exit is open. | ||
| 26644 | JR Z,Handler_DisplayRoom_Step12 | Skip the exit list when the room has none. | ||
| 26646 | LD A,C | One open exit uses the singular wording. | ||
| 26647 | CP 1 | More than one open exit uses the plural line. | ||
| 26649 | JR NZ,Handler_DisplayRoom_Step8 | |||
| 26651 | LD HL,25415 | Print There is an exit on the same line. | ||
| 26654 | CALL PrintString | |||
| 26657 | LD H,D | Return to the exit record and the direction names. | ||
| 26658 | LD L,E | |||
| 26659 | LD IX,25709 | |||
| 26663 | XOR A | |||
| 26664 | JR Handler_DisplayRoom_Step7 | |||
| Handler_DisplayRoom_Loop4 | 26666 | INC HL | Skip a closed exit and its direction name. | |
| 26667 | INC IX | |||
| 26669 | INC IX | |||
| Handler_DisplayRoom_Step7 | 26671 | CP (HL) | Keep skipping while this exit is closed. | |
| 26672 | JR Z,Handler_DisplayRoom_Loop4 | |||
| 26674 | LD L,(IX+0) | Read the name of this open exit. | ||
| 26677 | LD H,(IX+1) | |||
| 26680 | CALL PrintString | Call PrintString to print the message. | ||
| 26683 | JR Handler_DisplayRoom_Step11 | Continue at Handler_DisplayRoom_Step11 to end the list of exits. | ||
| Handler_DisplayRoom_Step8 | 26685 | LD HL,25396 | Print There are exits:-. | |
| 26688 | CALL PrintStringAndANewline | |||
| 26691 | LD H,D | Return to the exit record and the direction names. | ||
| 26692 | LD L,E | |||
| 26693 | LD IX,25709 | |||
| 26697 | XOR A | |||
| 26698 | JR Handler_DisplayRoom_Step9 | |||
| Handler_DisplayRoom_Loop5 | 26700 | EX DE,HL | Hold the exit record while the next name is printed. | |
| Handler_DisplayRoom_Loop6 | 26701 | INC HL | Skip a closed exit and its direction name. | |
| 26702 | INC IX | |||
| 26704 | INC IX | |||
| Handler_DisplayRoom_Step9 | 26706 | CP (HL) | Keep skipping while this exit is closed. | |
| 26707 | JR Z,Handler_DisplayRoom_Loop6 | |||
| 26709 | EX DE,HL | Bring the exit record back after printing a name. | ||
| 26710 | LD L,(IX+0) | Read the name of this open exit. | ||
| 26713 | LD H,(IX+1) | |||
| 26716 | CALL PrintString | Call PrintString to print the message. | ||
| 26719 | DEC C | One fewer exit name remains. | ||
| 26720 | LD A,C | |||
| 26721 | CP 1 | Finish the list when no exit name remains. | ||
| 26723 | JR C,Handler_DisplayRoom_Step11 | |||
| 26725 | JR Z,Handler_DisplayRoom_Step10 | The last remaining exit is joined with "and". | ||
| 26727 | LD A,44 | Separate these exit names with a comma. | ||
| 26729 | CALL PrintCharacter | Call PrintCharacter to print the character. | ||
| 26732 | XOR A | Prepare to test the next exit. | ||
| 26733 | JR Handler_DisplayRoom_Loop5 | Continue at Handler_DisplayRoom_Loop5 to name another open exit. | ||
| Handler_DisplayRoom_Step10 | 26735 | LD HL,25392 | Print & on the same line. | |
| 26738 | CALL PrintString | |||
| 26741 | XOR A | Prepare to test the next exit. | ||
| 26742 | JR Handler_DisplayRoom_Loop5 | Continue at Handler_DisplayRoom_Loop5 to name the last open exit. | ||
| Handler_DisplayRoom_Step11 | 26744 | LD HL,25707 | Print .. | |
| 26747 | CALL PrintStringAndANewline | |||
| Handler_DisplayRoom_Step12 | 26750 | LD A,(25123) | Fetch the current room. | |
| 26753 | CALL IsObjectPresent | Call IsObjectPresent to see whether anything is in the room. | ||
| 26756 | RET NZ | Return when the room is empty. | ||
| 26757 | LD HL,25377 | Print You can see:-. | ||
| 26760 | CALL PrintStringAndANewline | |||
| 26763 | LD A,(25123) | Fetch the current room. | ||
| 26766 | CALL PrintObjects | Call PrintObjects to list the objects here. | ||
| 26769 | RET | Return. | ||
| Prev: 26467 | Up: Map | Next: 26770 |