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

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

Changes to Configuration Program v2:

  • Menu structure should now be complete.
File size: 6.2 KB
Line 
1; File name : MenuEvents.asm
2; Project name : XTIDE Universal BIOS Configurator v2
3; Created date : 5.10.2010
4; Last update : 18.10.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.wTimeoutTicks], NO_TIMEOUT_USED
76 mov WORD [si+MENUINIT.wItems], ax
77 mov WORD [si+MENUINIT.bTitleLines], TITLE_LINES_IN_MENU
78 mov WORD [si+MENUINIT.bInfoLines], INFO_LINES_IN_MENU
79 mov WORD [si+MENUINIT.bWidth], MENU_WIDTH
80 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
81 mov [si+MENUINIT.bHeight], ah
82 stc
83 ret
84
85
86; Parameters:
87; None
88; Returns:
89; CF: Set to exit menu
90; Clear to cancel exit
91ALIGN JUMP_ALIGN
92.ExitMenu:
93 call Menupage_GetActiveMenupageToDSDI
94 mov si, [di+MENUPAGE.fnBack]
95 cmp si, ExitToDos
96 je SHORT .QuitProgram
97 call si ; Back to previous menu
98 clc
99 ret
100
101ALIGN JUMP_ALIGN
102.QuitProgram:
103 call Dialogs_DisplayQuitDialog
104 jz SHORT .ExitToDOS
105 clc
106 ret
107.ExitToDOS:
108 call Buffers_SaveChangesIfFileLoaded
109 stc
110 ret
111
112
113; Parameters:
114; CX: Index of new highlighted item
115; DX: Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
116ALIGN JUMP_ALIGN
117.ItemHighlightedFromCX:
118 CALL_MENU_LIBRARY ClearInformationArea
119 CALL_MENU_LIBRARY RefreshInformation
120 stc
121 ret
122
123
124; Parameters:
125; CX: Index of selected item
126ALIGN JUMP_ALIGN
127.ItemSelectedFromCX:
128 call Menupage_GetActiveMenupageToDSDI
129 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
130 call [si+MENUITEM.fnActivate]
131 stc
132 ret
133
134
135; Parameters:
136; AL: ASCII character for the key
137; AH: Keyboard library scan code for the key
138ALIGN JUMP_ALIGN
139.KeyStrokeInAX:
140 cmp ah, KEY_DISPLAY_ITEM_HELP
141 je SHORT .DisplayHelp
142 jmp SHORT .EventNotHandled
143
144ALIGN JUMP_ALIGN
145.DisplayHelp:
146 call Menupage_GetActiveMenupageToDSDI
147 CALL_MENU_LIBRARY GetHighlightedItemToAX
148 xchg cx, ax
149 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
150 call Menuitem_DisplayHelpMessageFromDSSI
151 stc
152 ret
153
154
155; Parameters:
156; CX: Index of item to refresh
157; Cursor has been positioned to the beginning of item line
158ALIGN JUMP_ALIGN
159.RefreshItemFromCX:
160 cmp cx, NO_ITEM_HIGHLIGHTED
161 je SHORT .NothingToRefresh
162 call Menupage_GetActiveMenupageToDSDI
163 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
164 jnc SHORT .NothingToRefresh
165 call MenuitemPrint_NameWithPossibleValueFromDSSI
166.NothingToRefresh:
167 stc
168 ret
169
170
171; Parameters:
172; CX: Index of highlighted item
173; Cursor has been positioned to the beginning of first line
174ALIGN JUMP_ALIGN
175.RefreshInformation:
176 cmp cx, NO_ITEM_HIGHLIGHTED
177 je SHORT .NothingToRefresh
178 call Menupage_GetActiveMenupageToDSDI
179 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
180 call MenuitemPrint_PrintQuickInfoFromDSSI
181 stc
182 ret
183
184
185; Parameters:
186; CX: Index of highlighted item
187; Cursor has been positioned to the beginning of first line
188ALIGN JUMP_ALIGN
189.RefreshTitle:
190 call .PrintProgramName
191 call .PrintLoadStatus
192 call .PrintStatusOfUnsavedChanges
193 stc
194 ret
195
196ALIGN JUMP_ALIGN
197.PrintProgramName:
198 mov si, g_szProgramTitle
199 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
200 ret
201
202ALIGN JUMP_ALIGN
203.PrintLoadStatus:
204 mov ax, [g_cfgVars+CFGVARS.wFlags]
205 test ax, FLG_CFGVARS_FILELOADED
206 jnz SHORT .PrintNameOfLoadedFile
207 test ax, FLG_CFGVARS_ROMLOADED
208 jnz SHORT .PrintLoadedEeprom
209 ; Fall to .PrintNothingLoaded
210
211.PrintNothingLoaded:
212 mov si, g_szBiosIsNotLoaded
213 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
214 ret
215
216ALIGN JUMP_ALIGN
217.PrintNameOfLoadedFile:
218 mov si, g_cfgVars+CFGVARS.szOpenedFile
219 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
220 jmp SHORT .PrintTypeOfLoadedBios
221
222ALIGN JUMP_ALIGN
223.PrintLoadedEeprom:
224 mov si, g_szEEPROM
225 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
226 ; Fall to .PrintTypeOfLoadedBios
227
228ALIGN JUMP_ALIGN
229.PrintTypeOfLoadedBios:
230 mov si, g_szSourceAndTypeSeparator
231 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
232 call Buffers_IsXtideUniversalBiosLoaded
233 jne SHORT .PrintUnidentifiedType
234
235 call Buffers_GetFileBufferToESDI
236 mov bx, es
237 lea si, [di+ROMVARS.szVersion]
238 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
239 ret
240
241ALIGN JUMP_ALIGN
242.PrintUnidentifiedType:
243 mov si, g_szUnidentified
244 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
245 ret
246
247ALIGN JUMP_ALIGN
248.PrintStatusOfUnsavedChanges:
249 test WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
250 jz SHORT .ReturnSinceNothingToPrint
251 mov si, g_szUnsaved
252 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
253.ReturnSinceNothingToPrint:
254 ret
Note: See TracBrowser for help on using the repository browser.