DECLARE SUB DisableSound ()
DECLARE SUB CheckDRV ()
DECLARE SUB TwoPlayer ()
DECLARE SUB CheckPass ()
'$DYNAMIC
DECLARE SUB Flames ()
DECLARE SUB TheEnd ()
DECLARE SUB SaveBMP (Filename$)
DECLARE SUB Unload ()
DECLARE SUB unloadmidi ()
DECLARE SUB IntX (intnum AS INTEGER, Regs AS ANY)
DECLARE SUB TestLevel (Livello$)
DECLARE SUB OpenEpisode (Nome$)
DECLARE SUB Level (Livello$)
DECLARE SUB PlayLevel (num$)
DECLARE SUB Chapter (chap$)
DECLARE SUB CheckPrintTempo ()
DECLARE SUB PlayMidi ()
DECLARE SUB LoadMidi (Filename$)
DECLARE SUB LoadLarge (Filename$)
DECLARE SUB PlayLarge ()
'$INCLUDE: 'directqb.bi'
'$INCLUDE: 'qb2.bi'
DECLARE SUB PauseProgram ()
DECLARE SUB ResumeMIDI ()
DECLARE SUB PauseMIDI ()
DECLARE SUB ViewBar ()
DECLARE SUB stopmidi ()
DECLARE FUNCTION TimeMIDI! ()
DECLARE SUB SetupPal ()
DECLARE SUB StartFlame ()
DECLARE SUB Delay (a%)
OPTION BASE 0
DEFINT A-Z
DECLARE SUB ViewFrames ()
DECLARE SUB Panic ()
DECLARE SUB CreateBall (Tipo%, X%, Y%, dx%, dy%)
DECLARE SUB MouseHide ()
DECLARE SUB Credit ()
DECLARE SUB ReturnData (Button%, X%, Y%)
DECLARE SUB MainMenu ()
DECLARE SUB MouseCursor ()
DECLARE SUB MouseShow ()
DECLARE SUB Chiud ()
DECLARE SUB Intro ()
DECLARE SUB IntroLevel ()
DECLARE SUB TESTFRAMES ()
DECLARE SUB Deathman (Balla%)
DECLARE SUB Clearball ()
DECLARE SUB Pause ()
DECLARE SUB Game ()
DECLARE SUB CheckMan ()
DECLARE SUB Pale (f$)
DECLARE SUB MoveMan ()
DECLARE SUB Stopprogram ()
DECLARE SUB EraseBall (BTE%)
DECLARE SUB CheckSparo ()
DECLARE SUB MoveSparo ()
DECLARE SUB DrawSparo ()
DECLARE SUB AttivaSparo ()
DECLARE FUNCTION NumberOfFreeBall! ()
DECLARE SUB SplitBall (Balla%)
DECLARE SUB LoadBall ()
DECLARE SUB MoveBalls ()
DECLARE SUB DrawBall ()
DECLARE SUB Initall ()
DECLARE SUB Shadetxt2 (message$, X!, Y!, way!)
DECLARE SUB ShowBMP (File$)
DECLARE SUB Fadeout ()
DECLARE FUNCTION MusicDone% ()
DECLARE FUNCTION BytesRequired& (Filename$)
DIM SHARED exited
DIM SHARED B1(842) AS INTEGER
DIM SHARED B2(222) AS INTEGER
DIM SHARED B3(64) AS INTEGER
DIM SHARED B4(19) AS INTEGER
DIM SHARED ManBuff(226) AS INTEGER
DIM SHARED ManBuff2(226) AS INTEGER
DIM SHARED ManBuff3(226) AS INTEGER
DIM SHARED ManBuff4(226) AS INTEGER
DIM SHARED ManBuff5(226) AS INTEGER
DIM SHARED ManBuff6(226) AS INTEGER
DIM SHARED ManBuff7(226) AS INTEGER
DIM SHARED Head(61) AS INTEGER
DIM SHARED Bar(3201) AS INTEGER
DIM SHARED Press
DIM SHARED Regs AS RegTypeX
DIM SHARED Tempo AS LONG
DIM SHARED TStart AS LONG
CONST MaxBall = 70

TYPE M
Ciclo AS INTEGER
Punti AS LONG
Vite AS INTEGER
X AS INTEGER
Y AS INTEGER
Delay AS INTEGER
Frame AS INTEGER
Direction AS INTEGER
END TYPE

TYPE SP
Count AS INTEGER
X AS INTEGER
Y AS INTEGER
Attivo AS INTEGER
Increment AS INTEGER
END TYPE

TYPE Balls
X AS INTEGER
Y AS INTEGER
Tipo AS INTEGER
DIRECTIONX AS INTEGER
DIRECTIONY AS INTEGER
MaxX AS INTEGER
MaxY AS INTEGER
MinX AS INTEGER
MinY AS INTEGER
DIMENSION AS INTEGER
Mantieni AS INTEGER
END TYPE

TYPE LVL
Music AS STRING * 40
BackGr AS STRING * 40
Level AS INTEGER
Time AS INTEGER
SparoSpeed AS INTEGER
END TYPE
DIM SHARED Levels AS LVL
DIM SHARED Passed AS INTEGER
DIM SHARED RMT AS INTEGER
DIM SHARED Numb AS INTEGER
DIM SHARED Man AS M
DIM SHARED Sparo AS SP
DIM SHARED Ball(1 TO MaxBall) AS Balls
DIM SHARED death
DIM SHARED stringa AS STRING
DIM SHARED Palett AS STRING * 768
DIM Tempos AS LONG
CONST True = -1, FALSE = 0
Initall
Intro
'TwoPlayer
MainMenu
Stopprogram
END

Errore:
RESUME NEXT

SUB AttivaSparo
IF NOT Sparo.Attivo = 1 THEN
Sparo.Count = 1
Sparo.Attivo = 1
Sparo.Y = 160
Sparo.X = Man.X - 3
END IF
END SUB

REM $STATIC
SUB Chapter (chap$)
DQBinstallKeyboard
stopmidi

Unload

CLOSE #9
OPEN LTRIM$(RTRIM$(chap$)) FOR INPUT AS #9
LINE INPUT #9, num$
LINE INPUT #9, Levels.Music

'Levels.Music = RTRIM$(LTRIM$(Music))

LINE INPUT #9, Levels.BackGr

ShowBMP LTRIM$(RTRIM$(Levels.BackGr))

DQBCopyLayer 0, 2

DQBclearLayer 0

LINE INPUT #9, SScreen$

ShowBMP LTRIM$(RTRIM$(SScreen$))
LOCATE 1, 1: COLOR 15: PRINT "PassWord:";
IF chap$ = "levels\chap2.cpt" THEN PRINT "IDKF"
IF chap$ = "levels\chap3.cpt" THEN PRINT "ERTY"
IF chap$ = "levels\chap4.cpt" THEN PRINT "XOLI"
IF chap$ = "levels\chap5.cpt" THEN PRINT "PILO"
Pause

LoadMidi Levels.Music

PlayMidi

FOR i = 1 TO VAL(num$)

LINE INPUT #9, a$

LINE INPUT #9, B$

LINE INPUT #9, c$

Levels.Time = VAL(B$)

Sparo.Increment = VAL(c$)

Level a$

IF exited = -1 THEN EXIT SUB

NEXT i
IF chap$ = "levels\chap1.cpt" THEN Man.Vite = Man.Vite + 1
END SUB

SUB CheckMan
FOR i = LBOUND(Ball) TO UBOUND(Ball)
IF NOT Ball(i).Tipo = 0 THEN
IF Ball(i).Y > 120 AND Ball(i).X > Man.X - 50 AND Ball(i).X < Man.X + 50 THEN
FOR X = Man.X - 7 TO Man.X + 5
IF Ball(i).X = X OR (Ball(i).X - Ball(i).DIMENSION) = X OR Ball(i).X = X OR (Ball(i).X + Ball(i).DIMENSION) = X THEN
   FOR Y = Man.Y - 27 TO Man.Y
