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

Last change on this file since 595 was 593, checked in by Tomi Tilli, 6 years ago

Flashing now works again.
Hack to get Windows 95 to work properly (MODULE_WIN95_CMOS_HACK included for 386 builds by default).
Edited makefile to produce large 386 build.
Fixed recovery time for QDI Vision VLB-IDE controllers.
No more warnings with Nasm 2.13.xx and later.
File dialog now properly restores default drive when file selection is cancelled.

File size: 14.3 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 xchg cx, ax ; Any Floppy Drives?
72 jcxz .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
78 ; Clear CH if floppy drive is selected for boot
79 mov ch, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags]
80 ;and ch, FLG_HOTKEY_HD_FIRST ; Needed if more flags are added
81 call FormatDriveHotkeyString
82
83.SkipFloppyDriveHotkeys:
84 ; Fall to .PrintHardDriveHotkeys
85
86;--------------------------------------------------------------------
87; .PrintHardDriveHotkeys
88; Parameters:
89; DS: RAMVARS segment
90; ES: BDA segment (zero)
91; Returns:
92; Nothing
93; Corrupts registers:
94; AX, CX, DX, SI, DI
95;--------------------------------------------------------------------
96 call BootVars_GetLetterForFirstHardDriveToAX
97 mov ah, ANGLE_QUOTE_RIGHT
98 mov cx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bHddLetter] ; Letter to CL, flags to CH
99 ;and ch, FLG_HOTKEY_HD_FIRST ; Needed if more flags are added
100 xor ch, FLG_HOTKEY_HD_FIRST ; Clear CH if HD is selected for boot, set otherwise
101 mov di, g_szHDD
102 call FormatDriveHotkeyString
103 ; Fall to .PrintBootMenuHotkey
104
105;--------------------------------------------------------------------
106; .PrintBootMenuHotkey
107; Parameters:
108; ES: BDA segment (zero)
109; Returns:
110; Nothing
111; Corrupts registers:
112; AX, CX, DX, SI, DI
113;--------------------------------------------------------------------
114.PrintBootMenuHotkey:
115%ifdef MODULE_BOOT_MENU
116 mov ax, BOOT_MENU_HOTKEY_SCANCODE | ('2' << 8)
117 mov di, g_szBootMenu
118 call FormatFunctionHotkeyString
119%endif
120 ; Fall to .PrintComDetectHotkey
121
122;--------------------------------------------------------------------
123; .PrintComDetectHotkey
124; Parameters:
125; ES: BDA segment (zero)
126; Returns:
127; Nothing
128; Corrupts registers:
129; AX, CX, DX, SI, DI
130;--------------------------------------------------------------------
131.PrintComDetectHotkey:
132%ifdef MODULE_SERIAL
133 mov ax, COM_DETECT_HOTKEY_SCANCODE | ('6' << 8)
134 mov di, g_szHotComDetect
135 call FormatFunctionHotkeyString
136%endif
137 ; Fall to .PrintRomBootHotkey
138
139;--------------------------------------------------------------------
140; .PrintRomBootHotkey
141; Parameters:
142; ES: BDA segment (zero)
143; Returns:
144; Nothing
145; Corrupts registers:
146; AX, CX, DX, SI, DI
147;--------------------------------------------------------------------
148.PrintRomBootHotkey:
149 mov ax, ROM_BOOT_HOTKEY_SCANCODE | ('8' << 8)
150 mov di, g_szRomBoot
151 call FormatFunctionHotkeyString
152 ; Fall to .EndHotkeyBarRendering
153
154;--------------------------------------------------------------------
155; .EndHotkeyBarRendering
156; Parameters:
157; Stack: Screen coordinates before drawing Hotkey Bar
158; Returns:
159; Nothing
160; Corrupts registers:
161; AX, CX, DI
162;--------------------------------------------------------------------
163.EndHotkeyBarRendering:
164 call HotkeyBar_ClearRestOfTopRow
165 pop ax
166 jmp SHORT HotkeyBar_RestoreCursorCoordinatesFromAX
167
168
169;--------------------------------------------------------------------
170; HotkeyBar_ClearRestOfTopRow
171; Parameters:
172; Nothing
173; Returns:
174; Nothing
175; Corrupts registers:
176; AX, CX, DI
177;--------------------------------------------------------------------
178HotkeyBar_ClearRestOfTopRow:
179 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
180 eMOVZX cx, al
181 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
182 sub cl, al
183 mov al, ' '
184 JMP_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
185
186
187;--------------------------------------------------------------------
188; FormatDriveHotkeyString
189; Parameters:
190; CH: Zero if letter in CL is selected for boot
191; CL: Drive letter hotkey from BOOTVARS
192; AL: First character for drive key string
193; AH: Second character for drive key string (ANGLE_QUOTE_RIGHT)
194; SI: Offset to hotkey description string
195; ES: BDA segment (zero)
196; Returns:
197; Nothing
198; Corrupts registers:
199; AX, CX, DX, SI, DI
200;--------------------------------------------------------------------
201FormatDriveHotkeyString:
202 ; Invalid scancodes are filtered on HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
203 ; so here we have either drive letter or function key pressed. If latter, draw
204 ; drive letters as unselected
205 cmp BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], FIRST_FUNCTION_KEY_SCANCODE
206 jae SHORT GetNonSelectedHotkeyDescriptionAttributeToDX
207
208 ; Drive selected to boot from?
209 test ch, ch
210 jnz SHORT GetNonSelectedHotkeyDescriptionAttributeToDX
211 jmp SHORT GetSelectedHotkeyDescriptionAttributeToDX
212
213
214;--------------------------------------------------------------------
215; FormatFunctionHotkeyString
216; Parameters:
217; AL: Scancode of function key, to know which if any to show as selected
218; Later replaced with an 'F' for the call to the output routine
219; AH: Second character for drive key string
220; SI: Offset to hotkey description string
221; ES: BDA segment (zero)
222; Returns:
223; Nothing
224; Corrupts registers:
225; AX, CX, DX, SI, DI
226;--------------------------------------------------------------------
227FormatFunctionHotkeyString:
228 xor cx, cx ; Null character, eaten in output routines
229
230 cmp [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
231 mov al, 'F' ; Replace scancode with character for output
232
233%ifdef MODULE_BOOT_MENU
234
235GetSelectedHotkeyDescriptionAttributeToDX:
236 mov si, ATTRIBUTE_CHARS.cHurryTimeout ; Selected hotkey
237 je SHORT GetDescriptionAttributeToDX ; From compare with bScancode above and from FormatDriveHotkeyString
238
239GetNonSelectedHotkeyDescriptionAttributeToDX:
240 mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Unselected hotkey
241
242 ; Display Library should not be called like this
243GetDescriptionAttributeToDX:
244 xchg dx, ax
245 call MenuAttribute_GetToAXfromTypeInSI
246 xchg dx, ax ; DX = Description attribute
247 ;; fall through to PushHotkeyParamsAndFormat
248
249
250%else ; if no MODULE_BOOT_MENU - No boot menu so use simpler attributes
251
252GetSelectedHotkeyDescriptionAttributeToDX:
253 mov dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
254 je SHORT SelectAttributeFromDHorDLbasedOnVideoMode ; From compare with bScancode above and from FormatDriveHotkeyString
255
256GetNonSelectedHotkeyDescriptionAttributeToDX:
257 mov dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
258
259SelectAttributeFromDHorDLbasedOnVideoMode:
260 mov ch, [es:BDA.bVidMode] ; We only need to preserve CL
261 shr ch, 1
262 jnc SHORT .AttributeLoadedToDL ; Black & White modes
263 shr ch, 1
264 jnz SHORT .AttributeLoadedToDL ; MDA
265 mov dl, dh
266.AttributeLoadedToDL:
267 ;; fall through to PushHotkeyParamsAndFormat
268
269%endif ; MODULE_BOOT_MENU
270
271
272;--------------------------------------------------------------------
273; PushHotkeyParamsAndFormat
274; Parameters:
275; AL: First character
276; AH: Second character
277; DX: Description Attribute
278; CX: Description string parameter
279; CS:DI: Description string
280; Returns:
281; Nothing
282; Corrupts registers:
283; AX, SI, DI
284;--------------------------------------------------------------------
285PushHotkeyParamsAndFormat:
286 push bp
287 mov bp, sp
288
289 mov si, MONO_BRIGHT
290
291 push si ; Key attribute
292 push ax ; First Character
293 mov al, ah
294 push ax ; Second Character
295
296 push dx ; Description attribute
297 push di ; Description string
298 push cx ; Description string parameter
299
300 push si ; Key attribute for last space
301
302 mov si, g_szHotkey
303 jmp DetectPrint_FormatCSSIfromParamsInSSBP
304
305
306;--------------------------------------------------------------------
307; MoveCursorToScreenTopLeftCorner
308; Parameters:
309; Nothing
310; Returns:
311; Nothing
312; Corrupts registers:
313; AX, DI
314;--------------------------------------------------------------------
315MoveCursorToScreenTopLeftCorner:
316 xor ax, ax ; Top left corner (0, 0)
317 ; Fall to HotkeyBar_RestoreCursorCoordinatesFromAX
318
319
320;--------------------------------------------------------------------
321; HotkeyBar_RestoreCursorCoordinatesFromAX
322; Parameters:
323; Nothing
324; Returns:
325; Nothing
326; Corrupts registers:
327; AX, DI
328;--------------------------------------------------------------------
329HotkeyBar_RestoreCursorCoordinatesFromAX:
330 JMP_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
331
332
333;--------------------------------------------------------------------
334; HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL
335; Parameters:
336; DS: RAMVARS segment
337; ES: BDA segment (zero)
338; DL: Drive Number
339; Returns:
340; Nothing
341; Corrupts registers:
342; AX, CX, DL, DI
343;--------------------------------------------------------------------
344HotkeyBar_StoreHotkeyToBootvarsForDriveNumberInDL:
345 call DriveXlate_ConvertDriveNumberFromDLtoDriveLetter
346 ; Fall to StoreHotkeyToBootvarsForDriveLetterInDL
347
348
349;--------------------------------------------------------------------
350; StoreHotkeyToBootvarsForDriveLetterInDL
351; Parameters:
352; DS: RAMVARS segment
353; ES: BDA segment (zero)
354; DL: Drive Letter ('A'...)
355; Returns:
356; Nothing
357; Corrupts registers:
358; AX, CX, DI
359;--------------------------------------------------------------------
360StoreHotkeyToBootvarsForDriveLetterInDL:
361 eMOVZX ax, dl
362 or al, 32 ; Upper case drive letter to lower case keystroke
363 jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
364
365
366;--------------------------------------------------------------------
367; ScanHotkeysFromKeyBufferAndStoreToBootvars
368; Parameters:
369; DS: RAMVARS segment
370; ES: BDA segment (zero)
371; Returns:
372; AL: Last scancode value
373; Corrupts registers:
374; AH, CX
375;--------------------------------------------------------------------
376ScanHotkeysFromKeyBufferAndStoreToBootvars:
377 call Keyboard_GetKeystrokeToAX
378 jz SHORT NoHotkeyToProcess
379
380 ; Prepare to read another key from buffer
381 ePUSH_T cx, ScanHotkeysFromKeyBufferAndStoreToBootvars
382 ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
383
384
385;--------------------------------------------------------------------
386; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
387; Parameters:
388; AL: Hotkey ASCII code
389; AH: Hotkey Scancode
390; DS: RAMVARS segment
391; ES: BDA segment (zero)
392; Returns:
393; AL: Last scancode seen
394; CF: Set if valid hotkey in AL
395; Clear if scancode in AL is not for any hotkey
396; Corrupts registers:
397; AH, CX, DI
398;--------------------------------------------------------------------
399HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
400 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
401
402 ; All scancodes are saved, even if it wasn't a drive letter,
403 ; which also covers our function key case. Invalid function keys
404 ; will not do anything (won't be printed, won't be accepted as input)
405 mov [es:di], ah
406
407 ; Drive letter hotkeys remaining, allow 'a' to 'z'
408 call Char_IsLowerCaseLetterInAL
409 jnc SHORT .KeystrokeIsNotValidDriveLetter
410 and al, ~32 ; We want to print upper case letters
411
412 ; Clear HD First flag to assume Floppy Drive hotkey
413 dec di
414 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
415
416 ; Determine if Floppy or Hard Drive hotkey
417 xchg cx, ax
418 call BootVars_GetLetterForFirstHardDriveToAX
419 cmp cl, al
420 jb SHORT .StoreDriveLetter ; Store Floppy Drive letter
421
422 ; Store Hard Drive letter
423 or BYTE [es:di], FLG_HOTKEY_HD_FIRST
424
425.StoreDriveLetter:
426 sbb di, BYTE 1 ; Sub CF if Floppy Drive
427 xchg ax, cx
428 stosb
429 stc ; Valid hotkey scancode returned in AL
430
431.KeystrokeIsNotValidDriveLetter:
432NoHotkeyToProcess:
433 mov al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
434 ret
435
436
437;--------------------------------------------------------------------
438; HotkeyBar_GetBootDriveNumbersToDX
439; Parameters:
440; DS: RAMVARS segment
441; ES: BDA segment (zero)
442; Returns:
443; DX: Drives selected as boot device, DL is primary
444; Corrupts registers:
445; AX
446;--------------------------------------------------------------------
447HotkeyBar_GetBootDriveNumbersToDX:
448 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wFddAndHddLetters]
449 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
450 jnz .noflip
451 xchg dl, dh
452.noflip:
453 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber
454 xchg dl, dh
455 ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber
456
457HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
458
Note: See TracBrowser for help on using the repository browser.