'=========================================================================== ' Subject: QBASIC MISSILE COMMAND W/MOUSE Date: 02-25-99 (23:23) ' Author: Mr Whisper Code: QB, QBasic, PDS ' Origin: mrwhisper@odos.freeserve.co.uk Packet: GAMES.ABC '=========================================================================== ' ' Q B a s i c M i s s i l e C o m m a n d ' ' Copyright (C) mr whisper 1997 ' Original keyboard version Copyright (C) mr whisper 1992 ' ' stop those pesky missiles using the mousie...left button to fire... ' use the 1, 2, 3 keys to select missile base to fire from....aye... ' ' bonus city at levels 6, 12 and 18 ' ' thanks to marky boy fer gettin the mouse controls an delays from ABC fur me ' ' To run this game, press Shift+F5. ' ' To exit QBasic, press Alt, F, X. ' ' 'Set default data type to integer for faster game play DEFINT A-Z 'User-defined TYPEs 'Sub Declarations DECLARE SUB SpacePause (text$) DECLARE SUB Initialize () CONST TRUE = -1 CONST FALSE = NOT TRUE CONST STARTOVER = 1 ' Parameters to 'Level' SUB CONST SAMELEVEL = 2 0 'Graphix Variables DIM SHARED City&(100) DIM SHARED Missile&(100) DIM SHARED Sat&(100) DIM SHARED Lines(90, 3) AS DOUBLE DIM SHARED Missiles(20, 3) AS DOUBLE DIM SHARED Explosions&(10, 3) DIM SHARED pi# 'mousie bit... DECLARE FUNCTION MouseInit% () DECLARE SUB MouseCall () DECLARE SUB MouseGetPressInfo (LBtn%, RBtn%, MBtn%, Count%, HPosn%, VPosn%) DECLARE SUB MouseGetReleaseInfo (LBtn%, RBtn%, MBtn%, Count%, HPosn%, VPosn%) DECLARE SUB MouseGetStatus (LBtn%, RBtn%, MBtn%, HPosn%, VPosn%) DECLARE SUB MouseHide () DECLARE SUB MouseReadCounters (HCount%, VCount%) DECLARE SUB MouseSetHorizRange (HMin%, HMax%) DECLARE SUB MouseSetPosn (HPosn%, VPosn%) DECLARE SUB MouseSetup () DECLARE SUB MouseSetVertRange (VMin%, VMax%) DECLARE SUB MouseShow () DECLARE SUB Delay (Value#) DECLARE SUB CalculateDelay () MouseInt: ' Machine language routine 40 bytes long: DATA 55 : 'PUSH BP DATA 89, E5 : 'MOV BP, SP DATA 56 : 'PUSH SI DATA 8B, 76, 06 : 'MOV SI,[BP+6] DATA 8B, 04 : 'MOV AX,[SI] DATA 8B, 5C, 02 : 'MOV BX,[SI+2] DATA 8B, 4C, 04 : 'MOV CX,[SI+4] DATA 8B, 54, 06 : 'MOV DX,[SI+6] DATA 8E, 44, 08 : 'MOV ES,[SI+8] DATA CD, 33 : 'INT 33h DATA 8C, 44, 08 : 'MOV [SI+8],ES DATA 89, 54, 06 : 'MOV [SI+6],DX DATA 89, 4C, 04 : 'MOV [SI+4],CX DATA 89, 5C, 02 : 'MOV [SI+2],BX DATA 89, 04 : 'MOV [SI],AX DATA 5E : 'POP SI DATA 5D : 'POP BP DATA CB : 'RETF TYPE MouseRegs AX AS INTEGER BX AS INTEGER CX AS INTEGER DX AS INTEGER ES AS INTEGER END TYPE DIM SHARED MReg AS MouseRegs REDIM SHARED MouseRoutine%(0 TO 19) DIM SHARED MouseReady% MouseReady% = 0 MouseSetup MouseReady% = MouseInit IF MouseReady% THEN ELSE CLS PRINT "This game requires a mouse and you do not have one installed." PRINT "Try keying 'MOUSE' at the DOS prompt to install the mouse driver." END END IF CALL MouseSetVertRange(20, 140) 'CALL MouseSetHorizRange(10, 610) MouseHide DIM SHARED MilliDelay AS DOUBLE: ' Delay value for 1 millisecond 'initialise delay CALL CalculateDelay 'Do ra Bizzo RANDOMIZE TIMER GOSUB ClearKeyLocks GOSUB SetColors GOSUB getgraphics GOSUB intro sam$ = "y" DO WHILE sam$ = "y" GOSUB initvars DO WHILE cities > 0 GOSUB playmissile LOOP sam$ = INKEY$ IF score# > highscore# THEN highscore# = score# END IF DO UNTIL sam$ = "y" OR sam$ = "n" GOSUB movelines GOSUB movemissiles GOSUB movesats LOCATE 8, 13 PRINT "HIGH SCORE "; highscore#; LOCATE 10, 17 PRINT "GAME OVER" LOCATE 12, 14 PRINT "PLAY AGAIN " sam$ = INKEY$ LOOP LOOP END ClearKeyLocks: DEF SEG = 0 ' Turn off CapLock, NumLock and ScrollLock KeyFlags = PEEK(1047) POKE 1047, &H0 DEF SEG RETURN RestoreKeyLocks: DEF SEG = 0 ' Restore CapLock, NumLock and ScrollLock states POKE 1047, KeyFlags DEF SEG RETURN SetColors: COLOR 0, 15 SCREEN 7 ' SCREEN 12 CLS RETURN intro: GOSUB initvars GOSUB setupscreen GOSUB golines FOR x = 1 TO 900 GOSUB movelines CALL Delay(MilliDelay * 10) throw$ = INKEY$ NEXT x LOCATE 10, 12 PRINT "MISSILE COMMAND"; LOCATE 12, 10 PRINT "PRESS A KEY TO START"; DO UNTIL poo$ <> "" poo$ = INKEY$ LOOP RETURN initvars: cities = 6 city1 = 1 city2 = 1 city3 = 1 city4 = 1 city5 = 1 city6 = 1 level = 1 pi# = 4 * ATN(1#) deadind = 0 xman = 160 yman = 100 direction = 0 score# = 0 RETURN getgraphics: 'Draw missile LINE (3, 0)-(6, 3), 5 LINE (6, 3)-(3, 6), 5 LINE (3, 6)-(0, 3), 5 LINE (0, 3)-(3, 0), 5 GET (0, 0)-(6, 6), Missile& CLS 0 'draw city LINE (10, 0)-(14, 0), 15 LINE (7, 3)-(10, 0), 15 LINE (7, 3)-(3, 3), 15 LINE (3, 3)-(0, 7), 15 LINE (0, 7)-(24, 7), 15 LINE (0, 7)-(3, 10), 15 LINE (14, 0)-(17, 3), 15 LINE (17, 3)-(20, 3), 15 LINE (20, 3)-(24, 7), 15 LINE (24, 7)-(20, 10), 15 LINE (20, 10)-(3, 10), 15 GET (0, 0)-(24, 10), City& CLS 0 ' draw satellite LINE (0, 0)-(7, 7), 6 LINE (7, 0)-(0, 7), 6 LINE (6, 2)-(15, 5), 6, BF PSET (6, 2), 6 PSET (6, 3), 6 PSET (6, 4), 6 ' PSET (5, 2), 6 PSET (5, 3), 6 PSET (5, 4), 6 PSET (14, 2), 0 PSET (14, 5), 0 ' PSET (14, 4), 6 ' PSET (14, 3), 6 ' PSET (15, 4), 6 GET (0, 0)-(24, 10), Sat& CLS 0 RETURN playmissile: CLS 0 LOCATE 10, 8 PRINT "Get ready for level "; level; CALL Delay(MilliDelay * 3000) GOSUB setupscreen GOSUB golines DO UNTIL ((linesleft < 1 AND linesongo < 1 AND missleft < 1 AND satongo = 0) OR cities < 1) AND explosion < 1 IF bigotog = 1 THEN bigtog = 0 ELSE bigtog = 1 move$ = INKEY$ CALL Delay(MilliDelay * 20) GOSUB eraseman IF xblank1 > 0 THEN LINE (xblank1, yblank1)-(xblank2, yblank2), 0 xblank1 = 0 yblank1 = 0 xblank2 = 0 yblank2 = 0 END IF IF explosion > 0 THEN GOSUB doexplosions END IF GOSUB moveman GOSUB movelines GOSUB movemissiles IF level > 8 THEN GOSUB movesats END IF LOCATE 1, 18 PRINT " - Missile command - SCORE 1UP"; score#; bigtog = 0 END IF LOOP IF cities > 0 THEN level = level + 1 GOSUB awardbonus END IF IF (level = 6 OR level = 12 OR level = 18) AND cities < 6 AND cities > 0 THEN IF city1 = 0 THEN city1 = 1 ELSEIF city2 = 0 THEN city2 = 1 ELSEIF city3 = 0 THEN city3 = 1 ELSEIF city4 = 0 THEN city4 = 1 ELSEIF city5 = 0 THEN city5 = 1 ELSEIF city6 = 0 THEN city6 = 1 END IF cities = cities + 1 END IF RETURN setupscreen: CLS 0 linesdead = 0 linesongo = 0 satongo = 0 missdead = 0 missongo = 0 missleft = 0 linesleft = 0 missdepongo = 1 levellines = 20 + (RND * 10) + (level * 5) IF levellines > 90 THEN levellines = 90 END IF IF level < 5 THEN levelmiss = 0 ELSE levelmiss = 4 + (RND * 2) + (level) END IF IF levelmiss > 20 THEN levelmiss = 20 END IF linesleft = levellines FOR flip = 1 TO levellines Lines(flip, 0) = 0 Lines(flip, 1) = 0 Lines(flip, 2) = 0 Lines(flip, 3) = 0 NEXT flip FOR flop = 1 TO levelmiss Missiles(flop, 0) = 0 Missiles(flop, 1) = 0 Missiles(flop, 2) = 0 Missiles(flop, 3) = 0 NEXT flop rocketdep1 = 20 rocketdep2 = 20 rocketdep3 = 20 LINE (0, 190)-(320, 190), 11 LINE (0, 180)-(10, 180), 11 LINE (10, 180)-(15, 190), 11 LINE (320, 180)-(310, 180), 11 LINE (310, 180)-(305, 190), 11 LINE (150, 190)-(155, 180), 11 LINE (155, 180)-(165, 180), 11 LINE (165, 180)-(170, 190), 11 PAINT (160, 187), 11 PAINT (5, 187), 11 PAINT (315, 187), 11 PAINT (160, 191), 11 IF city1 = 1 THEN PUT (29, 180), City&, OR END IF IF city2 = 1 THEN PUT (71, 180), City&, OR END IF IF city3 = 1 THEN PUT (113, 180), City&, OR END IF IF city4 = 1 THEN PUT (190, 180), City&, OR END IF IF city5 = 1 THEN PUT (230, 180), City&, OR END IF IF city6 = 1 THEN PUT (270, 180), City&, OR END IF linespeed = 500 RETURN awardbonus: bulletbonus = 0 citybonus = 0 CALL Delay(MilliDelay * 2000) LOCATE 10, 10 PRINT "Level "; (level - 1); "completed"; CALL Delay(MilliDelay * 2000) FOR award1 = 1 TO cities citybonus = citybonus + (200 + (level * 10)) PUT (80 + (award1 * 30), 100), City& LOCATE 12, 10 PRINT "Bonus : "; citybonus; CALL Delay(MilliDelay * 400) NEXT award1 score# = score# + citybonus CALL Delay(MilliDelay * 1000) bullettot = rocketdep1 + rocketdep2 + rocketdep3 FOR award2 = 1 TO bullettot bulletbonus = bulletbonus + (5 + level) LINE (80 + (award2 * 3), 140)-(80 + (award2 * 3), 143), 4 LOCATE 16, 10 PRINT "Bonus : "; bulletbonus; CALL Delay(MilliDelay * 50) NEXT award2 score# = score# + bulletbonus CALL Delay(MilliDelay * 5000) RETURN golines: FOR doit = 1 TO 8 + (level / 2) xline# = (RND * 320) xtarget# = (RND * 320) xlinemove# = (xtarget# - xline#) / 170 ylinemove = 1 Lines(doit, 0) = xline# Lines(doit, 1) = 15 Lines(doit, 2) = xlinemove# Lines(doit, 3) = ylinemove linesongo = linesongo + 1 NEXT doit RETURN moveman: CALL MouseGetStatus(L%, R%, M%, Horiz%, Vert%) xman = Horiz% yman = Vert% xman = xman / 2 yman = yman - 2 IF yman < 20 THEN yman = 20 END IF IF xman > 310 THEN xman = 310 END IF IF yman > 170 THEN yman = 170 END IF IF xman < 10 THEN xman = 10 END IF IF move$ = "1" THEN ' LOCATE 26, printloc ' PRINT " "; missdepongo = 1 ' LOCATE 26, 1 ' PRINT "ON"; ELSEIF move$ = "2" THEN ' LOCATE 26, printloc ' PRINT " "; missdepongo = 2 ' LOCATE 26, 18 ' PRINT "ON"; ELSEIF move$ = "3" THEN ' LOCATE 26, printloc ' PRINT " "; missdepongo = 3 ' LOCATE 26, 36 ' PRINT "ON"; END IF L = 1: R = 0: M = 0 CALL MouseGetPressInfo(L, R, M, CNT, H, V) IF CNT = 1 THEN GOSUB firelaser END IF oldman1 = POINT(xman - 3, yman) oldman2 = POINT(xman - 2, yman) oldman3 = POINT(xman - 1, yman) oldman4 = POINT(xman, yman) oldman5 = POINT(xman + 1, yman) oldman6 = POINT(xman + 2, yman) oldman7 = POINT(xman + 3, yman) oldman8 = POINT(xman, yman + 1) oldman9 = POINT(xman, yman + 2) oldman10 = POINT(xman, yman + 3) oldman11 = POINT(xman, yman - 1) oldman12 = POINT(xman, yman - 2) oldman13 = POINT(xman, yman - 3) LINE (xman - 3, yman)-(xman + 3, yman), 1 LINE (xman, yman + 3)-(xman, yman - 3), 1 RETURN eraseman: PSET (xman - 3, yman), oldman1 PSET (xman - 2, yman), oldman2 PSET (xman - 1, yman), oldman3 PSET (xman, yman), 0 PSET (xman + 1, yman), oldman5 PSET (xman + 2, yman), oldman6 PSET (xman + 3, yman), oldman7 PSET (xman, yman + 1), oldman8 PSET (xman, yman + 2), oldman9 PSET (xman, yman + 3), oldman10 PSET (xman, yman - 1), oldman11 PSET (xman, yman - 2), oldman12 PSET (xman, yman - 3), oldman13 RETURN firelaser: FOR explodealloc = 1 TO 10 IF Explosions&(explodealloc, 0) = 0 AND Explosions&(explodeallo, 1) = 0 THEN nextexplode = explodealloc explodealloc = 10 END IF NEXT explodealloc SELECT CASE missdepongo CASE 1 IF rocketdep1 > 0 THEN explosion = explosion + 1 LINE (10, 180)-(xman, yman), 2 rocketdep1 = rocketdep1 - 1 LOCATE 25, 1 PRINT rocketdep1; Explosions&(nextexplode, 0) = xman Explosions&(nextexplode, 1) = yman Exlposions&(nextexplode, 2) = 0 xblank1 = 10 yblank1 = 180 xblank2 = xman yblank2 = yman END IF CASE 2 IF rocketdep2 > 0 THEN explosion = explosion + 1 LINE (160, 180)-(xman, yman), 2 rocketdep2 = rocketdep2 - 1 LOCATE 25, 18 PRINT rocketdep2; Explosions&(nextexplode, 0) = xman Explosions&(nextexplode, 1) = yman Exlposions&(nextexplode, 2) = 0 xblank1 = 160 yblank1 = 180 xblank2 = xman yblank2 = yman END IF CASE 3 IF rocketdep3 > 0 THEN explosion = explosion + 1 LINE (310, 180)-(xman, yman), 2 rocketdep3 = rocketdep3 - 1 LOCATE 25, 36 PRINT rocketdep3; Explosions&(nextexplode, 0) = xman Explosions&(nextexplode, 1) = yman Exlposions&(nextexplode, 2) = 0 xblank1 = 310 yblank1 = 180 xblank2 = xman yblank2 = yman END IF END SELECT RETURN doexplosions: bangtog = bangtog + 1 IF bangtog = 3 THEN FOR dobang = 1 TO 10 xbang = Explosions&(dobang, 0) ybang = Explosions&(dobang, 1) bangstage = Explosions&(dobang, 2) IF xbang > 0 AND ybang > 0 THEN bangstage = bangstage + 1 IF bangstage < 12 THEN CIRCLE (xbang, ybang), bangstage, 2 ELSEIF bangstage < 40 THEN ' do nowt - as a pause ysee - sorta hang in the air type thang ELSEIF bangstage < 53 THEN CIRCLE (xbang, ybang), 52 - bangstage, 0 ELSE xbang = 0 ybang = 0 bangstage = 0 explosion = explosion - 1 END IF Explosions&(dobang, 0) = xbang Explosions&(dobang, 1) = ybang Explosions&(dobang, 2) = bangstage END IF NEXT dobang bangtog = 0 ELSE bangtog = bangtog + 1 END IF RETURN movesats: ' bong bong bong...satellite of love....bong bong bong satellite of lurv.. ' saaatt--ahhh--lite of....... IF sattoggle = 5 THEN IF satongo > 0 THEN check = POINT(satx + 8, saty + 6) IF check = 2 THEN LINE (satx, saty)-(satx + 15, saty + 10), 0, BF satongo = 0 score = score + 100 ELSE LINE (satx, saty)-(satx + 15, saty + 10), 0, BF satx = satx + satmove IF satx > 290 OR satx < 1 THEN satongo = 0 ELSE PUT (satx, saty), Sat&, OR GOSUB firesat END IF END IF ELSE satmibby = (RND * (500 - (level * 20))) IF satmibby = 6 AND missleft > 0 THEN saty = 30 + (RND * 70) + level ' tossing a coin to decide whether you should tell your folks ' about a dose of thrush you got while licking railings coin = (RND * 2) IF coin = 1 THEN satx = 1 satmove = 1 ELSE satx = 290 satmove = -1 END IF satongo = 1 END IF END IF sattoggle = 0 ELSE sattoggle = sattoggle + 1 END IF RETURN firesat: ' I saw 2 shooting stars last night, I wished on them... ' but they were only satellites, its wrong to wish on space hardware ' I wish I wish, I wish you cared.... mibbyfire = (RND * (50 - level)) IF mibbyfire = 3 THEN satxline# = satx + 15 xtarget# = (RND * 320) ytogo = 185 - saty + 5 satxlinemove# = (xtarget# - satxline#) / ytogo ylinemove = 1 allocit = 0 FOR pooit = 1 TO 80 IF Lines(pooit, 0) < 1 AND Lines(pooit, 1) < 1 THEN allocit = pooit pooit = 80 END IF NEXT pooit IF allocit > 0 THEN Lines(allocit, 0) = satxline# Lines(allocit, 1) = saty Lines(allocit, 2) = satxlinemove# Lines(allocit, 3) = ylinemove linesdead = linesdead - 1 linesongo = linesongo + 1 END IF END IF RETURN movemissiles: IF missongo > 0 THEN IF misstog = 3 THEN FOR missup = 1 TO levelmiss xmiss# = Missiles(missup, 0) ymiss = Missiles(missup, 1) xmissmove# = Missiles(missup, 2) ymissmove = Missiles(missup, 3) IF xmiss# > 0 AND ymiss > 0 THEN newxmiss# = xmiss# + xmissmove# newymiss = ymiss + ymissmove IF newymiss > 182 OR newxmiss# < 0 OR newxmiss# > 320 THEN missind = 1 GOSUB killsurfcity GOSUB killmiss ELSE GOSUB checkmissdead END IF Missiles(missup, 0) = newxmiss# Missiles(missup, 1) = newymiss END IF NEXT missup misstog = 0 ELSE misstog = misstog + 1 END IF ELSE mibbymiss = (RND * 1000) IF (linesdead > 20 AND linesongo < 10 AND missleft > 0) OR mibbymiss = 12 THEN GOSUB gonewmiss END IF END IF missleft = levelmiss - missdead RETURN movelines: ' move all lines IF linetog = 5 THEN FOR lineup = 1 TO levellines xline# = Lines(lineup, 0) yline = Lines(lineup, 1) xmove# = Lines(lineup, 2) ymove = Lines(lineup, 3) IF xline# > 0 AND yline > 0 THEN newxline# = xline# + xmove# newyline = yline + 1 IF newyline > 185 OR newxline# < 0 OR newxline# > 320 THEN GOSUB killsurfcity GOSUB killline ELSE GOSUB checklinedead END IF Lines(lineup, 0) = newxline# Lines(lineup, 1) = newyline END IF NEXT lineup linetog = 0 ELSE linetog = linetog + 1 END IF posspoop = (RND * 800) linesleft = levellines - linesdead IF linesongo < 4 OR posspoop = 10 THEN GOSUB gonewlines END IF RETURN killsurfcity: ' ahm gonna kill surf city with a neutron bomb etc... IF missind = 1 THEN newxline# = newxmiss# + 3 newyline = newymiss + 3 END IF FOR DIE = 1 TO 7 CIRCLE (newxline#, newyline), DIE, 3 NEXT DIE IF newxline# < 10 AND newyline > 170 THEN rocketdep1 = 0 LOCATE 25, 1 PRINT rocketdep1; END IF IF newxline# > 155 AND newxline# < 165 THEN rocketdep2 = 0 LOCATE 25, 18 PRINT rocketdep2; END IF IF newxline# > 310 AND newyline > 175 THEN rocketdep3 = 0 LOCATE 25, 36 PRINT rocketdep3; END IF IF newxline# > 29 AND newxline# < 49 AND city1 = 1 THEN city1 = 0 cities = cities - 1 END IF IF newxline# > 71 AND newxline# < 91 AND city2 = 1 THEN city2 = 0 cities = cities - 1 END IF IF newxline# > 113 AND newxline# < 133 AND city3 = 1 THEN city3 = 0 cities = cities - 1 END IF IF newxline# > 190 AND newxline# < 210 AND city4 = 1 THEN city4 = 0 cities = cities - 1 END IF IF newxline# > 230 AND newxline# < 250 AND city5 = 1 THEN city5 = 0 cities = cities - 1 END IF IF newxline# > 270 AND newxline# < 290 AND city6 = 1 THEN city6 = 0 cities = cities - 1 END IF FOR DIE = 7 TO 1 STEP -1 CIRCLE (newxline#, newyline), DIE, 0 NEXT DIE missind = 0 RETURN checkmissdead: checkmiss1 = POINT(newxmiss# + 3, newymiss + 3) checkmiss2 = POINT(newxmiss# + (xmissmove * 6) + 3, newymiss + 6 + 3) checkmiss3 = POINT(newxmiss# + (xmissmove * 3) + 3, newymiss + 3 + 3) IF checkmiss1 = 2 THEN GOSUB killmiss score# = score# + 100 ELSE IF checkmiss2 = 2 THEN newxmiss# = newxmiss# - xmissmove# newymiss = newymiss - ymissmove ELSE LINE (xmiss#, ymiss)-(xmiss# + 6, ymiss + 6), 0, BF END IF PUT (newxmiss#, newymiss), Missile&, OR END IF RETURN checklinedead: checkline = POINT(newxline#, newyline) IF checkline = 2 THEN GOSUB killline score# = score# + 25 ELSE LINE (xline#, yline)-(newxline#, newyline), 3 IF newyline > 60 AND newyline < 110 AND level > 2 THEN splitmibby = (RND * (500 - (level * 20))) IF splitmibby = 6 THEN GOSUB splitter END IF END IF END IF RETURN killmiss: LINE (xmiss#, ymiss)-(xmiss# + 6, ymiss + 6), 0, BF newxmiss# = 0 newymiss = 0 missongo = missongo - 1 missdead = missdead + 1 RETURN killline: DO UNTIL newyline = 15 newxline# = newxline# - xmove# newyline = newyline - ymove LINE (xline#, yline)-(newxline#, newyline), 0 xline# = newxline# yline = newyline LOOP newxline# = 0 newyline = 0 linesongo = linesongo - 1 linesdead = linesdead + 1 RETURN splitter: splitlinestogo = 2 + (RND * 2) IF splitlinestogo > 0 THEN FOR doit = 1 TO splitlinestogo splitxline# = newxline# xtarget# = (RND * 320) ytogo = 185 - newyline splitxlinemove# = (xtarget# - splitxline#) / ytogo ylinemove = 1 allocit = 0 FOR pooit = 1 TO 80 IF Lines(pooit, 0) < 1 AND Lines(pooit, 1) < 1 THEN allocit = pooit pooit = 80 END IF NEXT pooit IF allocit > 0 THEN Lines(allocit, 0) = splitxline# Lines(allocit, 1) = newyline Lines(allocit, 2) = splitxlinemove# Lines(allocit, 3) = ylinemove linesdead = linesdead - 1 linesongo = linesongo + 1 END IF NEXT doit END IF RETURN gonewmiss: newmisstogo = (RND * 2) + (level / 4) IF newmisstogo > missleft THEN newmisstogo = missleft END IF IF newmisstogo > 0 THEN FOR doit = 1 TO newmisstogo allocxmiss# = (RND * 300) + 10 xtarget# = (RND * 300) + 10 allocxmissmove# = (xtarget# - allocxmiss#) / 170 ymissmove = 1 allocit = 0 FOR pooit = 1 TO 20 IF Missiles(pooit, 0) < 1 AND Missiles(pooit, 1) < 1 THEN allocit = pooit pooit = 20 END IF NEXT pooit IF allocit > 0 THEN Missiles(allocit, 0) = allocxmiss# Missiles(allocit, 1) = 15 Missiles(allocit, 2) = allocxmissmove# Missiles(allocit, 3) = ymissmove missongo = missongo + 1 END IF NEXT doit END IF RETURN gonewlines: newlinestogo = (RND * 5) + (level) IF newlinestogo > 12 THEN newlinestogo = 12 END IF IF newlinestogo > linesleft THEN newlinestogo = linesleft END IF IF newlinestogo > 0 THEN FOR doit = 1 TO newlinestogo allocxline# = (RND * 320) xtarget# = (RND * 320) allocxlinemove# = (xtarget# - allocxline#) / 170 ylinemove = 1 allocit = 0 FOR pooit = 1 TO 60 IF Lines(pooit, 0) < 1 AND Lines(pooit, 1) < 1 THEN allocit = pooit pooit = 60 END IF NEXT pooit IF allocit > 0 THEN Lines(allocit, 0) = allocxline# Lines(allocit, 1) = 15 Lines(allocit, 2) = allocxlinemove# Lines(allocit, 3) = ylinemove linesongo = linesongo + 1 END IF NEXT doit END IF RETURN END DEFSNG A-Z SUB CalculateDelay Test# = 5000 ' Test variable to pass number to Subrountine StartTimer# = TIMER CALL Delay(Test#) StopTimer# = TIMER Difference# = StopTimer# - StartTimer# SecondDelay = Test# / Difference# MilliDelay = SecondDelay / 1000 END SUB SUB Delay (Value#) FOR A# = 1 TO Value# NEXT A# END SUB DEFINT A-Z SUB MouseCall '* '* Call mouse using current values in MReg registers '* DEF SEG = VARSEG(MouseRoutine%(0)) Addr% = VARPTR(MouseRoutine%(0)) CALL Absolute(MReg, Addr%) DEF SEG END SUB SUB MouseGetPressInfo (LBtn%, RBtn%, MBtn%, Count%, HPosn%, VPosn%) '* '* Gets info about last mouse click '* Set LBtn%, RBtn%, or MBtn% <> 0 for button to query '* LBtn%, RBtn%, or MBtn% return 1 to show which '* button is currently down or 0 to show which button '* is currently up '* Count% has count of clicks since last call '* HPosn% and VPosn% are horizontal and vertical position '* of cursor at last click '* IF MouseReady% THEN IF (LBtn% OR RBtn% OR MBtn%) <> 0 THEN MReg.AX = 5 IF LBtn% THEN MReg.BX = 0 IF RBtn% THEN MReg.BX = 1 IF MBtn% THEN MReg.BX = 2 MouseCall LBtn% = MReg.AX AND 1 RBtn% = (MReg.AX AND 2) \ 2 MBtn% = (MReg.AX AND 4) \ 4 Count% = MReg.BX HPosn% = MReg.CX VPosn% = MReg.DX ELSE CALL MouseGetStatus(LBtn%, RBtn%, MBtn%, HPosn%, VPosn%) Count% = 0 END IF ELSE LBtn% = 0: RBtn% = 0: MBtn% = 0 Count% = 0 HPosn% = -1: VPosn% = -1 END IF END SUB SUB MouseGetReleaseInfo (LBtn%, RBtn%, MBtn%, Count%, HPosn%, VPosn%) '* '* Gets info about last mouse release '* Set LBtn%, RBtn%, or MBtn% <> 0 for button query '* LBtn%, RBtn%, or MBtn% return 1 to show which '* button is currently down or 0 to show which '* button is currently up '* Count% has count of releases since last call '* HPosn% and VPosn% are horizontal and vertical position '* of cursor at last release '* IF MouseReady% THEN IF (LBtn% OR RBtn% OR MBtn%) <> 0 THEN MReg.AX = 6 IF LBtn% THEN MReg.BX = 0 IF RBtn% THEN MReg.BX = 1 IF MBtn% THEN MReg.BX = 2 MouseCall LBtn% = MReg.AX AND 1 RBtn% = (MReg.AX AND 2) \ 2 MBtn% = (MReg.AX AND 4) \ 4 Count% = MReg.BX HPosn% = MReg.CX VPosn% = MReg.DX ELSE CALL MouseGetStatus(LBtn%, RBtn%, MBtn%, HPosn%, VPosn%) Count% = 0 END IF ELSE LBtn% = 0: RBtn% = 0: MBtn% = 0 Count% = 0 HPosn% = -1: VPosn% = -1 END IF END SUB SUB MouseGetStatus (LBtn%, RBtn%, MBtn%, HPosn%, VPosn%) '* '* Gets current mouse status '* LBtn%, RBtn%, and MBtn% return '* 1 if button is down or 0 if button is up '* HPosn% returns horizontal position '* VPosn% returns vertical position '* IF MouseReady% THEN MReg.AX = 3 MouseCall LBtn% = MReg.BX AND 1 RBtn% = (MReg.BX AND 2) \ 2 MBtn% = (MReg.BX AND 4) \ 4 HPosn% = MReg.CX VPosn% = MReg.DX ELSE LBtn% = 0: RBtn% = 0: MBtn% = 0 HPosn% = -1: VPosn% = -1 END IF END SUB SUB MouseHide '* '* Hide the mouse cursor '* Decrement the mouse cursor flag '* Cursor hidden if flag <> 0 '* MouseInit sets flag to -1 '* IF MouseReady% THEN MReg.AX = 2 MouseCall END IF END SUB FUNCTION MouseInit% '* '* Initialize mouse and return '* number of buttons '* Return 0 if mouse driver '* unavailable or mouse not '* present '* DEF SEG = 0 Sum% = 0 FOR I% = &H33 * 4 TO &H33 * 4 + 3 Sum% = Sum% + PEEK(I%) NEXT I% IF Sum% = 0 THEN MouseInit% = 0 EXIT FUNCTION END IF MReg.AX = 0 MouseCall IF MReg.AX = 0 THEN MouseInit% = 0 ELSE MouseInit% = MReg.BX END IF END FUNCTION SUB MouseReadCounters (HCount%, VCount%) '* '* Returns mouse movement relative to '* the last time this function was called '* Measurements are in "mickeys". By default, '* 1 mickey = 1 pixel horizontally and '* 2 mickeys = 1 pixel vertically '* IF MouseReady% THEN MReg.AX = 11 MouseCall HCount% = MReg.CX VCount% = MReg.DX END IF END SUB SUB MouseSetHorizRange (HMin%, HMax%) '* '* Sets the minimum and maximum horizontal '* range of the mouse cursor. '* Moves the cursor inside the range if it's '* outside. '* IF MouseReady% THEN MReg.AX = 7 MReg.CX = HMin% MReg.DX = HMax% MouseCall END IF END SUB SUB MouseSetPosn (HPosn%, VPosn%) '* '* Sets mouse cursor to HPosn and VPosn '* IF MouseReady% THEN MReg.AX = 4 MReg.CX = HPosn% MReg.DX = VPosn% MouseCall END IF END SUB SUB MouseSetup '* '* Setup to use mouse '* MUST be called before '* MouseInit or any other '* mouse calls '* RESTORE MouseInt DEF SEG = VARSEG(MouseRoutine%(0)) Addr% = VARPTR(MouseRoutine%(0)) FOR I = 0 TO 39 READ A$ POKE Addr% + I, VAL("&H" + A$) NEXT I IF A$ <> "CB" THEN ERROR 255 DEF SEG END SUB SUB MouseSetVertRange (VMin%, VMax%) '* '* Sets the minimum and maximum vertical '* range of the mouse cursor '* Moves the cursor inside the range if it's '* outside IF MouseReady% THEN MReg.AX = 8 MReg.CX = VMin% MReg.DX = VMax% MouseCall END IF END SUB SUB MouseShow '* '* Display the mouse cursor '* Increments mouse cursor flag '* Cursor is displayed if flag is 0 '* MouseInit sets flag to -1 '* IF MouseReady% THEN MReg.AX = 1 MouseCall END IF END SUB