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

Last change on this file since 563 was 547, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

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