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

Last change on this file since 522 was 505, checked in by krille_n_@…, 12 years ago

Changes:

  • Reverted the changes to MenuEvents.inc done in r492 since they broke the F1 key function in XTIDECFG.
  • Added a tail-call optimized variant of the CALL_DISPLAY_LIBRARY macro (JMP_DISPLAY_LIBRARY).
  • Put a block size limit in AH1Eh_ChangeXTCFmodeBasedOnControlRegisterInAL. I think it's needed but if not, it's easy to remove.
  • Other optimizations and fixes.
File size: 12.7 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
[505]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
[505]129 ; Fall to .PrintRomBootHotkey
[492]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:
[505]171 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
[392]172 eMOVZX cx, al
[505]173 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
[392]174 sub cl, al
175 mov al, ' '
[505]176 JMP_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
[392]177
178
179;--------------------------------------------------------------------
180; FormatDriveHotkeyString
181; Parameters:
182; CL: Drive letter hotkey from BOOTVARS
[492]183; AL: First character for drive key string
184; AH: Second character for drive key string (ANGLE_QUOTE_RIGHT)
[392]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;--------------------------------------------------------------------
[492]192;; No work to do before going into FormatFunctionHotkeyString
193FormatDriveHotkeyString equ GetNonSelectedHotkeyDescriptionAttributeToDX
[392]194
195;--------------------------------------------------------------------
196; FormatFunctionHotkeyString
197; Parameters:
[492]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
[392]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:
[492]209 xor cx, cx ; Null character, eaten in output routines
[392]210
[492]211 cmp [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
212 mov al, 'F' ; Replace scancode with character for output
[392]213
214%ifdef MODULE_BOOT_MENU
[492]215
[392]216 mov si, ATTRIBUTE_CHARS.cHurryTimeout ; Selected hotkey
[505]217 je SHORT GetDescriptionAttributeToDX ; From compare with bScancode above
[392]218
219GetNonSelectedHotkeyDescriptionAttributeToDX:
220 mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Unselected hotkey
221
222 ; Display Library should not be called like this
223GetDescriptionAttributeToDX:
[492]224 xchg dx, ax
[392]225 call MenuAttribute_GetToAXfromTypeInSI
226 xchg dx, ax ; DX = Description attribute
[505]227 ;; fall through to PushHotkeyParamsAndFormat
[392]228
229
[500]230%else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes
231
[410]232 mov dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
[505]233 je SHORT SelectAttributeFromDHorDLbasedOnVideoMode ; From compare with bScancode above
[392]234
235GetNonSelectedHotkeyDescriptionAttributeToDX:
[410]236 mov dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
[492]237
[410]238SelectAttributeFromDHorDLbasedOnVideoMode:
[500]239 mov ch, [es:BDA.bVidMode] ; We only need to preserve CL
240 shr ch, 1
[410]241 jnc SHORT .AttributeLoadedToDL ; Black & White modes
[500]242 shr ch, 1
[410]243 jnz SHORT .AttributeLoadedToDL ; MDA
244 mov dl, dh
245.AttributeLoadedToDL:
[505]246 ;; fall through to PushHotkeyParamsAndFormat
[410]247
[492]248%endif ; MODULE_BOOT_MENU
[392]249
250
251;--------------------------------------------------------------------
252; PushHotkeyParamsAndFormat
253; Parameters:
[500]254; AL: First character
255; AH: Second character
[392]256; DX: Description Attribute
257; CX: Description string parameter
[492]258; CS:DI: Description string
[392]259; Returns:
260; Nothing
261; Corrupts registers:
262; AX, SI, DI
263;--------------------------------------------------------------------
264PushHotkeyParamsAndFormat:
265 push bp
266 mov bp, sp
267
[492]268 mov si, MONO_BRIGHT
[392]269
[492]270 push si ; Key attribute
271 push ax ; First Character
272 mov al, ah
273 push ax ; Second Character
274
[392]275 push dx ; Description attribute
[492]276 push di ; Description string
[392]277 push cx ; Description string parameter
[505]278
[492]279 push si ; Key attribute for last space
[392]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:
[505]309 JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
[392]310
311
312;--------------------------------------------------------------------
[395]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
[505]325 or al, 32 ; Upper case drive letter to lower case keystroke
[395]326 jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
327
328
329;--------------------------------------------------------------------
[492]330; HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]331; Parameters:
332; DS: RAMVARS segment
333; ES: BDA segment (zero)
334; Returns:
[492]335; AL: Last scancode value
[392]336; Corrupts registers:
[492]337; AH, CX
[392]338;--------------------------------------------------------------------
[492]339HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars:
[392]340 call Keyboard_GetKeystrokeToAX
341 jz SHORT NoHotkeyToProcess
342
[492]343 ePUSH_T cx, HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]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:
[492]355; AL: Last scancode seen
[392]356; Corrupts registers:
[492]357; AH, CX, DI
[392]358;--------------------------------------------------------------------
359HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
[492]360 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
[392]361
[492]362 ; All scancodes are saved, even if it wasn't a drive letter,
363 ; which also covers our function key case. Invalid function keys
[505]364 ; will not do anything (won't be printed, won't be accepted as input)
[492]365 mov [es:di], ah
[505]366
[392]367 ; Drive letter hotkeys remaining, allow 'a' to 'z'
368 call Char_IsLowerCaseLetterInAL
[492]369 jnc SHORT .KeystrokeIsNotValidDriveLetter
[505]370 and al, ~32 ; We want to print upper case letters
[392]371
372 ; Clear HD First flag to assume Floppy Drive hotkey
[492]373 dec di
[392]374 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
375
376 ; Determine if Floppy or Hard Drive hotkey
[505]377 xchg cx, ax
[492]378 call DriveXlate_GetLetterForFirstHardDriveToAX
[392]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:
[505]386 sbb di, BYTE 1 ; Sub CF if Floppy Drive
[392]387 xchg ax, cx
[505]388 mov [es:di], al
[392]389
[505]390.KeystrokeIsNotValidDriveLetter:
[392]391NoHotkeyToProcess:
[492]392 mov al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
[392]393 ret
394
395;--------------------------------------------------------------------
[492]396; HotkeyBar_GetBootDriveNumbersToDX
[392]397; Parameters:
398; DS: RAMVARS segment
399; ES: BDA segment (zero)
400; Returns:
[492]401; DX: Drives selected as boot device, DL is primary
[392]402; Corrupts registers:
[492]403; AX
[392]404;--------------------------------------------------------------------
[492]405HotkeyBar_GetBootDriveNumbersToDX:
[500]406 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters]
[505]407 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
[492]408 jnz .noflip
[392]409 xchg dl, dh
[505]410.noflip:
[492]411 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber
412 xchg dl, dh
[505]413 ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber
[392]414
[505]415HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
416
Note: See TracBrowser for help on using the repository browser.