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
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Hotkey Bar related functions.
3
4;
5; XTIDE Universal BIOS and Associated Tools
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.
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; 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:
34    call    HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
35    ; Fall to HotkeyBar_DrawToTopOfScreen
36       
37       
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
72    mov     ax, (ANGLE_QUOTE_RIGHT << 8) | DEFAULT_FLOPPY_DRIVE_LETTER
73    mov     cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFddLetter]
74    mov     di, g_szFDD
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;--------------------------------------------------------------------
90    call    DriveXlate_GetLetterForFirstHardDriveToAX
91    mov     ah, ANGLE_QUOTE_RIGHT
92    mov     cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bHddLetter]
93    mov     di, g_szHDD
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
108    mov     ax, BOOT_MENU_HOTKEY_SCANCODE | ('2' << 8)
109    mov     di, g_szBootMenu
110    call    FormatFunctionHotkeyString
111%endif
112    ; Fall to .PrintComDetectHotkey
113
114;--------------------------------------------------------------------
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;--------------------------------------------------------------------
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:
141    mov     ax, ROM_BOOT_HOTKEY_SCANCODE | ('8' << 8)
142    mov     di, g_szRomBoot
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
184;       AL:         First character for drive key string
185;       AH:         Second character for drive key string (ANGLE_QUOTE_RIGHT)
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;--------------------------------------------------------------------
193;; No work to do before going into FormatFunctionHotkeyString
194FormatDriveHotkeyString  equ  GetNonSelectedHotkeyDescriptionAttributeToDX
195
196;--------------------------------------------------------------------
197; FormatFunctionHotkeyString
198;   Parameters:
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
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:
210    xor     cx, cx      ; Null character, eaten in output routines
211
212    cmp     [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
213    mov     al, 'F'     ; Replace scancode with character for output
214
215%ifdef MODULE_BOOT_MENU
216
217    mov     si, ATTRIBUTE_CHARS.cHurryTimeout       ; Selected hotkey
218    jz      SHORT GetDescriptionAttributeToDX       ; From compare with bScancode above
219
220GetNonSelectedHotkeyDescriptionAttributeToDX:
221    mov     si, ATTRIBUTE_CHARS.cHighlightedItem    ; Unselected hotkey
222
223    ; Display Library should not be called like this
224GetDescriptionAttributeToDX:
225    xchg    dx, ax
226    call    MenuAttribute_GetToAXfromTypeInSI
227    xchg    dx, ax                  ; DX = Description attribute
228    ;;  fall through to PushHotkeyParamsAndFormat 
229
230
231%else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes
232
233    mov     dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
234    jz      SHORT SelectAttributeFromDHorDLbasedOnVideoMode         ; From compare with bScancode above
235
236GetNonSelectedHotkeyDescriptionAttributeToDX:
237    mov     dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
238
239SelectAttributeFromDHorDLbasedOnVideoMode:
240    mov     ch, [es:BDA.bVidMode]       ; We only need to preserve CL
241    shr     ch, 1
242    jnc     SHORT .AttributeLoadedToDL  ; Black & White modes
243    shr     ch, 1
244    jnz     SHORT .AttributeLoadedToDL  ; MDA
245    mov     dl, dh
246.AttributeLoadedToDL:
247    ;;  fall through to PushHotkeyParamsAndFormat       
248
249%endif ; MODULE_BOOT_MENU
250
251
252;--------------------------------------------------------------------
253; PushHotkeyParamsAndFormat
254;   Parameters:
255;       AL:         First character
256;       AH:         Second character
257;       DX:         Description Attribute
258;       CX:         Description string parameter
259;       CS:DI:      Description string
260;   Returns:
261;       Nothing
262;   Corrupts registers:
263;       AX, SI, DI
264;--------------------------------------------------------------------
265PushHotkeyParamsAndFormat:
266    push    bp
267    mov     bp, sp
268
269    mov     si, MONO_BRIGHT
270
271    push    si              ; Key attribute
272    push    ax              ; First Character
273    mov     al, ah
274    push    ax              ; Second Character
275
276    push    dx              ; Description attribute
277    push    di              ; Description string
278    push    cx              ; Description string parameter
279       
280    push    si              ; Key attribute for last space
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;--------------------------------------------------------------------
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
327    xor     al, 32  ; Upper case drive letter to lower case keystroke
328    jmp     SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
329
330
331;--------------------------------------------------------------------
332; HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
333;   Parameters:
334;       DS:     RAMVARS segment
335;       ES:     BDA segment (zero)
336;   Returns:
337;       AL:     Last scancode value
338;   Corrupts registers:
339;       AH, CX
340;--------------------------------------------------------------------
341HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars:
342    call    Keyboard_GetKeystrokeToAX
343    jz      SHORT NoHotkeyToProcess
344
345    ePUSH_T cx, HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
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:
357;       AL:     Last scancode seen
358;   Corrupts registers:
359;       AH, CX, DI
360;--------------------------------------------------------------------
361HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
362    mov     di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
363
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       
369    ; Drive letter hotkeys remaining, allow 'a' to 'z'
370    call    Char_IsLowerCaseLetterInAL
371    jnc     SHORT .KeystrokeIsNotValidDriveLetter
372    xor     al, 32                  ; We want to print upper case letters
373
374    ; Clear HD First flag to assume Floppy Drive hotkey
375    dec     di
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
380    call    DriveXlate_GetLetterForFirstHardDriveToAX
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:
388    sbb     di, BYTE 1          ; Sub CF if Floppy Drive
389    xchg    ax, cx
390    mov     [es:di], al         ; AH = zero to clear function hotkey
391
392.KeystrokeIsNotValidDriveLetter:       
393NoHotkeyToProcess:
394    mov     al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
395    ret
396
397;--------------------------------------------------------------------
398; HotkeyBar_GetBootDriveNumbersToDX
399;   Parameters:
400;       DS:     RAMVARS segment
401;       ES:     BDA segment (zero)
402;   Returns:
403;       DX:     Drives selected as boot device, DL is primary
404;   Corrupts registers:
405;       AX
406;--------------------------------------------------------------------
407HotkeyBar_GetBootDriveNumbersToDX:
408    mov     dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters]
409    test    BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST       
410    jnz     .noflip
411    xchg    dl, dh
412.noflip:   
413    call    DriveXlate_ConvertDriveLetterInDLtoDriveNumber
414    xchg    dl, dh
415    ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber       
416       
417HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:     
418
Note: See TracBrowser for help on using the repository browser.