IF Ball(i).Y = Y OR (Ball(i).Y - Ball(i).DIMENSION) = Y OR Ball(i).Y = Y OR (Ball(i).Y + Ball(i).DIMENSION) = Y THEN
Deathman (i)
EXIT SUB
END IF
NEXT Y
END IF
NEXT X

END IF
END IF
NEXT i
END SUB

SUB CheckPass

DQBRemoveKeyboard

DQBbox 0, 60, 110, 260, 130, 255
DQBboxf 0, 61, 111, 259, 129, 252
Testo$ = "Insert the password:" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 62, 111, 255
LOCATE 15, 15: COLOR 255
stringa$ = ""
DO

char$ = INPUT$(1)
char$ = UCASE$(char$)

IF char$ = CHR$(13) AND LEN(stringa$) = 4 THEN
IF stringa$ = "IDKF" THEN Passed = True: RMT = 1
IF stringa$ = "ERTY" THEN Passed = True: RMT = 2
IF stringa$ = "XOLI" THEN Passed = True: RMT = 3
IF stringa$ = "PILO" THEN Passed = True: RMT = 4
IF Passed = True THEN
DQBinstallKeyboard
MouseHide
OpenEpisode "levels\commandp.eps"
MouseShow
END IF
EXIT SUB
END IF

IF char$ = CHR$(8) THEN
IF LEN(stringa$) <> 0 THEN
stringa$ = MID$(stringa$, 1, LEN(stringa$) - 1)
END IF
GOTO cicl:
END IF
IF char$ = CHR$(27) THEN DQBinstallKeyboard: EXIT SUB
IF char$ <> " " AND NOT LEN(stringa$) = 4 THEN
stringa$ = stringa$ + char$
END IF
cicl:

DQBboxf 0, 65, 120, 105, 129, 252
Testo$ = stringa$ + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 65, 120, 255
LOOP

END SUB

SUB CheckPrintTempo
Tempos = Levels.Time - (TIMER - INT(TStart))
stringa$ = STR$(Tempos) + CHR$(0)
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), 152, 188, 1
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), 151, 189, 15
IF Tempos < 15 THEN
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), 152, 188, 1
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), 151, 189, 12
END IF
IF Tempos <= 0 THEN Deathman 1
END SUB

REM $DYNAMIC
SUB CheckSparo
IF Sparo.Attivo = 1 THEN
FOR i = LBOUND(Ball) TO UBOUND(Ball)
IF Ball(i).X >= Sparo.X - 25 OR Ball(i).X <= Sparo.X + 25 THEN
SELECT CASE Ball(i).Tipo
CASE 1
FOR T = Sparo.X - 20 TO Sparo.X + 20
IF Ball(i).X = T THEN
FOR R = 300 TO Sparo.Y STEP -1
IF Ball(i).Y = R THEN
SplitBall (i)
Sparo.Attivo = 0
EXIT SUB
END IF
NEXT R
END IF
NEXT T

CASE 2
FOR T = Sparo.X - 10 TO Sparo.X + 10
IF Ball(i).X = T THEN
FOR R = 200 TO Sparo.Y STEP -1
IF Ball(i).Y = R THEN
SplitBall (i)
Sparo.Attivo = 0
EXIT SUB
END IF
NEXT R
END IF
NEXT T
CASE 3
FOR T = Sparo.X - 5 TO Sparo.X + 5
IF Ball(i).X = T THEN
FOR R = 300 TO Sparo.Y STEP -1
IF Ball(i).Y = R THEN
SplitBall (i)
Sparo.Attivo = 0
EXIT SUB
END IF
NEXT R
END IF
NEXT T
CASE 4
FOR T = Sparo.X - 3 TO Sparo.X + 3
IF Ball(i).X = T THEN
FOR R = 300 TO Sparo.Y STEP -1
IF Ball(i).Y = R THEN
SplitBall (i)
Sparo.Attivo = 0
EXIT SUB
END IF
NEXT R
END IF
NEXT T
END SELECT
END IF
NEXT i
END IF

END SUB

REM $STATIC
SUB Chiud
COLOR 0
FOR i = 0 TO 99
PSET (0, i)
DRAW "r320"
PSET (0, 200 - i)
DRAW "r320"
FOR Y = 1 TO 20000
NEXT Y
NEXT i
FOR i = 0 TO 160
PSET (i, 100)
PSET (320 - i, 100)
FOR Y = 1 TO 5000: NEXT Y
NEXT i
COLOR 15
END SUB

SUB Clearball
FOR u = LBOUND(Ball) TO UBOUND(Ball)
Ball(u).Tipo = 0
Ball(u).X = 0
Ball(u).Y = 0
Ball(u).DIRECTIONX = 0
Ball(u).DIRECTIONY = 0
Ball(u).DIMENSION = 0
Ball(u).MaxX = 0
Ball(u).MaxY = 0
NEXT u
END SUB

SUB CreateBall (Tipo%, X%, Y%, dx%, dy%)
HND% = NumberOfFreeBall
Ball(HND%).Tipo = Tipo%
Ball(HND%).X% = X%
Ball(HND%).Y% = Y%
Ball(HND%).DIRECTIONX% = dx%
Ball(HND%).DIRECTIONY% = dy%
IF Ball(HND%).Tipo = 1 THEN Ball(HND%).DIMENSION = 20: Ball(HND%).MaxX = 300: Ball(HND%).MaxY = 180: Ball(HND%).MinX = 20: Ball(HND%).MinY = 40
IF Ball(HND%).Tipo = 2 THEN Ball(HND%).DIMENSION = 10: Ball(HND%).MaxX = 300: Ball(HND%).MaxY = 180: Ball(HND%).MinX = 20: Ball(HND%).MinY = 60
IF Ball(HND%).Tipo = 3 THEN Ball(HND%).DIMENSION = 5: Ball(HND%).MaxX = 300: Ball(HND%).MaxY = 180: Ball(HND%).MinX = 20: Ball(HND%).MinY = 90
IF Ball(HND%).Tipo = 4 THEN Ball(HND%).DIMENSION = 2: Ball(HND%).MaxX = 300: Ball(HND%).MaxY = 180: Ball(HND%).MinX = 20: Ball(HND%).MinY = 100
Numb = Numb + 1
END SUB

SUB Deathman (Balla)
Sparo.Y = 180
Sparo.Attivo = 0
Man.Vite = Man.Vite - 1
death = 1
Fadeout
DQBWait 50
CLS : PALETTE
IF Man.Vite < 0 THEN
ShowBMP "bmp\gameover.bmp"
DQBRemoveKeyboard
SLEEP
stopmidi
Unload
  DIM melt%(3000)
  FOR RR = 1 TO 3000
    RANDOMIZE TIMER
    XX = INT(RND * 271)
    RANDOMIZE TIMER
    YX = INT(RND * 150)
    GET (XX, YX)-(XX + 48, YX + 48), melt%
    PUT (XX, YX + 1), melt%, PSET
    IF INKEY$ = CHR$(27) THEN END
  NEXT RR
DQBinstallKeyboard
END IF
DQBclearLayer 1
END SUB

SUB Delay (a%)
T& = INT(TIMER)
DO
LOOP UNTIL T& + a% = INT(TIMER)
END SUB

REM $DYNAMIC
SUB DrawBall
DQBclearLayer 1
DQBCopyLayer 2, 1
FOR i = LBOUND(Ball) TO UBOUND(Ball)
IF NOT Ball(i).Tipo = 0 THEN
SELECT CASE Ball(i).Tipo
CASE 1
CALL DQBput(1, Ball(i).X - 20, Ball(i).Y - 20, VARSEG(B1(0)), VARPTR(B1(0)))
CASE 2
CALL DQBput(1, Ball(i).X - 10, Ball(i).Y - 10, VARSEG(B2(0)), VARPTR(B2(0)))
CASE 3
CALL DQBput(1, Ball(i).X - 5, Ball(i).Y - 5, VARSEG(B3(0)), VARPTR(B3(0)))
CASE 4
CALL DQBput(1, Ball(i).X - 2, Ball(i).Y - 2, VARSEG(B4(0)), VARPTR(B4(0)))
END SELECT
END IF
NEXT i
END SUB

