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

Last change on this file since 180 was 162, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

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