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

Last change on this file since 566 was 526, checked in by krille_n_@…, 12 years ago

Changes:

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