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
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; Scans key presses and draws any hotkey changes.
25;
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:
36 call ScanHotkeysFromKeyBufferAndStoreToBootvars
37 ; Fall to HotkeyBar_DrawToTopOfScreen
38
39
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
74 mov ax, (ANGLE_QUOTE_RIGHT << 8) | DEFAULT_FLOPPY_DRIVE_LETTER
75 mov cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFddLetter]
76 mov di, g_szFDD
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;--------------------------------------------------------------------
92 call BootVars_GetLetterForFirstHardDriveToAX
93 mov ah, ANGLE_QUOTE_RIGHT
94 mov cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bHddLetter]
95 mov di, g_szHDD
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
110 mov ax, BOOT_MENU_HOTKEY_SCANCODE | ('2' << 8)
111 mov di, g_szBootMenu
112 call FormatFunctionHotkeyString
113%endif
114 ; Fall to .PrintComDetectHotkey
115
116;--------------------------------------------------------------------
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
131 ; Fall to .PrintRomBootHotkey
132
133;--------------------------------------------------------------------
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:
143 mov ax, ROM_BOOT_HOTKEY_SCANCODE | ('8' << 8)
144 mov di, g_szRomBoot
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:
173 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
174 eMOVZX cx, al
175 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
176 sub cl, al
177 mov al, ' '
178 JMP_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
179
180
181;--------------------------------------------------------------------
182; FormatDriveHotkeyString
183; Parameters:
184; CL: Drive letter hotkey from BOOTVARS
185; AL: First character for drive key string
186; AH: Second character for drive key string (ANGLE_QUOTE_RIGHT)
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;--------------------------------------------------------------------
194;; No work to do before going into FormatFunctionHotkeyString
195FormatDriveHotkeyString equ GetNonSelectedHotkeyDescriptionAttributeToDX
196
197;--------------------------------------------------------------------
198; FormatFunctionHotkeyString
199; Parameters:
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
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:
211 xor cx, cx ; Null character, eaten in output routines
212
213 cmp [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
214 mov al, 'F' ; Replace scancode with character for output
215
216%ifdef MODULE_BOOT_MENU
217
218 mov si, ATTRIBUTE_CHARS.cHurryTimeout ; Selected hotkey
219 je SHORT GetDescriptionAttributeToDX ; From compare with bScancode above
220
221GetNonSelectedHotkeyDescriptionAttributeToDX:
222 mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Unselected hotkey
223
224 ; Display Library should not be called like this
225GetDescriptionAttributeToDX:
226 xchg dx, ax
227 call MenuAttribute_GetToAXfromTypeInSI
228 xchg dx, ax ; DX = Description attribute
229 ;; fall through to PushHotkeyParamsAndFormat
230
231
232%else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes
233
234 mov dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
235 je SHORT SelectAttributeFromDHorDLbasedOnVideoMode ; From compare with bScancode above
236
237GetNonSelectedHotkeyDescriptionAttributeToDX:
238 mov dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
239
240SelectAttributeFromDHorDLbasedOnVideoMode:
241 mov ch, [es:BDA.bVidMode] ; We only need to preserve CL
242 shr ch, 1
243 jnc SHORT .AttributeLoadedToDL ; Black & White modes
244 shr ch, 1
245 jnz SHORT .AttributeLoadedToDL ; MDA
246 mov dl, dh
247.AttributeLoadedToDL:
248 ;; fall through to PushHotkeyParamsAndFormat
249
250%endif ; MODULE_BOOT_MENU
251
252
253;--------------------------------------------------------------------
254; PushHotkeyParamsAndFormat
255; Parameters:
256; AL: First character
257; AH: Second character
258; DX: Description Attribute
259; CX: Description string parameter
260; CS:DI: Description string
261; Returns:
262; Nothing
263; Corrupts registers:
264; AX, SI, DI
265;--------------------------------------------------------------------
266PushHotkeyParamsAndFormat:
267 push bp
268 mov bp, sp
269
270 mov si, MONO_BRIGHT
271
272 push si ; Key attribute
273 push ax ; First Character
274 mov al, ah
275 push ax ; Second Character
276
277 push dx ; Description attribute
278 push di ; Description string
279 push cx ; Description string parameter
280
281 push si ; Key attribute for last space
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:
311 JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
312
313
314;--------------------------------------------------------------------
315; HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
316; Parameters:
317; DS: RAMVARS segment
318; ES: BDA segment (zero)
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)
335; DL: Drive Letter ('A'...)
336; Returns:
337; Nothing
338; Corrupts registers:
339; AX, CX, DI
340;--------------------------------------------------------------------
341StoreHotkeyToBootvarsForDriveLetterInDL:
342 eMOVZX ax, dl
343 or al, 32 ; Upper case drive letter to lower case keystroke
344 jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
345
346
347;--------------------------------------------------------------------
348; ScanHotkeysFromKeyBufferAndStoreToBootvars
349; Parameters:
350; DS: RAMVARS segment
351; ES: BDA segment (zero)
352; Returns:
353; AL: Last scancode value
354; Corrupts registers:
355; AH, CX
356;--------------------------------------------------------------------
357ScanHotkeysFromKeyBufferAndStoreToBootvars:
358 call Keyboard_GetKeystrokeToAX
359 jz SHORT NoHotkeyToProcess
360
361 ; Prepare to read another key from buffer
362 ePUSH_T cx, ScanHotkeysFromKeyBufferAndStoreToBootvars
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:
374; AL: Last scancode seen
375; CF: Set if valid hotkey in AL
376; Clear if scancode in AL is not for any hotkey
377; Corrupts registers:
378; AH, CX, DI
379;--------------------------------------------------------------------
380HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
381 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
382
383 ; All scancodes are saved, even if it wasn't a drive letter,
384 ; which also covers our function key case. Invalid function keys
385 ; will not do anything (won't be printed, won't be accepted as input)
386 mov [es:di], ah
387
388 ; Drive letter hotkeys remaining, allow 'a' to 'z'
389 call Char_IsLowerCaseLetterInAL
390 jnc SHORT .KeystrokeIsNotValidDriveLetter
391 and al, ~32 ; We want to print upper case letters
392
393 ; Clear HD First flag to assume Floppy Drive hotkey
394 dec di
395 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
396
397 ; Determine if Floppy or Hard Drive hotkey
398 xchg cx, ax
399 call BootVars_GetLetterForFirstHardDriveToAX
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:
407 sbb di, BYTE 1 ; Sub CF if Floppy Drive
408 xchg ax, cx
409 mov [es:di], al
410 stc ; Valid hotkey scancode returned in AL
411
412.KeystrokeIsNotValidDriveLetter:
413NoHotkeyToProcess:
414 mov al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
415 ret
416
417
418;--------------------------------------------------------------------
419; HotkeyBar_GetBootDriveNumbersToDX
420; Parameters:
421; DS: RAMVARS segment
422; ES: BDA segment (zero)
423; Returns:
424; DX: Drives selected as boot device, DL is primary
425; Corrupts registers:
426; AX
427;--------------------------------------------------------------------
428HotkeyBar_GetBootDriveNumbersToDX:
429 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters]
430 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
431 jnz .noflip
432 xchg dl, dh
433.noflip:
434 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber
435 xchg dl, dh
436 ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber
437
438HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
439
Note: See TracBrowser for help on using the repository browser.