Hmm, not sure why it froze up. Those remaining bat wings might be a clue as to some infrequent bug.
As for the wanting to just include 2 initials, just replace the existing displayhighscores sub with this slightly modified one. I set a new inmax variable to "2" for two initials. See it near the top of the displayhighscores sub. You can also change the value from "2" to 1 or 3 for one or three initials.
Pete
As for the wanting to just include 2 initials, just replace the existing displayhighscores sub with this slightly modified one. I set a new inmax variable to "2" for two initials. See it near the top of the displayhighscores sub. You can also change the value from "2" to 1 or 3 for one or three initials.
Code: (Select All)
SUB displayhighscores
inmax = 2 ' Change to 1, 2 or 3 determine how many initils you want to enter for high score.
IF inmax < 1 OR inmax > 3 THEN imax = 3
COLOR 0, 3
LOCATE 25, 68: PRINT "Score "; score$;
DIM hs AS STRING * 25
REDIM highscore$(6), hsdata$(6)
DO
IF _FILEEXISTS("ascii-invaders-high-score.dat") THEN
OPEN "ascii-invaders-high-score.dat" FOR RANDOM AS #1 LEN = 25
FOR i = 1 TO 5
GET #1, i, hs
highscore$(i) = MID$(hs, 10, 6): hsdata$(i) = hs
NEXT
CLOSE #1
ELSE
FOR i = 1 TO 5
hsdata$(i) = SPACE$(25)
NEXT
END IF
IF VAL(score$) > VAL(highscore$(5)) THEN
IF VAL(score$) > VAL(highscore$(1)) THEN
msg$ = " HIGH SCORE / Enter Your Initials! "
ELSE
msg$ = " Top 5 Score. Enter Your Initials! "
END IF
GOSUB hiscore
a = 14
OUT &H3C8, 0
OUT &H3C9, 20 - a
OUT &H3C9, 20 - a
OUT &H3C9, 20 - a
OUT &H3C8, 8
OUT &H3C9, 30 - a
OUT &H3C9, 30 - a
OUT &H3C9, 30 - a
OUT &H3C8, 7
OUT &H3C9, 30 - a
OUT &H3C9, 30 - a
OUT &H3C9, 30 - a
OUT &H3C8, 3
OUT &H3C9, 30 - a
OUT &H3C9, 30 - a
OUT &H3C9, 30 - a
GOSUB hardware_overlay
_FONT 16
COLOR White, 0
t$ = msg$
PSLC 4.6, 41 - LEN(msg$) \ 2, t$
font = _LOADFONT("lucon.ttf", 20, "monospace")
IF font <= 0 THEN font = 16
_FONT font
DEF SEG = 0
delay = .4
lscr = 19
z3 = TIMER
DO
initials$ = "": i = 0: nxt = 0
COLOR , _RGB(24, 24, 24): t$ = " " ' Blank initials for redo. Okay to blank at start.
PSL 5 + rank * 2, lscr, t$
_DISPLAY
DO
_LIMIT 60
IF ABS(z3 - TIMER) > .3 AND kflag > -2 THEN
underline 5 + rank * 2, lscr + nxt, 0
_DISPLAY
z3 = TIMER
END IF
SELECT CASE kflag
CASE 0
IF ABS(z1 - TIMER) > 1.5 AND i AND nxt < 3 THEN
SOUND 1500, 1
underline 5 + rank * 2, lscr + nxt, -1: uflag = 0
_DISPLAY
initials$ = initials$ + CHR$(64 + i)
nxt = nxt + 1 ' Next initial
i = 0 ' Reset alphabet.
z1 = TIMER
IF nxt = inmax THEN
kflag = -2 ' All initials have been input.
underline 5 + rank * 2, lscr + nxt, -1: uflag = 0
_DISPLAY
END IF
END IF
IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
kflag = -1 ' Alt key pressed.
z1 = TIMER: z2 = TIMER
i = i + 1: IF i > 26 THEN i = 1
COLOR , _RGB(24, 24, 24): t$ = " "
PSL 5 + rank * 2, lscr + nxt, t$
COLOR DarkOrange: t$ = CHR$(64 + i)
SOUND 1000, .1
PSL 5 + rank * 2, lscr + nxt, t$
underline 5 + rank * 2, lscr + nxt, 0
_DISPLAY
END IF
CASE -1
IF ABS(z2 - TIMER) > 2 THEN ' Key down long enough to indicate redo input.
IF nxt > 0 THEN ' Redo last initial input.
SOUND 300, .5
FOR nxt = 0 TO 3
underline 5 + rank * 2, lscr + nxt, -1: uflag = 0
NEXT
nxt = 0: i = 0
initials$ = ""
COLOR , _RGB(24, 24, 24): t$ = " "
PSL 5 + rank * 2, lscr, t$
_DISPLAY
z1 = TIMER ' Reset enter timer.
ELSE
SOUND 300, .5
i = 0
COLOR , _RGB(24, 24, 24): t$ = " "
PSL 5 + rank * 2, lscr, t$
_DISPLAY
z1 = TIMER ' Reset enter timer.
END IF
z2 = TIMER
END IF
IF PEEK(1047) MOD 16 <> 7 AND PEEK(1047) MOD 16 <> 8 THEN ' Alt key was released.
kflag = 0 ' Alt key up
z1 = TIMER
END IF
CASE -2 ' Finished. Initials will flash until confirmed by 2-second timer.
z1 = TIMER: z2 = TIMER
j = 0
DO
IF ABS(z1 - TIMER) > .3 THEN j = -j - 1: z1 = TIMER
IF j THEN
COLOR DarkOrange: t$ = initials$
PSL 5 + rank * 2, lscr, t$
_DISPLAY
ELSE
COLOR _RGB(24, 24, 24): t$ = initials$
PSL 5 + rank * 2, lscr, t$
_DISPLAY
END IF
IF ABS(z2 - TIMER) > 2.5 AND j THEN
kflag = -3
EXIT DO
END IF
IF PEEK(1047) MOD 16 = 7 OR PEEK(1047) MOD 16 = 8 THEN
BEEP
kflag = -4
EXIT DO
END IF
LOOP
CASE -3
_DELAY 1
l$ = "8"
n$ = "n24": PLAY "L" + l$ + n$
n$ = "n28": PLAY "L" + l$ + n$
n$ = "n28": PLAY "L" + l$ + n$
l$ = "7"
n$ = "n31": PLAY "L" + l$ + n$
l$ = "9"
n$ = "n28": PLAY "L" + l$ + n$
l$ = "3"
n$ = "n31": PLAY "L" + l$ + n$
kflag = 1
_DELAY 1: EXIT DO
CASE -4
kflag = 0 ' Repeat enter initials
nxt = 0
i = 0
EXIT DO
END SELECT
LOOP
IF kflag > 0 THEN kflag = 0: EXIT DO ' Exit routine.
LOOP
DEF SEG
hsname$ = initials$
MID$(hsdata$(rank), 5, 3) = hsname$ + SPACE$(3 - LEN(hsname$))
OPEN "ascii-invaders-high-score.dat" FOR RANDOM AS #1 LEN = 25
FOR i = 1 TO 5
hs = hsdata$(i)
IF LEFT$(hs, 1) = "" THEN MID$(hs, 1, 2) = "0" + LTRIM$(STR$(i))
PUT #1, i, hs
NEXT
CLOSE #1
_DELAY 1
_DISPLAY ' Remove scoreboard.
_DELAY 1
_FREEIMAGE Overlay
_FONT 16 'select inbuilt 8x16 default font
_FREEFONT font
_DEST 0 'Reset dest back to the normal screen 0.
_AUTODISPLAY
COLOR 6, 0
msg$ = SPACE$(40)
LOCATE 4, 41 - LEN(msg$) \ 2
PRINT msg$;
PALETTE
_DELAY 1
EXIT DO
ELSE
EXIT DO ' Not in the top 5 highest scores so exit sub.
END IF
LOOP
EXIT SUB
hardware_overlay:
Overlay = _NEWIMAGE(_WIDTH * _FONTWIDTH, _HEIGHT * _FONTHEIGHT, 32)
_DEST Overlay
_DISPLAY ' Turn autodisplay off.
font = _LOADFONT("lucon.ttf", 20, "monospace")
IF font <= 0 THEN font = 16
_FONT font
bxy% = 3
bxx% = 13
COLOR DarkOrange, 0
t$ = " " + CHR$(218) + STRING$(27, CHR$(196)) + CHR$(191) + " "
PSL bxy%, bxx% - 1, t$
FOR i = 1 TO 12
t$ = " " + CHR$(179) + STRING$(27, CHR$(32)) + CHR$(179) + " "
PSL bxy% + i, bxx% - 1, t$
NEXT
t$ = " " + CHR$(192) + STRING$(27, CHR$(196)) + CHR$(217) + " "
PSL bxy% + i, bxx% - 1, t$
bxy% = 4
COLOR Black, DarkOrange
t$ = " NAME SCORE DATE "
PSL bxy% + 1, bxx% + 1, t$
COLOR DarkOrange, 0
FOR i = 1 TO 5
t$ = hsdata$(i)
PSL bxy% + 1 + i * 2, bxx% + 2, t$
NEXT
_DISPLAY
RETURN
hiscore:
FOR i = 1 TO 5
IF VAL(score$) > VAL(highscore$(i)) THEN rank = i: EXIT FOR
NEXT
hsdata$(6) = SPACE$(25)
MID$(hsdata$(6), 10, 6) = score$
MID$(hsdata$(6), 18, 8) = MID$(DATE$, 1, 6) + MID$(DATE$, 9, 2)
highscore$(6) = score$
FOR i = 1 TO 6
FOR j = 1 TO 6
IF i <> j THEN
IF VAL(highscore$(i)) > VAL(highscore$(j)) THEN
SWAP highscore$(i), highscore$(j)
SWAP hsdata$(i), hsdata$(j)
END IF
END IF
NEXT
NEXT
FOR i = 1 TO 5
MID$(hsdata$(i), 1, 2) = "0" + LTRIM$(STR$(i))
NEXT
RETURN
END SUB
Pete