source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Menus/HotkeyBar.asm @ 500

Last change on this file since 500 was 500, checked in by aitotat@…, 11 years ago

Changes to XTIDE Universal BIOS:

  • Selected drive is again properly displayed on hotkeybar when MODULE_BOOT_MENU is not available.
File size: 12.8 KB
RevLine 
[392]1; Project name  :   XTIDE Universal BIOS
2; Description   :   Hotkey Bar related functions.
3
4;
[399]5; XTIDE Universal BIOS and Associated Tools
[392]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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.
[399]12;
[392]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.
[399]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
[392]19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; HotkeyBar_UpdateDuringDriveDetection
25;   Parameters:
26;       DS:     RAMVARS segment
27;       ES:     BDA segment (zero)
28;   Returns:
29;       Nothing
30;   Corrupts registers:
31;       AX, CX, DX, SI, DI
32;--------------------------------------------------------------------
33HotkeyBar_UpdateDuringDriveDetection:
[492]34    call    HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]35    ; Fall to HotkeyBar_DrawToTopOfScreen
[492]36       
37       
[392]38;--------------------------------------------------------------------
39; HotkeyBar_DrawToTopOfScreen
40;   Parameters:
41;       DS:     RAMVARS segment
42;       ES:     BDA segment (zero)
43;   Returns:
44;       Nothing
45;   Corrupts registers:
46;       AX, CX, DX, SI, DI
47;--------------------------------------------------------------------
48HotkeyBar_DrawToTopOfScreen:
49    ; Store current screen coordinates to be restored
50    ; when Hotkey Bar is rendered
51    call    DetectPrint_GetSoftwareCoordinatesToAX
52    push    ax
53
54    call    MoveCursorToScreenTopLeftCorner
55    ; Fall to .PrintFloppyDriveHotkeys
56
57;--------------------------------------------------------------------
58; .PrintFloppyDriveHotkeys
59;   Parameters:
60;       DS:     RAMVARS segment
61;       ES:     BDA segment (zero)
62;   Returns:
63;       Nothing
64;   Corrupts registers:
65;       AX, CX, DX, SI, DI
66;--------------------------------------------------------------------
67.PrintFloppyDriveHotkeys:
68    call    FloppyDrive_GetCountToAX
69    test    ax, ax      ; Any Floppy Drives?
70    jz      SHORT .SkipFloppyDriveHotkeys
71
[492]72    mov     ax, (ANGLE_QUOTE_RIGHT << 8) | DEFAULT_FLOPPY_DRIVE_LETTER
[500]73    mov     cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFddLetter]
[492]74    mov     di, g_szFDD
[392]75    call    FormatDriveHotkeyString
76
77.SkipFloppyDriveHotkeys:
78    ; Fall to .PrintHardDriveHotkeys
79
80;--------------------------------------------------------------------
81; .PrintHardDriveHotkeys
82;   Parameters:
83;       DS:     RAMVARS segment
84;       ES:     BDA segment (zero)
85;   Returns:
86;       Nothing
87;   Corrupts registers:
88;       AX, CX, DX, SI, DI
89;--------------------------------------------------------------------
[492]90    call    DriveXlate_GetLetterForFirstHardDriveToAX
[392]91    mov     ah, ANGLE_QUOTE_RIGHT
[500]92    mov     cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bHddLetter]
[492]93    mov     di, g_szHDD
[392]94    call    FormatDriveHotkeyString
95    ; Fall to .PrintBootMenuHotkey
96
97;--------------------------------------------------------------------
98; .PrintBootMenuHotkey
99;   Parameters:
100;       ES:     BDA segment (zero)
101;   Returns:
102;       Nothing
103;   Corrupts registers:
104;       AX, CX, DX, SI, DI
105;--------------------------------------------------------------------
106.PrintBootMenuHotkey:
107%ifdef MODULE_BOOT_MENU
[492]108    mov     ax, BOOT_MENU_HOTKEY_SCANCODE | ('2' << 8)
109    mov     di, g_szBootMenu
[392]110    call    FormatFunctionHotkeyString
111%endif
[492]112    ; Fall to .PrintComDetectHotkey
[392]113
114;--------------------------------------------------------------------
[492]115; .PrintComDetectHotkey
116;   Parameters:
117;       ES:     BDA segment (zero)
118;   Returns:
119;       Nothing
120;   Corrupts registers:
121;       AX, CX, DX, SI, DI
122;--------------------------------------------------------------------
123.PrintComDetectHotkey:
124%ifdef MODULE_SERIAL
125    mov     ax, COM_DETECT_HOTKEY_SCANCODE | ('6' << 8)
126    mov     di, g_szHotComDetect
127    call    FormatFunctionHotkeyString
128%endif
129    ; Fall to .PrintRomBootHotkey       
130
131;--------------------------------------------------------------------
[392]132; .PrintRomBootHotkey
133;   Parameters:
134;       ES:     BDA segment (zero)
135;   Returns:
136;       Nothing
137;   Corrupts registers:
138;       AX, CX, DX, SI, DI
139;--------------------------------------------------------------------
140.PrintRomBootHotkey:
[492]141    mov     ax, ROM_BOOT_HOTKEY_SCANCODE | ('8' << 8)
142    mov     di, g_szRomBoot
[392]143    call    FormatFunctionHotkeyString
144    ; Fall to .EndHotkeyBarRendering
145
146;--------------------------------------------------------------------
147; .EndHotkeyBarRendering
148;   Parameters:
149;       Stack:  Screen coordinates before drawing Hotkey Bar
150;   Returns:
151;       Nothing
152;   Corrupts registers:
153;       AX, CX, DI
154;--------------------------------------------------------------------
155.EndHotkeyBarRendering:
156    call    HotkeyBar_ClearRestOfTopRow
157    pop     ax
158    jmp     SHORT HotkeyBar_RestoreCursorCoordinatesFromAX
159
160
161;--------------------------------------------------------------------
162; HotkeyBar_ClearRestOfTopRow
163;   Parameters:
164;       Nothing
165;   Returns:
166;       Nothing
167;   Corrupts registers:
168;       AX, CX, DI
169;--------------------------------------------------------------------
170HotkeyBar_ClearRestOfTopRow:
171    CALL_DISPLAY_LIBRARY    GetColumnsToALandRowsToAH
172    eMOVZX  cx, al
173    CALL_DISPLAY_LIBRARY    GetSoftwareCoordinatesToAX
174    sub     cl, al
175    mov     al, ' '
176    CALL_DISPLAY_LIBRARY    PrintRepeatedCharacterFromALwithCountInCX
177    ret
178
179
180;--------------------------------------------------------------------
181; FormatDriveHotkeyString
182;   Parameters:
183;       CL:         Drive letter hotkey from BOOTVARS
[492]184;       AL:         First character for drive key string
185;       AH:         Second character for drive key string (ANGLE_QUOTE_RIGHT)
[392]186;       SI:         Offset to hotkey description string
187;       ES:         BDA segment (zero)
188;   Returns:
189;       Nothing
190;   Corrupts registers:
191;       AX, CX, DX, SI, DI
192;--------------------------------------------------------------------
[492]193;; No work to do before going into FormatFunctionHotkeyString
194FormatDriveHotkeyString  equ  GetNonSelectedHotkeyDescriptionAttributeToDX
[392]195
196;--------------------------------------------------------------------
197; FormatFunctionHotkeyString
198;   Parameters:
[492]199;       AL:         Scancode of function key, to know which if any to show as selected
200;                   Later replaced with an 'F' for the call to the output routine
201;       AH:         Second character for drive key string
[392]202;       SI:         Offset to hotkey description string
203;       ES:         BDA segment (zero)
204;   Returns:
205;       Nothing
206;   Corrupts registers:
207;       AX, CX, DX, SI, DI
208;--------------------------------------------------------------------
209FormatFunctionHotkeyString:
[492]210    xor     cx, cx      ; Null character, eaten in output routines
[392]211
[492]212    cmp     [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
213    mov     al, 'F'     ; Replace scancode with character for output
[392]214
215%ifdef MODULE_BOOT_MENU
[492]216
[392]217    mov     si, ATTRIBUTE_CHARS.cHurryTimeout       ; Selected hotkey
[492]218    jz      SHORT GetDescriptionAttributeToDX       ; From compare with bScancode above
[392]219
220GetNonSelectedHotkeyDescriptionAttributeToDX:
221    mov     si, ATTRIBUTE_CHARS.cHighlightedItem    ; Unselected hotkey
222
223    ; Display Library should not be called like this
224GetDescriptionAttributeToDX:
[492]225    xchg    dx, ax
[392]226    call    MenuAttribute_GetToAXfromTypeInSI
227    xchg    dx, ax                  ; DX = Description attribute
[492]228    ;;  fall through to PushHotkeyParamsAndFormat 
[392]229
230
[500]231%else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes
232
[410]233    mov     dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
[492]234    jz      SHORT SelectAttributeFromDHorDLbasedOnVideoMode         ; From compare with bScancode above
[392]235
236GetNonSelectedHotkeyDescriptionAttributeToDX:
[410]237    mov     dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
[492]238
[410]239SelectAttributeFromDHorDLbasedOnVideoMode:
[500]240    mov     ch, [es:BDA.bVidMode]       ; We only need to preserve CL
241    shr     ch, 1
[410]242    jnc     SHORT .AttributeLoadedToDL  ; Black & White modes
[500]243    shr     ch, 1
[410]244    jnz     SHORT .AttributeLoadedToDL  ; MDA
245    mov     dl, dh
246.AttributeLoadedToDL:
[492]247    ;;  fall through to PushHotkeyParamsAndFormat       
[410]248
[492]249%endif ; MODULE_BOOT_MENU
[392]250
251
252;--------------------------------------------------------------------
253; PushHotkeyParamsAndFormat
254;   Parameters:
[500]255;       AL:         First character
256;       AH:         Second character
[392]257;       DX:         Description Attribute
258;       CX:         Description string parameter
[492]259;       CS:DI:      Description string
[392]260;   Returns:
261;       Nothing
262;   Corrupts registers:
263;       AX, SI, DI
264;--------------------------------------------------------------------
265PushHotkeyParamsAndFormat:
266    push    bp
267    mov     bp, sp
268
[492]269    mov     si, MONO_BRIGHT
[392]270
[492]271    push    si              ; Key attribute
272    push    ax              ; First Character
273    mov     al, ah
274    push    ax              ; Second Character
275
[392]276    push    dx              ; Description attribute
[492]277    push    di              ; Description string
[392]278    push    cx              ; Description string parameter
[492]279       
280    push    si              ; Key attribute for last space
[392]281
282    mov     si, g_szHotkey
283    jmp     DetectPrint_FormatCSSIfromParamsInSSBP
284
285
286;--------------------------------------------------------------------
287; MoveCursorToScreenTopLeftCorner
288;   Parameters:
289;       Nothing
290;   Returns:
291;       Nothing
292;   Corrupts registers:
293;       AX, DI
294;--------------------------------------------------------------------
295MoveCursorToScreenTopLeftCorner:
296    xor     ax, ax          ; Top left corner (0, 0)
297    ; Fall to HotkeyBar_RestoreCursorCoordinatesFromAX
298
299
300;--------------------------------------------------------------------
301; HotkeyBar_RestoreCursorCoordinatesFromAX
302;   Parameters:
303;       Nothing
304;   Returns:
305;       Nothing
306;   Corrupts registers:
307;       AX, DI
308;--------------------------------------------------------------------
309HotkeyBar_RestoreCursorCoordinatesFromAX:
310    CALL_DISPLAY_LIBRARY    SetCursorCoordinatesFromAX
311    ret
312
313
314;--------------------------------------------------------------------
[395]315; HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
316;   Parameters:
317;       DS:     RAMVARS segment
318;       ES:     BDA segment (zero)
319;       DL:     Drive Letter ('A'...)
320;   Returns:
321;       Nothing
322;   Corrupts registers:
323;       AX, CX, DI
324;--------------------------------------------------------------------
325HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL:
326    eMOVZX  ax, dl
[491]327    xor     al, 32  ; Upper case drive letter to lower case keystroke
[395]328    jmp     SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
329
330
331;--------------------------------------------------------------------
[492]332; HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]333;   Parameters:
334;       DS:     RAMVARS segment
335;       ES:     BDA segment (zero)
336;   Returns:
[492]337;       AL:     Last scancode value
[392]338;   Corrupts registers:
[492]339;       AH, CX
[392]340;--------------------------------------------------------------------
[492]341HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars:
[392]342    call    Keyboard_GetKeystrokeToAX
343    jz      SHORT NoHotkeyToProcess
344
[492]345    ePUSH_T cx, HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]346    ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
347
348
349;--------------------------------------------------------------------
350; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
351;   Parameters:
352;       AL:     Hotkey ASCII code
353;       AH:     Hotkey Scancode
354;       DS:     RAMVARS segment
355;       ES:     BDA segment (zero)
356;   Returns:
[492]357;       AL:     Last scancode seen
[392]358;   Corrupts registers:
[492]359;       AH, CX, DI
[392]360;--------------------------------------------------------------------
361HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
[492]362    mov     di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
[392]363
[492]364    ; All scancodes are saved, even if it wasn't a drive letter,
365    ; which also covers our function key case.  Invalid function keys
366    ; will not do anything (won't be printed, won't be accepted as input)       
367    mov     [es:di], ah
368       
[392]369    ; Drive letter hotkeys remaining, allow 'a' to 'z'
370    call    Char_IsLowerCaseLetterInAL
[492]371    jnc     SHORT .KeystrokeIsNotValidDriveLetter
[491]372    xor     al, 32                  ; We want to print upper case letters
[392]373
374    ; Clear HD First flag to assume Floppy Drive hotkey
[492]375    dec     di
[392]376    and     BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
377
378    ; Determine if Floppy or Hard Drive hotkey
379    eMOVZX  cx, al                  ; Clear CH to clear scancode
[492]380    call    DriveXlate_GetLetterForFirstHardDriveToAX
[392]381    cmp     cl, al
382    jb      SHORT .StoreDriveLetter ; Store Floppy Drive letter
383
384    ; Store Hard Drive letter
385    or      BYTE [es:di], FLG_HOTKEY_HD_FIRST
386
387.StoreDriveLetter:
[492]388    sbb     di, BYTE 1          ; Sub CF if Floppy Drive
[392]389    xchg    ax, cx
[399]390    mov     [es:di], al         ; AH = zero to clear function hotkey
[392]391
[492]392.KeystrokeIsNotValidDriveLetter:       
[392]393NoHotkeyToProcess:
[492]394    mov     al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
[392]395    ret
396
397;--------------------------------------------------------------------
[492]398; HotkeyBar_GetBootDriveNumbersToDX
[392]399;   Parameters:
400;       DS:     RAMVARS segment
401;       ES:     BDA segment (zero)
402;   Returns:
[492]403;       DX:     Drives selected as boot device, DL is primary
[392]404;   Corrupts registers:
[492]405;       AX
[392]406;--------------------------------------------------------------------
[492]407HotkeyBar_GetBootDriveNumbersToDX:
[500]408    mov     dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters]
[492]409    test    BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST       
410    jnz     .noflip
[392]411    xchg    dl, dh
[492]412.noflip:   
413    call    DriveXlate_ConvertDriveLetterInDLtoDriveNumber
414    xchg    dl, dh
415    ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber       
416       
417HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:     
[392]418
Note: See TracBrowser for help on using the repository browser.