spacewar 3.1 24 sep 62 pt. 2 /main control routine for spaceships nob=30 /total number of colliding objects ml0, load .mtc, -4000 /delay for loop init ml1, mtb /loc of calc routines add (nob dap mx1 / nx1=mtb nob add (nob dap my1 / y ny1=nx1 nob add (nob dap ma1 / count for length of explosion or torp na1=ny1 nob add (nob dap mb1 / count of instructions taken by calc routine nb1=na1 nob add (nob dac .mdx / dx ndx=nb1 nob add (nob dac .mdy / dy ndy=ndx nob add (nob dap mom /angular velocity nom=ndy nob add (2 dap mth / angle nth=nom 2 add (2 dac .mfu /fuel nfu=nth 2 add (2 dac .mtr / no torps remaining ntr=nfu 2 add (2 dap mot / outline of spaceship not=ntr 2 add (2 dap mco / old control word nco=not 2 add (2 dac .mh1 nh1=nco 2 add (2 dac .mh2 nh2=nh1 2 add (2 dac .mh3 nh3=nh2 2 add (2 dac .mh4 nh4=nh3 2 nnn=nh4 2 law ss1 xor mtb sza jmp mdn law ss2 xor mtb 1 sza jmp mdn law 1 / test if both ships out of torps add ntr spa jmp md1 law 1 add ntr 1 spa i jmp mdn md1, xct tlf / restart delay is 2X torpedo life sal 1s dac .ntd jmp ml1 mdn, count .ntd,ml1 stf 1 stf 2 law ss1 xor mtb sza clf 1 sza i idx .1sc law ss2 xor mtb 1 sza clf 2 sza i idx .2sc clf 2 jmp a a1, law mg2 / test word control dac .cwg jmp a a40, law cwr / here from start at 4 dac .cwg jmp a6 a, lac .gct sma jmp a5 count .gct, a5 lac .1sc sas .2sc jmp a4 law i 1 dac .gct a5, lat and (40 sza i jmp a2 a4, lac .1sc lio .2sc hlt lat and (40 sza jmp a2 dzm .1sc dzm .2sc a6, lat rar 6s and (37 sza cma dac .gct a2, clear mtb, nnn-1 / clear out all tables law ss1 dac mtb law ss2 dac mtb 1 lac (200000 dac nx1 dac ny1 cma dac nx1 1 dac ny1 1 lac (144420 dac nth law nnn / start of outline program dac not lio ddd spi i jmp a3 jda oc / compile outline ot1 a3, dac not 1 jda oc ot2 xct tno dac ntr dac ntr 1 lac foo dac nfu dac nfu+1 law 2000 dac nb1 dac nb1 1 xct mhs dac nh2 dac nh2 1 jmp ml0 / control word get routines mg1, dap mg3 cli iot 11 mg3, jmp . mg2, dap mg4 lat swap mg4, jmp . ml1, lac . / 1st control word sza i / zero if not active jmp mq1 / not active swap idx .moc spi jmp mq4 law 1 add ml1 dap ml2 law 1 add mx1 dap mx2 law 1 add my1 dap my2 law 1 add ma1 dap ma2 law 1 add mb1 dap mb2 mot, lac . dap sp5 ml2, lac . / 2nd control word spq / can it collide? jmp mq2 / no mx1, lac . / calc if collision mx2, sub . / delta x spa / take abs val cma dac .mt1 sub me1 / < EPSILON ? sma jmp mq2 / no my1, lac . my2, sub . spa cma sub me1 / < epsilon ? sma jmp mq2 / no add .mt1 sub me2 sma jmp mq2 lac (mex 400000 / yes, EXPLODE dac i ml1 / replace calc routine with explosion dac i ml2 lac i mb1 / duration of explosion mb2, add . cma sar 8s add (1 ma1, dac . ma2, dac . mq2, idx mx2 / end of comparison loop idx my2 idx ma2 idx mb2 index ml2, (lac mtb nob, ml2 mq4, lac i ml1 / routine for calculating spaceship dap . 1 / or other object and displaying it jsp . mb1, lac . / alter count of number of instructions add .mtc dac .mtc mq1, idx mx1 / end of comparison and display loop idx my1 idx ma1 idx mb1 idx .mdx idx .mdy idx mom idx mth idx .mas idx .mfu idx .mtr idx mot idx mco idx .mh1 idx .mh2 idx .mh3 idx .mh4 index ml1, (lac mtb nob-1, ml1 lac i ml1 / display and compute last point sza i / if active jmp mq3 dap . 1 jsp . lac i mb1 add .mtc dac .mtc mq3, background / display stars of the heavens jsp blp / display massive star count .mtc, . / use up rest of time of main loop jmp ml0 / repeat whole works / misc calculation routines / explosion mex, dap mxr cla diff .mdx, mx1, (sar 3s cla diff .mdy, my1, (sar 3s law mst dap msh lac i mb1 / time involved cma cli-opr sar 3s dac .mxc ms1, sub (140 sma idx msh mz1, random and (777 ior (scl dac mi1 random scr 9s sir 9s msh, xct . mi1, hlt add i my1 swap add i mx1 dpy-i 300 count .mxc, mz1 count i ma1, mxr dzm i ml1 mxr, jmp . mst, scr 1s scr 3s / torpedo calc routine tcr, dap trc count i ma1, tc1 lac (mex 400000 dac i ml1 law i 2 dac i ma1 jmp trc tc1, lac i mx1 sar 9s xct the diff .mdy, my1, (sar 3s sar 9s xct the diff .mdx, mx1, (sar 3s dispt i, i my1, 1 trc, jmp . / hyperspace routines / this routine handles a non-colliding ship invisibly / in hyperspace hp1, dap hp2 count i ma1, hp2 law hp3 / next step dac i ml1 law 7 dac i mb1 random scr 9s sir 9s xct hr1 add i mx1 dac i mx1 swap add i my1 dac i my1 random scr 9s sir 9s xct hr2 dac i mdy dio i mdx setup .hpt,3 lac ran dac i mth hp4, lac i mth sma sub (311040 spa add (311040 dac i mth count .hpt,hp4 xct hd2 dac i ma1 hp2, jmp . / this routine handles a ship breaking out of / hyperspace. hp3, dap hp5 count i ma1,hp6 lac i .mh1 dac i ml1 law 2000 dac i mb1 count i .mh2,hp7 dzm i .mh2 hp7, xct hd3 dac i .mh3 lac i .mh4 add hur dac i .mh4 random ior (400000 add i .mh4 spa jmp hp5 lac (mex 400000 dac i ml1 law i 10 dac i ma1 law 2000 dac i mb1 hp6, lac i mx1 dispt i, i my1, 2 hp5, jmp . / spaceship calc ss1, dap srt / first spaceship jsp i .cwg dio .scw jmp sr0 ss2, dap srt / second spaceship jsp i .cwg rir 4s dio .scw sr0, sc1, lio .scw /control word clf 6 cla-opr /update angle spi add maa ril 1s spi sub maa mom, add . dac i mom szs 10 jmp sr8 dzm i mom ral 7s sr8, ril 1s spi stf 6 lio i .mfu spi i clf 6 mth, add . sma sub (311040 spa add (311040 dac i mth jda sin dac .sn dzm .bx dzm .by szs 60 jmp bsg lac i mx1 sar 9s sar 2s dac .t1 jda imp lac .t1 dac .t2 lac i my1 sar 9s sar 2s dac .t1 jda imp lac .t1 add .t2 sub str sma i sza-skp jmp pof add str dac .t1 jda sqt sar 9s jda mpy lac .t1 scr 2s szs i 20 / switch 2 for light star scr 2s sza jmp bsg dio .t1 lac i mx1 cma jda idv lac .t1 opr dac .bx lac i my1 cma jda idv lac .t1 opr dac .by bsg, cla sad i mfu clf 6 lac i mth jda cos dac .cs sar 9s xct sac szf i 6 cla add .by diff .mdy, my1, (sar 3s lac .sn sar 9s xct sac cma szf i 6 cla add .bx diff .mdx, mx1, (sar 3s sp1, scale .sn, 5s, .ssn sp2, scale .cs, 5s, .scn lac i mx1 sub .ssn dac .sx1 sub .ssn dac .stx lac i my1 add .scn dac .sy1 add .scn dac .sty scale .sn, 9s, ssn scale .cs, 9s, scn lac .ssn dac .ssm add .scn dac .ssc dac .ssd lac .ssn sub .scn dac .csn cma dac .csm lac .scn dac .scm cla cli-opr dpy-4000 sp5, jmp . sq6, ioh ranct sar 9s, sar 4s, .src lio .scw ril 2s spi i / not blasting jmp sq9 / no tail sq7, scale .sn, 8s, .ssn scale .cs, 8s, .scn count i mfu, st2 dzm i mfu jmp sq9 st2, yincr .sx1, .sy1, sub dispt i, .sy1 count .src,sq7 sq9, count i ma1, sr5 / check if torp tube reloaded dzm i ma1 / prevent count around mco, lac . / previous control word cma szs i 30 clc and .scw / present control word ral 3s / torpedo bit to bit 0 sma jmp sr5 / no launch count i .mtr, st1 / check if torpedos exhausted dzm i .mtr / prevent count around jmp sr5 st1, init sr1, mtb / search for unused object sr1, lac . sza i / 0 if unused jmp sr2 index sr1, (lac mtb nob, sr1 hlt / no space for new objects jmp .-1 sr2, lac (tcr / set up torpedo calc dac i sr1 law nob add sr1 dap ss3 lio .stx ss3, dio . add (nob dap ss4 lio .sty ss4, dio . add (nob dap sr6 add (nob dap sr7 add (nob dap sr3 add (nob dap sr4 lac .sn xct tvl cma add i .mdx sr3, dac . lac .cs xct tvl add i .mdy sr4, dac . xct rlt dac i ma1 / permit torp tubes to cool trf, xct tlf / life of torpedo sr6, dac . law 20 sr7, dap . / length of torp calc. sr5, count i mh3, st3 / hyperbutton active? dzm i .mh3 lac i .mh2 sza i jmp st3 lac .scw cma ior i mco and (600000 sza jmp st3 lac i ml1 dac i .mh1 lac (hp1 400000 dac i ml1 xct hd1 dac i ma1 law 3 dac i mb1 st3, srt, jmp . / here to handle spaceships dragged into star / spaceship in star pof, dzm i .mdx dzm i .mdy szs 50 jmp po1 lac (377777 dac i mx1 dac i my1 lac i mb1 dac .ssn count .ssn, . jmp srt po1, lac (mex 400000 / now go bang dac i ml1 law i 10 dac i ma1 jmp srt / outlines of spaceships ot1, 111131 111111 111111 111163 311111 146111 111114 700000 . 5/ ot2, 013113 113111 116313 131111 161151 111633 365114 700000 . 5/ constants variables p, . 200/ / space for patches mtb, / table of objects and their properties start _