$EXEICON:'SLICON'
_TITLE "SpaceLazer"
_FULLSCREEN _SQUAREPIXELS
START:
RANDOMIZE USING TIMER
CHDIR "DATA"
SCREEN _NEWIMAGE(320, 200, 32)
WI& = _LOADIMAGE("SLWI")
_ICON WI&
_MOUSEHIDE
_FREEIMAGE WI&
_DISPLAY
_PRINTMODE _KEEPBACKGROUND
LOCATE 6, 1
_DISPLAY
CHDIR ".."
CHDIR "SAVE"
OPEN "CONFIG.CFG" FOR INPUT AS #1
DO WHILE NOT EOF(1)
    INPUT #1, LV, FSV
LOOP
CLOSE #1
CHDIR ".."
CHDIR "DATA"
IF INSKP = 1 GOTO CONFIG
IF DIED = 1 GOTO CONFIG
LC = 0
DO
    IF FS >= FSV THEN _DISPLAY: FS = -1
    FS = FS + 1
    _LIMIT LV
    K$ = INKEY$
    IF K$ <> "" AND K$ <> CHR$(27) THEN EXIT DO
    IF INP(&H60) = 1 THEN
        QI = 1
        GOSUB QUIT
        CLS
    END IF
    LOCATE 6, 1
    COLOR _RGB32(191, 191, 191)
    _PRINTSTRING (4, 80), "    2020 PQWare Entertainment Group"
    _DISPLAY
    '_DELAY 0.01
    LC = LC + 1
LOOP UNTIL LC > 499
ITP = 80
DO
    _LIMIT LV
    _PRINTSTRING (4, ITP), "    2020 PQWare Entertainment Group"
    IF FS >= FSV THEN _DISPLAY: FS = -1
    FS = FS + 1
    CLS
    ITP = ITP - 1
    '_DELAY 0.01
LOOP UNTIL ITP < -16
CONFIG:
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
QI = 0
CLS
'DIM SHARED HSD1
'DIM SHARED HSD2
'DIM SHARED HSD3
'DIM SHARED HSN1$
'DIM SHARED HSN2$
'DIM SHARED HSN3$
LC = 0
DO
    C = ((CINT(RND * 3) + 1) * 64) - 1
    RX = CINT(RND * 319)
    RY = CINT(RND * 199)
    PSET (RX, RY), _RGB32(C, C, C)
    LC = LC + 1
LOOP UNTIL LC > 99
GOSUB SPRSETUP
_DISPLAY
IMGSPR 0, 0
LOADSPR 1, "SLLOGO"
'C1& = _RGB32(0, 127, 127)
'C2& = _RGB32(0, 255, 255)
CLS
SETSPR 0, 0, 0
SETSPR 1, -4, 0
BGPOS = -1
_SNDVOL TM&, 0.5
MENU:
TM& = _SNDOPEN("SLTM")
_SNDPLAY TM&
_SNDLOOP TM&
_KEYCLEAR
DO
    _LIMIT LV
    BGPOS = BGPOS - 1
    IF BGPOS < -319 THEN BGPOS = 0
    SETSPR 0, BGPOS, 0
    PUTSPR 0, 0
    SETSPR 0, BGPOS + 320, 0
    PUTSPR 0, 1
    PUTSPR 1, 1
    SCREEN , , 1, 1
    COLOR _RGB32(0, 191, 191)
    _PRINTSTRING (50, 152), "Press [ENTER]"
    '_DELAY 0.022
    K$ = INKEY$
    IF FS >= FSV THEN _DISPLAY: FS = -1
    FS = FS + 1
    IF INP(&H60) = 1 THEN
        _SNDPAUSE TM&
        GOSUB QUIT
        _KEYCLEAR
        IF _SNDPLAYING(TM&) = 0 THEN _SNDPLAY TM&
    END IF
    IF _SNDPLAYING(TM&) = 0 THEN _SNDPLAY TM&
LOOP UNTIL K$ = CHR$(13)
_SNDSTOP TM&
_SNDCLOSE TM&
'DELSPR 1
SCREEN , , 1, 1
DIFSEL:
CLS
COLOR _RGB32(255, 255, 0)
LOCATE 5, 9: PRINT "DIFFICULTY:"
COLOR _RGB32(0, 0, 255)
LOCATE 6, 9: PRINT "1: EASY"
COLOR _RGB32(0, 255, 0)
LOCATE 7, 9: PRINT "2: MEDIUM"
COLOR _RGB32(255, 0, 0)
LOCATE 8, 9: PRINT "3: HARD"
_DISPLAY
DO
    K$ = INKEY$
    IF K$ = "1" THEN ASR& = 32000: DFL$ = " [ON EASY]": DLVL = 3: EXIT DO
    IF K$ = "2" THEN ASR& = 16000: DFL$ = " [ON MEDIUM]": DLVL = 2: EXIT DO
    IF K$ = "3" THEN ASR& = 8000: DFL$ = " [ON HARD]": DLVL = 1: EXIT DO
    IF K$ = "" THEN _KEYCLEAR: GOTO MENU
