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

Last change on this file since 496 was 492, checked in by gregli@…, 12 years ago

Removed the dependency between MODULE_BOOT_MENU and MODULE_HOTKEYS. With these changes, 0, 1, or 2 of them can be included in a build. This change also means that the hotkeys don't work while the menu is up. But the most important hotkey there was for Rom Boot, and that has been added to the menu as a choice proper. Lots of changes across the board in the hotkeys code - even if we eventually back this change out (becaue, for example we want hotkeys to work in the menu) we should probably start from this base and add that functionality back in, as these changes results in approximately 120 bytes of savings and includes new functionality, such as the Rom Boot menu item and the Com Detect hotkey.

File size: 12.8 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:
[492]34 call HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]35 ; Fall to HotkeyBar_DrawToTopOfScreen
[492]36
37
[392]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:
[492]68 mov cx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
69
[392]70 call FloppyDrive_GetCountToAX
71 test ax, ax ; Any Floppy Drives?
72 jz SHORT .SkipFloppyDriveHotkeys
73
[492]74 mov ax, (ANGLE_QUOTE_RIGHT << 8) | DEFAULT_FLOPPY_DRIVE_LETTER
75 mov di, g_szFDD
[392]76 call FormatDriveHotkeyString
77
78.SkipFloppyDriveHotkeys:
79 ; Fall to .PrintHardDriveHotkeys
80
81;--------------------------------------------------------------------
82; .PrintHardDriveHotkeys
83; Parameters:
84; DS: RAMVARS segment
85; ES: BDA segment (zero)
86; Returns:
87; Nothing
88; Corrupts registers:
89; AX, CX, DX, SI, DI
90;--------------------------------------------------------------------
[492]91 call DriveXlate_GetLetterForFirstHardDriveToAX
[392]92 mov ah, ANGLE_QUOTE_RIGHT
[492]93 mov cl, ch
94 mov di, g_szHDD
[392]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
[492]109 mov ax, BOOT_MENU_HOTKEY_SCANCODE | ('2' << 8)
110 mov di, g_szBootMenu
[392]111 call FormatFunctionHotkeyString
112%endif
[492]113 ; Fall to .PrintComDetectHotkey
[392]114
115;--------------------------------------------------------------------
[492]116; .PrintComDetectHotkey
117; Parameters:
118; ES: BDA segment (zero)
119; Returns:
120; Nothing
121; Corrupts registers:
122; AX, CX, DX, SI, DI
123;--------------------------------------------------------------------
124.PrintComDetectHotkey:
125%ifdef MODULE_SERIAL
126 mov ax, COM_DETECT_HOTKEY_SCANCODE | ('6' << 8)
127 mov di, g_szHotComDetect
128 call FormatFunctionHotkeyString
129%endif
130 ; Fall to .PrintRomBootHotkey
131
132;--------------------------------------------------------------------
[392]133; .PrintRomBootHotkey
134; Parameters:
135; ES: BDA segment (zero)
136; Returns:
137; Nothing
138; Corrupts registers:
139; AX, CX, DX, SI, DI
140;--------------------------------------------------------------------
141.PrintRomBootHotkey:
[492]142 mov ax, ROM_BOOT_HOTKEY_SCANCODE | ('8' << 8)
143 mov di, g_szRomBoot
[392]144 call FormatFunctionHotkeyString
145 ; Fall to .EndHotkeyBarRendering
146
147;--------------------------------------------------------------------
148; .EndHotkeyBarRendering
149; Parameters:
150; Stack: Screen coordinates before drawing Hotkey Bar
151; Returns:
152; Nothing
153; Corrupts registers:
154; AX, CX, DI
155;--------------------------------------------------------------------
156.EndHotkeyBarRendering:
157 call HotkeyBar_ClearRestOfTopRow
158 pop ax
159 jmp SHORT HotkeyBar_RestoreCursorCoordinatesFromAX
160
161
162;--------------------------------------------------------------------
163; HotkeyBar_ClearRestOfTopRow
164; Parameters:
165; Nothing
166; Returns:
167; Nothing
168; Corrupts registers:
169; AX, CX, DI
170;--------------------------------------------------------------------
171HotkeyBar_ClearRestOfTopRow:
172 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
173 eMOVZX cx, al
174 CALL_DISPLAY_LIBRARY GetSoftwareCoordinatesToAX
175 sub cl, al
176 mov al, ' '
177 CALL_DISPLAY_LIBRARY PrintRepeatedCharacterFromALwithCountInCX
178 ret
179
180
181;--------------------------------------------------------------------
182; FormatDriveHotkeyString
183; Parameters:
184; CL: Drive letter hotkey from BOOTVARS
[492]185; AL: First character for drive key string
186; AH: Second character for drive key string (ANGLE_QUOTE_RIGHT)
[392]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;--------------------------------------------------------------------
[492]194;; No work to do before going into FormatFunctionHotkeyString
195FormatDriveHotkeyString equ GetNonSelectedHotkeyDescriptionAttributeToDX
[392]196
197;--------------------------------------------------------------------
198; FormatFunctionHotkeyString
199; Parameters:
[492]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
[392]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:
[492]211 xor cx, cx ; Null character, eaten in output routines
[392]212
[492]213 cmp [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode], al
214 mov al, 'F' ; Replace scancode with character for output
[392]215
216%ifdef MODULE_BOOT_MENU
[492]217
[392]218 mov si, ATTRIBUTE_CHARS.cHurryTimeout ; Selected hotkey
[492]219 jz SHORT GetDescriptionAttributeToDX ; From compare with bScancode above
[392]220
221GetNonSelectedHotkeyDescriptionAttributeToDX:
222 mov si, ATTRIBUTE_CHARS.cHighlightedItem ; Unselected hotkey
223
224 ; Display Library should not be called like this
225GetDescriptionAttributeToDX:
[492]226 xchg dx, ax
[392]227 call MenuAttribute_GetToAXfromTypeInSI
228 xchg dx, ax ; DX = Description attribute
[492]229 ;; fall through to PushHotkeyParamsAndFormat
[392]230
[492]231%else ; MODULE_BOOT_MENU - No boot menu so use simpler attributes
[392]232
[410]233 mov dx, (COLOR_ATTRIBUTE(COLOR_YELLOW, COLOR_CYAN) << 8) | MONO_REVERSE_BLINK
[492]234 jz SHORT SelectAttributeFromDHorDLbasedOnVideoMode ; From compare with bScancode above
[392]235
236GetNonSelectedHotkeyDescriptionAttributeToDX:
[410]237 mov dx, (COLOR_ATTRIBUTE(COLOR_BLACK, COLOR_CYAN) << 8) | MONO_REVERSE
[492]238
[410]239SelectAttributeFromDHorDLbasedOnVideoMode:
240 mov al, [es:BDA.bVidMode]
241 shr al, 1
242 jnc SHORT .AttributeLoadedToDL ; Black & White modes
243 shr al, 1
244 jnz SHORT .AttributeLoadedToDL ; MDA
245 mov dl, dh
246.AttributeLoadedToDL:
[492]247 ;; fall through to PushHotkeyParamsAndFormat
[410]248
[492]249%endif ; MODULE_BOOT_MENU
[392]250
251
252;--------------------------------------------------------------------
253; PushHotkeyParamsAndFormat
254; Parameters:
[492]255; BL: First character
256; BH: Second character
[392]257; DX: Description Attribute
258; CX: Description string parameter
[492]259; CS:DI: Description string
[392]260; Returns:
261; Nothing
262; Corrupts registers:
263; AX, SI, DI
264;--------------------------------------------------------------------
265PushHotkeyParamsAndFormat:
266 push bp
267 mov bp, sp
268
[492]269 mov si, MONO_BRIGHT
[392]270
[492]271 push si ; Key attribute
272 push ax ; First Character
273 mov al, ah
274 push ax ; Second Character
275
[392]276 push dx ; Description attribute
[492]277 push di ; Description string
[392]278 push cx ; Description string parameter
[492]279
280 push si ; Key attribute for last space
[392]281
282 mov si, g_szHotkey
283 jmp DetectPrint_FormatCSSIfromParamsInSSBP
284
285
286;--------------------------------------------------------------------
287; MoveCursorToScreenTopLeftCorner
288; Parameters:
289; Nothing
290; Returns:
291; Nothing
292; Corrupts registers:
293; AX, DI
294;--------------------------------------------------------------------
295MoveCursorToScreenTopLeftCorner:
296 xor ax, ax ; Top left corner (0, 0)
297 ; Fall to HotkeyBar_RestoreCursorCoordinatesFromAX
298
299
300;--------------------------------------------------------------------
301; HotkeyBar_RestoreCursorCoordinatesFromAX
302; Parameters:
303; Nothing
304; Returns:
305; Nothing
306; Corrupts registers:
307; AX, DI
308;--------------------------------------------------------------------
309HotkeyBar_RestoreCursorCoordinatesFromAX:
310 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
311 ret
312
313
314;--------------------------------------------------------------------
[395]315; HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL
316; Parameters:
317; DS: RAMVARS segment
318; ES: BDA segment (zero)
319; DL: Drive Letter ('A'...)
320; Returns:
321; Nothing
322; Corrupts registers:
323; AX, CX, DI
324;--------------------------------------------------------------------
325HotkeyBar_StoreHotkeyToBootvarsForDriveLetterInDL:
326 eMOVZX ax, dl
[491]327 xor al, 32 ; Upper case drive letter to lower case keystroke
[395]328 jmp SHORT HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
329
330
331;--------------------------------------------------------------------
[492]332; HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]333; Parameters:
334; DS: RAMVARS segment
335; ES: BDA segment (zero)
336; Returns:
[492]337; AL: Last scancode value
[392]338; Corrupts registers:
[492]339; AH, CX
[392]340;--------------------------------------------------------------------
[492]341HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars:
[392]342 call Keyboard_GetKeystrokeToAX
343 jz SHORT NoHotkeyToProcess
344
[492]345 ePUSH_T cx, HotkeyBar_ScanHotkeysFromKeyBufferAndStoreToBootvars
[392]346 ; Fall to HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
347
348
349;--------------------------------------------------------------------
350; HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX
351; Parameters:
352; AL: Hotkey ASCII code
353; AH: Hotkey Scancode
354; DS: RAMVARS segment
355; ES: BDA segment (zero)
356; Returns:
[492]357; AL: Last scancode seen
[392]358; Corrupts registers:
[492]359; AH, CX, DI
[392]360;--------------------------------------------------------------------
361HotkeyBar_StoreHotkeyToBootvarsIfValidKeystrokeInAX:
[492]362 mov di, BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode
[392]363
[492]364 ; All scancodes are saved, even if it wasn't a drive letter,
365 ; which also covers our function key case. Invalid function keys
366 ; will not do anything (won't be printed, won't be accepted as input)
367 mov [es:di], ah
368
[392]369 ; Drive letter hotkeys remaining, allow 'a' to 'z'
370 call Char_IsLowerCaseLetterInAL
[492]371 jnc SHORT .KeystrokeIsNotValidDriveLetter
[491]372 xor al, 32 ; We want to print upper case letters
[392]373
374 ; Clear HD First flag to assume Floppy Drive hotkey
[492]375 dec di
[392]376 and BYTE [es:di], ~FLG_HOTKEY_HD_FIRST
377
378 ; Determine if Floppy or Hard Drive hotkey
379 eMOVZX cx, al ; Clear CH to clear scancode
[492]380 call DriveXlate_GetLetterForFirstHardDriveToAX
[392]381 cmp cl, al
382 jb SHORT .StoreDriveLetter ; Store Floppy Drive letter
383
384 ; Store Hard Drive letter
385 or BYTE [es:di], FLG_HOTKEY_HD_FIRST
386
387.StoreDriveLetter:
[492]388 sbb di, BYTE 1 ; Sub CF if Floppy Drive
[392]389 xchg ax, cx
[399]390 mov [es:di], al ; AH = zero to clear function hotkey
[392]391
[492]392.KeystrokeIsNotValidDriveLetter:
[392]393NoHotkeyToProcess:
[492]394 mov al, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bScancode]
[392]395 ret
396
397;--------------------------------------------------------------------
[492]398; HotkeyBar_GetBootDriveNumbersToDX
[392]399; Parameters:
400; DS: RAMVARS segment
401; ES: BDA segment (zero)
402; Returns:
[492]403; DX: Drives selected as boot device, DL is primary
[392]404; Corrupts registers:
[492]405; AX
[392]406;--------------------------------------------------------------------
[492]407HotkeyBar_GetBootDriveNumbersToDX:
[392]408 mov dx, [es:BOOTVARS.hotkeyVars+HOTKEYVARS.wHddAndFddLetters]
[492]409 test BYTE [es:BOOTVARS.hotkeyVars+HOTKEYVARS.bFlags], FLG_HOTKEY_HD_FIRST
410 jnz .noflip
[392]411 xchg dl, dh
[492]412.noflip:
413 call DriveXlate_ConvertDriveLetterInDLtoDriveNumber
414 xchg dl, dh
415 ; Fall to HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber
416
417HotkeyBar_FallThroughTo_DriveXlate_ConvertDriveLetterInDLtoDriveNumber:
[392]418
Note: See TracBrowser for help on using the repository browser.