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

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

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 12.7 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-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; 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    JMP_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
177
178
179;--------------------------------------------------------------------
180; FormatDriveHotkeyString
181;   Parameters:
182;       CL:         Drive letter hotkey from BOOTVARS
183;       AL:         First character for drive key string
184;       AH:         Second character for drive key string (ANGLE_QUOTE_RIGHT)
185;       SI:         Offset to hotkey description string
186;       ES:         BDA segment (zero)
187;   Returns:
188;       Nothing
189;   Corrupts registers:
190;       AX, CX, DX, SI, DI
191;--------------------------------------------------------------------
192;; No work to do before going into FormatFunctionHotkeyString
193FormatDriveHotkeyString  equ  GetNonSelectedHotkeyDescriptionAttributeToDX
194
195;--------------------------------------------------------------------
196; FormatFunctionHotkeyString
197;   Parameters:
198;       AL:         Scancode of function key, to know which if any to show as selected
199;                   Later replaced with an 'F' for the call to the output routine
200;       AH:         Second character for drive key string
201;       SI:         Offset to hotkey description string
202;       ES:         BDA segment (zero)
203;   Returns:
204;       Nothing
205;   Corrupts registers:
206;       AX, CX, DX, SI, DI
207;--------------------------------------------------------------------
208FormatFunctionHotkeyString:
209    xor     cx, cx      ; Null character, eaten in output routines
210
211    cmp     [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
212    mov     al, 'F'     ; Replace scancode with character for output
213
214%ifdef MODULE_BOOT_MENU
215
216    mov     si, ATTRIBUTE_CHARS.cHurryTimeout       ; Selected hotkey
217    je      SHORT GetDescriptionAttributeToDX       ; From compare with bScancode above
218
219GetNonSelectedHotkeyDescriptionAttributeToDX:
220    mov     si, ATTRIBUTE_CHARS.cHighlightedItem    ; Unselected hotkey
221
222    ; Display Library should not be called like this
223GetDescriptionAttributeToDX:
224    xchg    dx, ax
225    call    MenuAttribute_GetToAXfromTypeInSI
226    xchg    dx, ax                  ; DX = Description attribute
227    ;;  fall through to PushHotkeyParamsAndFormat
228
229
230%else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes
231
232    mov     dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
233    je      SHORT SelectAttributeFromDHorDLbasedOnVideoMode     ; From compare with bScancode above
234
235GetNonSelectedHotkeyDescriptionAttributeToDX:
236    mov     dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
237
238SelectAttributeFromDHorDLbasedOnVideoMode:
239    mov     ch, [es:BDA.bVidMode]       ; We only need to preserve CL
240    shr     ch, 1
241    jnc     SHORT .AttributeLoadedToDL  ; Black & White modes
242    shr     ch, 1
243    jnz     SHORT .AttributeLoadedToDL  ; MDA
244    mov     dl, dh
245.AttributeLoadedToDL:
246    ;;  fall through to PushHotkeyParamsAndFormat
247
248%endif ; MODULE_BOOT_MENU
249
250
251;--------------------------------------------------------------------
252; PushHotkeyParamsAndFormat
253;   Parameters:
254;       AL:         First character
255;       AH:         Second character
256;       DX:         Description Attribute
257;       CX:         Description string parameter
258;       CS:DI:      Description string
259;   Returns:
260;       Nothing
261;   Corrupts registers:
262;       AX, SI, DI
263;--------------------------------------------------------------------
264PushHotkeyParamsAndFormat:
265    push    bp
266    mov     bp, sp
267
268    mov     si, MONO_BRIGHT
269
270    push    si              ; Key attribute
271    push    ax              ; First Character
272    mov     al, ah
273    push    ax              ; Second Character
274
275    push    dx              ; Description attribute
276    push    di              ; Description string
277    push    cx              ; Description string parameter
278
279    push    si              ; Key attribute for last space
280
281    mov     si, g_szHotkey
282    jmp     DetectPrint_FormatCSSIfromParamsInSSBP
283
284
285;--------------------------------------------------------------------
286; MoveCursorToScreenTopLeftCorner
287;   Parameters:
288;       Nothing
289;   Returns:
290;       Nothing
291;   Corrupts registers:
292;       AX, DI
293;--------------------------------------------------------------------
294MoveCursorToScreenTopLeftCorner:
295    xor     ax, ax          ; Top left corner (0, 0)
296    ; Fall to HotkeyBar_RestoreCursorCoordinatesFromAX
297
298
299;--------------------------------------------------------------------
300; HotkeyBar_RestoreCursorCoordinatesFromAX
301;   Parameters:
302;       Nothing
303;   Returns:
304;       Nothing
305;   Corrupts registers:
306;       AX, DI
307;--------------------------------------------------------------------
308HotkeyBar_RestoreCursorCoordinatesFromAX:
309    JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
310
311
312;--------------------------------------------------------------------
313; HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
314;   Parameters:
315;       DS:     RAMVARS segment
316;       ES:     BDA segment (zero)
317;       DL:     Drive Letter ('A'...)
318;   Returns:
319;       Nothing
320;   Corrupts registers:
321;       AX, CX, DI
322;--------------------------------------------------------------------
323HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL:
324    eMOVZX  ax, dl
325    or      al, 32  ; Upper case drive letter to lower case keystroke
326    jmp     SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
327
328
329;--------------------------------------------------------------------
330; HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
331;   Parameters:
332;       DS:     RAMVARS segment
333;       ES:     BDA segment (zero)
334;   Returns:
335;       AL:     Last scancode value
336;   Corrupts registers:
337;       AH, CX
338;--------------------------------------------------------------------
339HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars:
340    call    Keyboard_GetKeystrokeToAX
341    jz      SHORT NoHotkeyToProcess
342
343    ePUSH_T cx, HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
344    ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
345
346
347;--------------------------------------------------------------------
348; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
349;   Parameters:
350;       AL:     Hotkey ASCII code
351;       AH:     Hotkey Scancode
352;       DS:     RAMVARS segment
353;       ES:     BDA segment (zero)
354;   Returns:
355;       AL:     Last scancode seen
356;   Corrupts registers:
357;       AH, CX, DI
358;--------------------------------------------------------------------
359HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
360    mov     di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
361
362    ; All scancodes are saved, even if it wasn't a drive letter,
363    ; which also covers our function key case.  Invalid function keys
364    ; will not do anything (won't be printed, won't be accepted as input)
365    mov     [es:di], ah
366
367    ; Drive letter hotkeys remaining, allow 'a' to 'z'
368    call    Char_IsLowerCaseLetterInAL
369    jnc     SHORT .KeystrokeIsNotValidDriveLetter
370    and     al, ~32                 ; We want to print upper case letters
371
372    ; Clear HD First flag to assume Floppy Drive hotkey
373    dec     di
374    and     BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
375
376    ; Determine if Floppy or Hard Drive hotkey
377    xchg    cx, ax
378    call    DriveXlate_GetLetterForFirstHardDriveToAX
379    cmp     cl, al
380    jb      SHORT .StoreDriveLetter ; Store Floppy Drive letter
381
382    ; Store Hard Drive letter
383    or      BYTE [es:di], FLG_HOTKEY_HD_FIRST
384
385.StoreDriveLetter:
386    sbb     di, BYTE 1              ; Sub CF if Floppy Drive
387    xchg    ax, cx
388    mov     [es:di], al
389
390.KeystrokeIsNotValidDriveLetter:
391NoHotkeyToProcess:
392    mov     al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
393    ret
394
395;--------------------------------------------------------------------
396; HotkeyBar_GetBootDriveNumbersToDX
397;   Parameters:
398;       DS:     RAMVARS segment
399;       ES:     BDA segment (zero)
400;   Returns:
401;       DX:     Drives selected as boot device, DL is primary
402;   Corrupts registers:
403;       AX
404;--------------------------------------------------------------------
405HotkeyBar_GetBootDriveNumbersToDX:
406    mov     dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters]
407    test    BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
408    jnz     .noflip
409    xchg    dl, dh
410.noflip:
411    call    DriveXlate_ConvertDriveLetterInDLtoDriveNumber
412    xchg    dl, dh
413    ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber
414
415HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
416
Note: See TracBrowser for help on using the repository browser.