LOOP
_KEYCLEAR
CLS
COLOR _RGB32(255, 255, 0)
LOCATE 5, 9: PRINT "MUSIC:"
COLOR _RGB32(0, 0, 255)
LOCATE 6, 9: PRINT "1: SONG 1"
COLOR _RGB32(0, 255, 0)
LOCATE 7, 9: PRINT "2: SONG 2"
COLOR _RGB32(255, 0, 0)
LOCATE 8, 9: PRINT "3: SONG 3"
_DISPLAY
DO
    K$ = INKEY$
    IF K$ = "0" THEN EXIT DO
    IF K$ = "1" THEN GMFN$ = "1": EXIT DO
    IF K$ = "2" THEN GMFN$ = "2": EXIT DO
    IF K$ = "3" THEN GMFN$ = "3": EXIT DO
    IF K$ = "4" THEN GMFN$ = "4": EXIT DO
    IF K$ = "" GOTO DIFSEL
LOOP
CLS
COLOR _RGB32(191, 191, 191)
SCREEN , , 1, 1
_PRINTSTRING (4, 80), "            Please Wait...             "
_DISPLAY
PWP = 80
IF GMFN$ = "4" THEN
    GM& = _SNDOPEN("RKAS")
ELSE
    GM& = _SNDOPEN("SLGM" + GMFN$)
END IF
SS& = _SNDOPEN("SLSS")
RS& = _SNDOPEN("SLRS")
HS& = _SNDOPEN("SLHS")
AHN& = _SNDOPEN("SLAS")
ADMG = 10
LOADSPR 2, "SS0"
LOADSPR 3, "LZR"
LOADSPR 4, "A1"
LOADSPR 5, "A2"
LOADSPR 6, "A3"
LOADSPR 7, "PU01"
LOADSPR 8, "PU02"
LOADSPR 9, "PU03"
LOADSPR 10, "PU04"
LOADSPR 11, "PU05"
LOADSPR 12, "PU06"
LOADSPR 13, "RKT"
SETSPR 2, 12, 90
SETSPR 4, 10, 10
SETSPR 5, 27, 10
SETSPR 6, 44, 10
SETSPR 7, -17, 10
SETSPR 8, -17, 10
SETSPR 9, -17, 10
SETSPR 10, -17, 10
SETSPR 11, -17, 10
SETSPR 12, -17, 10
SIZESPR 2, 100, 100
SIZESPR 3, 100, 100
SIZESPR 4, 100, 100
SIZESPR 5, 100, 100
SIZESPR 6, 100, 100
SIZESPR 7, 100, 100
SIZESPR 8, 100, 100
SIZESPR 9, 100, 100
SIZESPR 10, 100, 100
SIZESPR 11, 100, 100
SIZESPR 12, 100, 100
LZRN = 0
DIM SHARED AX(0 TO 99)
DIM SHARED AY(0 TO 99)
DIM SHARED AD(0 TO 99)
DIM SHARED AMX(0 TO 99)
DIM SHARED AMY(0 TO 99)
'DIM SHARED BX(0 TO 99)
'DIM SHARED BY(0 TO 99)
'DIM SHARED BD(0 TO 99)
'DIM SHARED PUX(0 TO 5)
'DIM SHARED PUY(0 TO 5)
DIM SHARED LZRPX(0 TO 99)
DIM SHARED LZRPY(0 TO 99)
DIM SHARED LZRTD(0 TO 99)
ASPWN = 0
BSPWN = 0
BLTSPD = 55
SCORE = 0
OLDSC = 0
LC = 0
DO
    AX(LC) = -17
    AY(LC) = 92
    AD(LC) = CINT(RND * 2) + 4
    LC = LC + 1
LOOP UNTIL LC > 99
LC = 0
DO
    LZRPX(LC) = 340
    LZRPY(LC) = 0
    LC = LC + 1
    IF LC > 99 THEN EXIT DO
LOOP
OSPD = 1
HP = 100
SCORE = 0
SCREEN , , 1, 1
DO
    _LIMIT LV
    _PRINTSTRING (4, PWP), "            Please Wait...             "
    _DISPLAY
    IF FS >= FSV THEN _DISPLAY: FS = -1
    FS = FS + 1
    CLS
    PWP = PWP - 1
