0000- 5 0000- 6 ; ***************************************************************************** 0000- 7 ; MK14 MoonLander 0000- 8 ; Rev 1.0 7th Dec 2023 0000- 9 ; Developed by Ian Reynolds for the SBASM 8060 assembler 0000- 10 ; Uses the core Moon Lander game from the SoC MK14 manual 0000- 11 ; Graphics version based on an idea by SiriusHardware, Vintage Radio UK forums 0000- 12 ; Thanks to SiriusHardware for the moonscape graphic 0000- 13 ; 0000- 14 ; Requires continuous memory from 0x0200 to 0x07FF and base RAM at 0x0B00 and 0x0F00 0000- 15 ; For correct operation the VDU TOPPAGE signal needs to be connected to PS1, to use 2 pages of video RAM, and 0000- 16 ; connected to VDU Graph_nChar input to generate a top page of characters and lower page of graphics (or visa-versa) 0000- 17 ; The LED display still functions as per the original game 0000- 18 ; 0000- 19 ; Keys: 1 to 7 set the thrust 0000- 20 ; 0 kill motor 0000- 21 ; Any system key to restart the game at any point 0000- 22 ; 0000- 23 ; Comparison of original LED display to new VDU display. Note the information for the 0000- 24 ; increased fidelity is already in the original game - it just needed displaying 0000- 25 ;=====================================================================================! 0000- 26 ;! Feature ! LED Display ! VDU Display ! 0000- 27 ;!------------------------------------------------------------------------------------! 0000- 28 ;! Altitude ! 3 digits. 0-999. 999=touch down ! 4 digits. 0-9999. 0000=touch down ! 0000- 29 ;! Velocity ! 2 digits. Unsigned (absolute) ! 3 digits. Signed. -ve = Ascent ! 0000- 30 ;! Thrust ! Not displayed ! 1 digit. 0-7 ! 0000- 31 ;! Fuel ! 1 digit. 0-5. F=empty ! 2 digits. 0-88. 0=EMPTY ! 0000- 32 ;!------------------------------------------------------------------------------------! 0000- 33 ; 0000- 34 ; Additional features 0000- 35 ; ------------------- 0000- 36 ; Random starting altitude from 600 - 977 0000- 37 ; On touchdown a graphic indicates how good a landing you had: 0000- 38 ; Velocity >=30 = Crash landing; 0000- 39 ; Velocity >=10 and <30 = Hard landing 0000- 40 ; Velocity <10 = Perfect landing 0000- 41 ; Moonscape graphic displayed during game 0000- 42 ; 0000- 43 ; Visit the UK Vintage Radio Forums, Vintage Computers, for updates 0000- 44 ; 0000- 45 ; https://www.vintage-radio.net/ My username is Realtime 0000- 46 ; ***************************************************************************** 0000- 47 0000- 48 ;Game Constants 0200- 49 DISP_CH .EQ 0x0200 ; Start of VDU frame store for characters 0300- 50 DISP_GR .EQ 0x0300 ; Start of VDU frame store for graphics 030A- 51 DISP_LAND .EQ DISP_GR+0x0A ; Position for displaying landing graphic 0400- 52 PROG .EQ 0x0400 ; Start of program memory 07F0- 53 VAR .EQ 0x07F0 ; Variables storage area, separate from the MoonLander core variables at 0x0F05 07FF- 54 PIVIEW_MODE .EQ 0x07FF ; PiView VDU mode control address 0800- 55 INS8154 .EQ 0x0800 ; MK14 I/O chip base address 0B00- 56 MOONSCAPE .EQ 0x0B00 ; Location of moonscape graphic 0F05- 57 ML_VAR .EQ 0xF05 ; Local variable storage for core moon lander routine 0000- 58 0020- 59 Char_Space .EQ 0x20 ; ' ' 0021- 60 Port_B .EQ 0x21 ; INS8154 Port B Output register write address 0000- 61 0000- 62 ; Game Variables ; This list order needs to be maintained as it is cleared as a block during game initialisation 0000- 63 GAME_OVER .EQ 0x00 ; When not zero Game has ended 0001- 64 LAND_TYPE .EQ 0x01 ; Holds the Crash, Hard, Soft landing result 0002- 65 COUNT1 .EQ 0x02 ; General purpose loop counter 0003- 66 P1H .EQ 0x03 ; Temporary store for P1 High 0004- 67 P1L .EQ 0x04 ; Temporary store for P1 Low 0005- 68 P2H .EQ 0x05 ; Temporary store for P2 High 0006- 69 P2L .EQ 0x06 ; Temporary store for P2 Low 0007- 70 P3H .EQ 0x07 ; Temporary store for P3 High 0008- 71 P3L .EQ 0x08 ; Temporary store for P3 Low 0009- 72 FUEL_MSN .EQ 0x09 ; Conversion of binary fuel level to BCD 000A- 73 FUEL_LSN .EQ 0x0A ; Conversion of binary fuel level to BCD 000B- 74 ROD_ABS_H .EQ 0x0B ; Rate Of Descent (Velocity) absolute calculation upper byte 000C- 75 ROD_ABS_L .EQ 0x0C ; Rate Of Descent (Velocity) absolute calculation lower byte 000D- 76 RAND .EQ 0x0D ; Pseudo random number generated by incrementing each cycle of moon lander 0000- 77 0000- 78 0400- 79 .OR PROG 0400- 80 0400- 81 ; Set up INS8154 0400- 82 ; The following is for Realtime's 'Realview' MK14 VDU, using Port B for the control byte 0400- 83 ; Other VDU's may require a different set up byte 0400- 84 ENTRY: 0400-C4 08 85 ( 10) LDI INS8154/256 ; Base address of I/O device 0402-37 86 ( 8) XPAH P3 0403-C4 00 87 ( 10) LDI INS8154\256 0405-33 88 ( 8) XPAL P3 0406-C4 08 89 ( 10) LDI 0x08 0408-CB 23 90 ( 18) ST PORT_B+2(P3) ; Port B output definition register - bit3 (VDUOFF) as output, all others as inputs 040A-C4 FF 91 ( 10) LDI 0xFF ; Set VDU control bits - Enable VDU only. All other controls are via RealView DIP switches 040C-CB 21 92 ( 18) ST Port_B(P3) ; Set port B outputs (Port B is always in basic I/O mode) 040E- 93 ; 040E- 94 ; Port B bit 7 = PS3 - set to '0' \ 040E- 95 ; Port B bit 6 = PS1 - set to '1' \ Sets the video RAM address to 0x0200 040E- 96 ; Port B bit 5 = PS2 - set to '1' / However, note that PS1 must not be physically connected 040E- 97 ; Port B bit 4 = PS4 - set to '0' / to the VDU card as this line is controlled by the TOPPAGE signal 040E- 98 ; Port B bit 3 = VDUOFF - set to '0' for VDU on 040E- 99 ; Port B bit 2 = Graphics/nCharacters - set to '1' to allow TOPPAGE to control the mixed graphic/character display 040E- 100 ; Port B bit 1 = REVPAGES - set to '0' for 0x200 at top of the screen (0x300 at bottom) 040E- 101 ; Port B bit 0 = INVERT - set to '0' for white video on black background 040E- 102 040E- 103 ; Set PiView mode: 0E = text at top, graphics at bottom of display 040E-C4 07 104 ( 10) LDI PIVIEW_MODE/256 ; Base address of I/O device 0410-37 105 ( 8) XPAH P3 0411-C4 FF 106 ( 10) LDI PIVIEW_MODE\256 0413-33 107 ( 8) XPAL P3 0414-C4 0F 108 ( 10) LDI 0x0F ; Set graphics at bottom half of screen, characters at top 0416-CB 00 109 ( 18) ST (P3) 0418- 110 0418- 111 ;================================================ 0418- 112 ; Initialise the display 0418- 113 ; Copy splash screen to the graphics page 0418- 114 ; Fill the character page with space character 0418- 115 ;================================================ 0418- 116 ;Clear screen 0418- 117 SC1: 0418-C4 03 118 ( 10) LDI DISP_GR/256 041A-35 119 ( 8) XPAH P1 041B-C4 00 120 ( 10) LDI DISP_GR\256 041D-31 121 ( 8) XPAL P1 ; P1 now contains start address of graphics display 041E-C4 02 122 ( 10) LDI DISP_CH/256 0420-37 123 ( 8) XPAH P3 0421-C4 00 124 ( 10) LDI DISP_CH\256 0423-33 125 ( 8) XPAL P3 ; P3 now contains start address of character display 0424-C4 0B 126 ( 10) LDI MOONSCAPE/256 0426-36 127 ( 8) XPAH P2 0427-C4 00 128 ( 10) LDI MOONSCAPE\256 0429-32 129 ( 8) XPAL P2 ; P2 points to graphic initialisation data 042A- 130 SC2: 042A-C4 20 131 ( 10) LDI Char_Space 042C-CF 01 132 ( 18) ST @1(P3) ; Clear character location 042E-C6 01 133 ( 18) LD @1(P2) ; get splash screen byte 0430-CD 01 134 ( 18) ST @1(P1) ; store in graphics area 0432-37 135 ( 8) XPAH P3 0433-E4 03 136 ( 10) XRI DISP_CH/256+1 ; XOR to determine if page clear completed 0435-98 05 137 (9/11) JZ SC3 ; If zero then then finished clear screen 0437-E4 03 138 ( 10) XRI DISP_CH/256+1 ; Restore P1_H 0439-37 139 ( 8) XPAH P3 043A-90 EE 140 ( 11) JMP SC2 043C- 141 SC3: 043C-C4 07 142 ( 10) LDI VAR/256 043E-36 143 ( 8) XPAH P2 043F-C4 F0 144 ( 10) LDI VAR\256 0441-32 145 ( 8) XPAL P2 0442- 146 0442-C4 00 147 ( 10) LDI 0x00 0444-CA 00 148 ( 18) ST GAME_OVER(P2) ; 00 is game not over. non-zero is game over 0446- 149 0446- 150 ; Output Title and status display text 0446-C4 04 151 ( 10) LDI Title_text/256 ; Get start address of Title text block 0448-37 152 ( 8) XPAH P3 0449-C4 A3 153 ( 10) LDI Title_text\256 044B-33 154 ( 8) XPAL P3 044C-C4 02 155 ( 10) LDI DISP_CH/256 044E-35 156 ( 8) XPAH P1 044F-C4 10 157 ( 10) LDI DISP_CH\256+0x10 0451-31 158 ( 8) XPAL P1 0452-C4 05 159 ( 10) LDI 0x05 0454-CA 02 160 ( 18) ST COUNT1(P2) ; number of lines of text to output 0456- 161 SC4: 0456-C7 01 162 ( 18) LD @1(P3) ; get character from text string 0458-E4 55 163 ( 10) XRI 0x55 ; 0x55 is EOL 045A-98 06 164 (9/11) JZ SC5 045C-E4 55 165 ( 10) XRI 0x55 ; restore character value 045E-CD 01 166 ( 18) ST @1(P1) ; copy it to screen 0460-90 F4 167 ( 11) JMP SC4 0462- 168 SC5: 0462-BA 02 169 ( 22) DLD COUNT1(P2) 0464-98 09 170 (9/11) JZ Start ; end if count1 is zero 0466-31 171 ( 8) XPAL P1 0467-D4 F0 172 ( 10) ANI 0xF0 0469-02 173 ( 5) CCL 046A-F4 30 174 ( 11) ADI 0x30 046C-31 175 ( 8) XPAL P1 ; move P1 pointer to start of next line on screen 046D-90 E7 176 ( 11) JMP SC4 046F- 177 046F- 178 ;----------- 046F- 179 ; the following block is taken from the Moonlanding main program to free up some space in page 0F00 046F- 180 ;----------- 046F- 181 046F- 182 Start: 046F-C4 07 183 ( 10) LDI VAR/256 0471-36 184 ( 8) XPAH P2 0472-C4 F0 185 ( 10) LDI VAR\256 0474-32 186 ( 8) XPAL P2 0475-C4 0F 187 ( 10) LDI /Init 0477-35 188 ( 8) XPAH 1 0478-C4 14 189 ( 10) LDI #Init 047A-31 190 ( 8) XPAL 1 047B- 191 ;new section to generate random start altitude 047B-C2 0D 192 ( 18) LD RAND(P2) ; get latest 'random' number 047D-D4 03 193 ( 10) ANI 0x03 047F-02 194 ( 5) CCL 0480-F4 06 195 ( 11) ADI 0x06 0482-C9 00 196 ( 18) ST 0(P1) ; Result can be 6, 7, 8, 9 => high byte of altitude constant 0484-C2 0D 197 ( 18) LD RAND(P2) 0486-D4 77 198 ( 10) ANI 0x77 0488-C9 01 199 ( 18) ST 1(P1) ; result can be up to 77 => low byte of altitude constant 048A- 200 048A-C4 0F 201 ( 10) LDI /Ret 048C-36 202 ( 8) XPAH 2 048D-C4 20 203 ( 10) LDI #Ret 048F-32 204 ( 8) XPAL 2 0490-C4 0C 205 ( 10) LDI 12 0492-CA E4 206 ( 18) ST Count(2) 0494- 207 Set: ; copy game defaults to ML_VAR area 0494-C1 0B 208 ( 18) LD +11(1) 0496-CD FF 209 ( 18) ST @-1(1) 0498-BA E4 210 ( 22) DLD Count(2) 049A-9C F8 211 (9/11) JNZ Set 049C- 212 049C- 213 ; jump to main program 049C-C4 0F 37 C4 51 33 3F 214 JS P3,Again 04A3- 215 04A3- 216 ;================================================ 04A3- 217 ; Lines of Text for writing to display. EOL is 0x55 04A3- 218 ;================================================ 04A3-20 0D 0F 0F 0E 20 0C 01 0E 04 05 12 20 16 31 20 55 219 Title_text: .DB 0x20,0xD,0xF,0xF,0xE,0x20,0xC,0x1,0xE,0x4,0x5,0x12,0x20,0x16,0x31,0x20,0x55 ; MOON LANDER V1 04B4-01 0C 14 09 14 15 04 05 20 3D 55 220 .DB 0x1,0xC,0x14,0x9,0x14,0x15,0x4,0x5,0x20,0x3D,0x55 ; ALTITUDE = 04BF-16 05 0C 0F 03 09 14 19 20 3D 20 55 221 .DB 0x16,0x5,0xC,0xF,0x3,0x9,0x14,0x19,0x20,0x3D,0x20,0x55 ; VELOCITY = 04CB-14 08 12 15 13 14 20 20 20 3D 55 222 .DB 0x14,0x8,0x12,0x15,0x13,0x14,0x20,0x20,0x20,0x3D,0x55 ; THRUST = 04D6-06 15 05 0C 20 20 20 20 20 3D 55 223 .DB 0x6,0x15,0x5,0xC,0x20,0x20,0x20,0x20,0x20,0x3D,0x55 ; FUEL = 04E1- 224 ; Crash: .DB 0x3,0x12,0x1,0x13,0x8,0x20,0xC,0x1,0xE,0x4,0x9,0xE,0x7,0x55 ; CRASH LANDING 04E1- 225 ; Hard: .DB 0x8,0x1,0x12,0x4,0x20,0xC,0x1,0xE,0x4,0x9,0xE,0x7,0x55 ; HARD LANDING 04E1- 226 ; Soft: .DB 0x10,0x5,0x12,0x6,0x5,0x3,0x14,0x20,0xC,0x1,0xE,0x4,0x9,0xE,0x7,0x55 ; PERFECT LANDING 04E1- 227 04E1- 228 ;===================================================== 04E1- 229 ; VDU output subroutine 04E1- 230 ; 04E1- 231 ;Altitude ML_VAR+3 = 0xF08 04E1- 232 ;Velocity ML_VAR+6 = 0xF0B ; refered to as Rate of Descent in VDU driver 04E1- 233 ;Acceleration ML_VAR+9 = 0xF0E 04E1- 234 ;Thrust ML_VAR+11= 0xF10 04E1- 235 ;Fuel Left ML_VAR+13= 0xF12 04E1- 236 ; 04E1- 237 ;======================================================== 04E1- 238 VDU: 04E1-C4 07 239 ( 10) LDI VAR/256 ; Local variables pointer 04E3-37 240 ( 8) XPAH P3 ; P3 can be used as it's re-initialised on exit from this subroutine 04E4-C4 F0 241 ( 10) LDI VAR\256 04E6-33 242 ( 8) XPAL P3 04E7- 243 04E7-C3 00 244 ( 18) LD GAME_OVER(P3) 04E9-98 07 245 (9/11) JZ PILOT_DISPLAY 04EB- 246 ; Game over so use p3 for a long jump to return from the VDU handler 04EB-C4 0F 37 C4 58 33 3F 247 JS P3,VDU_RET 04F2- 248 04F2- 249 PILOT_DISPLAY: 04F2-AB 0D 250 ( 22) ILD RAND(P3) ; Increment 'random' number every cycle 04F4- 251 04F4-35 252 ( 8) XPAH P1 ; Temporary store for P1 04F5-CB 03 253 ( 18) ST P1H(P3) 04F7-31 254 ( 8) XPAL P1 04F8-CB 04 255 ( 18) ST P1L(P3) 04FA- 256 04FA-36 257 ( 8) XPAH P2 ; Temporary store for P2 04FB-CB 05 258 ( 18) ST P2H(P3) 04FD-32 259 ( 8) XPAL P2 04FE-CB 06 260 ( 18) ST P2L(P3) 0500- 261 0500-C4 0F 262 ( 10) LDI ML_VAR/256 ; Point to the Moon Lander variables 0502-35 263 ( 8) XPAH P1 0503-C4 05 264 ( 10) LDI ML_VAR\256 0505-31 265 ( 8) XPAL P1 0506- 266 0506-C4 02 267 ( 10) LDI DISP_CH/256 ; Point to the character display area 0508-36 268 ( 8) XPAH P2 0509-C4 5B 269 ( 10) LDI DISP_CH+0x5B\256 050B-32 270 ( 8) XPAL P2 050C-02 271 ( 5) CCL 050D- 272 ALTITUDE: 050D-C4 00 273 ( 10) LDI 0x00 050F-CB 01 274 ( 18) ST LAND_TYPE(P3) 0511-C1 03 275 ( 18) LD 3(P1) ; Altitude variable at ML_VAR+3 - 4 Nibbles, always positive until touchdown 0513-94 46 276 (9/11) JP DISP_ALT ; If negative then display zeros 0515-C4 30 277 ( 10) LDI 0x30 ; display all zeros for altitude 0517-CE 01 278 ( 18) ST @1(P2) 0519-CE 01 279 ( 18) ST @1(P2) 051B-CE 01 280 ( 18) ST @1(P2) 051D-CE 2D 281 ( 18) ST @0x2D(P2) 051F-C2 00 282 ( 18) LD 0(P2) ; Get ROD MSN from screen location. If '-' then good landing, else if non zero then definately a crash 0521-E4 2D 283 ( 10) XRI 0x2D ; is it '-'? 0523-9C 06 284 (9/11) JNZ LAND1 0525-C4 03 285 ( 10) LDI 0x03 ; = Soft landing 0527-CB 01 286 ( 18) ST LAND_TYPE(P3) ; Temp store landing result 0529-90 2E 287 ( 11) JMP LAND_END 052B- 288 LAND1: 052B-C2 00 289 ( 18) LD 0(P2) ; Get ROD MSN from screen location. If '-' then good landing, else if non zero then definately a crash 052D-E4 30 290 ( 10) XRI 0x30 ; is it '0'? 052F-98 06 291 (9/11) JZ LAND1b 0531-C4 01 292 ( 10) LDI 0x01 ; = crash landing 0533-CB 01 293 ( 18) ST LAND_TYPE(P3) ; Temp store landing result 0535-90 22 294 ( 11) JMP LAND_END 0537- 295 LAND1b: 0537-C2 01 296 ( 18) LD 1(P2) ; Get ROD middle digit from screen location. If >2 then crash 0539-02 297 ( 5) CCL 053A-F4 01 298 ( 11) ADI 0x01 ; add 1 to result. 053C-D4 0C 299 ( 10) ANI 0x0C ; If bits 2 or 3 are set result is >3 (i.e. digit >2) 053E-98 06 300 (9/11) JZ LAND2 0540-C4 01 301 ( 10) LDI 0x01 ; = Crash landing 0542-CB 01 302 ( 18) ST LAND_TYPE(P3) ; Temp store landing result 0544-90 13 303 ( 11) JMP LAND_END 0546- 304 LAND2: 0546-C2 01 305 ( 18) LD 1(P2) ; Get ROD middle digit from screen location. If >0 then hard landing 0548-02 306 ( 5) CCL 0549-F4 01 307 ( 11) ADI 0x01 ; add 1 to result. 054B-D4 0E 308 ( 10) ANI 0x0E ; If bits 2,3 or 4 are set then digit is >0 054D-98 06 309 (9/11) JZ LAND3 054F-C4 02 310 ( 10) LDI 0x02 ; = Hard landing 0551-CB 01 311 ( 18) ST LAND_TYPE(P3) ; Temp store landing result 0553-90 04 312 ( 11) JMP LAND_END 0555- 313 LAND3: 0555-C4 03 314 ( 10) LDI 0x03 ; Digit must be 0 so is a soft landing 0557-CB 01 315 ( 18) ST LAND_TYPE(P3) ; Temp store landing result 0559- 316 LAND_END: 0559-90 26 317 ( 11) JMP ROD 055B- 318 DISP_ALT: 055B-1C 319 ( 5) SR ; Shift high nibble right 055C-1C 320 ( 5) SR 055D-1C 321 ( 5) SR 055E-1C 322 ( 5) SR 055F-02 323 ( 5) CCL 0560-F4 30 324 ( 11) ADI 0x30 ; Convert to numeric character 0562-CE 01 325 ( 18) ST @1(P2) ; Write middle nibble to screen 0564-C1 03 326 ( 18) LD 0x03(P1) 0566-D4 0F 327 ( 10) ANI 0x0F ; Mask off lower nibble 0568-02 328 ( 5) CCL 0569-F4 30 329 ( 11) ADI 0x30 ; Convert to numeric character 056B-CE 01 330 ( 18) ST @1(P2) ; Write MS nibble to screen 056D-C1 04 331 ( 18) LD 0x04(P1) ; Split byte into 2 nibbles 056F-1C 332 ( 5) SR ; Shift high nibble right 0570-1C 333 ( 5) SR 0571-1C 334 ( 5) SR 0572-1C 335 ( 5) SR 0573-02 336 ( 5) CCL 0574-F4 30 337 ( 11) ADI 0x30 ; Convert to numeric character 0576-CE 01 338 ( 18) ST @1(P2) ; Write middle nibble to screen 0578-C1 04 339 ( 18) LD 0x04(P1) 057A-D4 0F 340 ( 10) ANI 0x0F ; mask off lower nibble 057C-02 341 ( 5) CCL 057D-F4 30 342 ( 11) ADI 0x30 ; Convert to numeric character 057F-CE 2D 343 ( 18) ST @0x2D(P2) ; Write LS nibble to screen 0581- 344 ; Rate Of Descent 0581- 345 ROD: ; Rate of Descent 6(P1)=MSB, 7(P1)=LSB 0581-C1 07 346 ( 18) LD 0x07(P1) ; Rate of Descent, signed BCD number - 3 nibbles displayed 0583-9C 04 347 (9/11) JNZ NZERO_ROD ; Check if RoD is zero 0585-C1 06 348 ( 18) LD 0x06(P1) 0587-98 04 349 (9/11) JZ ZERO_ROD 0589- 350 NZERO_ROD ; If not zero check if number is negative (bit 7 set) 0589-C1 06 351 ( 18) LD 0x06(P1) 058B-94 34 352 (9/11) JP POS_ROD ; If positive jump to Positive RoD display routine 058D- 353 ZERO_ROD: ; Else convert to a positive number and sign 058D-C1 07 354 ( 18) LD 0x07(P1) ; Convert -ve BCD to positive BCD by 058F-E4 FF 355 ( 10) XRI 0xFF ; complementing, 0591-03 356 ( 5) SCL ; 0592-FC 65 357 ( 12) CAI 0x65 ; subtracting 0x65 and adding zero (requird to complete the calulation) 0594-02 358 ( 5) CCL 0595-EC 00 359 ( 15) DAI 0x00 ; adding zero (requird to properly complete the calulation) 0597-CB 0C 360 ( 18) ST ROD_ABS_L(P3) 0599-C1 06 361 ( 18) LD 0x06(P1) 059B-E4 FF 362 ( 10) XRI 0xFF 059D-FC 65 363 ( 12) CAI 0x65 059F-02 364 ( 5) CCL 05A0-EC 00 365 ( 15) DAI 0x00 05A2-CB 0B 366 ( 18) ST ROD_ABS_H(P3) 05A4-D4 0F 367 ( 10) ANI 0x0F 05A6-02 368 ( 5) CCL 05A7-F4 30 369 ( 11) ADI 0x30 05A9-CE 01 370 ( 18) ST @1(P2) ; display RoD_H lower nibble 05AB-C3 0C 371 ( 18) LD ROD_ABS_L(P3) 05AD-1C 372 ( 5) SR 05AE-1C 373 ( 5) SR 05AF-1C 374 ( 5) SR 05B0-1C 375 ( 5) SR 05B1-02 376 ( 5) CCL 05B2-F4 30 377 ( 11) ADI 0x30 05B4-CE 01 378 ( 18) ST @1(P2) ; display RoD_L upper nibble 05B6-C3 0C 379 ( 18) LD ROD_ABS_L(P3) 05B8-D4 0F 380 ( 10) ANI 0x0F 05BA-02 381 ( 5) CCL 05BB-F4 30 382 ( 11) ADI 0x30 05BD-CE 2E 383 ( 18) ST @0x2E(P2) ; display RoD_L lower nibble 05BF-90 18 384 ( 11) JMP THRUST 05C1- 385 POS_ROD ; descent is a positive number 05C1-C4 2D 386 ( 10) LDI 0x2D ; minus sign output as descent is now ascent (-descent!) 05C3-CE 01 387 ( 18) ST @1(P2) 05C5-C1 07 388 ( 18) LD 0x07(P1) 05C7-1C 389 ( 5) SR 05C8-1C 390 ( 5) SR 05C9-1C 391 ( 5) SR 05CA-1C 392 ( 5) SR 05CB-02 393 ( 5) CCL 05CC-F4 30 394 ( 11) ADI 0x30 05CE-CE 01 395 ( 18) ST @1(P2) ; display RoD upper nibble 05D0-C1 07 396 ( 18) LD 0x07(P1) 05D2-D4 0F 397 ( 10) ANI 0x0F 05D4-02 398 ( 5) CCL 05D5-F4 30 399 ( 11) ADI 0x30 05D7-CE 2E 400 ( 18) ST @0x2E(P2) ; display RoD lower nibble 05D9- 401 THRUST: 05D9-C1 0C 402 ( 18) LD 0x0C(P1) ; Thrust - single nibble always positive 05DB-D4 0F 403 ( 10) ANI 0x0F 05DD-02 404 ( 5) CCL 05DE-F4 30 405 ( 11) ADI 0x30 05E0-CE 30 406 ( 18) ST @0x30(P2) ; display Thrust lower nibble 05E2- 407 FUEL_LEVEL: 05E2-C4 00 408 ( 10) LDI 0x00 05E4-CB 09 409 ( 18) ST FUEL_MSN(P3) 05E6-C1 0D 410 ( 18) LD 0x0D(P1) ;Fuel is binary not BCD so needs converting to 2 BCD digits 05E8-94 16 411 (9/11) JP DIV1 ; If Fuel=-1 then display EMPTY 05EA-C4 05 412 ( 10) LDI 0x05 ; E 05EC-CE 01 413 ( 18) ST @1(P2) 05EE-C4 0D 414 ( 10) LDI 0x0D ; M 05F0-CE 01 415 ( 18) ST @1(P2) 05F2-C4 10 416 ( 10) LDI 0x10 ; P 05F4-CE 01 417 ( 18) ST @1(P2) 05F6-C4 14 418 ( 10) LDI 0x14 ; T 05F8-CE 01 419 ( 18) ST @1(P2) 05FA-C4 19 420 ( 10) LDI 0x19 ; Y 05FC-CE 01 421 ( 18) ST @1(P2) 05FE-90 26 422 ( 11) JMP GAME_END 0600- 423 DIV1: 0600-03 424 ( 5) SCL 0601-FC 0A 425 ( 12) CAI 0x0A 0603-94 07 426 (9/11) JP DIV10 0605-02 427 ( 5) CCL 0606-F4 0A 428 ( 11) ADI 0x0A 0608-CB 0A 429 ( 18) ST FUEL_LSN(P3) ; Store the remainder as the LS nibble 060A-90 06 430 ( 11) JMP DIV20 060C- 431 DIV10: 060C-01 432 ( 7) XAE 060D-AB 09 433 ( 22) ILD FUEL_MSN(P3) ; Count the number of times 10 can be subtracted - Quotient is the MS nibble 060F-01 434 ( 7) XAE 0610-90 EE 435 ( 11) JMP DIV1 0612- 436 DIV20: 0612-C3 09 437 ( 18) LD FUEL_MSN(P3) 0614-02 438 ( 5) CCL 0615-F4 30 439 ( 11) ADI 0x30 0617-CE 01 440 ( 18) ST @1(P2) ; display Fuel upper nibble 0619-C3 0A 441 ( 18) LD FUEL_LSN(P3) 061B-E4 FF 442 ( 10) XRI 0xFF ; if fuel has gone negative, set to zero 061D-98 02 443 (9/11) JZ DIV30 061F-E4 FF 444 ( 10) XRI 0xFF 0621- 445 DIV30: 0621-02 446 ( 5) CCL 0622-F4 30 447 ( 11) ADI 0x30 0624-CE 01 448 ( 18) ST @1(P2) ; display Fuel lower nibble 0626- 449 0626- 450 GAME_END: 0626- 451 ; output landing graphic if appropriate 0626-C3 01 452 ( 18) LD LAND_TYPE(P3) 0628-98 45 453 (9/11) JZ RESTORE ; If zero then ship has not landed 062A-C4 03 454 ( 10) LDI DISP_LAND/256 062C-36 455 ( 8) XPAH P2 062D-C4 0A 456 ( 10) LDI DISP_LAND\256 062F-32 457 ( 8) XPAL P2 ; P2 now contains start address of graphics area 0630-C4 06 458 ( 10) LDI EXG/256 0632-35 459 ( 8) XPAH P1 0633-C4 82 460 ( 10) LDI EXG\256 0635-31 461 ( 8) XPAL P1 0636-C3 01 462 ( 18) LD LAND_TYPE(P3) 0638-E4 01 463 ( 10) XRI 0x01 ; Is it a Crash landing? 063A-9C 02 464 (9/11) JNZ NOT_CRASH 063C-90 0C 465 ( 11) JMP LAND_OUT 063E- 466 NOT_CRASH: 063E-E4 03 467 ( 10) XRI 0x03 ; is it a Hard landing? 0640-9C 04 468 (9/11) JNZ NOT_HARD 0642-C5 78 469 ( 18) LD @0x78(P1) ; Increment P1 to point to HLG graphic 0644-90 04 470 ( 11) JMP LAND_OUT 0646- 471 NOT_HARD: ; must be a soft landing 0646-C5 78 472 ( 18) LD @0x78(P1) 0648-C5 78 473 ( 18) LD @0x78(P1) ; Increment P1 to point to LLG graphic 064A- 474 LAND_OUT 064A-C4 1E 475 ( 10) LDI 0x1E ; Set graphics lines counter 064C-CB 02 476 ( 18) ST COUNT1(P3) 064E-C4 00 477 ( 10) LDI 0x00 0650-01 478 ( 7) XAE ; Set E to 0x00 0651- 479 LAND_OUT2: 0651-C5 01 480 ( 18) LD @1(P1) ; get graphic byte 0653-CE 01 481 ( 18) ST @1(P2) ; copy it to screen 0655-40 482 ( 6) LDE 0656-CA FE 483 ( 18) ST -2(P2) ; Blank byte left of graphic 0658-C5 01 484 ( 18) LD @1(P1) ; get graphic byte 065A-CE 01 485 ( 18) ST @1(P2) ; copy it to screen 065C-40 486 ( 6) LDE 065D-CA 02 487 ( 18) ST 2(P2) ; Blank byte right of graphic 065F-C5 01 488 ( 18) LD @1(P1) ; get graphic byte 0661-CE 01 489 ( 18) ST @1(P2) ; copy it to screen 0663-C5 01 490 ( 18) LD @1(P1) ; get graphic byte 0665-CE 05 491 ( 18) ST @5(P2) ; copy it to screen, increment to next line 0667-BB 02 492 ( 22) DLD COUNT1(P3) 0669-9C E6 493 (9/11) JNZ LAND_OUT2 066B-C4 FF 494 ( 10) LDI 0xFF 066D-CB 00 495 ( 18) ST GAME_OVER(P3) ; Indicate game over 066F- 496 RESTORE: 066F- 497 ; restore all pointers 066F-C3 03 498 ( 18) LD P1H(P3) 0671-35 499 ( 8) XPAH P1 0672-C3 04 500 ( 18) LD P1L(P3) 0674-31 501 ( 8) XPAL P1 0675-C3 05 502 ( 18) LD P2H(P3) 0677-36 503 ( 8) XPAH P2 0678-C3 06 504 ( 18) LD P2L(P3) 067A-32 505 ( 8) XPAL P2 067B- 506 ; Return from VDU handler using p3 for a long jump 067B-C4 0F 37 C4 58 33 3F 507 JS P3,VDU_RET 0682- 508 0682- 509 ;================================================================== 0682- 510 ; Explosion graphic 0682- 511 EXG: 0682-00 00 00 00 40 04 10 0C 20 08 20 18 70 18 70 30 512 .DB 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x10, 0x0C, 0x20, 0x08, 0x20, 0x18, 0x70, 0x18, 0x70, 0x30 0692-18 1C 70 70 1C 3C 71 90 0E 73 9F E0 07 E2 0F E0 513 .DB 0x18, 0x1C, 0x70, 0x70, 0x1C, 0x3C, 0x71, 0x90, 0x0E, 0x73, 0x9F, 0xE0, 0x07, 0xE2, 0x0F, 0xE0 06A2-07 E0 0F E0 02 80 00 70 83 00 00 7C 72 00 00 2E 514 .DB 0x07, 0xE0, 0x0F, 0xE0, 0x02, 0x80, 0x00, 0x70, 0x83, 0x00, 0x00, 0x7C, 0x72, 0x00, 0x00, 0x2E 06B2-1E 1E BC 7C 1A 12 A4 70 0B 1E BC 70 0F 98 A0 E2 515 .DB 0x1E, 0x1E, 0xBC, 0x7C, 0x1A, 0x12, 0xA4, 0x70, 0x0B, 0x1E, 0xBC, 0x70, 0x0F, 0x98, 0xA0, 0xE2 06C2-07 14 A0 7C 0E 12 A0 70 1E 00 00 28 32 00 00 34 516 .DB 0x07, 0x14, 0xA0, 0x7C, 0x0E, 0x12, 0xA0, 0x70, 0x1E, 0x00, 0x00, 0x28, 0x32, 0x00, 0x00, 0x34 06D2-76 00 00 7C 03 86 03 E0 03 FE 06 C0 07 FB 0E 40 517 .DB 0x76, 0x00, 0x00, 0x7C, 0x03, 0x86, 0x03, 0xE0, 0x03, 0xFE, 0x06, 0xC0, 0x07, 0xFB, 0x0E, 0x40 06E2-07 F7 7F E0 0E 3F 3F E0 0C 3D B0 70 1C 18 F0 18 518 .DB 0x07, 0xF7, 0x7F, 0xE0, 0x0E, 0x3F, 0x3F, 0xE0, 0x0C, 0x3D, 0xB0, 0x70, 0x1C, 0x18, 0xF0, 0x18 06F2-70 08 70 1C 40 10 20 04 519 .DB 0x70, 0x08, 0x70, 0x1C, 0x40, 0x10, 0x20, 0x04 06FA- 520 ;================================================================== 06FA- 521 ; Hard landing graphic 06FA- 522 HLG: 06FA-00 00 00 00 00 07 F0 90 00 0E 18 A0 00 14 14 C0 523 .DB 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x90, 0x00, 0x0E, 0x18, 0xA0, 0x00, 0x14, 0x14, 0xC0 070A-00 24 13 F0 00 C4 09 80 01 88 08 40 02 08 08 20 524 .DB 0x00, 0x24, 0x13, 0xF0, 0x00, 0xC4, 0x09, 0x80, 0x01, 0x88, 0x08, 0x40, 0x02, 0x08, 0x08, 0x20 071A-04 0A 84 10 04 12 84 10 04 12 A4 10 04 12 F4 08 525 .DB 0x04, 0x0A, 0x84, 0x10, 0x04, 0x12, 0x84, 0x10, 0x04, 0x12, 0xA4, 0x10, 0x04, 0x12, 0xF4, 0x08 072A-08 12 24 08 08 12 24 08 08 10 04 08 08 7F FF 09 526 .DB 0x08, 0x12, 0x24, 0x08, 0x08, 0x12, 0x24, 0x08, 0x08, 0x10, 0x04, 0x08, 0x08, 0x7F, 0xFF, 0x09 073A-4F 88 08 F8 04 08 08 12 22 0C 18 30 4B 04 10 22 527 .DB 0x4F, 0x88, 0x08, 0xF8, 0x04, 0x08, 0x08, 0x12, 0x22, 0x0C, 0x18, 0x30, 0x4B, 0x04, 0x10, 0x22 074A-01 04 10 40 20 FF FF 88 09 80 00 C2 13 84 14 A2 528 .DB 0x01, 0x04, 0x10, 0x40, 0x20, 0xFF, 0xFF, 0x88, 0x09, 0x80, 0x00, 0xC2, 0x13, 0x84, 0x14, 0xA2 075A-24 90 00 92 08 C3 E1 98 69 7E 3F 08 08 01 40 09 529 .DB 0x24, 0x90, 0x00, 0x92, 0x08, 0xC3, 0xE1, 0x98, 0x69, 0x7E, 0x3F, 0x08, 0x08, 0x01, 0x40, 0x09 076A-09 04 80 48 3D 20 0A 1E 530 .DB 0x09, 0x04, 0x80, 0x48, 0x3D, 0x20, 0x0A, 0x1E 0772- 531 ;================================================================== 0772- 532 ; Lunar Lander graphic 0772- 533 LLG: 0772-00 00 00 00 00 07 F0 00 00 0E 18 00 00 14 14 00 534 .DB 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xF0, 0x00, 0x00, 0x0E, 0x18, 0x00, 0x00, 0x14, 0x14, 0x00 0782-00 24 13 00 00 C4 09 80 01 88 08 40 02 08 08 20 535 .DB 0x00, 0x24, 0x13, 0x00, 0x00, 0xC4, 0x09, 0x80, 0x01, 0x88, 0x08, 0x40, 0x02, 0x08, 0x08, 0x20 0792-04 0A 84 10 04 12 84 10 04 12 A4 10 04 12 F4 08 536 .DB 0x04, 0x0A, 0x84, 0x10, 0x04, 0x12, 0x84, 0x10, 0x04, 0x12, 0xA4, 0x10, 0x04, 0x12, 0xF4, 0x08 07A2-08 12 24 08 08 12 24 08 08 10 04 08 08 7F FF 08 537 .DB 0x08, 0x12, 0x24, 0x08, 0x08, 0x12, 0x24, 0x08, 0x08, 0x10, 0x04, 0x08, 0x08, 0x7F, 0xFF, 0x08 07B2-0F 88 08 F8 04 08 08 10 02 0C 18 30 03 04 10 20 538 .DB 0x0F, 0x88, 0x08, 0xF8, 0x04, 0x08, 0x08, 0x10, 0x02, 0x0C, 0x18, 0x30, 0x03, 0x04, 0x10, 0x20 07C2-01 04 10 40 00 FF FF 80 01 80 00 C0 03 80 00 A0 539 .DB 0x01, 0x04, 0x10, 0x40, 0x00, 0xFF, 0xFF, 0x80, 0x01, 0x80, 0x00, 0xC0, 0x03, 0x80, 0x00, 0xA0 07D2-04 80 00 90 08 C3 E1 88 08 7E 3F 08 08 01 40 08 540 .DB 0x04, 0x80, 0x00, 0x90, 0x08, 0xC3, 0xE1, 0x88, 0x08, 0x7E, 0x3F, 0x08, 0x08, 0x01, 0x40, 0x08 07E2-08 00 80 08 3C 00 00 1E 541 .DB 0x08, 0x00, 0x80, 0x08, 0x3C, 0x00, 0x00, 0x1E 07EA- 542 07EA- 543 ;------------------------------------------------------------------------ 07EA- 544 ; 16 bytes reserved for game variables 07F0- 545 .OR VAR 07F0-00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 546 .DB 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 0800- 547 0800- 548 ;======================================================== 0800- 549 ; Original Moonlander_0f52 here 0800- 550 ; 0800- 551 ; Converted to SBASM by Slothie 2021 0800- 552 ;======================================================== 0800- 553 0800- 554 ;Constants 0005- 555 Grav .EQ 5 ;Force of gravity 0D00- 556 Disp .EQ 0xD00 ;Display address 010B- 557 Crom .EQ 0x10B ;Segment table FFFFFF80- 558 E .EQ -128 ;Extension register as offset 0800- 559 0800- 560 ;**Next 2 lines moved to bottom to eliminate fwd reference 0800- 561 ;Row .EQ Ret-0xF03 ;Ram Offsets 0800- 562 ;Count .EQ Ret-0xF04 0800- 563 ; 0800- 564 ;Variables 0F05- 565 .OR ML_VAR 0F05- 566 .DU 0F05- 567 Save .BS 1 0F06- 568 H1 .BS 1 0F07- 569 L1 .BS 1 0F08- 570 Alt .BS 3 ;Altitude ML_VAR+3 = 0xF08 0F0B- 571 Vel .BS 3 ;Velocity ML_VAR+6 = 0xF0B ; refered to as Rate of Descent in VDU driver 0F0E- 572 Accn .BS 2 ;Acceleration ML_VAR+9 = 0xF0E 0F10- 573 Thr .BS 2 ;Thrust ML_VAR+11= 0xF10 0F12- 574 Fuel .BS 2 ;Fuel Left ML_VAR+13= 0xF12 0F14- 575 .ED 0F14- 576 ; 0F14- 577 ; Initial values 0F14- 578 .OR 0xF14 0F14- 579 Init: 0F14-08 50 00 580 .DB 0x08, 0x50, 0x00 ; Altitude = 850 0F17-99 80 00 581 .DB 0x99, 0x80, 0x00 ; Velocity = -20 0F1A-99 98 582 .DB 0x99, 0x98 ; Acceleration = -2 0F1C-00 02 583 .DB 0x00, 0x02 ; Thrust = 2 0F1E-58 00 584 .DB 0x58, 0x00 ; Fuel = 5.8 0F20- 585 0F20- 586 Ret: 0F20-3E 587 ( 7) XPPC 2 ; P2 contains 0F20 0F21- 588 Displ: 0F21-C8 E3 589 ( 18) ST Save 0F23-C4 01 590 ( 10) LDI /Crom 0F25-35 591 ( 8) XPAH 1 0F26-C8 DF 592 ( 18) ST H1 ; Run out of pointers 0F28-C4 0B 593 ( 10) LDI #Crom 0F2A-31 594 ( 8) XPAL 1 0F2B-C8 DB 595 ( 18) ST L1 0F2D-C0 D7 596 ( 18) LD Save 0F2F-02 597 ( 5) CCL 0F30-D4 0F 598 ( 10) ANI 0x0F 0F32-01 599 ( 7) XAE 0F33- 600 Loop: 0F33-C1 80 601 ( 18) LD E(1) 0F35-CF 01 602 ( 18) ST @+1(3) 0F37-C4 00 603 ( 10) LDI 0 ;Delay point 0F39-8F 01 604 ( 13+) DLY 1 ;Determines speed 0F3B-C0 C9 605 ( 18) LD Save 0F3D-1C 606 ( 5) SR 0F3E-1C 607 ( 5) SR 0F3F-1C 608 ( 5) SR 0F40-1C 609 ( 5) SR 0F41-01 610 ( 7) XAE 0F42-06 611 ( 5) CSA 0F43-03 612 ( 5) SCL 0F44-94 ED 613 (9/11) JP Loop ;Do it twice 0F46-C4 00 614 ( 10) LDI 0 0F48-CF 01 615 ( 18) ST @+1(3) ;Blank between 0F4A-C0 BB 616 ( 18) LD H1 ;Restores P1 0F4C-35 617 ( 8) XPAH 1 0F4D-C0 B9 618 ( 18) LD l1 0F4F-31 619 ( 8) XPAL 1 0F50-90 CE 620 ( 11) JMP Ret ;Return 0F52- 621 0F52- 622 ; Main moon landing program - This section moved to expansion RAM to make space in 0xF00 RAM 0F52- 623 ; Start: 0F52- 624 ; LDI /Init 0F52- 625 ; XPAH 1 0F52- 626 ; LDI #Init 0F52- 627 ; XPAL 1 0F52- 628 ; LDI /Ret 0F52- 629 ; XPAH 2 0F52- 630 ; LDI #Ret 0F52- 631 ; XPAL 2 0F52- 632 ; LDI 12 0F52- 633 ; ST Count(2) 0F52- 634 ; Set: 0F52- 635 ; LD +11(1) 0F52- 636 ; ST @-1(1) 0F52- 637 ; DLD Count(2) 0F52- 638 ; JNZ Set 0F52- 639 ;Main Loop 0F52- 640 Again: 0F52-C4 04 37 C4 E0 33 3F 641 JS P3,VDU ; Output flight parameters to the VDU 0F59- 642 VDU_RET: 0F59-C4 0C 643 ( 10) LDI /Disp-1 0F5B-37 644 ( 8) XPAH 3 0F5C-C4 FF 645 ( 10) LDI #Disp-1 0F5E-33 646 ( 8) XPAL 3 0F5F-C4 01 647 ( 10) LDI 1 0F61-CA E4 648 ( 18) ST Count(2) 0F63-C5 06 649 ( 18) LD @+6(1) ;P1->Vel+2 0F65-94 04 650 (9/11) JP Twice ;Altitude positive? 0F67-C5 04 651 ( 18) LD @+4(1) ;P1->Thr+1 0F69-90 32 652 ( 11) JMP Off ;Don't update 0F6B- 653 Twice: 0F6B-C4 02 654 ( 10) LDI 2 ;Update velocity and 0F6D-CA E3 655 ( 18) ST Row(2) ;Then altitude... 0F6F-02 656 ( 5) CCL 0F70- 657 Dadd: 0F70-C5 FF 658 ( 18) LD @-1(1) 0F72-E9 02 659 ( 23) DAD +2(1) 0F74-C9 00 660 ( 18) ST (1) 0F76-BA E3 661 ( 22) DLD Row(2) 0F78-9C F6 662 (9/11) JNZ Dadd 0F7A-C1 02 663 ( 18) LD +2(1) 0F7C-94 02 664 (9/11) JP Pos ;Gone negative? 0F7E-C4 99 665 ( 10) LDI 0x99 0F80- 666 Pos: 0F80-ED FF 667 ( 23) DAD @-1(1) 0F82-C9 00 668 ( 18) ST (1) 0F84-BA E4 669 ( 22) DLD Count(2) 0F86-94 E3 670 (9/11) JP Twice 0F88-C5 0C 671 ( 18) LD @12(1) ;P1->Alt 0F8A-AA E3 672 ( 22) ILD Row(2) ;Row = 1 0F8C-03 673 ( 5) SCL 0F8D- 674 Dsub: 0F8D-C5 FF 675 ( 18) LD @-1(1) ;Fuel 0F8F-F9 FE 676 ( 20) CAD -2(1) ;Subtract thrust 0F91-C9 00 677 ( 18) ST (1) 0F93-08 678 ( 5) NOP 0F94-BA E3 679 ( 22) DLD Row(2) 0F96-94 F5 680 (9/11) JP Dsub 0F98-06 681 ( 5) CSA ;P1->Fuel now 0F99-94 02 682 (9/11) JP Off ;Fuel run out? 0F9B-90 04 683 ( 11) JMP Accns 0F9D- 684 Off: 0F9D-C4 00 685 ( 10) LDI 0 0F9F-C9 FF 686 ( 18) ST -1(1) ;Zero thrust 0FA1- 687 Accns: 0FA1-C1 FF 688 ( 18) LD -1(1) 0FA3-03 689 ( 5) SCL 0FA4-EC 94 690 ( 15) DAI 0x99-Grav 0FA6-C9 FD 691 ( 18) ST -3(1) ;Accn + 1 0FA8-C4 99 692 ( 10) LDI 0x99 0FAA-EC 00 693 ( 15) DAI 0 0FAC-C9 FC 694 ( 18) ST -4(1) ;Accn 0FAE- 695 Dispy: 0FAE-C1 00 696 ( 18) LD (1) ;Fuel 0FB0-3E 697 ( 7) XPPC 2 ;Display it OK 0FB1-C1 F9 698 ( 18) LD -7(1) ;Vel 0FB3-94 0A 699 (9/11) JP Posv 0FB5-C4 99 700 ( 10) LDI 0x99 0FB7-03 701 ( 5) SCL 0FB8-F9 FA 702 ( 20) CAD -6(1) ;Vel+1 0FBA-03 703 ( 5) SCL 0FBB-EC 00 704 ( 15) DAI 0 0FBD-90 02 705 ( 11) JMP Sto 0FBF- 706 Posv: 0FBF-C1 FA 707 ( 18) LD -6(1) ;Vel+1 0FC1- 708 Sto: 0FC1-3E 709 ( 7) XPPC 2 ;Display velocity 0FC2-C1 F7 710 ( 18) LD -9(1) ;Alt+1 0FC4-3E 711 ( 7) XPPC 2 ;Display it 0FC5-C7 FF 712 ( 18) LD @-1(3) ;Get rid of blank 0FC7-C5 F6 713 ( 18) LD @-10(1) ;P1->Alt now 0FC9-3E 714 ( 7) XPPC 2 0FCA-C4 0A 715 ( 10) LDI 10 0FCC-CA E4 716 ( 18) ST Count(2) 0FCE- 717 Toil: 0FCE-C7 FF 718 ( 18) LD @-1(3) ; Key pressed? 0FD0-94 17 719 (9/11) JP Press ; Key 0-7? 0FD2-E4 DF 720 ( 10) XRI 0xDF ; Command key? 0FD4-9C 0D 721 (9/11) JNZ CONT ; rStart(2) ;Begin again if so 0FD6- 722 WAIT_KEY: ; New code to wait for the key to be released 0FD6-C3 00 723 ( 18) LD (3) ; Key still pressed? 0FD8-E4 DF 724 ( 10) XRI 0xDF ; Command key? 0FDA-98 FA 725 (9/11) JZ WAIT_KEY ; Still pressed so go back 0FDC-C4 04 37 C4 17 33 3F 726 JS P3,SC1 ; Full restart of Game 0FE3- 727 CONT: 0FE3-BA E4 728 ( 22) DLD Count(2) 0FE5-9C E7 729 (9/11) JNZ Toil 0FE7-92 31 730 ( 11) JMP rAgain(2) ;Another circuit 0FE9- 731 Press: 0FE9-C1 09 732 ( 18) LD +9(1) ;Thr+1 0FEB-98 03 733 (9/11) JZ Back ;Engines stopped? 0FED-33 734 ( 8) XPAL 3 ;Which Row? 0FEE-C9 09 735 ( 18) ST +9(1) ;Set thrust 0FF0- 736 Back: 0FF0-92 31 737 ( 11) JMP rAgain(2) 0FF2- 738 0FF2- 739 ; These lines moved here to eliminate forward references 0FF2- 740 ; that SBASM complains about. 0FF2- 741 ; Also the SoC listing has the subtraction backwards! 0FF2- 742 ; These values are the offset relative to P1 which points to 0FF2- 743 ; 0xF20, or the Ret label. All variables are stored before this 0FF2- 744 ; memory location at -ve offsets. FFFFFFE3- 745 Row .EQ 0xF03-Ret ;Ram Offsets FFFFFFE4- 746 Count .EQ 0xF04-Ret 0FF2- 747 ; 0FF2- 748 ; these calcs done to fix the way SBASM does calculations. 0031- 749 rAgain .EQ Again-Ret-1 FFFFF54E- 750 rStart .EQ Start-Ret-1 0FF2- 751 0B00- 752 .OR MOONSCAPE 0B00- 753 ; Graham's Moonscape 0B00-9F FF FF FF FF FF FF F9 754 .DB 0x9F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF9 0B08-2F FF FF FF FF FF FF F4 755 .DB 0x2F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF4 0B10-4C 00 00 00 00 00 00 32 756 .DB 0x4C,0x00,0x00,0x00,0x00,0x00,0x00,0x32 0B18-90 00 40 00 00 80 00 09 757 .DB 0x90,0x00,0x40,0x00,0x00,0x80,0x00,0x09 0B20-E0 00 00 00 00 00 00 07 758 .DB 0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x07 0B28-E0 00 00 00 00 00 00 07 759 .DB 0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x07 0B30-C0 00 00 04 00 00 00 03 760 .DB 0xC0,0x00,0x00,0x04,0x00,0x00,0x00,0x03 0B38-C2 00 00 00 00 00 00 23 761 .DB 0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x23 0B40-C0 00 00 00 00 00 00 03 762 .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0B48-C0 08 00 00 00 00 00 03 763 .DB 0xC0,0x08,0x00,0x00,0x00,0x00,0x00,0x03 0B50-C0 14 00 00 40 00 20 03 764 .DB 0xC0,0x14,0x00,0x00,0x40,0x00,0x20,0x03 0B58-C0 0E 00 00 00 08 00 03 765 .DB 0xC0,0x0E,0x00,0x00,0x00,0x08,0x00,0x03 0B60-C0 5F 00 80 00 1C 00 03 766 .DB 0xC0,0x5F,0x00,0x80,0x00,0x1C,0x00,0x03 0B68-C0 2F 80 00 00 2E 00 03 767 .DB 0xC0,0x2F,0x80,0x00,0x00,0x2E,0x00,0x03 0B70-C1 1F C0 00 00 1F 00 03 768 .DB 0xC1,0x1F,0xC0,0x00,0x00,0x1F,0x00,0x03 0B78-C0 3F E0 00 00 BF 80 03 769 .DB 0xC0,0x3F,0xE0,0x00,0x00,0xBF,0x80,0x03 0B80-C4 5F F0 00 00 7F C0 03 770 .DB 0xC4,0x5F,0xF0,0x00,0x00,0x7F,0xC0,0x03 0B88-C0 3F F8 04 02 FF E0 03 771 .DB 0xC0,0x3F,0xF8,0x04,0x02,0xFF,0xE0,0x03 0B90-D0 5F FC 00 01 FF F0 03 772 .DB 0xD0,0x5F,0xFC,0x00,0x01,0xFF,0xF0,0x03 0B98-C0 BF FE 00 0A FF F8 03 773 .DB 0xC0,0xBF,0xFE,0x00,0x0A,0xFF,0xF8,0x03 0BA0-C0 5F FF 00 05 FF FC 03 774 .DB 0xC0,0x5F,0xFF,0x00,0x05,0xFF,0xFC,0x03 0BA8-C0 AF FF 80 2B FF FE 03 775 .DB 0xC0,0xAF,0xFF,0x80,0x2B,0xFF,0xFE,0x03 0BB0-C0 5F FF C0 15 FF FF 03 776 .DB 0xC0,0x5F,0xFF,0xC0,0x15,0xFF,0xFF,0x03 0BB8-C0 2F FF E0 AA FF FF 83 777 .DB 0xC0,0x2F,0xFF,0xE0,0xAA,0xFF,0xFF,0x83 0BC0-C0 17 FF F0 15 7F FF C3 778 .DB 0xC0,0x17,0xFF,0xF0,0x15,0x7F,0xFF,0xC3 0BC8-C0 2B FF F8 2A FF FF E3 779 .DB 0xC0,0x2B,0xFF,0xF8,0x2A,0xFF,0xFF,0xE3 0BD0-E0 15 FF FC 15 7F FF F7 780 .DB 0xE0,0x15,0xFF,0xFC,0x15,0x7F,0xFF,0xF7 0BD8-E0 0A FF FE 02 BF FF E7 781 .DB 0xE0,0x0A,0xFF,0xFE,0x02,0xBF,0xFF,0xE7 0BE0-90 01 7F FF 01 5F FF 89 782 .DB 0x90,0x01,0x7F,0xFF,0x01,0x5F,0xFF,0x89 0BE8-4C 00 00 00 00 00 00 32 783 .DB 0x4C,0x00,0x00,0x00,0x00,0x00,0x00,0x32 0BF0-2F FF FF FF FF FF FF F4 784 .DB 0x2F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF4 0BF8-9F FF FF FF FF FF FF F9 785 .DB 0x9F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF9 0C00- 786 0C00- 787 ; empty scape 0C00- 788 ; .DB 0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD 0C00- 789 ; .DB 0x5F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFA 0C00- 790 ; .DB 0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x05 0C00- 791 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 792 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 793 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 794 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 795 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 796 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 797 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 798 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 799 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 800 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 801 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 802 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 803 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 804 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 805 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 806 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 807 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 808 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 809 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 810 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 811 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 812 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 813 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 814 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 815 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 816 ; .DB 0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x03 0C00- 817 ; .DB 0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x05 0C00- 818 ; .DB 0x5F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFA 0C00- 819 ; .DB 0xBF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD 0C00- 820 0C00- 821 ; ENTRY is the execution address that the Hex loader will use during program load 0C00- 822 EXEC_ADR: FFFE- 823 .OR 0xFFFE FFFE-04 824 .DB ENTRY/256 FFFF-00 825 .DB ENTRY\256 010000- 826