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

Last change on this file since 436 was 410, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Hotkey Bar now support color attributes even when not including MODULE_BOOT_MENU.
  • Cleaned AH=09h code a bit.
  • MODULE_ADVANCED_ATA now properly changes the device type to 32-bit.
  • BSY and RDY timeouts are now 2500 ms.
File size: 14.9 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:
34 call 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 di, DEFAULT_FLOPPY_DRIVE_LETTER | (ANGLE_QUOTE_RIGHT<<8)
73 mov cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFddLetter]
74 mov si, 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 HotkeyBar_GetLetterForFirstHardDriveToAX
91 mov ah, ANGLE_QUOTE_RIGHT
92 xchg di, ax
93 mov cl, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bHddLetter]
94 mov si, g_szHDD
95 call FormatDriveHotkeyString
96 ; Fall to .PrintBootMenuHotkey
97
98;--------------------------------------------------------------------
99; .PrintBootMenuHotkey
100; Parameters:
101; ES: BDA segment (zero)
102; Returns:
103; Nothing
104; Corrupts registers:
105; AX, CX, DX, SI, DI
106;--------------------------------------------------------------------
107.PrintBootMenuHotkey:
108%ifdef MODULE_BOOT_MENU
109 mov ah, BOOT_MENU_HOTKEY_SCANCODE
110 mov di, 'F' | ('2'<<8) ; F2
111 mov si, g_szBootMenu
112 call FormatFunctionHotkeyString
113%endif
114 ; Fall to .PrintRomBootHotkey
115
116;--------------------------------------------------------------------
117; .PrintRomBootHotkey
118; Parameters:
119; ES: BDA segment (zero)
120; Returns:
121; Nothing
122; Corrupts registers:
123; AX, CX, DX, SI, DI
124;--------------------------------------------------------------------
125.PrintRomBootHotkey:
126 mov ah, ROM_BOOT_HOTKEY_SCANCODE
127 mov di, 'F' | ('8'<<8) ; F8
128 mov si, g_szRomBoot
129 call FormatFunctionHotkeyString
130 ; Fall to .EndHotkeyBarRendering
131
132;--------------------------------------------------------------------
133; .EndHotkeyBarRendering
134; Parameters:
135; Stack: Screen coordinates before drawing Hotkey Bar
136; Returns:
137; Nothing
138; Corrupts registers:
139; AX, CX, DI
140;--------------------------------------------------------------------
141.EndHotkeyBarRendering:
142 call HotkeyBar_ClearRestOfTopRow
143 pop ax
144 jmp SHORT HotkeyBar_RestoreCursorCoordinatesFromAX
145
146
147;--------------------------------------------------------------------
148; HotkeyBar_ClearRestOfTopRow
149; Parameters:
150; Nothing
151; Returns:
152; Nothing
153; Corrupts registers:
154; AX, CX, DI
155;--------------------------------------------------------------------
156HotkeyBar_ClearRestOfTopRow:
157 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
158 eMOVZX cx, al
159 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
160 sub cl, al
161 mov al, ' '
162 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
163 ret
164
165
166;--------------------------------------------------------------------
167; FormatDriveHotkeyString
168; Parameters:
169; CL: Drive letter hotkey from BOOTVARS
170; DI low: First character for drive key string
171; DI high: Second character for drive key string (ANGLE_QUOTE_RIGHT)
172; SI: Offset to hotkey description string
173; ES: BDA segment (zero)
174; Returns:
175; Nothing
176; Corrupts registers:
177; AX, CX, DX, SI, DI
178;--------------------------------------------------------------------
179FormatDriveHotkeyString:
180 ePUSH_T ax, PushHotkeyParamsAndFormat
181 jmp SHORT GetNonSelectedHotkeyDescriptionAttributeToDX
182
183
184;--------------------------------------------------------------------
185; FormatFunctionHotkeyString
186; Parameters:
187; AH: Hotkey scancode to compare with BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
188; SI: Offset to hotkey description string
189; DI low: First character for drive key string
190; DI high: Second character for drive key string
191; ES: BDA segment (zero)
192; Returns:
193; Nothing
194; Corrupts registers:
195; AX, CX, DX, SI, DI
196;--------------------------------------------------------------------
197FormatFunctionHotkeyString:
198 ePUSH_T ax, PushHotkeyParamsAndFormat
199 mov cx, g_szBoot ; Description parameter string
200 cmp [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], ah
201 jne SHORT GetNonSelectedHotkeyDescriptionAttributeToDX
202 ; Fall to GetSelectedHotkeyDescriptionAttributeToDX
203
204
205;--------------------------------------------------------------------
206; GetSelectedHotkeyDescriptionAttributeToDX
207; GetNonSelectedHotkeyDescriptionAttributeToDX
208; Parameters:
209; CF: Set if selected hotkey
210; Cleared if unselected hotkey
[410]211; ES: BDA segment (zero)
[392]212; Returns:
213; DX: Description Attribute
214; Corrupts registers:
215; AX
216;--------------------------------------------------------------------
217%ifdef MODULE_BOOT_MENU
218GetSelectedHotkeyDescriptionAttributeToDX:
219 push si
220 mov si, ATTRIBUTE_CHARS.cHurryTimeout ; Selected hotkey
221 jmp SHORT GetDescriptionAttributeToDX
222
223GetNonSelectedHotkeyDescriptionAttributeToDX:
224 push si
225 mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Unselected hotkey
226
227 ; Display Library should not be called like this
228GetDescriptionAttributeToDX:
229 call MenuAttribute_GetToAXfromTypeInSI
230 pop si
231 xchg dx, ax ; DX = Description attribute
232 ret
233
234%else ; No boot menu so use simpler attributes
235
236GetSelectedHotkeyDescriptionAttributeToDX:
[410]237 mov dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
238 jmp SHORT SelectAttributeFromDHorDLbasedOnVideoMode
[392]239
240GetNonSelectedHotkeyDescriptionAttributeToDX:
[410]241 mov dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
242SelectAttributeFromDHorDLbasedOnVideoMode:
243 mov al, [es:BDA.bVidMode]
244 shr al, 1
245 jnc SHORT .AttributeLoadedToDL ; Black & White modes
246 shr al, 1
247 jnz SHORT .AttributeLoadedToDL ; MDA
248 mov dl, dh
249.AttributeLoadedToDL:
[392]250 ret
[410]251
[392]252%endif
253
254
255;--------------------------------------------------------------------
256; PushHotkeyParamsAndFormat
257; Parameters:
258; DI low: First character
259; DI high: Second character
260; DX: Description Attribute
261; CX: Description string parameter
262; CS:SI: Description string
263; Returns:
264; Nothing
265; Corrupts registers:
266; AX, SI, DI
267;--------------------------------------------------------------------
268PushHotkeyParamsAndFormat:
269 push bp
270 mov bp, sp
271
272 mov ax, MONO_BRIGHT
273 push ax ; Key attribute
274 xchg ax, di
275 push ax ; First character
276 xchg al, ah
277 push ax ; Second character
278
279 push dx ; Description attribute
280 push si ; Description string
281 push cx ; Description string parameter
282
283 push di ; Key attribute for last space
284 mov si, g_szHotkey
285 jmp DetectPrint_FormatCSSIfromParamsInSSBP
286
287
288;--------------------------------------------------------------------
289; MoveCursorToScreenTopLeftCorner
290; Parameters:
291; Nothing
292; Returns:
293; Nothing
294; Corrupts registers:
295; AX, DI
296;--------------------------------------------------------------------
297MoveCursorToScreenTopLeftCorner:
298 xor ax, ax ; Top left corner (0, 0)
299 ; Fall to HotkeyBar_RestoreCursorCoordinatesFromAX
300
301
302;--------------------------------------------------------------------
303; HotkeyBar_RestoreCursorCoordinatesFromAX
304; Parameters:
305; Nothing
306; Returns:
307; Nothing
308; Corrupts registers:
309; AX, DI
310;--------------------------------------------------------------------
311HotkeyBar_RestoreCursorCoordinatesFromAX:
312 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
313 ret
314
315
316;--------------------------------------------------------------------
[395]317; HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
318; Parameters:
319; DS: RAMVARS segment
320; ES: BDA segment (zero)
321; DL: Drive Letter ('A'...)
322; Returns:
323; Nothing
324; Corrupts registers:
325; AX, CX, DI
326;--------------------------------------------------------------------
327HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL:
328 eMOVZX ax, dl
329 call Char_ChangeCaseInAL ; Upper case drive letter to lower case keystroke
330 jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
331
332
333;--------------------------------------------------------------------
[392]334; ScanHotkeysFromKeyBufferAndStoreToBootvars
335; Parameters:
336; DS: RAMVARS segment
337; ES: BDA segment (zero)
338; Returns:
339; Nothing
340; Corrupts registers:
341; AX, CX
342;--------------------------------------------------------------------
343ScanHotkeysFromKeyBufferAndStoreToBootvars:
344 call Keyboard_GetKeystrokeToAX
345 jz SHORT NoHotkeyToProcess
346
347 ePUSH_T cx, ScanHotkeysFromKeyBufferAndStoreToBootvars
348 ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
349
350
351;--------------------------------------------------------------------
352; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
353; Parameters:
354; AL: Hotkey ASCII code
355; AH: Hotkey Scancode
356; DS: RAMVARS segment
357; ES: BDA segment (zero)
358; Returns:
359; CF: Set if valid keystroke
360; Clear if invalid keystroke
361; Corrupts registers:
362; AX, CX, DI
363;--------------------------------------------------------------------
364HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
365 ; Boot menu
366%ifdef MODULE_BOOT_MENU
367 cmp ah, BOOT_MENU_HOTKEY_SCANCODE ; Display Boot Menu?
368 je SHORT .StoreFunctionHotkeyFromAH
369%endif
370
371 ; ROM Boot
372 cmp ah, ROM_BOOT_HOTKEY_SCANCODE ; ROM Boot?
373 je SHORT .StoreFunctionHotkeyFromAH
374
375 ; Drive letter hotkeys remaining, allow 'a' to 'z'
376 call Char_IsLowerCaseLetterInAL
377 jnc SHORT .KeystrokeIsNotValidHotkey
378 call Char_ChangeCaseInAL ; We want to print upper case letters
379
380 ; Clear HD First flag to assume Floppy Drive hotkey
381 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags
382 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
383
384 ; Determine if Floppy or Hard Drive hotkey
385 eMOVZX cx, al ; Clear CH to clear scancode
386 call HotkeyBar_GetLetterForFirstHardDriveToAX
387 cmp cl, al
388 jb SHORT .StoreDriveLetter ; Store Floppy Drive letter
389
390 ; Store Hard Drive letter
391 or BYTE [es:di], FLG_HOTKEY_HD_FIRST
392
393.StoreDriveLetter:
[399]394 adc di, BYTE 1 ; Add CF if Floppy Drive
[392]395 xchg ax, cx
[399]396 mov [es:di], al ; AH = zero to clear function hotkey
[392]397
398.StoreFunctionHotkeyFromAH:
399 mov [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], ah
400 stc ; Valid hotkey
401
402.KeystrokeIsNotValidHotkey:
403NoHotkeyToProcess:
404 ret
405
406
407;--------------------------------------------------------------------
408; HotkeyBar_GetSecondaryBootDriveNumberToDL
409; HotkeyBar_GetPrimaryBootDriveNumberToDL
410; Parameters:
411; DS: RAMVARS segment
412; ES: BDA segment (zero)
413; Returns:
414; DL: Drive selected as boot device
415; Corrupts registers:
416; AX, DH
417;--------------------------------------------------------------------
418HotkeyBar_GetSecondaryBootDriveNumberToDL:
419 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
420 xchg dl, dh
421 jmp SHORT GetBootDriveNumberFromLettersInDX
422
423HotkeyBar_GetPrimaryBootDriveNumberToDL:
424 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
425GetBootDriveNumberFromLettersInDX:
426 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
427 eCMOVZ dl, dh
[395]428 ; Fall to HotkeyBar_ConvertDriveLetterInDLtoDriveNumber
[392]429
430
431;--------------------------------------------------------------------
[395]432; HotkeyBar_ConvertDriveLetterInDLtoDriveNumber
[392]433; Parameters:
434; DS: RAMVARS segment
435; DL: Drive letter ('A'...)
436; Returns:
437; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
438; Corrupts registers:
439; AX, DH
440;--------------------------------------------------------------------
[395]441HotkeyBar_ConvertDriveLetterInDLtoDriveNumber:
[392]442 call HotkeyBar_GetLetterForFirstHardDriveToAX
443 cmp dl, al
444 jb SHORT .ConvertLetterInDLtoFloppyDriveNumber
445
446 ; Convert letter in DL to Hard Drive number
447 sub dl, al
448 or dl, 80h
449 ret
450
451.ConvertLetterInDLtoFloppyDriveNumber:
452 sub dl, DEFAULT_FLOPPY_DRIVE_LETTER
453 ret
454
455
456;--------------------------------------------------------------------
457; HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter
458; Parameters:
459; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
460; DS: RAMVARS Segment
461; Returns:
462; DL: Drive letter ('A'...)
463; CF: Set if Hard Drive
464; Clear if Floppy Drive
465; Corrupts registers:
466; AX
467;--------------------------------------------------------------------
468HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter:
469 test dl, dl
470 jns SHORT .GetDefaultFloppyDrive
471
472 ; Store default hard drive to boot from
473 call HotkeyBar_GetLetterForFirstHardDriveToAX
474 sub dl, 80h
475 add dl, al
476 stc
477 ret
478
479.GetDefaultFloppyDrive:
480 add dl, DEFAULT_FLOPPY_DRIVE_LETTER ; Clears CF
481 ret
482
483
484;--------------------------------------------------------------------
485; Returns letter for first hard disk. Usually it will be 'C' but it
486; can be higher if more than two floppy drives are found.
487;
488; HotkeyBar_GetLetterForFirstHardDriveToAX
489; Parameters:
490; DS: RAMVARS segment
491; Returns:
492; AX: Upper case letter for first hard disk
493; Corrupts registers:
494; Nothing
495;--------------------------------------------------------------------
496HotkeyBar_GetLetterForFirstHardDriveToAX:
497 call FloppyDrive_GetCountToAX
498 add al, DEFAULT_FLOPPY_DRIVE_LETTER
499 MAX_U al, DEFAULT_HARD_DRIVE_LETTER
500 ret
Note: See TracBrowser for help on using the repository browser.