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

Last change on this file since 370 was 369, checked in by gregli@…, 13 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

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