![]() |
Routines |
| Prev: 49362 | Up: Map | Next: 49665 |
|
On the first visit, show the picture and the long description, then list what is here and which ways lead out.
|
||||
|
Clear the screen, then show the room picture on a first visit.
|
||||
| Handler_DisplayRoom | 49401 | PUSH DE | Stash DE on the stack. | |
| 49402 | CALL ClearScreen | Call ClearScreen to clear the screen. | ||
| 49405 | POP DE | Restore DE from the stack. | ||
| 49406 | LD A,(47870) | Jump to Handler_DisplayRoom_PrintDescription when room descriptions are switched off. | ||
| 49409 | OR A | |||
| 49410 | JR Z,Handler_DisplayRoom_PrintDescription | |||
| 49412 | LD A,(47771) | Search the picture list for this room. Jump to Handler_DisplayRoom_PrintDescription when it has no picture. | ||
| 49415 | LD HL,(47844) | |||
| 49418 | LD BC,(47870) | |||
| 49422 | CPIR | |||
| 49424 | JR NZ,Handler_DisplayRoom_PrintDescription | |||
| 49426 | LD A,(47870) | Jump to Handler_DisplayRoom_FirstVisit when this visit should show the picture. | ||
| 49429 | INC C | |||
| 49430 | SUB C | |||
| 49431 | LD C,A | |||
| 49432 | XOR A | |||
| 49433 | OR E | |||
| 49434 | JR NZ,Handler_DisplayRoom_FirstVisit | |||
| 49436 | LD HL,47664 | Find this room's visited flag. | ||
| 49439 | LD A,C | |||
| Handler_DisplayRoom_Loop | 49440 | CP 8 | ||
| 49442 | JR C,Handler_DisplayRoom_Next | |||
| 49444 | SUB 8 | This room's flag is in the next flag byte. | ||
| 49446 | INC HL | |||
| 49447 | JR Handler_DisplayRoom_Loop | |||
| Handler_DisplayRoom_Next | 49449 | LD B,A | Turn that bit number into a flag mask. | |
| 49450 | INC B | |||
| 49451 | LD D,0 | |||
| Handler_DisplayRoom_FlagBit | 49453 | RL D | ||
| 49455 | DJNZ Handler_DisplayRoom_FlagBit | |||
| 49457 | LD A,(HL) | Jump to Handler_DisplayRoom_PrintDescription when this room has already been visited. | ||
| 49458 | AND D | |||
| 49459 | JR NZ,Handler_DisplayRoom_PrintDescription | |||
| 49461 | LD A,(HL) | Mark this room as visited. | ||
| 49462 | OR D | |||
| 49463 | LD (HL),A | |||
| Handler_DisplayRoom_FirstVisit | 49464 | LD A,8 | Remember that the long description was shown, and set the text row to 8. | |
| 49466 | LD (47936),A | |||
| 49469 | LD HL,47660 | |||
| 49472 | SET 0,(HL) | |||
| 49474 | LD IX,(47846) | Call GetTableEntry to fetch this room's picture handler. | ||
| 49478 | LD E,C | |||
| 49479 | CALL GetTableEntry | |||
| 49482 | LD DE,49487 | Return to Handler_DisplayRoom_PrintDescription afterwards and jump to that handler. | ||
| 49485 | PUSH DE | |||
| 49486 | JP (HL) | |||
|
Print the room description and work out the exits.
|
||||
| Handler_DisplayRoom_PrintDescription | 49487 | CALL SetScreenPosition | Call SetScreenPosition to move the cursor to the text line stored at LineNumber. | |
| 49490 | LD A,24 | Set the text row to 24, under the picture. | ||
| 49492 | LD (47936),A | |||
| 49495 | LD A,(47771) | Call GetTableEntry to fetch this room's long description. | ||
| 49498 | LD IX,(47848) | |||
| 49502 | LD E,A | |||
| 49503 | CALL GetTableEntry | |||
| 49506 | CALL PrintStringAndNewline | Call PrintStringAndNewline to print the room description and start a new line. | ||
| 49509 | LD HL,47660 | Skip the key-wait unless the long description was just shown. | ||
| 49512 | BIT 0,(HL) | |||
| 49514 | JR Z,Handler_DisplayRoom_ListExits | |||
| 49516 | RES 0,(HL) | Clear that flag and wait for a key. | ||
| 49518 | CALL GetUserInput | |||
|
Count the number of exits in the room data.
|
||||
| Handler_DisplayRoom_ListExits | 49521 | CALL GetRoomPointer | Call GetRoomPointer to fetch this room's six exits. | |
| 49524 | LD D,H | Count how many of the six exits leave this room. | ||
| 49525 | LD E,L | |||
| 49526 | LD B,6 | |||
| 49528 | LD C,0 | |||
| 49530 | XOR A | |||
| Handler_DisplayRoom_CountExits | 49531 | CP (HL) | ||
| 49532 | JR Z,Handler_DisplayRoom_CountNext | |||
| 49534 | INC C | |||
| Handler_DisplayRoom_CountNext | 49535 | INC HL | ||
| 49536 | DJNZ Handler_DisplayRoom_CountExits | |||
| 49538 | OR C | Jump to Handler_DisplayRoom_ListObjects when there are no exits. | ||
| 49539 | JR Z,Handler_DisplayRoom_ListObjects | |||
| 49541 | LD A,C | Jump to Handler_DisplayRoom_ManyExits when more than one exit is open. | ||
| 49542 | CP 1 | |||
| 49544 | JR NZ,Handler_DisplayRoom_ManyExits | |||
| 49546 | LD HL,48060 | Print " There is an exit ". | ||
| 49549 | CALL PrintString | |||
| 49552 | LD H,D | Point back at the exits and the direction names for the one way out. | ||
| 49553 | LD L,E | |||
| 49554 | LD IX,48562 | |||
| 49558 | XOR A | |||
| 49559 | JR Handler_DisplayRoom_OneExit | |||
| Handler_DisplayRoom_SkipClosed | 49561 | INC HL | Skip a closed exit and move on to the next way out. | |
| 49562 | INC IX | |||
| 49564 | INC IX | |||
| Handler_DisplayRoom_OneExit | 49566 | CP (HL) | ||
| 49567 | JR Z,Handler_DisplayRoom_SkipClosed | |||
| 49569 | LD L,(IX+0) | Call PrintString to print the direction name. | ||
| 49572 | LD H,(IX+1) | |||
| 49575 | CALL PrintString | |||
| 49578 | JR Handler_DisplayRoom_FullStop | Jump to Handler_DisplayRoom_FullStop to finish the exit sentence. | ||
| Handler_DisplayRoom_ManyExits | 49580 | LD HL,48041 | Print " There are exits:-". | |
| 49583 | CALL PrintStringAndNewline | |||
| 49586 | LD H,D | Point back at the exits and the direction names. | ||
| 49587 | LD L,E | |||
| 49588 | LD IX,48562 | |||
| 49592 | XOR A | |||
| 49593 | JR Handler_DisplayRoom_ExitOpen | |||
| Handler_DisplayRoom_NextExit | 49595 | EX DE,HL | Exchange the exit list back into HL and step to the next open way out. | |
| Handler_DisplayRoom_StepExit | 49596 | INC HL | ||
| 49597 | INC IX | |||
| 49599 | INC IX | |||
| Handler_DisplayRoom_ExitOpen | 49601 | CP (HL) | ||
| 49602 | JR Z,Handler_DisplayRoom_StepExit | |||
| 49604 | EX DE,HL | Call PrintString to print the direction name. | ||
| 49605 | LD L,(IX+0) | |||
| 49608 | LD H,(IX+1) | |||
| 49611 | CALL PrintString | |||
| 49614 | DEC C | Jump to Handler_DisplayRoom_FullStop when no exits remain. | ||
| 49615 | LD A,C | |||
| 49616 | CP 1 | |||
| 49618 | JR C,Handler_DisplayRoom_FullStop | |||
| 49620 | JR Z,Handler_DisplayRoom_And | Jump to Handler_DisplayRoom_And to join the last exit with "and". | ||
| 49622 | LD A,44 | Print a comma between the exits. | ||
| 49624 | CALL PrintCharacter | |||
| 49627 | XOR A | Jump back to Handler_DisplayRoom_NextExit for the next exit. | ||
| 49628 | JR Handler_DisplayRoom_NextExit | |||
| Handler_DisplayRoom_And | 49630 | LD HL,48037 | Print " & ". | |
| 49633 | CALL PrintString | |||
| 49636 | XOR A | Jump back to Handler_DisplayRoom_NextExit for the next exit. | ||
| 49637 | JR Handler_DisplayRoom_NextExit | |||
| Handler_DisplayRoom_FullStop | 49639 | LD HL,48377 | Print ".". | |
| 49642 | CALL PrintStringAndNewline | |||
|
Are there any objects here?
|
||||
| Handler_DisplayRoom_ListObjects | 49645 | LD A,(47771) | Call IsObjectPresent to see whether this room holds anything. Return when it does not. | |
| 49648 | CALL IsObjectPresent | |||
| 49651 | RET NZ | |||
| 49652 | LD HL,48022 | Print " You can see:-". | ||
| 49655 | CALL PrintStringAndNewline | |||
| 49658 | LD A,(47771) | Call PrintObjects to list what is in this room. | ||
| 49661 | CALL PrintObjects | |||
|
The exits and objects for this room are done.
|
||||
| 49664 | RET | Return. | ||
|
View the equivalent code in;
|
||||
| Prev: 49362 | Up: Map | Next: 49665 |