SUB DrawSparo
IF Sparo.Attivo = 1 THEN
IF Sparo.Y <= 20 THEN
Sparo.Attivo = 0
EXIT SUB
ELSE
IF Sparo.Y = INT(Sparo.Y) THEN
FOR o% = 180 TO Sparo.Y STEP -1
CALL DQBpset(1, Sparo.X, o%, 15)
NEXT o%
FOR o% = 180 TO Sparo.Y STEP -1
CALL DQBpset(1, Sparo.X - 1, o%, 1)
NEXT o%
FOR o% = 180 TO Sparo.Y STEP -1
CALL DQBpset(1, Sparo.X + 1, o%, 1)
NEXT o%

END IF
END IF
END IF
END SUB

SUB EraseBall (BTE)
Ball(BTE).X = 0
Ball(BTE).Y = 0
Ball(BTE).Tipo = 0
Ball(BTE).DIRECTIONX = 0
Ball(BTE).DIRECTIONY = 0
END SUB

SUB Initall
OPEN "pang.ini" FOR INPUT AS #1
INPUT #1, loaded%
IF loaded% = 0 THEN
DisableSound
ELSE
CheckDRV
END IF
CLOSE #1
Man.Ciclo = 49

Man.Frame = 1

Sparo.Increment = 3

Man.Vite = 5

Man.Delay = 1

SCREEN 0, 0, 0: WIDTH 80: CLS
PRINT "Initialiting Library..."
PRINT
PRINT "Loading Balls..."

LoadBall

PRINT "Getting EMS...";
X = DQBinit(3, 0)

IF X = 0 THEN
PRINT "OK"
END IF

PRINT "Detecting JoyStick 1...";
IF DQBjoyDetected(0) THEN PRINT "Detected":  ELSE PRINT "Not Detected"

PRINT "Detecting JoyStick 2...";
IF DQBjoyDetected(1) THEN PRINT "Detected":  ELSE PRINT "Not Detected"

PRINT "Installing keyboard...";
DQBinstallKeyboard
PRINT "OK"
PRINT "Press a key to continue..."

X% = MouseInit%
DQBsetTransPut
'DO
'LOOP UNTIL DQBkey(KeyEnter)

SCREEN 13

END SUB

REM $STATIC
SUB Intro
DQBRemoveKeyboard
SCREEN 13: CLS
DQBinstallKeyboard
Testo$ = "Press ENTER to see the introduction or" + CHR$(0)
testo2$ = "Press ESC to skip the introduction" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 1, 80, 1
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 2, 81, 15
DQBPrint 0, VARSEG(testo2$), SADD(testo2$), 1, 100, 1
DQBPrint 0, VARSEG(testo2$), SADD(testo2$), 2, 101, 15
DO
IF DQBkey(1) THEN GOTO Fines
IF DQBkey(&H1C) THEN EXIT DO
LOOP
DQBRemoveKeyboard

SCREEN 13

LoadMidi "midi\new05.mid"
PlayMidi
GOTO pr:
DIM a%(32000)

DEF SEG = VARSEG(a%(0))
BLOAD "graph\tlp.arr", VARPTR(a%(0))
Pale "graph\tlp.pal"
CLS
i& = 0

DO
DEF SEG = VARSEG(a%(0))

i& = i& + 1

X& = PEEK(i&)

DEF SEG = &HA000

POKE i&, X&

LOOP UNTIL i& = 32000

i& = 0
Delay 3
DO
DEF SEG = VARSEG(a%(0))
i& = i& + 1
IF i& > 32000 THEN EXIT DO
X& = PEEK(i& + 32000)
DEF SEG = &HA000
POKE i& + 32000, X&
LOOP UNTIL i& = 32000
DEF SEG = &HA000
Delay 3
DO
X& = X& + 1
IF X& > 60000 THEN EXIT DO
POKE X&, 0
LOOP UNTIL X& = 60000
PALETTE
CLS
ERASE a%
pr:
ShowBMP "bmp\title.bmp"
Delay 5
ShowBMP "bmp\title2.bmp"
Delay 6
PALETTE
CLS
DEBUG1:
'GOTO debg:
DIM ManShoot(0 TO 451) AS INTEGER
DIM ManNormal(226)  AS INTEGER
DIM ManShoot2(0 TO 451) AS INTEGER
DIM ManNormal2(226)  AS INTEGER
DIM MegaBall(5547) AS INTEGER
'Big Ball
OPEN "graph\Bball.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 5547
GET #1, , MegaBall(i)
NEXT i
CLOSE #1
'Two Man
OPEN "graph\ManN.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManNormal(i)
NEXT i
CLOSE #1
OPEN "graph\ManN2.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManNormal2(i)
NEXT i
CLOSE #1
'Man at shoot
OPEN "graph\ManS.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 451
GET #1, , ManShoot(i)
NEXT i
CLOSE #1
OPEN "graph\ManS2.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 451
GET #1, , ManShoot2(i)
NEXT i
CLOSE #1
'Ok
DQBclearLayer 0
'GOTO debg
H& = TIMER
DQBput 0, 100, 90, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
DQBput 0, 250, 115, VARSEG(B4(0)), VARPTR(B4(0))
stringa$ = "OOO, what a cool ball..." + CHR$(0)

DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 50, 40, 15

Delay 3
DQBclearLayer 0
DQBput 0, 100, 90, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
DQBput 0, 250, 115, VARSEG(B4(0)), VARPTR(B4(0))
stringa$ = "I'll take it!" + CHR$(0)

DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 50, 40, 15

Delay 2

DQBclearLayer 0
DQBput 0, 100, 90, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
DQBput 0, 250, 115, VARSEG(B4(0)), VARPTR(B4(0))
stringa$ = "?" + CHR$(0)

DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 250, 40, 15
Delay 2

FOR i = 250 TO 320
DQBclearLayer 0
DQBput 0, 100, 90, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
DQBput 0, i, 115, VARSEG(B4(0)), VARPTR(B4(0))
DQBWait 1
NEXT i
stringa$ = "Wait!" + CHR$(0)
FOR i = 100 TO 320 STEP 20

FOR a = i TO i + 6
DQBclearLayer 0
DQBput 0, a, 90, VARSEG(ManBuff5(0)), VARPTR(ManBuff5(0))
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), a, 40, 15
DQBWait 1
NEXT a

FOR a = i + 7 TO i + 13
DQBclearLayer 0
DQBput 0, a, 90, VARSEG(ManBuff6(0)), VARPTR(ManBuff6(0))
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), a, 40, 15
DQBWait 1
NEXT a

FOR a = i + 14 TO i + 20
DQBclearLayer 0
DQBput 0, a, 90, VARSEG(ManBuff7(0)), VARPTR(ManBuff7(0))
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), a, 40, 15
DQBWait 1
NEXT a
NEXT i
'------'
DQBclearLayer 0
stringa$ = "BOOM" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 300, 40, 15
Delay 1
DQBclearLayer 0
stringa$ = "WHAT?" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 300, 40, 15
Delay 1
DQBclearLayer 0
stringa$ = "HELP!" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 300, 40, 15
Delay 1
DQBclearLayer 0



stringa$ = "Help!" + CHR$(0)
FOR i = 300 TO -100 STEP -20

FOR a = i TO i - 6 STEP -1
DQBclearLayer 0
DQBclearLayer 1
DQBput 1, a, 90, VARSEG(ManBuff(0)), VARPTR(ManBuff(0))
DQBput 1, a + 80, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), a, 40, 15
DQBCopyLayer 1, 0
DQBWait 1
NEXT a

FOR a = i - 7 TO i - 13 STEP -1
DQBclearLayer 0
DQBclearLayer 1
DQBput 1, a, 90, VARSEG(ManBuff2(0)), VARPTR(ManBuff2(0))
DQBput 1, a + 80, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), a, 40, 15
DQBCopyLayer 1, 0
DQBWait 1
NEXT a

