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

Last change on this file was 592, checked in by krille_n_, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 6.7 KB
Line 
1; Project name  :   XTIDE Universal BIOS Configurator v2
2; Description   :   Menu event handling.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; MenuEvents_DisplayMenu
25;   Parameters:
26;       Nothing
27;   Returns:
28;       Nothing
29;   Corrupts registers:
30;       All, except segments
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33MenuEvents_DisplayMenu:
34    mov     bx, MenuEventHandler
35    JMP_MENU_LIBRARY DisplayWithHandlerInBXandUserDataInDXAX
36
37
38;--------------------------------------------------------------------
39; MenuEventHandler
40;   Common parameters for all events:
41;       BX:         Menu event (anything from MENUEVENT struct)
42;       SS:BP:      Menu library handle
43;   Common return values for all events:
44;       CF:         Set if event processed
45;                   Cleared if event not processed
46;   Corrupts registers:
47;       All
48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
50MenuEventHandler:
51    cmp     bx, MENUEVENT.RefreshItemFromCX ; Above last supported item?
52    ja      SHORT .EventNotHandled
53    jmp     [cs:bx+.rgfnEventSpecificHandlers]
54.EventNotHandled:
55.IdleProcessing:
56    clc
57    ret
58
59ALIGN WORD_ALIGN
60.rgfnEventSpecificHandlers:
61    dw      .InitializeMenuinitFromDSSI
62    dw      .ExitMenu
63    dw      .IdleProcessing
64    dw      .ItemHighlightedFromCX
65    dw      .ItemSelectedFromCX
66    dw      .KeyStrokeInAX
67    dw      .RefreshTitle
68    dw      .RefreshInformation
69    dw      .RefreshItemFromCX
70
71
72; Parameters:
73;   DS:SI:      Ptr to MENUINIT struct to initialize
74; Returns:
75;   DS:SI:      Ptr to initialized MENUINIT struct
76ALIGN JUMP_ALIGN
77.InitializeMenuinitFromDSSI:
78    push    ds
79    push    cs
80    pop     ds
81    mov     di, g_MenupageForMainMenu
82    call    Menupage_SetActiveMenupageFromDSDI
83    call    Menupage_GetVisibleMenuitemsToAXfromDSDI
84    pop     ds
85
86    mov     [si+MENUINIT.wItems], ax
87    mov     WORD [si+MENUINIT.wTitleAndInfoLines], INFO_LINES_IN_MENU << 8 | TITLE_LINES_IN_MENU
88    mov     BYTE [si+MENUINIT.bWidth], MENU_WIDTH
89    CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
90    mov     [si+MENUINIT.bHeight], ah
91    call    MainMenu_EnterMenuOrModifyItemVisibility
92    stc
93    ret
94
95
96; Parameters:
97;   None
98; Returns:
99;   CF:     Set to exit menu
100;           Clear to cancel exit
101ALIGN JUMP_ALIGN
102.ExitMenu:
103    call    Menupage_GetActiveMenupageToDSDI
104    mov     si, [di+MENUPAGE.fnBack]
105    cmp     si, ExitToDosFromBackButton
106    je      SHORT .QuitProgram
107    call    si                  ; Back to previous menu
108    clc
109    ret
110
111ALIGN JUMP_ALIGN
112.QuitProgram:
113    mov     bx, g_szDlgExitToDos
114    call    Dialogs_DisplayYesNoResponseDialogWithTitleStringInBX
115    jz      SHORT .ExitToDOS
116    clc
117    ret
118.ExitToDOS:
119    call    Buffers_SaveChangesIfFileLoaded
120    CALL_MENU_LIBRARY Close
121    stc
122    ret
123
124
125; Parameters:
126;   CX:         Index of new highlighted item
127;   DX:         Index of previously highlighted item or NO_ITEM_HIGHLIGHTED
128ALIGN JUMP_ALIGN
129.ItemHighlightedFromCX:
130    CALL_MENU_LIBRARY ClearInformationArea
131    CALL_MENU_LIBRARY RefreshInformation
132    stc
133    ret
134
135
136; Parameters:
137;   CX:         Index of selected item
138ALIGN JUMP_ALIGN
139.ItemSelectedFromCX:
140    call    Menupage_GetActiveMenupageToDSDI
141    call    Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
142    call    [si+MENUITEM.fnActivate]
143    stc
144    ret
145
146
147; Parameters:
148;   AL:         ASCII character for the key
149;   AH:         Keyboard library scan code for the key
150ALIGN JUMP_ALIGN
151.KeyStrokeInAX:
152    cmp     ah, KEY_DISPLAY_ITEM_HELP
153    jne     SHORT .EventNotHandled
154
155;ALIGN JUMP_ALIGN
156;.DisplayHelp:
157    call    Menupage_GetActiveMenupageToDSDI
158    CALL_MENU_LIBRARY GetHighlightedItemToAX
159    xchg    cx, ax
160    call    Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
161    call    Menuitem_DisplayHelpMessageFromDSSI
162    stc
163    ret
164
165
166; Parameters:
167;   CX:         Index of item to refresh
168;   Cursor has been positioned to the beginning of item line
169ALIGN JUMP_ALIGN
170.RefreshItemFromCX:
171    inc     cx                  ; NO_ITEM_HIGHLIGHTED ?
172    jz      SHORT .NothingToRefresh
173    dec     cx
174    call    Menupage_GetActiveMenupageToDSDI
175    call    Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
176    jnc     SHORT .NothingToRefresh
177    call    MenuitemPrint_NameWithPossibleValueFromDSSI
178.NothingToRefresh:
179    stc
180    ret
181
182
183; Parameters:
184;   CX:         Index of highlighted item
185;   Cursor has been positioned to the beginning of first line
186ALIGN JUMP_ALIGN
187.RefreshInformation:
188    inc     cx                  ; NO_ITEM_HIGHLIGHTED ?
189    jz      SHORT .NothingToRefresh
190    dec     cx
191    call    Menupage_GetActiveMenupageToDSDI
192    call    Menupage_GetCXthVisibleMenuitemToDSSIfromDSDI
193    call    MenuitemPrint_PrintQuickInfoFromDSSI
194    stc
195    ret
196
197
198; Parameters:
199;   CX:         Index of highlighted item
200;   Cursor has been positioned to the beginning of first line
201ALIGN JUMP_ALIGN
202.RefreshTitle:
203    call    .PrintProgramName
204    call    .PrintLoadStatus
205    call    .PrintStatusOfUnsavedChanges
206    stc
207.ReturnSinceNothingToPrint:
208    ret
209
210ALIGN JUMP_ALIGN
211.PrintProgramName:
212    mov     si, g_szProgramTitle
213    JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
214
215ALIGN JUMP_ALIGN
216.PrintLoadStatus:
217    mov     al, [g_cfgVars+CFGVARS.wFlags]
218    test    al, FLG_CFGVARS_FILELOADED
219    jnz     SHORT .PrintNameOfLoadedFile
220    test    al, FLG_CFGVARS_ROMLOADED
221    mov     si, g_szEEPROM
222    jnz     SHORT .PrintNameOfLoadedFileOrEeprom
223    ; Fall to .PrintNothingLoaded
224
225.PrintNothingLoaded:
226    mov     si, g_szBiosIsNotLoaded
227    JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
228
229ALIGN JUMP_ALIGN
230.PrintNameOfLoadedFile:
231    mov     si, g_cfgVars+CFGVARS.szOpenedFile
232    ; Fall to .PrintNameOfLoadedFileOrEeprom
233
234ALIGN JUMP_ALIGN
235.PrintNameOfLoadedFileOrEeprom:
236    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
237    ; Fall to .PrintTypeOfLoadedBios
238
239.PrintTypeOfLoadedBios:
240    mov     si, g_szSourceAndTypeSeparator
241    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
242    call    Buffers_IsXtideUniversalBiosLoaded
243    jne     SHORT .PrintUnidentifiedType
244
245    call    Buffers_GetFileBufferToESDI
246    mov     bx, es
247    lea     si, [di+ROMVARS.szVersion]
248    JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
249
250ALIGN JUMP_ALIGN
251.PrintUnidentifiedType:
252    mov     si, g_szUnidentified
253    JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
254
255ALIGN JUMP_ALIGN
256.PrintStatusOfUnsavedChanges:
257    test    BYTE [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
258    jz      SHORT .ReturnSinceNothingToPrint
259    mov     si, g_szUnsaved
260    JMP_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
Note: See TracBrowser for help on using the repository browser.