LUNAR LANDER ioh=iot i define initialize A,B law B dap A term define index A,B,C idx A sas B jmp C term define swap rcl 9s rcl 9s term define load A,B lio (B dio A term define setup A,B law i B dac A term define count A,B isp A jmp B term define random lac ran rar 1s xor (355670 add (355670 dac ran term ran, 0 / Store random number here. / Draw a point at X,Y on the display. Note X and Y are positive integers / between 0 and 1023 and must be converted to screen coordinates. define PLOT X,Y lac Y / Get the y coordibate. sub (777 / Convert to screen coordinates. sal 8s / Move y to high bits. swap / Move value from AC to IO register. lac X / Get the x coordinate. sub (777 / Convert to screen coordinates. sal 8s / Move x to high AC bits. dpy-i 4300 / Draw pixel. Don't wait. term / Start of program code. 3/ jmp sbf / Ignore sequence break. jmp a0 / Alternate start address, jump to a0. Use control boxes. jmp a1 / Alternate start address, jump to a1. Use test word controls. jmp a3 / Alternate start address, jump to a3. Use joystick controls. / Routine to flush sequence breaks, if they occur. sbf, tyi lio 2 lac 0 lsm jmp i 1 / Subroutine to display a multi digit number on the screen. / The position to display the LAST digit is stored in dgx,dgy. / The number to display will be passed stored in num. ddr, jmp . ddg, dap ddr / Get ready for return. lac num / Get resdy to keep going. dac quo / Set quotient with number. dzm rem / Zero remainder. lac num / Check for single digit passed. sub (12 sma / Number < 10? jmp clc / No - Keep going. lac num / Yes - Display the number. dac rem / Set remainder with digit to display. dzm quo / Zero quotient, / Display the digit in remainder. d1g, law dtb / Load the address of the digit address table. add rem / Add the character offset we want. dap . 1 / Save the combined address. jmp i . / Jump indirect to the correct character code. / Return will be jump to ndg. ndg, lac dgx / Shift x coordinate to left. sub (14000 dac dgx lac quo / Done if zero quotient. sza i / Not Zero? jmp ddr / No - Done displaying number. / Divide quotient by 10 via multiple subtractions. clc, lac quo / Move quotient to remainder. dac rem dzm quo / Zero quotient. div, lac rem / Get remainder. sub (12 / Subtract 10 from remainder. sma / Result minus? jmp qpl / No - update qutoient and keep going. jmp d1g / Display this next digit. qpl, dac rem / Save remainder. lac quo / Increase the quotient by 1. add (1 dac quo jmp div jmp ddr / Done displaying number. / Digits / Digits c0, lio dgy / 0 lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg c1, lio dgy / 1 lac dgx add (4000 dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 jmp ndg c2, lio dgy / 2 lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg c3, lio dgy / 3 lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg c4, lio dgy / 4 lac dgx dpy-i 4200 add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (6000 ioh dpy-i 4200 jmp ndg c5, lio dgy / 5 lac dgx dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg c6, lio dgy / 6 lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg c7, lio dgy / 7 lac dgx dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 jmp ndg c8, lio dgy / 8 lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg c9, lio dgy / 9 lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (6000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp ndg / Table of digit display addresses. dtb, c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 / Specioal Characters. r10, jmp . / : c10, dap r10 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r10 r11, jmp . / - c11, dap r11 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r11 r12, jmp . / V c12, dap r12 lio dgy lac dgx dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 jmp r12 r13, jmp . / H c13, dap r13 lio dgy lac dgx dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 jmp r13 r14, jmp . / S c14, dap r14 lio dgy lac dgx add (2000 dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 jmp r14 r15, jmp . / F c15, dap r15 lio dgy lac dgx dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 jmp r15 r16, jmp . / x c16, dap r16 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (10000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r16 r17, jmp . / Up Arrow. c17, dap r17 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r17 r18, jmp . / Down Arrow. c18, dap r18 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r18 r19, jmp . / Left Arrow. c19, dap r19 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r19 r20, jmp . / Right Arrow. c20, dap r20 lio dgy lac dgx lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 add (2000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s add (4000 ioh dpy-i 4200 lac dgx rcr 9s rcr 9s sub (2000 rcr 9s rcr 9s jmp r20 / Bits for thrust. t00, 637760 / Counter-clockwise 90. t01, 155754 / Counter-clockwise 45. t02, 776630 / Upright. t03, 615764 / Clockwise 45. t04, 177714 / Clockwise 90. / Draw the LEM exhaust if thrust is on. ltt, jmp . lt0, dap ltt ldt, lac . / Load the exhaust bitmap. dac bmr / Save the bitmap. lac (400000 / Setup the first (leftmost bit) to look at. dac bit dzm xct / Zero the x and y counters. dzm yct lac tcx / Initialize starting coordinates for the exhaust. dac bsx lac tcy dac bsy tpr, lac bmr / Process the row. and bit sza i / Is bit set? jmp lnb / No - next bit. lac bsx / Yes -Draw the bit. lio bsy dpy-i 4300 lnb, lac bit rar 1s / Advance to the next bit. dac bit idx xct / Check for end of row. sub (4 sza i / Have we done 4 bits yet? jmp lnr / Yes - advance to next row. lac bsx / No - Bump the x position. add scl dac bsx jmp tpr lnr, idx yct / Check for end of rows. sub (4 sza i / Have we done 4 rows yet? jmp ltt / Yes - Done drawing exhaust. lac tcx / No - Reset x coordinate. dac bsx lac bsy / Increment y coordinate. sub scl dac bsy dzm xct / Reset the x counter. jmp tpr / Bits for the LEM in counter-clockwise position. l00, 000004 016344 021254 040460 040440 040440 040440 040440 040460 021254 016344 000004 0 / End of table marker. / Bits for the LEM in counter-clockwise 45 degrees position. l01, 007000 010400 020200 040200 100360 100410 101020 042042 034124 004210 004400 005200 002200 000400 001000 0 / End of table marker. / Bits for the LEM in upright position. l02, 007700 010040 020020 020020 020020 010040 007700 030060 020020 037760 004100 010040 070070 0 / End of table marker. / Bits for the LEM in clockwise 45 degrees position. l03, 000700 001040 002020 002010 036004 041004 020404 210210 124160 042100 001100 002500 002200 001000 000400 0 / End of table marker. / Bits for the LEM in clockwise position. l04, 100000 116340 152420 031010 011010 011010 011010 011010 031010 152420 116340 100000 0 / End of table marker. / Setup to display the LEM, exhaust, and apply velocity. lt1, jmp . lm1, dap lt1 lac scx / Get the current screen coordinates of the LEM. dac tcx sub (4400 / Left edge of bitmap. dac bsx lac scy add (4400 / Top edge of bitmap. dac bsy lac rot / Setup lbn to point to the first row of the appropriate LEM bitmap. sza / Rotation 0? jmp cr1 / No - Check rotation 1. init lbn, l00 / Yes - Set for counter-clockwise 90. init ldt, t00 lac scx / Set coordinates for exhaust. add (12000 dac tcx lac scy add (400 dac tcy lac tac / Set the thrust values based on LEM orientation. cma / Invert. dac th / Negative horizontal with full thrust. dzm tv / No vertical thrust. jmp lbn / Draw LEM. cr1, sub (1 sza / Rotation 1? jmp cr2 / No - Check rotation 2. init lbn, l01 / Yes - Set for counter-clockwise 45. init ldt, t01 lac scx / Set coordinates for exhaust. add (7400 dac tcx lac scy sub (7000 add (400 dac tcy lac tac / Set the thrust values based on LEM orientation. sar 1s / Split thruts between horizontal and vertical. cma / Invert. dac th / N horizontal with half thrust. dac tv / Negative vertical with half thrust. jmp lbn / Draw LEM. cr2, lac rot sub (2 sza / Rotation 2? jmp cr3 / No - Check rotation 3. init lbn, l02 / Yes - Set for upright. init ldt, t02 lac scx / Set coordinates for exhaust. add (2400 dac tcx lac scy sub (7000 dac tcy lac tac / Set the thrust values based on LEM orientation. cma / Invert. dzm th / No horizontal thrust. dac tv / Negative vertical with full thrust. jmp lbn / Draw LEM. cr3, lac rot sub (3 sza / Rotation 3? jmp cr4 / No - Check rotation 3. init lbn, l03 / Yes - Set for clockwise 45. init ldt, t03 lac scx / Set coordinates for exhaust. sub (2400 dac tcx lac scy sub (6000 sub (400 dac tcy lac tac / Set the thrust values based on LEM orientation. sar 1s / Split thruts between horizontal and vertical. dac th / Positive horizontal with half thrust. cma / Invert. dac tv / Negative vertical with half thrust. jmp lbn / Draw LEM. cr4, init lbn, l04 / Must be rotation 4. init ldt, t04 lac scx / Set coordinates for exhaust. sub (5000 dac tcx lac scy add (400 dac tcy lac tac / Set the thrust values based on LEM orientation. dac th / Positive horizontal with full thrust. dzm tv / No vertical thrust. / Draw the LEM based on an 18-bit by 18 word bitmap. lbn, lac . / Get the next row from the LEM bitmap. sza i / Is row value 0? jmp lt1 / Yes - Then done drawing the LEM. / Process the next row of the bitmap. dac bmr / No - Save the next row value. lac (400000 / Setup the first (leftmost bit) to look at. dac bit nb0, lac bit / Get the current bit position. and bmr / Check to see if bit is to be displayed. sza i / Is bit position value zero? jmp nb1 / Yes - Get ready for next bit. lac bsx / No - Draw the bit. lio bsy dpy-i 4700 nb1, lac bit / Check to see if all the bits have been processed. sad (1 / Is bit in last position? jmp nrw / Yes - Get ready for next row. lac bit / No - Shift the test bit right one place. rar 1s dac bit lac bsx / Advance screen x. add scl dac bsx jmp nb0 / Do the next bit. nrw, lac lbn / Point to the next row in the bitmap. add (1 dac lbn lac bsy / Advance screen y. sub scl dac bsy lac scx / Reset screen x. sub (4400 dac bsx lac (400000 / Setup the first (leftmost bit) to look at. dac bit jmp lbn / Points that make up the terrain. trn, 400710 405700 412656 417626 424602 431570 436570 443570 450570 455570 462570 467565 474551 501525 506501 513464 520461 525454 532442 537430 544421 551416 556417 563417 570417 575417 602417 607420 614425 621433 626440 633442 640443 645443 652443 657443 664443 671442 676440 703433 710427 715424 722424 727423 734424 741424 746424 753424 760424 765424 772424 777424 004424 011424 016424 023424 030424 035424 042424 047430 054436 061444 066447 073450 100453 105461 112467 117473 124474 131476 136503 143511 150516 155517 162520 167520 174520 201520 206520 213522 220533 225546 232561 237567 244571 251600 256614 263627 270636 275640 302643 307650 314656 321662 326664 333663 340664 345664 352664 357664 0 / End of data marker. / Draw the terrain. dtr, dap dtx / Setup return address. init dti, trn / Point to first word of terrain data. dti, lac . / Get the next terrain data word. sza i / Is 0? jmp dtx / Yes - return. cli / Set the y coordinate. scr 9s / Shift low 9-bits into the high 9-bits of IO. sal 9s / Move remaining 9-bits into the high part of AC. dpy-i 4300 / Plot the point. idx dti / Bump the data address to the next point. jmp dti / Continue. dtx,jmp . / Return. / Y-coordinates of the terrain points in 0-1024 screen coordinates. ypt, 000620 000601 000534 000455 000404 000360 000360 000360 000360 000360 000360 000353 000322 000253 000203 000151 000143 000130 000105 000061 000042 000035 000036 000036 000036 000036 000036 000041 000052 000066 000100 000105 000106 000106 000106 000106 000106 000105 000100 000067 000057 000051 000050 000047 000050 000050 000050 000050 000050 000050 000050 000050 000050 000050 000050 000050 000050 000050 000051 000061 000074 000110 000117 000120 000127 000142 000156 000166 000170 000175 000207 000223 000234 000237 000240 000240 000240 000240 000240 000245 000266 000315 000343 000357 000362 000401 000430 000457 000475 000500 000506 000521 000535 000545 000550 000547 000550 000550 000550 000550 0 / End of data marker. / The left endpoints of landing zones. lzx, 50 / 5x 322 / 2x 466 / 3x 632 / 1x 1320 / 4x 1642 / 5x 0 / End of data marker. / The right endpoints of landing zones. rzx, 144 / 5x 416 / 2x 574 / 3x 1104 / 1x 1414 / 4x 1724 / 5x / Scores for successful landings by target multiplier. skz, 372 / 5 x 50 = 250 144 / 2 x 50 = 100 226 / 3 x 50 = 150 62 / 1 x 50 = 50 310 / 4 x 50 = 200 372 / 5 x 50 = 250 / Setup for an explosion. exp, dap ext / Setup return address. law exx / Load address x origin into AC. dap ex1 / Deposit AC in address part at label ex1. law exy / Load address y origin into AC. dap ex2 / Deposit AC in address part at label ex2. law edx / Load address x delta into AC. dap ex3 / Deposit AC in address part at label ex3. law edy / Load address y delta into AC. dap ex4 / Deposit AC in address part at label ex4. lac xmn / Explosion starts from the LEM center. add xmx / Calculate center x of bounding box. sar 1s / Divide by 2. dac scx / Save center x. lac ymn add ymx / Calculate center y of bounding box. sar 1s / Divide by 2. dac scy / Save center y. elp, random / Create a random x start offset. and (17 sub (10 add scx / Add the x origin. dac dgx / Save. ex1, dac . / Save the particle x coordinate. random / Create a random y start offset. and (17 sub (10 add scy / Add the y origin. dac dgy / Save. ex2, dac . / Save the particle y coordinate. PLOT dgx,dgy / Highlight to point. random / New random number. and (17 / Reduce to 0-15. add (1 / Range 1-16. dac dy random / Get a new random number. and (17 / Reduce to 0-15. sub (10 / Range -7 to 8. dac dx / Save as x delta. ex3, dac . / Save the particle dx. lac dy / Get the particle dy. ex4, dac . / Save the particle dy. idx ex1 / Increment all the pointers. idx ex2 idx ex3 idx ex4 / Increment value in ex4, leave it in AC. sas (dac edy+nep / Table full? jmp elp / No - Keep going. ext, jmp . / Yes - Return. / Draw an explosion frame. dex, dap det / Setup return address. law exx / Load address x origin into AC. dap dx1 / Setup in dx1. dap dx3 / Setup in dx3. law exy / Load address y origin into AC. dap dx4 / Setup in dx4. dap dx6 / Setup in dx6. law edx / Load address x delta into AC. dap dx2 / Setup in dx2 law edy / Load address y delta into AC. dap dx5 / Setup in dx5. lac egr / Gravital velocity to impose on each particle. add acc / Add moon's acceleration. dac egr / Save. dx1, lac . / Load the x particle position. dx2, add . / Add the x delta. dac scx / Save new x. dx3, dac . / Update particle x position. dx4, lac . / Load the y particle position. dx5, add . / Add the y delta. sub egr / Apply moon's gravity. dac scy / Save new y. dx6, dac . / Update particle y position. spa / Don't plot negative values of y. jmp spl lac scx / Don't plot negative values of x. spa jmp spl sub (1777 / Check for x > 1023. sma jmp spl / Don't plot x values > 1023. PLOT scx,scy / Draw the particle. spl, idx dx1 / Increment all the pointers. idx dx2 idx dx3 idx dx4 idx dx5 idx dx6 sas (dac exy+nep / Table done? jmp dx1 / No - Keep going. det, jmp . / Return. / Draw the target values. dtv, dap dvx lac nel / Get the explosion loop counter. sza / Zero? jmp dvx / No - Bypass targets. lac (565000 / First target 5x. dac dgy lac (436000 dac dgx lac (5 / 5 dac num jsp ddg lac dgx add (27000 dac dgx / x jsp c16 lac (414000 / Second target 2x. dac dgy lac (557000 dac dgx lac (2 / 2 dac num jsp ddg lac dgx add (27000 dac dgx / x jsp c16 lac (440000 / Third target 3x. dac dgy lac (637000 dac dgx lac (3 / 3 dac num jsp ddg lac dgx add (27000 dac dgx / x jsp c16 lac (421000 / Fourth target 1x dac dgy lac (764000 dac dgx lac (1 / 1 dac num jsp ddg lac dgx add (27000 dac dgx / x jsp c16 lac (514000 / Fifth target 4x. dac dgy lac (155000 dac dgx lac (4 / 4 dac num jsp ddg lac dgx add (27000 dac dgx / x jsp c16 lac (661000 / Sixth target 5x. dac dgy lac (331000 dac dgx lac (5 / 5 dac num jsp ddg lac dgx add (27000 dac dgx / x jsp c16 dvx, jmp . / Return. / Draw the fuel status. dfs, dap dfx / Set return address. lac (372000 / Set top of fuel position. dac dgy lac (-361000 / F /cma dac dgx jsp c15 lac (-344000 / : /cma dac dgx jsp c10 lac ful dac num / Save the number. lac (-265000 / Set the x coordinate of the last letter. /cma dac dgx jsp ddg / Display the number. dfx, jmp . / Return. / Draw the score. drs, dap dxs / Set return address. lac (346360 / Set top of score position. dac dgy lac (-361000 / S dac dgx jsp c14 lac (-344000 / : dac dgx jsp c10 lac sco dac num / Save the number. lac (-265000 / Set the x coordinate of the last letter. dac dgx jsp ddg / Display the number. dxs, jmp . / Return. / NEW GAME text encoded as a 54 x 7 bitmap. nge, 427652 003434 247600 1 624052 004042 524000 1 424052 004042 524000 1 527052 005676 527400 1 424052 004242 524000 1 464052 004242 524000 1 427624 003442 527600 0 / End of data marker. / GAME OVER text encoded as a 54 x 7 bitmap. got, 343424 760071 057570 1 / End of line markers. 404252 400105 050104 1 404252 400105 050104 1 567652 740104 517170 1 424252 400104 510120 1 424252 400104 210110 1 344252 760070 217504 0 / End of data marker. / Draw some game text. ngt, dap ngx lac (624 / Set up screen start coordinates of the bitmap. sub (777 sal 8s dac bsx dac tmp lac (1016 sub (777 sal 8s dac bsy ngn, lac . / Get the next row word from the NG bitmap. dac bmr / Save for processing. sza i / Is row value 0? jmp ngx / Yes - Then done drawing the message. sas (1 / Is row word value 1? jmp pnr / No - Process the row word. / Yes - Advance the y coordinate one line. lac bsy / Advance screen y. sub (2000 dac bsy lac tmp / Reset screen x. dac bsx jmp ng2 / Get the next word. / Process the next word of the bitmap. pnr, lac (400000 / Setup the first (leftmost bit) to look at. dac bit ng0, lac bit / Get the current bit position. and bmr / Check to see if bit is to be displayed. sza i / Is bit position value zero? jmp ng1 / Yes - Get ready for next bit. lac bsx / No - Draw the bit. lio bsy dpy-i 4300 ng1, lac bsx / Advance screen x. add (2000 dac bsx lac bit / Move to next bit position. rar 1s dac bit sad (400000 / Is bit in first position? jmp ng2 / Yes - Get the next word. jmp ng0 / No - Do the next bit. ng2, idx ngn / Advance the data pointer. jmp ngn / Keep looping. ngx, jmp . / Draw the vertical velocity status. dvv, dap dxv / Set return address. lac (372000 / Set top of vertical velocity position. dac dgy lac (252000 / V dac dgx jsp c12 lac (267166 / : dac dgx jsp c10 lac vy lio (302000 / Get ready to display direction. dio dgx sza i / Not Zero? jmp dny / No - Don't show direction. sma / Is velocity negative? jmp ddn / No - Go to down arrow. jsp c17 / Yes - Display up arrow. lac vy cma jmp dny ddn, jsp c18 / Display down arrow. lac vy dny, dac num / Save the number. lac (362000 / Set the x coordinate of the last letter. dac dgx jsp ddg / Display the number. dxv, jmp . / Return. / Draw the horizontal velocity status. dhv, dap dxh / Set return address. lac (346360 / Set top of horizontal velocity position. dac dgy lac (252000 / H dac dgx jsp c13 lac (267166 / : dac dgx jsp c10 lio (302000 / Get ready to display direction. dio dgx lac vx sza i / Not Zero? jmp dnx / No - Don't show direction. sma / Is velocity negative? jmp ddp / No - Go to left arrow. jsp c20 / Yes - Display right arrow. lac vx cma / Compliment. jmp dnx ddp, jsp c19 lac vx dnx, dac num / Save the number. lac (362000 / Set the x coordinate of the last letter. dac dgx jsp ddg / Display the number. dxh, jmp . / Return. / Get raw input. gri, dap grx / Set return address. cla / Clear the accumulator. rcw, jsp . / Call the appropriate input routine. grx, jmp . / Return with input in AC. / Process inputs. pip, dap pix / Set return address. jsp gri / Get the raw input. dac cin / Save as current input. rar 4s / Combine plyaer 1 and player 2 inputs. ior cin dac cin and (400000 / Check for left. sza i / Is left? jmp ckr / No - Check for right bit. lac pin / Yes - Check the previous input. and (400000 sza / Is previous input left? jmp ckr / Yes - Wait for left bit to be cleared. lac rot / Get the current rotation. sza i / Already at 0? jmp ckr / Yes - Check for right bit. sub (1 / Rotate counter-clockwise by one. dac rot / Save change. jmp ckt / Skip right bit check. ckr, lac cin / Refetch the input. and (200000 / Check for right. sza i / Is right? jmp ckt / No - Check for thrust bit. lac pin / Yes - Check the previous input. and (200000 sza / Is previous input right? jmp ckt / Yes - Wait for right bit to be cleared. lac rot / Get the current rotation. sub (4 / sza i / Already at 4? jmp ckt / Yes - Check for thrust bit. lac rot / No - Update rotation. add (1 / Rotate clockwise by one. dac rot / Save change. ckt, dzm thr / Set thrust to off. lac cin / Refetch the input. dac pin / Move to previous input. and (100000 / Check for thrust. sza i / Is thrust? jmp pix / No - Keep going. lac ful / Yes - Apply thrust velocities if fuel. sza i / Is fuel? jmp pix / No - Don't apply velocities. lac vy / Yes - Apply velocities. add tv dac vy lac vx sub th dac vx lac ful / Reduce the fuel by 1. sub (1 dac ful lac thr / Indicate that thrust is on. add (1 dac thr pix, jmp . / Return / Apply all velocities to the game environment. agv, dap agx / Set return address. lac vy / Increase vertical velocity by add acc / the acceleration of moon's gravity. dac vy lac gmy / Advance game y by velocity. lio vy / Get the y velocity. sir 5s / Shift off the fractional part. dio vel / Save. sub vel / Reduce game y by velocity. dac gmy spa / Is game y still positive? jmp nxr / No - Restart. lac (17500 / Yes - Check game Y too high. sub gmy spa / Is game y below max height? jmp nxr / No - Restart. / Yes - Continue with game. lac gmx / Advance game x by velocity. lio vx / Get the x velocity. sir 5s / Shift off the fractional part. dio vel / Save. sub vel / Reduce game x by velocity. dac gmx spa / Is game x still positive? jmp nxr / No - Restart. lac (17500 / Yes - Check game x too far right. sub gmx spa / Is game x within max height right? jmp nxr / No - Restart. / Yes - Continue with game. lac gmy / Convert from game space to screen space. sar 3s / Divide by 8 to get within the 1024 mark. sub (777 / Convert to screen coordinates sal 8s / Move to upper 10 bits. dac scy / Save for draw to use. lac gmx / Convert from game space to screen space. sar 3s / Divide by 8 to get within the 1024 mark. sub (777 / Convert to screen coordinates sal 8s / Move to upper 10 bits. dac scx / Save for draw to use. agx, jmp . / Return. / Check for LEM terrain intersection. lti, dap ltx / Set return address. lac gmx / Convert the LEM game coordinates to 0-1023 sar 3s / screen coordinates. dac scx lac gmy sar 3s dac scy lac scx / Create bounding box. add (27 dac xmx lac scx sub (7 dac xmn lac scy add (11 dac ymx lac scy sub (22 dac ymn / Iterate through the terrain points to see if they intersect with the LEM. dzm xct / Zero x coordinate counter. init chi, ypt / Point to first word of terrain y 0-1023 data. chi, lac . / Get the next y coordinate. sza i / Not zero? jmp ltx / No - Done checking intersections. dac yct / Yes - Save Y value for further checking. sub ymx / Check top of bounding box. sma / Negative? jmp nxp / No - y is above the bounding box. lac yct / Yes - Check bottom of bounding box. sub ymn spa / Positive? jmp nxp / No - y is below the bounding box. lac xct / Yes - Check left of bounding box. sub xmn spa / Positive? jmp nxp / No - y is left of the bounding box. lac xct / Yes - check right of bounding box. sub xmx sma / Negative? jmp nxp / No - point does not intersect. / If we get here the point is inside the LEM's bounding box. / First check for a soft landing. lac rot / Get the LEM's rotation. Must be upright. sas (2 / Upright? jmp sex / No - Set for explosion. init lx, lzx / Yes - Setup for landing zone check. Left point. init rx, rzx / Right point. init sc, skz / Score. lx, lac . / Get the left landing zone end point. sza i / Not Zero? jmp sex / No - End of landing zone table. dac dgx / Yes - Save left end. rx, lac . / Get the right landing zone end point. dac dgy / Save right end. lac scx / Get the x center of the LEM. sub dgx / Check against left edge of landing zone. spa / Positive? jmp nlz / No - Point is outside landing zone. lac scx / Yes - Check right edge of landing zone. sub dgy sma / Negative? jmp nlz / No - Point is outside landing zone. jmp cvv / Yes - Hit landing zone check velocity. nlz, idx lx / Check next landing zone. idx rx idx sc jmp lx cvv, lac vy / Yes - Make sure verticle velocity < 100. sub (144 sma / Negative? jmp sex / No - Landing too hard. lac vx / Yes - Check horizontal velocity. spa / Positive? cma / No - Compliment want absolute value. sub (62 / Yes - Make sure horizontal velocity < 50. sma / Negative? jmp sex / No - Too much drift. / Good landing! sc, lac . / Show the score increasing. dac tmp slp, lac sco / Get the score. add (1 dac sco / Update by one. jsp drs / Show the score. jsp dtr / Show terrain. lac tmp / Decrease new score by one. sub (1 dac tmp sza / Zero? jmp slp / No - Keep showing score increasing. lac (62 / Yes - Add 50 to fuel. dac tmp sfp, lac ful / Get the score. add (1 dac ful / Update by one. jsp dfs / Show the fuel. jsp dtr / Show terrain. lac tmp / Decrease new fuel by one. sub (1 dac tmp sza / Zero? jmp sfp / No - Keep showing fuel increasing. jmp nxr / Yes - Restart round. / Set for explosion! sex, jsp exp / Setup tables for explosion. lac (40 / Bunch of loops for explosion. dac nel / Set explosion frame counter. lac (20 / Bunch of frames to skip. dac skp / Set explosion frame skip. dzm egr / Gravity imposed on particles. stf 1 / Disable inputs checking. stf 2 / Disable Velocity updates. stf 3 / Disable collision deterction. stf 4 / Disable draw LEM. Enable draw explosion. stf 5 / Disable status. stf 6 / Disable drawing targets. dzm vx / Clear velocities. dzm vy lac sco / Five points for a crash. add (5 dac sco jmp ltx / Exit checks. nxp, lac xct / Advance to next x coordinate. add (12 / Add 10. dac xct idx chi / Index to the next y coordinate. jmp chi ltx, jmp . / Return. / Read the control boxes. rcb, dap rcx cli / Clear the IO register. iot 11 / Make the IOT call to fetch the control box values. swap / Want the result in AC register. rcx, jmp . / Read the testword. rtw, dap rtx lat / Load test word switches into the AC register. rtx, jmp . / Read the joystick. rjs, dap rjx cli / Clear the IO register. iot 15 / Make the IOT call to fetch the joystick values. swap / Want the result in AC register. rjx, jmp . / The screen is 1024 x 1024 pixes. Assume each pixel is 8 meters square. That gives an on / screen game area of 8.192 x 8.192 kilometers. acc, 1 / Lunar gravity is 1.62 m/s**2. Approximate with 1 for now. vel, 0 / Temporary storage for velocity. vy, 0 / Velocity due to moon's gravity and vertical thrust. vx, 0 / Horizontal velocity due to thrust. ful, 0 / Fuel. sco, 0 / Score. tac, 4 / Thrust of the LEM engine. tv, 0 / Vertical thrust. th, 0 / Horizontal thrust. thr, 0 / Non-zero if thrust pressed. cin, 0 / Current input word. pin, 0 / Previous imput word. gmx, 0 / Position of LEM in game space. Center of screen. gmy, 0 / Top of game at 8,000 meters. scx, 0 / Position of LEM in screen space. scy, 0 tcx, 0 / Position of the LEM exhaust in screen space. tcy, 0 dgy, 0 / Set when calling digit writing routine dgx, 0 sdy, 0 / Save the dgy value here when doing multiple digits. num, 0 / Used when displaying multi-digit number. quo, 0 / Used for division quotient when dividing. rem, 0 / Used for division remainder when dividing. tmp, 0 / Temporary storage. bmr, 0 / Current row of the LEM bitmap being drawn. bit, 0 / Next bit in the row to check. bsx, 0 / The x,y screen coordinate to draw the next bitmap dot at. bsy, 0 scl, 1000 / Scale to draw the lem. xct, 0 / An x counter. yct, 0 / A y counter. xmn, 0 / Bounding box for the LEM. xmx, 0 ymn, 0 ymx, 0 rot, 2 / Current rotation of the LEM. sec, 12 / Have to count ten 100 milisecond loops for a second. 5sc, 5 / For 5 second intervals. / Explosion stuff. nep=70 / Number of explosion particles. exx, . nep/ / Particle x coordinate. exy, . nep/ / Particle y coordinate. edx, . nep/ / Particle dx. edy, . nep/ / Partivle dy. nel, 0 / Number of times to go through the explosion loop. skp, 0 / Explosion frames to skip. egr, 0 / Gravity imposed on each particle. dx, 0 / Delta x applied to particles. dy, 0 / Delta y applied to patticles. / Start a new game. a0, law rcb / Configure to read control boxes. dap rcw jmp ngm a1, law rtw / Configure to read testword. dap rcw jmp ngm a3, law rjs / Connfigure to read the joystick. dap rcw / New game. ngm, dzm sco / Clear the score. lac (1747 / Top up the fuel. / lac (100 / DEBUG. dac ful dzm vy / Clear verticle velocity. lac (-1130 dac vx / Horizontal Velocity 400. dzm rot / LEM pointing to the left. lac (15530 / Set the LEM at 7,000 meters. dac gmy lac (50 / Start on left side of screen. dac gmx / Attract mode. atm, jsp gri / Get the raw input. dac pin jsp lm1 / Draw LEM. jsp agv / Apply velocity. dzm vy / Negate gravity. jsp dtr / Draw terrain. init ngn, nge / Set address to start of bitmap. jsp ngt / Draw the "NEW GAME" text. lac (17430 / Check game x too far right. sub gmx sma / Is game x within max right? jmp cpn / Yes - Keep going. lac (50 / Restart on left side of screen. dac gmx cpn, lac pin / Get button press from begining of loop. sza i / Not Zero? jmp atm / No - Keep looping. jsp gri / Yes - Get the input again. sza i / Not Zero? jmp nxr / No - Start a new game. jmp atm / Yes - Keep looping. / Next round. nxr, lac (15530 / Set the LEM at 7,000 meters. dac gmy lac (50 / Start on left side of screen. dac gmx dzm vy / Initialize verticle velocity to zero. lac (-620 dac vx / Initialize horizontal Velocity to 400. dzm rot / Set LEM pointing left. / Setup the initial active game components. clf 1 / Enable inputs. clf 2 / Enable velocities. clf 3 / Enable collosion detection. clf 4 / Enable draw LEM. Disable explosion. clf 5 / Enable status. clf 6 / Enable targets. / Main loop. fr0, load \ict, -1 / Loops about every 100 milliseconds. lac sec / Get the second count. sub (1 / Reduce by one. sza i / Not Zero? jmp dsc / No - Do the one second code. dac sec / Yes - Save the new second count. jmp inp / Continue with acceleration calculation. dsc, lac (12 / Reset the second counter. dac sec // Put the one second code here. lac 5sc / Check the 5 second counter. sub (1 dac 5sc / Save result. sza / Is AC Zero? jmp inp / No - Bypass lac (5 / Yes - Reset 5 second counter. dac 5sc // Put the five second code here. / Draw the targets. szf 6 / Is the Targets flag zero? jmp inp / No - Bypass drawing targets. jsp dtv / Yes - Draw the target landing locations. / Check for inputs. inp, szf 1 / Is the Input flag 0? jmp avl / No - Bypass input checks. jsp pip / Yes - Process inputs. / Apply velocities to game position. avl, szf 2 / Is the Velocity flag 0? jmp dst / No - Bypass velocity updates. jsp agv / Yes - Apply velocity changes. / Draw the vertical and horizontal velocity values. dst, szf 5 / Is the Status flag 0? jmp dtn / No - Bypass updating the status. jsp dvv / Yes - Draw the game status text. jsp dhv jsp dfs jsp drs / Draw the terrain. dtn, jsp dtr / Draw the terrain. / Draw the LEM. plm, szf 4 / Is the LEM/Explosion flag 0? jmp dxn / No - Draw the explosion. jsp lm1 / Yes - Draw the LEM. lac thr sza / Is thrust on? jsp lt0 / Yes - Show LEM exhaust. jmp ctn / Draw the explosion. dxn, lac skp / Check for skip frame. add (-1 dac skp sza / Zero? jmp cnt / No - Skip drawing explosion. jsp dex / Yes - Draw an explosion frame. lac (20 / Update skip. dac skp lac nel / Update counter. add (-1 dac nel sza / Zero? jmp ctn / No - Keep going with mail loop. lac ful / Yes - Check fuel. sza / Zero? jmp nxr / No - Keep playing current game. / End of game. Wait for a button press. wlp, jsp gri / Get the raw input. dac pin jsp drs / Show the score. jsp dtr / Show the terrain. init ngn, got / Set address to start of bitmap. jsp ngt / Draw the "GAME OVER" text. lac pin / Get button press from beginning of loop. sza i / Not Zero? jmp wlp / No - Keep looping. jsp gri / Yes - Get the input again. sza i / Not Zero? jmp ngm / No - Start a new game. jmp wlp / Yes - Leep looping. / Check for contact with the terrain. ctn, szf 3 / Is the Collision flag 0? jmp cnt / No - Bypass collision checking. jsp lti / Yes - Perform collision detection. cnt, count \ict, . / Use up rest of time of main loop. jmp fr0 / Next frame. / Insert constants and variables, end of program. constants variables start 4