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

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

Changes to Configurator v2:

  • Saving changes now works again (got broken in r118).
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 je SHORT .DisplayHelp
138 jmp SHORT .EventNotHandled
139
140ALIGN JUMP_ALIGN
141.DisplayHelp:
142 call Menupage_GetActiveMenupageToDSDI
143 CALL_MENU_LIBRARY GetHighlightedItemToAX
144 xchg cx, ax
145 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
146 call Menuitem_DisplayHelpMessageFromDSSI
147 stc
148 ret
149
150
151; Parameters:
152; CX: Index of item to refresh
153; Cursor has been positioned to the beginning of item line
154ALIGN JUMP_ALIGN
155.RefreshItemFromCX:
156 cmp cx, NO_ITEM_HIGHLIGHTED
157 je SHORT .NothingToRefresh
158 call Menupage_GetActiveMenupageToDSDI
159 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
160 jnc SHORT .NothingToRefresh
161 call MenuitemPrint_NameWithPossibleValueFromDSSI
162.NothingToRefresh:
163 stc
164 ret
165
166
167; Parameters:
168; CX: Index of highlighted item
169; Cursor has been positioned to the beginning of first line
170ALIGN JUMP_ALIGN
171.RefreshInformation:
172 cmp cx, NO_ITEM_HIGHLIGHTED
173 je SHORT .NothingToRefresh
174 call Menupage_GetActiveMenupageToDSDI
175 call Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
176 call MenuitemPrint_PrintQuickInfoFromDSSI
177 stc
178 ret
179
180
181; Parameters:
182; CX: Index of highlighted item
183; Cursor has been positioned to the beginning of first line
184ALIGN JUMP_ALIGN
185.RefreshTitle:
186 call .PrintProgramName
187 call .PrintLoadStatus
188 call .PrintStatusOfUnsavedChanges
189 stc
190 ret
191
192ALIGN JUMP_ALIGN
193.PrintProgramName:
194 mov si, g_szProgramTitle
195 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
196 ret
197
198ALIGN JUMP_ALIGN
199.PrintLoadStatus:
200 mov ax, [g_cfgVars+CFGVARS.wFlags]
201 test ax, FLG_CFGVARS_FILELOADED
202 jnz SHORT .PrintNameOfLoadedFile
203 test ax, FLG_CFGVARS_ROMLOADED
204 jnz SHORT .PrintLoadedEeprom
205 ; Fall to .PrintNothingLoaded
206
207.PrintNothingLoaded:
208 mov si, g_szBiosIsNotLoaded
209 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
210 ret
211
212ALIGN JUMP_ALIGN
213.PrintNameOfLoadedFile:
214 mov si, g_cfgVars+CFGVARS.szOpenedFile
215 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
216 jmp SHORT .PrintTypeOfLoadedBios
217
218ALIGN JUMP_ALIGN
219.PrintLoadedEeprom:
220 mov si, g_szEEPROM
221 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
222 ; Fall to .PrintTypeOfLoadedBios
223
224ALIGN JUMP_ALIGN
225.PrintTypeOfLoadedBios:
226 mov si, g_szSourceAndTypeSeparator
227 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
228 call Buffers_IsXtideUniversalBiosLoaded
229 jne SHORT .PrintUnidentifiedType
230
231 call Buffers_GetFileBufferToESDI
232 mov bx, es
233 lea si, [di+ROMVARS.szVersion]
234 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
235 ret
236
237ALIGN JUMP_ALIGN
238.PrintUnidentifiedType:
239 mov si, g_szUnidentified
240 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
241 ret
242
243ALIGN JUMP_ALIGN
244.PrintStatusOfUnsavedChanges:
245 test WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
246 jz SHORT .ReturnSinceNothingToPrint
247 mov si, g_szUnsaved
248 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
249.ReturnSinceNothingToPrint:
250 ret
Note: See TracBrowser for help on using the repository browser.