LOOP UNTIL PWP < -16
_SNDVOL GM&, 0.5
_SNDPLAY GM&
_SNDLOOP GM&
_KEYCLEAR
LZRPX(99) = 340
DO
    _LIMIT LV
    BGPOS = BGPOS - 0.5
    IF BGPOS < -319 THEN BGPOS = 0
    CLNSPR 0, BGPOS, 0, 1
    CLNSPR 0, BGPOS + 320, 0, 1
    SCREEN , , 1, 1
    _PRINTMODE _KEEPBACKGROUND
    _FONT 8
    LOCATE 1, 6
    PRINT "HEALTH:"; HP;
    LOCATE 1, 20
    PRINT "SCORE:"; SCORE;
    _FONT 16
    SCREEN , , 0, 1
    IF D = 1 THEN
        CLS
        CLNSPR 0, BGPOS, 0, 1
        CLNSPR 0, BGPOS + 320, 0, 1
        SCREEN , , 1, 1
        _PRINTMODE _KEEPBACKGROUND
        _FONT 8
        LOCATE 1, 6
        PRINT "HEALTH:"; HP;
        LOCATE 1, 20
        PRINT "SCORE:"; SCORE;
        _FONT 16
        SCREEN , , 0, 1
        _DISPLAY
        GOTO DCHK
    END IF
    SSMV = 0
    SSMX = 0
    IF _KEYDOWN(18432) THEN SSMV = 1
    IF _KEYDOWN(20480) THEN SSMV = -1
    IF _KEYDOWN(19712) THEN SSMX = 1
    IF _KEYDOWN(19200) THEN SSMX = -1
    IF SSMV = 1 AND SPRY1P(2) > 0 THEN MOVESPR 2, 0, -1 ': SY = SY - 1
    IF SSMV = -1 AND SPRY1P(2) < 190 THEN MOVESPR 2, 0, 1 ': SY = SY + 1
    IF SSMX = 1 AND SPRX1P(2) < 300 THEN MOVESPR 2, 1, 0
    IF SSMX = -1 AND SPRX1P(2) > 12 THEN MOVESPR 2, -1, 0
    IF JNTNSPLM = 1 THEN
        LOADSPR 21, "JTNP"
        SETSPR 21, -250, -12
        JPE = 1
        JNTNSPLM = 0
    END IF
    IF JPE = 1 THEN
        MOVESPR 21, 1, 0
        LC = 0
        DO
            IF AX(LC) < SPRX1P(21) + 180 THEN AX(LC) = -17
            IF CINT(RND * 512) = 0 THEN _SNDPLAY AHN&
            LC = LC + 1
        LOOP UNTIL LC > 99
        IF SPRX1P(21) > 320 THEN JPE = 0: DELSPR 21
    END IF
    _KEYCLEAR
    IF CINT(RND * ASR& / 1000) = 0 THEN
        AX(ASPWN) = 321
        AY(ASPWN) = CINT(RND * 183)
        AMX(ASPWN) = RND * 0.01
        AMY(ASPWN) = RND * 1 - 0.5
        ASPWN = ASPWN + 1
        IF ASPWN > 99 THEN ASPWN = 0
    END IF
    R1 = CINT(RND * 10000 * DLVL)
    IF R1 < 6 THEN
        IF SPRX1P(R1 + 7) < -16 THEN
            SETSPR R1 + 7, 320, CINT(RND * 183)
        END IF
    END IF
    IF SCORE > 99 AND SCORE < 1000 THEN BLTSPD = 33
    IF SCORE > 999 THEN BLTSPD = 11
    IF INP(&H60) = 57 AND BWT > BLTSPD - 1 THEN
        IF WTS = 0 THEN
            LZRTD(LZRN) = 0
            _SNDPLAY SS&
            '_KEYCLEAR
            WTS = 1
            BWT = 0
            IF BSV = 1 THEN
                BSV = 0
            ELSE
                BSV = 1
            END IF
            IF BSV = 0 THEN LZRPY(LZRN) = SPRY1P(2) + 1
            IF BSV = 1 THEN LZRPY(LZRN) = SPRY1P(2) + 6
            LZRPX(LZRN) = SPRX1P(2) + 8
            LZRN = LZRN + 1
            IF LZRN > 99 THEN LZRN = 0
        END IF
    END IF
    IF INP(&H60) = 185 THEN WTS = 0
    IF INP(&H60) = 19 AND BWT > BLTSPD - 1 THEN
        IF RKT > 0 THEN
            IF WTS = 0 THEN
                LZRTD(LZRN) = 1: RKT = RKT - 1
                _SNDPLAY RS&
                '_KEYCLEAR
                WTS = 1
                BWT = 0
                LZRPY(LZRN) = SPRY1P(2) + 2
                LZRPX(LZRN) = SPRX1P(2) + 8
                LZRN = LZRN + 1
                IF LZRN > 99 THEN LZRN = 0
            END IF
        END IF
    END IF
    IF INP(&H60) = 147 THEN WTS = 0
    IF BWT < BLTSPD THEN BWT = BWT + 1
    LC = 0
    DO
        LC2 = 0
        DO
            IF LZRPX(LC) > AX(LC2) AND LZRPX(LC) < AX(LC2) + 15 OR LZRPX(LC) + 13 > AX(LC2) AND LZRPX(LC) + 13 < AX(LC2) + 15 THEN
                IF LZRPY(LC) > AY(LC2) AND LZRPY(LC) < AY(LC2) + 15 OR LZRPY(LC) + 2 > AY(LC2) AND LZRPY(LC) + 2 < AY(LC2) + 15 THEN
                    _SNDPLAY AHN&
                    IF LZRTD(LC) = 0 THEN LZRPX(LC) = 339
                    AX(LC2) = -17
                    SCORE = SCORE + 1
                END IF
            END IF
            IF SPRX1P(2) > AX(LC2) AND SPRX1P(2) < AX(LC2) + 15 OR SPRX1P(2) + 13 > AX(LC2) AND SPRX1P(2) + 13 < AX(LC2) + 15 THEN
                IF SPRY1P(2) > AY(LC2) AND SPRY1P(2) < AY(LC2) + 15 OR SPRY1P(2) + 13 > AY(LC2) AND SPRY1P(2) + 13 < AY(LC2) + 15 THEN
                    _SNDPLAY HS&
                    HP = HP - CINT(ADMG)
                    IF ADMG < 10 THEN ADMG = ADMG * 1.25
                    IF ADMG > 10 THEN ADMG = 10
                    AX(LC2) = -17
                END IF
            END IF
            LC2 = LC2 + 1
        LOOP UNTIL LC2 > 99
        IF LZRPX(LC) < 339 THEN
            IF LZRTD(LC) = 1 THEN
                LZRPX(LC) = LZRPX(LC) + 0.5
                CLNSPR 13, LZRPX(LC), LZRPY(LC), 1
            ELSE
                LZRPX(LC) = LZRPX(LC) + 2
                CLNSPR 3, LZRPX(LC), LZRPY(LC), 1
            END IF
        END IF
        LC = LC + 1
        IF LC > 99 THEN EXIT DO
    LOOP
    LC2 = 0
    DO
        IF SPRX1P(2) > SPRX1P(LC2 + 7) AND SPRX1P(2) < SPRX1P(LC2 + 7) + 15 OR SPRX1P(2) + 13 > SPRX1P(LC2 + 7) AND SPRX1P(2) + 13 < SPRX1P(LC2 + 7) + 15 THEN
            IF SPRY1P(2) > SPRY1P(LC2 + 7) AND SPRY1P(2) < SPRY1P(LC2 + 7) + 15 OR SPRY1P(2) + 13 > SPRY1P(LC2 + 7) AND SPRY1P(2) + 13 < SPRY1P(LC2 + 7) + 15 THEN
                _SNDPLAYFILE "SLPS"
                IF LC2 = 0 THEN RKT = RKT + 1
                IF LC2 = 1 THEN RKT = RKT + 2
                IF LC2 = 2 THEN HP = HP + 50
                IF LC2 = 3 THEN IF HP < 100 THEN HP = 100
                IF LC2 = 4 THEN ADMG = ADMG / 2
                IF LC2 = 5 THEN SCORE = SCORE + CINT(RND * 5) + 10
                SETSPR LC2 + 7, -17, SPRY1P(LC2)
            END IF
        END IF
        LC2 = LC2 + 1
    LOOP UNTIL LC2 > 5
    MOVESPR 7, -0.25, 0
    MOVESPR 8, -0.25, 0
    MOVESPR 9, -0.25, 0
    MOVESPR 10, -0.25, 0
    MOVESPR 11, -0.25, 0
    MOVESPR 12, -0.25, 0
    IF ASR& > 6000 THEN ASR& = ASR& - 1
    IF INP(&H60) = 1 THEN
        _SNDPAUSE GM&
        M = 1
        GOSUB QUIT
        IF _SNDPLAYING(GM&) = 0 THEN _SNDPLAY GM&
    END IF
    IF _SNDPLAYING(GM&) = 0 THEN _SNDPLAY GM&
    '(100 * DLVL) - 1
    IF SCORE - OLDSC > (200 * DLVL) - 1 OR SBFC = 1 THEN
        GOSUB BOSSF
        _SNDSTOP GM&
        _SNDPLAY GM&
        _SNDLOOP GM&
        SBFC = 0
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        OLDSC = SCORE
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        _KEYCLEAR
        BWT = 5
    END IF
    DCHK:
    IF D = 1 THEN
        SCREEN , , 0, 1
        CLS
        SCREEN , , 1, 1
        CLS
        SCREEN , , 0, 1
        CLNSPR 0, BGPOS, 0, 1
        CLNSPR 0, BGPOS + 320, 0, 1
        SCREEN , , 1, 1
        _PRINTMODE _KEEPBACKGROUND
        _FONT 8
        LOCATE 1, 6
        PRINT "HEALTH:"; HP;
        LOCATE 1, 20
        PRINT "SCORE:"; SCORE;
        _FONT 16
        SCREEN , , 0, 1
        _DISPLAY
        GOTO GAMEOVER
    END IF
    IF HP < 1 THEN D = 1
    '_DELAY 0.0025
    IF FS = FSV THEN
        LC = 0
        DO
            IF AX(LC) > -17 THEN CLNSPR AD(LC), AX(LC), AY(LC), 1: AX(LC) = AX(LC) - 1 - AMX(LC): AY(LC) = AY(LC) + AMY(LC)
            LC = LC + 1
        LOOP UNTIL LC > 98
        PUTSPR 2, 1
        PUTSPR 7, 1
        PUTSPR 8, 1
        PUTSPR 9, 1
        PUTSPR 10, 1
        PUTSPR 11, 1
        PUTSPR 12, 1
        IF JPE = 1 THEN PUTSPR 21, 1
        _DISPLAY
        FS = -1
    END IF
    FS = FS + 1
