-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmenukeys.bas
96 lines (74 loc) · 2.96 KB
/
menukeys.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
REM ***********************************************************************************************************
REM * Menukeys.Bas XC=BASIC Module V3.X
REM *
REM * Simple MENU routine.
REM *
REM * (c)sadLogic and all of Humankind - Use as you see fit Jan 2022
REM *
REM * Updated to get around some string bugs JakeBullet Mar-29-2022 Watch RU soldiers driving stolen cars...
REM ***********************************************************************************************************
'Include "strings.bas"
'Include "colors.bas"
CONST TRUE = 255 : CONST FALSE = 0
DECLARE SUB mnuInit(xLeft AS BYTE ,xTop AS BYTE , NormalColor as BYTE, HilightColor AS BYTE ) STATIC SHARED
DECLARE SUB mnuAddItem(menuStr as STRING * 39, HilightLetter as STRING * 1) STATIC SHARED
DECLARE SUB mnuAddItemRev(menuStr AS STRING * 39, HilightLetter as STRING * 1 ) STATIC SHARED
DECLARE SUB mnuAddItemSpacer() STATIC SHARED
DECLARE FUNCTION mnuGetKey AS BYTE () STATIC SHARED
DECLARE SUB mnuAddToKeyTrap(xKey AS STRING * 1) STATIC SHARED
DIM mLeft AS BYTE
DIM mNormalClr AS BYTE
DIM mHilightClr AS BYTE
DIM mKeys AS STRING * 40
DIM mCurrrentRow AS BYTE
DIM mTMP AS BYTE
SUB mnuInit(xLeft AS BYTE ,xTop AS BYTE , NormalColor as BYTE, HilightColor AS BYTE ) STATIC SHARED
mLeft = xLeft
mKeys = ""
mNormalClr = NormalColor
mHilightClr = HilightColor
mCurrrentRow = xTop
END SUB
SUB mnuAddItemSpacer() STATIC SHARED SHARED
mCurrrentRow = mCurrrentRow + 1
END SUB
SUB mnuAddToKeyTrap(xKey AS STRING * 1) STATIC SHARED
CONST KEY_9 = 57
CONST KEY_0 = 48
mTMP = ASC(xKey)
IF mTMP >= KEY_0 AND mTMP <= KEY_9 THEN
REM -- Numeric, add once
mKeys = mKeys + xKey
RETURN
END IF
REM -- AlphaNumeric, trap both
mKeys = mKeys + UCASE$(xKey) + LCASE$(xKey)
END SUB
SUB mnuAddItem(menuStr as string * 39, HilightLetter as string * 1 ) STATIC SHARED
TEXTAT mLeft, mCurrrentRow, menuStr, mNormalClr
IF LEN(HilightLetter) = 1 THEN
TEXTAT mLeft + strInstr(menuStr,HilightLetter) - 1, mCurrrentRow, HilightLetter, mHilightClr
CALL mnuAddToKeyTrap(HilightLetter)
END IF
mCurrrentRow = mCurrrentRow + 1
END SUB
SUB mnuAddItemRev(menuStr as string * 39, HilightLetter as string * 1 ) STATIC SHARED
TEXTAT mLeft, mCurrrentRow, menuStr, mNormalClr
IF LEN(HilightLetter) = 1 THEN
LOCATE mLeft + strInstr(menuStr,HilightLetter) - 1, mCurrrentRow
PRINT "{REV_ON}" + HilightLetter + "{REV_OFF}" ; : REM '--- Same as TEXTAT except respects PET codes
CALL mnuAddToKeyTrap(HilightLetter)
END IF
mCurrrentRow = mCurrrentRow + 1
END SUB
FUNCTION mnuGetKey AS BYTE () STATIC SHARED
mnuDoAgain:
mTMP = 0
DO
GET mTMP
LOOP UNTIL mTMP > 0
'POKE 54296,15 : POKE 54296,0 : rem make a click sound
'CALL scrn_DebugTextBtm(str$(aa))
IF strInstr(mKeys, CHR$(mTMP)) = 0 THEN GOTO mnuDoAgain
RETURN mTMP
END FUNCTION