FOR a = i - 14 TO i - 20 STEP -1
DQBclearLayer 0
DQBclearLayer 1
DQBput 1, a, 90, VARSEG(ManBuff3(0)), VARPTR(ManBuff3(0))
DQBput 1, a + 80, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), a, 40, 15
DQBCopyLayer 1, 0
DQBWait 1
NEXT a
NEXT i

stringa$ = "Now I take my gun..." + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 0, 40, 15
Delay 3

FOR i = 1 TO 200
DQBclearLayer 1
DQBput 1, i, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT i

FOR i = 0 TO 100 STEP 20
FOR a = i TO i + 6
DQBclearLayer 0
DQBclearLayer 1
DQBput 1, a, 90, VARSEG(ManBuff5(0)), VARPTR(ManBuff5(0))
DQBput 1, 200, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT a

FOR a = i + 7 TO i + 13
DQBclearLayer 0
DQBclearLayer 1
DQBput 1, a, 90, VARSEG(ManBuff6(0)), VARPTR(ManBuff6(0))
DQBput 1, 200, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT a

FOR a = i + 14 TO i + 20
DQBclearLayer 0
DQBclearLayer 1
DQBput 1, a, 90, VARSEG(ManBuff7(0)), VARPTR(ManBuff7(0))
DQBput 1, 200, 100, VARSEG(B2(0)), VARPTR(B2(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT a
NEXT i
DQBboxf 0, 100, 85, 150, 120, 0
DQBput 0, 120, 90, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))

DQBWait 5
FOR i = 0 TO 20 STEP 2
FOR B = 0 TO 20
DQBpset 0, B + 200, i + 100, 0
DQBWait 1
NEXT B
FOR B = 20 TO 0 STEP -1
DQBpset 0, B + 200, i + 1 + 100, 0
NEXT B
NEXT i
stringa$ = "What?" + CHR$(0)
DQBclearLayer 0
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 40, 15
DQBboxf 0, 100, 85, 150, 120, 0
DQBput 0, 120, 90, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
Delay 2
DQBsetSolidText
stringa$ = "                    " + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 40, 15
DQBsetTransText
stringa$ = "Where is the ball?" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 40, 15
DQBboxf 0, 100, 85, 150, 120, 0
DQBput 0, 120, 90, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
Delay 2
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 40, 15
DQBboxf 0, 100, 85, 150, 120, 0
DQBput 0, 120, 90, VARSEG(ManNormal(0)), VARPTR(ManNormal(0))
Delay 2
DQBscroll 0, 0, 0
FOR i = 1 TO 50
DQBclearLayer 0
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 38, 15
DQBboxf 0, 100, 85, 150, 100, 0
DQBput 0, 120, 88, VARSEG(ManNormal(0)), VARPTR(ManNormal(0))
DQBWait 1
DQBclearLayer 0
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 42, 15
DQBboxf 0, 100, 85, 150, 140, 0
DQBput 0, 120, 92, VARSEG(ManNormal(0)), VARPTR(ManNormal(0))
DQBWait 1
NEXT i

FOR i = 1 TO 70
DQBclearLayer 1
DQBput 1, 100, 90, VARSEG(ManNormal(0)), VARPTR(ManNormal(0))
DQBput 1, 80, i, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))
DQBCopyLayer 1, 0
NEXT i
Delay 2
SetupPal
Delay 1
StartFlame
Fines:
SCREEN 13
stopmidi
Unload
DQBinstallKeyboard
DQBclearLayer 2
DQBboxf 2, 0, 0, 320, 200, 10
'Stopprogram
ERASE ManNormal
ERASE ManNormal2
ERASE ManShoot
ERASE ManShoot2
ERASE MegaBall
END SUB

SUB IntroLevel

DrawBall
DQBCopyLayer 1, 0
Text$ = "Ready!" + CHR$(0)
DQBPrint 0, VARSEG(Text$), SADD(Text$), 130, 50, 1
DQBPrint 0, VARSEG(Text$), SADD(Text$), 129, 49, 15
DQBWait 50
Text$ = "Go!" + CHR$(0)
DQBPrint 0, VARSEG(Text$), SADD(Text$), 130, 70, 1
DQBPrint 0, VARSEG(Text$), SADD(Text$), 129, 69, 15
DQBWait 100
END SUB

SUB Level (Livello$)
ON ERROR GOTO Errore:
Rinizia:
Numb = 0
Clearball
Ciclo = 0

PlayLevel Livello$

death = 0
Sparo.X = 180

DQBsetBIOSfont

Man.X = 160
Man.Y = 180
Quante& = 0

IntroLevel
TStart = INT(TIMER)
DO
Ciclo = Ciclo + 1
IF Sparo.Count <> 0 THEN Sparo.Count = Sparo.Count + 1

IF Press = 1 THEN
Man.Ciclo = Man.Ciclo + 1
ELSE
Man.Frame = 4
Man.Ciclo = 1
END IF

IF Ciclo = 2 THEN


DQBclearLayer 1

MoveSparo
MoveBalls
CheckMan

IF death = 1 THEN EXIT DO
CheckSparo
DrawBall
DrawSparo
MoveMan
Ciclo = 0
END IF

IF DQBkey(KEYSPACE) THEN AttivaSparo: Man.Frame = 4: Man.Ciclo = 0

IF DQBkey(KEYRIGHT) AND Sparo.Count = 0 THEN
Man.X = Man.X + 1: Press = 1: Man.Direction = 0: IF Man.Frame = 4 OR Man.Direction = 1 THEN Man.Frame = 1: Man.Direction = 0: Man.Ciclo = 0
GOTO AfterKey
ELSE
Press = 0
END IF

IF DQBkey(KEYLEFT) AND Sparo.Count = 0 THEN
Man.X = Man.X - 1: Press = 1: Man.Direction = 1: IF Man.Frame = 4 OR Man.Direction = 0 THEN Man.Frame = 1: Man.Direction = 1: Man.Ciclo = 0
GOTO AfterKey:
ELSE
Press = 0
END IF
AfterKey:
IF DQBkey(&H19) THEN Pause
ViewBar
CheckPrintTempo
DQBCopyLayer 1, VIDEO
IF Man.Delay <> 0 THEN
DQBWait Man.Delay

END IF

IF Numb = 0 THEN GOTO nrt:

IF Sparo.Count >= 7 THEN Sparo.Count = 0
LOOP UNTIL DQBkey(KEYESC)
IF DQBkey(KEYESC) THEN exited = -1
IF Man.Vite < 0 THEN exited = -1: EXIT SUB

IF death = 1 THEN GOTO Rinizia

nrt:

END SUB

REM $DYNAMIC
SUB LoadBall
PRINT "1.bll  ...";
OPEN "graph\1.bll" FOR BINARY AS #1
GET #1, , H
FOR i = 0 TO 842
GET #1, , B1(i)
NEXT i
CLOSE #1
PRINT "OK"
PRINT "2.bll  ...";
OPEN "graph\2.bll" FOR BINARY AS #1
GET #1, , H
FOR i = 0 TO 222
GET #1, , B2(i)
NEXT i
CLOSE #1
PRINT "OK"
PRINT "3.bll  ...";
OPEN "graph\3.bll" FOR BINARY AS #1
GET #1, , H
FOR i = 0 TO 64
GET #1, , B3(i)
NEXT i
CLOSE #1
PRINT "OK"
PRINT "4.bll  ...";
OPEN "graph\4.bll" FOR BINARY AS #1
GET #1, , H
FOR i = 0 TO 19
GET #1, , B4(i)
NEXT i
CLOSE #1
PRINT "OK"
CLOSE
PRINT "Man...";
OPEN "graph\man.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff(i)
NEXT i
CLOSE
PRINT "OK"
PRINT "Man2...";
OPEN "graph\man2.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff2(i)
NEXT i
CLOSE
PRINT "OK"
PRINT "Man3...";
OPEN "graph\man3.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff3(i)
NEXT i
CLOSE
PRINT "OK"
PRINT "Man4...";
OPEN "graph\man4.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff4(i)
NEXT i
CLOSE
PRINT "OK"
PRINT "Man5...";
OPEN "graph\man5.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff5(i)
NEXT i
CLOSE
PRINT "OK"
PRINT "Man6...";
OPEN "graph\man6.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff6(i)
NEXT i
CLOSE
PRINT "OK"
PRINT "Man7...";
OPEN "graph\man7.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManBuff7(i)
NEXT i
CLOSE
PRINT "Head..."
OPEN "graph\head.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 61
GET #1, , Head(i)
NEXT i
CLOSE
PRINT "Bar title"
OPEN "graph\bar.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 3201
GET #1, , Bar(i)
NEXT i
CLOSE

