Prev: 24162 Up: Map Next: 24332
24165: Show Ending
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 24165 XOR A Clear A.
24166 LD (57055),A Write 0 to LevelNumber, to make the next game start on the first level.
24169 LD DE,24162 Point DE at the rectangle description at EndingWindow_Fill.
24172 LD HL,30512 Set HL to the position of the bottom left of the game window.
24175 CALL FillRectangle Call FillRectangle to blank the attributes of the game window, so the message cannot be seen yet.
24178 LD DE,24335 Point DE at the message at 24335.
24181 LD B,7 Set the number of lines in the message in B to 7.
24183 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.
24186 LD HL,2064 Set HL to the position of the top left of the game window in the view buffer.
24189 CALL GetBufferAddress Call GetBufferAddress to find the address in the view buffer.
24192 EX DE,HL Move it into DE.
24193 LD HL,16422 Point HL at the top left of the game window on the screen.
24196 LD C,112 Set the scanline counter in C to 112.
ShowEnding_SaveLine 24198 LD B,20 Set the line length in B to 20 bytes.
24200 PUSH HL Stash the screen address on the stack.
ShowEnding_SaveByte 24201 LD A,(HL) Fetch a byte of the screen.
24202 LD (DE),A Store it in the view buffer.
24203 LD (HL),0 Clear the byte of the screen.
24205 INC HL Move onto the next byte of the screen.
24206 INC DE Move onto the next byte of the view buffer.
24207 DJNZ ShowEnding_SaveByte Decrease the line length by one and loop back to ShowEnding_SaveByte until the whole line has been saved.
24209 INC DE Skip the four unused bytes at the end of the line in the view buffer.
24210 INC DE
24211 INC DE
24212 INC DE
24213 POP HL Restore the screen address.
24214 INC H Move down a scanline.
24215 LD A,H Jump to ShowEnding_NextLine unless the new scanline is the start of a new character row.
24216 AND 7
24218 JR NZ,ShowEnding_NextLine
24220 LD A,L Move onto the next character row.
24221 ADD A,32
24223 LD L,A
24224 JR C,ShowEnding_NextLine Jump to ShowEnding_NextLine if the row is still in the same third of the screen.
24226 LD A,H Move into the next third of the screen.
24227 SUB 8
24229 LD H,A
ShowEnding_NextLine 24230 DEC C Decrease the scanline counter by one and jump back to ShowEnding_SaveLine until all 112 scanlines have been saved.
24231 JR NZ,ShowEnding_SaveLine
Make the message visible and scroll the saved picture back in.
24233 LD DE,24332 Point DE at the rectangle description at EndingMessage.
24236 LD HL,30512 Set HL to the position of the bottom left of the game window.
24239 CALL FillRectangle Call FillRectangle to make the attributes of the game window bright white.
24242 CALL WipeViewIn Call WipeViewIn to scroll the saved picture into the window.
Wait while checking for the pause keys.
24245 LD B,2 Set the number of long waits in B to 2.
ShowEnding_Wait 24247 PUSH BC Stash the long wait counter on the stack.
24248 LD DE,0 Start the short wait counter in DE at 0.
ShowEnding_WaitLoop 24251 PUSH DE Stash the short wait counter on the stack.
24252 CALL PauseGame Call PauseGame to check for the pause keys.
24255 POP DE Restore the short wait counter from the stack.
24256 DEC DE Decrease the short wait counter by one.
24257 LD A,D Jump back to ShowEnding_WaitLoop until the high byte of the counter is zero.
24258 OR D
24259 JR NZ,ShowEnding_WaitLoop
24261 POP BC Restore the long wait counter from the stack.
24262 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.
24264 LD B,24 Set the flash counter in B to 24.
24266 LD IY,(23793) Bring back IY from SavedIY.
ShowEnding_Flash 24270 PUSH BC Stash the flash counter on the stack.
24271 LD A,B Copy the flash counter into A.
24272 ADD A,A Multiply it by four...
24273 ADD A,A
24274 LD (24297),A ...and store it in the operand of the instruction at 24296.
24277 LD (24319),A Store it in the operand of the instruction at 24318 too.
24280 XOR A Write 0 to the attribute of the rectangle description at EndingMessage.
24281 LD (24334),A
Hide the message and click.
24284 EI Enable interrupts.
24285 HALT Wait for the next frame.
24286 DI Disable interrupts.
24287 LD HL,30512 Set HL to the position of the bottom left of the game window.
24290 LD DE,24332 Point DE at the rectangle description at EndingMessage.
24293 CALL FillRectangle Call FillRectangle to make the attributes of the game window black.
24296 LD B,0 Set the length of the click.
24298 CALL PlayClick Call PlayClick to click the speaker.
Show the message and click.
24301 EI Enable interrupts.
24302 HALT Wait for the next frame.
24303 DI Disable interrupts.
24304 LD A,71 Write 71 to the attribute of the rectangle description at EndingMessage.
24306 LD (24334),A
24309 LD HL,30512 Set HL to the position of the bottom left of the game window.
24312 LD DE,24332 Point DE at the rectangle description at EndingMessage.
24315 CALL FillRectangle Call FillRectangle to make the attributes of the game window bright white.
24318 LD B,0 Set the length of the click.
24320 CALL PlayClick Call PlayClick to click the speaker.
24323 CALL PauseGame Call PauseGame to check for the pause keys.
24326 POP BC Restore the flash counter from the stack.
24327 DJNZ ShowEnding_Flash Decrease the flash counter by one and jump back to ShowEnding_Flash until the message has flashed 24 times.
24329 JP WipeViewOut Jump to WipeViewOut to scroll the window away.
Prev: 24162 Up: Map Next: 24332