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

Last change on this file since 408 was 399, checked in by krille_n_@…, 13 years ago

Changes:

  • Added Power Management (Standby Timer) support to the BIOS and made it part of an optional module (MODULE_FEATURE_SETS). The total amount of ROM space used by this feature is 37 bytes. UNTESTED
  • Size optimizations (mostly inlining of procedures) and fixed a few bugs in AH9h_HInit.asm:
    1. DPT_ATA.bInitError would be cleared only if MODULE_SERIAL was not defined.
    2. The FLG_INITERROR_FAILED_TO_SET_BLOCK_MODE flag could never be set.
    3. InitializeBlockMode could potentially loop forever if there was an error.
  • Removed some odd looking code in .PushResetStatus in BootMenuPrintCfg.asm
  • Made some changes to XTIDECFG so it can be built.
File size: 14.5 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
211; Returns:
212; DX: Description Attribute
213; Corrupts registers:
214; AX
215;--------------------------------------------------------------------
216%ifdef MODULE_BOOT_MENU
217GetSelectedHotkeyDescriptionAttributeToDX:
218 push si
219 mov si, ATTRIBUTE_CHARS.cHurryTimeout ; Selected hotkey
220 jmp SHORT GetDescriptionAttributeToDX
221
222GetNonSelectedHotkeyDescriptionAttributeToDX:
223 push si
224 mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Unselected hotkey
225
226 ; Display Library should not be called like this
227GetDescriptionAttributeToDX:
228 call MenuAttribute_GetToAXfromTypeInSI
229 pop si
230 xchg dx, ax ; DX = Description attribute
231 ret
232
233%else ; No boot menu so use simpler attributes
234
235GetSelectedHotkeyDescriptionAttributeToDX:
236 mov dl, MONO_REVERSE_BLINK
237 ret
238
239GetNonSelectedHotkeyDescriptionAttributeToDX:
240 mov dl, MONO_REVERSE
241 ret
242%endif
243
244
245;--------------------------------------------------------------------
246; PushHotkeyParamsAndFormat
247; Parameters:
248; DI low: First character
249; DI high: Second character
250; DX: Description Attribute
251; CX: Description string parameter
252; CS:SI: Description string
253; Returns:
254; Nothing
255; Corrupts registers:
256; AX, SI, DI
257;--------------------------------------------------------------------
258PushHotkeyParamsAndFormat:
259 push bp
260 mov bp, sp
261
262 mov ax, MONO_BRIGHT
263 push ax ; Key attribute
264 xchg ax, di
265 push ax ; First character
266 xchg al, ah
267 push ax ; Second character
268
269 push dx ; Description attribute
270 push si ; Description string
271 push cx ; Description string parameter
272
273 push di ; Key attribute for last space
274 mov si, g_szHotkey
275 jmp DetectPrint_FormatCSSIfromParamsInSSBP
276
277
278;--------------------------------------------------------------------
279; MoveCursorToScreenTopLeftCorner
280; Parameters:
281; Nothing
282; Returns:
283; Nothing
284; Corrupts registers:
285; AX, DI
286;--------------------------------------------------------------------
287MoveCursorToScreenTopLeftCorner:
288 xor ax, ax ; Top left corner (0, 0)
289 ; Fall to HotkeyBar_RestoreCursorCoordinatesFromAX
290
291
292;--------------------------------------------------------------------
293; HotkeyBar_RestoreCursorCoordinatesFromAX
294; Parameters:
295; Nothing
296; Returns:
297; Nothing
298; Corrupts registers:
299; AX, DI
300;--------------------------------------------------------------------
301HotkeyBar_RestoreCursorCoordinatesFromAX:
302 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
303 ret
304
305
306;--------------------------------------------------------------------
[395]307; HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
308; Parameters:
309; DS: RAMVARS segment
310; ES: BDA segment (zero)
311; DL: Drive Letter ('A'...)
312; Returns:
313; Nothing
314; Corrupts registers:
315; AX, CX, DI
316;--------------------------------------------------------------------
317HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL:
318 eMOVZX ax, dl
319 call Char_ChangeCaseInAL ; Upper case drive letter to lower case keystroke
320 jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
321
322
323;--------------------------------------------------------------------
[392]324; ScanHotkeysFromKeyBufferAndStoreToBootvars
325; Parameters:
326; DS: RAMVARS segment
327; ES: BDA segment (zero)
328; Returns:
329; Nothing
330; Corrupts registers:
331; AX, CX
332;--------------------------------------------------------------------
333ScanHotkeysFromKeyBufferAndStoreToBootvars:
334 call Keyboard_GetKeystrokeToAX
335 jz SHORT NoHotkeyToProcess
336
337 ePUSH_T cx, ScanHotkeysFromKeyBufferAndStoreToBootvars
338 ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
339
340
341;--------------------------------------------------------------------
342; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
343; Parameters:
344; AL: Hotkey ASCII code
345; AH: Hotkey Scancode
346; DS: RAMVARS segment
347; ES: BDA segment (zero)
348; Returns:
349; CF: Set if valid keystroke
350; Clear if invalid keystroke
351; Corrupts registers:
352; AX, CX, DI
353;--------------------------------------------------------------------
354HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
355 ; Boot menu
356%ifdef MODULE_BOOT_MENU
357 cmp ah, BOOT_MENU_HOTKEY_SCANCODE ; Display Boot Menu?
358 je SHORT .StoreFunctionHotkeyFromAH
359%endif
360
361 ; ROM Boot
362 cmp ah, ROM_BOOT_HOTKEY_SCANCODE ; ROM Boot?
363 je SHORT .StoreFunctionHotkeyFromAH
364
365 ; Drive letter hotkeys remaining, allow 'a' to 'z'
366 call Char_IsLowerCaseLetterInAL
367 jnc SHORT .KeystrokeIsNotValidHotkey
368 call Char_ChangeCaseInAL ; We want to print upper case letters
369
370 ; Clear HD First flag to assume Floppy Drive hotkey
371 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags
372 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
373
374 ; Determine if Floppy or Hard Drive hotkey
375 eMOVZX cx, al ; Clear CH to clear scancode
376 call HotkeyBar_GetLetterForFirstHardDriveToAX
377 cmp cl, al
378 jb SHORT .StoreDriveLetter ; Store Floppy Drive letter
379
380 ; Store Hard Drive letter
381 or BYTE [es:di], FLG_HOTKEY_HD_FIRST
382
383.StoreDriveLetter:
[399]384 adc di, BYTE 1 ; Add CF if Floppy Drive
[392]385 xchg ax, cx
[399]386 mov [es:di], al ; AH = zero to clear function hotkey
[392]387
388.StoreFunctionHotkeyFromAH:
389 mov [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], ah
390 stc ; Valid hotkey
391
392.KeystrokeIsNotValidHotkey:
393NoHotkeyToProcess:
394 ret
395
396
397;--------------------------------------------------------------------
398; HotkeyBar_GetSecondaryBootDriveNumberToDL
399; HotkeyBar_GetPrimaryBootDriveNumberToDL
400; Parameters:
401; DS: RAMVARS segment
402; ES: BDA segment (zero)
403; Returns:
404; DL: Drive selected as boot device
405; Corrupts registers:
406; AX, DH
407;--------------------------------------------------------------------
408HotkeyBar_GetSecondaryBootDriveNumberToDL:
409 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
410 xchg dl, dh
411 jmp SHORT GetBootDriveNumberFromLettersInDX
412
413HotkeyBar_GetPrimaryBootDriveNumberToDL:
414 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
415GetBootDriveNumberFromLettersInDX:
416 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
417 eCMOVZ dl, dh
[395]418 ; Fall to HotkeyBar_ConvertDriveLetterInDLtoDriveNumber
[392]419
420
421;--------------------------------------------------------------------
[395]422; HotkeyBar_ConvertDriveLetterInDLtoDriveNumber
[392]423; Parameters:
424; DS: RAMVARS segment
425; DL: Drive letter ('A'...)
426; Returns:
427; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
428; Corrupts registers:
429; AX, DH
430;--------------------------------------------------------------------
[395]431HotkeyBar_ConvertDriveLetterInDLtoDriveNumber:
[392]432 call HotkeyBar_GetLetterForFirstHardDriveToAX
433 cmp dl, al
434 jb SHORT .ConvertLetterInDLtoFloppyDriveNumber
435
436 ; Convert letter in DL to Hard Drive number
437 sub dl, al
438 or dl, 80h
439 ret
440
441.ConvertLetterInDLtoFloppyDriveNumber:
442 sub dl, DEFAULT_FLOPPY_DRIVE_LETTER
443 ret
444
445
446;--------------------------------------------------------------------
447; HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter
448; Parameters:
449; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
450; DS: RAMVARS Segment
451; Returns:
452; DL: Drive letter ('A'...)
453; CF: Set if Hard Drive
454; Clear if Floppy Drive
455; Corrupts registers:
456; AX
457;--------------------------------------------------------------------
458HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter:
459 test dl, dl
460 jns SHORT .GetDefaultFloppyDrive
461
462 ; Store default hard drive to boot from
463 call HotkeyBar_GetLetterForFirstHardDriveToAX
464 sub dl, 80h
465 add dl, al
466 stc
467 ret
468
469.GetDefaultFloppyDrive:
470 add dl, DEFAULT_FLOPPY_DRIVE_LETTER ; Clears CF
471 ret
472
473
474;--------------------------------------------------------------------
475; Returns letter for first hard disk. Usually it will be 'C' but it
476; can be higher if more than two floppy drives are found.
477;
478; HotkeyBar_GetLetterForFirstHardDriveToAX
479; Parameters:
480; DS: RAMVARS segment
481; Returns:
482; AX: Upper case letter for first hard disk
483; Corrupts registers:
484; Nothing
485;--------------------------------------------------------------------
486HotkeyBar_GetLetterForFirstHardDriveToAX:
487 call FloppyDrive_GetCountToAX
488 add al, DEFAULT_FLOPPY_DRIVE_LETTER
489 MAX_U al, DEFAULT_HARD_DRIVE_LETTER
490 ret
Note: See TracBrowser for help on using the repository browser.