LOOP
QUIT:
IF M = 1 THEN
    SCREEN , , 1, 1
    CLS
    CLNSPR 0, BGPOS, 0, 1
    CLNSPR 0, BGPOS + 320, 0, 1
END IF
IF QI <> 1 THEN SCREEN , , 1, 1
_AUTODISPLAY
LOCATE 6, 13
IF QI = 1 THEN LOCATE 7, 13
_KEYCLEAR
_PRINTMODE _KEEPBACKGROUND
COLOR _RGB32(0, 191, 191)
INPUT "QUIT? (Y/N):", QG$
IF QI <> 1 THEN SCREEN , , 0, 1
IF M = 1 THEN
    IF LCASE$(QG$) = "cheat" THEN
        LOCATE 7, 13
        _PRINTMODE _KEEPBACKGROUND
        COLOR _RGB32(0, 191, 191)
        SCREEN , , 1, 1
        INPUT "Code: ", CC$
        SCREEN , , 0, 1
        IF LCASE$(CC$) = "jonathan" THEN JNTNSPLM = 1
        IF LCASE$(CC$) = "rick" THEN
            GMSTP = _SNDPAUSED(GM&)
            _SNDSTOP GM&
            _SNDCLOSE GM&
            GM& = _SNDOPEN("RKAS")
            IF GMSTP = 0 THEN
                _SNDVOL GM&, 0.5
                _SNDPLAY GM&
                _SNDLOOP GM&
            END IF
        END IF
        IF LCASE$(CC$) = "digitus" THEN
            DELSPR 3
            LOADSPR 3, "LZR1"
        END IF
        IF LCASE$(CC$) = "bossfight" THEN
            SBFC = 1
        END IF
    END IF
