source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Menupages/BootMenuSettingsMenu.asm @ 592

Last change on this file since 592 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: 16.5 KB
Line 
1; Project name  :   XTIDE Universal BIOS Configurator v2
2; Description   :   "Boot settings" menu structs and functions.
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 initialized data
21SECTION .data
22
23ALIGN WORD_ALIGN
24g_MenupageForBootMenuSettingsMenu:
25istruc MENUPAGE
26    at  MENUPAGE.fnEnter,           dw  BootMenuSettingsMenu_EnterMenuOrModifyItemVisibility
27    at  MENUPAGE.fnBack,            dw  ConfigurationMenu_EnterMenuOrModifyItemVisibility
28    at  MENUPAGE.wMenuitems,        dw  7
29iend
30
31g_MenuitemBootMnuStngsBackToConfigurationMenu:
32istruc MENUITEM
33    at  MENUITEM.fnActivate,        dw  ConfigurationMenu_EnterMenuOrModifyItemVisibility
34    at  MENUITEM.szName,            dw  g_szItemBackToCfgMenu
35    at  MENUITEM.szQuickInfo,       dw  g_szNfoIdeBackToCfgMenu
36    at  MENUITEM.szHelp,            dw  g_szNfoIdeBackToCfgMenu
37    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
38    at  MENUITEM.bType,             db  TYPE_MENUITEM_PAGEBACK
39iend
40
41g_MenuitemBootMnuStngsDisplayMode:
42istruc MENUITEM
43    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
44    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
45    at  MENUITEM.szName,            dw  g_szItemBootDispMode
46    at  MENUITEM.szQuickInfo,       dw  g_szNfoDispMode
47    at  MENUITEM.szHelp,            dw  g_szNfoDispMode
48    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE
49    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
50    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.wDisplayMode
51    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgBootDispMode
52    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceBootDispMode
53    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  g_rgwChoiceToValueLookupForDisplayModes
54    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForDisplayModes
55iend
56
57g_MenuitemBootMnuStngsColorTheme:
58istruc MENUITEM
59    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
60    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
61    at  MENUITEM.szName,            dw  g_szItemColorTheme
62    at  MENUITEM.szQuickInfo,       dw  g_szNfoColorTheme
63    at  MENUITEM.szHelp,            dw  g_szHelpColorTheme
64    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_MODIFY_MENU
65    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
66    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.pColorTheme     ; Only ever read - never modified
67    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgColorTheme
68    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceColorTheme
69    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  NULL
70    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForColorTheme
71    at  MENUITEM.itemValue + ITEM_VALUE.fnValueReader,              dw  ReadColorTheme
72    at  MENUITEM.itemValue + ITEM_VALUE.fnValueWriter,              dw  WriteColorTheme
73iend
74
75g_MenuitemBootMnuStngsFloppyDrives:
76istruc MENUITEM
77    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
78    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
79    at  MENUITEM.szName,            dw  g_szItemBootFloppyDrvs
80    at  MENUITEM.szQuickInfo,       dw  g_szNfoBootFloppyDrvs
81    at  MENUITEM.szHelp,            dw  g_szHelpBootFloppyDrvs
82    at  MENUITEM.bFlags,            db  FLG_MENUITEM_VISIBLE | FLG_MENUITEM_BYTEVALUE
83    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
84    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.bMinFddCnt
85    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgBootFloppyDrvs
86    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceBootFloppyDrvs
87    at  MENUITEM.itemValue + ITEM_VALUE.rgwChoiceToValueLookup,     dw  NULL
88    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForFloppyDrives
89iend
90
91g_MenuitemBootMenuSerialScanDetect:
92istruc MENUITEM
93    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateMultichoiceSelectionForMenuitemInDSSI
94    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
95    at  MENUITEM.szName,            dw  g_szItemSerialDetect
96    at  MENUITEM.szQuickInfo,       dw  g_szNfoSerialDetect
97    at  MENUITEM.szHelp,            dw  g_szHelpSerialDetect
98    at  MENUITEM.bFlags,            db  FLG_MENUITEM_FLAGVALUE
99    at  MENUITEM.bType,             db  TYPE_MENUITEM_MULTICHOICE
100    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.wFlags
101    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgSerialDetect
102    at  MENUITEM.itemValue + ITEM_VALUE.szMultichoice,              dw  g_szMultichoiceBooleanFlag
103    at  MENUITEM.itemValue + ITEM_VALUE.rgszValueToStringLookup,    dw  g_rgszValueToStringLookupForFlagBooleans
104    at  MENUITEM.itemValue + ITEM_VALUE.wValueBitmask,              dw  FLG_ROMVARS_SERIAL_SCANDETECT
105iend
106
107g_MenuitemBootMnuStngsDefaultBootDrive:
108istruc MENUITEM
109    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateHexInputForMenuitemInDSSI
110    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
111    at  MENUITEM.szName,            dw  g_szItemBootDrive
112    at  MENUITEM.szQuickInfo,       dw  g_szNfoBootDrive
113    at  MENUITEM.szHelp,            dw  g_szHelpBootDrive
114    at  MENUITEM.bFlags,            db  FLG_MENUITEM_BYTEVALUE
115    at  MENUITEM.bType,             db  TYPE_MENUITEM_HEX
116    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.bBootDrv
117    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgBootDrive
118    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  0
119    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  0FFh
120iend
121
122g_MenuitemBootMnuStngsSelectionTimeout:
123istruc MENUITEM
124    at  MENUITEM.fnActivate,        dw  Menuitem_ActivateUnsignedInputForMenuitemInDSSI
125    at  MENUITEM.fnFormatValue,     dw  MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
126    at  MENUITEM.szName,            dw  g_szItemBootTimeout
127    at  MENUITEM.szQuickInfo,       dw  g_szNfoBootTimeout
128    at  MENUITEM.szHelp,            dw  g_szHelpBootTimeout
129    at  MENUITEM.bFlags,            db  NULL
130    at  MENUITEM.bType,             db  TYPE_MENUITEM_UNSIGNED
131    at  MENUITEM.itemValue + ITEM_VALUE.wRomvarsValueOffset,        dw  ROMVARS.wBootTimeout
132    at  MENUITEM.itemValue + ITEM_VALUE.szDialogTitle,              dw  g_szDlgBootTimeout
133    at  MENUITEM.itemValue + ITEM_VALUE.wMinValue,                  dw  2
134    at  MENUITEM.itemValue + ITEM_VALUE.wMaxValue,                  dw  1092
135iend
136
137g_rgwChoiceToValueLookupForDisplayModes:
138    dw  DEFAULT_TEXT_MODE
139    dw  CGA_TEXT_MODE_BW40
140    dw  CGA_TEXT_MODE_CO40
141    dw  CGA_TEXT_MODE_BW80
142    dw  CGA_TEXT_MODE_CO80
143    dw  MDA_TEXT_MODE
144g_rgszValueToStringLookupForDisplayModes:
145    dw  g_szValueBootDispModeBW40
146    dw  g_szValueBootDispModeCO40
147    dw  g_szValueBootDispModeBW80
148    dw  g_szValueBootDispModeCO80
149    dw  g_szValueBootDispModeDefault
150    dw  NULL
151    dw  NULL
152    dw  g_szValueBootDispModeMono
153
154g_rgszValueToStringLookupForFloppyDrives:
155    dw  g_szValueBootFloppyDrvsAuto
156    dw  g_szValueBootFloppyDrvs1
157    dw  g_szValueBootFloppyDrvs2
158    dw  g_szValueBootFloppyDrvs3
159    dw  g_szValueBootFloppyDrvs4
160
161g_rgszValueToStringLookupForColorTheme:
162    dw  g_szValueColorTheme0
163    dw  g_szValueColorTheme1
164    dw  g_szValueColorTheme2
165    dw  g_szValueColorTheme3
166    dw  g_szValueColorTheme4
167    dw  g_szValueColorTheme5
168
169ColorThemeTable:
170    ; Classic (default)
171    db  COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_BLUE)                           ; .cBordersAndBackground
172    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cShadow
173    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLUE)                     ; .cTitle
174    db  COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLUE)                            ; .cItem
175    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_CYAN)                     ; .cHighlightedItem
176    db  COLOR_ATTRIBUTE(COLOR_RED, COLOR_BLUE) | FLG_COLOR_BLINK            ; .cHurryTimeout
177    db  COLOR_ATTRIBUTE(COLOR_GREEN, COLOR_BLUE)                            ; .cNormalTimeout
178    ; Argon Blue
179    db  COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK)                      ; .cBordersAndBackground
180    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cShadow
181    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)                    ; .cTitle
182    db  COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)                           ; .cItem
183    db  COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK)                      ; .cHighlightedItem
184    db  COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK) | FLG_COLOR_BLINK    ; .cHurryTimeout
185    db  COLOR_ATTRIBUTE(COLOR_LIGHT_BLUE, COLOR_BLACK)                      ; .cNormalTimeout
186    ; Neon Red
187    db  COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)                       ; .cBordersAndBackground
188    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cShadow
189    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)                    ; .cTitle
190    db  COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)                           ; .cItem
191    db  COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)                       ; .cHighlightedItem
192    db  COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK) | FLG_COLOR_BLINK     ; .cHurryTimeout
193    db  COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)                       ; .cNormalTimeout
194    ; Phosphor Green
195    db  COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)                     ; .cBordersAndBackground
196    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cShadow
197    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)                    ; .cTitle
198    db  COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)                           ; .cItem
199    db  COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)                     ; .cHighlightedItem
200    db  COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK) | FLG_COLOR_BLINK   ; .cHurryTimeout
201    db  COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)                     ; .cNormalTimeout
202    ; Moon Surface
203    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cBordersAndBackground
204    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cShadow
205    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK)                    ; .cTitle
206    db  COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)                           ; .cItem
207    db  COLOR_ATTRIBUTE(COLOR_BROWN, COLOR_BLACK)                           ; .cHighlightedItem
208    db  COLOR_ATTRIBUTE(COLOR_BRIGHT_WHITE, COLOR_BLACK) | FLG_COLOR_BLINK  ; .cHurryTimeout
209    db  COLOR_ATTRIBUTE(COLOR_WHITE, COLOR_BLACK)                           ; .cNormalTimeout
210    ; Toxic Waste
211    db  COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)                     ; .cBordersAndBackground
212    db  COLOR_ATTRIBUTE(COLOR_GRAY, COLOR_BLACK)                            ; .cShadow
213    db  COLOR_ATTRIBUTE(COLOR_LIGHT_GREEN, COLOR_BLACK)                     ; .cTitle
214    db  COLOR_ATTRIBUTE(COLOR_LIGHT_CYAN, COLOR_BLACK)                      ; .cItem
215    db  COLOR_ATTRIBUTE(COLOR_LIGHT_CYAN, COLOR_BLUE)                       ; .cHighlightedItem
216    db  COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK) | FLG_COLOR_BLINK     ; .cHurryTimeout
217    db  COLOR_ATTRIBUTE(COLOR_LIGHT_RED, COLOR_BLACK)                       ; .cNormalTimeout
218EndOfColorThemeTable:
219CountOfThemes   equ     (EndOfColorThemeTable-ColorThemeTable) / ATTRIBUTE_CHARS_size
220
221
222; Section containing code
223SECTION .text
224
225;--------------------------------------------------------------------
226; BootMenuSettingsMenu_EnterMenuOrModifyItemVisibility
227;   Parameters:
228;       SS:BP:  Menu handle
229;   Returns:
230;       Nothing
231;   Corrupts registers:
232;       All, except BP
233;--------------------------------------------------------------------
234ALIGN JUMP_ALIGN
235BootMenuSettingsMenu_EnterMenuOrModifyItemVisibility:
236    push    cs
237    pop     ds
238    call    Buffers_GetRomvarsFlagsToAX
239    call    .EnableOrDisableScanForSerialDrives
240    call    .EnableOrDisableDefaultBootDrive
241    call    .EnableOrDisableColorThemeSelection
242    call    .EnableOrDisableBootMenuSelectionTimeout
243    mov     si, g_MenupageForBootMenuSettingsMenu
244    jmp     Menupage_ChangeToNewMenupageInDSSI
245
246
247;--------------------------------------------------------------------
248; .EnableOrDisableScanForSerialDrives
249;   Parameters:
250;       AX:     ROMVARS.wFlags
251;       SS:BP:  Menu handle
252;   Returns:
253;       Nothing
254;   Corrupts registers:
255;       BX
256;--------------------------------------------------------------------
257ALIGN JUMP_ALIGN
258.EnableOrDisableScanForSerialDrives:
259    mov     bx, g_MenuitemBootMenuSerialScanDetect
260    test    ax, FLG_ROMVARS_MODULE_SERIAL
261    jmp     SHORT .DisableMenuitemFromCSBXifZFset
262
263
264;--------------------------------------------------------------------
265; .EnableOrDisableDefaultBootDrive
266;   Parameters:
267;       AX:     ROMVARS.wFlags
268;       SS:BP:  Menu handle
269;   Returns:
270;       Nothing
271;   Corrupts registers:
272;       BX
273;--------------------------------------------------------------------
274ALIGN JUMP_ALIGN
275.EnableOrDisableDefaultBootDrive:
276    mov     bx, g_MenuitemBootMnuStngsDefaultBootDrive
277    test    ax, FLG_ROMVARS_MODULE_HOTKEYS | FLG_ROMVARS_MODULE_BOOT_MENU
278    jmp     SHORT .DisableMenuitemFromCSBXifZFset
279
280
281;--------------------------------------------------------------------
282; .EnableOrDisableColorThemeSelection
283;   Parameters:
284;       AX:     ROMVARS.wFlags
285;       SS:BP:  Menu handle
286;   Returns:
287;       Nothing
288;   Corrupts registers:
289;       BX
290;--------------------------------------------------------------------
291ALIGN JUMP_ALIGN
292.EnableOrDisableColorThemeSelection:
293    mov     bx, g_MenuitemBootMnuStngsColorTheme
294    test    ax, FLG_ROMVARS_MODULE_BOOT_MENU
295    jmp     SHORT .DisableMenuitemFromCSBXifZFset
296
297
298;--------------------------------------------------------------------
299; .EnableOrDisableBootMenuSelectionTimeout
300;   Parameters:
301;       AX:     ROMVARS.wFlags
302;       SS:BP:  Menu handle
303;   Returns:
304;       Nothing
305;   Corrupts registers:
306;       BX
307;--------------------------------------------------------------------
308ALIGN JUMP_ALIGN
309.EnableOrDisableBootMenuSelectionTimeout:
310    mov     bx, g_MenuitemBootMnuStngsSelectionTimeout
311    test    ax, FLG_ROMVARS_MODULE_BOOT_MENU
312.DisableMenuitemFromCSBXifZFset:
313    jz      SHORT .DisableMenuitemFromCSBX
314    ; Fall to .EnableMenuitemFromCSBX
315
316
317;--------------------------------------------------------------------
318; .EnableMenuitemFromCSBX
319; .DisableMenuitemFromCSBX
320;   Parameters:
321;       CS:BX:  Ptr to MENUITEM
322;   Returns:
323;       Nothing
324;   Corrupts registers:
325;       Nothing
326;--------------------------------------------------------------------
327ALIGN JUMP_ALIGN
328.EnableMenuitemFromCSBX:
329    jmp     EnableMenuitemFromCSBX
330
331ALIGN JUMP_ALIGN
332.DisableMenuitemFromCSBX:
333    jmp     DisableMenuitemFromCSBX
334
335
336;--------------------------------------------------------------------
337; ReadColorTheme
338;   Parameters:
339;       AX:     Value read from the ROMVARS location
340;       ES:DI:  ROMVARS location where the value was just read from
341;       DS:SI:  MENUITEM pointer
342;   Returns:
343;       AX:     Value that the MENUITEM system will interact with and display
344;   Corrupts registers:
345;       BX, DI, ES
346;--------------------------------------------------------------------
347ALIGN JUMP_ALIGN
348ReadColorTheme:
349    push    ds
350
351    push    es                          ; ES -> DS
352    pop     ds
353    push    cs                          ; CS -> ES
354    pop     es
355
356    mov     di, EndOfColorThemeTable-1  ; ES:DI now points to the end of the last theme in the table of available themes in XTIDECFG
357    xor     bx, bx
358
359    push    si
360    push    cx
361    mov     cx, CountOfThemes
362    std
363.NextTheme:
364    push    cx
365    mov     cl, ATTRIBUTE_CHARS_size
366    mov     si, ax                      ; [ROMVARS.pColorTheme] to SI
367    dec     si
368    add     si, cx                      ; DS:SI now points to the end of the ColorTheme in the loaded BIOS
369    sub     di, bx                      ; Update the pointer to the end of the next theme in the table
370
371    ; We verify that the theme in the loaded BIOS exists in our table. If it doesn't exist then that most likely means
372    ; the loaded BIOS doesn't contain MODULE_BOOT_MENU and the theme actually isn't a theme - it's code. Either way,
373    ; we don't trust it enough to copy it over as corrupt/invalid settings could render the UI in XTIDECFG unreadable.
374    repe    cmpsb
375    mov     bx, cx
376    pop     cx
377    loopne  .NextTheme
378    cld
379    mov     ax, cx
380    jne     SHORT .SkipCopy
381
382    ; Copy the color theme fron the loaded BIOS overwriting XTIDECFG's own theme
383    inc     si
384    mov     di, ColorTheme              ; ES:DI now points to ColorTheme in XTIDECFG
385
386    mov     cl, ATTRIBUTE_CHARS_size
387    call    Memory_CopyCXbytesFromDSSItoESDI
388
389.SkipCopy:
390    pop     cx
391    pop     si
392    pop     ds
393    ret
394
395
396;--------------------------------------------------------------------
397; WriteColorTheme
398;   Parameters:
399;       AX:     Value that the MENUITEM system was interacting with
400;       ES:DI:  ROMVARS location where the value is to be stored
401;       DS:SI:  MENUITEM pointer
402;   Returns:
403;       AX:     Value to actually write to ROMVARS
404;   Corrupts registers:
405;       Nothing
406;--------------------------------------------------------------------
407ALIGN JUMP_ALIGN
408WriteColorTheme:
409    push    cx
410    push    si
411    push    di
412
413    mov     cx, ATTRIBUTE_CHARS_size
414    mul     cl                          ; Multiply with the menu choice index
415    mov     si, ColorThemeTable
416    add     si, ax
417    mov     ax, [es:di]                 ; Fetch the ptr to ColorTheme
418    mov     di, ax
419
420    call    Memory_CopyCXbytesFromDSSItoESDI
421
422    pop     di
423    pop     si
424    pop     cx
425    ret
426
Note: See TracBrowser for help on using the repository browser.