REM Unnamed Shooter, the project formerly known as "Blast 1½".
     REM Created June/July 2009 by Simon Mathiassen
     REM Portions of code courtesy David Williams
     REM Thanks to Jon Ripley for the FMOD code.

     
SYS "GetWindowLong", @hwnd%, -16 TO S%
     SYS "SetWindowLong", @hwnd%, -16, S% AND NOT &50000
     SYS "SetWindowPos", @hwnd%, 0, 0, 0, 0, 0, 32+7

     MODE 18
     CLS
     OFF

     ON ERROR PROC
error

     SYS "timeBeginPeriod", 1
     SYS "GetSystemMetrics", 0 TO xscreen%
     SYS "GetSystemMetrics", 1 TO yscreen%
     SYS "SetWindowPos", @hwnd%, 0, (xscreen%-640)/2, (yscreen%-480)/2, 0, 0, 5  REM Center the display window

     
SYS "ShowWindow", @hwnd%, 9

     REM Test for user stupidity
     
X=OPENIN (@dir$+"data\alien100.bmp")
     IF X=0 PROCIdiot
     CLOSE #X

     Autospeed%=0
     Autospeedselected%=0
     sound%=1

     blastscore$ = @dir$+"ushoot.dat"
     highscorefile=OPENIN blastscore$
     IF highscorefile=0 PROCCreatehighscore : highscorefile=OPENIN blastscore$
     INPUT#highscorefile,name1$,score1,name2$,score2,name3$,score3,wait%,starfield%,shadow%,accept%
     CLOSE#highscorefile

     M% = 30
     HIMEM = LOMEM + M%*&FA000
     *ESC OFF
     REM CALL @dir$+"data\fmod"

     
SYS "AddFontResource", @dir$+"data\BLADR.TTF"
     *FONT Arial,20

     PROCfmod

     INSTALL @lib$+"GFXLIB"
     INSTALL @lib$+"SOCKLIB"

     I% = FNSYS_NameToAddress( "InvalidateRect" )
     W% = FNSYS_NameToAddress( "Sleep" )

     PROCAutoInit32(0)

     MCI_OPEN            = &803
     MCI_CLOSE           = &804
     MCI_PLAY            = &806
     MCI_SEEK            = &807
     MCI_STOP            = &808
     MCI_SET             = &80D
     MCI_STATUS          = &814
     MCI_ALL_DEVICE_ID   = -1
     MCI_WAIT            = 2
     MCI_FROM            = 4
     MCI_TO              = 8
     MCI_STATUS_POSITION = 2
     MCI_STATUS_ITEM     = &100
     MCI_OPEN_ELEMENT    = &200
     MCI_SET_TIME_FORMAT = &400
     MCI_PAUSE = &809
     MCI_RESUME = &855
     MCI_STATUS_LENGTH = 1

     MciSendCommand% = FNSYS_NameToAddress( "mciSendCommand" )

     PRINTTAB(16,7)"Please wait, loading.....";

     PROCcreateBg
     PROCinitStars


     SYS _FSOUND_Init%, 44100, 32, 0 TO ret%
     IF ret% = 0 PRINT "Cannot initialise fmod.dll, no soundcard installed?":END

     
title$ = "Unnamed Shooter V1.0"
     SYS "SetWindowText", @hwnd%, title$

     DIM alien%(500),alienx%(500),alieny%(500),alienprogress%(500),alienexplode%(500),alienexplosiontimer%(500),rotatealien%(500),alienver%(500),aliensprite%(500),aliendied%(500)
     DIM pattern1data%(500000)

     DIM alien2%(500),alienx2%(500),alieny2%(500),alienprogress2%(500),alienexplode2%(500),alienexplosiontimer2%(500),rotatealien2%(500),alienver2%(500),aliensprite2%(500),aliendied2%(500)
     DIM pattern2data%(500000)

     DIM missile%(9),missilex%(9),missiley%(9),missilesprite%(9)

     REM Load sounds
     
SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\boom.wav", _FSOUND_NORMAL, 0, 0 TO hBOOM%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\laser.wav", _FSOUND_NORMAL, 0, 0 TO hLASER%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\Sweepdow.wav", _FSOUND_NORMAL, 0, 0 TO hSWEEPDOW%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\Fanf15.wav", _FSOUND_NORMAL, 0, 0 TO hYEHAW%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\zap.wav", _FSOUND_NORMAL, 0, 0 TO hZAP%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\bomb.wav", _FSOUND_NORMAL, 0, 0 TO hBOMB%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\Whoosh.wav", _FSOUND_NORMAL, 0, 0 TO hWHOOSH%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\Fanf10.wav", _FSOUND_NORMAL, 0, 0 TO hFANFARE%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\Fanf18.wav", _FSOUND_NORMAL, 0, 0 TO hPERFECT%
     SYS _FSOUND_Sample_Load%, _FSOUND_FREE, @dir$+"data\Fanf22.wav", _FSOUND_NORMAL, 0, 0 TO hPOWERUP%
     REM SYS _FMUSIC_LoadSong%, @dir$+"data\acid.it" TO handle%

     
PROCopen( @dir$ + "data\music.wma" )
     mciStatusParms%!8 = MCI_STATUS_LENGTH
     SYS MciSendCommand%, DeviceID%, MCI_STATUS, MCI_STATUS_ITEM, mciStatusParms%
     tracklength%=mciStatusParms%!4

     REM Initialize Sprites
     
PROCLoadData( @dir$ + "data\brf10.DAT", font1%, 0 )
     PROCLoadData( @dir$ + "data\brf12.DAT", font2%, 0 )

     RANDOM%=RND(-TIME)
     RANDOM%=RND(300)+100

     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\alien"+STR$(RANDOM%)+".bmp", ship%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\nightsky.bmp", nightsky%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\gameover.bmp", gameover%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\shooter.bmp", shooter%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\keys.bmp", keys%, FALSE )
     FOR X=1 TO 9
       PROCLoad_24bppBM_as_32bppBM( @dir$+"data\missile1.bmp", missilesprite%(X), FALSE )
     NEXT
     PROC
Load_24bppBM_as_32bppBM( @dir$+"data\frame1.bmp", sprite13%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\frame2.bmp", sprite14%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\frame3.bmp", sprite15%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\frame4.bmp", sprite16%, FALSE )

     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\powerup.bmp", pusprite%, FALSE )
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\powerup2.bmp", pusprite2%, FALSE )


     FOR X=100 TO 400
       PROCLoad_24bppBM_as_32bppBM( @dir$+"data\alien"+STR$(X)+".bmp", aliensprite%(X-100), FALSE )
     NEXT

     FOR
X=100 TO 400
       PROCLoad_24bppBM_as_32bppBM( @dir$+"data\alien"+STR$(X)+".bmp", aliensprite2%(X-100), FALSE )
     NEXT


     
REM IF TIME MOD(2) PROCIntro ELSE PROCIntro2
     
REPEAT

       PROC
Intro
       Timer%=0
       Loop%=0

       Fps%=0
       debug%=0
       debugmessage$=""
       REM ON ERROR OFF
       
cheat%=0
       hit=0
       score=0
       lives%=5
       N%=1
       N2%=1
       round%=0
       wave%=0

       REM SYS _FMUSIC_PlaySong%, handle%
       
IF sound%=1 PROCplay( 0 )

       REPEAT
         PROC
Main
       UNTIL lives%=0 OR lives%=-1
       Autospeed%=0
       Autospeedselected%=0
       bg.y#=0
       PROCstop
       REM SYS _FMUSIC_StopSong%, handle%
       REM *REFRESH ON
       
PROCUpdatespeed REM Just to keep current speed setting
       REM SYS _FMUSIC_FreeSong%, handle%
       
SYS GFXLIB_Clr,dispVars{},&0
       FOR X=7680 TO 640 STEP -46
         xpos=(640-X)/2
         ypos=xpos*0.75
         Y=X*0.75
         SYS GFXLIB_BPlotScale,dispVars{}, gameover%,640,480,X,Y,xpos,ypos
         SYS I%, @hwnd%, 0, 0
         WAIT 1
       NEXT

       CLS
       SYS
GFXLIB_MMXCopy64, dispVars{}, gameover%, dibSectionAddr%, 19200



       score$ = "You Scored " + STR$score
       SYS GFXLIB_GetBmFontStrWidth, font2%, score$ TO scorewidth%
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, score$, (640-scorewidth%)/2, 325, &43171F
       kill$ = "You killed " + STR$hit + " Aliens"
       SYS GFXLIB_GetBmFontStrWidth, font2%, kill$ TO killwidth%
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, kill$, (640-killwidth%)/2, 305, &43171F
       PROCUpdatespeed REM Just to keep current speed setting
       
IF score>score3 PROCNewhighscore
       SYS GFXLIB_GetBmFontStrWidth, font2%, "Press SPACE to continue" TO txtWidth%
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "Press SPACE to continue", (640-txtWidth%)/2, 10, &43171F
       SYS I%, @hwnd%, 0, 0 REM Update screen
       
REPEAT
         
A$=GET$
       UNTIL
A$=" "

     UNTIL 2=1

     DEF PROCMain

     CLS
     VDU
23,1,0;0;0;0;

     adjusted%=0
     adjustcounter%=0
     starfield%=1

     FOR X=1 TO 9
       missile%(X)=0
       missilex%(X)=0
       missiley%(X)=0
     NEXT

     
rank$=""
     powerup%=0
     powerup2%=0
     pudrop%=0
     pux%=0
     puy%=0
     pund%=0
     musicisplaying%=1
     skillkill%=0
     skillkillcounter%=0
     stopmusic%=0
     soundtimer%=0
     b%=0
     Y%=0
     X%=288
     noreset%=0
     count=0
     delay%=0
     speedup%=0
     speeddown%=0
     enter%=0
     timer%=0
     missile1%=0
     missile1x%=0
     missile1y%=50
     missile2%=0
     missile2x%=0
     missile2y%=50
     missile3%=0
     missile3x%=0
     missile3y%=50
     padlen% = 9
     padlen2%=2
     left%=0
     right%=0
     up%=0
     down%=0
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1active%=0
     wave1started%=0
     wave2active%=0
     wave2started%=0
     N%=1
     N2%=1
     startsprite%=0
     endsprite%=0
     startsprite2%=0
     endsprite2%=0
     stepcounter%=0
     stepcounter2%=0
     alienwave1gap%=0
     alienwave2gap%=0
     pattern1length%=0
     pattern2length%=0
     wave1completed%=1
     wave2completed%=1
     busy%=0
     message$=""
     message%=0
     Z%=0
     COLOUR 7
     VDU 4
     SYS "timeBeginPeriod",1 TO sperm%

     TIME=0

     REPEAT
       SYS
"GetForegroundWindow" TO hw%
       IF hw% = @hwnd% THEN

         
REM SYS "timeGetTime" TO tick

         REM SYS GFXLIB_MMXCopy64, dispVars{}, nightsky%, dibSectionAddr%, 19200
         
PROCdrawBg
         (ROUNDS)

         mciStatusParms%!8 = MCI_STATUS_POSITION
         SYS MciSendCommand%, DeviceID%, MCI_STATUS, MCI_STATUS_ITEM, mciStatusParms%
         IF mciStatusParms%!4 >= tracklength% THEN
           PROC
play( 0 )
         ENDIF


         IF
round%=0 AND wave1active%=0 AND wave1started%=0 AND busy%=0 wave%=wave%+1 PROCRound1 PROCWhoosh
         IF round%=1 AND wave1active%=0 AND wave1started%=0 AND busy%=0 wave%=wave%+1 PROCRound2 PROCWhoosh
         IF round%=2 AND wave1active%=0 AND wave1started%=0 AND busy%=0 wave%=wave%+1 PROCRound3 PROCWhoosh
         IF round%=4 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound4 PROCWhoosh
         IF round%=6 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound5 PROCWhoosh
         IF round%=7 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound6 PROCWhoosh
         IF round%=9 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound7 PROCWhoosh
         IF round%=11 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound8 PROCWhoosh
         IF round%=12 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound9 PROCWhoosh
         IF round%=14 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound10 PROCWhoosh
         IF round%=15 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound11 PROCWhoosh
         IF round%=17 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound12 PROCWhoosh
         IF round%=19 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound13 PROCWhoosh
         IF round%=21 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound14 PROCWhoosh
         IF round%=22 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound15 PROCWhoosh
         IF round%=23 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound16 PROCWhoosh
         IF round%=24 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound17 PROCWhoosh
         IF round%=25 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound18 PROCWhoosh
         IF round%=27 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound19 PROCWhoosh
         IF round%=29 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRound20 PROCWhoosh


         IF round%>29 AND wave1active%=0 AND wave1started%=0 AND wave2active%=0 AND wave2started%=0 AND busy%=0 wave%=wave%+1 PROCRoundrandom PROCWhoosh

         IF busy%=1 PROCLevelup

         REM *REFRESH OFF



         REM Skill message


         REM IF skillkill%=1 COLOUR RND(13): PRINTTAB(17,1)Message$
         
IF skillkill%=1 skillkillcounter%=skillkillcounter%+1
         IF skillkill%=1 AND skillkillcounter%=1 SYS GFXLIB_GetBmFontStrWidth, font2%, Message$ TO skillwidth%
         IF skillkill%=1 SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, Message$, (640-skillwidth%)/2, 420, &F0F0F0


         IF skillkillcounter% >130 skillkillcounter%=0 skillkill%=0 REM PROCDisplayscore


         
IF INKEY(-26) left%=left%+1 right%=right%-1 REM Arrowkey left Move Left
         
IF INKEY(-122) right%=right%+1 left%=left%-1 REM Arrowkey right Move Right
         
IF INKEY(-58) up%=up%+1 down%=down%-1 REM Arrowkey up Move up
         
IF INKEY(-42) down%=down%+1 up%=up%-1 REM Arrowkey down Move down

         
IF INKEY(-90) Autospeed%=1 Autospeedselected%=1 REM "Del" Enables automatic speed adjustment
         
IF INKEY(-74) AND enter%=0 PROClaunch: enter%=1 REM "ENTER" Fire Missile
         
IF NOT INKEY(-74) enter%=0
         IF INKEY(-98) AND Z%=0 PROClaunch: Z%=1
         IF NOT INKEY(-98) Z%=0
         IF INKEY(-59) AND speedup%=0 wait%=wait%-1: speedup%=1 Autospeed%=0 REM Numeric "+" Increase speed

         
IF NOT INKEY(-59) speedup%=0
         IF INKEY(-51) debug%=1 REM "D" for Debug Mode
         
IF INKEY(-60) AND speeddown%=0 wait%=wait%+1: speeddown%=1 Autospeed%=0 REM numeric "-" Decrease speed
         
IF NOT INKEY (-60) speeddown%=0
         IF INKEY(-113) lives%=0 PROCDie ENDPROC
         
REM Cheatmode hotkey removed :-)
         
IF INKEY(-86) starfield%=0 REM "N" disables plotting of stars (For slow machines. Obsolete now, but left in just in case)
         
IF NOT INKEY(-26) left%=left%-1
         IF NOT INKEY(-122) right%=right%-1
         IF NOT INKEY(-58) up%=up%-1
         IF NOT INKEY(-42) down%=down%-1
         IF sound%=1 AND skillkill%=0 AND INKEY(-17) sound%=0 skillkill%=1 Message$="sound off" Autospeed%=1 PROCpausemusic REM "Q" for sound on/off
         
