From 55f1c85d0dfd2ddbc25f726a704f8fc18a0fcc9d Mon Sep 17 00:00:00 2001 From: Lars Brinkhoff Date: Tue, 22 Jan 2019 21:39:17 +0100 Subject: [PATCH] Imlac Spacewar. --- Makefile | 4 +- build/misc.tcl | 9 + doc/imlac/sw.info | 59 ++ doc/programs.md | 1 + src/imlac/disfix.9 | 12 + src/imlac/imdefs.999999 | 1 + src/imsrc/swar.8 | 1891 +++++++++++++++++++++++++++++++++++++++ 7 files changed, 1975 insertions(+), 2 deletions(-) create mode 100644 doc/imlac/sw.info create mode 100644 src/imlac/disfix.9 create mode 120000 src/imlac/imdefs.999999 create mode 100644 src/imsrc/swar.8 diff --git a/Makefile b/Makefile index 4e32ee19..ff92424c 100644 --- a/Makefile +++ b/Makefile @@ -27,13 +27,13 @@ SRC = syseng sysen1 sysen2 sysen3 sysnet kshack dragon channa \ macsym lmcons dmcg hack hibou agb gt40 rug maeda ms kle aap common \ fonts zork 11logo kmp info aplogo bkph bbn pdp11 chsncp sca music1 \ moon teach ken lmio1 llogo a2deh chsgtv clib sys3 lmio turnip \ - mits_s rab stan_k bs cstacy kp dcp2 -pics- victor + mits_s rab stan_k bs cstacy kp dcp2 -pics- victor imlac DOC = info _info_ sysdoc sysnet syshst kshack _teco_ emacs emacs1 c kcc \ chprog sail draw wl pc tj6 share _glpr_ _xgpr_ inquir mudman system \ xfont maxout ucode moon acount alan channa fonts games graphs humor \ kldcp libdoc lisp _mail_ midas quux scheme manual wp chess ms macdoc \ aplogo _klfe_ pdp11 chsncp cbf rug bawden llogo eak clib teach pcnet \ - combat pdl minits mits_s chaos hal -pics- + combat pdl minits mits_s chaos hal -pics- imlac BIN = sys2 emacs _teco_ lisp liblsp alan inquir sail comlap c decsys \ graphs draw datdrw fonts fonts1 fonts2 games macsym maint imlac \ _www_ hqm gt40 llogo bawden sysbin -pics- diff --git a/build/misc.tcl b/build/misc.tcl index 2ea3e6ee..81fed85a 100644 --- a/build/misc.tcl +++ b/build/misc.tcl @@ -1165,6 +1165,15 @@ respond "M IML" "\r" respond ":PDUMP" "games; ts maze\r" respond "*" ":kill\r" +# SWAR +respond "*" ":midas imlac;_imsrc; swar\r" +respond "INFINITE FUEL AND BULLETS VERSION?" "N\r" +expect ":KILL" +respond "*" ":imtran\r" +respond "@" "imlac; swar iml_imlac; swar bin\r" +respond "@" "\032" +type ":kill\r" + # KLH's Knight TV clock. respond "*" ":midas klh; ts tinyw_klh; clock\r" respond "=" "1\r" diff --git a/doc/imlac/sw.info b/doc/imlac/sw.info new file mode 100644 index 00000000..c73bdadf --- /dev/null +++ b/doc/imlac/sw.info @@ -0,0 +1,59 @@ + SPACE-WAR + + This is Spacewar for the IMLAC PDS-1. + + Spacewar is controlled from the switches on the Programmer's +Console of a PDS-1. The keyset and keyboard are also used to a limited +extent. The meanings of the console switches are as follows: + + + SHIP 1 CONTROL SHIP 3 SHIP 2 + (stubby ship) (triangle ship) (needle ship) + | | | | | + | 0 1 2 3 | 4 5 6 7 | 8 9 10 11 | 12 13 14 15 | + | | | | | + <- -> a f s g 3 r <- -> a f <- -> a f + p r r a + i a d n + n v d + i s o + t h m + y i + p + + + For each ship, the left button is counter-clockwise roll, the +second is clockwise roll, the third is rocket thrust, and the right- +most is bullet firing. + Putting both rolls on at once causes warping. + Putting thrust and both rolls on at the same time makes you +invisible or visible, depending on your current state. + + Control switches: + +Switch 4 - In down position, turns on spin mode, in which angular + momentum is conserved. In non-spin mode, the ship will not + rotate if neither rotation switch is down. + +Switch 5 - In down position, turns off the Sun's gravity. + +Switch 6 - In down position, adds 3rd ship (triangle ship) at start of + game. If this ship is in the game, it uses the keyset (to + eliminate the tangle of fingers on the console switches. + +Switch 7 - In down position, randomizes starting positions. + + The rightmost four keys on the keyset will also control ship 1 or +ship 3 (depending upon whether there are 2 or 3 ships in the game)in a +manner similar to the four switches. + + Typing "BREAK" causes the game to be interrupted into a mode where +the scores are displayed and keyboard commands may be typed. Commands +currently available are: + + R - reset scores to zero. + + Spacewar loads into the high 4K of the IMLAC and thus may be +loaded on top of SSV without destroying it. To return to SSV, type +control-Z on the keyboard. + de \ No newline at end of file diff --git a/doc/programs.md b/doc/programs.md index b1f48170..bd728c5b 100644 --- a/doc/programs.md +++ b/doc/programs.md @@ -282,6 +282,7 @@ - STYLOG, convert PTY output file into ASCII file. - SUPARD, draw ARDS graphics to SUPDUP. - SUPDUP, Supdup client. +- SWAR, Imlac Spacewar. - SYSCHK, check up on system job. - SYSLOD, system load histogram. - SYSMSG, displays system messages. diff --git a/src/imlac/disfix.9 b/src/imlac/disfix.9 new file mode 100644 index 00000000..e04ff06a --- /dev/null +++ b/src/imlac/disfix.9 @@ -0,0 +1,12 @@ +TITLE DISPLAY MACRO FIX FILE + +EQUALS ..DLXA DLXA +EQUALS ..DLYA DLYA +EXPUNG DLXA DLYA + +DEFINE DLXA (ARGG) + ..DLXA TERMIN + +DEFINE DLYA (ARGG) + ..DLYA TERMIN + \ No newline at end of file diff --git a/src/imlac/imdefs.999999 b/src/imlac/imdefs.999999 new file mode 120000 index 00000000..21bcfe03 --- /dev/null +++ b/src/imlac/imdefs.999999 @@ -0,0 +1 @@ +imsrc/imdefs.> \ No newline at end of file diff --git a/src/imsrc/swar.8 b/src/imsrc/swar.8 new file mode 100644 index 00000000..dbec1f3f --- /dev/null +++ b/src/imsrc/swar.8 @@ -0,0 +1,1891 @@ +TITLE CHAR SET 2 + +; this is spacewar for the imlac pds-1. buttons and conventions are +; as follows: + +; SHIP 1 CONTROL SHIP 3 SHIP 2 +; (stubby ship) (triangle ship) (needle ship) +; | | | | | +; | 0 1 2 3 | 4 5 6 7 | 8 9 10 11 | 12 13 14 15 | +; | | | | | +; <- -> a f s g s r <- -> a f <- -> a f +; p r h a +; i a i n +; n v p d + +; for each of these, the left button is counter-clockwise roll, +; the second is clockwise roll, the third is rocket thrust, and +; the rightmost is bullet firing. putting both rolls on at +; once causes warping. putting thrust and both rolls on at +; the same time makes you invisible or visible, depending on +; your current state. + +; button 4 - in down position, turns on spin mode. +; button 5 - in down position, turns off gravity. +; button 6 - in down position, includes 3rd ship at start of game +; button 7 - in down position, randomizes starting positions. + +; the rightmost four keys on the keyset will also control ship 1 in a +; manner similar to the four switches. + ; definitions + +MAXADR=37777' +PDS4=1 +.MLLIT==1 +.INSRT IMLAC;IMDEFS > +.INSRT IMLAC;DISFIX > + +IF1,[PRINTX /INFINITE FUEL AND BULLETS VERSION? / +.TTYMAC A +IFSE A,YES,[NBULLT==40000 + NFUEL==40000 + PRINTX /OK SUCKER +/ +] +IFSN A,YES,[NBULLT==40 + NFUEL==3000] +TERMIN +] + + + .ADDR.=1 + + IF1,EXPUNG SET,MUL,DIV,XCT + +DEFINE SET L1,L2 + LAC L2 + DAC L1 +TERMIN + +DEFINE SETN L1,L2 + LAC L2 + CIA + DAC L1 +TERMIN + +DEFINE SETI L1,L2 + LAW L2 + DAC L1 +TERMIN + +DEFINE SETNI L1,L2 + LWC L2 + DAC L1 +TERMIN + +; size of a block +BLK=3777 + +; auto-index registers +X0=10 +X1=11 +X2=12 +X3=13 +X4=14 +X5=15 +X6=16 +X7=17 + +NUMSHP=3 +NUMBLT=25 +NUMOBJ=30 + + ; startup + + LOC 30000 + + JMP STRTUP + JMP NEWPAS + +; constants + +GRAV: -3000 ; gravity constant +THRST: SAR 2 ; thrust factor +ROLL: 20 ; amount of roll force + + LOC 30030 ; skip over auto-index block + +FUEL: -NFUEL ; fuel supply for ships +BLTNO: -NBULLT ; number of bullets per ship +BLTVEL: SAR 1 ; bullet's velocity +BLTIM: -200 ; time that bullets last +BLTINT: -7 ; interval between bullet firings +SUNSIZ: -1200 ; size of sun +SHPSIZ: -2000 ; size of ships and bullets +WRPDEL: -200 ; time that a warp lasts +WSTRTM: -250 ; time that a warp star lasts +PSTWDL: -200 ; minimum delay until next warp +WPAREA: NOP ; distance warp moves you fudge factor +WRPVEL: SAR 3 ; how fast are you going when you come back +WRPFAC: 2000 ; warp factor -- do you come back? +SHLOC: 40000 ; initial location of ships 1&2 +S3LOC: 70000 ; initial location of ship 3 +SNXLOC: 77777' +SNYLOC: 77777' + ; startup + +; start of program + +STRTUP: JMS LDA% + CLA + DAC SCORE1 + DAC SCORE2 + DAC SCORE3 + LAC [DSTS 2,] ; get scale word + DAC @SCBUFP ; and put it in the main buffer + LAC BUFF2 ; initialize an auto-index register + DAC X0 ; to the second buffer + AND [7777] + XOR [DJMP 10000,] ; form jump to it + DAC @STRPWD ; and put it at the end of the star buffer + LAC [DHLT] ; get a display halt instruction + DAC @BUFF2 ; and put at start of second buffer + LWC 21 + DAC STRTMR ; initialize the star timer + JMS STRSET ; set up the stars + JMP RESTRT ; start a new game + ; start of new game + +RESTRT: LAC [TRNSFS-1] + DAC X5 ; initialize a pointer to working storage + LWC BUFLEN ; get the size of working storage + DAC TEMP0 + CLA ; clear a + DAC @X5 ; zero out working storage + ISZ TEMP0 + JMP .-2 + +; count ships & set up transfer vector + + LWC 1 + DAC UPSCR + LAC [+60000] + DAC SHP1TR ; initialize transfer vector for ships + LAC [+60000] + DAC SHP2TR + LAC SWITCH + AND [1000] ; check for third ship + ASZ + LAC [+60000] + DAC SHP3TR + LAC SWITCH + AND [1000] ; is ship 3 there? + ASZ + COA ;count it if so + CMA ;get negative of count-1 + DAC NSHIP ; and save # of ships + ; set up initial ship locations & orientations + + LAC SHLOC ; get initial ship location + JMS STRTRN ; allow random positions + DAC S1XLOC + JMS STRTRN + DAC S1YLOC + CIA ; set up starting positions + JMS STRTRN + DAC S2XLOC + JMS STRTRN + DAC S2YLOC + CAL ; ship 3 usually starts at x {} 0 + JMS STRTRN + DAC XLOCS+2 + LAC S3LOC + JMS STRTRN + DAC YLOCS+2 + LAC [40000] ; set ship orientations + DAC SHP2AN ; for ship 2 + CIA + DAC SHP1AN ; for ship 1 + LAC [100000] + DAC SHP2AN+1 ; for ship 3 + + LAC FUEL + DAC SHP1FU ; and fuel + DAC SHP2FU + DAC SHP3FU + + LAC BLTNO + DAC SHP1BL ; and bullets + DAC SHP2BL + DAC SHP3BL + LAC SWITCH ; get switches + AND [1000] ; check if ship 3 on + ASN ; if it is not + DAC SHP3BL ; wipe out its bullets + + LAC [S1PIC] ; long skinny rocket + DAC PS1PIC + LAC [S2PIC] ; short fat rocket + DAC PS2PIC + LAC [S3PIC] ; triangular rocket + DAC PS3PIC + + LAC BLTIM + SAL 1 + DAC GAMTIM ; endgame lasts twice as long as a bullet + + LAC BLTVEL ; set bullet velocity + DAC BLTXV ; in appropriate routines + DAC BLTYV + + LAC THRST ; set thrust + DAC THRST1 + JMP NEWPAS ; now start a new pass + +; randomize starting position + +STRTRN: HLT + DAC TEMP0 ; save regular position for now + LAC SWITCH ; get switches + AND [400] ; look at switch 7 + ASN ; if its up, get a random delta + JMP .+4 ; otherwise, skip + JMS RANDM ; get a random number + JMS XCT ; use the magic warp area fudge + WPAREA + ADD TEMP0 ; add to regular start position + JMP @STRTRN ; and return + ; start of new pass + +; restart display +NEWPAS: LAC SCBUFP ; point to scope buffer + DLA ; put address in display program counter + DON ; and start displaying buffer + SSF ; has 40 cycle synch trapped yet? + JMP .-1 ; no, so wait for it + SCF ; clear it again + +; read piano + JMS LDA% + +; read keyboard + KSF + JMP RSTSCP + CLA + KRC + DAC KEYBRD' + SAD [211] + JMP .+3 + SAM [1372] + SAD [20] + JMP @[100] + SAM [236] ; BREAK + ASN + JMS CMDMOD + SAM [77] + SAD [240] + JMP RESTRT + +; reset scope buffers +RSTSCP: LAC OFFS + CIA + ADD @STRPWD + SUB [1] ; set pointer to new scope buffer + AND [7777] ; mask to address only + XOR [30000] + DAC X0 ; initialize index register + +; reset all variables for a new pass + LAC [JMP D477+2] + DAC D477 + + LWC NUMSHP + DAC SHPCNT + + LWC NUMOBJ ; # of things allowed on scope + DAC OBJCNT + + LAC [TRNSFS] ; get a pointer to the transfer vector + DAC TRNSFR + + LAC [XLOCS] + DAC PXLOC + + LAC [YLOCS] + DAC PYLOC + + LAC [XVELS] + DAC PXVEL + + LAC [YVELS] + DAC PYVEL ; reset many pointers for new pass + + LAC [TIMERS] + DAC PTIMR + + LAC [ANGLES] + DAC PANGL + + LAC [ROLLS] + DAC PROLL + + LAC [FUELS] + DAC PFUEL + + LAC [BULLTS] + DAC PBLTS + + LAC [PICTRS] + DAC PPICTR + + LAC [D1276] + DAC PTNXTW + + LAC [WPFACS] + DAC PWPFAC + + LAC [INV] + DAC INVIS + + LAC [INVTMS] + DAC IVTIM + +; determine if game over + LAC NSHIP ; get number of ships + ASM + JMP ENDGAM ; only 1 ship left, so end the game + LAC SHP1BL ; get ship1's bullets + ADD SHP2BL ; add ship2's bullets + ADD SHP3BL ; and ship3's bullets + ASN ; are they all out of bullets? + JMP ENDGAM ; quit if so + ; collision routine + +; check for collisions with other objects + +COLID1: LAC @TRNSFR ; get an entry out of transfer vector + ASN + JMP NEXT ; if zero, go on to next object + ASP + JMP GOTOIT ; if the entry is negative, we're either exploding or warp + LAC TRNSFR ; else, get a pointer to the next entry + DAC X5 ; in the transfer vector + LAC PXLOC ; and a pointer to + DAC X6 ; the x locations + LAC PYLOC ; and the + DAC X7 ; y locations + AND [1777] ; mask off non-address bits + XOR [30000] + SUB [XVELS] ; subtract the end of the table + DAC TEMP0 ; to get the number of entries to check +COLID2: ISZ TEMP0 + JMP .+2 + JMP CHKSUN ; no collisions, so check if we hit the sun + LAC @X5 ; get the next entry in the transfer vector + ASN ; if zero, there's nothing there + JMP D445 ; so bump pointers + ASP ; if its negative, its warping or blowing up + JMP D445 ; so go bump the rest of the pointer + LAC @X6 ; else, get the x location + CIA ; complement it + ADD @PXLOC ; add it to the x loc. of the object we're checking + ASP ; make distance positve + CIA + ADD SHPSIZ ; subtract the size of this object + ASM ; are they close enough? + JMP D446 ; no, so go bump the y loc. pointer and continue + LAC @X7 ; yes, so we must check + CIA + ADD @PYLOC ; if the y locs are as close + ASP ; make distance positive + CIA + ADD SHPSIZ ; subtract object size + ASM ; did they collide? + JMP COLID2 ; no, so go check the next thing on the list + JMP KILL2 ; yes, so go kill both objects + + +D445: ISZ X6 ; bump the x location pointer +D446: ISZ X7 ; bump the y location pointer + JMP COLID2 ; and go check the next object + ; check for collision with sun + +CHKSUN: LAC @PXLOC ; get the x location + SUB SNYLOC ;SUN NOT AT CORNER ANYMORE + ASP ; get positive distance + CIA + DAC TEMP0 ; save it + LAC @PYLOC + SUB SNYLOC ; AGAIN, SUN NOT AT CORNER ANYMORE + ASP ; and ydistance + CIA + ADD TEMP0 ; add the x loc + CLL ; clear link + RAR 1 ; divide sum by 2 + ADD SUNSIZ ; subtract the size of the sun + ASP ; did we hit it? + JMP KILL1 ; yes, so kill us + +;object did not collide with anything + +GOTOIT: LAC @TRNSFR ; get proper routine for this object + AND [3777] ; just the address part + XOR [30000] ; but we are now in high seg! + DAC D466 + JMP @D466 ; and transfer to it +D466: HLT + +; cycle thru each object on screen + +NEXT: ISZ TRNSFR ; point to next object + ISZ PXLOC + ISZ PYLOC + ISZ PXVEL + ISZ PYVEL + ISZ PTIMR + ISZ OBJCNT ; check if we're done + +D477: HLT + JMP FRMSUN ; done, so go form the sun + ISZ PANGL ; the following apply to ships only + ISZ PROLL + ISZ PFUEL + ISZ PBLTS + ISZ PPICTR + ISZ PTNXTW + ISZ PWPFAC + ISZ INVIS + ISZ IVTIM + ISZ SHPCNT + JMP COLID1 + LAC [JMP COLID1] ; check bullets,fuel,etc for rockets only + DAC D477 + JMP COLID1 + ; subroutines to set up explosions +KILL2: LAC X5 ; transfer point to destroy two things at once + DAC TEMP0 + ADD [170] ; get the address of the timer for us + DAC TEMP1 + LAC @TEMP0 ; get the transfer vector entry for this object + AND [74000] ; keep 4 high order bits + ADD [+100000] ; address of explosion routine + DAC @TEMP0 ; and the sign bit to signal were not really there + RAL 3 ; use 4 high order bits + RAL 3 + AND [17] + ADD [3] + CIA ; calculate the time this explosion should last + DAC @TEMP1 ; and put it in the timer cell + LAC @TEMP0 ; get transfer + AND [60000] ; check for a ship + ASZ + ISZ NSHIP ; eliminate it + NOP + +KILL1: LAC @TRNSFR ; transfer point to destroy one thing + AND [74000] ; keep the 4 high order bits + ADD [+100000] ; address of explosion routine + DAC @TRNSFR + RAL 3 ; use 4 high order bits + RAL 3 + AND [17] + ADD [3] + CIA ; get the time for this explosion + DAC @PTIMR ; and put it in the timer cell + LAC @TRNSFR ; see what we are wiping out + AND [60000] ; check for a ship + ASN ; is it a ship? + JMP .+4 ; if not a ship, skip + CLA ; clear a + DAC @PBLTS ; wipe out its bullets + ISZ NSHIP ; count ship blown up + NOP ; prevent randomness + JMP GOTOIT ; and go to it +; form the sun +FRMSUN: CAL ; move to center of screen + LAC SNXLOC ;LOCATION OF SUN + DAC XLOC + LAC SNYLOC ;LOCATION OF SUN + DAC YLOC + JMS SCPMOV ; draw a point in the middle + DAC @X0 ; make it a bright one + DAC @X0 + DAC @X0 + JMS RANDM ; get a random number + AND [77] ; get delta x - delta y parts + IOR [INC E,B00] ; form display instruction to move there + DAC @X0 ; and put in display list + AND [77] ; recover delta parts + DAC TEMP0 ; save them temporarily + SAL 3 ; move to upper inc byte too + SAL 3 + SAL 2 + DAC TEMP1 ; save upper byte deltas + ADD TEMP0 ; recover lower byte part + XOR [INC 344,344] ; turn beam on and draw back thru center + DAC @X0 ; and put in display list + LAC TEMP1 ; get upper byte delta + IOR [INC B00,111] ; draw back to center & exit + DAC @X0 ; and store it in the display list + ; finish off this scope buffer + + LAC [DSTB 3,] ; set up high volt clear command + DAC @X0 ; put it in this buffer + LAC [DHLT] ; now stop the display + DAC @X0 ; and put it at the end of the buffer we just finished + LAC OFFS + CIA ; flip the offset + DAC OFFS + ADD @STRPWD ; and add it to the star buffer trap word + DAC @STRPWD ; so that it points to the buffer we just wrote +; +; + JMS STRMOV ; move the stars + JMP NEWPAS ; start next pass +; +; +; +; update score +ENDGAM: ISZ UPSCR + JMP UPTIME + LAC SHP1TR + ASZ + ASP + JMP .+2 + ISZ SCORE1 + LAC SHP2TR + ASZ + ASP + JMP .+2 + ISZ SCORE2 + LAC SHP3TR + ASZ + ASP + JMP .+2 + ISZ SCORE3 +UPTIME: ISZ GAMTIM ; is the game over yet? + JMP COLID1 ; no, so return + JMP RESTRT ; yes, so restart +; set up the stars +STRSET: 0 + LAC SCBUFP ; point to star buffer + DAC X1 + LAC [DGD] ; get an enter suppressed d grid mode command + DAC @X1 ; put as 1st word of star buffer + LAC [STRTBL-1] ; point to star table + DAC X2 +STR0: LAC @X2 ; pick up x location + ASP ; is it negative? + JMP STR1 + SAL 1 + XOR [DLXA 0,] ; set x location of star + DAC @X1 ; store it in star buffer + LAC @X2 ; get y location + SAL 1 + DAC TEMP0 ; save it temporarily + AND [3777] ; mask to address portion + XOR [DLYA 0,] ; set y location of star + DAC @X1 ; store it in buffer + LAC [DDSP] ; plot star + DAC @X1 + JMP STR0 +STR1: LAC X1 ; get buffer pointer + DAC PSBUF ; save it + LAC STRPWD + AND [7777] + XOR [DJMP 10000,] + DAC @X1 ; store in buffer + JMP @STRSET ; return +; move the stars across the screen +STRMOV: HLT + ISZ STRTMR ; bump star timer + JMP @STRMOV + LWC 4 ; reset timer + DAC STRTMR + LAC SCBUFP ; point to star buffer + IAC ; skip grid command + DAC X1 ; set up index register +STRM1: LAC X1 ; get pointer + DAC X2 ; save another copy + SAM PSBUF ; are we done? + JMP .+2 ; no + JMP @STRMOV ; yes, so return +; + LAC @X1 ; pick up x location + IAC ; bump it + AND [DLXA 3777,] ; preserve instruction format + DAC @X2 ; replace it + ISZ X1 ; skip y location + ISZ X1 ; skip display point + JMP STRM1 + ; buffer + +STRTMR: 000000 +SCNTR: 000000 +PSBUF: 0 +PSTRS: 0 +; . . . . . . . . . . . . . +TEMP0: 0 +TEMP1: 0 +TEMP2: 0 +TEMP3: 0 +OBJCNT: 0 ; +SHPCNT: 0 ; complement of number of ships +GAMTIM: 0 ; timer to time out game +SCBUFP: .SCBUF ; pointer to beginning of scope buffer +STRPWD: .STRPW ; end of the star scope buffer +BUFF1: .BUFF1 ; address of the first shp-blt scope buffer +BUFF2: .BUFF2 ; address of second shp-blt scope buffer +OFFS: BUFSIZ ; offset between buffers +NSHIP: 0 ; number of ships left on the screen +; +UPSCR: -1 ; -1 if score not yet updated for this game +SCORE1: 0 +SCORE2: 0 +SCORE3: 0 +; +; +; transfer vector +; +TRNSFS: BLOCK 30 +SHP1TR=TRNSFS +SHP2TR=SHP1TR+1 +SHP3TR=SHP2TR+1 +TRNEND=TRNSFS+27 +; +; +; x locations of ships and bullets +; +XLOCS: BLOCK 30 +S1XLOC=XLOCS +S2XLOC=S1XLOC+1 +; +; +; y locations of ships and bullets +; +YLOCS: BLOCK 30 +S1YLOC=YLOCS +S2YLOC=S1YLOC+1 +; +; +; x velocity of ships and bullets +; +XVELS: BLOCK 30 +; +; +; y velocities of ships and bullets +; +YVELS: BLOCK 30 +; +; +; +; timers for bullets and ships {warp} time +; +TIMERS: BLOCK 30 +; +; +; . . . . . . . . . . . . . . . . . . . . +; +; the following data is for ships only +; +; angle of ships +; +ANGLES: BLOCK 3 +SHP1AN=ANGLES +SHP2AN=SHP1AN+1 +; +; +; roll of ships +; +ROLLS: BLOCK 3 +; +; +; fuel supply +; +FUELS: BLOCK 3 +SHP1FU=FUELS +SHP2FU=SHP1FU+1 +SHP3FU=SHP2FU+1 +; +; +; bullet supply +; +BULLTS: BLOCK 3 +SHP1BL=BULLTS +SHP2BL=SHP1BL+1 +SHP3BL=SHP2BL+1 +; +; pointer to the pictures of the ships +; +PICTRS: BLOCK 3 +PS1PIC=PICTRS +PS2PIC=PS1PIC+1 +PS3PIC=PS2PIC+1 +; +; +; time untill next warp +; +D1276: BLOCK 3 +; +; +; warp factors +; +WPFACS: BLOCK 3 +; +; invisible flags +INV: BLOCK 3 +; +; invisible timers +; +INVTMS: BLOCK 3 +; +; +; +; . . . . . . . . . . . . . . . . . . . . . +; +; +; pointers to the above buffer +; +; +BUFLEN=253 ; length of working storage +TRNSFR: 000000 +PXLOC: 000000 +PYLOC: 000000 +PXVEL: 000000 +PYVEL: 000000 +PTIMR: 000000 +PANGL: 000000 +PROLL: 000000 +PFUEL: 000000 +PBLTS: 000000 +PPICTR: 000000 +PTNXTW: 000000 +PWPFAC: 000000 +INVIS: 0 +IVTIM: 0 + ; general ship routines +; +S1STRT: LAC SWITCH ; get the buttons + RAR 3 ; for ship 1 + RAR 2 + JMP SRTN1 +S2STRT: LAC SWITCH ; get the buttons + JMP SRTN1 +S3STRT: LAC SWITCH ; get the buttons + RAL 3 ; for ship 3 + RAL 3 + RAL 2 +SRTN1: AND [170000] + DAC BUTTNS + LAC [NOP] ; get a nop instruction and put it + DAC D1475 ; in such a place as not to print a jet on the rocket + ISZ @PTIMR ; increment the bullets interval timer + NOP + ISZ @PTNXTW ; and the time until next warp + NOP +; +; check for warp +; + LAC BUTTNS + AND [160000] ; look at both rolls & thrust + SAM [140000] ; warping if both rolls & no thrust + JMP CHKINV ; otherwise check for invisibility + LAC @PTNXTW + ASP ; check if we can warp yet + JMP CALANG ; no, so skip + LAC @TRNSFR + DAC @PTNXTW ; if so save our old transfer point + LAC [+100000] ; get address of warp routine + DAC @TRNSFR ; put it in the transfer table + LAC WRPDEL ; warp time + DAC @PTIMR + JMP NEXT ; and return +; +; check for invisibility +; +CHKINV: ISZ @IVTIM ; increment the time since we last changed invisibility + NOP + SAM [160000] ; invisibility if both rolls & thrust on + JMP INV1 ; exit if not + LAC @IVTIM ; get the timer + ASP ; can we change yet + JMP CALANG ; no, so skip + LWC 30 ; get a new timer of one second + DAC @IVTIM ; and replace the old one + LAC @INVIS ; get the old invisible flag + XOR [1] ; change it's state + DAC @INVIS ; and replace it +INV1: LAC BUTTNS ; restore push buttons + ; +; calculate roll +; +CALROL: AND [140000] ; check if either roll is on + ASN ; one is, so continue + JMP CRL1 ; neither is + ASM ; which roll is it? + JMP .+3 + LAC ROLL ; get left roll constant + JMP .+3 + LAC ROLL ; get roll constant + CIA ; complement it for right roll +CRL1: DAC RTEMP ; save it temporarily + ADD @PROLL ; add the previous roll + DAC @PROLL ; to get the new roll + LAC SWITCH + AND [4000] ; is spin on? + ASZ + JMP CALANG ; exit if so + LAC RTEMP ; get the roll back + SAL 3 ; make it reasonable + SAL 2 + DAC @PROLL ; put it in roll slot + JMP CALANG ; go calculate ship angle +; +RTEMP: 0 +BUTTNS: 0 +; +; +; calculate angle +; +; +CALANG: LAC @PANGL ; get the old angle + ADD @PROLL ; and add the roll + DAC @PANGL ; to get the new angle + JMS SINCOS ; get the sin and cos of the angle + JMS GRVITY ; and get the effect of gravity on this ship + ; +; +; check for firing +; +; + LAC @PFUEL + ASM ; check if we have fuel + JMP UPDAT + LAC BUTTNS + RAL 2 + ASM ; and that we are firing + JMP UPDAT + LAC COSINE ; get the cosine of the angle of the ship + JMS THRUST ; calculate thrust + ADD XGRAV ; add the effect of gravity + DAC XGRAV ; to get a composite effect on the x velocity + LAC SINE ; get the sine of the angle of the ship + JMS THRUST ; calculate thrust + ADD YGRAV + DAC YGRAV ; to get the effect on y velocity + LAC [JMP D1475+2] ; put a skip instruction in + DAC D1475 ; d1475 to print a jet on the rocket + ISZ @PFUEL ; decrement the amount of fuel left + NOP + ; +; cycle velocity and acceleration +; +; +UPDAT: LAC XGRAV + ADD @PXVEL ; update x velocity + DAC @PXVEL + SAR 3 + ADD @PXLOC ; and x location + DAC @PXLOC + LAC YGRAV + ADD @PYVEL ; and y velocity + DAC @PYVEL + SAR 3 + ADD @PYLOC ; and y location + DAC @PYLOC + LAC SINE + SAR 3 + SAR 3 + SAR 1 + DAC SIN1 + CIA + DAC MSIN1 + DAC MSIN2 + LAC COSINE + SAR 3 + SAR 3 + SAR 1 + DAC COS1 + CIA + DAC MCOS1 + DAC MCOS2 + ADD MSIN1 + DAC MSNMC2 ; -sin-cos + DAC MSNMCS ; minus sin minus cos + LAC SIN1 + ADD MCOS1 + DAC SINMCS ; sin-cos + CIA + DAC CSMSIN ; cos-sin + LAC COSINE + SAR 3 + ADD @PXLOC + DAC XFRONT + LAC SINE + SAR 3 + ADD @PYLOC + DAC YFRONT + JMS DRWSHP ; draw ship +D1475: HLT ; we put a skip here if we are firing our rocket + JMP FIRBLT ; else, go check for firing bullets + ; print jet on rocket +; + JMS RANDM + RAL 3 + RAL 2 + IOR [177760] + DAC TEMP0 + LAC COSINE + CIA + SAR 3 + SAR 3 + DAC MCOS1 + LAC SINE + CIA + SAR 3 + SAR 3 + DAC MSIN1 +PJET1: LAC XLOC + ADD MCOS1 + DAC XLOC + LAC YLOC + ADD MSIN1 + DAC YLOC + JMS SCPMOV + ISZ TEMP0 + JMP PJET1 +; check for bullets +; +FIRBLT: LAC BUTTNS ; get the buttons + RAL 3 + ASM ; check if we are firing bullets + JMP NEXT ; if not, go on to next object + LAC @PTIMR + ASP ; check if we can fire a bullet yet + JMP NEXT + LAC @PBLTS + ASM ; check if in fact we have any bullets to fire + JMP NEXT +; +; look for a free slot in the transfer vector +; + LAC [TRNEND] ; load a lac from the last entry in the transfer vect + DAC FIRTMP ; stick it in the next location +FIR1: LAC @FIRTMP + ASN ; did we find an empty slot + JMP FIR2 ; yes so go set it up + LWC 1 ; no, so we must get a minus 1 + ADD FIRTMP ; and decrement the instruction + SAM [SHP3TR] ; is transfer vector full? + JMP .+2 + JMP NEXT ; yes, so no more bullets + DAC FIRTMP ; no, so restore our new instruction + JMP FIR1 ; nad look some more + ; +; +FIRTMP: 0 +; +FIR2: LAC [+14000] ; get a pointer to the bullet routine + DAC @FIRTMP ; and put it in the transfer vector + LAC FIRTMP + ADD [NUMOBJ] + DAC TEMP0 ; get a pointer to the xloc + ADD [NUMOBJ] + DAC TEMP1 ; and the yloc + ADD [NUMOBJ] + DAC TEMP2 ; and the x velocity + ADD [NUMOBJ] + DAC TEMP3 ; and the y velocity + ADD [NUMOBJ] + DAC FIRTMP ; also get a pointer to the timer + LAC COSINE + SAR 2 + ADD @PXLOC + DAC @TEMP0 ; generate the x location + LAC SINE + SAR 2 + ADD @PYLOC + DAC @TEMP1 ; and the y location + LAC COSINE +BLTXV: HLT ; velocity adjustment will be deposited here + ADD @PXVEL + DAC @TEMP2 ; the x velocity + LAC SINE +BLTYV: HLT ; velocity adjustment will be deposited here + ADD @PYVEL + DAC @TEMP3 ; and the y velocity + LAC BLTIM ; get the time that bullets last + DAC @FIRTMP ; and put it in the timer + LAC BLTINT ; bullet interval + DAC @PTIMR ; put it in the ships timer + ISZ @PBLTS ; decrement the number of bullets + JMP NEXT + JMP NEXT ; and return +; warp routines +WRPOUT: ISZ @PTIMR ; is it time to come back yet??? + JMP NEXT ; no, so return + LAC [+60000] ; yes, get the address of the warp star routine + DAC @TRNSFR ; and put it in the transfer vector + LAC WSTRTM ; and the time that a warp star lasts + DAC @PTIMR ; put it in the timer + JMS RANDM ; get a random number + JMS XCT ; modify it with the magic warp area constant + WPAREA + ADD @PXLOC ; add the previous x location + DAC @PXLOC ; get a random x location + JMS RANDM + JMS XCT ; do the same for y location + WPAREA + ADD @PYLOC + DAC @PYLOC + JMP NEXT ; go on to next object + ; +; make warp star +; +MKWSTR: LAC @PTIMR ; get warp timer + AND [4] ; check bits + ASZ ; blink warp star + JMP MKW1 + LAC @PXLOC + DAC XLOC ; get the x loc + LAC @PYLOC + DAC YLOC ; and y loc + JMS SCPMOV ; and put the star on the scope + LAC [DJMS WRPSTR,] ; get a jump to its picture + DAC @X0 ; and put it in the buffer +MKW1: ISZ @PTIMR ; increment the warp star timer + JMP NEXT ; and return if non-zero + LAC @PWPFAC ; if zero, get the old warp factor + ADD WRPFAC ; add the warp constant + DAC @PWPFAC ; to get a new warp factor + JMS RANDM ; get a random number + ASM + CIA ; make sure we have a negative number + ADD @PWPFAC ; add the warp factor + ASM ; if it's still negative, we made it + JMP WRPKIL ; we didn't come back so blow up + LAC @PTNXTW ; we survived ! ! ! + DAC @TRNSFR ; so restore the old transfer vector entry + JMS RANDM ; get a random number + JMS XCT ; for the x velocity + WRPVEL + DAC @PXVEL + JMS RANDM + JMS XCT + WRPVEL + DAC @PYVEL ; and the y velocity + LAC RND + DAC @PANGL ; get a new angle + RAL 2 + SAR 3 + SAR 1 + DAC @PROLL ; and a new roll + LAC PSTWDL ; time until possible next warp + DAC @PTNXTW ; put it in the time until next warp + JMP NEXT ; and return +; +; set up for explosion +; +WRPKIL: LAC [+160000] ; put the address of explosion + DAC @TRNSFR ; routine in the transfer vector + LWC 21 ; get the time an explosion lasts + DAC @PTIMR ; and put it in the timer slot + ISZ NSHIP ; count ships + NOP + JMP NEXT ; and return +; +WRPSTR: INC E,D11 + INC BM2M2,D02 + INC B2M2,151 ; warp star picture + ; bullet management routine +; +BLTRTN: JMS GRVITY + LAC XGRAV ; get the effect of gravity on the x velocity + ADD @PXVEL + DAC @PXVEL ; and replace the old x velocity + SAR 3 + ADD @PXLOC + DAC @PXLOC ; also update the x location + DAC XLOC + LAC YGRAV ; do the same for y velocity and location + ADD @PYVEL + DAC @PYVEL + SAR 3 + ADD @PYLOC + DAC @PYLOC + DAC YLOC + JMS SCPMOV ; put the point on the screen + DAC @X0 ; and again to double intensity + ISZ @PTIMR ; increment the bullet timer + JMP NEXT + JMP KILL1 ; and destroy it if it times out +; calculate thrust +; +THRUST: HLT + SAR 3 + SAR 3 + SAR 0 +THRST1: HLT ; thrust adjustment will be deposited here + JMP @THRUST ; return + ; explosion routine +; +BLOWUP: LAC @TRNSFR + AND [60000] ; is this a ship? + ASZ + JMP BLWSHP ; yes, so handle special +; + LAC @PXLOC ; blow up bullets + DAC XLOC + LAC @PYLOC + DAC YLOC ; get position + JMS SCPMOV ; draw it + DAC @X0 ; brighter + DAC @X0 ; and brighter still + DAC @X0 +; +BL1: ISZ @PTIMR ; when timer times out + JMP NEXT + CLA + DAC @TRNSFR ; zero out transfer vector slot + JMP NEXT +; +BLWSHP: LWC 10 ; draw ship explosion + DAC TEMP0 ; save # of points to draw + JMS RANDM + AND [3500] ; get random y-delta + DAC TEMP1 ; save it + JMS RANDM ; now for xloc + AND [3500] ; get random x-delta + DAC TEMP2 ; save it +BLWSH1: ADD @PXLOC ; add xloc of ship + DAC XLOC + LAC TEMP1 + ADD @PYLOC ; add yloc of ship + DAC YLOC + JMS SCPMOV ; plot the point + LAC @PYLOC + SUB TEMP1 ; draw opposite corner + DAC YLOC + JMS SCPMOV ; plot the point + LAC TEMP2 ; pick up x-delta + CIA ; complement it + DAC TEMP2 ; replace it + ASP + JMP BLWSH1 ; and draw the opposite diagonal points + ISZ TEMP0 ; have we drawn enough points? + JMP BLWSHP+2 ; no, so loop + JMP BL1 + ; draw a ship on the scope + +DRWSHP: 0 + + LWC 1 ; -1 - drawing left half + DAC TEMP0 ; 0 - drawing right half + +DRW1: DAC TEMP2 ; initial one-level pdl + ADD @PPICTR ; point at picture - 1 in + DAC X5 ; auto - index register + +; set up xloc and yloc with x,y of front of ship + SET XLOC,XFRONT + SET YLOC,YFRONT + +; set up word of picture +DRW2: LAC @X5 ; get next word of picture description + CLL + RAL 1 ; throw away bit 0 as we are working with 15 bits + DAC TEMP1 ; save as current word + +; dispatch on next three bits of word +DRW3: LAC TEMP1 + RAL 3 ; bring left-most 3 bits into rightmost + DAC TEMP1 ; save + RAL 1 ; one more bit (remember link?) + AND [7] ; get 3 high order bits + ADD [JMP D2016] ; form a jump instruction + DAC DRW4 ; and put it out to execute +; clear 3 lower bits -- when word is zero we will exit + LAC TEMP1 + AND [177770] ; clear lower bits + DAC TEMP1 ; and save it + +; dispatch with jump instruction generated +DRW4: HLT ; execute the jump instruction we generated +D2016: JMP DRW2 ; 0 - next word + JMP DRAW.1 ; 1 - draw a point straight down + JMP DRAW.2 ; 2 - draw a point to the left + JMP DRAW.3 ; 3 - draw a point diagonally down to the left + JMP DRAW.4 ; 4 - draw a point to the right + JMP DRAW.5 ; 5 - draw a point diagonally down to the right + JMP SAVPTR ; 6 - push or pop one level pdl + ISZ TEMP0 ; 7 - end of half + JMP @DRWSHP ; wasn't -1, so been through once, done now + +; prepare to draw other half of ship + SETN MSIN2,MSIN2 + SETN MCOS2,MCOS2 + SETN SIN1,SIN1 + SETN COS1,COS1 + SET ARITH3,MSNMCS + SET MSNMCS,SINMCS + SET SINMCS,ARITH3 + SET ARITH3,MSNMC2 + SET MSNMC2,CSMSIN + SET CSMSIN,ARITH3 + LWC 1 + JMP DRW1 ; loop + +; draw a point straight down +DRAW.1: LAC XLOC + ADD MCOS1 + DAC XLOC + LAC YLOC + ADD MSIN1 + JMP ICHK + +; draw a point to the left +DRAW.2: LAC XLOC + ADD MSIN2 + DAC XLOC + LAC YLOC + ADD COS1 + JMP ICHK + +; draw a point diagonally down and left +DRAW.3: LAC XLOC + ADD MSNMCS ; -sim-cos + DAC XLOC + LAC YLOC + ADD CSMSIN + JMP ICHK + +; draw a point to the right +DRAW.4: LAC XLOC + ADD SIN1 + DAC XLOC + LAC YLOC + ADD MCOS2 + JMP ICHK + +; draw a point diagonally down and right +DRAW.5: LAC XLOC + ADD SINMCS + DAC XLOC + LAC YLOC + ADD MSNMC2 ; -sin-cos + JMP ICHK + +; push or pop one level pdl +SAVPTR: ISZ TEMP2 ; if -1, push + JMP D2140 +; push + SET TEMP2,XLOC + SET TEMP3,YLOC + JMP DRW3 ; exit to next byte +; pop +D2140: LWC 1 + ADD TEMP2 + DAC XLOC ; x + SET YLOC,TEMP3 + LWC 1 ; reset temp2 + DAC TEMP2 + JMP DRW3 ; exit to next byte + +; output y value and then output DLXA,DLYA +ICHK: DAC YLOC + LAC @INVIS ; get invisibility + ASN ; don't draw if we're invisible + JMS SCPMOV ; put out DLXA,DLYA + JMP DRW3 + ; variables for ship drawing routine + +XFRONT: 0 ; x front of ship +YFRONT: 0 ; y front of ship +MCOS1: 0 ; -cosine +MSIN1: 0 ; -sin +MCOS2: 0 ; -cosine +MSIN2: 0 ; -sin +COS1: 0 ; cosine +SIN1: 0 ; sin +MSNMCS: 0 ; -sin - cosine +MSNMC2: 0 ; -sin - cosine +CSMSIN: 0 ; cosine - sin +SINMCS: 0 ; sin - cosine + +; * ship pictures * + +; needle ship +S1PIC: 11113 + 11111 + 11111 + 11111 + 11633 + 11111 + 14611 + 11111 + 14700 + +; stubby ship +S2PIC: 11311 + 31131 + 11116 + 31313 + 11111 + 61151 + 11163 + 33651 + 14700 + +; triangle ship +S3PIC: 31131 + 13113 + 11311 + 63333 + 33334 + 44444 + 44444 + 46555 + 55555 + 22270 + ; gravity subroutines + +GRVITY: 0 + LAC SWITCH ; get the switches + RAL 3 ; check if gravity is on + RAL 2 + ASM ; it is if switch is down + JMP GRAV0 ; yes, so calculate it + CLA ; otherwise, + DAC XGRAV ; let the effect of gravity be zero + DAC YGRAV + JMP @GRVITY ; and return + +; calculate X=|x|**2 +GRAV0: LAC @PXLOC ; get x location + SUB SNXLOC ;LOCATION OF SUN + JMS SHIFT ; shift it down + DAC GRAV2 + JMS MUL ; square it +GRAV2: 0 ; x location + LAC ARITH0 ; get x~2 + DAC TEMP0 ; save it + +; calculate Y=|y|**2 + LAC @PYLOC ; get y location + SUB SNYLOC ;LOCATION OF SUN + JMS SHIFT ; shift it down + DAC GRAV3 ; save it + JMS MUL ; square it +GRAV3: 0 ; y location + LAC ARITH0 ; get y~2 + +; X+Y + ADD TEMP0 ; get x~2 + y~2 +; SAR 3 + SAR 3 ; shift it down + DAC GRAV1 ; save it + +; G = g/((X+Y)/100) + LAC GRAV ; g - gravity constant + JMS DIV +GRAV1: 0 ; X+Y + LAC ARITH1 ; pick up the quotient + DAC GRAV4 ; save total gravity effect + +; Gx + LAC GRAV2 ; load shifted x loc + JMS MUL +GRAV4: 0 ; G = g/((X+Y)/100) + +; Gx/(x+y) + LAC GRAV2 ; get shifted x loc + ADD GRAV3 ; add shifted y loc + DAC GRAV5 ; save it + LAC ARITH0 ; get x loc . total gravity effect + JMS DIV ; by abs(x)+abs(y) +GRAV5: 0 ; x+y + LAC ARITH1 ; pick up quotient + DAC XGRAV ; save x gravity effect + LAC @PXLOC ; make it right sign + ASM + JMP .+4 + +; x effect and y effect = G + LAC XGRAV + CIA + DAC XGRAV +; y effect = G - x effect + LAC GRAV4 ; get the total gravity effect + SUB ARITH1 ; subtract xgravity portion + DAC YGRAV ; save y gravity effect + LAC @PYLOC ; make it right sign + ASM + JMP @GRVITY + LAC YGRAV + CIA + DAC YGRAV + JMP @GRVITY ; return + +; variables for gravity routine +XGRAV: 0 +YGRAV: 0 + +; * shift right 9 bits * + +SHIFT: HLT ; routine to shift right 9 + ASP ; make positive before shift + CIA + SAR 3 + SAR 3 + SAR 3 + JMP @SHIFT + ; * sine - csine routine * + +SINCOS: 0 ; angle entered in ac + CLA ; clear signs + DAC SSIGN + DAC CSIGN + LAC @PANGL ; get angle + ASM ; is it negative? + JMP .+3 + ISZ SSIGN ; yes, so signal sine will be negative + CMA ; make it positive + AND [40000] ; is it in second or third quadrant? + ASZ + ISZ CSIGN ; yes, so signal cosine will be negative + + LAC @PANGL ; get the angle again + AND [77777] ; reduce to quadrants 1 & 2 + DAC TEMP0 ; save it + AND [40000] ; is it in second quadrant? + ASZ + JMP .+3 + LAC TEMP0 ; no, so reload absolute angle + JMP .+3 ; and skip + LAC [101777] ; yes, so reverse measurement + SUB TEMP0 + + RAL 3 ; get important bits + RAL 3 + RAL 1 + AND [37] + DAC TEMP0 + ADD [SINTAB] ; look up address in sine table + DAC TEMP1 ; save address + LAC @TEMP1 ; pick up value + DAC SINE ; save as sine + LAC SSIGN ; check if it should be neg. + ASN + JMP .+4 + LAC SINE ; yes, so negate it + CIA + DAC SINE + + LAC [COSTAB] ; get cosine table address + SUB TEMP0 ; get appropriate address + DAC TEMP1 ; save address + LAC @TEMP1 ; pick up value + DAC COSINE ; save as our cosine + LAC CSIGN ; should it be neg.? + ASN + JMP @SINCOS ; no, so return + LAC COSINE ; yes, so negate it + CIA + DAC COSINE + JMP @SINCOS ; and now return + ; * sin - cosine table * + +SINTAB: 0 ; table of 1-quadrant sines reading down + 1442 + 3075 + 4510 + 6075 + 7423 + 10705 + 12112 + 13236 + 14272 + 15231 + 16066 + 16616 + 17235 + 17541 + 17727 +COSTAB: 20000 ; table of 1-quadrant cosines reading up + +; variables for sin-cosine routine +SINE: 0 +COSINE: 0 +SSIGN: 0 +CSIGN: 0 + +; * input reader * + +LDA%: 0 + CLA + DAC MOUSE1 + RAL 3 + RAL 1 + AND [360] + DAC MSETMP + CLA + LDA + CMA + DAC SWITCH + AND [1000] + ASZ + JMP MSEOR + LAC MSETMP + RAL 3 + RAL 3 + RAL 2 + DAC MSETMP +MSEOR: LAC MSETMP + IOR SWITCH + DAC SWITCH + JMP @LDA% + +; input variables +SWITCH: 0 +MOUSE1: 0 +MSETMP: 0 + ; * multiply and divide routines * + +ARITH0: 0 ; fakes mq register +ARITH1: 0 ; temp storage for arith routines +ARITH2: 0 +ARITH3: 0 + +; multiply routine +MUL: 0 + ASP ; everything should be + + CIA + DAC ARITH1 ; store multiplier + LAC @MUL ; get the multiplicand + ISZ MUL ; bump the return + ASP + CIA + DAC ARITH3 ; store it + CLA + DAC ARITH0 +MUL1: LAC ARITH1 + ASN + JMP @MUL + CLL + RAR 1 + DAC ARITH1 + LSN + JMP MUL2 + LAC ARITH0 + ADD ARITH3 + DAC ARITH0 +MUL2: LAC ARITH3 + SAL 1 + DAC ARITH3 + JMP MUL1 + +; divide routine +DIV: 0 + ASP ; make dividend positive + CIA + DAC ARITH0 ; store dividend + LAC @DIV ; get the divisor + ISZ DIV ; bump return + ASP ; make it positive + CIA + DAC ARITH2 ; store divisor + ASZ + JMP .+4 + LAC ARITH0 + DAC ARITH1 + JMP @DIV + CLA + DAC ARITH1 + DAC ARITH3 + LAC ARITH2 + SUB ARITH0 + ASM + JMP .+6 + LAC ARITH2 + SAL 1 + DAC ARITH2 + ISZ ARITH3 + JMP .-7 + LAC ARITH3 + IAC + CMA + DAC ARITH3 +DIV1: ISZ ARITH3 + JMP .+2 + JMP @DIV + LAC ARITH0 + SUB ARITH2 + ASM + DAC ARITH0 + RAL 1 + CML + LAC ARITH1 + RAL 1 + DAC ARITH1 + LAC ARITH2 + SAR 1 + DAC ARITH2 + JMP DIV1 + ; * fake xct instruction * + +XCT: 0 + DAC ARITH3 ; save accumulator + LAC @XCT ; pick up instruction address + DAC XCT1 ; save it + LAC @XCT1 ; pick up actual instruction + DAC XCT1 ; save it + LAC ARITH3 ; reload accumulator + ISZ XCT ; bump return +XCT1: HLT ; to be replaced with xct instruction + JMP @XCT ; return + +; * random number generator * + +RANDM: 0 + LAC [135243] ; get some random bits + XOR RND ; xor with the last random number we generated + RAR 2 + ADD RND ; and add the old number to get + DAC RND ; a new random number + JMP @RANDM ; and return + +RND: 0 ; random number seed + +; * scope locate routine * + +; moves the scope pointer to the x and y locs +; specified in xloc and yloc and puts out a dot + +SCPMOV: 0 + LAC XLOC + RAR 3 + RAR 2 + AND [3777] ; delete random bits + XOR [DLXA 2000,] ; set x location + DAC @X0 + + LAC YLOC + RAR 3 + RAR 2 + AND [3777] ; delete random bits + XOR [DLYA 2000,] ; set y location + DAC @X0 + + LAC [DDSP] ; plot the point + DAC @X0 + JMP @SCPMOV ; return + +; arguments to scpmov +XLOC: 0 +YLOC: 0 + +; * star table * + +STRTBL: + 1777?561?1722?101515?1712?1677?1712?105 + 1656?452?1441?402?1410?1240?1357?732 + 1267?1247?1226?414?1210?1723?1076?472 + 1026?1522?734?1161?712?211?706?1305 + 655?402?642?411?631?1657?627?1075 + 623?1716?560?225?547?1064?451?1277 + 404?662?335?336?323?1266?272?233 + 222?776?174?1100?165?257?164?1335 + 157?120?115?31?60?454?40?1302 + 21?1124?177735?1670 +ENDSTR=. ; end of star table + + +CMDMOD: 0 +DISP: LAC [S1SCR-1] + DAC X4 + LAC SCORE1 + JMS NUMDIS + LAC [S2SCR-1] + DAC X4 + LAC SCORE2 + JMS NUMDIS + LAC [S3SCR-1] + DAC X4 + LAC SCORE3 + JMS NUMDIS + + LAC SWITCH + AND [1000] + ASZ + LAC [DNOP] + DAC S3BLOC + + LAC [CMDDIS] + DLA + DON + SSF + JMP .-1 + SCF + + KSF + JMP DISP + CLA + KRC + AND [3777] + + SAM [236] ; BREAK + ASN + JMP @CMDMOD + SAD [211] + JMP .+3 + SAM [1372] + SAD [20] + JMP @[100] + SAD [27] + JMP .+3 + SAM [362] + JMP .+5 + CLA + DAC SCORE1 + DAC SCORE2 + DAC SCORE3 + + JMP DISP + +CMDDIS: DSTS 2 + DSTB 0 + DADR + DGD +; display scores + DLXA 300 + DLYA 1440 +S1SCR: DNOP + DNOP + DNOP + DLXA 300 + DLYA 1240 +S2SCR: DNOP + DNOP + DNOP + +; display ships + DSTS 0 + DSTB 3 + DLXA 200 + DLYA 1400 + DJMS SHIP1 + DLXA 200 + DLYA 1200 + DJMS SHIP2 +S3BLOC: DNOP + DLXA 200 + DLYA 1000 + DJMS SHIP3 +; score for 3 + DSTS 2 + DSTB 0 + DLXA 300 + DLYA 1040 +S3SCR: DNOP + DNOP + DNOP + DHLT + +SHIP1: DLV B,-20.,0 + DLV B,0,170. + DLV B,10.,30. + DLV B,10.,-30. + DLV B,0,-170. + DLV B,10.,0 + DLV B,0,40. + DLV B,-10.,10. + DLV D,-20.,0 + DLV B,-10.,-10. + DLV B,0,-40. + DLV B,10.,0 + DRJM + +SHIP2: DLV B,-20.,0 + DLV B,0,20. + DLV B,-10.,30. + DLV B,0,50. + DLV B,10.,40. + DLV B,10.,20. + DLV B,10.,-20. + DLV B,10.,-40. + DLV B,0,-50. + DLV B,-10.,-30. + DLV B,0,-20. + DLV D,0,20. + DLV B,20.,-20. + DLV B,10.,0 + DLV B,0,30. + DLV B,-20.,20. + DLV D,-40.,0 + DLV B,-20.,-20. + DLV B,0,-30. + DLV B,10.,0 + DLV B,20.,20. + DRJM + +SHIP3: DLV D,10.,0 + DLV B,-50.,60. + DLV B,-50.,-60. + DLV B,160.,0 + DLV B,-50.,60. + DLV B,-50.,-60. + DLV D,-10.,60. + DLV B,30.,100. + DLV B,30.,-100. + DRJM + +NUMDIS: 0 + DAC TNUM' + CLA ; in 4 decimal digits + DAC DFLAG' ; zero to kill leading zeros + LWC 3 + DAC LOOPIN' ; set 4 decimal digits + LAC [SUBT] + DAC SUBPNT' ; set subtract pointer for base conversion + +GOZAP: LAC LOOPIN + IAC + ASN + ISZ DFLAG + CLA + XAM TNUM ; load buffer size +SUBR: SUB @SUBPNT ; divide loop for base conversion + ASP + JMP .+3 + ISZ TNUM ; increment digit count + JMP SUBR + ADD @SUBPNT ; restore + XAM TNUM ; load digit, store dividend + ASZ ; is digit zero? + JMP NONA ; no + SAM DFLAG ; suppress zeros? + JMP NONA+1 + LAC [DNOP] + DAC @X4 ; kill the digit! + JMP WHAMZ + +NONA: ISZ DFLAG + ADD @[31] ; get address of proper djmp + ADD [20] + DAC GRAB' + LAC @GRAB + DAC @X4 ; put it out in the display list +WHAMZ: ISZ SUBPNT ; advance subpointer + ISZ LOOPIN ; check for all four digits + JMP GOZAP ; continue to continue + JMP @NUMDIS ; exit + +SUBT: 100. + 10. + 1. + ; variables and constants (before buffer) + + VARIABLES + CONSTANTS + +BUFSIZ=2000 + +; scope buffers +.SCBUF: BLOCK 300 ; start of scope buffers +.STRPW: 0 ; star trap word +.BUFF1: BLOCK BUFSIZ ; first buffer +.BUFF2: BLOCK BUFSIZ-1 ; second buffer +BUFEND=. + + END STRTUP +  \ No newline at end of file