PRINT "OK"
END SUB

REM $STATIC
SUB MainMenu
IniMenu:
stopmidi
Unload
MouseHide
ShowBMP "bmp\menu3.bmp"
CLOSE
Man.Vite = 5
Text$ = "One player game" + CHR$(0)
DQBPrint 0, VARSEG(Text$), SADD(Text$), 102, 80, 255
DQBPrint 0, VARSEG(Text$), SADD(Text$), 101, 79, 252

Text$ = "One player Panic" + CHR$(0)

DQBPrint 0, VARSEG(Text$), SADD(Text$), 98, 100, 255
DQBPrint 0, VARSEG(Text$), SADD(Text$), 97, 99, 252

Text$ = "Two player time-combat" + CHR$(0)

DQBPrint 0, VARSEG(Text$), SADD(Text$), 78, 120, 252
DQBPrint 0, VARSEG(Text$), SADD(Text$), 77, 119, 15

Text$ = "Credits" + CHR$(0)

DQBPrint 0, VARSEG(Text$), SADD(Text$), 135, 140, 255
DQBPrint 0, VARSEG(Text$), SADD(Text$), 134, 139, 252

Text$ = "Exit" + CHR$(0)

DQBPrint 0, VARSEG(Text$), SADD(Text$), 150, 160, 255
DQBPrint 0, VARSEG(Text$), SADD(Text$), 149, 159, 252

MouseShow
MouseShow
MouseShow
DO

'Primo bottone
'x1=200 x2=440 y1=78 y2=88

ReturnData Button%, X%, Y%

IF Button% = 1 THEN

DO
ReturnData Button%, X%, Y%
LOOP UNTIL Button = 0

IF (X% >= 200 AND X% <= 440) AND (Y% >= 78 AND Y% <= 88) THEN 'One player

MouseHide

DQBbox 0, 100, 70, 240, 100, 255
DQBboxf 0, 101, 71, 239, 99, 252
Testo$ = "New Game" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 103, 73, 255
Testo$ = "Insert PassWord" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 103, 82, 255
Testo$ = "Return" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 103, 91, 255
MouseShow
DO
ReturnData Button%, X%, Y%

IF Button% = 1 THEN

IF X <= 332 AND X >= 206 AND Y >= 73 AND Y <= 80 THEN
DQBclearLayer 0
PALETTE
DQBCopyLayer 0, 2
MouseHide
Unload
RMT = 0
Passed = FALSE
OpenEpisode "levels\CommandP.EPS"
GOTO IniMenu
END IF

IF X <= 298 AND X >= 206 AND Y >= 91 AND Y <= 98 THEN
GOTO IniMenu
END IF

IF X <= 444 AND X >= 206 AND Y >= 82 AND Y <= 89 THEN
CheckPass
GOTO IniMenu
END IF

END IF
LOOP

END IF

IF (X% >= 298 AND X% <= 360) AND (Y% >= 158 AND Y% <= 168) THEN 'Exit
MouseHide
DQBbox 0, 100, 100, 220, 150, 255
DQBboxf 0, 101, 101, 219, 149, 252
Testo$ = "Are you sure?" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 110, 110, 255
Testo$ = "(Y/N)" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), 140, 120, 255
DQBRemoveKeyboard

DO
X$ = INPUT$(1)
IF UCASE$(X$) = "Y" THEN Stopprogram
IF UCASE$(X$) = "N" THEN DQBinstallKeyboard: GOTO IniMenu:
LOOP

Stopprogram
END
END IF

IF (X% >= 190 AND X% <= 450) AND (Y% >= 98 AND Y% <= 108) THEN 'One player P
PanicS:
MouseHide
PALETTE
DQBclearLayer 2
ShowBMP "bmp\1.bmp"
DQBCopyLayer 0, 2
Panic
GOTO IniMenu:
END IF

IF (X% >= 268 AND X% <= 378) AND (Y% >= 139 AND Y% <= 148) THEN 'One player P
LoadMidi "midi\sample01.mid": PlayMidi
Credit
GOTO IniMenu:
END IF

END IF

LOOP

END SUB

REM $DYNAMIC
SUB MoveBalls
FOR i = LBOUND(Ball) TO UBOUND(Ball)
IF NOT Ball(i).Tipo = 0 THEN

IF Ball(i).DIRECTIONX = 1 THEN

Ball(i).X = Ball(i).X + 1

ELSE

Ball(i).X = Ball(i).X - 1

END IF

IF Ball(i).DIRECTIONY = 1 THEN

Ball(i).Y = Ball(i).Y + 1

ELSE

Ball(i).Y = Ball(i).Y - 1

END IF

IF Ball(i).X + Ball(i).DIMENSION >= Ball(i).MaxX THEN Ball(i).DIRECTIONX = 0
IF Ball(i).Y + Ball(i).DIMENSION >= Ball(i).MaxY THEN Ball(i).DIRECTIONY = 0
IF Ball(i).X - Ball(i).DIMENSION <= Ball(i).MinX THEN Ball(i).DIRECTIONX = 1
IF Ball(i).Y - Ball(i).DIMENSION <= Ball(i).MinY THEN Ball(i).DIRECTIONY = 1
END IF
NEXT i

END SUB

REM $STATIC
SUB MoveMan
IF Man.X + 10 >= 300 THEN Man.X = 290
IF Man.X - 10 <= 20 THEN Man.X = 30
 
IF Man.Frame = 4 THEN
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff4(0)), VARPTR(ManBuff4(0)))
GOTO FineSub:
END IF

IF Man.Frame = 1 THEN
IF Man.Direction = 0 THEN
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff5(0)), VARPTR(ManBuff5(0)))
END IF

IF Man.Direction = 1 THEN
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff(0)), VARPTR(ManBuff(0)))
END IF

IF Man.Ciclo >= 10 THEN
Man.Frame = 2
Man.Ciclo = 0
END IF
GOTO FineSub
END IF
IF Man.Frame = 2 THEN
IF Man.Direction = 0 THEN
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff6(0)), VARPTR(ManBuff6(0)))
END IF
IF Man.Direction = 1 THEN
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff2(0)), VARPTR(ManBuff2(0)))
END IF
IF Man.Ciclo >= 10 THEN
Man.Frame = 3
Man.Ciclo = 0
END IF
GOTO FineSub
END IF
IF Man.Frame = 3 THEN
IF Man.Direction = 1 THEN
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff3(0)), VARPTR(ManBuff3(0)))
ELSE
CALL DQBput(1, Man.X - 10, Man.Y - 30, VARSEG(ManBuff7(0)), VARPTR(ManBuff7(0)))
END IF
IF Man.Ciclo >= 10 THEN
Man.Frame = 1
Man.Ciclo = 0
END IF
END IF

FineSub:
END SUB

REM $DYNAMIC
SUB MoveSparo
IF Sparo.Attivo = 1 THEN
Sparo.Y = Sparo.Y - Sparo.Increment
END IF
END SUB

FUNCTION NumberOfFreeBall!
FOR R = LBOUND(Ball) TO UBOUND(Ball)
IF Ball(R).Tipo = 0 THEN
NumberOfFreeBall = R
EXIT FUNCTION
END IF
NEXT R
NumberOfFreeBall = -1

END FUNCTION

REM $STATIC
SUB OpenEpisode (Nome$)
ON ERROR GOTO 0
exited = 0
OPEN Nome$ FOR INPUT AS #10
LINE INPUT #10, num$