END IF
_DISPLAY
IF UCASE$(LEFT$(QG$, 1)) <> "Y" THEN RETURN
IF M = 1 THEN CLEAR: INSKP = 1: CHDIR "..": GOTO START 'MENU
SYSTEM
GAMEOVER:
_SNDSTOP GM&
_SNDCLOSE GM&
DS& = _SNDOPEN("SLDS")
SCREEN , , 1, 1
_PRINTMODE _KEEPBACKGROUND
COLOR _RGB32(191, 0, 0)
_PRINTSTRING (4, 80), "               GAME OVER               "
_DISPLAY
_SNDPLAY DS&
_DELAY _SNDLEN(DS&) + 0.1
_PRINTSTRING (4, 96), "            Press any key...           "
_DISPLAY
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
SLEEP
IF DFL$ = " [ON MEDIUM]" THEN SCORE = SCORE + 75
IF DFL$ = " [ON HARD]" THEN SCORE = SCORE + 150
IF HSCHK(SCORE) <> 0 THEN
    CLS
    _PRINTSTRING (4, 80), "               GAME OVER               "
    _DISPLAY
    LOCATE 7, 12
    _KEYCLEAR
    INPUT "NAME?: ", NAME$
    'IF
    HSSAVE HSCHK(SCORE), NAME$, SCORE, DFL$
END IF
CHDIR ".."
CHDIR "SAVE"
OPEN "HS.DAT" FOR INPUT AS #1
DO WHILE NOT EOF(1)
    INPUT #1, HS1, HS2, HS3, HSN1$, HSN2$, HSN3$, DFL1$, DFL2$, DFL3$
LOOP
CLOSE #1
CLS
COLOR _RGB32(255, 255, 0)
LOCATE 5, 6: PRINT "HIGH SCORES"
COLOR _RGB32(0, 0, 255)
IF HS1 = 0 THEN
    LOCATE 6, 6: PRINT "< empty >"
ELSE
    IF LEN(HSN1$) > 10 THEN HSN1$ = LEFT$(HSN1$, 10) + "..."
    IF DFL1$ = " [ON MEDIUM]" THEN HS1 = HS1 - 75
    IF DFL1$ = " [ON HARD]" THEN HS1 = HS1 - 150
    LOCATE 6, 6: PRINT HSN1$; ": "; HS1; DFL1$;
END IF
COLOR _RGB32(0, 255, 0)
IF HS2 = 0 THEN
    LOCATE 7, 6: PRINT "< empty >"
ELSE
    IF LEN(HSN2$) > 10 THEN HSN2$ = LEFT$(HSN2$, 10) + "..."
    IF DFL2$ = " [ON MEDIUM]" THEN HS2 = HS2 - 75
    IF DFL2$ = " [ON HARD]" THEN HS2 = HS2 - 150
    LOCATE 7, 6: PRINT HSN2$; ": "; HS2; DFL2$;
END IF
COLOR _RGB32(255, 0, 0)
IF HS3 = 0 THEN
    LOCATE 8, 6: PRINT "< empty >"
ELSE
    IF LEN(HSN3$) > 10 THEN HSN3$ = LEFT$(HSN3$, 10) + "..."
    IF DFL3$ = " [ON MEDIUM]" THEN HS3 = HS3 - 75
    IF DFL3$ = " [ON HARD]" THEN HS3 = HS3 - 150
    LOCATE 8, 6: PRINT HSN3$; ": "; HS3; DFL3$;