IF sound%=0 AND skillkill%=0 AND INKEY(-17) sound%=1 skillkill%=1 Message$="sound on" Autospeed%=1 PROCresumemusic
         IF INKEY(-82) AND shadow%=1 AND skillkill%=0 shadow%=0 skillkill%=1 Message$="shadows off" Autospeed%=1
         IF INKEY(-82) AND shadow%=0 AND skillkill%=0 shadow%=1 skillkill%=1 Message$="shadows on" Autospeed%=1

         IF wait%=-1 wait%=0


         REM IF starfield%=1 PROCPlotstars

         
timer%=timer%+1

         REM Aliens Moving
         
FOR R%=startsprite%+N% TO startsprite% STEP -1

           IF alien%(R%)=1 AND alienexplode%(R%)=0 AND alienver%(R%)=0 alienx%(R%)=pattern1data%(alienprogress%(R%))
           IF alien%(R%)=1 AND alienexplode%(R%)=0 alienprogress%(R%)=alienprogress%(R%)+1
           IF alien%(R%)=1 AND alienexplode%(R%)=0 AND alienver%(R%)=0 alieny%(R%)=pattern1data%(alienprogress%(R%))
           IF alien%(R%)=1 AND alienexplode%(R%)=0 alienprogress%(R%)=alienprogress%(R%)+1
           IF alien%(R%)=1 AND alienexplode%(R%)=0 rotatealien%(R%)=pattern1data%(alienprogress%(R%))
           IF alien%(R%)=1 AND alienexplode%(R%)=0 alienprogress%(R%)=alienprogress%(R%)+1
           IF alien%(R%)=1 AND alienexplode%(R%)=0 AND shadow%=1 SYS GFXLIB_PlotRotateShapeHalfIntensity, dispVars{}, aliensprite%(R%), 56, 56, alienx%(R%)-6, alieny%(R%)-6, rotatealien%(R%)
           IF alien%(R%)=1 AND alienexplode%(R%)=0 SYS GFXLIB_PlotRotateSetACBit, dispVars{}, aliensprite%(R%), 56, 56, alienx%(R%), alieny%(R%), rotatealien%(R%), 5

         NEXT

         FOR
R%=startsprite2%+N2% TO startsprite2% STEP -1

           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 AND alienver2%(R%)=0 alienx2%(R%)=pattern2data%(alienprogress2%(R%))
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 alienprogress2%(R%)=alienprogress2%(R%)+1
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 AND alienver2%(R%)=0 alieny2%(R%)=pattern2data%(alienprogress2%(R%))
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 alienprogress2%(R%)=alienprogress2%(R%)+1
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 rotatealien2%(R%)=pattern2data%(alienprogress2%(R%))
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 alienprogress2%(R%)=alienprogress2%(R%)+1
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 AND shadow%=1 SYS GFXLIB_PlotRotateShapeHalfIntensity, dispVars{}, aliensprite2%(R%), 56, 56, alienx2%(R%)-6, alieny2%(R%)-6, rotatealien2%(R%)
           IF alien2%(R%)=1 AND alienexplode2%(R%)=0 SYS GFXLIB_PlotRotateSetACBit, dispVars{}, aliensprite2%(R%), 56, 56, alienx2%(R%), alieny2%(R%), rotatealien2%(R%), 5

         NEXT

         IF
shadow%=1 SYS GFXLIB_PlotRotateShapeHalfIntensity, dispVars{}, ship%, 56, 56, X%+22, Y%+22,0
         SYS GFXLIB_PlotTestACBit, dispVars{}, ship%, 56, 56, X%, Y%, 5 TO collision%
         IF collision%<> 0 AND cheat%=0 PROCDie ENDPROC


         
REM Missile moving and collision detection

         
IF missile%(4)=1 missilex%(4)=missilex%(4)-2
         IF missile%(4)=1 AND missilex%(4)<1 missile%(4)=0
         IF missile%(5)=1 missilex%(5)=missilex%(5)+2
         IF missile%(5)=1 AND missilex%(5)>640 missile%(5)=0
         IF missile%(6)=1 missilex%(6)=missilex%(6)-2
         IF missile%(6)=1 AND missilex%(6)<1 missile%(6)=0
         IF missile%(7)=1 missilex%(7)=missilex%(7)+2
         IF missile%(7)=1 AND missilex%(7)>640 missile%(7)=0
         IF missile%(8)=1 missilex%(8)=missilex%(8)-2
         IF missile%(8)=1 AND missilex%(8)<1 missile%(8)=0
         IF missile%(9)=1 missilex%(9)=missilex%(9)+2
         IF missile%(9)=1 AND missilex%(9)>640 missile%(9)=0



         FOR Z=1 TO 9

           IF missile%(Z)=1 SYS GFXLIB_PlotRotate, dispVars{}, missilesprite%(Z), 32, 32, missilex%(Z), missiley%(Z),0
           IF missile%(Z)=1 missiley%(Z)=missiley%(Z)+15 IF missiley%(Z) > 480 missile%(Z)=0
           FOR R%=startsprite% TO startsprite%+N%

             IF missile%(Z)=1 AND alienexplode%(R%)=0 AND alien%(R%)=1 AND missilex%(Z) < alienx%(R%)+28 AND missilex%(Z) > alienx%(R%)-28 AND missiley%(Z)>=alieny%(R%)-28 AND missiley%(Z) < alieny%(R%)+28 alienexplode%(R%)=1 missile%(Z)=0  PROCSweepdow

           NEXT



           FOR
R%=startsprite2% TO startsprite2%+N2%

             IF missile%(Z)=1 AND alienexplode2%(R%)=0 AND alien2%(R%)=1 AND missilex%(Z) < alienx2%(R%)+28 AND missilex%(Z) > alienx2%(R%)-28 AND missiley%(Z)>=alieny2%(R%)-28 AND missiley%(Z) < alieny2%(R%)+28 alienexplode2%(R%)=1 missile%(Z)=0  PROCSweepdow

           NEXT
         NEXT

         
REM More Keyboard testing
         
X%=X%-left% IF X%<0 X%=0
         X%=X%+right% IF X%>576 X%=576
         IF left%>10 left%=10
         IF right%>10 right%=10
         IF left%<0 left%=0
         IF right%<0 right%=0

         Y%=Y%-down% IF Y%<0 Y%=0
         Y%=Y%+up% IF Y%>200 Y%=200
         IF up%>3 up%=3
         IF down%>3 down%=3
         IF up%<0 up%=0
         IF down%<0 down%=0

         REPEAT UNTIL INKEY(0)=-1

         REM Alien Explosion handling
         
FOR R%=startsprite% TO startsprite%+N%

           IF powerup%=0 AND alienexplode%(R%)=1 AND RND(1000)=1 AND pudrop%=0 pund%=1 pudrop%=1 puangle%=RND(360) puy%=alieny%(R%) pux%=alienx%(R%) skillkill%=1 Message$="grab the powerup!"
           IF pudrop%=0 AND  alienexplode%(R%)=1 AND RND(2000)=1 AND lives%=1 pund%=2 pudrop%=1 powerup2%=1 puangle%=RND(360) puy%=alieny%(R%) pux%=alienx%(R%) skillkill%=1 Message$="grab the powerup!"

           IF alienexplode%(R%)=1 alienexplosiontimer%(R%)=alienexplosiontimer%(R%)+1
           IF alienexplode%(R%)=1 AND alienexplosiontimer%(R%)<5 SYS GFXLIB_PlotRotate, dispVars{}, sprite13%, 64, 64, alienx%(R%), alieny%(R%),alienexplosiontimer%(R%)+35
           IF alienexplode%(R%)=1 AND alienexplosiontimer%(R%)>5 AND alienexplosiontimer%(R%)<10 SYS GFXLIB_PlotRotate, dispVars{}, sprite14%, 64, 64, alienx%(R%), alieny%(R%),alienexplosiontimer%(R%)+35
           IF alienexplode%(R%)=1 AND alienexplosiontimer%(R%)>10 AND alienexplosiontimer%(R%)<15 SYS GFXLIB_PlotRotate, dispVars{}, sprite15%, 64, 64, alienx%(R%), alieny%(R%),alienexplosiontimer%(R%)+35
           IF alienexplode%(R%)=1 AND alienexplosiontimer%(R%)>15 SYS GFXLIB_PlotRotate, dispVars{}, sprite16%, 64, 64, alienx%(R%), alieny%(R%),alienexplosiontimer%(R%)+35


           IF alienexplosiontimer%(R%)=20 alienexplode%(R%)=0 alien%(R%)=0 aliendied%(R%)=1 alienexplosiontimer%(R%)=0 hit=hit+1 score=score+500

         NEXT



         FOR
R%=startsprite2% TO startsprite2%+N2%

           IF powerup%=0 AND alienexplode2%(R%)=1 AND RND(1000)=1 AND pudrop%=0 pund%=1 pudrop%=1 puangle%=RND(360) puy%=alieny2%(R%) pux%=alienx2%(R%) skillkill%=1 Message$="grab the powerup!"
           IF pudrop%=0 AND  alienexplode2%(R%)=1 AND RND(2000)=1 AND lives%=1 pund%=2 pudrop%=1 powerup2%=1 puangle%=RND(360) puy%=alieny2%(R%) pux%=alienx2%(R%) skillkill%=1 Message$="grab the powerup!"

           IF alienexplode2%(R%)=1 alienexplosiontimer2%(R%)=alienexplosiontimer2%(R%)+1
           IF alienexplode2%(R%)=1 AND alienexplosiontimer2%(R%)<5 SYS GFXLIB_PlotRotate, dispVars{}, sprite13%, 64, 64, alienx2%(R%), alieny2%(R%),alienexplosiontimer2%(R%)+25
           IF alienexplode2%(R%)=1 AND alienexplosiontimer2%(R%)>5 AND alienexplosiontimer2%(R%)<10 SYS GFXLIB_PlotRotate, dispVars{}, sprite14%, 64, 64, alienx2%(R%), alieny2%(R%),alienexplosiontimer2%(R%)+25
           IF alienexplode2%(R%)=1 AND alienexplosiontimer2%(R%)>10 AND alienexplosiontimer2%(R%)<15 SYS GFXLIB_PlotRotate, dispVars{}, sprite15%, 64, 64, alienx2%(R%), alieny2%(R%),alienexplosiontimer2%(R%)+25
           IF alienexplode2%(R%)=1 AND alienexplosiontimer2%(R%)>15 SYS GFXLIB_PlotRotate, dispVars{}, sprite16%, 64, 64, alienx2%(R%), alieny2%(R%),alienexplosiontimer2%(R%)+25


           IF alienexplosiontimer2%(R%)=20 alienexplode2%(R%)=0 alien2%(R%)=0 aliendied2%(R%)=1 alienexplosiontimer2%(R%)=0 hit=hit+1 score=score+500

         NEXT


         
REM Respawn Aliens
         
stepcounter%=stepcounter%+1: IF stepcounter%>alienwave1gap% N%=N%+1 stepcounter%=0
         IF N%>endsprite%-startsprite% THEN N%=endsprite%-startsprite%
         FOR R%=startsprite% TO startsprite%+N%



           IF alien%(R%)=0 AND wave1active%=1 AND aliendied%(R%)=0 AND stepcounter%=alienwave1gap% alien%(R%)=1 alienprogress%(R%)=1
           IF N%=endsprite%-startsprite% wave1active%=0
           IF alien%(R%)=1 AND alienprogress%(R%)>=pattern1length% DIV 5 alien%(R%)=0 aliendied%(R%)=1 perfect1%=0


         NEXT
         IF
N%=endsprite%-startsprite% AND wave1started%=1 AND wave1completed%=0 THEN PROCCheckwave1dead


         stepcounter2%=stepcounter2%+1: IF stepcounter2%>alienwave2gap% N2%=N2%+1 stepcounter2%=0
         IF N2%>endsprite2%-startsprite2% THEN N2%=endsprite2%-startsprite2%
         FOR R%=startsprite2% TO startsprite2%+N2%



           IF alien2%(R%)=0 AND wave2active%=1 AND aliendied2%(R%)=0 AND stepcounter2%=alienwave2gap% alien2%(R%)=1 alienprogress2%(R%)=1
           IF N2%=endsprite2%-startsprite2% wave2active%=0
           IF alien2%(R%)=1 AND alienprogress2%(R%)>=pattern2length% DIV 5 alien2%(R%)=0 aliendied2%(R%)=1 perfect2%=0


         NEXT
         IF
N2%=endsprite2%-startsprite2% AND wave2started%=1 AND wave2completed%=0 THEN PROCCheckwave2dead

         REM Powerup Handling

         
IF powerup%=0 AND pudrop%=1 AND pund%=1 AND X%< pux% AND X%> pux%-64 AND Y%>=puy%-64 AND Y% < puy% powerup%=1 pudrop%=0 skillkill%=1 Message$="powerup! triple-shot!" PROCPowerupsound
         IF pudrop%=1 AND pund%=1 SYS GFXLIB_PlotRotate, dispVars{}, pusprite%, 28, 28, pux%, puy%,puangle%

         IF pudrop%=1 puy%=puy%-1
         IF pudrop%=1 puangle%=puangle%+2 IF puangle%>360 puangle%=0
         IF pudrop%=1 AND puy%<1 pudrop%=0


         IF pudrop%=1 AND pund%=2 SYS GFXLIB_PlotRotate, dispVars{}, pusprite2%, 28, 28, pux%, puy%,puangle%
         IF powerup2%=1 AND pudrop%=1 AND pund%=2 AND X%< pux% AND X%> pux%-64 AND Y%>=puy%-64 AND Y% < puy% lives%=lives%+1 powerup2%=0 pudrop%=0 skillkill%=1 Message$="powerup! extra life!" PROCPowerupsound

         REMSpeed adjustment

         REM SYS "timeGetTime" TO tick2
         REM elapsed=tick2-tick
         REM IF elapsed<1 elapsed=1

         
Loop%=Loop%+1
         IF TIME>10 Fps%=Loop%*10 Loop%=0
         IF Fps%>90 AND TIME>10 AND Autospeed%=1 wait%=wait%+1 adjusted%=1
         IF Fps%<80 AND TIME>10 AND Autospeed%=1 wait%=wait%-1 adjusted%=1
         REM IF Fps%<70 AND TIME>10 AND Autospeed%=1 wait%=wait%-1 adjusted%=1
         
IF wait%<0 wait%=0
         IF adjusted%=0 AND Autospeed%=1 adjustcounter%=adjustcounter%+1
         IF adjustcounter%>600 Autospeed%=0 Autospeedselected%=0
         IF adjusted%=1 adjustcounter%=0
         adjusted%=0
         REM IF TIME>10 AND wait%=0 N%=N%-1
         
IF TIME>10 THEN TIME=0

         PROCDisplayscore
         IF debug%=1 PROCDebug

         SYS I%, @hwnd%, 0, 0 REM Update screen
         
IF INKEY(-56) PROCwait REM "P" for pause
       
ENDIF
       IF
wait%>0 SYS W%, wait%
       *REFRESH


     UNTIL 2=1


     DEF PROCCheckwave1dead
     stillalive%=0
     FOR Q%=startsprite% TO endsprite%
       IF alien%(Q%)=1 stillalive%=1
     NEXT
     IF
