Skip to content

Commit 416c69a

Browse files
Merge pull request #6 from Ripjetski6502/dev
merging menus into wmenu, rework code to use const for window count
2 parents d52426b + 037e8ff commit 416c69a

File tree

8 files changed

+51
-157
lines changed

8 files changed

+51
-157
lines changed

bin/fullappdemo.xex

-367 Bytes
Binary file not shown.

src/a8defines.pas

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface
1414

1515
const
1616
// Version
17-
LIB_VERSION = '1.1.3';
17+
LIB_VERSION = '1.2.0';
1818

1919
// Window Record and Memory Alloc
2020
WRECSZ = 10;
@@ -56,41 +56,41 @@ interface
5656
XNONE = 255;
5757

5858
// OS Registers
59-
DMACTL = 559;
60-
COLDST = 580;
61-
GPRIOR = 623;
59+
// DMACTL = 559;
60+
// COLDST = 580;
61+
// GPRIOR = 623;
6262
INVFLG = 694;
6363
SHFLOK = 702;
6464
HELPFG = 732;
6565
KEYPCH = 764;
66-
GRACTL = 53277;
66+
// GRACTL = 53277;
6767
CONSOL = 53279;
68-
PMBASE = 54279;
68+
// PMBASE = 54279;
6969

7070
// PM Registers
71-
HPOSP0 = 53248;
72-
HPOSP1 = 53249;
73-
HPOSP2 = 53250;
71+
// HPOSP0 = 53248;
72+
// HPOSP1 = 53249;
73+
// HPOSP2 = 53250;
7474

7575
// Screen Bits
7676
ALMARG = 82;
7777
RSCRN = 88;
78-
PCOLR0 = 704;
79-
PCOLR1 = 705;
80-
PCOLR2 = 706;
81-
PCOLR3 = 707;
82-
AFOREG = 709;
83-
ABACKG = 710;
84-
ABORDR = 712;
78+
// PCOLR0 = 704;
79+
// PCOLR1 = 705;
80+
// PCOLR2 = 706;
81+
// PCOLR3 = 707;
82+
// AFOREG = 709;
83+
// ABACKG = 710;
84+
// ABORDR = 712;
8585
ACURIN = 752;
8686

8787
// Colors
88-
CBLACK = 0;
89-
CWHITE = 14;
90-
CGREEN = 210;
91-
CBLUE = 146;
92-
CRED = 50;
93-
CYELLOW = 222;
88+
// CBLACK = 0;
89+
// CWHITE = 14;
90+
// CGREEN = 210;
91+
// CBLUE = 146;
92+
// CRED = 50;
93+
// CYELLOW = 222;
9494

9595
// Keystroke Values
9696
KNOMAP = 199;

src/a8defwin.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ interface
1717
type
1818
// Window handle info
1919
td_wnrec = record
20-
bU, bX, bY, bW, bH, bI: array[0..10] of Byte;
21-
cM: array[0..10] of ^Byte;
22-
cZ: array[0..10] of Word;
20+
bU, bX, bY, bW, bH, bI: array[0..WRECSZ] of Byte;
21+
cM: array[0..WRECSZ] of ^Byte;
22+
cZ: array[0..WRECSZ] of Word;
2323
end;
2424

2525
// Window position - virtual cursor

src/a8libgadg.pas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ function GCombo(bN, x, y, bE, bI, bS: Byte; pS: TStringArray): Byte;
651651
// calculating position based on parent window
652652
bZ:=WOpen(baW.bX[bN] + x - 1, baW.bY[bN] + y + 1, bL + 2, bS + 2, WOFF);
653653

654-
bC:=MenuV(bZ, 1, 1, WON, bC, bS, pS);
654+
bC:=WMenu(bZ, 1, 1, GVERT, WON, bC, bS, pS);
655655
WClose(bZ);
656656
bM := true;
657657

src/a8libmenu.pas

Lines changed: 17 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// a8libstr.pas
1111
// a8libmisc.pas
1212
// Revised:
13-
// - Added MenuH to draw menu horizontally
13+
// - Merged MenuH and MenuV to single routine WMenu
1414
// --------------------------------------------------
1515

