![]() |
Routines |
| Prev: 5E62 | Up: Map | Next: 5F0C |
|
Used by the routine at RunGame.
Used when all five levels have been completed. It prints the congratulation message over the game window, saves the window and clears it, and then scrolls the saved picture back in underneath the message. After a long pause the message flashes, with a clicking sound which rises in pitch, and the window is scrolled away by WipeViewOut.
|
||||
|
Reset the level number and print the message.
|
||||
| ShowEnding | 5E65 | XOR A | Clear A. | |
| 5E66 | LD ($DEDF),A | Write 00 to LevelNumber, to make the next game start on the first level. | ||
| 5E69 | LD DE,$5E62 | Point DE at the rectangle description at EndingWindow_Fill. | ||
| 5E6C | LD HL,$7730 | Set HL to the position of the bottom left of the game window. | ||
| 5E6F | CALL FillRectangle | Call FillRectangle to blank the attributes of the game window, so the message cannot be seen yet. | ||
| 5E72 | LD DE,$5F0F | Point DE at the message at 5F0F. | ||
| 5E75 | LD B,$07 | Set the number of lines in the message in B to 07. | ||
| 5E77 | CALL PrintTextRecords | Call PrintTextRecords to print the message. | ||
|
Save the picture in the game window into the view buffer, clearing the window as it goes.
|
||||
| 5E7A | LD HL,$0810 | Set HL to the position of the top left of the game window in the view buffer. | ||
| 5E7D | CALL GetBufferAddress | Call GetBufferAddress to find the address in the view buffer. | ||
| 5E80 | EX DE,HL | Move it into DE. | ||
| 5E81 | LD HL,$4026 | Point HL at the top left of the game window on the screen. | ||
| 5E84 | LD C,$70 | Set the scanline counter in C to 70. | ||
| ShowEnding_SaveLine | 5E86 | LD B,$14 | Set the line length in B to 14 bytes. | |
| 5E88 | PUSH HL | Stash the screen address on the stack. | ||
| ShowEnding_SaveByte | 5E89 | LD A,(HL) | Fetch a byte of the screen. | |
| 5E8A | LD (DE),A | Store it in the view buffer. | ||
| 5E8B | LD (HL),$00 | Clear the byte of the screen. | ||
| 5E8D | INC HL | Move onto the next byte of the screen. | ||
| 5E8E | INC DE | Move onto the next byte of the view buffer. | ||
| 5E8F | DJNZ ShowEnding_SaveByte | Decrease the line length by one and loop back to ShowEnding_SaveByte until the whole line has been saved. | ||
| 5E91 | INC DE | Skip the four unused bytes at the end of the line in the view buffer. | ||
| 5E92 | INC DE | |||
| 5E93 | INC DE | |||
| 5E94 | INC DE | |||
| 5E95 | POP HL | Restore the screen address. | ||
| 5E96 | INC H | Move down a scanline. | ||
| 5E97 | LD A,H | Jump to ShowEnding_NextLine unless the new scanline is the start of a new character row. | ||
| 5E98 | AND $07 | |||
| 5E9A | JR NZ,ShowEnding_NextLine | |||
| 5E9C | LD A,L | Move onto the next character row. | ||
| 5E9D | ADD A,$20 | |||
| 5E9F | LD L,A | |||
| 5EA0 | JR C,ShowEnding_NextLine | Jump to ShowEnding_NextLine if the row is still in the same third of the screen. | ||
| 5EA2 | LD A,H | Move into the next third of the screen. | ||
| 5EA3 | SUB $08 | |||
| 5EA5 | LD H,A | |||
| ShowEnding_NextLine | 5EA6 | DEC C | Decrease the scanline counter by one and jump back to ShowEnding_SaveLine until all 70 scanlines have been saved. | |
| 5EA7 | JR NZ,ShowEnding_SaveLine | |||
|
Make the message visible and scroll the saved picture back in.
|
||||
| 5EA9 | LD DE,$5F0C | Point DE at the rectangle description at EndingMessage. | ||
| 5EAC | LD HL,$7730 | Set HL to the position of the bottom left of the game window. | ||
| 5EAF | CALL FillRectangle | Call FillRectangle to make the attributes of the game window bright white. | ||
| 5EB2 | CALL WipeViewIn | Call WipeViewIn to scroll the saved picture into the window. | ||
|
Wait while checking for the pause keys.
|
||||
| 5EB5 | LD B,$02 | Set the number of long waits in B to 02. | ||
| ShowEnding_Wait | 5EB7 | PUSH BC | Stash the long wait counter on the stack. | |
| 5EB8 | LD DE,$0000 | Start the short wait counter in DE at 00. | ||
| ShowEnding_WaitLoop | 5EBB | PUSH DE | Stash the short wait counter on the stack. | |
| 5EBC | CALL PauseGame | Call PauseGame to check for the pause keys. | ||
| 5EBF | POP DE | Restore the short wait counter from the stack. | ||
| 5EC0 | DEC DE | Decrease the short wait counter by one. | ||
| 5EC1 | LD A,D | Jump back to ShowEnding_WaitLoop until the high byte of the counter is zero. | ||
| 5EC2 | OR D | |||
| 5EC3 | JR NZ,ShowEnding_WaitLoop | |||
| 5EC5 | POP BC | Restore the long wait counter from the stack. | ||
| 5EC6 | DJNZ ShowEnding_Wait | Decrease the long wait counter by one and jump back to ShowEnding_Wait until both long waits are over. | ||
|
Flash the message.
|
||||
| 5EC8 | LD B,$18 | Set the flash counter in B to 18. | ||
| 5ECA | LD IY,($5CF1) | Bring back IY from SavedIY. | ||
| ShowEnding_Flash | 5ECE | PUSH BC | Stash the flash counter on the stack. | |
| 5ECF | LD A,B | Copy the flash counter into A. | ||
| 5ED0 | ADD A,A | Multiply it by four... | ||
| 5ED1 | ADD A,A | |||
| 5ED2 | LD ($5EE9),A | ...and store it in the operand of the instruction at 5EE8. | ||
| 5ED5 | LD ($5EFF),A | Store it in the operand of the instruction at 5EFE too. | ||
| 5ED8 | XOR A | Write 00 to the attribute of the rectangle description at EndingMessage. | ||
| 5ED9 | LD ($5F0E),A | |||
|
Hide the message and click.
|
||||
| 5EDC | EI | Enable interrupts. | ||
| 5EDD | HALT | Wait for the next frame. | ||
| 5EDE | DI | Disable interrupts. | ||
| 5EDF | LD HL,$7730 | Set HL to the position of the bottom left of the game window. | ||
| 5EE2 | LD DE,$5F0C | Point DE at the rectangle description at EndingMessage. | ||
| 5EE5 | CALL FillRectangle | Call FillRectangle to make the attributes of the game window black. | ||
| 5EE8 | LD B,$00 | Set the length of the click. | ||
| 5EEA | CALL PlayClick | Call PlayClick to click the speaker. | ||
|
Show the message and click.
|
||||
| 5EED | EI | Enable interrupts. | ||
| 5EEE | HALT | Wait for the next frame. | ||
| 5EEF | DI | Disable interrupts. | ||
| 5EF0 | LD A,$47 | Write 47 to the attribute of the rectangle description at EndingMessage. | ||
| 5EF2 | LD ($5F0E),A | |||
| 5EF5 | LD HL,$7730 | Set HL to the position of the bottom left of the game window. | ||
| 5EF8 | LD DE,$5F0C | Point DE at the rectangle description at EndingMessage. | ||
| 5EFB | CALL FillRectangle | Call FillRectangle to make the attributes of the game window bright white. | ||
| 5EFE | LD B,$00 | Set the length of the click. | ||
| 5F00 | CALL PlayClick | Call PlayClick to click the speaker. | ||
| 5F03 | CALL PauseGame | Call PauseGame to check for the pause keys. | ||
| 5F06 | POP BC | Restore the flash counter from the stack. | ||
| 5F07 | DJNZ ShowEnding_Flash | Decrease the flash counter by one and jump back to ShowEnding_Flash until the message has flashed 18 times. | ||
| 5F09 | JP WipeViewOut | Jump to WipeViewOut to scroll the window away. | ||
| Prev: 5E62 | Up: Map | Next: 5F0C |