'$DYNAMIC DEFINT A-Z 'structs TYPE shipdata maxs AS INTEGER turn AS INTEGER acc AS INTEGER maxe AS INTEGER maxl AS INTEGER front AS INTEGER sidearm AS INTEGER back AS INTEGER egen AS INTEGER hull AS INTEGER END TYPE TYPE gameship x AS LONG y AS LONG w AS INTEGER h AS INTEGER pnum AS INTEGER xm AS INTEGER ym AS INTEGER ang AS INTEGER e AS INTEGER life AS INTEGER delay AS INTEGER snum AS INTEGER target AS INTEGER END TYPE TYPE projectile stat AS INTEGER x AS LONG y AS LONG pnum AS INTEGER xm AS INTEGER ym AS INTEGER ang AS INTEGER acc AS INTEGER maxs AS INTEGER decay AS INTEGER enum AS INTEGER damage AS INTEGER target AS INTEGER owner AS INTEGER END TYPE TYPE pstarts spoint AS INTEGER pnum AS INTEGER ecost AS INTEGER speed AS INTEGER acc AS INTEGER maxs AS INTEGER ang AS INTEGER damage AS INTEGER delay AS INTEGER decay AS INTEGER target AS INTEGER END TYPE TYPE ppic x AS INTEGER y AS INTEGER w AS INTEGER h AS INTEGER p AS INTEGER END TYPE TYPE hull size AS INTEGER fx AS INTEGER fy AS INTEGER rx AS INTEGER ry AS INTEGER lx AS INTEGER ly AS INTEGER bx AS INTEGER by AS INTEGER END TYPE TYPE weapon numshots AS INTEGER stype AS INTEGER END TYPE 'basic functions DECLARE SUB tempinit (sd() AS shipdata, wd() AS weapon, ws() AS pstarts, pp() AS ppic, hd() AS hull, pic()) DECLARE SUB makeshot (shots() AS projectile, wdata AS weapon, wstart() AS pstarts, ship AS gameship, hdata AS hull, shott, who, freeshot) 'asm code declarations DECLARE SUB setmodex () DECLARE SUB restoremode () DECLARE SUB setpal (p()) DECLARE SUB copypage (BYVAL p1, BYVAL p2) DECLARE SUB setvispage (BYVAL p) DECLARE SUB clearpage (BYVAL p) DECLARE SUB putpixel (BYVAL x, BYVAL y, BYVAL c, BYVAL p) DECLARE SUB rotatesprite (pic(), pal(), BYVAL po, BYVAL x, BYVAL y, BYVAL a, BYVAL p) DECLARE SUB rectangle (BYVAL x, BYVAL y, BYVAL w, BYVAL h, BYVAL c, BYVAL p) DECLARE FUNCTION getcos (BYVAL a) DECLARE FUNCTION getsin (BYVAL a) DECLARE SUB drawsprite (pic(), pal(), BYVAL po, BYVAL x, BYVAL y, BYVAL p) DECLARE SUB wardsprite (pic(), pal(), BYVAL po, BYVAL x, BYVAL y, BYVAL p) DECLARE SUB loadsprite (pic(), BYVAL x, BYVAL y, BYVAL w, BYVAL h, BYVAL p) DECLARE SUB stosprite (pic(), BYVAL x, BYVAL y, BYVAL p) DECLARE SUB fadeto (palbuff(), BYVAL r, BYVAL g, BYVAL b) DECLARE SUB fadetopal (pal(), palbuff()) DECLARE SUB setdiskpages (buf(), BYVAL h, BYVAL l) DECLARE SUB loadpage (fil$, BYVAL i, BYVAL p) DECLARE SUB storepage (fil$, BYVAL i, BYVAL p) DECLARE SUB setkeys () DECLARE SUB setfont (f()) DECLARE SUB printstr (s$, BYVAL x, BYVAL y, BYVAL p) DECLARE SUB textcolor (BYVAL f, BYVAL b) DECLARE SUB setwait (a(), BYVAL t) DECLARE SUB dowait () DECLARE FUNCTION Keyseg () DECLARE FUNCTION keyoff () DECLARE FUNCTION keyval (BYVAL a) DECLARE FUNCTION getkey () TYPE Regtype ax AS INTEGER bx AS INTEGER cx AS INTEGER dx AS INTEGER bp AS INTEGER si AS INTEGER di AS INTEGER flags AS INTEGER ds AS INTEGER es AS INTEGER END TYPE DIM SHARED regs AS Regtype CONST maxships = 1 CONST maxweapons = 3 CONST maxplayers = 1 CONST maxshots = 200 CONST hulltypes = 1 CONST shotpics = 2 DIM tmr(1), font(1024), newpal(800), buffer(16000), musak(3000), voic(8000) DIM shipp(800), shotp(800), pal(80), spal(80) DIM sdata(maxplayers) AS shipdata DIM ship(maxplayers) AS gameship DIM shot(maxshots) AS projectile DIM wdata(maxweapons) AS weapon, wstart(maxweapons, 5) AS pstarts DIM spdata(shotpics) AS ppic DIM hdata(hulltypes) AS hull RANDOMIZE TIMER regs.ax = &H3509: CALL interruptx(&H21, regs, regs) off9 = regs.bx: seg9 = regs.es regs.ax = &H2509: regs.ds = Keyseg: regs.dx = keyoff CALL interruptx(&H21, regs, regs) fadeto buffer(), 0, 0, 0 setmodex DEF SEG = VARSEG(newpal(0)) BLOAD "palette.sto", VARPTR(newpal(0)) setpal newpal() DEF SEG = VARSEG(shipp(0)) BLOAD "hull.1", VARPTR(shipp(0)) DEF SEG = VARSEG(pal(0)) BLOAD "generic.pal", VARPTR(pal(0)) DEF SEG = VARSEG(spal(0)) BLOAD "shot.pal", VARPTR(spal(0)) tempinit sdata(), wdata(), wstart(), spdata(), hdata(), shotp() ship(1).life = sdata(1).maxl gameruns = 1 FOR i = 0 TO maxshots shot(i).stat = -1 NEXT i freeshot = 0 dpage = 0: vpage = 1 setkeys WHILE gameruns = 1 setwait tmr(), 55 setkeys IF keyval(1) > 1 THEN gameruns = 0 IF keyval(75) > 1 THEN ship(1).ang = ship(1).ang + sdata(1).turn / 2 IF ship(1).ang > 255 THEN ship(1).ang = ship(1).ang - 256 END IF IF keyval(75) = 1 THEN ship(1).ang = ship(1).ang + sdata(1).turn IF ship(1).ang > 255 THEN ship(1).ang = ship(1).ang - 256 END IF IF keyval(77) > 1 THEN ship(1).ang = ship(1).ang - sdata(1).turn / 2 IF ship(1).ang < 0 THEN ship(1).ang = ship(1).ang + 256 END IF IF keyval(77) = 1 THEN ship(1).ang = ship(1).ang - sdata(1).turn IF ship(1).ang < 0 THEN ship(1).ang = ship(1).ang + 256 END IF IF keyval(72) > 0 THEN scos = getcos(ship(1).ang): ssin = getsin(ship(1).ang) ship(1).xm = ship(1).xm + scos * sdata(1).acc ship(1).ym = ship(1).ym + ssin * sdata(1).acc END IF IF keyval(82) > 0 AND ship(1).delay = 0 THEN makeshot shot(), wdata(sdata(1).front), wstart(), ship(1), hdata(sdata(1).hull), sdata(1).front, 1, freeshot END IF IF keyval(80) > 0 AND ship(1).delay = 0 THEN makeshot shot(), wdata(sdata(1).back), wstart(), ship(1), hdata(sdata(1).hull), sdata(1).back, 1, freeshot END IF IF (keyval(79) > 0 OR keyval(81) > 0) AND ship(1).delay = 0 THEN makeshot shot(), wdata(sdata(1).sidearm), wstart(), ship(1), hdata(sdata(1).hull), sdata(1).sidearm, 1, freeshot END IF FOR i = 1 TO maxplayers IF ship(i).life > 0 THEN ship(i).e = ship(i).e + sdata(i).egen IF ship(i).e <> ship(i).e THEN rectangle 300, 160, 10, 2, 9, dpage rectangle 300, 160 - sdata(i).egen, 10, sdata(i).egen, 7, dpage IF ship(i).e > sdata(i).maxe THEN ship(i).e = sdata(i).maxe ship(i).x = ship(i).x + ship(i).xm ship(i).y = ship(i).y + ship(i).ym ' IF ship(i).xm * ship(i).xm + ship(i).ym * ship(i).ym > sdata(i).maxs * sdata(i).maxs THEN ' 'use arctan? ' END IF IF ship(i).delay > 0 THEN ship(i).delay = ship(i).delay - 1: ELSE ship(i).delay = 0 END IF NEXT i FOR i = 0 TO maxshots IF shot(i).stat >= 0 THEN shot(i).stat = shot(i).stat XOR 1 shot(i).x = shot(i).x + shot(i).xm shot(i).y = shot(i).y + shot(i).ym scos = getcos(shot(i).ang): ssin = getsin(shot(i).ang) shot(i).xm = shot(i).xm + shot(i).acc * scos shot(i).ym = shot(i).ym + shot(i).acc * ssin tempx = shot(i).x - ship(1).x: tempy = shot(i).y - ship(1).y IF ABS(tempx) < 40960 AND ABS(tempy) < 25600 THEN tempp = shot(i).pnum ' loadsprite shotp(), spdata(tempp).x, spdata(tempp).y, spdata(tempp).w, spdata(tempp).h, 3 ' rotatesprite shotp(), spal(), spdata(tempp).p, 160 + INT(tempx / 256), 100 + INT(tempy / 256), shot(i).ang-64, dpage rectangle 160 + INT(tempx / 256), 100 + INT(tempy / 256), 2, 2, tempp + 1, dpage END IF shot(i).decay = shot(i).decay - 1 IF shot(i).decay < 1 THEN shot(i).stat = -1 IF freeshot > i THEN freeshot = i END IF rectangle 10, i, 10, 1, shot(i).pnum + 1, dpage END IF NEXT i rectangle 10, freeshot, 10, 1, 15, dpage rotatesprite shipp(), pal(), 0, 160, 100, ship(1).ang - 64, dpage tempy = 50 * (ship(1).e / sdata(1).maxe) rectangle 300, 70 - tempy, 10, tempy, 14, dpage SWAP dpage, vpage setvispage vpage clearpage dpage dowait WEND finis: regs.ax = &H2509: regs.ds = seg9: regs.dx = off9 CALL interruptx(&H21, regs, regs) fadeto buffer(), 0, 0, 0 restoremode SYSTEM REM $STATIC SUB makeshot (shots() AS projectile, wdata AS weapon, wstart() AS pstarts, ship AS gameship, hdata AS hull, shott, who, freeshot) IF ship.e > wstart(shott, ship.snum).ecost AND freeshot <= maxshots THEN rectangle 20, 20, 10, 10, 2, 0 rectangle 20, 20, 10, 10, 2, 1 ship.e = ship.e - wstart(shott, ship.snum).ecost shots(freeshot).pnum = wstart(shott, ship.snum).pnum shots(freeshot).owner = who scos = getcos(ship.ang) ssin = getsin(ship.ang) SELECT CASE wstart(shott, ship.snum).spoint CASE 0 shots(freeshot).x = ship.x + scos * hdata.fx - ssin * hdata.fy shots(freeshot).y = ship.y + scos * hdata.fy + ssin * hdata.fx CASE 1 shots(freeshot).x = ship.x + scos * hdata.lx - ssin * hdata.ly shots(freeshot).y = ship.y + scos * hdata.ly + ssin * hdata.lx CASE 2 shots(freeshot).x = ship.x + scos * hdata.rx - ssin * hdata.ry shots(freeshot).y = ship.y + scos * hdata.ry + ssin * hdata.rx CASE 3 shots(freeshot).x = ship.x + scos * hdata.bx - ssin * hdata.by shots(freeshot).y = ship.y + scos * hdata.by + ssin * hdata.bx END SELECT temp = ship.ang + wstart(shott, ship.snum).ang shots(freeshot).ang = temp scos = getcos(temp): ssin = getsin(temp) shots(freeshot).xm = ship.xm + scos * wstart(shott, ship.snum).speed shots(freeshot).ym = ship.ym + ssin * wstart(shott, ship.snum).speed shots(freeshot).acc = wstart(shott, ship.snum).acc shots(freeshot).damage = wstart(shott, ship.snum).damage shots(freeshot).maxs = wstart(shott, ship.snum).maxs shots(freeshot).decay = wstart(shott, ship.snum).decay shots(freeshot).target = ship.target shots(freeshot).stat = 1 WHILE shots(freeshot).stat >= 0 AND freeshot < maxshots freeshot = freeshot + 1 WEND ship.snum = ship.snum + 1 IF ship.snum > wdata.numshots THEN ship.snum = 0 END IF IF wstart(shott, ship.snum).delay < 0 THEN makeshot shots(), wdata, wstart(), ship, hdata, shott, who, freeshot ELSE ship.delay = wstart(shott, ship.snum).delay + 1 END IF END IF END SUB SUB tempinit (sd() AS shipdata, wd() AS weapon, ws() AS pstarts, pp() AS ppic, hd() AS hull, pic()) sd(1).maxs = 10 sd(1).turn = 4 sd(1).acc = 5 sd(1).maxe = 1000 sd(1).maxl = 100 sd(1).front = 1 sd(1).sidearm = 2 sd(1).back = 3 sd(1).egen = 10 sd(1).hull = 1 hd(1).size = 10 hd(1).fx = 13 hd(1).fy = 0 hd(1).rx = 2 hd(1).ry = 10 hd(1).lx = 2 hd(1).ly = -10 hd(1).bx = -8 hd(1).by = 0 DEF SEG = VARSEG(pic(0)) BLOAD "shot0.0", VARPTR(pic(0)) stosprite pic(), 0, 100, 3 BLOAD "shot1.0", VARPTR(pic(0)) stosprite pic(), 20, 100, 3 pp(0).x = 0: pp(0).y = 100 pp(0).w = 5: pp(0).h = 8: pp(0).p = 0 DEF SEG = VARSEG(pic(0)) BLOAD "shot0.1", VARPTR(pic(0)) stosprite pic(), 40, 100, 3 BLOAD "shot1.1", VARPTR(pic(0)) stosprite pic(), 86, 100, 3 pp(0).x = 40: pp(0).y = 100 pp(0).w = 7: pp(0).h = 13: pp(0).p = 0 DEF SEG = VARSEG(pic(0)) BLOAD "shot0.2", VARPTR(pic(0)) stosprite pic(), 132, 100, 3 BLOAD "shot1.2", VARPTR(pic(0)) stosprite pic(), 135, 100, 3 pp(0).x = 132: pp(0).y = 100 pp(0).w = 1: pp(0).h = 5: pp(0).p = 0 wd(1).numshots = 0 wd(1).stype = 0 ws(1, 0).spoint = 0 ws(1, 0).pnum = 1 ws(1, 0).ecost = 1 ws(1, 0).speed = 8 ws(1, 0).acc = 0 ws(1, 0).ang = 0 ws(1, 0).damage = 50 ws(1, 0).delay = 10 ws(1, 0).decay = 12 ws(1, 0).target = 0 wd(2).numshots = 1 wd(2).stype = 0 ws(2, 0).spoint = 1 ws(2, 0).pnum = 2 ws(2, 0).ecost = 5 ws(2, 0).speed = 3 ws(2, 0).acc = 1 ws(2, 0).ang = 1 ws(2, 0).damage = 25 ws(2, 0).delay = 2 ws(2, 0).decay = 12 ws(2, 0).target = 0 ws(2, 1).spoint = 2 ws(2, 1).pnum = 2 ws(2, 1).ecost = 5 ws(2, 1).speed = 3 ws(2, 1).acc = 1 ws(2, 1).ang = -1 ws(2, 1).damage = 25 ws(2, 1).delay = 2 ws(2, 1).decay = 12 ws(2, 1).target = 0 wd(3).numshots = 1 wd(3).stype = 0 ws(3, 0).spoint = 1 ws(3, 0).pnum = 0 ws(3, 0).ecost = 20 ws(3, 0).speed = 13 ws(3, 0).acc = -1 ws(3, 0).ang = 0 ws(3, 0).damage = 25 ws(3, 0).delay = -1 ws(3, 0).decay = 13 ws(3, 0).target = 0 ws(3, 1).spoint = 2 ws(3, 1).pnum = 0 ws(3, 1).ecost = 0 ws(3, 1).speed = 13 ws(3, 1).acc = -1 ws(3, 1).ang = 0 ws(3, 1).damage = 25 ws(3, 1).delay = 20 ws(3, 1).decay = 13 ws(3, 1).target = 0 END SUB