DEFINT A-Z
' $INCLUDE: 'bomb.bi'
'$DYNAMIC
DECLARE SUB game ()
DECLARE SUB finalstuff ()
DECLARE SUB stuff3 ()
DECLARE SUB stuff2 ()
DECLARE SUB stuff1 ()
DECLARE SUB endit ()
DECLARE SUB gravity ()
DECLARE SUB checkexplosions ()
DECLARE SUB putpieces ()
DECLARE SUB loadgfx ()
DECLARE SUB makelevels ()
DECLARE SUB putlevels ()
DECLARE SUB checkver (i%, n%, item%)
DECLARE SUB check (i%, n%, item%)
DECLARE FUNCTION int86qb$ (intnr%, flag%, ax%, bx%, CX%, dx%, di%, si%, bp%, ds%, es%)
DECLARE FUNCTION int2str$ (sword%)
DECLARE FUNCTION PlayMIDI% ()
DECLARE FUNCTION LoadAndPlayMIDI% (Filename$)
DECLARE SUB LoadMIDI (Filename$)
DECLARE SUB stopmidi ()
DECLARE SUB Pokestring (SEGJE%, OFFJE%, Main$)
DECLARE FUNCTION TimeMIDI! ()
DECLARE SUB del (dela%)
DECLARE SUB Pause (tdelay#)
DECLARE SUB fliplay (Filename$)
'COMMON SHARED win%
DIM SHARED MIDI.LOADED AS INTEGER
DIM SHARED MIDI.PLAYTIME AS SINGLE
DIM SHARED MIDI.INTERRUPT AS INTEGER
DIM SHARED row1(-15 TO 45)
DIM SHARED row2(-15 TO 45)
DIM SHARED row3(-15 TO 45)
DIM SHARED row4(-15 TO 45)
DIM SHARED row5(-15 TO 45)
DIM SHARED row6(-15 TO 45)
DIM SHARED row7(-15 TO 45)
MIDI.LOADED = 0
MIDI.PLAYTIME = 0
MIDI.INTERRUPT = &H81
CONST FALSE = 0
CONST TRUE = NOT FALSE
TYPE FLIheaderType
	Size AS LONG
	ID AS INTEGER
	Frames AS INTEGER
	XRes AS INTEGER
	YRes AS INTEGER
	ColorBits AS INTEGER
	Flags AS INTEGER
	Speed AS INTEGER
	Reserved AS STRING * 110
END TYPE
TYPE FLIframeChunkType
	Size AS LONG
	ID AS INTEGER
	Chunks AS INTEGER
	Reserved AS STRING * 8
END TYPE
TYPE FLIdataChunkType
	Size AS LONG
	ID AS INTEGER
END TYPE
DEFINT A-Z
100
SCREEN 13
stopmidi
fliplay "logo.fli"
IF LoadAndPlayMIDI%("bdtm_02.mid") = 0 THEN  ELSE
fliplay "open.flc"
SLEEP
set320x200 8
future.print 10, 120, "1.story", 15, 1
future.print 10, 140, "2.festival", 1, 15
future.print 10, 160, "3.exit", 15, 1
110
g$ = INKEY$
IF g$ = "1" OR g$ = "2" OR g$ = "3" THEN  ELSE GOTO 110
IF g$ = "1" THEN mode% = 1
IF g$ = "2" THEN mode% = 2
IF g$ = "3" THEN SYSTEM
CLS
stopmidi
set320x200 8
SetMaskColor 0
loadgfx
X% = 250
Y% = 0
level% = 0
																									IF mode% = 1 THEN continue% = 3 ELSE continue% =  _
2

game
IF level% < 10 THEN

viewpage 0
del 20000
setpage 0
future.cls 0: SCREEN 13
fliplay "gameover.flc"
SLEEP
END IF

GOTO 100

REM $STATIC
SUB check (i%, n%, item%)

IF i% = 1 THEN
IF row1(n% + 1) = item% THEN
row1(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row1(n% - 1) = item% THEN
row1(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF

IF i% = 2 THEN
IF row2(n% + 1) = item% THEN
row2(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row2(n% - 1) = item% THEN
row2(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF

IF i% = 3 THEN
IF row3(n% + 1) = item% THEN
row3(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row3(n% - 1) = item% THEN
row3(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF

IF i% = 4 THEN
IF row4(n% + 1) = item% THEN
row4(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row4(n% - 1) = item% THEN
row4(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF

IF i% = 5 THEN
IF row5(n% + 1) = item% THEN
row5(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row5(n% - 1) = item% THEN
row5(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF

IF i% = 6 THEN
IF row6(n% + 1) = item% THEN
row6(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row6(n% - 1) = item% THEN
row6(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF

IF i% = 7 THEN
IF row7(n% + 1) = item% THEN
row7(n% + 1) = 0
loadwav "explode.wav"
checkver i%, n% + 1, item%
check i%, n% + 1, item%
END IF
IF row7(n% - 1) = item% THEN
row7(n% - 1) = 0
loadwav "explode.wav"
checkver i%, n% - 1, item%
check i%, n% - 1, item%
END IF
END IF


END SUB

SUB checkexplosions

SHARED bomb%, item%, X%, Y%, drag%
SHARED toss%, blow%, win%, bomb1%
SHARED ch%, last%
SHARED time%, continue%

'check explosions!!!
FOR i% = 1 TO 7
IF bomb% = 0 AND item% = 5 THEN
IF ABS(X% - (205 - ABS(205 - drag%))) <= 25 AND ABS(Y% - 30) <= 25 AND drag% > 205 THEN
toss% = 99
bomb% = 1
blow% = 1
END IF

IF ABS(X% - drag%) <= 25 AND ABS(Y% - 30) <= 25 AND drag% < 205 THEN
toss% = 99
bomb% = 1
END IF
END IF
FOR n% = 1 TO 12
IF ABS(X% - (n% * 20)) <= 15 AND ABS(Y% - (63 + (i% * 17))) <= 12 THEN
blow% = 0
IF i% = 1 AND row1(n%) > 0 THEN blow% = 1
IF i% = 2 AND row2(n%) > 0 THEN blow% = 1
IF i% = 3 AND row3(n%) > 0 THEN blow% = 1
IF i% = 4 AND row4(n%) > 0 THEN blow% = 1
IF i% = 5 AND row5(n%) > 0 THEN blow% = 1
IF i% = 6 AND row6(n%) > 0 THEN blow% = 1
IF i% = 7 AND row7(n%) > 0 THEN blow% = 1

IF i% = 1 AND row1(n%) = 10 THEN win% = 1
IF i% = 2 AND row2(n%) = 10 THEN win% = 1
IF i% = 3 AND row3(n%) = 10 THEN win% = 1
IF i% = 4 AND row4(n%) = 10 THEN win% = 1
IF i% = 5 AND row5(n%) = 10 THEN win% = 1
IF i% = 6 AND row6(n%) = 10 THEN win% = 1
IF i% = 7 AND row7(n%) = 10 THEN win% = 1



IF blow% >= 1 THEN
IF X% < 31 THEN X% = 31
IF Y% > 140 THEN Y% = 130
'LOCATE 1, 1: PRINT x% - 30, y% - 8
Future.EMSPut X% - 30, Y% - 8, bomb1%
toss% = 99
IF i% = 1 AND row1(n%) = item% THEN
ch% = 1
row1(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF i% = 2 AND row2(n%) = item% THEN
ch% = 1
row2(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF i% = 3 AND row3(n%) = item% THEN
ch% = 1
row3(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF i% = 4 AND row4(n%) = item% THEN
ch% = 1
row4(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF i% = 5 AND row5(n%) = item% THEN
ch% = 1
row5(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF i% = 6 AND row6(n%) = item% THEN
ch% = 1
row6(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF i% = 7 AND row7(n%) = item% THEN
ch% = 1
row7(n%) = 0
checkver i% + 0, n% + 0, item% + 0
END IF
IF ch% = 1 THEN
check i%, n%, item%
END IF
END IF
END IF
NEXT n%
IF ch% = 0 AND i% = 7 AND toss% = 99 THEN
FOR t% = 1 TO 12
IF 205 - ABS(205 - drag%) > (20 * t%) AND 205 - ABS(205 - drag%) < (38 * t%) THEN IF row1(t%) = 0 THEN row1(t%) = last% ELSE IF row1(t% + 1) = 0 THEN row1(t% + 1) = last%
NEXT t%
IF item% < 5 THEN last% = item%
END IF
NEXT i%
ch% = 0
blow% = 0
IF bomb% > 0 THEN last% = 0



END SUB

SUB checkver (i%, n%, item%)

IF i% = 1 THEN
IF row2(n%) = item% THEN
row2(n%) = 0
loadwav "explode.wav"
check 2, n%, item%
checkver 2, n%, item%
END IF
END IF

IF i% = 2 THEN
IF row3(n%) = item% THEN
row3(n%) = 0
loadwav "explode.wav"
check 3, n%, item%
checkver 3, n%, item%
END IF
IF row1(n%) = item% THEN
row1(n%) = 0
loadwav "explode.wav"
check 1, n%, item%
checkver 1, n%, item%
END IF
END IF

IF i% = 3 THEN
IF row4(n%) = item% THEN
row4(n%) = 0
loadwav "explode.wav"
check 4, n%, item%
checkver 4, n%, item%
END IF
IF row2(n%) = item% THEN
row2(n%) = 0
loadwav "explode.wav"
check 2, n%, item%
checkver 2, n%, item%
END IF
END IF

IF i% = 4 THEN
IF row5(n%) = item% THEN
row5(n%) = 0
loadwav "explode.wav"
check 5, n%, item%
checkver 5, n%, item%
END IF
IF row3(n%) = item% THEN
row3(n%) = 0
loadwav "explode.wav"
check 3, n%, item%
checkver 3, n%, item%
END IF
END IF

IF i% = 5 THEN
IF row6(n%) = item% THEN
row6(n%) = 0
loadwav "explode.wav"
check 6, n%, item%
checkver 6, n%, item%
END IF
IF row4(n%) = item% THEN
row4(n%) = 0
loadwav "explode.wav"
check 4, n%, item%
checkver 4, n%, item%
END IF
END IF

IF i% = 6 THEN
IF row7(n%) = item% THEN
row7(n%) = 0
loadwav "explode.wav"
check 7, n%, item%
checkver 7, n%, item%
END IF
IF row5(n%) = item% THEN
row5(n%) = 0
loadwav "explode.wav"
check 5, n%, item%
checkver 5, n%, item%
END IF
END IF

IF i% = 7 THEN
IF row6(n%) = item% THEN
row6(n%) = 0
loadwav "explode.wav"
check 6, n%, item%
checkver 6, n%, item%
END IF
END IF




END SUB

DEFSNG A-Z
SUB del (dela%)
FOR i# = 1 TO dela%
NEXT i#
END SUB

DEFINT A-Z
SUB endit

SHARED cg%, bg%
SHARED pc1%, pc2%, pc3%, pc4%, pc5%, ball%
SHARED dino1%, dino2%, dino3%
SHARED bg1%, bg2%, bg3%, bg4%
SHARED bomb1%, bomb2%, attack%
SHARED time%, continue%

stopmidi
DeallExpMem bg%
DeallExpMem pc1%
DeallExpMem pc2%
DeallExpMem pc3%
DeallExpMem pc4%
DeallExpMem pc5%
DeallExpMem ball%
DeallExpMem dino1%
DeallExpMem dino2%
DeallExpMem dino3%
DeallExpMem bg1%
DeallExpMem bg2%
DeallExpMem bg3%
DeallExpMem bg4%
DeallExpMem bomb1%
DeallExpMem bomb2%
DeallExpMem attack%
DeallExpMem cg%
SYSTEM


END SUB

SUB finalstuff

SHARED time%, continue%
SHARED toss%, arc%, Y%, add%, X%, pow%, last%, item%
SHARED pc1%, pc2%, pc3%, pc4%, attack%, GK$, mode%
SHARED cg%, bg%
SHARED pc5%, ball%
SHARED dino1%, dino2%, dino3%
SHARED bg1%, bg2%, bg3%, bg4%
SHARED bomb1%, bomb2%


IF toss% >= 1 THEN toss% = toss% + 1

IF toss% = 0 THEN Future.EMSPut 250, 10, bg1%
'balls thrown!!!
IF toss% = 1 THEN Future.EMSPut 250, 10, bg2%
IF toss% = 2 THEN Future.EMSPut 250, 10, bg3%
IF toss% >= 3 THEN
Future.EMSPut 250, 10, bg4%
IF toss% < arc% / 2 THEN Y% = Y% - arc% / 4 + 1 ELSE Y% = Y% + arc% / 4 + 3
add% = arc% / 2.7
'FOR i% = 1 TO 36

X% = X% - (pow% / 2) + add%
IF X% > 240 THEN X% = 240
IF pow% = 0 THEN X% = 240
IF X% <= 1 OR Y% >= 180 OR X% >= 300 THEN
X% = 1
Y% = 180
last% = item%
toss% = 100
END IF
IF Y% < 1 THEN
ELSE
IF item% = 1 THEN Future.EMSPut X%, Y%, pc1%'
IF item% = 2 THEN Future.EMSPut X%, Y%, pc2%'
IF item% = 3 THEN Future.EMSPut X%, Y%, pc3%'
IF item% = 4 THEN Future.EMSPut X%, Y%, pc4%'
IF item% = 5 THEN Future.EMSPut X%, Y%, attack%
END IF
END IF
'end balls thrown!!!
IF toss% = 100 THEN
IF mode% = 2 THEN time% = time% - 1
toss% = 0
IF mode% = 1 THEN item% = INT(RND * 5) + 1
END IF
IF toss% = 0 THEN
X% = 240
Y% = 40
END IF



IF pow% < 0 THEN pow% = 0
IF pow% > 60 THEN pow% = 60
IF arc% < 0 THEN arc% = 0
IF arc% > 36 THEN arc% = 36


LINE (236, 38 - arc%)-(248, 38), 12, BF
LINE (236, 1)-(248, 38), 16, B

LINE (310 - pow%, 3)-(310, 15), 12, BF
LINE (250, 3)-(310, 15), 16, B


IF item% < 1 THEN item% = 1
Future.LINE 250, 16, 270, 38, 16, BF
IF item% = 1 THEN Future.EMSPut 250, 17, pc1%
IF item% = 2 THEN Future.EMSPut 250, 17, pc2%
IF item% = 3 THEN Future.EMSPut 250, 17, pc3%
IF item% = 4 THEN Future.EMSPut 250, 17, pc4%
IF item% = 5 THEN Future.EMSPut 250, 17, attack%

IF toss% = 0 THEN
IF GK$ = CHR$(0) + "H" THEN arc% = arc% + 1
IF GK$ = CHR$(0) + "P" THEN arc% = arc% - 1
IF GK$ = CHR$(0) + "K" THEN pow% = pow% + 1
IF GK$ = CHR$(0) + "M" THEN pow% = pow% - 1
IF mode% = 2 THEN
IF GK$ = CHR$(32) THEN
item% = item% + 1
IF item% = 6 THEN item% = 1
END IF
END IF
IF GK$ = CHR$(13) THEN
toss% = 1
END IF
IF GK$ = CHR$(27) THEN endit

END IF
'future.PRINT 1, 1, win%, 1, 15
del 1500


END SUB

SUB game


SHARED cg%, bg%, continue%
SHARED pc1%, pc2%, pc3%, pc4%, pc5%, ball%
SHARED dino1%, dino2%, dino3%
SHARED bg1%, bg2%, bg3%, bg4%
SHARED bomb1%, bomb2%, attack%

SHARED GK$, drag%, bomb%, zz%, last%, time%
SHARED toss%, arc%, Y%, add%, X%, pow%, item%
SHARED win%, mode%, level%

0
stuff2
1
stuff3
stuff1
IF level% = 10 THEN EXIT SUB
IF time% = 0 THEN
LOCATE 15, 15: future.print 160, 100, "TIME OVER!!!", 1, 15
SLEEP
continue% = continue% - 1
setpage 4
viewpage 4
future.cls 0
future.print 120, 90, "you have lost", 1, 0
SLEEP
IF continue% > 0 THEN GOTO 0 ELSE EXIT SUB
END IF
putpieces
IF last% > 4 THEN last% = 4
checkexplosions
gravity
finalstuff
IF win% = 1 THEN
COLOR 176
'LINE (0, 50)-(250, 200), 0, BF
viewpage 1
FOR i% = 0 TO 8
del 1500
Future.EMSPut i% * 20 + 1, 50, bomb2%
Future.EMSPut i% * 20 + 1, 110, bomb2%
NEXT i%
viewpage 0
del 20000
setpage 0
future.cls 0: SCREEN 13
fliplay "suzie3.flc"
del 20000
SLEEP 1
stopmidi
level% = level% + 1
GOTO 0
END IF
SetMaskColor -1
Future.EMSGet 1, 1, 320, 200, cg%
	viewpage 1
	setpage 0
	Future.EMSPut 1, 1, cg%
	viewpage 0
GOTO 1


END SUB

SUB gravity

FOR n% = 2 TO 7
FOR i% = 1 TO 20
IF n% = 2 THEN
IF row2(i%) = 0 THEN
row2(i%) = row1(i%)
row1(i%) = 0
END IF
END IF
IF n% = 3 THEN
IF row3(i%) = 0 THEN
row3(i%) = row2(i%)
row2(i%) = 0
END IF
END IF
IF n% = 4 THEN
IF row4(i%) = 0 THEN
row4(i%) = row3(i%)
row3(i%) = 0
END IF
END IF
IF n% = 5 THEN
IF row5(i%) = 0 THEN
row5(i%) = row4(i%)
row4(i%) = 0
END IF
END IF
IF n% = 6 THEN
IF row6(i%) = 0 THEN
row6(i%) = row5(i%)
row5(i%) = 0
END IF
END IF
IF n% = 7 THEN
IF row7(i%) = 0 THEN
row7(i%) = row6(i%)
row6(i%) = 0
END IF
END IF
NEXT i%
NEXT n%


END SUB

DEFSNG A-Z
FUNCTION int86qb$ (intnr%, flag%, ax%, bx%, CX%, dx%, di%, si%, bp%, ds%, es%)
'------------------------------------------------------------------------
'Conversion of all integers in strings
flag$ = LEFT$(int2str$(flag%), 1): ax$ = int2str$(ax%):
bx$ = int2str$(bx%): CX$ = int2str$(CX%): dx$ = int2str$(dx%):
di$ = int2str$(di%): si$ = int2str$(si%): bp$ = int2str$(bp%):
ds$ = int2str$(ds%): es$ = int2str$(es%):
'Now all integersvalues are direct usable in asm$
'------------------------------------------------------------------------
DIM datas%(11)    'that is all we need
dataseg% = VARSEG(datas%(0)): flagoff% = VARPTR(datas%(0))
dataseg$ = int2str$(dataseg%): flagoff$ = int2str$(flagoff%)
axoff$ = int2str$(flagoff% + 2): bxoff$ = int2str$(flagoff% + 4)
cxoff$ = int2str$(flagoff% + 6): dxoff$ = int2str$(flagoff% + 8)
dioff$ = int2str$(flagoff% + 10): sioff$ = int2str$(flagoff% + 12)
bpoff$ = int2str$(flagoff% + 14): dsoff$ = int2str$(flagoff% + 16)
esoff$ = int2str$(flagoff% + 18): intnroff$ = int2str$(flagoff% + 20)
'Now all integers are directly adressable in memory through asm$
'We could have used only this as pointers and leave the immediate values
'but....we don't.
'------------------------------------------------------------------------
asm$ = ""
asm$ = asm$ + CHR$(&H9C)                       'pushf
asm$ = asm$ + CHR$(&H50)                       'push ax
asm$ = asm$ + CHR$(&H53)                       'push bx
asm$ = asm$ + CHR$(&H51)                       'push cx
asm$ = asm$ + CHR$(&H52)                       'push dx
asm$ = asm$ + CHR$(&H57)                       'push di
asm$ = asm$ + CHR$(&H56)                       'push si
asm$ = asm$ + CHR$(&H55)                       'push bp
asm$ = asm$ + CHR$(&H1E)                       'push ds
asm$ = asm$ + CHR$(&H6)                        'push es

'2)LOAD REGISTERS
'First the flags( questionable if this ever happens):
asm$ = asm$ + CHR$(&HB4) + flag$              'mov ax,flag$
asm$ = asm$ + CHR$(&H9E)                      'sahf stores ah into flags

'Segment registers mbv ax :  only when not (accidentally) 0
IF ds% <> 0 THEN                              'safety
  asm$ = asm$ + CHR$(&HB8) + ds$              'mov ax,ds$
  asm$ = asm$ + CHR$(&H8E) + CHR$(&HD8)       'mov ds,ax
END IF
IF es% <> 0 THEN                              'safety
  asm$ = asm$ + CHR$(&HB8) + es$              'mov ax,es$
  asm$ = asm$ + CHR$(&H8E) + CHR$(&HC0)       'mov es,ax
END IF
'the rest of registers :
asm$ = asm$ + CHR$(&HB8) + ax$                'mov ax,ax$
asm$ = asm$ + CHR$(&HBB) + bx$                'mov bx,bx$
asm$ = asm$ + CHR$(&HB9) + CX$                'mov cx,cx$
asm$ = asm$ + CHR$(&HBA) + dx$                'mov dx,dx$
asm$ = asm$ + CHR$(&HBF) + di$                'mov di,di$
asm$ = asm$ + CHR$(&HBE) + si$                'mov si,si$
asm$ = asm$ + CHR$(&HBD) + bp$                'mov bp,bp$
'oke now the interrupt himself
asm$ = asm$ + CHR$(&HCD) + CHR$(intnr%)       'interrupt nr

'First make our DATAS% adressable:
asm$ = asm$ + CHR$(&H1E)                         'push ds
asm$ = asm$ + CHR$(&HB8) + dataseg$              'mov ax,DATASseg$
asm$ = asm$ + CHR$(&H8E) + CHR$(&HD8)            'mov ds,ax
					  
'We first pushed DS segment register since we want to adress our DATA_segment
asm$ = asm$ + CHR$(&H8F) + CHR$(&H6) + dsoff$    'pop dsoff$
asm$ = asm$ + CHR$(&H8C) + CHR$(&H6) + esoff$    'mov esoff$,ES

asm$ = asm$ + CHR$(&H9F)                         'lahf
asm$ = asm$ + CHR$(&H88) + CHR$(&H26) + flagoff$ 'mov flagoff$,ah
		    
'The rest is more simple i think:
asm$ = asm$ + CHR$(&H89) + CHR$(&H2E) + bpoff$   'mov bpoff$,bp
asm$ = asm$ + CHR$(&H89) + CHR$(&H36) + sioff$   'mov sioff$,si
asm$ = asm$ + CHR$(&H89) + CHR$(&H3E) + dioff$   'mov dioff$,di
asm$ = asm$ + CHR$(&H89) + CHR$(&H16) + dxoff$   'mov dxoff$,dx
asm$ = asm$ + CHR$(&H89) + CHR$(&HE) + cxoff$    'mov cxoff$,cx
asm$ = asm$ + CHR$(&H89) + CHR$(&H1E) + bxoff$   'mov bxoff$,bx
asm$ = asm$ + CHR$(&HA3) + axoff$                'mov axoff$,ax
			       
'Now let us neatly finish by just popping everything back in order
asm$ = asm$ + CHR$(&H7)                          'pop es
asm$ = asm$ + CHR$(&H1F)                         'pop ds
asm$ = asm$ + CHR$(&H5D)                         'pop bp
asm$ = asm$ + CHR$(&H5E)                         'pop si
asm$ = asm$ + CHR$(&H5F)                         'pop di
asm$ = asm$ + CHR$(&H5A)                         'pop dx
asm$ = asm$ + CHR$(&H59)                         'pop cx
asm$ = asm$ + CHR$(&H5B)                         'pop bx
asm$ = asm$ + CHR$(&H58)                         'pop ax
asm$ = asm$ + CHR$(&H9D)                         'popf
'We are done?
asm$ = asm$ + CHR$(&HCB)                         'retf

DEF SEG = VARSEG(asm$)
offcode% = SADD(asm$): CALL absolute(offcode%): DEF SEG

ui$ = HEX$(intnr%)
FOR i% = 0 TO 9
  hx$ = HEX$(datas%(i%))
  hx$ = STRING$(4 - LEN(hx$), "0") + hx$
  ui$ = ui$ + "," + hx$
NEXT

int86qb$ = ui$

END FUNCTION

DEFINT A-Z
SUB loadgfx


SHARED time%, continue%
SHARED cg%, bg%
SHARED pc1%, pc2%, pc3%, pc4%, pc5%, ball%
SHARED dino1%, dino2%, dino3%
SHARED bg1%, bg2%, bg3%, bg4%
SHARED bomb1%, bomb2%, attack%

viewpage 3


cg% = AllExpMem(64000)
bg% = AllExpMem(64000)
pc1% = AllExpMem(8 * 60)
pc2% = AllExpMem(8 * 60)
pc3% = AllExpMem(8 * 75)
pc4% = AllExpMem(8 * 75)
pc5% = AllExpMem(8 * 75)
ball% = AllExpMem(8 * 65)
dino1% = AllExpMem(8 * 300)
dino2% = AllExpMem(8 * 300)
dino3% = AllExpMem(8 * 300)
bg1% = AllExpMem(8 * 530)
bg2% = AllExpMem(8 * 530)
bg3% = AllExpMem(8 * 530)
bg4% = AllExpMem(8 * 530)
bomb1% = AllExpMem(8 * 630)
bomb2% = AllExpMem(8 * 1430)
attack% = AllExpMem(8 * 75)
LoadGIF "bg1.gif"
Future.EMSGet 1, 1, 320, 199, bg%
LoadGIF "pieces.gif"
Future.EMSGet 1, 73, 19, 90, pc1%
Future.EMSGet 21, 73, 39, 90, pc2%
Future.EMSGet 41, 73, 59, 90, pc3%
Future.EMSGet 61, 73, 79, 90, pc4%
Future.EMSGet 81, 73, 99, 90, pc5%
Future.EMSGet 161, 73, 179, 90, ball%
Future.EMSGet 5, 38, 49, 69, dino1%
Future.EMSGet 53, 38, 97, 69, dino2%
Future.EMSGet 101, 38, 145, 69, dino3%
LoadGIF "suzie.gif"
Future.EMSGet 1, 1, 69, 61, bg1%
Future.EMSGet 71, 1, 139, 61, bg2%
Future.EMSGet 141, 1, 209, 61, bg3%
Future.EMSGet 211, 1, 279, 61, bg4%
Future.EMSGet 1, 64, 69, 124, bomb1%
Future.EMSGet 72, 64, 184, 152, bomb2%
Future.EMSGet 186, 64, 204, 81, attack%
Future.LINE 0, 0, 320, 200, 0, BF



END SUB

SUB makelevels

SHARED level%
SHARED time%, continue%

FOR i% = 1 TO 12
row1(i%) = 0
row2(i%) = 0
row3(i%) = 0
row4(i%) = 0
row5(i%) = 0
row6(i%) = 0
row7(i%) = 0
NEXT i%


IF level% = 0 THEN
FOR i% = 1 TO 12
row1(i%) = 1
row2(i%) = 2
row3(i%) = 3
row4(i%) = 4
row5(i%) = 1
row6(i%) = 2
row7(i%) = 3
NEXT i%
row1(5) = 10
END IF

IF level% = 1 THEN
row1(6) = 1
row2(6) = 1
row3(6) = 1
row4(6) = 1
row5(6) = 1
row6(6) = 1
row7(6) = 1
row2(5) = 2
row3(5) = 2
row4(5) = 2
row5(5) = 2
row6(5) = 2
row7(5) = 2
FOR i% = 1 TO 4
row5(i%) = 3
row6(i%) = 3
row7(i%) = 3
NEXT i%
row4(4) = 10
END IF

IF level% = 2 THEN
FOR i% = 1 TO 12
row3(i%) = 1
row4(i%) = 1
row5(i%) = 1
row6(i%) = 1
row7(i%) = 1
NEXT i%
row3(5) = 4
row3(3) = 4
row3(4) = 4
row4(4) = 4
row5(4) = 1
row6(4) = 4
row7(4) = 4
row7(3) = 4
row7(5) = 4
row7(4) = 10
END IF

IF level% = 3 THEN
FOR i% = 1 TO 12
row1(i%) = 1
row2(i%) = 2
row3(i%) = 1
row4(i%) = 1
row5(i%) = 1
row6(i%) = 1
row7(i%) = 1
NEXT i%
row1(6) = 2
row3(4) = 10
END IF

IF level% = 4 THEN
FOR i% = 1 TO 12
row1(i%) = 3
row2(i%) = 4
row3(i%) = 3
row4(i%) = 4
row5(i%) = 3
row6(i%) = 4
row7(i%) = 3
NEXT i%
row1(8) = 2
row2(8) = 2
row3(8) = 2
row4(8) = 2
row5(8) = 2
row6(8) = 2
row7(8) = 2
row1(4) = 2
row2(4) = 2
row3(4) = 2
row4(4) = 2
row5(4) = 2
row6(4) = 2
row7(4) = 2
FOR i% = 1 TO 12
row5(i%) = 2
NEXT i%
row2(4) = 10
END IF

IF level% = 5 THEN
FOR i% = 1 TO 12
row1(i%) = 1
row2(i%) = 1
row3(i%) = 1
row4(i%) = 1
row5(i%) = 1
row6(i%) = 1
row7(i%) = 1
NEXT i%
row1(4) = 3
FOR i% = 1 TO 6
row2(i%) = 3
NEXT i%
row3(7) = 1
row4(7) = 4
row5(7) = 2
row6(7) = 4
row7(7) = 2
row3(6) = 1
row4(6) = 4
row5(6) = 2
row6(6) = 4
row7(6) = 2
row3(5) = 1
row4(5) = 4
row5(5) = 2
row6(5) = 4
row7(5) = 2

row2(3) = 10
END IF

IF level% = 6 THEN
FOR i% = 1 TO 12
row1(i%) = 1
row2(i%) = 1
row3(i%) = 1
row4(i%) = 1
row5(i%) = 1
row6(i%) = 1
row7(i%) = 1
NEXT i%
row1(2) = 2
row1(3) = 2
row1(4) = 2
row1(6) = 3
row1(7) = 3
row1(8) = 3
FOR i% = 1 TO 12
row2(i%) = 2
NEXT i%
row3(3) = 10
END IF

IF level% = 7 THEN
row4(6) = 6
row5(6) = 6
row6(6) = 6
row5(5) = 10
FOR i% = 1 TO 6
row6(i%) = 6
row7(i%) = 6
NEXT i%
row4(6) = 1
END IF

IF level% = 8 THEN
FOR i% = 1 TO 9
row3(i%) = 6
row4(i%) = 6
row5(i%) = 6
row6(i%) = 6
row7(i%) = 1
NEXT i%
row3(8) = 0
row3(9) = 0
row4(8) = 0
row4(9) = 0
row4(7) = 1
row5(8) = 1
row4(6) = 1
row4(5) = 1
row5(5) = 1
row5(6) = 1
row6(8) = 1
row7(8) = 1
row7(9) = 6
row4(4) = 10
row6(4) = 1
row7(4) = 1
END IF

IF level% = 9 THEN
FOR i% = 1 TO 4
row2(i%) = 6
row3(i%) = 6
row4(i%) = 6
NEXT i%
FOR i% = 1 TO 5
row5(i%) = 6
row6(i%) = 6
row7(i%) = 6
NEXT i%
row5(4) = 10
END IF
END SUB

SUB Pause (tdelay#)
'----------------------------------------------------------------------------
time1# = TIMER
DO
LOOP WHILE (TIMER - time1# < tdelay#) OR (time1# > TIMER)
END SUB

DEFSNG A-Z
SUB Pokestring (SEGJE%, OFFJE%, Main$)
'------------------------------------------------------
'This function pokes a string (might be ASCIIZ)into
'memory at a given location, making it possible to
'access strings in byte form
'------------------------------------------------------

DEF SEG = SEGJE%
FOR i% = 0 TO LEN(Main$) - 1
  POKE OFFJE% + i%, ASC(MID$(Main$, i% + 1, 1))
NEXT
DEF SEG

END SUB

DEFINT A-Z
SUB putlevels
SHARED level%
SHARED time%, continue%
RANDOMIZE TIMER

STATIC cinematic%

IF cinematic% = 0 THEN

IF level% = 0 THEN
IF LoadAndPlayMIDI%("l-gaim.mid") = 0 THEN  ELSE
cinematic% = 1
viewpage 0
del 20000
setpage 0
future.cls 0: SCREEN 13
fliplay "story1.fli"
del 20000
SLEEP
END IF

IF level% = 3 THEN
IF LoadAndPlayMIDI%("l-gaim.mid") = 0 THEN  ELSE
cinematic% = 1
viewpage 0
del 20000
setpage 0
future.cls 0: SCREEN 13
fliplay "story2.fli"
del 20000
SLEEP
END IF

IF level% = 7 THEN
IF LoadAndPlayMIDI%("l-gaim.mid") = 0 THEN  ELSE
cinematic% = 1
viewpage 0
del 20000
setpage 0
future.cls 0: SCREEN 13
fliplay "story3.fli"
del 20000
SLEEP
END IF

IF level% = 10 THEN
IF LoadAndPlayMIDI%("beauti~1.mid") = 0 THEN  ELSE
cinematic% = 1
viewpage 0
del 20000
setpage 0
future.cls 0: SCREEN 13
fliplay "end.fli"
del 20000
SLEEP
END IF


END IF

IF level% = 2 THEN cinematic% = 0

IF level% = 6 THEN cinematic% = 0

IF level% = 8 THEN cinematic% = 0

IF level% = 0 THEN row1(6) = 10

IF level% = 1 THEN row3(7) = 10
		     
IF level% = 2 THEN row2(3) = 10

IF level% = 3 THEN row3(4) = 10

IF level% = 4 THEN
row4(3) = 10
row1(1) = 6
row1(6) = 6
row3(6) = 6
END IF

IF level% = 5 THEN
row5(6) = 10
row2(9) = 6
row2(10) = 6
END IF

IF level% = 6 THEN
row1(5) = 6
row1(6) = 6
row1(7) = 6
row1(11) = 6
row5(9) = 10
END IF

IF level% = 7 THEN
row6(3) = 10
row1(1) = 6
row1(2) = 6
row1(6) = 6
row1(7) = 6
row1(8) = 6
END IF

IF level% = 8 THEN
row5(4) = 10
row1(7) = 6
row2(8) = 6
row3(9) = 6
row4(10) = 6
row1(3) = 6
row2(4) = 6
END IF
IF level% = 9 THEN
row5(2) = 10
row1(5) = 6
row2(5) = 6
row3(5) = 6
row4(7) = 6
row5(7) = 6
row6(7) = 6
END IF


END SUB

SUB putpieces

SHARED pc1%, pc2%, pc3%, pc4%, pc5%, ball%, last%
SHARED time%, continue%

'piece placement start
FOR i% = 1 TO 12
IF row1(i%) = 1 THEN Future.EMSPut (i% * 20), 80, pc1%
IF row1(i%) = 2 THEN Future.EMSPut (i% * 20), 80, pc2%
IF row1(i%) = 3 THEN Future.EMSPut (i% * 20), 80, pc3%
IF row1(i%) = 4 THEN Future.EMSPut (i% * 20), 80, pc4%
IF row1(i%) = 6 THEN Future.EMSPut (i% * 20), 80, pc5%
IF row1(i%) = 10 THEN Future.EMSPut (i% * 20), 80, ball%

IF row2(i%) = 1 THEN Future.EMSPut (i% * 20), 97, pc1%
IF row2(i%) = 2 THEN Future.EMSPut (i% * 20), 97, pc2%
IF row2(i%) = 3 THEN Future.EMSPut (i% * 20), 97, pc3%
IF row2(i%) = 4 THEN Future.EMSPut (i% * 20), 97, pc4%
IF row2(i%) = 6 THEN Future.EMSPut (i% * 20), 97, pc5%
IF row2(i%) = 10 THEN Future.EMSPut (i% * 20), 97, ball%

IF row3(i%) = 1 THEN Future.EMSPut (i% * 20), 114, pc1%
IF row3(i%) = 2 THEN Future.EMSPut (i% * 20), 114, pc2%
IF row3(i%) = 3 THEN Future.EMSPut (i% * 20), 114, pc3%
IF row3(i%) = 4 THEN Future.EMSPut (i% * 20), 114, pc4%
IF row3(i%) = 6 THEN Future.EMSPut (i% * 20), 114, pc5%
IF row3(i%) = 10 THEN Future.EMSPut (i% * 20), 114, ball%

IF row4(i%) = 1 THEN Future.EMSPut (i% * 20), 131, pc1%
IF row4(i%) = 2 THEN Future.EMSPut (i% * 20), 131, pc2%
IF row4(i%) = 3 THEN Future.EMSPut (i% * 20), 131, pc3%
IF row4(i%) = 4 THEN Future.EMSPut (i% * 20), 131, pc4%
IF row4(i%) = 6 THEN Future.EMSPut (i% * 20), 131, pc5%
IF row4(i%) = 10 THEN Future.EMSPut (i% * 20), 131, ball%

IF row5(i%) = 1 THEN Future.EMSPut (i% * 20), 148, pc1%
IF row5(i%) = 2 THEN Future.EMSPut (i% * 20), 148, pc2%
IF row5(i%) = 3 THEN Future.EMSPut (i% * 20), 148, pc3%
IF row5(i%) = 4 THEN Future.EMSPut (i% * 20), 148, pc4%
IF row5(i%) = 6 THEN Future.EMSPut (i% * 20), 148, pc5%
IF row5(i%) = 10 THEN Future.EMSPut (i% * 20), 148, ball%

IF row6(i%) = 1 THEN Future.EMSPut (i% * 20), 165, pc1%
IF row6(i%) = 2 THEN Future.EMSPut (i% * 20), 165, pc2%
IF row6(i%) = 3 THEN Future.EMSPut (i% * 20), 165, pc3%
IF row6(i%) = 4 THEN Future.EMSPut (i% * 20), 165, pc4%
IF row6(i%) = 6 THEN Future.EMSPut (i% * 20), 165, pc5%
IF row6(i%) = 10 THEN Future.EMSPut (i% * 20), 165, ball%

IF row7(i%) = 1 THEN Future.EMSPut (i% * 20), 182, pc1%
IF row7(i%) = 2 THEN Future.EMSPut (i% * 20), 182, pc2%
IF row7(i%) = 3 THEN Future.EMSPut (i% * 20), 182, pc3%
IF row7(i%) = 4 THEN Future.EMSPut (i% * 20), 182, pc4%
IF row7(i%) = 6 THEN Future.EMSPut (i% * 20), 182, pc5%
IF row7(i%) = 10 THEN Future.EMSPut (i% * 20), 182, ball%

NEXT i%


END SUB

SUB stuff1

SHARED continue%
SHARED cg%, bg%
SHARED pc1%, pc2%, pc3%, pc4%, pc5%, ball%
SHARED dino1%, dino2%, dino3%
SHARED bg1%, bg2%, bg3%, bg4%
SHARED bomb1%, bomb2%, attack%

SHARED GK$, drag%, bomb%, zz%, last%, time%



GK$ = INKEY$
WHILE INKEY$ <> "": WEND
Future.LINE 1, 0, 320, 70, 0, BF
Future.EMSPut 1, 0, bg%'
IF bomb% >= 1 THEN
Future.EMSPut 205 - ABS(205 - drag%), 30, dino3%
bomb% = bomb% + 1
IF bomb% = 100 THEN bomb% = 0
ELSE
drag% = drag% + 5
IF drag% <= 205 THEN Future.EMSPut drag%, 30, dino1%
IF drag% > 205 THEN Future.EMSPut 205 - ABS(205 - drag%), 30, dino2%
IF drag% = 410 THEN drag% = 5
IF drag% > 205 THEN zz% = 205 - ABS(205 - drag%) ELSE zz% = drag%
IF last% = 1 THEN Future.EMSPut zz% + 5, 55, pc1%
IF last% = 2 THEN Future.EMSPut zz% + 5, 55, pc2%
IF last% = 3 THEN Future.EMSPut zz% + 5, 55, pc3%
IF last% = 4 THEN Future.EMSPut zz% + 5, 55, pc4%

END IF
FOR i% = 1 TO time%
Future.EMSPut 1 + (i% * 18), 1, ball%
NEXT i%




END SUB

SUB stuff2

SHARED win%, mode%, last%, time%, X%
SHARED continue%

FOR i% = 1 TO 12
row1(i%) = 0
row2(i%) = 0
row3(i%) = 0
row4(i%) = 0
row5(i%) = 0
row6(i%) = 0
row7(i%) = 0
NEXT i%


win% = 0

IF mode% = 1 THEN
FOR i% = 1 TO 20
FOR ii% = 1 TO 7
RANDOMIZE TIMER
X% = INT(RND * 5)
IF ii% = 1 THEN row1(i%) = X%
IF ii% = 2 THEN row2(i%) = X%
IF ii% = 3 THEN row3(i%) = X%
IF ii% = 4 THEN row4(i%) = X%
IF ii% = 5 THEN row5(i%) = X%
IF ii% = 6 THEN row6(i%) = X%
IF ii% = 7 THEN row7(i%) = X%
NEXT ii%
NEXT i%
putlevels
END IF



IF mode% = 2 THEN makelevels

last% = 0
IF mode% = 1 THEN time% = 2 ELSE time% = 3
WHILE INKEY$ <> "": WEND
IF LoadAndPlayMIDI%("ctend.mid") = 0 THEN  ELSE


END SUB

SUB stuff3

SHARED bg%, time%
SHARED continue%

setpage 1
viewpage 0

	SetMaskColor 0
Future.LINE 0, 0, 320, 200, 0, BF
Future.EMSPut 0, 0, bg%

IF TimeMIDI > 250 THEN
IF LoadAndPlayMIDI%("ctend.mid") = 0 THEN  ELSE
time% = time% - 1
END IF


END SUB

DEFSNG A-Z
SUB trash


END SUB

