source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuEvents.asm@ 472

Last change on this file since 472 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 6.7 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : Menu event handling.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; MenuEvents_DisplayMenu
25; Parameters:
26; Nothing
27; Returns:
28; Nothing
29; Corrupts registers:
30; All, except segments
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33MenuEvents_DisplayMenu:
34 mov bx, MenuEventHandler
35 CALL_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
36 ret
37
38
39;--------------------------------------------------------------------
40; MenuEventHandler
41; Common parameters for all events:
42; BX: Menu event (anything from MENUEVENT struct)
43; SS:BP: Menu library handle
44; Common return values for all events:
45; CF: Set if event processed
46; Cleared if event not processed
47; Corrupts registers:
48; All
49;--------------------------------------------------------------------
50ALIGN JUMP_ALIGN
51MenuEventHandler:
52 cmp bx, MENUEVENT.RefreshItemFromCX ; Above last supported item?
53 ja SHORT .EventNotHandled
54 jmp [cs:bx+.rgfnEventSpecificHandlers]
55.EventNotHandled:
56.IdleProcessing:
57 clc
58 ret
59
60ALIGN WORD_ALIGN
61.rgfnEventSpecificHandlers:
62 dw .InitializeMenuinitFromDSSI
63 dw .ExitMenu
64 dw .IdleProcessing
65 dw .ItemHighlightedFromCX
66 dw .ItemSelectedFromCX
67 dw .KeyStrokeInAX
68 dw .RefreshTitle
69 dw .RefreshInformation
70 dw .RefreshItemFromCX
71
72
73; Parameters:
74; DS:SI: Ptr to MENUINIT struct to initialize
75; Returns:
76; DS:SI: Ptr to initialized MENUINIT struct
77ALIGN JUMP_ALIGN
78.InitializeMenuinitFromDSSI:
79 push ds
80 push cs
81 pop ds
82 mov di, g_MenupageForMainMenu
83 call Menupage_SetActiveMenupageFromDSDI
84 call Menupage_GetVisibleMenuitemsToAXfromDSDI
85 pop ds
86
87 mov WORD [si+MENUINIT.wItems], ax
88 mov WORD [si+MENUINIT.bTitleLines], TITLE_LINES_IN_MENU
89 mov WORD [si+MENUINIT.bInfoLines], INFO_LINES_IN_MENU
90 mov BYTE [si+MENUINIT.bWidth], MENU_WIDTH
91 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
92 mov [si+MENUINIT.bHeight], ah
93 call MainMenu_EnterMenuOrModifyItemVisibility
94 stc
95 ret
96
97
98; Parameters:
99; None
100; Returns:
101; CF: Set to exit menu
102; Clear to cancel exit
103ALIGN JUMP_ALIGN
104.ExitMenu:
105 call Menupage_GetActiveMenupageToDSDI
106 mov si, [di+MENUPAGE.fnBack]
107 cmp si, ExitToDosFromBackButton
108 je SHORT .QuitProgram
109 call si ; Back to previous menu
110 clc
111 ret
112
113ALIGN JUMP_ALIGN
114.QuitProgram:
115 call Dialogs_DisplayQuitDialog
116 jz SHORT .ExitToDOS
117 clc
118 ret
119.ExitToDOS:
120 call Buffers_SaveChangesIfFileLoaded
121 CALL_MENU_LIBRARY Close
122 stc
123 ret
124
125
126; Parameters:
127; CX: Index of new highlighted item
128; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
129ALIGN JUMP_ALIGN
130.ItemHighlightedFromCX:
131 CALL_MENU_LIBRARY ClearInformationArea
132 CALL_MENU_LIBRARY RefreshInformation
133 stc
134 ret
135
136
137; Parameters:
138; CX: Index of selected item
139ALIGN JUMP_ALIGN
140.ItemSelectedFromCX:
141 call Menupage_GetActiveMenupageToDSDI
142 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
143 call [si+MENUITEM.fnActivate]
144 stc
145 ret
146
147
148; Parameters:
149; AL: ASCII character for the key
150; AH: Keyboard library scan code for the key
151ALIGN JUMP_ALIGN
152.KeyStrokeInAX:
153 cmp ah, KEY_DISPLAY_ITEM_HELP
154 jne SHORT .EventNotHandled
155
156;ALIGN JUMP_ALIGN
157;.DisplayHelp:
158 call Menupage_GetActiveMenupageToDSDI
159 CALL_MENU_LIBRARY GetHighlightedItemToAX
160 xchg cx, ax
161 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
162 call Menuitem_DisplayHelpMessageFromDSSI
163 stc
164 ret
165
166
167; Parameters:
168; CX: Index of item to refresh
169; Cursor has been positioned to the beginning of item line
170ALIGN JUMP_ALIGN
171.RefreshItemFromCX:
172 cmp cx, NO_ITEM_HIGHLIGHTED
173 je SHORT .NothingToRefresh
174 call Menupage_GetActiveMenupageToDSDI
175 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
176 jnc SHORT .NothingToRefresh
177 call MenuitemPrint_NameWithPossibleValueFromDSSI
178.NothingToRefresh:
179 stc
180 ret
181
182
183; Parameters:
184; CX: Index of highlighted item
185; Cursor has been positioned to the beginning of first line
186ALIGN JUMP_ALIGN
187.RefreshInformation:
188 cmp cx, NO_ITEM_HIGHLIGHTED
189 je SHORT .NothingToRefresh
190 call Menupage_GetActiveMenupageToDSDI
191 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
192 call MenuitemPrint_PrintQuickInfoFromDSSI
193 stc
194 ret
195
196
197; Parameters:
198; CX: Index of highlighted item
199; Cursor has been positioned to the beginning of first line
200ALIGN JUMP_ALIGN
201.RefreshTitle:
202 call .PrintProgramName
203 call .PrintLoadStatus
204 call .PrintStatusOfUnsavedChanges
205 stc
206 ret
207
208ALIGN JUMP_ALIGN
209.PrintProgramName:
210 mov si, g_szProgramTitle
211 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
212 ret
213
214ALIGN JUMP_ALIGN
215.PrintLoadStatus:
216 mov ax, [g_cfgVars+CFGVARS.wFlags]
217 test ax, FLG_CFGVARS_FILELOADED
218 jnz SHORT .PrintNameOfLoadedFile
219 test ax, FLG_CFGVARS_ROMLOADED
220 jnz SHORT .PrintLoadedEeprom
221 ; Fall to .PrintNothingLoaded
222
223.PrintNothingLoaded:
224 mov si, g_szBiosIsNotLoaded
225 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
226 ret
227
228ALIGN JUMP_ALIGN
229.PrintNameOfLoadedFile:
230 mov si, g_cfgVars+CFGVARS.szOpenedFile
231 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
232 jmp SHORT .PrintTypeOfLoadedBios
233
234ALIGN JUMP_ALIGN
235.PrintLoadedEeprom:
236 mov si, g_szEEPROM
237 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
238 ; Fall to .PrintTypeOfLoadedBios
239
240ALIGN JUMP_ALIGN
241.PrintTypeOfLoadedBios:
242 mov si, g_szSourceAndTypeSeparator
243 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
244 call Buffers_IsXtideUniversalBiosLoaded
245 jne SHORT .PrintUnidentifiedType
246
247 call Buffers_GetFileBufferToESDI
248 mov bx, es
249 lea si, [di+ROMVARS.szVersion]
250 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
251 ret
252
253ALIGN JUMP_ALIGN
254.PrintUnidentifiedType:
255 mov si, g_szUnidentified
256 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
257 ret
258
259ALIGN JUMP_ALIGN
260.PrintStatusOfUnsavedChanges:
261 test WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
262 jz SHORT .ReturnSinceNothingToPrint
263 mov si, g_szUnsaved
264 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
265.ReturnSinceNothingToPrint:
266 ret
Note: See TracBrowser for help on using the repository browser.