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

Last change on this file since 595 was 593, checked in by Tomi Tilli, 6 years ago

Flashing now works again.
Hack to get Windows 95 to work properly (MODULE_WIN95_CMOS_HACK included for 386 builds by default).
Edited makefile to produce large 386 build.
Fixed recovery time for QDI Vision VLB-IDE controllers.
No more warnings with Nasm 2.13.xx and later.
File dialog now properly restores default drive when file selection is cancelled.

File size: 9.1 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-2013 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_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
98; Parameters:
99; AX: Index of highlighted item
100; DS:SI: Ptr to MENUINIT struct to initialize
101; SS:BP: Ptr to DIALOG
102; Returns:
103; DS:SI: Ptr to initialized MENUINIT struct
104; CF: Set since event processed
105;--------------------------------------------------------------------
106ALIGN JUMP_ALIGN
107Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX:
108 les di, [bp+DIALOG.fpDialogIO]
109 mov WORD [es:di+DIALOG_INPUT.fszItems], g_szSingleItem
110 mov [es:di+DIALOG_INPUT.fszItems+2], cs
111 ; Fall to Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
112
113;--------------------------------------------------------------------
114; Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
115; Parameters:
116; AX: Index of highlighted item
117; DS:SI: Ptr to MENUINIT struct to initialize
118; SS:BP: Ptr to DIALOG
119; Returns:
120; DS:SI: Ptr to initialized MENUINIT struct
121; CF: Set since event processed
122;--------------------------------------------------------------------
123ALIGN JUMP_ALIGN
124Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX:
125 mov [bp+MENUINIT.wHighlightedItem], ax
126 les di, [bp+DIALOG.fpDialogIO]
127 call .GetWidthBasedOnParentMenuToAL
128 mov [bp+MENUINIT.bWidth], al
129
130 lds si, [es:di+DIALOG_INPUT.fszTitle]
131 call ItemLineSplitter_GetLinesToAXforStringInDSSI
132 mov [bp+MENUINIT.bTitleLines], al
133
134 lds si, [es:di+DIALOG_INPUT.fszItems]
135 call ItemLineSplitter_GetLinesToAXforStringInDSSI
136 mov [bp+MENUINIT.wItems], ax
137
138 lds si, [es:di+DIALOG_INPUT.fszInfo]
139 call ItemLineSplitter_GetLinesToAXforStringInDSSI
140 mov [bp+MENUINIT.bInfoLines], al
141
142 call .GetHeightToAH ; Line counts are required
143 mov [bp+MENUINIT.bHeight], ah
144 stc
145 ret
146
147
148;--------------------------------------------------------------------
149; .GetWidthBasedOnParentMenuToAL
150; Parameters:
151; SS:BP: Ptr to DIALOG
152; Returns:
153; AX: Width for dialog
154; Corrupts registers:
155; BX
156;--------------------------------------------------------------------
157ALIGN JUMP_ALIGN
158.GetWidthBasedOnParentMenuToAL:
159 mov bx, [bp+DIALOG.pParentMenu]
160 mov al, [ss:bx+MENUINIT.bWidth]
161 sub al, DIALOG_DELTA_WIDTH_FROM_PARENT
162 cmp al, DIALOG_MAX_WIDTH
163 jb .ALlessThanDIALOG_MAX_WIDTH
164 mov al, DIALOG_MAX_WIDTH
165ALIGN JUMP_ALIGN, ret
166.ALlessThanDIALOG_MAX_WIDTH:
167 ret
168
169
170;--------------------------------------------------------------------
171; .GetHeightToAH
172; Parameters:
173; SS:BP: Ptr to DIALOG
174; Returns:
175; AH: Height for dialog
176; Corrupts registers:
177; AL, BX, DI
178;--------------------------------------------------------------------
179ALIGN JUMP_ALIGN
180.GetHeightToAH:
181 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
182 xchg bx, ax
183 mov ah, MENU_VERTICAL_BORDER_LINES
184 add ah, [bp+MENUINIT.bTitleLines]
185 add ah, [bp+MENUINIT.wItems]
186 add ah, [bp+MENUINIT.bInfoLines]
187 cmp ah, bh
188 jb .AHlessThanBH
189 xchg bx, ax
190ALIGN JUMP_ALIGN
191.AHlessThanBH:
192 cmp ah, DIALOG_MAX_HEIGHT
193 jb .AHlessThanDIALOG_MAX_HEIGHT
194 mov ah, DIALOG_MAX_HEIGHT
195ALIGN JUMP_ALIGN, ret
196.AHlessThanDIALOG_MAX_HEIGHT:
197 ret
198
199
200;--------------------------------------------------------------------
201; Dialog_EventRefreshTitle
202; Dialog_EventRefreshInformation
203; Parameters:
204; SS:BP: Ptr to DIALOG
205; Returns:
206; CF: Set since event processed
207;--------------------------------------------------------------------
208ALIGN JUMP_ALIGN
209Dialog_EventRefreshTitle:
210 lds si, [bp+DIALOG.fpDialogIO]
211 lds si, [si+DIALOG_INPUT.fszTitle]
212 jmp SHORT PrintTitleOrInfoLine
213
214ALIGN JUMP_ALIGN
215Dialog_EventRefreshInformation:
216 lds si, [bp+DIALOG.fpDialogIO]
217 lds si, [si+DIALOG_INPUT.fszInfo]
218 ; Fall to PrintTitleOrInfoLine
219
220ALIGN JUMP_ALIGN
221PrintTitleOrInfoLine:
222 mov bx, ds
223 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
224 stc
225 ret
226
227
228;--------------------------------------------------------------------
229; Dialog_EventRefreshItemFromCX
230; Parameters:
231; CX: Item to refresh
232; SS:BP: Ptr to DIALOG
233; Returns:
234; CF: Set since event processed
235;--------------------------------------------------------------------
236ALIGN JUMP_ALIGN
237Dialog_EventRefreshItemFromCX:
238 lds si, [bp+DIALOG.fpDialogIO]
239 lds si, [si+DIALOG_INPUT.fszItems]
240 call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
241 jnc SHORT .LineNotFound
242
243 mov bx, ds
244 CALL_DISPLAY_LIBRARY PrintCharBufferFromBXSIwithLengthInCX
245.LineNotFound:
246 stc
247 ret
248
249
250;--------------------------------------------------------------------
251; Dialog_RemoveFromScreenByRedrawingParentMenu
252; Parameters:
253; SS:BP: Ptr to DIALOG
254; Returns:
255; Nothing
256; Corrupts:
257; AX, BX, CX, DX, SI, DI
258;--------------------------------------------------------------------
259ALIGN JUMP_ALIGN
260Dialog_RemoveFromScreenByRedrawingParentMenu:
261 mov si, [bp+DIALOG.pParentMenu] ; SS:SI points to parent MENU
262 call .GetParentTitleBorderCoordinatesToDX
263 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
264 cmp ah, dh ; Dialog taller than parent?
265 jnb SHORT .RedrawWholeParentWindow
266 ; Fall to .RedrawDialogAreaAndWholeParentWindow
267
268;--------------------------------------------------------------------
269; .RedrawDialogAreaAndWholeParentWindow
270; .RedrawWholeParentWindow
271; Parameters:
272; SS:SI: Ptr to parent MENU
273; SS:BP: Ptr to DIALOG
274; Returns:
275; Nothing
276; Corrupts:
277; AX, BX, CX, DX, SI, DI
278;--------------------------------------------------------------------
279.RedrawDialogAreaAndWholeParentWindow:
280 push si
281 call MenuBorders_AdjustDisplayContextForDrawingBorders
282 pop si
283 mov al, SCREEN_BACKGROUND_ATTRIBUTE
284 CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
285 mov ax, [bp+MENUINIT.wWidthAndHeight]
286 CALL_DISPLAY_LIBRARY ClearAreaWithHeightInAHandWidthInAL
287 ; Fall to .RedrawWholeParentWindow
288
289ALIGN JUMP_ALIGN
290.RedrawWholeParentWindow:
291 push bp
292 mov bp, si
293 call MenuInit_RefreshMenuWindow
294 pop bp
295 ret
296
297;--------------------------------------------------------------------
298; .GetParentTitleBorderCoordinatesToDX
299; Parameters:
300; SS:SI: Ptr to parent MENU
301; SS:BP: Ptr to DIALOG
302; Returns:
303; DL: Parent border column (X)
304; DH: Parent border row (Y)
305; Corrupts:
306; AX
307;--------------------------------------------------------------------
308ALIGN JUMP_ALIGN
309.GetParentTitleBorderCoordinatesToDX:
310 xchg si, bp
311 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
312 xchg bp, si
313 xchg dx, ax
314 ret
Note: See TracBrowser for help on using the repository browser.