1616
unit a8libmenu;
@@ -27,131 +27,14 @@ interface
2727
// --------------------------------------------------
2828
// Function Prototypes
2929
// --------------------------------------------------
30-
function MenuV(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte;
31-
function MenuH(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte;
30+
function WMenu(bN, x, y, bO, bI, bS, bC: Byte; pS: TStringArray): Byte;
3231

3332
implementation
3433

3534
uses
3635
a8libwin, a8libmisc;
3736

38-
// ------------------------------------------------------------
39-
// Func...: MenuV(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte
40-
// Desc...: Vertical menu
41-
// Param..: bN = Window handle number
42-
// x = window column for cursor
43-
// y = window row for cursor
44-
// bI = Inverse flag (WON = leave on at selection)
45-
// bS = Start item number
46-
// bC = Number of menu items
47-
// pS = pointer to array of menu item strings
48-
// Return.: Selected item #, ESC (XESC), or TAB (XTAB)
49-
// ------------------------------------------------------------
50-
function MenuV(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte;
51-
var
52-
bF: Boolean;
53-
bL, bK, tmp: Byte;
54-
cL: string[39]; // 40 - 1
55-
tmpStr: string[39];
56-
begin
57-
bF := false;
58-
59-
// Set default return to start item #
60-
Result := bS;
61-
62-
// Continue until finished
63-
while not bF do
64-
begin
65-
// Display each item
66-
for bL := 0 to bC - 1 do
67-
begin
68-
tmpStr := pS[bL];
69-
SetLength(cL, Length(tmpStr));
70-
Move(@tmpStr[1], @cL[1], Length(cL));
71-
72-
// Display item at row count - inverse if start item
73-
if bL + 1 = Result then
74-
begin
75-
tmp := WON;
76-
end
77-
else begin
78-
tmp := WOFF;
79-
end;
80-
WPrint(bN, x, y + bL, tmp, cL);
81-
end;
82-
83-
// Get key (no inverse key)
84-
bK := WaitKCX(WOFF);
85-
86-
// Process key
87-
if (bK = KDOWN) or (bK = KEQUAL) or (bK = KRIGHT) or (bK = KASTER) then
88-
begin
89-
// Increment (move down list)
90-
Inc(Result);
91-
92-
// Check for overrun and roll to top
93-
if Result > bC then
94-
begin
95-
Result := 1;
96-
end;
97-
end
98-
else if (bK = KUP) or (bK = KMINUS) or (bK = KLEFT) or (bK = KPLUS) then
99-
begin
100-
// Decrement (move up list)
101-
Dec(Result);
102-
103-
// Check for underrun and roll to bottom
104-
if Result < 1 then
105-
begin
106-
Result := bC;
107-
end;
108-
end;
109-
110-
// Set last selected item before checking for ESC/TAB/ENTER
111-
bL := Result;
112-
113-
// If ESC, set choice to XESC
114-
if bK = KESC then
115-
begin
116-
Result := XESC;
117-
bF := true;
118-
end
119-
// For TAB, set choice to XTAB
120-
else if bK = KTAB then
121-
begin
122-
Result := XTAB;
123-
bF := true;
124-
end
125-
// For enter, just exit
126-
else if bK = KENTER then
127-
begin
128-
bF := true;
129-
end;
130-
end;
131-
132-
// Uninverse last selection if needed
133-
if bI = WOFF then
134-
begin
135-
tmpStr := pS[bL - 1];
136-
SetLength(cL, Length(tmpStr));
137-
Move(@tmpStr[1], @cL[1], Length(cL));
138-
WPrint(bN, x, y + bL - 1, WOFF, cL);
139-
end;
140-
end;
141-
142-
// ------------------------------------------------------------
143-
// Func...: MenuH(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte
144-
// Desc...: Vertical menu
145-
// Param..: bN = Window handle number
146-
// x = window column for cursor
147-
// y = window row for cursor
148-
// bI = Inverse flag (WON = leave on at selection)
149-
// bS = Start item number
150-
// bC = Number of menu items
151-
// pS = pointer to array of menu item strings
152-
// Return.: Selected item #, ESC (XESC), or TAB (XTAB)
153-
// ------------------------------------------------------------
154-
function MenuH(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte;
37+
function WMenu(bN, x, y, bO, bI, bS, bC: Byte; pS: TStringArray): Byte;
15538
var
15639
bF: Boolean;
15740
bL, bK, tmp, l, pos: Byte;
@@ -182,8 +65,14 @@ function MenuH(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte;
18265
else begin
18366
tmp := WOFF;
18467
end;
185-
WPrint(bN, pos + bL, y, tmp, cL);
186-
pos:=pos + l;
68+
if bO = GHORZ then
69+
begin
70+
WPrint(bN, pos + bL, y, tmp, cL);
71+
pos:= pos + l;
72+
end
73+
else begin
74+
WPrint(bN, x, y + bL, tmp, cL);
75+
end;
18776
end;
18877

18978
// Get key (no inverse key)
@@ -241,7 +130,12 @@ function MenuH(bN, x, y, bI, bS, bC: Byte; pS: TStringArray): Byte;
241130
tmpStr := pS[bL - 1];
242131
SetLength(cL, Length(tmpStr));
243132
Move(@tmpStr[1], @cL[1], Length(cL));
244-
WPrint(bN, pos + bL - 1, y, WOFF, cL);
133+
134+
if bO = GHORZ then
135+
WPrint(bN, pos + bL - 1, y, WOFF, cL)
136+
else
137+
WPrint(bN, x, y + bL - 1, WOFF, cL);
245138
end;
246139
end;
140+
247141
end.

src/a8libwin.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ procedure WInit;
7373
cpWM := baWM;
7474

7575
// Work on 10 window+system handles
76-
for bL := 0 to 10 do
76+
for bL := 0 to WRECSZ do
7777
begin
7878
// Clear window handle record vars
7979
baW.bU[bL] := WOFF;
@@ -127,7 +127,7 @@ function WOpen(x, y, w, h, bT: Byte): Byte;
127127
Result := WENONE;
128128

129129
// Cycle through handles (exluding system)
130-
for bL := 0 to 10 do
130+
for bL := 0 to WRECSZ do
131131
begin
132132
// If handle is not in use
133133
if baW.bU[bL] = WOFF then

src/fullappdemo.pas

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ procedure SubMenu;
514514
while not bD do
515515
begin
516516
// Display menu and get choice
517-
bC := MenuV(bW1, 1, 1, WOFF, bC, 3, pcM);
517+
bC := WMenu(bW1, 1, 1, GVERT, WOFF, bC, 3, pcM);
518518

519519
// Process choice
520520
case bC of
@@ -550,7 +550,7 @@ procedure MainMenu;
550550
while not bD do
551551
begin
552552
// Display menu and get choice
553-
bC := MenuV(bW1, 1, 1, WON, bC, 4, pcM);
553+
bC := WMenu(bW1, 1, 1, GVERT, WON, bC, 4, pcM);
554554

555555
// Process choice
556556
case bC of
@@ -574,7 +574,7 @@ procedure MainMenu;
574574
bC := 1;
575575
// Setup screen
576576
WInit;
577-
WBack(14);
577+
WBack($2E);
578578

579579
// Open menu window
580580
bW1 := WOpen(0, 0, 40, 3, WOFF);
@@ -588,7 +588,7 @@ procedure MainMenu;
588588
while not bE do
589589
begin
590590
// Call menu
591-
bC := MenuH(bW1, 1, 1, WON, bC, 3, pcM);
591+
bC := WMenu(bW1, 1, 1, GHORZ, WON, bC, 3, pcM);
592592

593593
// Process choice
594594
case bC of

src/stubapp.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ procedure SubMenu3;
6464
while not bD do
6565
begin
6666
// Display menu and get choice
67-
bC := MenuV(bW1, 1, 1, WOFF, 1, 3, pcM);
67+
bC := WMenu(bW1, 1, 1, GVERT,WOFF, 1, 3, pcM);
6868

6969
// Process choice
7070
case bC of
@@ -108,7 +108,7 @@ procedure SubMenu3;
108108
while not bD do
109109
begin
110110
// Call menu
111-
bC := MenuV(bW2, 1, 2, WOFF, 1, 5, pcM);
111+
bC := WMenu(bW2, 1, 2, GVERT, WOFF, 1, 5, pcM);
112112

113113
// Process choice
114114
case bC of

0 commit comments

Comments
 (0)