stillalive%=1 THEN ENDPROC
     IF
wave1completed%=1 THEN ENDPROC
     IF
wave2completed%=1 busy%=1
     startsprite%=0
     endsprite%=0
     wave1completed%=1
     wave1started%=0
     round%=round%+1
     N%=1
     ENDPROC

     
DEF PROCCheckwave2dead
     stillalive2%=0
     FOR Q%=startsprite2% TO endsprite2%
       IF alien2%(Q%)=1 stillalive2%=1
     NEXT
     IF
stillalive2%=1 ENDPROC
     IF
wave2completed%=1 ENDPROC
     IF
wave1completed%=1 busy%=1
     startsprite2%=0
     endsprite2%=0
     wave2completed%=1
     wave2started%=0
     round%=round%+1
     N2%=1
     ENDPROC


     
DEF PROCLoadwave1pattern (pattern1wave%)
     REM Load Patterns
     
FOR Q%=1 TO 300
       aliendied%(Q%)=0
     NEXT
     
pattern1=OPENIN (@dir$+"data\pattern"+STR$pattern1wave%+".dat")
     pattern1length%=EXT#pattern1

     FOR Q%=1 TO pattern1length%
       INPUT#pattern1, pattern1data%(Q%)
     NEXT
     CLOSE
#pattern1
     ENDPROC


     
DEF PROCLoadwave2pattern (pattern2wave%)
     REM Load Patterns
     
FOR Q%=1 TO 300
       aliendied2%(Q%)=0
     NEXT
     
pattern2=OPENIN (@dir$+"data\pattern"+STR$pattern2wave%+".dat")
     pattern2length%=EXT#pattern2

     FOR Q%=1 TO pattern2length%
       INPUT#pattern2, pattern2data%(Q%)
     NEXT
     CLOSE
#pattern2
     ENDPROC


     
DEF PROCRound1
     Z=OPENIN (@dir$+"data\pattern999.dat")
     IF Z=0 PROCLoadwave1pattern (1) ELSE PROCLoadwave1pattern (999)
     CLOSE#Z
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=220
     endsprite%=260
     wave1completed%=0
     wave2completed%=1
     ENDPROC

     
DEF PROCRound2
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=15
     stepcounter%=0
     wave1active%=1
     startsprite%=10
     endsprite%=60
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (2)
     ENDPROC

     
DEF PROCRound3
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=60
     endsprite%=110
     wave1completed%=0
     PROCLoadwave1pattern (1)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=20
     stepcounter2%=0
     wave2active%=1
     startsprite2%=111
     endsprite2%=137
     wave2completed%=0
     PROCLoadwave2pattern (3)
     ENDPROC

     
DEF PROCRound4
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=15
     stepcounter%=0
     wave1active%=1
     startsprite%=140
     endsprite%=180
     wave1completed%=0
     PROCLoadwave1pattern (4)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=15
     stepcounter2%=0
     wave2active%=1
     startsprite2%=140
     endsprite2%=180
     wave2completed%=0
     PROCLoadwave2pattern (5)
     ENDPROC


     
DEF PROCRound5
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=180
     endsprite%=210
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (6)
     ENDPROC


     
DEF PROCRound6
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=15
     stepcounter%=0
     wave1active%=1
     startsprite%=1
     endsprite%=29
     wave1completed%=0
     PROCLoadwave1pattern (7)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=15
     stepcounter2%=0
     wave2active%=1
     startsprite2%=1
     endsprite2%=29
     wave2completed%=0
     PROCLoadwave2pattern (8)
     ENDPROC


     
DEF PROCRound7
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=20
     stepcounter%=0
     wave1active%=1
     startsprite%=150
     endsprite%=180
     wave1completed%=0
     PROCLoadwave1pattern (9)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=20
     stepcounter2%=0
     wave2active%=1
     startsprite2%=150
     endsprite2%=180
     wave2completed%=0
     PROCLoadwave2pattern (10)
     ENDPROC


     
DEF PROCRound8
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=220
     endsprite%=270
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (11)
     ENDPROC



     
DEF PROCRound9
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=270
     endsprite%=300
     wave1completed%=0
     PROCLoadwave1pattern (12)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=10
     stepcounter2%=0
     wave2active%=1
     startsprite2%=270
     endsprite2%=300
     wave2completed%=0
     PROCLoadwave2pattern (13)
     ENDPROC



     
DEF PROCRound10
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=7
     stepcounter%=0
     wave1active%=1
     startsprite%=150
     endsprite%=200
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (14)
     ENDPROC



     
DEF PROCRound11
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=15
     stepcounter%=0
     wave1active%=1
     startsprite%=210
     endsprite%=240
     wave1completed%=0
     PROCLoadwave1pattern (15)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=15
     stepcounter2%=0
     wave2active%=1
     startsprite2%=210
     endsprite2%=240
     wave2completed%=0
     PROCLoadwave2pattern (16)
     ENDPROC


     
DEF PROCRound12
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=240
     endsprite%=270
     wave1completed%=0
     PROCLoadwave1pattern (17)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=10
     stepcounter2%=0
     wave2active%=1
     startsprite2%=240
     endsprite2%=270
     wave2completed%=0
     PROCLoadwave2pattern (18)
     ENDPROC


     
DEF PROCRound13
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=12
     stepcounter%=0
     wave1active%=1
     startsprite%=270
     endsprite%=300
     wave1completed%=0
     PROCLoadwave1pattern (19)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=12
     stepcounter2%=0
     wave2active%=1
     startsprite2%=240
     endsprite2%=270
     wave2completed%=0
     PROCLoadwave2pattern (20)
     ENDPROC

     
DEF PROCRound14
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=150
     endsprite%=200
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (21)
     ENDPROC

     
DEF PROCRound15
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=100
     endsprite%=150
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (22)
     ENDPROC

     
DEF PROCRound16
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=50
     endsprite%=100
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (23)
     ENDPROC



     
DEF PROCRound17
     dualwave%=0
     perfect1%=1
     perfect2%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=50
     endsprite%=100
     wave1completed%=0
     wave2completed%=1
     PROCLoadwave1pattern (24)
     ENDPROC

     
DEF PROCRound18
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=12
     stepcounter%=0
     wave1active%=1
     startsprite%=50
     endsprite%=100
     wave1completed%=0
     PROCLoadwave1pattern (25)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=12
     stepcounter2%=0
     wave2active%=1
     startsprite2%=1
     endsprite2%=50
     wave2completed%=0
     PROCLoadwave2pattern (26)
     ENDPROC

     
DEF PROCRound19
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=10
     stepcounter%=0
     wave1active%=1
     startsprite%=200
     endsprite%=250
     wave1completed%=0
     PROCLoadwave1pattern (27)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=10
     stepcounter2%=0
     wave2active%=1
     startsprite2%=150
     endsprite2%=200
     wave2completed%=0
     PROCLoadwave2pattern (28)
     ENDPROC

     
DEF PROCRound20
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=8
     stepcounter%=0
     wave1active%=1
     startsprite%=50
     endsprite%=100
     wave1completed%=0
     PROCLoadwave1pattern (29)
     perfect2%=1
     wave2started%=1
     alienwave2gap%=8
     stepcounter2%=0
     wave2active%=1
     startsprite2%=1
     endsprite2%=50
     wave2completed%=0
     PROCLoadwave2pattern (30)
     ENDPROC



     
DEF PROCRoundrandom
     dualwave%=1
     perfect1%=1
     wave1started%=1
     alienwave1gap%=12
     stepcounter%=0
     wave1active%=1
     startsprite%=50
     endsprite%=75
     wave1completed%=0
     perfect2%=1
     wave2started%=1
     alienwave2gap%=12
     stepcounter2%=0
     wave2active%=1
     startsprite2%=1
     endsprite2%=25
     wave2completed%=0
     REPEAT
       
RANDOM1%=RND(30)
       RANDOM2%=RND(30)
     UNTIL RANDOM1%<>RANDOM2%
     PROCLoadwave1pattern (RANDOM1%)
     PROCLoadwave2pattern (RANDOM2%)
     ENDPROC


     
DEF PROCLevelup
     message$="Wave "+STR$wave%+" Completed"
     SYS GFXLIB_GetBmFontStrWidth, font2%, message$ TO txtWidth%
     SYS GFXLIB_GetBmFontStrWidth, font2%, "Perfect, bonus!" TO txtWidth2%
     SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, message$, (640-txtWidth%)/2, 230, &FFFFFF
     IF sound%=1 AND message%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hFANFARE%
     IF perfect1%=1 AND perfect2%=1 AND message%>75 SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "Perfect, bonus!", (640-txtWidth2%)/2, 200, RND(16777215) score=score+500
     IF sound%=1 AND perfect1%=1 AND perfect2%=1 AND message%=75 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hPERFECT%
     message%=message%+1 IF message%=150 message%=0: busy%=0

     ENDPROC


     
DEF PROClaunch
     IF missile%(1)=0 AND timer%>5 AND powerup%=1 missile%(1)=1 missilex%(1)=X%+28  missiley%(1)=Y%+56 missile%(4)=1 missilex%(4)=X%+28  missiley%(4)=Y%+56 missile%(5)=1 missilex%(5)=X%+28  missiley%(5)=Y%+56 timer%=0 PROCLaser ENDPROC
     IF
missile%(1)=0 AND timer%>5 missile%(1)=1 missilex%(1)=X%+28  missiley%(1)=Y%+56 timer%=0 PROCLaser ENDPROC
     IF
missile%(2)=0 AND timer%>5 AND powerup%=1 missile%(2)=1 missilex%(2)=X%+28  missiley%(2)=Y%+56 missile%(6)=1 missilex%(6)=X%+28  missiley%(6)=Y%+56 missile%(7)=1 missilex%(7)=X%+28  missiley%(7)=Y%+56 timer%=0 PROCLaser ENDPROC
     IF
missile%(2)=0 AND timer%>5 missile%(2)=1 missilex%(2)=X%+28  missiley%(2)=Y%+56 timer%=0 PROCLaser ENDPROC
     IF
missile%(3)=0 AND timer%>5 AND powerup%=1 missile%(3)=1 missilex%(3)=X%+28  missiley%(3)=Y%+56 missile%(8)=1 missilex%(8)=X%+28  missiley%(8)=Y%+56 missile%(9)=1 missilex%(9)=X%+28  missiley%(9)=Y%+56 timer%=0 PROCLaser ENDPROC
     IF
missile%(3)=0 AND timer%>5 missile%(3)=1 missilex%(3)=X%+28  missiley%(3)=Y%+56 timer%=0 PROCLaser ENDPROC
     ENDPROC

     
DEF PROCDie
     REM *REFRESH ON
     
IF debug%=1 PROCDebug

     IF cheat%=0 lives%=lives%-1
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hBOOM%

     FOR delay% = 10 TO 0 STEP -0.10
       PROCdrawBg


       FOR R%=startsprite%+N% TO startsprite% STEP -1
         IF alien%(R%)=1 AND alienexplode%(R%)=0 AND shadow%=1 SYS GFXLIB_PlotRotateShapeHalfIntensity, dispVars{}, aliensprite%(R%), 56, 56, alienx%(R%)-6, alieny%(R%)-6, rotatealien%(R%)
         IF alien%(R%)=1 AND alienexplode%(R%)=0 SYS GFXLIB_PlotRotateSetACBit, dispVars{}, aliensprite%(R%), 56, 56, alienx%(R%), alieny%(R%), rotatealien%(R%), 5
       NEXT
       FOR
R%=startsprite2%+N2% TO startsprite2% STEP -1
         IF alien2%(R%)=1 AND alienexplode2%(R%)=0 AND shadow%=1 SYS GFXLIB_PlotRotateShapeHalfIntensity, dispVars{}, aliensprite2%(R%), 56, 56, alienx2%(R%)-6, alieny2%(R%)-6, rotatealien2%(R%)
         IF alien2%(R%)=1 AND alienexplode2%(R%)=0 SYS GFXLIB_PlotRotateSetACBit, dispVars{}, aliensprite2%(R%), 56, 56, alienx2%(R%), alieny2%(R%), rotatealien2%(R%), 5
       NEXT

       SYS
I%, @hwnd%, 0, 0 REM Update screen
       
WAIT delay%



       SYS GFXLIB_Plot, dispVars{}, ship%, 56, 56, X%, Y%


       SYS I%, @hwnd%, 0, 0 REM Update screen
       
WAIT delay%

     NEXT
     PROC
drawBg
     SYS I%, @hwnd%, 0, 0 REM Update screen

     
WAIT 100
     FOR X=startsprite% TO endsprite%
       alien%(X)=0 alienexplode%(X)=0
     NEXT
     FOR
X=startsprite2% TO endsprite2%
       alien2%(X)=0 alienexplode2%(X)=0
     NEXT

     IF
wave1completed%=1 AND wave2completed%=0 AND dualwave%=1 round%=round%-1
     IF wave1completed%=0 AND wave2completed%=1 AND dualwave%=1 round%=round%-1

     wave%=wave%-1
     startsprite%=0
     endsprite%=0
     wave1completed%=1
     wave1started%=0
     N%=1
     startsprite2%=0
     endsprite2%=0
     wave2completed%=1
     wave2started%=0
     N2%=1
     wave1active%=0
     wave2active%=0
     powerup%=0
     ENDPROC

     
DEF PROCCreatehighscore
     CLS
     
*FONT System,12
     PRINTTAB(40,2)"ATTENTION!"
     PRINTTAB(2,5)"This program has the ability of automatically posting your highscores to an online database"
     PRINTTAB(2,6)"featuring the best scores achieved. (look in the readme.txt for the URL)"
     PRINTTAB(2,7)"Data transmitted is limited to your score and whatever you enter on the highscore table."
     PRINTTAB(2,9)"It is completely optional, and you now have to decide whether you want this to happen or not."
     PRINTTAB(38,12)"PRESS EITHER:"
     PRINTTAB(25,14)"""Y"" - To signify that you DO allow this, or:"
     PRINTTAB(25,15)"""N"" - To signify that you do NOT."
     REPEAT A$=GET$
     UNTIL
A$="n" OR A$="N" OR A$="y" OR A$="Y"
     IF A$="Y" OR A$="y" accept%=1
     IF A$="N" OR A$="n" accept%=0
     Autospeed%=1
     shadow%=1
     name1$="No-one"
     name2$="No-one"
     name3$="No-one"
     starfield%=1
     wait%=10
     score1=0
     score2=0
     score3=0
     highscorefile=OPENOUT blastscore$
     PRINT#highscorefile,name1$,score1,name2$,score2,name3$,score3,wait%,starfield%,shadow%,accept%
     CLOSE#highscorefile
     ENDPROC


     
DEF PROCUpdatespeed
     highscorefile=OPENOUT blastscore$
     PRINT#highscorefile,name1$,score1,name2$,score2,name3$,score3,wait%,starfield%,shadow%,accept%
     CLOSE#highscorefile
     ENDPROC



     