END IF
_DISPLAY
_KEYCLEAR
SLEEP
CHDIR ".."
SCREEN , , 0, 1
CLEAR
DIED = 1
GOTO START
BOSSF:
_SNDSTOP GM&
LOADSPR 14, "B0"
SETSPR 14, 303, 94
LOADSPR 15, "BL"
SETSPR 15, 320, 0
SCREEN , , 1, 1
CLS
_PRINTMODE _KEEPBACKGROUND
COLOR _RGB32(191, 0, 0)
_PRINTSTRING (4, 80), "              BOSS FIGHT!              "
_DISPLAY
SCREEN , , 0, 1
LC = 0
DO
    AX(LC) = -17
    AY(LC) = 92
    AD(LC) = CINT(RND * 2) + 4
    LC = LC + 1
LOOP UNTIL LC > 99
LC = 0
DO
    LZRPX(LC) = 340
    LZRPY(LC) = 0
    LC = LC + 1
    IF LC > 99 THEN EXIT DO
LOOP
DIM SHARED LZRBPX(0 TO 99)
DIM SHARED LZRBPY(0 TO 99)
LC = 0
DO
    LZRBPX(LC) = -17
    LZRBPY(LC) = 0
    LC = LC + 1
    IF LC > 99 THEN EXIT DO
