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

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

Changes to all parts of the project:

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