IF Passed THEN
FOR i = 1 TO RMT
LINE INPUT #10, dummy$
NEXT i
END IF
FOR i = 1 TO VAL(num$) - RMT
exited = 0
LINE INPUT #10, nume$
Chapter nume$
IF exited = -1 THEN EXIT SUB
NEXT i

IF LTRIM$(RTRIM$(UCASE$(Nome$))) = "LEVELS\COMMANDP.EPS" THEN
TheEnd
ELSE
LINE INPUT #10, finalscr$
ShowBMP finalscr$
END IF
CLOSE #10, #9
END SUB

SUB Pale (f$)
E = FREEFILE
OPEN f$ FOR BINARY AS #E
Pal$ = INPUT$(1024, E)
CLOSE #E
FOR c = 0 TO 2 ^ 8 - 1
 B = ASC(MID$(Pal$, c * 4 + 1, 1)) \ 4
 g = ASC(MID$(Pal$, c * 4 + 2, 1)) \ 4
 R = ASC(MID$(Pal$, c * 4 + 3, 1)) \ 4
 OUT &H3C8, c
 OUT &H3C9, R: OUT &H3C9, g: OUT &H3C9, B
NEXT

END SUB

SUB Panic
DQBinstallKeyboard
Man.Vite = 5
Music = 1
LoadMidi "midi\music01.mid"
PlayMidi

ON ERROR GOTO Errore:

BallRate% = 10
CreatedBall% = 0
MaxCBall% = 4

Inizia:
IF NOT BallRate% >= 10 THEN
BallRate% = BallRate% + 1
MaxCBall% = MaxCBall% - 2
CreatedBall% = MaxCBall% - 1
END IF
Numb = 1
Clearball
Ciclo = 0

death = 0
Sparo.X = 180

CreateBall 1, INT(RND * 320), 1, 1, 1

DQBsetBIOSfont
Man.X = 160
Man.Y = 180
Quante& = 0
IF Man.Vite < 0 THEN exited = -1: stopmidi: EXIT SUB
IntroLevel
TStart = TIMER
Tempo2& = TIMER
DO
IF BallRate% <= 3 THEN TheEnd: EXIT SUB


R& = TIMER
IF INT(R& - Tempo2&) >= BallRate% OR Numb = 1 THEN
CreatedBall% = CreatedBall% + 1
Tipo = INT(RND * 4)
IF Tipo = 0 THEN Tipo = 4
CreateBall Tipo, INT((RND * 300 + 10) + 5), 1, 1, 1
IF CreatedBall% = MaxCBall% THEN
CreatedBall% = 0
MaxCBall% = MaxCBall% + 2
BallRate% = BallRate% - 1
END IF
Tempo2& = TIMER
END IF

Ciclo = Ciclo + 1
IF Sparo.Count <> 0 THEN Sparo.Count = Sparo.Count + 1

IF Press = 1 THEN
Man.Ciclo = Man.Ciclo + 1
ELSE
Man.Frame = 4
Man.Ciclo = 1
END IF

IF Ciclo = 2 THEN


DQBclearLayer 1

MoveSparo
MoveBalls
CheckMan

IF death = 1 THEN EXIT DO

CheckSparo
DrawBall
DrawSparo
MoveMan
Ciclo = 0
END IF

IF DQBkey(KEYSPACE) THEN AttivaSparo: Man.Frame = 4: Man.Ciclo = 0

IF DQBkey(KEYRIGHT) AND Sparo.Count = 0 THEN
Man.X = Man.X + 1: Press = 1: Man.Direction = 0: IF Man.Frame = 4 OR Man.Direction = 1 THEN Man.Frame = 1: Man.Direction = 0: Man.Ciclo = 0
GOTO AfterKey2
ELSE
Press = 0
END IF

IF DQBkey(KEYLEFT) AND Sparo.Count = 0 THEN
Man.X = Man.X - 1: Press = 1: Man.Direction = 1: IF Man.Frame = 4 OR Man.Direction = 0 THEN Man.Frame = 1: Man.Direction = 1: Man.Ciclo = 0
GOTO AfterKey2:
ELSE
Press = 0
END IF
AfterKey2:
IF DQBkey(&H19) THEN Pause

ViewBar

DQBCopyLayer 1, VIDEO
IF Man.Delay <> 0 THEN
DQBWait Man.Delay

END IF

IF Numb = 0 THEN GOTO nrt2:

IF Sparo.Count >= 7 THEN Sparo.Count = 0

IF MusicDone% THEN

IF Music = 1 THEN
stopmidi
Unload
LoadMidi "midi\music02.mid"
PlayMidi
Music = 2
END IF
GOTO FineMusica:
IF Music = 2 THEN
stopmidi
Unload
LoadMidi "midi\music03.mid"
PlayMidi
Music = 3
END IF
GOTO FineMusica:
IF Music = 3 THEN
stopmidi
Unload
LoadMidi "midi\music04.mid"
PlayMidi
Music = 4
END IF
GOTO FineMusica:
IF Music = 4 THEN
stopmidi
Unload
LoadMidi "midi\music05.mid"
PlayMidi
Music = 5
END IF
GOTO FineMusica:
IF Music = 5 THEN
stopmidi
Unload
LoadMidi "midi\sample01.mid"
PlayMidi
Music = 6
END IF
GOTO FineMusica:
IF Music = 6 THEN
stopmidi
Unload
LoadMidi "midi\music01.mid"
PlayMidi
Music = 1
END IF
FineMusica:
END IF

IF Man.Vite < 0 THEN exited = -1: stopmidi: EXIT SUB

LOOP UNTIL DQBkey(KEYESC)
IF death = 1 THEN GOTO Inizia:
nrt2:
stopmidi
END SUB

SUB Pause
R& = TIMER
DO
LOOP UNTIL DQBkey(KEYENTER)
H& = TIMER
H& = INT(H& - R&)
TStart = TStart + H&
END SUB

SUB PlayLevel (num$)
OPEN num$ FOR INPUT AS #1
INPUT #1, lv
INPUT #1, rt
Numb = rt
FOR i = 1 TO rt
INPUT #1, Tipo
INPUT #1, X
INPUT #1, Y
INPUT #1, DIRECTIONX
INPUT #1, DIRECTIONY
INPUT #1, MaxX
INPUT #1, MaxY
INPUT #1, MinX
INPUT #1, MinY
INPUT #1, Mantieni
Ball(i).Tipo = Tipo
Ball(i).X = X
Ball(i).Y = Y
Ball(i).DIRECTIONX = DIRECTIONX
Ball(i).DIRECTIONY = DIRECTIONY
IF Ball(i).Tipo = 1 THEN Ball(i).DIMENSION = 20
IF Ball(i).Tipo = 2 THEN Ball(i).DIMENSION = 10
IF Ball(i).Tipo = 3 THEN Ball(i).DIMENSION = 5
IF Ball(i).Tipo = 4 THEN Ball(i).DIMENSION = 2
Ball(i).MaxX = MaxX
Ball(i).MaxY = MaxY
Ball(i).MinX = MinX
Ball(i).MinY = MinY
Ball(i).Mantieni = Mantieni
NEXT i
CLOSE #1
END SUB

REM $DYNAMIC
SUB SplitBall (Balla)

IF NOT Ball(Balla).Tipo = 0 AND NOT Ball(Balla).Tipo = 4 THEN

E = NumberOfFreeBall

Ball(E).Tipo = 1

T = NumberOfFreeBall

Ball(T).Tipo = 1
Ball(E).X = Ball(Balla).X
Ball(E).Y = Ball(Balla).Y
Ball(E).DIRECTIONX = 0
Ball(E).DIRECTIONY = 0

Ball(T).X = Ball(Balla).X
Ball(T).Y = Ball(Balla).Y
Ball(T).DIRECTIONX = 1
Ball(T).DIRECTIONY = 0

Numb = Numb + 2

SELECT CASE Ball(Balla).Tipo

CASE 1
Ball(T).Tipo = 2
Ball(E).Tipo = 2

CASE 2
Ball(T).Tipo = 3
Ball(E).Tipo = 3

CASE 3
Ball(T).Tipo = 4
Ball(E).Tipo = 4

END SELECT