LOOP
SSMV = 0
SSMX = 0
BF& = _SNDOPEN("SLBF")
_SNDPLAYFILE "SLBI"
_DELAY 1.99
_SNDPLAY BF&
_SNDLOOP BF&
BHP = 100
THP = HP
SETSPR 2, 12, 90
DO
    _LIMIT LV
    BGPOS = BGPOS - 0.5
    IF BGPOS < -319 THEN BGPOS = 0
    CLNSPR 0, BGPOS, 0, 1
    CLNSPR 0, BGPOS + 320, 0, 1
    SCREEN , , 1, 1
    _PRINTMODE _KEEPBACKGROUND
    _FONT 8
    LOCATE 1, 6
    PRINT "HEALTH:"; HP;
    LOCATE 2, 2
    PRINT "BOSS HEALTH:"; BHP;
    LOCATE 1, 20
    PRINT "SCORE:"; SCORE;
    _FONT 16
    SCREEN , , 0, 1
    SSMV = 0
    SSMX = 0
    IF _KEYDOWN(18432) THEN SSMV = 1
    IF _KEYDOWN(20480) THEN SSMV = -1
    IF _KEYDOWN(19712) THEN SSMX = 1
    IF _KEYDOWN(19200) THEN SSMX = -1
    IF SSMV = 1 AND SPRY1P(2) > 0 THEN MOVESPR 2, 0, -1 ': SY = SY - 1
    IF SSMV = -1 AND SPRY1P(2) < 190 THEN MOVESPR 2, 0, 1 ': SY = SY + 1
    IF SSMX = 1 AND SPRX1P(2) < 276 THEN MOVESPR 2, 1, 0
    IF SSMX = -1 AND SPRX1P(2) > 12 THEN MOVESPR 2, -1, 0
    _KEYCLEAR
    IF CINT(RND * (32 * DLVL)) = 0 THEN
        LZRBPX(ASPWN) = SPRX1P(14) - 1
        LZRBPY(ASPWN) = SPRY1P(14) + 7
        AMX(ASPWN) = RND * 0.01
        AMY(ASPWN) = RND * 0.5 - 0.25
        ASPWN = ASPWN + 1
        IF ASPWN > 99 THEN ASPWN = 0
    END IF
    R1 = CINT(RND * 10000 * DLVL)
    IF R1 < 6 THEN
        IF SPRX1P(R1 + 7) < -16 THEN
            SETSPR R1 + 7, 320, CINT(RND * 183)
        END IF
    END IF
    IF SCORE > 99 AND SCORE < 1000 THEN BLTSPD = 33
    IF SCORE > 999 THEN BLTSPD = 11
    IF INP(&H60) = 57 AND BWT > BLTSPD - 1 THEN
        IF WTS = 0 THEN
            LZRTD(LZRN) = 0
            _SNDPLAY SS&
            '_KEYCLEAR
            WTS = 1
            BWT = 0
            IF BSV = 1 THEN
                BSV = 0
            ELSE
                BSV = 1
            END IF
            IF BSV = 0 THEN LZRPY(LZRN) = SPRY1P(2) + 1
            IF BSV = 1 THEN LZRPY(LZRN) = SPRY1P(2) + 6
            LZRPX(LZRN) = SPRX1P(2) + 8
            LZRN = LZRN + 1
            IF LZRN > 99 THEN LZRN = 0
        END IF
    END IF
    IF INP(&H60) = 185 THEN WTS = 0
    IF INP(&H60) = 19 AND BWT > BLTSPD - 1 THEN
        IF RKT > 0 THEN
            IF WTS = 0 THEN
                LZRTD(LZRN) = 1: RKT = RKT - 1
                _SNDPLAY RS&
                '_KEYCLEAR
                WTS = 1
                BWT = 0
                LZRPY(LZRN) = SPRY1P(2) + 2
                LZRPX(LZRN) = SPRX1P(2) + 8
                LZRN = LZRN + 1
                IF LZRN > 99 THEN LZRN = 0
            END IF
        END IF
    END IF
    IF INP(&H60) = 147 THEN WTS = 0
    IF BWT < BLTSPD THEN BWT = BWT + 1
    LC = 0
    DO
        LC2 = 0
        DO
            IF LZRPX(LC) > SPRX1P(14) AND LZRPX(LC) < SPRX1P(14) + 14 OR LZRPX(LC) + 13 > SPRX1P(14) AND LZRPX(LC) + 13 < SPRX1P(14) + 14 THEN
                IF LZRPY(LC) > SPRY1P(14) AND LZRPY(LC) < SPRY1P(14) + 15 OR LZRPY(LC) + 2 > SPRY1P(14) AND LZRPY(LC) + 2 < SPRY1P(14) + 15 THEN
                    _SNDPLAY AHN&
                    LZRPX(LC) = 339
                    LZRPX(LC2) = 321
                    BHP = BHP - (DLVL * 5)
                    IF LZRTD(LC) = 1 THEN BHP = BHP - (DLVL * 5)
                END IF
            END IF
            IF SPRX1P(2) > LZRBPX(LC2) AND SPRX1P(2) < LZRBPX(LC2) + 13 OR SPRX1P(2) + 13 > LZRBPX(LC2) AND SPRX1P(2) + 13 < LZRBPX(LC2) + 13 THEN
                IF SPRY1P(2) > LZRBPY(LC2) AND SPRY1P(2) < LZRBPY(LC2) + 2 OR SPRY1P(2) + 13 > LZRBPY(LC2) AND SPRY1P(2) + 13 < LZRBPY(LC2) + 13 THEN
                    _SNDPLAY HS&
                    HP = HP - CINT(ADMG)
                    IF ADMG < 10 THEN ADMG = ADMG * 1.25
                    IF ADMG > 10 THEN ADMG = 10
                    LZRBPX(LC2) = -17
                END IF
            END IF
            LC2 = LC2 + 1
        LOOP UNTIL LC2 > 99
        IF LZRPX(LC) < 339 THEN
            IF LZRTD(LC) = 1 THEN
                LZRPX(LC) = LZRPX(LC) + 0.5
                CLNSPR 13, LZRPX(LC), LZRPY(LC), 1
            ELSE
                LZRPX(LC) = LZRPX(LC) + 2
                CLNSPR 3, LZRPX(LC), LZRPY(LC), 1
            END IF
        END IF
        LC = LC + 1
        IF LC > 99 THEN EXIT DO
    LOOP
    LC2 = 0
    DO
        IF SPRX1P(2) > SPRX1P(LC2 + 7) AND SPRX1P(2) < SPRX1P(LC2 + 7) + 15 OR SPRX1P(2) + 13 > SPRX1P(LC2 + 7) AND SPRX1P(2) + 13 < SPRX1P(LC2 + 7) + 15 THEN
            IF SPRY1P(2) > SPRY1P(LC2 + 7) AND SPRY1P(2) < SPRY1P(LC2 + 7) + 15 OR SPRY1P(2) + 13 > SPRY1P(LC2 + 7) AND SPRY1P(2) + 13 < SPRY1P(LC2 + 7) + 15 THEN
                _SNDPLAYFILE "SLPS"
                IF LC2 = 0 THEN RKT = RKT + 1
                IF LC2 = 1 THEN RKT = RKT + 2
                IF LC2 = 2 THEN HP = HP + 50
                IF LC2 = 3 THEN IF HP < 100 THEN HP = 100
                IF LC2 = 4 THEN ADMG = ADMG / 2
                IF LC2 = 5 THEN SCORE = SCORE + CINT(RND * 5) + 10
                SETSPR LC2 + 7, -17, SPRY1P(LC2)
            END IF
        END IF
        LC2 = LC2 + 1
    LOOP UNTIL LC2 > 5
    IF CINT(RND * 15) = 0 THEN R2& = CINT(RND * 30000) - 16600
    IF R2& < -1000 AND SPRY1P(14) < 165 THEN MOVESPR 14, 0, 1
    IF R2& > 1000 AND SPRY1P(14) > 0 THEN MOVESPR 14, 0, -1
    IF INP(&H60) = 1 THEN
        _SNDPAUSE BF&
        M = 1
        GOSUB QUIT
        IF _SNDPLAYING(BF&) = 0 THEN _SNDPLAY BF&
    END IF
    IF _SNDPLAYING(BF&) = 0 THEN _SNDPLAY BF&
    MOVESPR 7, -0.25, 0
    MOVESPR 8, -0.25, 0
    MOVESPR 9, -0.25, 0
    MOVESPR 10, -0.25, 0
    MOVESPR 11, -0.25, 0
    MOVESPR 12, -0.25, 0
    MOVESPR 14, 0, BM
    IF FS = FSV THEN
        LC = 0
        DO
            IF LZRBPX(LC) > -17 THEN CLNSPR 15, LZRBPX(LC), LZRBPY(LC), 1: LZRBPX(LC) = LZRBPX(LC) - 2 - AMX(LC): LZRBPY(LC) = LZRBPY(LC) + AMY(LC)
            LC = LC + 1
        LOOP UNTIL LC > 98
        PUTSPR 2, 1
        PUTSPR 7, 1
        PUTSPR 8, 1
        PUTSPR 9, 1
        PUTSPR 10, 1
        PUTSPR 11, 1
        PUTSPR 12, 1
        PUTSPR 14, 1
        _DISPLAY
        FS = -1
    END IF
    IF BHP < 1 THEN
        _SNDSTOP BF&
        SCREEN , , 1, 1
        CLS
        CLNSPR 0, BGPOS, 0, 1
        CLNSPR 0, BGPOS + 320, 0, 1
        SCREEN , , 1, 1
        _PRINTMODE _KEEPBACKGROUND
        _FONT 8
        LOCATE 1, 6
        PRINT "HEALTH:"; HP;
        LOCATE 1, 20
        PRINT "SCORE:"; SCORE;
        _FONT 16
        SCREEN , , 1, 1
        _DISPLAY
        _PRINTMODE _KEEPBACKGROUND
        COLOR _RGB32(0, 191, 0)
        _PRINTSTRING (4, 80), "                YOU WIN!               "
        _DISPLAY
        BWLS& = _SNDOPEN("SLBW")
        _SNDPLAY BWLS&
        _DELAY _SNDLEN(BWLS&) + 0.1
        _SNDCLOSE BWLS&
        _PRINTSTRING (4, 96), "            Press any key...           "
        _DISPLAY
        SLEEP
        SCORE = SCORE + (50 * DLVL)
        _SNDPLAY GM&
        EXIT DO
    END IF
    IF HP < 1 THEN
        _SNDSTOP BF&
        SCREEN , , 1, 1
        CLS
        CLNSPR 0, BGPOS, 0, 1
        CLNSPR 0, BGPOS + 320, 0, 1
        SCREEN , , 1, 1
        _PRINTMODE _KEEPBACKGROUND
        _FONT 8
        LOCATE 1, 6
        PRINT "HEALTH:"; HP;
        LOCATE 1, 20
        PRINT "SCORE:"; SCORE;
        _FONT 16
        SCREEN , , 1, 1
        _DISPLAY
        _PRINTMODE _KEEPBACKGROUND
        COLOR _RGB32(191, 0, 0)
        _PRINTSTRING (4, 80), "                YOU LOSE               "
        _DISPLAY
        BWLS& = _SNDOPEN("SLBL")
        _SNDPLAY BWLS&
        _DELAY _SNDLEN(BWLS&) + 0.1
        _SNDCLOSE BWLS&
        _PRINTSTRING (4, 96), "            Press any key...           "
        _DISPLAY
        SLEEP
        _SNDPLAY GM&
        EXIT DO
    END IF
    FS = FS + 1