DEF PROCNewhighscore
     VDU 5
     *FONT Blade Runner movie font,20
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hYEHAW%
     SYS GFXLIB_GetBmFontStrWidth, font2%, "congratulations! new highscore!" TO txtWidth%
     SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "congratulations! new highscore!", (640-txtWidth%)/2, 50, &43171F
     SYS GFXLIB_GetBmFontStrWidth, font2%, "Enter your name:" TO txtWidth2%
     SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "Enter your name:", (640-txtWidth2%)/2, 150, &43171F
     GCOL 0,8
     MOVE 300,250
     SYS I%, @hwnd%, 0, 0
     REPEAT UNTIL INKEY(0)=-1
     INPUT LINE name$
     PROCSortscore
     highscorefile=OPENOUT blastscore$
     PRINT#highscorefile,name1$,score1,name2$,score2,name3$,score3,wait%,starfield%,shadow%,accept%
     CLOSE#highscorefile
     scrollleft%=(640-scorewidth%)/2
     scrollright%=(640-killwidth%)/2
     scrolldown%=150
     PROCpostweb
     REPEAT
       SYS
GFXLIB_MMXCopy64, dispVars{}, gameover%, dibSectionAddr%, 19200
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "congratulations! new highscore!", (640-txtWidth%)/2, scrolldown%-100, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "Enter your name:", (640-txtWidth2%)/2, scrollleft%, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, score$, scrollleft%, 325, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, kill$, scrollright%, 305, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, name$, 150, 125, RND(16777215)
       scrollleft%=scrollleft%-4
       scrollright%=scrollright%+4
       scrolldown%=scrolldown%-2

       SYS I%, @hwnd%, 0, 0
       SYS W%, wait%
     UNTIL scrollright%>700
     place$="You are "+rank$+" on the highscore list"
     SYS GFXLIB_GetBmFontStrWidth, font2%, place$ TO txtWidth2%
     SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, place$, (640-txtWidth2%)/2, 355, &8B3043
     SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, name$, 150, 125, &8B3043
     ENDPROC


     
DEF PROCSweepdow
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hSWEEPDOW%
     ENDPROC

     
DEF PROCLaser
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hLASER%
     ENDPROC

     
DEF PROCBombsound
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hBOMB%
     ENDPROC


     
DEF PROCWhoosh
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hWHOOSH%
     ENDPROC

     
DEF PROCPowerupsound
     IF sound%=1 SYS _FSOUND_PlaySound%, _FSOUND_FREE, hPOWERUP%
     ENDPROC

     
DEF PROCQuit
     SYS _FSOUND_Close%
     SYS "RemoveFontResource", @dir$+"data\BLADR.TTF"
     QUIT

     
DEF PROCwait
     SYS GFXLIB_GetBmFontStrWidth, font2%,"Paused - SPACE to continue" TO pausewidth%
     REM SYS _FMUSIC_SetPaused%, handle%, 1
     
PROCpausemusic
     SYS GFXLIB_DrawBmFont1, dispVars{}, font2%, "Paused - SPACE to continue", (640-pausewidth%)/2, 240
     SYS I%, @hwnd%, 0, 0
     REPEAT A=GET UNTIL A=32
     REM SYS _FMUSIC_SetPaused%, handle%, 0
     
PROCresumemusic
     ENDPROC

     
DEF PROCDisplayscore
     IF cheat%=0 score$ = "Score: " + STR$score
     IF cheat%=1 score$ = "Score: " + STR$score + " CHEATING"
     lives$ = "lives: " + STRING$(padlen2%-LENSTR$lives%,"0")+STR$lives%
     SYS GFXLIB_DrawBmFont3, dispVars{}, font1%, score$, 0, 460, &F0F0F0
     SYS GFXLIB_DrawBmFont3, dispVars{}, font1%, lives$, 510, 460, &F0F0F0
     IF Autospeed%=1 Autospeed$="AUTO-ADJUSTING - FPS: " + STR$Fps%
     IF Autospeed%=1 AND Autospeedselected%=1 SYS GFXLIB_DrawBmFont3, dispVars{}, font1%, Autospeed$, 0, 440, &F0F0F0
     ENDPROC

     
DEF PROCPlot
     SYS GFXLIB_PlotPixel, dispVars{}, B%(D%), C%(D%), &FFFFFF
     REM PLOT 70,B%(D%), C%(D%)
     
IF S%(D%)>6 PROCPlotmore REM Plot more detailed stars on faster machines
     
ENDPROC

     
DEF PROCPlotmore
     SYS GFXLIB_PlotPixel, dispVars{}, B%(D%)+2, C%(D%), &FFFFFF
     SYS GFXLIB_PlotPixel, dispVars{}, B%(D%)-2, C%(D%), &FFFFFF
     SYS GFXLIB_PlotPixel, dispVars{}, B%(D%), C%(D%)+2, &FFFFFF
     SYS GFXLIB_PlotPixel, dispVars{}, B%(D%), C%(D%)-2, &FFFFFF
     ENDPROC

     
DEF PROCDebug
     *FONT Arial,12
     REM IF hit<150 hit=151
     
PRINTTAB(0,1)"Delay ";wait%
     PRINTTAB(0,2)"FPS ";Fps%

     PRINTTAB(0,3)"Stars ";starfield%
     PRINTTAB(0,4)"Autoadjust ";Autospeed%



     ENDPROC

     
DEF PROCPlotstars
     REM Update Positions
     
FOR D%=0 TO A%

       C%(D%)=C%(D%)-S%(D%) IF C%(D%)<5 C%(D%)=500 B%(D%)=RND(640) S%(D%)=RND(10)
       REM ENDIF
     
NEXT
     
REM Plot New Star
     
GCOL0,7
     FOR D%=0 TO A%
       PROCPlot
     NEXT
     ENDPROC

     
DEF PROCIntro


     SYS GFXLIB_Clr,dispVars{},&0
     FOR X=0 TO 640 STEP 4
       xpos=(640-X)/2
       ypos=xpos*0.75
       Y=X*0.75
       SYS GFXLIB_BPlotScale,dispVars{}, shooter%,640,480,X,Y,xpos,ypos
       SYS I%, @hwnd%, 0, 0
       WAIT 1
     NEXT

     
points1$ = "With " + STR$score1 + " Points"
     points2$ = "With " + STR$score2 + " Points"
     points3$ = "With " + STR$score3 + " Points"
     display1$="1. "+name1$
     display2$="2. "+name2$
     display3$="3. "+name3$

     TIME=0
     color=&8B3043
     scrollleft1%=2000
     scrollleft2%=1050
     scrollleft3%=1100
     REPEAT
       
REM REPEAT SYS "GetForegroundWindow" TO hw% SYS W%,1 UNTIL hw% = @hwnd%
       
SYS GFXLIB_MMXCopy64, dispVars{}, shooter%, dibSectionAddr%, 19200

       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, "Current Highscores by:", scrollleft1%, 130, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, display1$, scrollleft1%, 100, color
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, points1$, scrollleft1%, 85, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, display2$, scrollleft2%, 65, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, points2$, scrollleft2%, 50, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, display3$, scrollleft3%, 30, &43171F
       SYS GFXLIB_DrawBmFont3, dispVars{}, font2%, points3$, scrollleft3%, 15, &43171F
       SYS I%, @hwnd%, 0, 0 REM Update screen
       
scrollleft1%=scrollleft1%-2 IF scrollleft1%<150 scrollleft1%=150
       IF scrollleft1%<550 scrollleft2%=scrollleft2%-2
       IF scrollleft2%<150 scrollleft2%=150
       IF scrollleft2%<550 scrollleft3%=scrollleft3%-2
       IF scrollleft3%<150 scrollleft3%=150
       IF wait%>0 SYS W%, wait%-1
       REM IF TIME>2500 color=RND(16777215)
       
*REFRESH
       IF TIME>2500 PROCIntro
       IF INKEY(-82) SYS "ShellExecute", @hwnd%, 0, "http://81red.dk/usscores.php", 0, "", 1

     UNTIL INKEY(-99) OR INKEY(-71) OR INKEY (-113) OR INKEY(-35)

     IF INKEY (-113) PROCQuit
     IF INKEY (-71) PROCKeys
     IF INKEY (-35) PROCEditor

     ENDPROC

     
DEF PROCKeys
     SYS GFXLIB_MMXCopy64, dispVars{}, keys%, dibSectionAddr%, 19200
     SYS I%, @hwnd%, 0, 0 REM Update screen
     
REPEAT A=GET UNTIL A=32
     ENDPROC

     
DEF PROCpostweb
     REM post score to Web.
     
ENDPROC
     
REM code removed as to not tempt those that might abuse it and post ridiculous scores to my site :)

     
DEF PROCerror
     ON ERROR OFF
     
error$="Damn, something is out of whack! The error was:"+CHR$13
     error$+=REPORT$+" at line "+STR$(ERL)+CHR$13
     error$+="Please report the above to error@81red.dk so it can be fixed."
     SYS "MessageBox", @hwnd%, error$, 0, 48
     PROCQuit
     ENDPROC


     
DEF PROCSortscore
     IF score>score1 score3=score2 name3$=name2$ score2=score1 name2$=name1$ score1=score name1$=name$ rank$="1st" ENDPROC
     IF
score>score2 score3=score2 name3$=name2$ score2=score name2$=name$ rank$="2nd" ENDPROC
     IF
score>score3 score3=score name3$=name$ rank$="3rd" ENDPROC


     
DEF PROCdrawBg
     LOCAL A%, D%, H%, I%, W%, P%

     D% = dispVars{}

     REM. Draw bg bitmap
     
