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

Last change on this file since 159 was 60, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:

  • Timeout count down is now stopped when any key pressed.
File size: 8.2 KB
Line 
1; File name : Dialog.asm
2; Project name : Assembly Library
3; Created date : 6.8.2010
4; Last update : 22.11.2010
5; Author : Tomi Tilli
6; Description : Common functions for many dialogs.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Dialog_DisplayWithDialogInputInDSSIandHandlerInBX
13; Parameters:
14; BX: Offset to menu event handler
15; DX:AX: Optional user data
16; DS:SI: Ptr to DIALOG_INPUT
17; SS:BP: Ptr to parent MENU
18; Returns:
19; AX: Selected item
20; Corrupts registers:
21; BX, CX, DX, SI, DI
22;--------------------------------------------------------------------
23ALIGN JUMP_ALIGN
24Dialog_DisplayWithDialogInputInDSSIandHandlerInBX:
25 push es
26 push ds
27 mov di, bp ; Backup parent MENU
28 mov cx, DIALOG_size
29 eENTER_STRUCT cx
30
31 call Memory_ZeroSSBPwithSizeInCX
32 mov [bp+DIALOG.fpDialogIO], si
33 mov [bp+DIALOG.fpDialogIO+2], ds
34 mov [bp+DIALOG.pParentMenu], di
35
36 call MenuInit_EnterMenuWithHandlerInBXandUserDataInDXAX
37 call Dialog_RemoveFromScreenByRedrawingParentMenu
38 call Keyboard_RemoveAllKeystrokesFromBuffer
39
40 mov ax, [bp+MENUINIT.wHighlightedItem]
41 eLEAVE_STRUCT DIALOG_size
42 pop ds
43 pop es
44 ret
45
46
47;--------------------------------------------------------------------
48; Dialog_EventNotHandled
49; Parameters:
50; BX: Menu event (anything from MENUEVENT struct)
51; SS:BP: Ptr to DIALOG
52; Returns:
53; CF: Cleared since event not processed
54; Corrupts registers:
55; Nothing
56;--------------------------------------------------------------------
57ALIGN JUMP_ALIGN
58Dialog_EventNotHandled:
59 clc
60 ret
61
62
63;--------------------------------------------------------------------
64; Dialog_EventAnyThatClosesDialog
65; Dialog_EventExitMenu
66; Parameters:
67; SS:BP: Ptr to DIALOG
68; Returns:
69; CF: Set since event processed
70; Corrupts registers:
71; Nothing
72;--------------------------------------------------------------------
73ALIGN JUMP_ALIGN
74Dialog_EventAnyThatClosesDialog:
75 call MenuInit_CloseMenuWindow
76ALIGN JUMP_ALIGN
77Dialog_EventExitMenu:
78 stc
79 ret
80
81
82;--------------------------------------------------------------------
83; Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX
84; Parameters:
85; AX: Index of highlighted item
86; DS:SI: Ptr to MENUINIT struct to initialize
87; SS:BP: Ptr to DIALOG
88; Returns:
89; DS:SI: Ptr to initialized MENUINIT struct
90; CF: Set since event processed
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93Dialog_EventInitializeMenuinitFromDSSIforSingleItemWithHighlightedItemInAX:
94 les di, [bp+DIALOG.fpDialogIO]
95 mov WORD [es:di+DIALOG_INPUT.fszItems], g_szSingleItem
96 mov [es:di+DIALOG_INPUT.fszItems+2], cs
97 ; Fall to Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
98
99;--------------------------------------------------------------------
100; Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX
101; Parameters:
102; AX: Index of highlighted item
103; DS:SI: Ptr to MENUINIT struct to initialize
104; SS:BP: Ptr to DIALOG
105; Returns:
106; DS:SI: Ptr to initialized MENUINIT struct
107; CF: Set since event processed
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
110Dialog_EventInitializeMenuinitFromDSSIwithHighlightedItemInAX:
111 mov [bp+MENUINIT.wHighlightedItem], ax
112 les di, [bp+DIALOG.fpDialogIO]
113 call .GetWidthBasedOnParentMenuToAL
114 mov [bp+MENUINIT.bWidth], al
115
116 lds si, [es:di+DIALOG_INPUT.fszTitle]
117 call ItemLineSplitter_GetLinesToAXforStringInDSSI
118 mov [bp+MENUINIT.bTitleLines], al
119
120 lds si, [es:di+DIALOG_INPUT.fszItems]
121 call ItemLineSplitter_GetLinesToAXforStringInDSSI
122 mov [bp+MENUINIT.wItems], ax
123
124 lds si, [es:di+DIALOG_INPUT.fszInfo]
125 call ItemLineSplitter_GetLinesToAXforStringInDSSI
126 mov [bp+MENUINIT.bInfoLines], al
127
128 call .GetHeightToAH ; Line counts are required
129 mov [bp+MENUINIT.bHeight], ah
130 stc
131 ret
132
133;--------------------------------------------------------------------
134; .GetWidthBasedOnParentMenuToAL
135; Parameters:
136; SS:BP: Ptr to DIALOG
137; Returns:
138; AX: Width for dialog
139; Corrupts registers:
140; BX
141;--------------------------------------------------------------------
142ALIGN JUMP_ALIGN
143.GetWidthBasedOnParentMenuToAL:
144 mov bx, [bp+DIALOG.pParentMenu]
145 mov al, [ss:bx+MENUINIT.bWidth]
146 sub al, DIALOG_DELTA_WIDTH_FROM_PARENT
147 MIN_U al, DIALOG_MAX_WIDTH
148 ret
149
150;--------------------------------------------------------------------
151; .GetHeightToAH
152; Parameters:
153; SS:BP: Ptr to DIALOG
154; Returns:
155; AH: Height for dialog
156; Corrupts registers:
157; AL, BX, DI
158;--------------------------------------------------------------------
159ALIGN JUMP_ALIGN
160.GetHeightToAH:
161 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
162 xchg bx, ax
163 mov ah, [bp+MENUINIT.bTitleLines]
164 add ah, [bp+MENUINIT.wItems]
165 add ah, [bp+MENUINIT.bInfoLines]
166 add ah, BYTE MENU_VERTICAL_BORDER_LINES
167 MIN_U ah, bh
168 MIN_U ah, DIALOG_MAX_HEIGHT
169 ret
170
171
172;--------------------------------------------------------------------
173; Dialog_EventRefreshTitle
174; Dialog_EventRefreshInformation
175; Parameters:
176; SS:BP: Ptr to DIALOG
177; Returns:
178; CF: Set since event processed
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181Dialog_EventRefreshTitle:
182 lds si, [bp+DIALOG.fpDialogIO]
183 lds si, [si+DIALOG_INPUT.fszTitle]
184 jmp SHORT PrintTitleOrInfoLine
185
186ALIGN JUMP_ALIGN
187Dialog_EventRefreshInformation:
188 lds si, [bp+DIALOG.fpDialogIO]
189 lds si, [si+DIALOG_INPUT.fszInfo]
190 ; Fall to PrintTitleOrInfoLine
191
192ALIGN JUMP_ALIGN
193PrintTitleOrInfoLine:
194 mov bx, ds
195 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
196 stc
197 ret
198
199
200;--------------------------------------------------------------------
201; Dialog_EventRefreshItemFromCX
202; Parameters:
203; CX: Item to refresh
204; SS:BP: Ptr to DIALOG
205; Returns:
206; CF: Set since event processed
207;--------------------------------------------------------------------
208ALIGN JUMP_ALIGN
209Dialog_EventRefreshItemFromCX:
210 lds si, [bp+DIALOG.fpDialogIO]
211 lds si, [si+DIALOG_INPUT.fszItems]
212 call ItemLineSplitter_GetLineToDSSIandLengthToCXfromStringInDSSIwithIndexInCX
213 jnc SHORT .LineNotFound
214
215 mov bx, ds
216 CALL_DISPLAY_LIBRARY PrintCharBufferFromBXSIwithLengthInCX
217.LineNotFound:
218 stc
219 ret
220
221
222;--------------------------------------------------------------------
223; Dialog_RemoveFromScreenByRedrawingParentMenu
224; Parameters:
225; SS:BP: Ptr to DIALOG
226; Returns:
227; Nothing
228; Corrupts:
229; AX, BX, CX, DX, SI, DI
230;--------------------------------------------------------------------
231ALIGN JUMP_ALIGN
232Dialog_RemoveFromScreenByRedrawingParentMenu:
233 mov si, [bp+DIALOG.pParentMenu] ; SS:SI points to parent MENU
234 call .GetParentTitleBorderCoordinatesToDX
235 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
236 cmp ah, dh ; Dialog taller than parent?
237 jb SHORT .RedrawDialogAreaAndWholeParentWindow
238 jmp SHORT .RedrawWholeParentWindow
239
240;--------------------------------------------------------------------
241; .GetParentTitleBorderCoordinatesToDX
242; Parameters:
243; SS:SI: Ptr to parent MENU
244; SS:BP: Ptr to DIALOG
245; Returns:
246; DL: Parent border column (X)
247; DH: Parent border row (Y)
248; Corrupts:
249; AX
250;--------------------------------------------------------------------
251ALIGN JUMP_ALIGN
252.GetParentTitleBorderCoordinatesToDX:
253 xchg si, bp
254 call MenuLocation_GetTitleBordersTopLeftCoordinatesToAX
255 xchg bp, si
256 xchg dx, ax
257 ret
258
259;--------------------------------------------------------------------
260; .RedrawDialogAreaAndWholeParentWindow
261; .RedrawWholeParentWindow
262; Parameters:
263; SS:SI: Ptr to parent MENU
264; SS:BP: Ptr to DIALOG
265; Returns:
266; Nothing
267; Corrupts:
268; AX, BX, CX, DX, SI, DI
269;--------------------------------------------------------------------
270ALIGN JUMP_ALIGN
271.RedrawDialogAreaAndWholeParentWindow:
272 push si
273 call MenuBorders_AdjustDisplayContextForDrawingBorders
274 pop si
275 mov al, SCREEN_BACKGROUND_ATTRIBUTE
276 CALL_DISPLAY_LIBRARY SetCharacterAttributeFromAL
277 mov ax, [bp+MENUINIT.wWidthAndHeight]
278 CALL_DISPLAY_LIBRARY ClearAreaWithHeightInAHandWidthInAL
279 ; Fall to .RedrawWholeParentWindow
280
281ALIGN JUMP_ALIGN
282.RedrawWholeParentWindow:
283 push bp
284 mov bp, si
285 call MenuInit_RefreshMenuWindow
286 pop bp
287 ret
Note: See TracBrowser for help on using the repository browser.