Prev: C397 Up: Map Next: C432
C3A4: Display Sun Moon Frame
Used by the routine at RunGame.
Shows the window of the panel that holds the sun or the moon, and the sun or moon in it. The sun and the moon go along an arc from pixel X coordinate B0 to E0, which is the height from the table at SunMoonHeights. When one of them gets to the end the other takes over, the player transforms, and each time the sun comes back a day is added and the day is shown on the panel. When 40 days have passed the game is over. Nothing is done when the final animation is under way.
Input
IX Address of the sun/moon object
DisplaySunMoonFrame C3A4 LD A,($5BC3) Fetch the flag that says the final animation has started from FinalAnimationFlag.
C3A7 AND A Test it.
C3A8 RET NZ Return if the final animation has started.
C3A9 LD A,(IX+$1A) Fetch the pixel X coordinate of the sun/moon.
C3AC CP $E1 Jump to DisplaySunMoonFrame_Toggle if the sun/moon has got there.
C3AE JR Z,DisplaySunMoonFrame_Toggle
C3B0 LD A,(IX+$1A) Fetch the pixel X coordinate.
C3B3 ADD A,$10 Add 10 to it.
C3B5 LD HL,$C440 Point HL at SunMoonHeights.
C3B8 RRCA Divide the number by four.
C3B9 RRCA
C3BA AND %00001111 Keep the lowest four bits.
C3BC CALL AddAToHL Find the address of the height.
C3BF LD A,(HL) Fetch the height.
C3C0 LD (IX+$1B),A Set the pixel Y coordinate of the sun/moon.
Draw the window in the screen buffer, wiping what was there first.
DisplaySunMoonFrame_Draw C3C3 LD BC,$1F06 Set the number of lines to 1F and the number of bytes to 06.
C3C6 LD HL,$D90A Point HL at ScreenBuffer_SunMoonWindow.
C3C9 PUSH BC Stash the size of the window on the stack.
C3CA PUSH HL Stash the position of the window on the stack.
C3CB LD A,C Swap B and C, so that B is the width and C is the height.
C3CC LD C,B
C3CD LD B,A
C3CE XOR A Clear A.
C3CF CALL FillWindow Clear the window.
C3D2 CALL PrintSprite Draw the sun/moon.
C3D5 LD IX,$BFDB Point IX at PanelObject.
C3D9 LD (IX+$07),$00 Clear the flags.
C3DD LD (IX+$00),$5A Set the graphic number to the left of the frame.
C3E1 LD (IX+$1A),$B8 Set the pixel X coordinate to B8.
C3E5 LD (IX+$1B),$00 Set the pixel Y coordinate to 00.
C3E9 CALL PrintSprite Draw the left of the frame.
C3EC LD (IX+$1A),$D0 Set the pixel X coordinate to D0.
C3F0 LD (IX+$00),$BA Set the graphic number to the right of the frame.
C3F4 CALL PrintSprite Draw the right of the frame.
C3F7 POP HL Restore the position of the window from the stack.
C3F8 POP BC Restore the size of the window from the stack.
C3F9 LD DE,$57F7 Point DE at the position of the window on the display.
C3FC JP CopyBlockToScreen Copy the window from the screen buffer to the display.
The sun or the moon has gone round: change to the other one, which makes the player transform. Add a day when it is the sun that is coming back.
DisplaySunMoonFrame_Toggle C3FF LD A,(IX+$00) Fetch the graphic number of the sun/moon.
C402 XOR %00000001 Change the sun to the moon, or the moon to the sun.
C404 LD (IX+$00),A Set the graphic number of the sun/moon.
C407 CALL ColourSunMoon Colour the sun/moon.
C40A LD (IX+$1A),$B0 Set the pixel X coordinate of the sun/moon back to the start.
C40E LD A,$01 Get the value that sets a flag.
C410 LD ($5BB1),A Flag that the player has to transform at TransformFlag.
C413 LD A,($C44D) Fetch the graphic number of the sun/moon from SunMoonObject.
C416 AND %00000001 Keep the lowest bit.
C418 RET NZ Return if it is the moon.
DisplaySunMoonFrame_AddDay C419 LD HL,$5BB9 Point HL at Days.
C41C LD A,(HL) Fetch it.
C41D ADD A,$01 Add one.
C41F DAA Keep it as a BCD number.
C420 LD (HL),A Store it.
C421 CP $40 Jump to GameOver if they have all gone.
C423 JP Z,GameOver
C426 CALL PrintDays Print the number of days.
C429 LD BC,$0078 Set the position of the days on the panel.
C42C CALL CopyAreaToScreen Copy the number of days from the screen buffer to the display.
C42F JP DisplaySunMoonFrame_Draw Jump to DisplaySunMoonFrame_Draw.
Prev: C397 Up: Map Next: C432