W% = dispVars.bmBuffW% DIV 2
     H% = dispVars.bmBuffH% DIV 2
     A% = bg.bmAddr% + 4*INT(bg.y#) * W%
     SYS GFXLIB_MMXScale2X, D%, A%, W%, H%, dibs%
     bg.y# += 0.5
     IF bg.y# >= bg.h% - dispVars.bmBuffH%DIV2 THEN
       
bg.y# = 0.0
     ENDIF

     
REM. Draw stars
     
P% = GFXLIB_PlotOpaqueLD
     FOR I%=0 TO numStars%-1
       SYS P%, D%, star{(I%)}.bmAddr%, 12, 12, star{(I%)}.x%, star{(I%)}.y#
       star{(I%)}.y# -= star{(I%)}.dy#
       IF star{(I%)}.y# <= -12 THEN
         
star{(I%)}.x% = RND( dispVars.bmBuffW% )
         star{(I%)}.y# = dispVars.bmBuffH%
       ENDIF
     NEXT
     ENDPROC
     
:
     :
     :
     :
     DEF PROCinitStars
     LOCAL I%
     DIM starBmAddrTbl(15)
     FOR I%=0 TO 15
       PROCLoadBMP( @dir$ + "data\star_12x12_8bpp.BMP", starBmAddrTbl(I%), 0 )
       SYS GFXLIB_SetDispVars, dispVars{}, starBmAddrTbl(I%), 12, 12, 0, 0,12,12,TRUE

       SYS
GFXLIB_PlotScaleFade, dispVars{}, starBmAddrTbl(I%), 12, 12, 12,12, 0, 0, 25 + ((255-25) * I%/15)

     NEXT I%
     SYS GFXLIB_QuickSetDispVars, dispVars{}, dibs%
     numStars% = 60
     DIM star{( numStars%-1 ) bmAddr%, x%, y#, dy#}
     FOR I%=0 TO numStars%-1
       star{(I%)}.x% = RND( dispVars.bmBuffW% )
       star{(I%)}.y# = RND( dispVars.bmBuffH% )
       star{(I%)}.dy# = 1.0 + 4.0*RND(1)
       star{(I%)}.bmAddr% = starBmAddrTbl( 16 * star{(I%)}.dy#/5 )
     NEXT I%
     ENDPROC
     
:
     :
     :
     :
     DEF PROCcreateBg
     LOCAL C%, D%, G%, H%, I%, J%, P%, R%, S%, X%, Y%
     LOCAL scrW%, scrH%, blob%

     scrW% = dispVars.bmBuffW%
     scrH% = dispVars.bmBuffH%

     DIM bg{ w%, h%, memSize%, bmAddr%, y# }

     bg.y# = 0.0

     PROCLoadBMP( @dir$ + "data\blob_64x64_8bpp.BMP", blob%, 0 )

     D% = dispVars{}
     G% = GFXLIB_PlotColourBlendOpaque
     H% = GFXLIB_PlotScaleColourBlend

     bg.w% = dispVars.bmBuffW% DIV 2
     bg.h% = 16 * (dispVars.bmBuffH% DIV 2)
     bg.memSize% = 4 * bg.w% * bg.h%
     bg.bmAddr% = FNmalloc( bg.memSize% )

     dispVars.bmBuffAddr% = bg.bmAddr%
     dispVars.bmBuffW% = bg.w%
     dispVars.bmBuffH% = bg.h%

     REM. Ensure same background pattern each time
     
R% = RND(-TIME)

     REM. PlotColourBlendOpaque (dispVars, bmAddr, bmW, bmH, bmX, bmY, colour, strength, opacity)

     
FOR I%=1 TO 100
       X% = RND( bg.w% ) - 32
       Y% = 3/2*scrH%DIV2 + RND( bg.h% - 3/2*scrH% )
       FOR J%=1 TO 10 + RND(40)
         C% = FNrgb( RND(30), 155+RND(100), 230+RND(25) )
         SYS G%, D%, blob%, 64, 64, X%, Y%, C%, 255, 32+RND(223)
         X% += RND(32) * (RND(3) - 2)
         Y% += RND(32) * (RND(3) - 2)
       NEXT
     NEXT

     
REM. Blur background
     
FOR I%=1 TO 3
       SYS GFXLIB_BoxBlurNxNR, bg.bmAddr%, bg.w%, bg.h%, 17
     NEXT

     
REM. PlotScaleColourBlend (dispVars, bmAddr, bmW, bmH, newBmW, newBmH, xPos, yPos, colour, strength)

     REM. Draw random white-ish blobs
     
FOR I%=1 TO 1000
       X% = RND( bg.w% )
       Y% = RND( bg.h% )
       P% = bg.bmAddr%!(4*X% + 4*Y%*bg.w%)
       S% = RND(20)
       IF P%<>0 THEN
         SYS
H%, D%, blob%, 64, 64, S%, S%, X%, Y%, FNrgb(200+RND(56), 200+RND(56), 200+RND(56)), 255
       ENDIF
     NEXT

     
REM. Do some more blurring...
     
FOR I%=1 TO 2
       SYS GFXLIB_BoxBlurNxNR, bg.bmAddr%, bg.w%, bg.h%, 17
     NEXT

     
REM. Darken background
     
SYS GFXLIB_MMXSubtract64, dispVars{}, bg.bmAddr%, 4*(bg.w% * bg.h% DIV 64), 150

     REM. Restore the dispVars struct
     
SYS GFXLIB_QuickSetDispVars, dispVars{}, dibs%
     ENDPROC



     
DEF PROCEditor
     MODE 18
     DIM xbuffer%(10000), ybuffer%(10000), rbuffer%(10000), radianbuffer(10000)
     OFF
     
RANDOM%=RND(-TIME)
     PROCLoad_24bppBM_as_32bppBM( @dir$+"data\alien"+STR$(RND (300)+100)+".bmp", editorsprite%, FALSE )
     REM PROCLoad_24bppBM_as_32bppBM( @dir$+"data\nightsky.bmp", nightsky%, FALSE )
     
r=0
     r%=0
     REM ORIGIN 640,512
     
MOUSE ON 3
     step%=0.1
     pressed%=0
     enter%=0
     coord%=0
     x%=0
     y%=0
     REPEAT
       SYS
GFXLIB_MMXCopy64, dispVars{}, nightsky%, dibSectionAddr%, 19200
       MOUSE x%, y%, b%
       PRINTTAB(0,0)"X,Y ";x%/2;" ";y%/2;" Step: ";step%/2
       PRINTTAB(0,1)"Points plotted: ";coord%;" Radian: ";r;" Degrees: ";r%;
       GCOL b%
       IF b% xbuffer%(coord%)=x%/2 ybuffer%(coord%)=y%/2 rbuffer%(coord%)=r% radianbuffer(coord%)=r pressed%=1 coord%=coord%+1 WAIT 10 ELSE MOVE x%,y%
       IF b%=FALSE pressed%=0
       WAIT 0

       IF INKEY (-59) step%=step%+2 WAIT 10
       IF INKEY (-60) step%=step%-2 WAIT 10
       IF step%<2 step%=2

       IF INKEY(-51) r=RAD(90)
       IF INKEY(-34) r=RAD(0)
       IF INKEY(-66) r=RAD(270)
       IF INKEY(-82) r=RAD(180)

       IF INKEY(-52) PROCReplay

       IF INKEY(-92) coord%=coord%+1 xbuffer%(coord%)=x%/2 ybuffer%(coord%)=y%/2 rbuffer%(coord%)=r% radianbuffer(coord%)=r WAIT 10
       IF INKEY(-123) x%=x%-step% MOUSE TO x%,y% WAIT 10
       IF INKEY(-27) x%=x%+step% MOUSE TO x%,y% WAIT 10

       IF INKEY(-125) y%=y%-step% MOUSE TO x%,y% WAIT 10
       IF INKEY(-43) y%=y%+step% MOUSE TO x%,y% WAIT 10

       IF INKEY(-48) PROCStepback WAIT 10

       REM IF INKEY(-122) AND NOT INKEY(-1) x%=x%+2 MOUSE TO x%,y% WAIT 10
       
IF INKEY(-122) r=r+0.017 WAIT 10

       REM IF INKEY(-26) AND NOT INKEY(-1) x%=x%-2 MOUSE TO x%,y% WAIT 10
       
IF INKEY(-26) r=r-0.017 WAIT 10

       REM IF INKEY(-42) AND NOT INKEY(-1) y%=y%-2 MOUSE TO x%,y% WAIT 10
       
IF INKEY(-42) step%=step%-2 WAIT 10

       REM IF INKEY(-58) AND NOT INKEY(-1) y%=y%+2 MOUSE TO x%,y% WAIT 10
       
IF INKEY(-58) step%=step%+2 WAIT 10
       IF r>6.295 r=0
       IF r<0 r=6.295
       r%=DEG(r)
       IF INKEY(-74) coord%=coord%+1 x%=x%+step%*SIN(r) y%=y%+step%*COS(r) xbuffer%(coord%)=x%/2 ybuffer%(coord%)=y%/2 rbuffer%(coord%)=r% radianbuffer(coord%)=r  MOUSE TO x%,y% enter%=1 WAIT 10
       IF NOT INKEY (-74) enter%=0

       SYS GFXLIB_PlotRotateSetACBit, dispVars{}, editorsprite%, 56, 56, x%/2, y%/2, r%, 5
       SYS I%, @hwnd%, 0, 0
       REPEAT UNTIL INKEY(0)=-1
       WAIT 1
     UNTIL INKEY(-99)
     IF coord%=0 MOUSE OFF ENDPROC
     
F=OPENOUT (@dir$+"data\pattern999.dat")
     FOR X=1 TO coord%
       PRINT#F,xbuffer%(X),ybuffer%(X),rbuffer%(X)
     NEXT
     CLOSE
#F
     MOUSE OFF
     ENDPROC

     
DEF PROCStepback
     x%=xbuffer%(coord%)*2
     y%=ybuffer%(coord%)*2
     r=radianbuffer(coord%)
     MOUSE TO x%,y%
     IF coord%=1 ENDPROC
     
coord%=coord%-1
     ENDPROC

     
DEF PROCReplay
     rx%=0
     ry%=0
     rr%=0
     FOR X=1 TO coord%
       rx%=xbuffer%(X)
       ry%=ybuffer%(X)
       rr%=rbuffer%(X)
       SYS GFXLIB_PlotRotateSetACBit, dispVars{}, editorsprite%, 56, 56, rx%, ry%, rr%, 5
       SYS I%, @hwnd%, 0, 0
       WAIT 10
     NEXT
     ENDPROC

     
DEF PROCIdiot
     idiot$="Hmmm.. It seems that the files required to run this game are missing."+CHR$13
     idiot$+="Please make sure you are not trying to run this directly from within a zipped file, without EXTRACTING THE CONTENTS first."+CHR$13
     SYS "MessageBox", @hwnd%, idiot$, 0, 16
     *QUIT
     ENDPROC

     
DEF PROCpausemusic
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     SYS
"mciSendCommand", DeviceID%, MCI_PAUSE, MCI_WAIT, 0
     ENDPROC

     
DEF PROCresumemusic
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     SYS
"mciSendCommand", DeviceID%, MCI_RESUME, MCI_WAIT, 0
     ENDPROC


     
DEF PROCopen( file$ )
     PRIVATE A%
     LOCAL F%, R%

     IF A% = 0 THEN
       
DeviceID% = 0
       DIM Ofn% 75, FileName% 255
       DIM mciOpenParms% 19, mciPlayParms% 11, mciSetParms% 11, mciStatusParms% 15, mciSeekParms% 7
       A% = 1
     ENDIF

     
$$FileName% = file$

     filter$ = "Media files"+CHR$0+"*.MP3;*.WMA;*.MID;*.MIDI;*.RMI;*.WAV;*.AVI;*.MPG;*.MP2;*.WMV;*.MOV;*.MPEG"+CHR$0+"All files"+CHR$0+"*.*"+CHR$0+CHR$0

     !Ofn% = 76
     Ofn%!4 = @hwnd%
     Ofn%!12 = !^filter$
     Ofn%!28 = FileName%
     Ofn%!32 = 256
     Ofn%!52 = 6

     mciOpenParms%!4 = 0
     mciOpenParms%!8 = MCI_ALL_DEVICE_ID
     mciOpenParms%!12 = FileName%
     SYS "mciSendCommand", 0, MCI_OPEN, MCI_OPEN_ELEMENT, mciOpenParms% TO R%

     IF R% THEN ERROR 100, "Can't find suitable codec"

     DeviceID% = mciOpenParms%!4
     SYS "mciSendCommand", DeviceID%, MCI_SET, MCI_SET_TIME_FORMAT, mciSetParms%
     ENDPROC
     
:
     :
     :
     :
     DEF PROCplay(mciPlayParms%!4)
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     SYS
"mciSendCommand", DeviceID%, MCI_PLAY, MCI_FROM, mciPlayParms%
     ENDPROC
     
:
     :
     :
     :
     DEF PROCseek(mciSeekParms%!4)
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     SYS
"mciSendCommand", DeviceID%, MCI_SEEK, MCI_TO, mciSeekParms%
     ENDPROC
     
:
     :
     :
     :
     DEF PROCstop
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     SYS
"mciSendCommand", DeviceID%, MCI_STOP, MCI_WAIT, 0
     ENDPROC
     
:
     :
     :
     :
     DEF PROCclose
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     SYS
"mciSendCommand", DeviceID%, MCI_CLOSE, MCI_WAIT, 0
     DeviceID% = 0
     ENDPROC
     
:
     :
     :
     :
     DEF PROCcleanup
     DeviceID% += 0
     IF DeviceID%=0 THEN ENDPROC
     PROC
stop
     PROCclose
     ENDPROC


     
DEF PROCfmod
     REM FMOD.DLL Header File 25-May-2007
     REM BBC BASIC Translation (C) Jon Ripley

     
SYS "GetModuleHandle", "kernel32.dll" TO _hdll%
     SYS "GetProcAddress", _hdll%, "GetProcAddress" TO _%
     SYS "LoadLibrary", "data\fmod.dll" TO _hdll%
     IF _hdll%=0 THEN PRINT "Warning: A required DLL 'fmod.dll' could not be found."
     SYS _%, _hdll%, "_FMUSIC_FreeSong@4" TO _FMUSIC_FreeSong%
     SYS _%, _hdll%, "_FMUSIC_GetBPM@4" TO _FMUSIC_GetBPM%
     SYS _%, _hdll%, "_FMUSIC_GetGlobalVolume@4" TO _FMUSIC_GetGlobalVolume%
     SYS _%, _hdll%, "_FMUSIC_GetMasterVolume@4" TO _FMUSIC_GetMasterVolume%
     SYS _%, _hdll%, "_FMUSIC_GetName@4" TO _FMUSIC_GetName%
     SYS _%, _hdll%, "_FMUSIC_GetNumChannels@4" TO _FMUSIC_GetNumChannels%
     SYS _%, _hdll%, "_FMUSIC_GetNumInstruments@4" TO _FMUSIC_GetNumInstruments%
     SYS _%, _hdll%, "_FMUSIC_GetNumOrders@4" TO _FMUSIC_GetNumOrders%
     SYS _%, _hdll%, "_FMUSIC_GetNumPatterns@4" TO _FMUSIC_GetNumPatterns%
     SYS _%, _hdll%, "_FMUSIC_GetNumSamples@4" TO _FMUSIC_GetNumSamples%
     SYS _%, _hdll%, "_FMUSIC_GetOpenState@4" TO _FMUSIC_GetOpenState%
     SYS _%, _hdll%, "_FMUSIC_GetOrder@4" TO _FMUSIC_GetOrder%
     SYS _%, _hdll%, "_FMUSIC_GetPattern@4" TO _FMUSIC_GetPattern%
     SYS _%, _hdll%, "_FMUSIC_GetPatternLength@8" TO _FMUSIC_GetPatternLength%
     SYS _%, _hdll%, "_FMUSIC_GetPaused@4" TO _FMUSIC_GetPaused%
     SYS _%, _hdll%, "_FMUSIC_GetRealChannel@8" TO _FMUSIC_GetRealChannel%
     SYS _%, _hdll%, "_FMUSIC_GetRow@4" TO _FMUSIC_GetRow%
     SYS _%, _hdll%, "_FMUSIC_GetSample@8" TO _FMUSIC_GetSample%
     SYS _%, _hdll%, "_FMUSIC_GetSpeed@4" TO _FMUSIC_GetSpeed%
     SYS _%, _hdll%, "_FMUSIC_GetTime@4" TO _FMUSIC_GetTime%
     SYS _%, _hdll%, "_FMUSIC_GetType@4" TO _FMUSIC_GetType%
     SYS _%, _hdll%, "_FMUSIC_GetUserData@4" TO _FMUSIC_GetUserData%
     SYS _%, _hdll%, "_FMUSIC_IsFinished@4" TO _FMUSIC_IsFinished%
     SYS _%, _hdll%, "_FMUSIC_IsPlaying@4" TO _FMUSIC_IsPlaying%
     SYS _%, _hdll%, "_FMUSIC_LoadSong@4" TO _FMUSIC_LoadSong%
     SYS _%, _hdll%, "_FMUSIC_LoadSongEx@24" TO _FMUSIC_LoadSongEx%
     SYS _%, _hdll%, "_FMUSIC_OptimizeChannels@12" TO _FMUSIC_OptimizeChannels%
     SYS _%, _hdll%, "_FMUSIC_PlaySong@4" TO _FMUSIC_PlaySong%
     SYS _%, _hdll%, "_FMUSIC_SetInstCallback@12" TO _FMUSIC_SetInstCallback%
     SYS _%, _hdll%, "_FMUSIC_SetLooping@8" TO _FMUSIC_SetLooping%
     SYS _%, _hdll%, "_FMUSIC_SetMasterSpeed@8" TO _FMUSIC_SetMasterSpeed%
     SYS _%, _hdll%, "_FMUSIC_SetMasterVolume@8" TO _FMUSIC_SetMasterVolume%
     SYS _%, _hdll%, "_FMUSIC_SetOrder@8" TO _FMUSIC_SetOrder%
     SYS _%, _hdll%, "_FMUSIC_SetOrderCallback@12" TO _FMUSIC_SetOrderCallback%
     SYS _%, _hdll%, "_FMUSIC_SetPanSeperation@8" TO _FMUSIC_SetPanSeperation%
     SYS _%, _hdll%, "_FMUSIC_SetPaused@8" TO _FMUSIC_SetPaused%
     SYS _%, _hdll%, "_FMUSIC_SetReverb@4" TO _FMUSIC_SetReverb%
     SYS _%, _hdll%, "_FMUSIC_SetRowCallback@12" TO _FMUSIC_SetRowCallback%
     SYS _%, _hdll%, "_FMUSIC_SetSample@12" TO _FMUSIC_SetSample%
     SYS _%, _hdll%, "_FMUSIC_SetUserData@8" TO _FMUSIC_SetUserData%
     SYS _%, _hdll%, "_FMUSIC_SetZxxCallback@8" TO _FMUSIC_SetZxxCallback%
     SYS _%, _hdll%, "_FMUSIC_StopAllSongs@0" TO _FMUSIC_StopAllSongs%
     SYS _%, _hdll%, "_FMUSIC_StopSong@4" TO _FMUSIC_StopSong%
     SYS _%, _hdll%, "_FSOUND_3D_GetAttributes@12" TO _FSOUND_3D_GetAttributes%
     SYS _%, _hdll%, "_FSOUND_3D_GetMinMaxDistance@12" TO _FSOUND_3D_GetMinMaxDistance%
     SYS _%, _hdll%, "_FSOUND_3D_Listener_GetAttributes@32" TO _FSOUND_3D_Listener_GetAttributes%
     SYS _%, _hdll%, "_FSOUND_3D_Listener_SetAttributes@32" TO _FSOUND_3D_Listener_SetAttributes%
     SYS _%, _hdll%, "_FSOUND_3D_Listener_SetCurrent@8" TO _FSOUND_3D_Listener_SetCurrent%
     SYS _%, _hdll%, "_FSOUND_3D_SetAttributes@12" TO _FSOUND_3D_SetAttributes%
     SYS _%, _hdll%, "_FSOUND_3D_SetDistanceFactor@4" TO _FSOUND_3D_SetDistanceFactor%
     SYS _%, _hdll%, "_FSOUND_3D_SetDopplerFactor@4" TO _FSOUND_3D_SetDopplerFactor%
     SYS _%, _hdll%, "_FSOUND_3D_SetMinMaxDistance@12" TO _FSOUND_3D_SetMinMaxDistance%
     SYS _%, _hdll%, "_FSOUND_3D_SetRolloffFactor@4" TO _FSOUND_3D_SetRolloffFactor%
     SYS _%, _hdll%, "_FSOUND_CD_Eject@4" TO _FSOUND_CD_Eject%
     SYS _%, _hdll%, "_FSOUND_CD_GetNumTracks@4" TO _FSOUND_CD_GetNumTracks%
     SYS _%, _hdll%, "_FSOUND_CD_GetPaused@4" TO _FSOUND_CD_GetPaused%
     SYS _%, _hdll%, "_FSOUND_CD_GetTrack@4" TO _FSOUND_CD_GetTrack%
     SYS _%, _hdll%, "_FSOUND_CD_GetTrackLength@8" TO _FSOUND_CD_GetTrackLength%
     SYS _%, _hdll%, "_FSOUND_CD_GetTrackTime@4" TO _FSOUND_CD_GetTrackTime%
     SYS _%, _hdll%, "_FSOUND_CD_GetVolume@4" TO _FSOUND_CD_GetVolume%
     SYS _%, _hdll%, "_FSOUND_CD_OpenTray@8" TO _FSOUND_CD_OpenTray%
     SYS _%, _hdll%, "_FSOUND_CD_Play@8" TO _FSOUND_CD_Play%
     SYS _%, _hdll%, "_FSOUND_CD_SetPaused@8" TO _FSOUND_CD_SetPaused%
     SYS _%, _hdll%, "_FSOUND_CD_SetPlayMode@8" TO _FSOUND_CD_SetPlayMode%
     SYS _%, _hdll%, "_FSOUND_CD_SetTrackTime@8" TO _FSOUND_CD_SetTrackTime%
     SYS _%, _hdll%, "_FSOUND_CD_SetVolume@8" TO _FSOUND_CD_SetVolume%
     SYS _%, _hdll%, "_FSOUND_CD_Stop@4" TO _FSOUND_CD_Stop%
     SYS _%, _hdll%, "_FSOUND_Close@0" TO _FSOUND_Close%
     SYS _%, _hdll%, "_FSOUND_DSP_ClearMixBuffer@0" TO _FSOUND_DSP_ClearMixBuffer%
     SYS _%, _hdll%, "_FSOUND_DSP_Create@12" TO _FSOUND_DSP_Create%
     SYS _%, _hdll%, "_FSOUND_DSP_Free@4" TO _FSOUND_DSP_Free%
     SYS _%, _hdll%, "_FSOUND_DSP_GetActive@4" TO _FSOUND_DSP_GetActive%
     SYS _%, _hdll%, "_FSOUND_DSP_GetBufferLength@0" TO _FSOUND_DSP_GetBufferLength%
     SYS _%, _hdll%, "_FSOUND_DSP_GetBufferLengthTotal@0" TO _FSOUND_DSP_GetBufferLengthTotal%
     SYS _%, _hdll%, "_FSOUND_DSP_GetClearUnit@0" TO _FSOUND_DSP_GetClearUnit%
     SYS _%, _hdll%, "_FSOUND_DSP_GetClipAndCopyUnit@0" TO _FSOUND_DSP_GetClipAndCopyUnit%
     SYS _%, _hdll%, "_FSOUND_DSP_GetFFTUnit@0" TO _FSOUND_DSP_GetFFTUnit%
     SYS _%, _hdll%, "_FSOUND_DSP_GetMusicUnit@0" TO _FSOUND_DSP_GetMusicUnit%
     SYS _%, _hdll%, "_FSOUND_DSP_GetPriority@4" TO _FSOUND_DSP_GetPriority%
     SYS _%, _hdll%, "_FSOUND_DSP_GetSFXUnit@0" TO _FSOUND_DSP_GetSFXUnit%
     SYS _%, _hdll%, "_FSOUND_DSP_GetSpectrum@0" TO _FSOUND_DSP_GetSpectrum%
     SYS _%, _hdll%, "_FSOUND_DSP_MixBuffers@28" TO _FSOUND_DSP_MixBuffers%
     SYS _%, _hdll%, "_FSOUND_DSP_SetActive@8" TO _FSOUND_DSP_SetActive%
     SYS _%, _hdll%, "_FSOUND_DSP_SetPriority@8" TO _FSOUND_DSP_SetPriority%
     SYS _%, _hdll%, "_FSOUND_File_SetCallbacks@20" TO _FSOUND_File_SetCallbacks%
     SYS _%, _hdll%, "_FSOUND_FX_Disable@4" TO _FSOUND_FX_Disable%
     SYS _%, _hdll%, "_FSOUND_FX_Enable@8" TO _FSOUND_FX_Enable%
     SYS _%, _hdll%, "_FSOUND_FX_SetChorus@32" TO _FSOUND_FX_SetChorus%
     SYS _%, _hdll%, "_FSOUND_FX_SetCompressor@28" TO _FSOUND_FX_SetCompressor%
     SYS _%, _hdll%, "_FSOUND_FX_SetDistortion@24" TO _FSOUND_FX_SetDistortion%
     SYS _%, _hdll%, "_FSOUND_FX_SetEcho@24" TO _FSOUND_FX_SetEcho%
     SYS _%, _hdll%, "_FSOUND_FX_SetFlanger@32" TO _FSOUND_FX_SetFlanger%
     SYS _%, _hdll%, "_FSOUND_FX_SetGargle@12" TO _FSOUND_FX_SetGargle%
     SYS _%, _hdll%, "_FSOUND_FX_SetI3DL2Reverb@52" TO _FSOUND_FX_SetI3DL2Reverb%
     SYS _%, _hdll%, "_FSOUND_FX_SetParamEQ@16" TO _FSOUND_FX_SetParamEQ%
     SYS _%, _hdll%, "_FSOUND_FX_SetWavesReverb@20" TO _FSOUND_FX_SetWavesReverb%
     SYS _%, _hdll%, "_FSOUND_GetAmplitude@4" TO _FSOUND_GetAmplitude%
     SYS _%, _hdll%, "_FSOUND_GetChannelsPlaying@0" TO _FSOUND_GetChannelsPlaying%
     SYS _%, _hdll%, "_FSOUND_GetCPUUsage@0" TO _FSOUND_GetCPUUsage%
     SYS _%, _hdll%, "_FSOUND_GetCurrentLevels@12" TO _FSOUND_GetCurrentLevels%
     SYS _%, _hdll%, "_FSOUND_GetCurrentPosition@4" TO _FSOUND_GetCurrentPosition%
     SYS _%, _hdll%, "_FSOUND_GetCurrentSample@4" TO _FSOUND_GetCurrentSample%
     SYS _%, _hdll%, "_FSOUND_GetDriver@0" TO _FSOUND_GetDriver%
     SYS _%, _hdll%, "_FSOUND_GetDriverCaps@8" TO _FSOUND_GetDriverCaps%
     SYS _%, _hdll%, "_FSOUND_GetDriverName@4" TO _FSOUND_GetDriverName%
     SYS _%, _hdll%, "_FSOUND_GetError@0" TO _FSOUND_GetError%
     SYS _%, _hdll%, "_FSOUND_GetFrequency@4" TO _FSOUND_GetFrequency%
     SYS _%, _hdll%, "_FSOUND_GetLoopMode@4" TO _FSOUND_GetLoopMode%
     SYS _%, _hdll%, "_FSOUND_GetMaxChannels@0" TO _FSOUND_GetMaxChannels%
     SYS _%, _hdll%, "_FSOUND_GetMaxSamples@0" TO _FSOUND_GetMaxSamples%
     SYS _%, _hdll%, "_FSOUND_GetMemoryStats@8" TO _FSOUND_GetMemoryStats%
     SYS _%, _hdll%, "_FSOUND_GetMixer@0" TO _FSOUND_GetMixer%
     SYS _%, _hdll%, "_FSOUND_GetMute@4" TO _FSOUND_GetMute%
     SYS _%, _hdll%, "_FSOUND_GetNumDrivers@0" TO _FSOUND_GetNumDrivers%
     SYS _%, _hdll%, "_FSOUND_GetNumHardwareChannels@0" TO _FSOUND_GetNumHardwareChannels%
     SYS _%, _hdll%, "_FSOUND_GetNumHWChannels@12" TO _FSOUND_GetNumHWChannels%
     SYS _%, _hdll%, "_FSOUND_GetNumSubChannels@4" TO _FSOUND_GetNumSubChannels%
     SYS _%, _hdll%, "_FSOUND_GetOutput@0" TO _FSOUND_GetOutput%
     SYS _%, _hdll%, "_FSOUND_GetOutputHandle@0" TO _FSOUND_GetOutputHandle%
     SYS _%, _hdll%, "_FSOUND_GetOutputRate@0" TO _FSOUND_GetOutputRate%
     SYS _%, _hdll%, "_FSOUND_GetPan@4" TO _FSOUND_GetPan%
     SYS _%, _hdll%, "_FSOUND_GetPaused@4" TO _FSOUND_GetPaused%
     SYS _%, _hdll%, "_FSOUND_GetPriority@4" TO _FSOUND_GetPriority%
     SYS _%, _hdll%, "_FSOUND_GetReserved@4" TO _FSOUND_GetReserved%
     SYS _%, _hdll%, "_FSOUND_GetSFXMasterVolume@0" TO _FSOUND_GetSFXMasterVolume%
     SYS _%, _hdll%, "_FSOUND_GetSubChannel@8" TO _FSOUND_GetSubChannel%
     SYS _%, _hdll%, "_FSOUND_GetSurround@4" TO _FSOUND_GetSurround%
     SYS _%, _hdll%, "_FSOUND_GetVersion@0" TO _FSOUND_GetVersion%
     SYS _%, _hdll%, "_FSOUND_GetVolume@4" TO _FSOUND_GetVolume%
     SYS _%, _hdll%, "_FSOUND_Init@12" TO _FSOUND_Init%
     SYS _%, _hdll%, "_FSOUND_IsPlaying@4" TO _FSOUND_IsPlaying%
     SYS _%, _hdll%, "_FSOUND_PlaySound@8" TO _FSOUND_PlaySound%
     SYS _%, _hdll%, "_FSOUND_PlaySoundEx@16" TO _FSOUND_PlaySoundEx%
     SYS _%, _hdll%, "_FSOUND_Record_GetDriver@0" TO _FSOUND_Record_GetDriver%
     SYS _%, _hdll%, "_FSOUND_Record_GetDriverName@4" TO _FSOUND_Record_GetDriverName%
     SYS _%, _hdll%, "_FSOUND_Record_GetNumDrivers@0" TO _FSOUND_Record_GetNumDrivers%
     SYS _%, _hdll%, "_FSOUND_Record_GetPosition@0" TO _FSOUND_Record_GetPosition%
     SYS _%, _hdll%, "_FSOUND_Record_SetDriver@4" TO _FSOUND_Record_SetDriver%
     SYS _%, _hdll%, "_FSOUND_Record_StartSample@8" TO _FSOUND_Record_StartSample%
     SYS _%, _hdll%, "_FSOUND_Record_Stop@0" TO _FSOUND_Record_Stop%
     SYS _%, _hdll%, "_FSOUND_Reverb_GetChannelProperties@8" TO _FSOUND_Reverb_GetChannelProperties%
     SYS _%, _hdll%, "_FSOUND_Reverb_GetProperties@4" TO _FSOUND_Reverb_GetProperties%
     SYS _%, _hdll%, "_FSOUND_Reverb_SetChannelProperties@8" TO _FSOUND_Reverb_SetChannelProperties%
     SYS _%, _hdll%, "_FSOUND_Reverb_SetProperties@4" TO _FSOUND_Reverb_SetProperties%
     SYS _%, _hdll%, "_FSOUND_Sample_Alloc@28" TO _FSOUND_Sample_Alloc%
     SYS _%, _hdll%, "_FSOUND_Sample_Free@4" TO _FSOUND_Sample_Free%
     SYS _%, _hdll%, "_FSOUND_Sample_Get@4" TO _FSOUND_Sample_Get%
     SYS _%, _hdll%, "_FSOUND_Sample_GetDefaults@20" TO _FSOUND_Sample_GetDefaults%
     SYS _%, _hdll%, "_FSOUND_Sample_GetDefaultsEx@32" TO _FSOUND_Sample_GetDefaultsEx%
     SYS _%, _hdll%, "_FSOUND_Sample_GetLength@4" TO _FSOUND_Sample_GetLength%
     SYS _%, _hdll%, "_FSOUND_Sample_GetLoopPoints@12" TO _FSOUND_Sample_GetLoopPoints%
     SYS _%, _hdll%, "_FSOUND_Sample_GetMinMaxDistance@12" TO _FSOUND_Sample_GetMinMaxDistance%
     SYS _%, _hdll%, "_FSOUND_Sample_GetMode@4" TO _FSOUND_Sample_GetMode%
     SYS _%, _hdll%, "_FSOUND_Sample_GetName@4" TO _FSOUND_Sample_GetName%
     SYS _%, _hdll%, "_FSOUND_Sample_Load@20" TO _FSOUND_Sample_Load%
     SYS _%, _hdll%, "_FSOUND_Sample_Lock@28" TO _FSOUND_Sample_Lock%
     SYS _%, _hdll%, "_FSOUND_Sample_SetDefaults@20" TO _FSOUND_Sample_SetDefaults%
     SYS _%, _hdll%, "_FSOUND_Sample_SetDefaultsEx@32" TO _FSOUND_Sample_SetDefaultsEx%
     SYS _%, _hdll%, "_FSOUND_Sample_SetLoopPoints@12" TO _FSOUND_Sample_SetLoopPoints%
     SYS _%, _hdll%, "_FSOUND_Sample_SetMaxPlaybacks@8" TO _FSOUND_Sample_SetMaxPlaybacks%
     SYS _%, _hdll%, "_FSOUND_Sample_SetMinMaxDistance@12" TO _FSOUND_Sample_SetMinMaxDistance%
     SYS _%, _hdll%, "_FSOUND_Sample_SetMode@8" TO _FSOUND_Sample_SetMode%
     SYS _%, _hdll%, "_FSOUND_Sample_Unlock@20" TO _FSOUND_Sample_Unlock%
     SYS _%, _hdll%, "_FSOUND_Sample_Upload@12" TO _FSOUND_Sample_Upload%
     SYS _%, _hdll%, "_FSOUND_SetBufferSize@4" TO _FSOUND_SetBufferSize%
     SYS _%, _hdll%, "_FSOUND_SetCurrentPosition@8" TO _FSOUND_SetCurrentPosition%
     SYS _%, _hdll%, "_FSOUND_SetDriver@4" TO _FSOUND_SetDriver%
     SYS _%, _hdll%, "_FSOUND_SetFrequency@8" TO _FSOUND_SetFrequency%
     SYS _%, _hdll%, "_FSOUND_SetFrequencyEx@8" TO _FSOUND_SetFrequencyEx%
     SYS _%, _hdll%, "_FSOUND_SetHWND@4" TO _FSOUND_SetHWND%
     SYS _%, _hdll%, "_FSOUND_SetLoopMode@8" TO _FSOUND_SetLoopMode%
     SYS _%, _hdll%, "_FSOUND_SetMaxHardwareChannels@4" TO _FSOUND_SetMaxHardwareChannels%
     SYS _%, _hdll%, "_FSOUND_SetMemorySystem@20" TO _FSOUND_SetMemorySystem%
     SYS _%, _hdll%, "_FSOUND_SetMinHardwareChannels@4" TO _FSOUND_SetMinHardwareChannels%
     SYS _%, _hdll%, "_FSOUND_SetMixer@4" TO _FSOUND_SetMixer%
     SYS _%, _hdll%, "_FSOUND_SetMute@8" TO _FSOUND_SetMute%
     SYS _%, _hdll%, "_FSOUND_SetOutput@4" TO _FSOUND_SetOutput%
     SYS _%, _hdll%, "_FSOUND_SetPan@8" TO _FSOUND_SetPan%
     SYS _%, _hdll%, "_FSOUND_SetPanSeperation@4" TO _FSOUND_SetPanSeperation%
     SYS _%, _hdll%, "_FSOUND_SetPaused@8" TO _FSOUND_SetPaused%
     SYS _%, _hdll%, "_FSOUND_SetPriority@8" TO _FSOUND_SetPriority%
     SYS _%, _hdll%, "_FSOUND_SetReserved@8" TO _FSOUND_SetReserved%
     SYS _%, _hdll%, "_FSOUND_SetSFXMasterVolume@4" TO _FSOUND_SetSFXMasterVolume%
     SYS _%, _hdll%, "_FSOUND_SetSpeakerMode@4" TO _FSOUND_SetSpeakerMode%
     SYS _%, _hdll%, "_FSOUND_SetSurround@8" TO _FSOUND_SetSurround%
     SYS _%, _hdll%, "_FSOUND_SetVolume@8" TO _FSOUND_SetVolume%
     SYS _%, _hdll%, "_FSOUND_SetVolumeAbsolute@8" TO _FSOUND_SetVolumeAbsolute%
     SYS _%, _hdll%, "_FSOUND_StopSound@4" TO _FSOUND_StopSound%
     SYS _%, _hdll%, "_FSOUND_Stream_AddSyncPoint@12" TO _FSOUND_Stream_AddSyncPoint%
     SYS _%, _hdll%, "_FSOUND_Stream_Close@4" TO _FSOUND_Stream_Close%
     SYS _%, _hdll%, "_FSOUND_Stream_Create@20" TO _FSOUND_Stream_Create%
     SYS _%, _hdll%, "_FSOUND_Stream_CreateDSP@16" TO _FSOUND_Stream_CreateDSP%
     SYS _%, _hdll%, "_FSOUND_Stream_DeleteSyncPoint@4" TO _FSOUND_Stream_DeleteSyncPoint%
     SYS _%, _hdll%, "_FSOUND_Stream_FindTagField@20" TO _FSOUND_Stream_FindTagField%
     SYS _%, _hdll%, "_FSOUND_Stream_GetLength@4" TO _FSOUND_Stream_GetLength%
     SYS _%, _hdll%, "_FSOUND_Stream_GetLengthMs@4" TO _FSOUND_Stream_GetLengthMs%
     SYS _%, _hdll%, "_FSOUND_Stream_GetMode@4" TO _FSOUND_Stream_GetMode%
     SYS _%, _hdll%, "_FSOUND_Stream_GetNumSubStreams@4" TO _FSOUND_Stream_GetNumSubStreams%
     SYS _%, _hdll%, "_FSOUND_Stream_GetNumSyncPoints@4" TO _FSOUND_Stream_GetNumSyncPoints%
     SYS _%, _hdll%, "_FSOUND_Stream_GetNumTagFields@8" TO _FSOUND_Stream_GetNumTagFields%
     SYS _%, _hdll%, "_FSOUND_Stream_GetOpenState@4" TO _FSOUND_Stream_GetOpenState%
     SYS _%, _hdll%, "_FSOUND_Stream_GetPosition@4" TO _FSOUND_Stream_GetPosition%
     SYS _%, _hdll%, "_FSOUND_Stream_GetSample@4" TO _FSOUND_Stream_GetSample%
     SYS _%, _hdll%, "_FSOUND_Stream_GetSyncPoint@8" TO _FSOUND_Stream_GetSyncPoint%
     SYS _%, _hdll%, "_FSOUND_Stream_GetSyncPointInfo@8" TO _FSOUND_Stream_GetSyncPointInfo%
     SYS _%, _hdll%, "_FSOUND_Stream_GetTagField@24" TO _FSOUND_Stream_GetTagField%
     SYS _%, _hdll%, "_FSOUND_Stream_GetTime@4" TO _FSOUND_Stream_GetTime%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_GetBufferProperties@12" TO _FSOUND_Stream_Net_GetBufferProperties%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_GetLastServerStatus@0" TO _FSOUND_Stream_Net_GetLastServerStatus%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_GetStatus@20" TO _FSOUND_Stream_Net_GetStatus%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_SetBufferProperties@12" TO _FSOUND_Stream_Net_SetBufferProperties%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_SetMetadataCallback@12" TO _FSOUND_Stream_Net_SetMetadataCallback%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_SetNetDataCallback@8" TO _FSOUND_Stream_Net_SetNetDataCallback%
     SYS _%, _hdll%, "_FSOUND_Stream_Net_SetProxy@4" TO _FSOUND_Stream_Net_SetProxy%
     SYS _%, _hdll%, "_FSOUND_Stream_Open@16" TO _FSOUND_Stream_Open%
     SYS _%, _hdll%, "_FSOUND_Stream_Play@8" TO _FSOUND_Stream_Play%
     SYS _%, _hdll%, "_FSOUND_Stream_PlayEx@16" TO _FSOUND_Stream_PlayEx%
     SYS _%, _hdll%, "_FSOUND_Stream_SetBufferSize@4" TO _FSOUND_Stream_SetBufferSize%
     SYS _%, _hdll%, "_FSOUND_Stream_SetEndCallback@12" TO _FSOUND_Stream_SetEndCallback%
     SYS _%, _hdll%, "_FSOUND_Stream_SetLoopCount@8" TO _FSOUND_Stream_SetLoopCount%
     SYS _%, _hdll%, "_FSOUND_Stream_SetLoopPoints@12" TO _FSOUND_Stream_SetLoopPoints%
     SYS _%, _hdll%, "_FSOUND_Stream_SetMode@8" TO _FSOUND_Stream_SetMode%
     SYS _%, _hdll%, "_FSOUND_Stream_SetPCM@8" TO _FSOUND_Stream_SetPCM%
     SYS _%, _hdll%, "_FSOUND_Stream_SetPosition@8" TO _FSOUND_Stream_SetPosition%
     SYS _%, _hdll%, "_FSOUND_Stream_SetSubStream@8" TO _FSOUND_Stream_SetSubStream%
     SYS _%, _hdll%, "_FSOUND_Stream_SetSubStreamSentence@12" TO _FSOUND_Stream_SetSubStreamSentence%
     SYS _%, _hdll%, "_FSOUND_Stream_SetSyncCallback@12" TO _FSOUND_Stream_SetSyncCallback%
     SYS _%, _hdll%, "_FSOUND_Stream_SetTime@8" TO _FSOUND_Stream_SetTime%
     SYS _%, _hdll%, "_FSOUND_Stream_Stop@4" TO _FSOUND_Stream_Stop%
     SYS _%, _hdll%, "_FSOUND_Update@0" TO _FSOUND_Update%

     DIM _FSOUND_REVERB_CHANNELPROPERTIES{ \
     
\    Direct%,               \ int32 direct path level (at low and mid frequencies)
     
\    DirectHF%,             \ int32 relative direct path level at high frequencies
     
\    Room%,                 \ int32 room effect level (at low and mid frequencies)
     
\    RoomHF%,               \ int32 relative room effect level at high frequencies
     
\    Obstruction%,          \ int32 main obstruction control (attenuation at high frequencies)
     
\    ObstructionLFRatio%,   \ single obstruction low-frequency level re. main control
     
\    Occlusion%,            \ int32 main occlusion control (attenuation at high frequencies)
     
\    OcclustionLFRatio%,    \ single occlusion low-frequency level re. main control
     
\    OcclusionRoomRatio%,   \ single relative occlusion control for room effect
     
\    OcclusionDirectRatio%, \ single relative occlusion control for direct path
     
\    Exclusion%,            \ int32 main exlusion control (attenuation at high frequencies)
     
\    ExclusionLFRatio%,     \ single exclusion low-frequency level re. main control
     
\    OutsideVolumeHF%,      \ int32 outside sound cone level at high frequencies
     
\    DopplerFactor%,        \ single like DS3D flDopplerFactor but per source
     
\    RolloffFactor%,        \ single like DS3D flRolloffFactor but per source
     
\    RoomRolloffFactor%,    \ single like DS3D flRolloffFactor but for room effect
     
\    AirAbsorptionFactor%,  \ single multiplies AirAbsorptionHF member of FSOUND_REVERB_PROPERTIES
     
\    flags%                 \ int32 modifies the behavior of properties
     
\    }

     DIM _FSOUND_REVERB_PROPERTIES{ \
     
\                          \        MIN     MAX    DEFAULT DESCRIPTION
     
\    Environment%,         \ int32  0       25     0       sets all listener properties
     
\    EnvSize%,             \ single 1.0     100.0  7.5     environment size in meters
     
\    EnvDiffusion%,        \ single 0.0     1.0    1.0     environment diffusion
     
\    Room%,                \ int32  -10000  0      -1000   room effect level (at mid frequencies)
     
\    RoomHF%,              \ int32  -10000  0      -100    relative room effect level at high frequencies
     
\    RoomLF%,              \ int32  -10000  0      0       relative room effect level at low frequencies
     
\    DecayTime%,           \ single 0.1     20.0   1.49    reverberation decay time at mid frequencies
     
\    DecayHFRatio%,        \ single 0.1     2.0    0.83    high-frequency to mid-frequency decay time ratio
     
\    DecayLFRatio%,        \ single 0.1     2.0    1.0     low-frequency to mid-frequency decay time ratio
     
\    Reflections%,         \ int32  -10000  1000   -2602   early reflections level relative to room effect
     
\    ReflectionsDelay%,    \ single 0.0     0.3    0.007   initial reflection delay time
     
\    ReflectionsPan%(3),   \ single 0,0,0   early reflections panning vector
     
\    Reverb%,              \ int32  -1000   2000   200     late reverberation level relative to room effect
     
\    ReverbDelay%,         \ single 0.0     0.1    0.011   late reverberation delay time relative to initial reflection
     
\    ReverbPan%(3),        \ single 0,0,0   late reverberation panning vector
     
\    EchoTime%,            \ single .075    0.25   0.25    echo time
     
\    EchoDepth%,           \ single 0.0     1.0    0.0     echo depth
     
\    ModulationTime%,      \ single 0.04    4.0    0.25    modulation time
     
\    ModulationDepth%,     \ single 0.0     1.0    0.0     modulation depth
     
\    AirAbsorptionHF%,     \ single -100    0.0    -5.0    change in level per meter at high frequencies
     
\    HFReference%,         \ single 1000.0  20000  5000.0  reference high frequency (hz)
     
\    LFReference%,         \ single 20.0    1000.0 250.0   reference low frequency (hz)
     
\    RoomRolloffFactor%,   \ single 0.0     10.0   0.0     like FSOUND_3D_SetRolloffFactor but for room effect
     
\    Diffusion%,           \ single 0.0     100.0  100.0   Value that controls the echo density in the late reverberation decay. (xbox only)
     
\    Density%,             \ single 0.0     100.0  100.0   Value that controls the modal density in the late reverberation decay (xbox only)
     
\    flags%                \ int32 modifies the behavior of above properties
     
\    }

     DIM _FSOUND_TOC_TAG{ \
     
\    TagName&(3),      \ byte The string "TOC" (4th character is 0), just in case this structure is accidentally treated as a string.
     
\    NumTracks%,       \ int32 The number of tracks on the CD.
     
\    Min%(99),         \ int32 The start offset of each track in minutes.
     
\    Sec%(99),         \ int32 The start offset of each track in seconds.
     
\    Frame%(99)        \ int32 The start offset of each track in frames.
     
\    }


     REM FMOD_ERRORS
     
_FMOD_ERR_NONE             = 0 :REM No errors
     
_FMOD_ERR_BUSY             = 1 :REM Cannot call this command after FSOUND_Init. Call FSOUND_Close first.
     
_FMOD_ERR_UNINITIALIZED    = 2 :REM This command failed because FSOUND_Init was not called
     
_FMOD_ERR_INIT             = 3 :REM Error initializing output device.
     
_FMOD_ERR_ALLOCATED        = 4 :REM Error initializing output device, but more specifically, the output device is already in use and cannot be reused.
     
_FMOD_ERR_PLAY             = 5 :REM Playing the sound failed.
     
_FMOD_ERR_OUTPUT_FORMAT    = 6 :REM Soundcard does not support the features needed for this soundsystem (16bit stereo output)
     
_FMOD_ERR_COOPERATIVELEVEL = 7 :REM Error setting cooperative level for hardware.
     
_FMOD_ERR_CREATEBUFFER     = 8 :REM Error creating hardware sound buffer.
     
_FMOD_ERR_FILE_NOTFOUND    = 9 :REM File not found
     
_FMOD_ERR_FILE_FORMAT      = 10 :REM Unknown file format
     
_FMOD_ERR_FILE_BAD         = 11 :REM Error loading file
     
_FMOD_ERR_MEMORY           = 12 :REM Not enough memory
     
_FMOD_ERR_VERSION          = 13 :REM The version number of this file format is not supported
     
_FMOD_ERR_INVALID_PARAM    = 14 :REM An invalid parameter was passed to this function
     
_FMOD_ERR_NO_EAX           = 15 :REM Tried to use an EAX command on a non EAX enabled channel or output.
     
_FMOD_ERR_CHANNEL_ALLOC    = 16 :REM Failed to allocate a new channel
     
_FMOD_ERR_RECORD           = 17 :REM Recording is not supported on this machine
     
_FMOD_ERR_MEDIAPLAYER      = 18 :REM Windows Media Player not installed so cannot play wma or use internet streaming.
     
_FMOD_ERR_CDDEVICE         = 19 :REM An error occured trying to open the specified CD device


     REM FMUSIC_TYPES
     
_FMUSIC_TYPE_NONE = 0
     _FMUSIC_TYPE_MOD  = 1 :REM Protracker / Fasttracker
     
_FMUSIC_TYPE_S3M  = 2 :REM ScreamTracker 3
     
_FMUSIC_TYPE_XM   = 3 :REM FastTracker 2
     
_FMUSIC_TYPE_IT   = 4 :REM Impulse Tracker.
     
_FMUSIC_TYPE_MIDI = 5 :REM MIDI file
     
_FMUSIC_TYPE_FSB  = 6 :REM FMOD Sample Bank file


     REM FSOUND_CAPS
     
_FSOUND_CAPS_HARDWARE = &1 :REM This driver supports hardware accelerated 3d sound.
     
_FSOUND_CAPS_EAX2     = &2 :REM This driver supports EAX 2 reverb
     
_FSOUND_CAPS_EAX3     = &10 :REM This driver supports EAX 3 reverb


     REM FSOUND_CDPLAYMODES
     
_FSOUND_CD_PLAYCONTINUOUS = 0 :REM Starts from the current track and plays to end of CD.
     
_FSOUND_CD_PLAYONCE       = 1 :REM Plays the specified track then stops.
     
_FSOUND_CD_PLAYLOOPED     = 2 :REM Plays the specified track looped, forever until stopped manually.
     
_FSOUND_CD_PLAYRANDOM     = 3 :REM Plays tracks in random order


     REM FSOUND_CHANNELSAMPLEMODE
     
_FSOUND_FREE          = -1 :REM definition for dynamically allocated channel or sample
     
_FSOUND_UNMANAGED     = -2 :REM definition for allocating a sample that is NOT managed by fsound
     
_FSOUND_ALL           = -3 :REM for a channel index or sample index, this flag affects ALL channels or samples available! Not supported by all functions.
     
_FSOUND_STEREOPAN     = -1 :REM definition for full middle stereo volume on both channels
     
_FSOUND_SYSTEMCHANNEL = -1000 :REM special channel ID for channel based functions that want to alter the global FSOUND software mixing output channel
     
_FSOUND_SYSTEMSAMPLE  = -1000 :REM special sample ID for all sample based functions that want to alter the global FSOUND software mixing output sample


     REM FSOUND_DSP_PRIORITIES
     
_FSOUND_DSP_DEFAULTPRIORITY_CLEARUNIT       = 0 :REM DSP CLEAR unit - done first
     
_FSOUND_DSP_DEFAULTPRIORITY_SFXUNIT         = 100 :REM DSP SFX unit - done second
     
_FSOUND_DSP_DEFAULTPRIORITY_MUSICUNIT       = 200 :REM DSP MUSIC unit - done third
     
_FSOUND_DSP_DEFAULTPRIORITY_USER            = 300 :REM User priority, use this as reference for your own dsp units
     
_FSOUND_DSP_DEFAULTPRIORITY_FFTUNIT         = 900 :REM This reads data for FSOUND_DSP_GetSpectrum, so it comes after user units
     
_FSOUND_DSP_DEFAULTPRIORITY_CLIPANDCOPYUNIT = 1000 :REM DSP CLIP AND COPY unit - last


     REM FSOUND_FX_MODES
     
_FSOUND_FX_CHORUS       = 0
     _FSOUND_FX_COMPRESSOR   = 1
     _FSOUND_FX_DISTORTION   = 2
     _FSOUND_FX_ECHO         = 3
     _FSOUND_FX_FLANGER      = 4
     _FSOUND_FX_GARGLE       = 5
     _FSOUND_FX_I3DL2REVERB  = 6
     _FSOUND_FX_PARAMEQ      = 7
     _FSOUND_FX_WAVES_REVERB = 8


     REM FSOUND_INITMODES
     
_FSOUND_INIT_USEDEFAULTMIDISYNTH     = &1 :REM Causes MIDI playback to force software decoding.
     
_FSOUND_INIT_GLOBALFOCUS             = &2 :REM For DirectSound output - sound is not muted when window is out of focus.
     
_FSOUND_INIT_ENABLESYSTEMCHANNELFX   = &4 :REM For DirectSound output - Allows FSOUND_FX api to be used on global software mixer output!
     
_FSOUND_INIT_ACCURATEVULEVELS        = &8 :REM This latency adjusts FSOUND_GetCurrentLevels, but incurs a small cpu and memory hit
     
_FSOUND_INIT_PS2_DISABLECORE0REVERB  = &10 :REM PS2 only - Disable reverb on CORE 0 to regain SRAM
     
_FSOUND_INIT_PS2_DISABLECORE1REVERB  = &20 :REM PS2 only - Disable reverb on CORE 1 to regain SRAM
     
_FSOUND_INIT_PS2_SWAPDMACORES        = &40 :REM PS2 only - By default FMOD uses DMA CH0 for mixing, CH1 for uploads, this flag swaps them around
     
_FSOUND_INIT_DONTLATENCYADJUST       = &80 :REM Callbacks are not latency adjusted, and are called at mix time. Also information functions are immediate
     
_FSOUND_INIT_GC_INITLIBS             = &100 :REM Gamecube only - Initializes GC audio libraries
     
_FSOUND_INIT_STREAM_FROM_MAIN_THREAD = &200 :REM Turns off fmod streamer thread, and makes streaming update from FSOUND_Update called by the user


     REM FSOUND_MIXERTYPES
     
_FSOUND_MIXER_AUTODETECT = 0 :REM CE/PS2 Only - Non interpolating/low quality mixer
     
_FSOUND_MIXER_BLENDMODE  = 1 :REM removed / obsolete.
     
_FSOUND_MIXER_MMXP5      = 2 :REM removed / obsolete.
     
_FSOUND_MIXER_MMXP6      = 3 :REM removed / obsolete.

     
_FSOUND_MIXER_QUALITY_AUTODETECT = 4 :REM All platforms - Autodetect the fastest quality mixer based on your cpu.
     
_FSOUND_MIXER_QUALITY_FPU        = 5 :REM Win32/Linux only - Interpolating/volume ramping FPU mixer.
     
_FSOUND_MIXER_QUALITY_MMXP5      = 6 :REM Win32/Linux only - Interpolating/volume ramping FPU mixer.
     
_FSOUND_MIXER_QUALITY_MMXP6      = 7 :REM Win32/Linux only - Interpolating/volume ramping ppro+ MMX mixer.

     
_FSOUND_MIXER_MONO         = 8 :REM CE/PS2 only - MONO non interpolating/low quality mixer. For speed
     
_FSOUND_MIXER_QUALITY_MONO = 9 :REM CE/PS2 only - MONO Interpolating mixer. For speed


     REM FSOUND_MODES
     
_FSOUND_LOOP_OFF      = &1 :REM For non looping samples.
     
_FSOUND_LOOP_NORMAL   = &2 :REM For forward looping samples.
     
_FSOUND_LOOP_BIDI     = &4 :REM For bidirectional looping samples. (no effect if in hardware).
     
_FSOUND_8BITS         = &8 :REM For 8 bit samples.
     
_FSOUND_16BITS        = &10 :REM For 16 bit samples.
     
_FSOUND_MONO          = &20 :REM For mono samples.
     
_FSOUND_STEREO        = &40 :REM For stereo samples.
     
_FSOUND_UNSIGNED      = &80 :REM For source data containing unsigned samples.
     
_FSOUND_SIGNED        = &100 :REM For source data containing signed data.
     
_FSOUND_DELTA         = &200 :REM For source data stored as delta values.
     
_FSOUND_IT214         = &400 :REM For source data stored using IT214 compression.
     
_FSOUND_IT215         = &800 :REM For source data stored using IT215 compression.
     
_FSOUND_HW3D          = &1000 :REM Attempts to make samples use 3d hardware acceleration. (if the card supports it)
     
_FSOUND_2D            = &2000 :REM Ignores any 3d processing. overrides FSOUND_HW3D. Located in software.
     
_FSOUND_STREAMABLE    = &4000 :REM For realtime streamable samples. If you dont supply this sound may come out corrupted.
     
_FSOUND_LOADMEMORY    = &8000 :REM For FSOUND_Sample_Load - name will be interpreted as a pointer to data
     
_FSOUND_LOADRAW       = &10000 :REM For FSOUND_Sample_Load/FSOUND_Stream_Open - will ignore file format and treat as raw pcm.
     
_FSOUND_MPEGACCURATE  = &20000 :REM For FSOUND_Stream_Open - scans MP2/MP3 (VBR also) for accurate FSOUND_Stream_GetLengthMs/FSOUND_Stream_SetTime.
     
_FSOUND_FORCEMONO     = &40000 :REM For forcing stereo streams and samples to be mono - needed with FSOUND_HW3D - incurs speed hit
     
_FSOUND_HW2D          = &80000 :REM 2d hardware sounds. allows hardware specific effects
     
_FSOUND_ENABLEFX      = &100000 :REM Allows DX8 FX to be played back on a sound. Requires DirectX 8 - Note these sounds cant be played more than once, or have a changing frequency
     
_FSOUND_MPEGHALFRATE  = &200000 :REM For FMODCE only - decodes mpeg streams using a lower quality decode, but faster execution
     
_FSOUND_XADPCM        = &400000 :REM For XBOX only - Describes a user sample that its contents are compressed as XADPCM
     
_FSOUND_VAG           = &800000 :REM For PS2 only - Describes a user sample that its contents are compressed as Sony VAG format.
     
_FSOUND_NONBLOCKING   = &1000000 :REM For FSOUND_Stream_Open - Causes stream to open in the background and not block the foreground app - stream plays only when ready.
     
_FSOUND_GCADPCM       = &2000000 :REM For Gamecube only - Contents are compressed as Gamecube DSP-ADPCM format
     
_FSOUND_MULTICHANNEL  = &4000000 :REM For PS2 only - Contents are interleaved into a multi-channel (more than stereo) format
     
_FSOUND_USECORE0      = &8000000 :REM For PS2 only - Sample/Stream is forced to use hardware voices 00-23
     
_FSOUND_USECORE1      = &10000000 :REM For PS2 only - Sample/Stream is forced to use hardware voices 24-47
     
_FSOUND_LOADMEMORYIOP = &20000000 :REM For PS2 only - "name" will be interpreted as a pointer to data for streaming and samples. The address provided will be an IOP address
     
_FSOUND_STREAM_NET    = &80000000 :REM Specifies an internet stream

     
_FSOUND_NORMAL = _FSOUND_16BITS OR _FSOUND_SIGNED OR _FSOUND_MONO


     REM FSOUND_OUTPUTTYPES
     
_FSOUND_OUTPUT_NOSOUND = 0 :REM NoSound driver, all calls to this succeed but do nothing.
     
_FSOUND_OUTPUT_WINMM   = 1 :REM Windows Multimedia driver.
     
_FSOUND_OUTPUT_DSOUND  = 2 :REM DirectSound driver. You need this to get EAX2 or EAX3 support, or FX api support.
     
_FSOUND_OUTPUT_A3D     = 3 :REM A3D driver.

     
_FSOUND_OUTPUT_OSS  = 4 :REM Linux/Unix OSS (Open Sound System) driver, i.e. the kernel sound drivers.
     
_FSOUND_OUTPUT_ESD  = 5 :REM Linux/Unix ESD (Enlightment Sound Daemon) driver.
     
_FSOUND_OUTPUT_ALSA = 6 :REM Linux Alsa driver.

     
_FSOUND_OUTPUT_ASIO = 7 :REM Low latency ASIO driver
     
_FSOUND_OUTPUT_XBOX = 8 :REM Xbox driver
     
_FSOUND_OUTPUT_PS2  = 9 :REM PlayStation 2 driver
     
_FSOUND_OUTPUT_MAC  = 10 :REM Mac SoundMager driver
     
_FSOUND_OUTPUT_GC   = 11 :REM Gamecube driver

     
_FSOUND_OUTPUT_NOSOUND_NONREALTIME = 12 :REM This is the same as nosound, but the sound generation is driven by FSOUND_Update


     REM FSOUND_REVERB_CHANNELFLAGS
     
_FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO = &1 :REM Automatic setting of Direct due to distance from listener
     
_FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO     = &2 :REM Automatic setting of Room due to distance from listener
     
_FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO   = &4 :REM Automatic setting of RoomHF due to distance from listener
     
_FSOUND_REVERB_CHANNELFLAGS_DEFAULT      = _FSOUND_REVERB_CHANNELFLAGS_DIRECTHFAUTO OR _FSOUND_REVERB_CHANNELFLAGS_ROOMAUTO OR _FSOUND_REVERB_CHANNELFLAGS_ROOMHFAUTO


     REM FSOUND_REVERB_PROPERTYFLAGS
     
_FSOUND_REVERBFLAGS_DECAYTIMESCALE        = &1 :REM EnvironmentSize affects reverberation decay time
     
_FSOUND_REVERBFLAGS_REFLECTIONSSCALE      = &2 :REM EnvironmentSize affects reflection level
     
_FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE = &4 :REM EnvironmentSize affects initial reflection delay time
     
_FSOUND_REVERBFLAGS_REVERBSCALE           = &8 :REM EnvironmentSize affects reflections level
     
_FSOUND_REVERBFLAGS_REVERBDELAYSCALE      = &10 :REM EnvironmentSize affects late reverberation delay time
     
_FSOUND_REVERBFLAGS_DECAYHFLIMIT          = &20 :REM AirAbsorptionHF affects DecayHFRatio
     
_FSOUND_REVERBFLAGS_ECHOTIMESCALE         = &40 :REM EnvironmentSize affects echo time
     
_FSOUND_REVERBFLAGS_MODULATIONTIMESCALE   = &80 :REM EnvironmentSize affects modulation time
     
_FSOUND_REVERB_FLAGS_CORE0                = &100 :REM PS2 Only - Reverb is applied to CORE0 (hw voices 0-23)
     
_FSOUND_REVERB_FLAGS_CORE1                = &200 :REM PS2 Only - Reverb is applied to CORE1 (hw voices 24-47)
     
_FSOUND_REVERBFLAGS_DEFAULT = _FSOUND_REVERBFLAGS_DECAYTIMESCALE OR _FSOUND_REVERBFLAGS_REFLECTIONSSCALE OR _FSOUND_REVERBFLAGS_REFLECTIONSDELAYSCALE OR _FSOUND_REVERBFLAGS_REVERBSCALE OR \
     
\ _FSOUND_REVERBFLAGS_REVERBDELAYSCALE OR _FSOUND_REVERBFLAGS_DECAYHFLIMIT OR _FSOUND_REVERB_FLAGS_CORE0 OR _FSOUND_REVERB_FLAGS_CORE1


     REM FSOUND_SPEAKERMODES
     
_FSOUND_SPEAKERMODE_DOLBYDIGITAL = 0 :REM The audio is played through a speaker arrangement of surround speakers with a subwoofer.
     
_FSOUND_SPEAKERMODE_HEADPHONE    = 1 :REM The speakers are headphones.
     
_FSOUND_SPEAKERMODE_MONO         = 2 :REM The speakers are monaural.
     
_FSOUND_SPEAKERMODE_QUAD         = 3 :REM The speakers are quadraphonic.
     
_FSOUND_SPEAKERMODE_STEREO       = 4 :REM The speakers are stereo (default value).
     
_FSOUND_SPEAKERMODE_SURROUND     = 5 :REM The speakers are surround sound.
     
_FSOUND_SPEAKERMODE_DTS          = 6 :REM The audio is played through a speaker arrangement of surround speakers with a subwoofer.
     
_FSOUND_SPEAKERMODE_PROLOGIC2    = 7 :REM Dolby Prologic 2. Playstation 2 and Gamecube only


     REM FSOUND_STATUS_FLAGS
     
_FSOUND_PROTOCOL_SHOUTCAST = &1
     _FSOUND_PROTOCOL_ICECAST   = &2
     _FSOUND_PROTOCOL_HTTP      = &4
     _FSOUND_FORMAT_MPEG        = &10000
     _FSOUND_FORMAT_OGGVORBIS   = &20000


     REM FSOUND_STREAM_NET_STATUS
     
_FSOUND_STREAM_NET_NOTCONNECTED = 0 :REM Stream hasn:REMt connected yet
     
_FSOUND_STREAM_NET_CONNECTING   = 1 :REM Stream is connecting to remote host
     
_FSOUND_STREAM_NET_BUFFERING    = 2 :REM Stream is buffering data
     
_FSOUND_STREAM_NET_READY        = 3 :REM Stream is ready to play
     
_FSOUND_STREAM_NET_ERROR        = 4 :REM Stream has suffered a fatal error


     REM FSOUND_TAGFIELD_TYPE
     
_FSOUND_TAGFIELD_VORBISCOMMENT = 0 :REM A vorbis comment
     
_FSOUND_TAGFIELD_ID3V1         = 1 :REM Part of an ID3v1 tag
     
_FSOUND_TAGFIELD_ID3V2         = 2 :REM An ID3v2 frame
     
_FSOUND_TAGFIELD_SHOUTCAST     = 3 :REM A SHOUTcast header line
     
_FSOUND_TAGFIELD_ICECAST       = 4 :REM An Icecast header line
     
_FSOUND_TAGFIELD_ASF           = 5 :REM An Advanced Streaming Format header line

     
ENDPROC