LOOP
LC = 0
DO
    LZRPX(LC) = 340
    LZRPY(LC) = 0
    LC = LC + 1
    IF LC > 99 THEN EXIT DO
LOOP
ERASE LZRBPX
ERASE LZRBPY
SETSPR 2, 12, 90
DELSPR 14
DELSPR 15
SSMV = 0
SSMX = 0
HP = THP
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
_KEYCLEAR
RETURN

'SUBS

'$INCLUDE: 'LIB\SPRLIB.BI'
FUNCTION HSCHK (S)
    HSCHK = 0
    CHDIR ".."
    CHDIR "SAVE"
    OPEN "HS.DAT" FOR INPUT AS #1
    DO WHILE NOT EOF(1)
        INPUT #1, HSD1, HSD2, HSD3, HSN1$, HSN2$, HSN3$, DF1$, DF2$, DF3$
    LOOP
    CLOSE #1
    IF S > HSD1 AND HSCHK = 0 THEN
        HSCHK = 1
    END IF
    IF S > HSD2 AND HSCHK = 0 THEN
        HSCHK = 2
    END IF
    IF S > HSD3 AND HSCHK = 0 THEN
        HSCHK = 3
    END IF
    CHDIR ".."
    CHDIR "DATA"
END SUB
SUB HSSAVE (P, N$, S, DF$)
    CHDIR ".."
    CHDIR "SAVE"
    OPEN "HS.DAT" FOR INPUT AS #1
    DO WHILE NOT EOF(1)
        INPUT #1, HSD1, HSD2, HSD3, HSN1$, HSN2$, HSN3$, DF1$, DF2$, DF3$
    LOOP
    CLOSE #1
    IF P = 1 THEN
        HSD3 = HSD2
        HSN3$ = HSN2$
        DF3$ = DF2$
        HSD2 = HSD1
        HSN2$ = HSN1$
        DF2$ = DF1$
        HSD1 = S
        HSN1$ = N$
        DF1$ = DF$
    END IF
    IF P = 2 THEN
        HSD3 = HSD2
        HSN3$ = HSN2$
        DF3$ = DF2$
        HSD2 = S
        HSN2$ = N$
        DF2$ = DF$
    END IF
    IF P = 3 THEN
        HSD3 = S
        HSN3$ = N$
        DF3$ = DF$
    END IF
    OPEN "HS.DAT" FOR OUTPUT AS #2
    WRITE #2, HSD1, HSD2, HSD3, HSN1$, HSN2$, HSN3$, DF1$, DF2$, DF3$
    CLOSE #2
    CHDIR ".."
    CHDIR "DATA"
END SUB

