source: xtideuniversalbios/trunk/Assembly_Library/Src/Menu/Dialog/Dialog.asm

Last change on this file was 625, checked in by Krister Nordvall, 21 months ago

Changes:

  • Added a configuration option to let the BIOS store RamVars to an UMB when Full operating mode is enabled. This is primarily for XT class machines with RAM in the UMA (which apparently is a common thing these days).
  • Added two new builds specifically for IBM PS/2 machines. This is for support of the new McIDE adapter from the guys at zzxio.com. Note that the additional hardware specific code (under the USE_PS2 define) is for the PS/2 machines themselves and not for the McIDE adapters, so any controller in an IBM PS/2 machine can be used with the USE_PS2 define.
  • Moved pColorTheme out of the range of ROMVARS being copied over when doing "Load old settings from EEPROM" in XTIDECFG. This fixed a serious bug from r592 where loading a BIOS from file and then loading the old settings from ROM would corrupt 7 bytes of code somewhere in the loaded BIOS.
  • Optimizations (speed and size) to the library. Browsing the menus in XTIDECFG should now feel a little less sluggish.
  • Hopefully fixed a problem with the PostCommitHook script where it sometimes wouldn't find the CommitInProgress file. I say hopefully because testing this is a nightmare.
File size: 9.7 KB
Line 
1; Project name : Assembly Library
2; Description : Common functions for many dialogs.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2023 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20
21; Section containing code
22SECTION .text
23
24;--------------------------------------------------------------------
25; Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
26; Parameters:
27; BX: Offset to menu event handler
28; DX:AX: Optional user data
29; DS:SI: Ptr to DIALOG_INPUT
30; SS:BP: Ptr to parent MENU
31; Returns:
32; AX: Selected item
33; Corrupts registers:
34; BX, CX, DX, DI
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37Dialog_DisplayWithDialogInputInDSSIandHandlerInBX:
38 push es
39 push ds
40 mov di, bp ; Backup parent MENU
41 mov cx, DIALOG_size
42 eENTER_STRUCT cx
43
44 call Memory_ZeroSSBPwithSizeInCX
45 mov [bp+DIALOG.fpDialogIO], si
46 mov [bp+DIALOG.fpDialogIO+2], ds
47 mov [bp+DIALOG.pParentMenu], di
48
49 call MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
50 call Dialog_RemoveFromScreenByRedrawingParentMenu
51 call Keyboard_RemoveAllKeystrokesFromBuffer
52
53 mov ax, [bp+MENUINIT.wHighlightedItem]
54 mov si, [bp+DIALOG.fpDialogIO] ; Restore SI
55 eLEAVE_STRUCT DIALOG_size
56 pop ds
57 pop es
58 ret
59
60
61;--------------------------------------------------------------------
62; Dialog_EventNotHandled
63; Parameters:
64; BX: Menu event (anything from MENUEVENT struct)
65; SS:BP: Ptr to DIALOG
66; Returns:
67; CF: Cleared since event not processed
68; Corrupts registers:
69; Nothing
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72Dialog_EventNotHandled:
73 clc
74 ret
75
76
77;--------------------------------------------------------------------
78; Dialog_EventAnyThatClosesDialog
79; Dialog_EventExitMenu
80; Parameters:
81; SS:BP: Ptr to DIALOG
82; Returns:
83; CF: Set since event processed
84; Corrupts registers:
85; Nothing
86;--------------------------------------------------------------------
87ALIGN JUMP_ALIGN
88Dialog_EventAnyThatClosesDialog:
89 call MenuInit_CloseMenuWindow
90ALIGN JUMP_ALIGN
91Dialog_EventExitMenu:
92 stc
93 ret
94
95
96;--------------------------------------------------------------------
97; Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithItemZero
98; Parameters:
99; DS:SI: Ptr to MENUINIT struct to initialize
100; SS:BP: Ptr to DIALOG
101; Returns:
102; DS:SI: Ptr to initialized MENUINIT struct
103; CF: Set since event processed
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithItemZero:
107 xor ax, ax
108 ; Fall to Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
109
110;--------------------------------------------------------------------
111; Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
112; Parameters:
113; AX: Index of highlighted item
114; DS:SI: Ptr to MENUINIT struct to initialize
115; SS:BP: Ptr to DIALOG
116; Returns:
117; DS:SI: Ptr to initialized MENUINIT struct
118; CF: Set since event processed
119;--------------------------------------------------------------------
120Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX:
121 les di, [bp+DIALOG.fpDialogIO]
122 mov WORD [es:di+DIALOG_INPUT.fszItems], g_szSingleItem
123 mov [es:di+DIALOG_INPUT.fszItems+2], cs
124 ; Fall to Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
125
126;--------------------------------------------------------------------
127; Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
128; Parameters:
129; AX: Index of highlighted item
130; DS:SI: Ptr to MENUINIT struct to initialize
131; SS:BP: Ptr to DIALOG
132; Returns:
133; DS:SI: Ptr to initialized MENUINIT struct
134; CF: Set since event processed
135;--------------------------------------------------------------------
136ALIGN JUMP_ALIGN
137Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX:
138 mov [bp+MENUINIT.wHighlightedItem], ax
139 les di, [bp+DIALOG.fpDialogIO]
140 call .GetWidthBasedOnParentMenuToAL
141 mov [bp+MENUINIT.bWidth], al
142
143 lds si, [es:di+DIALOG_INPUT.fszTitle]
144 call ItemLineSplitter_GetLinesToAXforStringInDSSI
145 mov [bp+MENUINIT.bTitleLines], al
146
147 lds si, [es:di+DIALOG_INPUT.fszItems]
148 call ItemLineSplitter_GetLinesToAXforStringInDSSI
149 mov [bp+MENUINIT.wItems], ax
150
151 lds si, [es:di+DIALOG_INPUT.fszInfo]
152 call ItemLineSplitter_GetLinesToAXforStringInDSSI
153 mov [bp+MENUINIT.bInfoLines], al
154
155 call .GetHeightToAH ; Line counts are required
156 mov [bp+MENUINIT.bHeight], ah
157 stc
158 ret
159
160
161;--------------------------------------------------------------------
162; .GetWidthBasedOnParentMenuToAL
163; Parameters:
164; SS:BP: Ptr to DIALOG
165; Returns:
166; AX: Width for dialog
167; Corrupts registers:
168; BX
169;--------------------------------------------------------------------
170ALIGN JUMP_ALIGN
171.GetWidthBasedOnParentMenuToAL:
172 mov bx, [bp+DIALOG.pParentMenu]
173 mov al, [ss:bx+MENUINIT.bWidth]
174 sub al, DIALOG_DELTA_WIDTH_FROM_PARENT
175 cmp al, DIALOG_MAX_WIDTH
176 jb .ALlessThanDIALOG_MAX_WIDTH
177 mov al, DIALOG_MAX_WIDTH
178ALIGN JUMP_ALIGN, ret
179.ALlessThanDIALOG_MAX_WIDTH:
180 ret
181
182
183;--------------------------------------------------------------------
184; .GetHeightToAH
185; Parameters:
186; SS:BP: Ptr to DIALOG
187; Returns:
188; AH: Height for dialog
189; Corrupts registers:
190; AL, BX, DI
191;--------------------------------------------------------------------
192ALIGN JUMP_ALIGN
193.GetHeightToAH:
194 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
195 xchg bx, ax
196 mov ah, MENU_VERTICAL_BORDER_LINES
197 add ah, [bp+MENUINIT.bTitleLines]
198 add ah, [bp+MENUINIT.wItems]
199 add ah, [bp+MENUINIT.bInfoLines]
200 cmp ah, bh
201 jb .AHlessThanBH
202 xchg bx, ax
203ALIGN JUMP_ALIGN
204.AHlessThanBH:
205 cmp ah, DIALOG_MAX_HEIGHT
206 jb .AHlessThanDIALOG_MAX_HEIGHT
207 mov ah, DIALOG_MAX_HEIGHT
208ALIGN JUMP_ALIGN, ret
209.AHlessThanDIALOG_MAX_HEIGHT:
210 ret
211
212
213;--------------------------------------------------------------------
214; Dialog_EventRefreshTitle
215; Dialog_EventRefreshInformation
216; Parameters:
217; SS:BP: Ptr to DIALOG
218; Returns:
219; CF: Set since event processed
220;--------------------------------------------------------------------
221ALIGN JUMP_ALIGN
222Dialog_EventRefreshTitle:
223 lds si, [bp+DIALOG.fpDialogIO]
224 lds si, [si+DIALOG_INPUT.fszTitle]
225 jmp SHORT PrintTitleOrInfoLine
226
227ALIGN JUMP_ALIGN
228Dialog_EventRefreshInformation:
229 lds si, [bp+DIALOG.fpDialogIO]
230 lds si, [si+DIALOG_INPUT.fszInfo]
231 ; Fall to PrintTitleOrInfoLine
232
233ALIGN JUMP_ALIGN
234PrintTitleOrInfoLine:
235 mov bx, ds
236 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
237 stc
238 ret
239
240
241;--------------------------------------------------------------------
242; Dialog_EventRefreshItemFromCX
243; Parameters:
244; CX: Item to refresh
245; SS:BP: Ptr to DIALOG
246; Returns:
247; CF: Set since event processed
248;--------------------------------------------------------------------
249ALIGN JUMP_ALIGN
250Dialog_EventRefreshItemFromCX:
251 lds si, [bp+DIALOG.fpDialogIO]
252 lds si, [si+DIALOG_INPUT.fszItems]
253 call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
254 jnc SHORT .LineNotFound
255
256 mov bx, ds
257 CALL_DISPLAY_LIBRARY PrintCharBufferFromBXSIwithLengthInCX
258.LineNotFound:
259 stc
260 ret
261
262
263;--------------------------------------------------------------------
264; Dialog_RemoveFromScreenByRedrawingParentMenu
265; Parameters:
266; SS:BP: Ptr to DIALOG
267; Returns:
268; Nothing
269; Corrupts:
270; AX, BX, CX, DX, SI, DI
271;--------------------------------------------------------------------
272ALIGN JUMP_ALIGN
273Dialog_RemoveFromScreenByRedrawingParentMenu:
274 mov si, [bp+DIALOG.pParentMenu] ; SS:SI points to parent MENU
275 call .GetParentTitleBorderCoordinatesToDX
276 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
277 cmp ah, dh ; Dialog taller than parent?
278 jnb SHORT .RedrawWholeParentWindow
279 ; Fall to .RedrawDialogAreaAndWholeParentWindow
280
281;--------------------------------------------------------------------
282; .RedrawDialogAreaAndWholeParentWindow
283; .RedrawWholeParentWindow
284; Parameters:
285; SS:SI: Ptr to parent MENU
286; SS:BP: Ptr to DIALOG
287; Returns:
288; Nothing
289; Corrupts:
290; AX, BX, CX, DX, SI, DI
291;--------------------------------------------------------------------
292.RedrawDialogAreaAndWholeParentWindow:
293 push si
294 call MenuBorders_AdjustDisplayContextForDrawingBorders
295 pop si
296 mov al, SCREEN_BACKGROUND_ATTRIBUTE
297 CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
298 mov ax, [bp+MENUINIT.wWidthAndHeight]
299 CALL_DISPLAY_LIBRARY ClearAreaWithHeightInAHandWidthInAL
300 ; Fall to .RedrawWholeParentWindow
301
302ALIGN JUMP_ALIGN
303.RedrawWholeParentWindow:
304 push bp
305 mov bp, si
306 call MenuInit_RefreshMenuWindow
307 pop bp
308 ret
309
310;--------------------------------------------------------------------
311; .GetParentTitleBorderCoordinatesToDX
312; Parameters:
313; SS:SI: Ptr to parent MENU
314; SS:BP: Ptr to DIALOG
315; Returns:
316; DL: Parent border column (X)
317; DH: Parent border row (Y)
318; Corrupts:
319; AX
320;--------------------------------------------------------------------
321ALIGN JUMP_ALIGN
322.GetParentTitleBorderCoordinatesToDX:
323 xchg si, bp
324 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
325 xchg bp, si
326 xchg dx, ax
327 ret
Note: See TracBrowser for help on using the repository browser.