Prev: 50071 Up: Map Next: 50226
50084: 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 176 to 224, 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 64 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 50084 LD A,(23491) Fetch the flag that says the final animation has started from FinalAnimationFlag.
50087 AND A Test it.
50088 RET NZ Return if the final animation has started.
50089 LD A,(IX+26) Fetch the pixel X coordinate of the sun/moon.
50092 CP 225 Jump to DisplaySunMoonFrame_Toggle if the sun/moon has got there.
50094 JR Z,DisplaySunMoonFrame_Toggle
50096 LD A,(IX+26) Fetch the pixel X coordinate.
50099 ADD A,16 Add 16 to it.
50101 LD HL,50240 Point HL at SunMoonHeights.
50104 RRCA Divide the number by four.
50105 RRCA
50106 AND %00001111 Keep the lowest four bits.
50108 CALL AddAToHL Find the address of the height.
50111 LD A,(HL) Fetch the height.
50112 LD (IX+27),A Set the pixel Y coordinate of the sun/moon.
Draw the window in the screen buffer, wiping what was there first.
DisplaySunMoonFrame_Draw 50115 LD BC,7942 Set the number of lines to 31 and the number of bytes to 6.
50118 LD HL,55562 Point HL at ScreenBuffer_SunMoonWindow.
50121 PUSH BC Stash the size of the window on the stack.
50122 PUSH HL Stash the position of the window on the stack.
50123 LD A,C Swap B and C, so that B is the width and C is the height.
50124 LD C,B
50125 LD B,A
50126 XOR A Clear A.
50127 CALL FillWindow Clear the window.
50130 CALL PrintSprite Draw the sun/moon.
50133 LD IX,49115 Point IX at PanelObject.
50137 LD (IX+7),0 Clear the flags.
50141 LD (IX+0),90 Set the graphic number to the left of the frame.
50145 LD (IX+26),184 Set the pixel X coordinate to 184.
50149 LD (IX+27),0 Set the pixel Y coordinate to 0.
50153 CALL PrintSprite Draw the left of the frame.
50156 LD (IX+26),208 Set the pixel X coordinate to 208.
50160 LD (IX+0),186 Set the graphic number to the right of the frame.
50164 CALL PrintSprite Draw the right of the frame.
50167 POP HL Restore the position of the window from the stack.
50168 POP BC Restore the size of the window from the stack.
50169 LD DE,22519 Point DE at the position of the window on the display.
50172 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 50175 LD A,(IX+0) Fetch the graphic number of the sun/moon.
50178 XOR %00000001 Change the sun to the moon, or the moon to the sun.
50180 LD (IX+0),A Set the graphic number of the sun/moon.
50183 CALL ColourSunMoon Colour the sun/moon.
50186 LD (IX+26),176 Set the pixel X coordinate of the sun/moon back to the start.
50190 LD A,1 Get the value that sets a flag.
50192 LD (23473),A Flag that the player has to transform at TransformFlag.
50195 LD A,(50253) Fetch the graphic number of the sun/moon from SunMoonObject.
50198 AND %00000001 Keep the lowest bit.
50200 RET NZ Return if it is the moon.
DisplaySunMoonFrame_AddDay 50201 LD HL,23481 Point HL at Days.
50204 LD A,(HL) Fetch it.
50205 ADD A,1 Add one.
50207 DAA Keep it as a BCD number.
50208 LD (HL),A Store it.
50209 CP 64 Jump to GameOver if they have all gone.
50211 JP Z,GameOver
50214 CALL PrintDays Print the number of days.
50217 LD BC,120 Set the position of the days on the panel.
50220 CALL CopyAreaToScreen Copy the number of days from the screen buffer to the display.
50223 JP DisplaySunMoonFrame_Draw Jump to DisplaySunMoonFrame_Draw.
Prev: 50071 Up: Map Next: 50226