IF Ball(Balla).Mantieni = True THEN
Ball(T).MaxX = Ball(Balla).MaxX
Ball(T).MaxY = Ball(Balla).MaxY
Ball(T).MinX = Ball(Balla).MinX
Ball(T).MinY = Ball(Balla).MinY
Ball(E).MaxX = Ball(Balla).MaxX
Ball(E).MaxY = Ball(Balla).MaxY
Ball(E).MinX = Ball(Balla).MinX
Ball(E).MinY = Ball(Balla).MinY
Ball(T).Mantieni = True
Ball(E).Mantieni = True
ELSE

SELECT CASE Ball(T).Tipo
CASE 1
Ball(T).MaxX = 300
Ball(T).MaxY = 180
Ball(T).MinX = 20
Ball(T).MinY = 40
Ball(E).MaxX = 300
Ball(E).MaxY = 180
Ball(E).MinX = 20
Ball(E).MinY = 40

CASE 2
Ball(T).MaxX = 300
Ball(T).MaxY = 180
Ball(T).MinX = 20
Ball(T).MinY = 60
Ball(E).MaxX = 300
Ball(E).MaxY = 180
Ball(E).MinX = 20
Ball(E).MinY = 60

CASE 3
Ball(T).MaxX = 300
Ball(T).MaxY = 180
Ball(T).MinX = 20
Ball(T).MinY = 90
Ball(E).MaxX = 300
Ball(E).MaxY = 180
Ball(E).MinX = 20
Ball(E).MinY = 90

CASE 4
Ball(T).MaxX = 300
Ball(T).MaxY = 180
Ball(T).MinX = 20
Ball(T).MinY = 100
Ball(E).MaxX = 300
Ball(E).MaxY = 180
Ball(E).MinX = 20
Ball(E).MinY = 100
END SELECT

END IF

IF Ball(E).Tipo = 1 THEN Ball(E).DIMENSION = 20
IF Ball(E).Tipo = 2 THEN Ball(E).DIMENSION = 10
IF Ball(E).Tipo = 3 THEN Ball(E).DIMENSION = 5
IF Ball(E).Tipo = 4 THEN Ball(E).DIMENSION = 2

IF Ball(T).Tipo = 1 THEN Ball(T).DIMENSION = 20
IF Ball(T).Tipo = 2 THEN Ball(T).DIMENSION = 10
IF Ball(T).Tipo = 3 THEN Ball(T).DIMENSION = 5
IF Ball(T).Tipo = 4 THEN Ball(T).DIMENSION = 2

END IF

EraseBall Balla
Numb = Numb - 1
END SUB

REM $STATIC
SUB Stopprogram
'showbmp "graph\end.bmh"
CLOSE
DQBRemoveKeyboard
'SLEEP
'Chiud
stopmidi
DQBclose
SCREEN 0, 0, 0: WIDTH 80
END
END SUB

SUB TESTFRAMES
'DQBput 0, 0, 0, VARSEG(ManBuff(0)), VARPTR(ManBuff(0))
'DQBput 0, 20, 0, VARSEG(ManBuff2(0)), VARPTR(ManBuff2(0))
'DQBput 0, 40, 0, VARSEG(ManBuff3(0)), VARPTR(ManBuff3(0))
'DQBput 0, 60, 0, VARSEG(ManBuff4(0)), VARPTR(ManBuff4(0))
'DQBput 0, 80, 0, VARSEG(ManBuff5(0)), VARPTR(ManBuff5(0))
'DQBput 0, 100, 0, VARSEG(ManBuff6(0)), VARPTR(ManBuff6(0))
'DQBput 0, 120, 0, VARSEG(ManBuff7(0)), VARPTR(ManBuff7(0))
'DQBput 0, 100, 40, VARSEG(Bar(0)), VARPTR(Bar(0))
'DQBclose
DQBclearLayer 1
DQBclearLayer 2
DQBclearLayer 0
CreateBall 4, 100, 100, 1, 1
CreateBall 4, 150, 100, 1, 1
CreateBall 4, 100, 140, 1, 1
CreateBall 4, 150, 140, 1, 1
CreateBall 1, 125, 120, 1, 1
CreateBall 2, 125, 120, 1, 1
CreateBall 3, 125, 120, 1, 1
CreateBall 4, 125, 120, 1, 1
DrawBall
DrawSparo
Man.Frame = 4
Man.X = 100
Man.Y = 180
CheckMan
MoveMan
ViewBar
'CheckPrintTempo
DQBCopyLayer 1, 0
SaveBMP "scr.bmp"
Pause
Stopprogram
END SUB

SUB TestLevel (Livello$)
SCREEN 13
DQBinstallKeyboard
DQBclearLayer 2
Levels.Time = 299

Level Livello$

IF exited = -1 THEN Stopprogram
END SUB

SUB TheEnd
Numb = 0
LoadMidi "midi\new05.mid": PlayMidi
CLS
DQBRemoveKeyboard
DQBclearLayer 0
DQBclearLayer 1
DQBclearLayer 2

DIM ManShoot(0 TO 451) AS INTEGER
DIM ManNormal(226)  AS INTEGER
DIM ManShoot2(0 TO 451) AS INTEGER
DIM ManNormal2(226)  AS INTEGER
DIM MegaBall(5547) AS INTEGER

'Big Ball
OPEN "graph\Bball.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 5547
GET #1, , MegaBall(i)
NEXT i
CLOSE #1
'Two Man
OPEN "graph\ManN.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManNormal(i)
NEXT i
CLOSE #1
OPEN "graph\ManN2.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 226
GET #1, , ManNormal2(i)
NEXT i
CLOSE #1
'Man at shoot
OPEN "graph\ManS.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 451
GET #1, , ManShoot(i)
NEXT i
CLOSE #1
OPEN "graph\ManS2.arr" FOR BINARY AS #1
GET #1, , dummy
FOR i = 0 TO 451
GET #1, , ManShoot2(i)
NEXT i
CLOSE #1
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
DQBput 0, 200, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))

stringa$ = "Your are at the end of your life!" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 20, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 21, 51, 15

Delay 3

DQBclearLayer 0
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
DQBput 0, 200, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))

stringa$ = "That's what you think!!!" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 101, 51, 15
Delay 3

DQBclearLayer 0
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
DQBput 0, 200, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))

stringa$ = "You can't escape now" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 30, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 30, 51, 15
Delay 3

FOR i = 200 TO 320
DQBput 1, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
DQBput 1, i, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))
DQBCopyLayer 1, 0
DQBclearLayer 1
DQBWait 1
NEXT i

DQBclearLayer 0
DQBput 0, 100, 100, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))

stringa$ = "DAMN" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 90, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 90, 51, 15
Delay 3

DQBclearLayer 0
DQBput 0, 200, 100, VARSEG(ManNormal(0)), VARPTR(ManNormal(0))
DQBput 0, 100, 100, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
Delay 1

DQBclearLayer 0
DQBput 0, 200, 100, VARSEG(ManNormal(0)), VARPTR(ManNormal(0))
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
stringa$ = "What?" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 90, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 90, 51, 15

Delay 3

DQBclearLayer 0
DQBput 0, 200, 100, VARSEG(ManShoot2(0)), VARPTR(ManShoot2(0))
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
stringa$ = "You can't kill yourself..." + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 101, 51, 15
Delay 3

DQBclearLayer 0
DQBput 0, 200, 100, VARSEG(ManShoot2(0)), VARPTR(ManShoot2(0))
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
stringa$ = "Let's see..." + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 40, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 41, 51, 15
Delay 3

FOR i = 110 TO 200

FOR Y = 0 TO 4
DQBpset 1, i + Y, 110, 1
DQBpset 1, i + Y, 109, 15
DQBpset 1, i + Y, 111, 15
NEXT Y
DQBput 1, 200, 100, VARSEG(ManShoot2(0)), VARPTR(ManShoot2(0))
DQBput 1, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
DQBCopyLayer 1, 0
DQBclearLayer 1
DQBWait 1
DQBclearLayer 2
DQBput 1, 200, 100, VARSEG(ManShoot2(0)), VARPTR(ManShoot2(0))
DQBput 1, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
NEXT i

