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

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

Changes to Configurator v2:

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