source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm@ 382

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

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 12.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for printing boot menu strings.
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; BootMenuPrint_RefreshItem
25;
26; Parameters:
27; DL: Untranslated Floppy Drive number
28; Returns:
29; Nothing
30; Corrupts registers:
31; AX, BX, DX, SI, DI
32;--------------------------------------------------------------------
33BootMenuPrint_RefreshItem:
34 call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
35 jnc BootMenuEvent_EventCompleted ; if no menu item selected, out we go
36
37 push bp
38 mov bp, sp
39
40 call FindDPT_ForDriveNumberInDL
41 jc .notOurs
42
43 call BootMenuInfo_ConvertDPTtoBX
44 mov si, g_szDriveNumBOOTNFO ; special g_szDriveNum that prints from BDA
45 jmp .go
46
47.notOurs:
48 mov si,g_szDriveNum
49 mov bx,g_szForeignHD ; assume a hard disk for the moment
50
51 test dl, dl
52 js .go
53 mov bl,((g_szFloppyDrv)-$$ & 0xff) ; and revisit the earlier assumption...
54
55.go:
56 mov ax, dx ; preserve DL for the floppy drive letter addition
57 call DriveXlate_ToOrBack
58 push dx ; translated drive number
59 push bx ; sub string
60 add al, 'A' ; floppy drive letter (we always push this although
61 push ax ; the hard disks don't ever use it, but it does no harm)
62
63 jmp short BootMenuPrint_RefreshInformation.FormatRelay
64
65;--------------------------------------------------------------------
66; Prints Boot Menu title strings.
67;
68; BootMenuPrint_TitleStrings
69; Parameters:
70; Nothing
71; Returns:
72; CF: Set since menu event handled
73; Corrupts registers:
74; AX, SI, DI
75;--------------------------------------------------------------------
76BootMenuPrint_TitleStrings:
77 mov si, ROMVARS.szTitle
78 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
79 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
80 mov si, ROMVARS.szVersion
81 ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
82
83;--------------------------------------------------------------------
84; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
85; Parameters:
86; CS:SI: Ptr to NULL terminated string to print
87; Returns:
88; CF: Set since menu event was handled successfully
89; Corrupts registers:
90; AX, DI
91;--------------------------------------------------------------------
92BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
93;
94; We send all CSSI strings through the Format routine for the case of
95; compressed strings, but this doesn't hurt in the non-compressed case either
96; (perhaps a little slower, but shouldn't be noticeable to the user)
97; and results in smaller code size.
98;
99 push bp
100 mov bp,sp
101 jmp short BootMenuPrint_RefreshInformation.FormatRelay
102
103
104;--------------------------------------------------------------------
105; BootMenuPrint_FloppyMenuitemInformation
106; Parameters:
107; DL: Untranslated Floppy Drive number
108; DS: RAMVARS segment
109; Returns:
110; CF: Set since menu event was handled successfully
111; Corrupts registers:
112; AX, BX, CX, DX, SI, DI, ES
113;--------------------------------------------------------------------
114BootMenuPrint_RefreshInformation:
115 CALL_MENU_LIBRARY ClearInformationArea
116
117 call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
118 jnc BootMenuEvent_EventCompleted ; if no menu selection, abort
119
120 push bp
121 mov bp, sp
122
123 mov si, g_szCapacity ; Setup print string now, carries through to print call
124
125 call FindDPT_ForDriveNumberInDL
126
127 inc dl ; are we a hard disk?
128 dec dl ; inc/dec will set SF, without modifying CF or DL
129 js .HardDiskRefreshInformation
130
131 jnc .ours ; Based on CF from FindDPT_ForDriveNumberInDL above
132 call FloppyDrive_GetType ; Get Floppy Drive type to BX
133 jmp .around
134.ours:
135 call AH8h_GetDriveParameters
136.around:
137
138 mov ax, g_szFddSizeOr ; .PrintXTFloppyType
139 test bl, bl ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
140 jz SHORT .PushAXAndOutput
141
142 mov al, (g_szFddUnknown - $$) & 0xff ; .PrintUnknownFloppyType
143 cmp bl, FLOPPY_TYPE_35_ED
144 ja SHORT .PushAXAndOutput
145
146 ; Fall to .PrintKnownFloppyType
147
148;--------------------------------------------------------------------
149; .PrintKnownFloppyType
150; Parameters:
151; BX: Floppy drive type
152; Returns:
153; CF: Set since menu event was handled successfully
154; Corrupts registers:
155; AX, BX, SI, DI
156;
157; Floppy Drive Types:
158;
159; 0 Handled above
160; 1 FLOPPY_TYPE_525_DD 5 1/4 360K
161; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M
162; 3 FLOPPY_TYPE_35_DD 3 1/2 720K
163; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M
164; 5 3.5" ED on some BIOSes 3 1/2 2.88M
165; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M
166; >6 Unknwon, handled above
167;
168;--------------------------------------------------------------------
169.PrintKnownFloppyType:
170 mov al, (g_szFddSize - $$) & 0xff
171 push ax
172
173 mov al, (g_szFddThreeHalf - $$) & 0xff
174 cmp bl, FLOPPY_TYPE_525_HD
175 ja .ThreeHalf
176 mov al, (g_szFddFiveQuarter - $$) & 0xff
177.ThreeHalf:
178 push ax ; "5 1/4" or "3 1/2"
179
180 mov al,FloppyTypes.rgbCapacityMultiplier
181 mov bh, 0
182 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table
183
184.PushAXAndOutput:
185 push ax
186
187.FormatRelay:
188 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
189
190
191;--------------------------------------------------------------------
192; Prints Hard Disk Menuitem information strings.
193;
194; BootMenuPrint_HardDiskMenuitemInformation
195; Parameters:
196; DS: RAMVARS segment
197; Returns:
198; CF: Set since menu event was handled successfully
199; Corrupts registers:
200; BX, CX, DX, SI, DI, ES
201;--------------------------------------------------------------------
202.HardDiskRefreshInformation:
203 jc .HardDiskMenuitemInfoForForeignDrive ; Based on CF from FindDPT_ForDriveNumberInDL (way) above
204
205.HardDiskMenuitemInfoForOurDrive:
206 ePUSH_T ax, g_szInformation ; Add substring for our hard disk information
207 call BootMenuInfo_GetTotalSectorCount ; Get Total LBA Size
208 jmp .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
209
210.HardDiskMenuitemInfoForForeignDrive:
211 call DriveXlate_ToOrBack
212 call AH15h_GetSectorCountFromForeignDriveToDXAX
213
214.ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
215 ePUSH_T cx, g_szCapacityNum ; Push format substring
216 call Size_ConvertSectorCountInBXDXAXtoKiB
217 mov cx, BYTE_MULTIPLES.kiB
218 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
219 push ax ; Size in magnitude
220 push cx ; Tenths
221 push dx ; Magnitude character
222
223 test di,di
224 jz short BootMenuPrint_FormatCSSIfromParamsInSSBP
225
226%include "BootMenuPrintCfg.asm" ; inline of code to fill out remainder of information string
227
228;;; fall-through to BootMenuPrint_FormatCSSIfromParamsInSSBP
229
230
231;--------------------------------------------------------------------
232; BootMenuPrint_FormatCSSIfromParamsInSSBP
233; Parameters:
234; CS:SI: Ptr to string to format
235; BP: SP before pushing parameters
236; Returns:
237; BP: Popped from stack
238; CF: Set since menu event was handled successfully
239; Corrupts registers:
240; AX, DI
241;--------------------------------------------------------------------
242BootMenuPrint_FormatCSSIfromParamsInSSBP:
243 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
244 stc ; Successful return from menu event
245 pop bp
246 ret
247
248
249;--------------------------------------------------------------------
250; BootMenuPrint_ClearScreen
251; Parameters:
252; Nothing
253; Returns:
254; Nothing
255; Corrupts registers:
256; AX, DI
257;--------------------------------------------------------------------
258BootMenuPrint_ClearScreen:
259 call BootMenuPrint_InitializeDisplayContext
260 xor ax, ax
261 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
262 mov ax, ' ' | (MONO_NORMAL<<8)
263 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
264 ret
265
266
267;--------------------------------------------------------------------
268; BootMenuPrint_TheBottomOfScreen
269; Parameters:
270; DS: RAMVARS segment
271; Returns:
272; Nothing
273; Corrupts registers:
274; AX, BX, CX, DX, SI, DI
275;--------------------------------------------------------------------
276BootMenuPrint_TheBottomOfScreen:
277 call FloppyDrive_GetCountToAX
278 xchg bx, ax ; Floppy Drive count to BL
279 call RamVars_GetHardDiskCountFromBDAtoAX
280 mov bh, al ; Hard Disk count to BH
281 ; Fall to .MoveCursorToHotkeyStrings
282
283;--------------------------------------------------------------------
284; .MoveCursorToHotkeyStrings
285; Parameters:
286; Nothing
287; Returns:
288; Nothing
289; Corrupts registers:
290; AX, DI
291;--------------------------------------------------------------------
292.MoveCursorToHotkeyStrings:
293 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
294 xor al, al
295 dec ah
296 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
297 ; Fall to .PrintHotkeyString
298
299;--------------------------------------------------------------------
300; .PrintHotkeyString
301; Parameters:
302; BL: Floppy Drives
303; BH: Hard Drives
304; Returns:
305; Nothing
306; Corrupts registers:
307; AX, CX, DX, SI, DI
308;--------------------------------------------------------------------
309.PrintHotkeyString:
310 ; Display Library should not be called like this
311 mov si, ATTRIBUTE_CHARS.cHighlightedItem
312 call MenuAttribute_GetToAXfromTypeInSI
313 xchg dx, ax
314 mov cx, MONO_BRIGHT
315
316 test bl, bl ; Any Floppy Drives?
317 jz SHORT .SkipFloppyDriveHotkeys
318 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
319 mov si, g_szFDD
320 call PushHotkeyParamsAndFormat
321
322.SkipFloppyDriveHotkeys:
323 test bh, bh ; Any Hard Drives?
324 jz SHORT .SkipHardDriveHotkeys
325 call BootMenu_GetLetterForFirstHardDiskToAL
326 mov ah, ANGLE_QUOTE_RIGHT
327 mov si, g_szHDD
328 call PushHotkeyParamsAndFormat
329
330.SkipHardDriveHotkeys:
331 ; Fall to .PrintRomBootHotkey
332
333;--------------------------------------------------------------------
334; .PrintRomBootHotkey
335; Parameters:
336; CX: Key Attribute
337; DX: Description Attribute
338; Returns:
339; Nothing
340; Corrupts registers:
341; AX, SI, DI
342;--------------------------------------------------------------------
343.PrintRomBootHotkey:
344 mov ax, 'F' | ('8'<<8) ; F8
345 mov si, g_szRomBoot
346 ; Fall to PushHotkeyParamsAndFormat
347
348;--------------------------------------------------------------------
349; PushHotkeyParamsAndFormat
350; Parameters:
351; AL: First character
352; AH: Second character
353; CX: Key Attribute
354; DX: Description Attribute
355; CS:SI: Description string
356; Returns:
357; Nothing
358; Corrupts registers:
359; AX, SI, DI
360;--------------------------------------------------------------------
361PushHotkeyParamsAndFormat:
362 push bp
363 mov bp, sp
364
365 push cx ; Key attribute
366 push ax ; First character
367 xchg al, ah
368 push ax ; Second character
369 push dx ; Description attribute
370 push si ; Description string
371 push cx ; Key attribute for last space
372 mov si, g_szHotkey
373
374BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
375 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
376
377
378;--------------------------------------------------------------------
379; BootMenuPrint_InitializeDisplayContext
380; Parameters:
381; Nothing
382; Returns:
383; Nothing
384; Corrupts registers:
385; AX, DI
386;--------------------------------------------------------------------
387BootMenuPrint_InitializeDisplayContext:
388 CALL_DISPLAY_LIBRARY InitializeDisplayContext
389 ret
390
391
392FloppyTypes:
393.rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size
394.rgbCapacity:
395 db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1
396 db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2
397 db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3
398 db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4
399 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5
400 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6
Note: See TracBrowser for help on using the repository browser.