Delay 2
DQBclearLayer 0
DQBput 0, 200, 100, VARSEG(ManShoot2(0)), VARPTR(ManShoot2(0))
DQBput 0, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))

SetupPal

Delay 3

PALETTE

DQBclearLayer 0

DQBput 0, 100, 100, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))

Delay 3

DQBclearLayer 1
FOR i = -100 TO 50
DQBput 1, 100, 100, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
DQBput 1, 200, i, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))
DQBCopyLayer 1, 0
DQBclearLayer 1
DQBWait 1
NEXT i

DQBclearLayer 1
DQBclearLayer 0

DQBput 0, 100, 100, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
DQBput 0, 200, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))
stringa$ = "It's the end for you!" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 100, 50, 1
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 101, 51, 15
Delay 3
DQBclearLayer 0
FOR i = 110 TO 250

FOR Y = 0 TO 4
DQBpset 1, i + Y, 110, 1
DQBpset 1, i + Y, 109, 15
DQBpset 1, i + Y, 111, 15
NEXT Y
DQBput 1, 100, 100, VARSEG(ManShoot(0)), VARPTR(ManShoot(0))
DQBput 1, 200, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))
DQBCopyLayer 1, 0
DQBclearLayer 1
DQBWait 1
NEXT i
DQBclearLayer 2
DQBput 2, 200, 50, VARSEG(MegaBall(0)), VARPTR(MegaBall(0))

FOR i = 100 TO -100 STEP -20

FOR a = i TO i - 6 STEP -1
DQBclearLayer 1
DQBCopyLayer 2, 1
DQBput 1, a, 90, VARSEG(ManBuff(0)), VARPTR(ManBuff(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT a

FOR a = i - 7 TO i - 13 STEP -1
DQBclearLayer 1
DQBCopyLayer 2, 1
DQBput 1, a, 90, VARSEG(ManBuff2(0)), VARPTR(ManBuff2(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT a

FOR a = i - 14 TO i - 20 STEP -1
DQBclearLayer 1
DQBCopyLayer 2, 1
DQBput 1, a, 90, VARSEG(ManBuff3(0)), VARPTR(ManBuff3(0))
DQBCopyLayer 1, 0
DQBWait 1
NEXT a
NEXT i
DQBCopyLayer 2, 0
SetupPal
Delay 2
CLS : PALETTE
DQBput 0, 190, 90, VARSEG(B1(0)), VARPTR(B1(0))
DQBput 0, 210, 90, VARSEG(B1(0)), VARPTR(B1(0))
DQBput 0, 190, 110, VARSEG(B1(0)), VARPTR(B1(0))
DQBput 0, 210, 110, VARSEG(B1(0)), VARPTR(B1(0))
Delay 1
SetupPal
Delay 1
CLS : PALETTE

DQBput 0, 190, 90, VARSEG(B2(0)), VARPTR(B2(0))
DQBput 0, 210, 90, VARSEG(B2(0)), VARPTR(B2(0))
DQBput 0, 190, 110, VARSEG(B2(0)), VARPTR(B2(0))
DQBput 0, 210, 110, VARSEG(B2(0)), VARPTR(B2(0))
Delay 1
SetupPal
Delay 1
CLS : PALETTE

DQBput 0, 190, 90, VARSEG(B3(0)), VARPTR(B3(0))
DQBput 0, 210, 90, VARSEG(B3(0)), VARPTR(B3(0))
DQBput 0, 190, 110, VARSEG(B3(0)), VARPTR(B3(0))
DQBput 0, 210, 110, VARSEG(B3(0)), VARPTR(B3(0))
Delay 1
SetupPal
Delay 1
CLS : PALETTE
DQBput 0, 190, 90, VARSEG(B4(0)), VARPTR(B4(0))
DQBput 0, 210, 90, VARSEG(B4(0)), VARPTR(B4(0))
DQBput 0, 190, 110, VARSEG(B4(0)), VARPTR(B4(0))
DQBput 0, 210, 110, VARSEG(B4(0)), VARPTR(B4(0))
Delay 1
SetupPal
Delay 1
debg:
CLS : PALETTE
ShowBMP "bmp\end.bmp"
DO: LOOP UNTIL MusicDone%: stopmidi: Unload
LoadMidi "midi\sample01.mid": PlayMidi
DQBclearLayer 1
DQBclearLayer 2
DQBCopyLayer 0, 2
Delay 3

FOR i = 0 TO 150 STEP 20

FOR a = i TO i + 6
DQBCopyLayer 2, 0
DQBput 0, a, 150, VARSEG(ManBuff5(0)), VARPTR(ManBuff5(0))
DQBWait 1
NEXT a

FOR a = i + 7 TO i + 13
DQBCopyLayer 2, 0
DQBput 0, a, 150, VARSEG(ManBuff6(0)), VARPTR(ManBuff6(0))
DQBWait 1
NEXT a

FOR a = i + 14 TO i + 20
DQBCopyLayer 2, 0
DQBput 0, a, 150, VARSEG(ManBuff7(0)), VARPTR(ManBuff7(0))
DQBWait 1
NEXT a
NEXT i

DQBCopyLayer 2, 0
DQBput 0, a, 150, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
Delay 3
CreateBall 4, 250, 50, 0, 1
DrawBall
DQBCopyLayer 1, 0
DQBput 0, a, 150, VARSEG(ManNormal2(0)), VARPTR(ManNormal2(0))
Delay 2
Testo$ = "?" + CHR$(0)
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), a, 140, 1
DQBPrint 0, VARSEG(Testo$), SADD(Testo$), a + 1, 141, 15
Delay 2
Man.Vite = 1: Man.X = a: Man.Y = 180
Sparo.Increment = 1
Man.Frame = 4
DO
IF Numb = 0 THEN EXIT DO
DrawBall
AttivaSparo
MoveBalls
MoveSparo
DrawSparo
MoveMan
CheckSparo
DQBCopyLayer 1, 0
DQBWait 1
IF Numb <= 0 THEN EXIT DO
LOOP
DQBclearLayer 0
Credit
END SUB

SUB TwoPlayer
DQBinstallKeyboard
ShowBMP "bmp\menu.bmp"
MouseShow
stringa$ = "Two players mode not avaiable now." + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 30, 50, 15
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 31, 51, 1

stringa$ = "Sorry for that. Please wait the second release." + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 0, 70, 15
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 1, 71, 1

stringa$ = "Look at http://tlp.virtualave.net" + CHR$(0)
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 30, 90, 15
DQBPrint 0, VARSEG(stringa$), SADD(stringa$), 31, 91, 1



Pause

END SUB

SUB ViewBar
DQBput 1, 0, 179, VARSEG(Bar(0)), VARPTR(Bar(0))
IF Man.Vite > 3 THEN
DQBput 1, 10, 185, VARSEG(Head(0)), VARPTR(Head(0))
DQBput 1, 25, 185, VARSEG(Head(0)), VARPTR(Head(0))
DQBput 1, 40, 185, VARSEG(Head(0)), VARPTR(Head(0))
stringa$ = STR$(Man.Vite) + CHR$(0)
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), 52, 188, 1
stringa$ = STR$(Man.Vite) + CHR$(0)
DQBPrint 1, VARSEG(stringa$), SADD(stringa$), 51, 187, 15
END IF
IF Man.Vite = 3 THEN
DQBput 1, 10, 185, VARSEG(Head(0)), VARPTR(Head(0))
DQBput 1, 25, 185, VARSEG(Head(0)), VARPTR(Head(0))
DQBput 1, 40, 185, VARSEG(Head(0)), VARPTR(Head(0))
END IF
IF Man.Vite = 2 THEN
DQBput 1, 10, 185, VARSEG(Head(0)), VARPTR(Head(0))
DQBput 1, 25, 185, VARSEG(Head(0)), VARPTR(Head(0))
END IF

IF Man.Vite = 1 THEN
DQBput 1, 10, 185, VARSEG(Head(0)), VARPTR(Head(0))
END IF

END SUB

