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