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

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

Changes to XTIDE Universal BIOS:

  • Greatly improved Hotkey Bar is displayed during drive detection.
  • 8k builds no longer include boot menu.
  • Boot menu is displayed only if F2 is pressed during drive detection.
  • Some changes to directory structure.


File size: 13.9 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-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.
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; 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;--------------------------------------------------------------------
307; ScanHotkeysFromKeyBufferAndStoreToBootvars
308; Parameters:
309; DS: RAMVARS segment
310; ES: BDA segment (zero)
311; Returns:
312; Nothing
313; Corrupts registers:
314; AX, CX
315;--------------------------------------------------------------------
316ScanHotkeysFromKeyBufferAndStoreToBootvars:
317 call Keyboard_GetKeystrokeToAX
318 jz SHORT NoHotkeyToProcess
319
320 ePUSH_T cx, ScanHotkeysFromKeyBufferAndStoreToBootvars
321 ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
322
323
324;--------------------------------------------------------------------
325; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
326; Parameters:
327; AL: Hotkey ASCII code
328; AH: Hotkey Scancode
329; DS: RAMVARS segment
330; ES: BDA segment (zero)
331; Returns:
332; CF: Set if valid keystroke
333; Clear if invalid keystroke
334; Corrupts registers:
335; AX, CX, DI
336;--------------------------------------------------------------------
337HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
338 ; Boot menu
339%ifdef MODULE_BOOT_MENU
340 cmp ah, BOOT_MENU_HOTKEY_SCANCODE ; Display Boot Menu?
341 je SHORT .StoreFunctionHotkeyFromAH
342%endif
343
344 ; ROM Boot
345 cmp ah, ROM_BOOT_HOTKEY_SCANCODE ; ROM Boot?
346 je SHORT .StoreFunctionHotkeyFromAH
347
348 ; Drive letter hotkeys remaining, allow 'a' to 'z'
349 call Char_IsLowerCaseLetterInAL
350 jnc SHORT .KeystrokeIsNotValidHotkey
351 call Char_ChangeCaseInAL ; We want to print upper case letters
352
353 ; Clear HD First flag to assume Floppy Drive hotkey
354 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags
355 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
356
357 ; Determine if Floppy or Hard Drive hotkey
358 eMOVZX cx, al ; Clear CH to clear scancode
359 call HotkeyBar_GetLetterForFirstHardDriveToAX
360 cmp cl, al
361 jb SHORT .StoreDriveLetter ; Store Floppy Drive letter
362
363 ; Store Hard Drive letter
364 or BYTE [es:di], FLG_HOTKEY_HD_FIRST
365
366.StoreDriveLetter:
367 adc di, BYTE 0 ; Add 1 if Floppy Drive
368 xchg ax, cx
369 mov [es:di+1], al ; AH = zero to clear function hotkey
370
371.StoreFunctionHotkeyFromAH:
372 mov [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], ah
373 stc ; Valid hotkey
374
375.KeystrokeIsNotValidHotkey:
376NoHotkeyToProcess:
377 ret
378
379
380;--------------------------------------------------------------------
381; HotkeyBar_GetSecondaryBootDriveNumberToDL
382; HotkeyBar_GetPrimaryBootDriveNumberToDL
383; Parameters:
384; DS: RAMVARS segment
385; ES: BDA segment (zero)
386; Returns:
387; DL: Drive selected as boot device
388; Corrupts registers:
389; AX, DH
390;--------------------------------------------------------------------
391HotkeyBar_GetSecondaryBootDriveNumberToDL:
392 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
393 xchg dl, dh
394 jmp SHORT GetBootDriveNumberFromLettersInDX
395
396HotkeyBar_GetPrimaryBootDriveNumberToDL:
397 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
398GetBootDriveNumberFromLettersInDX:
399 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
400 eCMOVZ dl, dh
401 ; Fall to ConvertDriveLetterInDLtoDriveNumber
402
403
404;--------------------------------------------------------------------
405; ConvertDriveLetterInDLtoDriveNumber
406; Parameters:
407; DS: RAMVARS segment
408; DL: Drive letter ('A'...)
409; Returns:
410; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
411; Corrupts registers:
412; AX, DH
413;--------------------------------------------------------------------
414ConvertDriveLetterInDLtoDriveNumber:
415 call HotkeyBar_GetLetterForFirstHardDriveToAX
416 cmp dl, al
417 jb SHORT .ConvertLetterInDLtoFloppyDriveNumber
418
419 ; Convert letter in DL to Hard Drive number
420 sub dl, al
421 or dl, 80h
422 ret
423
424.ConvertLetterInDLtoFloppyDriveNumber:
425 sub dl, DEFAULT_FLOPPY_DRIVE_LETTER
426 ret
427
428
429;--------------------------------------------------------------------
430; HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter
431; Parameters:
432; DL: Drive number (0xh for Floppy Drives, 8xh for Hard Drives)
433; DS: RAMVARS Segment
434; Returns:
435; DL: Drive letter ('A'...)
436; CF: Set if Hard Drive
437; Clear if Floppy Drive
438; Corrupts registers:
439; AX
440;--------------------------------------------------------------------
441HotkeyBar_ConvertDriveNumberFromDLtoDriveLetter:
442 test dl, dl
443 jns SHORT .GetDefaultFloppyDrive
444
445 ; Store default hard drive to boot from
446 call HotkeyBar_GetLetterForFirstHardDriveToAX
447 sub dl, 80h
448 add dl, al
449 stc
450 ret
451
452.GetDefaultFloppyDrive:
453 add dl, DEFAULT_FLOPPY_DRIVE_LETTER ; Clears CF
454 ret
455
456
457;--------------------------------------------------------------------
458; Returns letter for first hard disk. Usually it will be 'C' but it
459; can be higher if more than two floppy drives are found.
460;
461; HotkeyBar_GetLetterForFirstHardDriveToAX
462; Parameters:
463; DS: RAMVARS segment
464; Returns:
465; AX: Upper case letter for first hard disk
466; Corrupts registers:
467; Nothing
468;--------------------------------------------------------------------
469HotkeyBar_GetLetterForFirstHardDriveToAX:
470 call FloppyDrive_GetCountToAX
471 add al, DEFAULT_FLOPPY_DRIVE_LETTER
472 MAX_U al, DEFAULT_HARD_DRIVE_LETTER
473 ret
Note: See TracBrowser for help on using the repository browser.