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

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

Initial string compression checkin. All changes are under MODULE_STRINGS_COMPRESSED, and this can still be turned off. With this checkin, the serial and ebios code can both be turned on at the same time and still we remain below the 8K boundary (barely). I still need to chekin StringsCompress.pl after some more code cleanup. The output, in StringsCompressed.asm is checked in here, and should continue be to checkin when Strings.asm is changed, for those who do not have/want to run the Perl script to recreate it.

File size: 14.7 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_ClearScreen
9; Parameters:
10; Nothing
11; Returns:
12; Nothing
13; Corrupts registers:
14; AX, DI
15;--------------------------------------------------------------------
16ALIGN JUMP_ALIGN
17BootMenuPrint_ClearScreen:
18 call BootMenuPrint_InitializeDisplayContext
19 xor ax, ax
20 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
21 mov ax, ' ' | (MONO_NORMAL<<8)
22 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
23 ret
24
25
26;--------------------------------------------------------------------
27; BootMenuPrint_InitializeDisplayContext
28; Parameters:
29; Nothing
30; Returns:
31; Nothing
32; Corrupts registers:
33; AX, DI
34;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36BootMenuPrint_InitializeDisplayContext:
37 CALL_DISPLAY_LIBRARY InitializeDisplayContext
38 ret
39
40
41;--------------------------------------------------------------------
42; Prints Boot Menu title strings.
43;
44; BootMenuPrint_TitleStrings
45; Parameters:
46; Nothing
47; Returns:
48; CF: Set since menu event handled
49; Corrupts registers:
50; AX, SI, DI
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53BootMenuPrint_TitleStrings:
54 mov si, ROMVARS.szTitle
55 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
56 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
57 mov si, ROMVARS.szVersion
58 ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
59
60
61;--------------------------------------------------------------------
62; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
63; Parameters:
64; CS:SI: Ptr to NULL terminated string to print
65; Returns:
66; CF: Set since menu event was handled successfully
67; Corrupts registers:
68; AX, DI
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
72;
73; We send all CSSI strings through the Format routine for the case of
74; compressed strings, but this doesn't hurt in the non-compressed case either
75; (perhaps a little slower, but shouldn't be noticeable to the user)
76; and results in smaller code size.
77;
78 push bp
79 mov bp,sp
80 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
81
82;--------------------------------------------------------------------
83; BootMenuPrint_FloppyMenuitem
84; Parameters:
85; DL: Untranslated Floppy Drive number
86; Returns:
87; Nothing
88; Corrupts registers:
89; AX, DX, SI, DI
90;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92BootMenuPrint_FloppyMenuitem:
93 call PrintDriveNumberAfterTranslationFromDL
94 push bp
95 mov bp, sp
96 mov si, g_szFDLetter
97 ePUSH_T ax, g_szFloppyDrv
98 add dl, 'A'
99 push dx ; Drive letter
100 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
101
102
103;--------------------------------------------------------------------
104; BootMenuPrint_HardDiskMenuitem
105; Parameters:
106; DL: Untranslated Hard Disk number
107; DS: RAMVARS segment
108; Returns:
109; CF: Set since menu event handled
110; Corrupts registers:
111; AX, BX, SI, DI
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114BootMenuPrint_HardDiskMenuitem:
115 call PrintDriveNumberAfterTranslationFromDL
116 call RamVars_IsDriveHandledByThisBIOS
117 jnc SHORT .HardDiskMenuitemForForeignDrive
118 ; Fall to .HardDiskMenuitemForOurDrive
119
120;--------------------------------------------------------------------
121; .HardDiskMenuitemForOurDrive
122; Parameters:
123; DL: Untranslated Hard Disk number
124; DS: RAMVARS segment
125; Returns:
126; CF: Set since menu event handled
127; Corrupts registers:
128; AX, BX, SI, DI
129;--------------------------------------------------------------------
130.HardDiskMenuitemForOurDrive:
131 call BootInfo_GetOffsetToBX
132 lea si, [bx+BOOTNFO.szDrvName]
133 xor bx, bx ; BDA segment
134 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
135 stc
136 ret
137
138;--------------------------------------------------------------------
139; BootMenuPrint_HardDiskMenuitemForForeignDrive
140; Parameters:
141; DL: Untranslated Hard Disk number
142; DS: RAMVARS segment
143; Returns:
144; CF: Set since menu event handled
145; Corrupts registers:
146; AX, SI, DI
147;--------------------------------------------------------------------
148ALIGN JUMP_ALIGN
149.HardDiskMenuitemForForeignDrive:
150 mov si, g_szforeignHD
151 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
152
153
154;--------------------------------------------------------------------
155; PrintDriveNumberAfterTranslationFromDL
156; Parameters:
157; DL: Untranslated Floppy Drive number
158; DS: RAMVARS segment
159; Returns:
160; Nothing
161; Corrupts registers:
162; AX, DI
163;--------------------------------------------------------------------
164ALIGN JUMP_ALIGN
165PrintDriveNumberAfterTranslationFromDL:
166 mov ax, dx
167 call DriveXlate_ToOrBack
168 xchg dx, ax ; Restore DX, WORD to print in AL
169 xor ah, ah
170 push bp
171 mov bp, sp
172 mov si, g_szDriveNum
173 push ax
174 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
175
176
177;--------------------------------------------------------------------
178; BootMenuPrint_FloppyMenuitemInformation
179; Parameters:
180; DL: Untranslated Floppy Drive number
181; DS: RAMVARS segment
182; Returns:
183; CF: Set since menu event was handled successfully
184; Corrupts registers:
185; AX, BX, CX, DX, SI, DI, ES
186;--------------------------------------------------------------------
187ALIGN JUMP_ALIGN
188BootMenuPrint_FloppyMenuitemInformation:
189 call BootMenuPrint_ClearInformationArea
190 call FloppyDrive_GetType ; Get Floppy Drive type to BX
191
192 push bp
193 mov bp, sp
194 ePUSH_T ax, g_szCapacity
195
196 mov si, g_szFddSizeOr ; .PrintXTFloppyType
197 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
198 jz SHORT .output
199
200 mov si, g_szFddUnknown ; .PrintUnknownFloppyType
201 cmp bl, FLOPPY_TYPE_35_ED
202 ja SHORT .output
203
204 ; Fall to .PrintKnownFloppyType
205
206
207;--------------------------------------------------------------------
208; .PrintKnownFloppyType
209; Parameters:
210; BX: Floppy drive type
211; Returns:
212; CF: Set since menu event was handled successfully
213; Corrupts registers:
214; AX, BX, SI, DI
215;
216; Floppy Drive Types:
217;
218; 0 Handled above
219; 1 FLOPPY_TYPE_525_DD 5 1/4 360K
220; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M
221; 3 FLOPPY_TYPE_35_DD 3 1/2 720K
222; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M
223; 5 3.5" ED on some BIOSes 3 1/2 2.88M
224; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M
225; >6 Unknwon, handled above
226;
227;--------------------------------------------------------------------
228.PrintKnownFloppyType:
229 mov si, g_szFddSize
230
231 mov ax, g_szFddThreeHalf
232 cmp bl, FLOPPY_TYPE_525_HD
233 ja .ThreeHalf
234%if g_szFddThreeFive_Displacement = 2
235 inc ax ; compressed string case
236 inc ax
237%else
238 add ax, g_szFddThreeFive_Displacement
239%endif
240.ThreeHalf:
241 push ax ; "5 1/4" or "3 1/2"
242
243 mov al,FloppyTypes.rgbCapacityMultiplier
244 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table
245 push ax
246
247ALIGN JUMP_ALIGN
248.output:
249 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
250
251FloppyTypes:
252.rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size
253.rgbCapacity:
254 db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1
255 db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2
256 db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3
257 db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4
258 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5
259 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6
260
261%if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
262%error "FddThreeFive_Displacement incorrect"
263%endif
264
265;--------------------------------------------------------------------
266; Prints Hard Disk Menuitem information strings.
267;
268; BootMenuPrint_HardDiskMenuitemInformation
269; Parameters:
270; DL: Untranslated Hard Disk number
271; DS: RAMVARS segment
272; Returns:
273; CF: Set since menu event was handled successfully
274; Corrupts registers:
275; BX, CX, DX, SI, DI, ES
276;--------------------------------------------------------------------
277ALIGN JUMP_ALIGN
278BootMenuPrint_HardDiskMenuitemInformation:
279 call RamVars_IsDriveHandledByThisBIOS
280 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
281 call FindDPT_ForDriveNumber ; DS:DI to point DPT
282 ; Fall to .HardDiskMenuitemInfoForOurDrive
283
284;--------------------------------------------------------------------
285; .HardDiskMenuitemInfoForOurDrive
286; Parameters:
287; DL: Untranslated Hard Disk number
288; DS:DI: Ptr to DPT
289; Returns:
290; Nothing
291; Corrupts registers:
292; AX, BX, CX, DX, SI, DI, ES
293;--------------------------------------------------------------------
294.HardDiskMenuitemInfoForOurDrive:
295 push di
296 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
297 push bp
298 mov bp, sp
299 ePUSH_T ax, g_szCapacity
300
301 ; Get and push L-CHS size
302 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
303 call AH15h_GetSectorCountToDXAX
304 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
305
306 ; Get and push total LBA size
307 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
308 call BootInfo_GetTotalSectorCount
309 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
310
311 mov si, g_szSizeDual
312 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
313
314
315;--------------------------------------------------------------------
316; .HardDiskMenuitemInfoForForeignDrive
317; Parameters:
318; DL: Untranslated Hard Disk number
319; DS: RAMVARS segment
320; Returns:
321; CF: Set since menu event was handled successfully
322; Corrupts registers:
323; AX, BX, CX, DX, SI, DI
324;--------------------------------------------------------------------
325ALIGN JUMP_ALIGN
326.HardDiskMenuitemInfoForForeignDrive:
327 push bp
328 mov bp, sp
329 ePUSH_T ax, g_szCapacity
330
331 call DriveXlate_ToOrBack
332 call AH15h_GetSectorCountFromForeignDriveToDXAX
333 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
334
335 mov si, g_szSizeSingle
336 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
337
338
339;--------------------------------------------------------------------
340; BootMenuPrint_FormatCSSIfromParamsInSSBP
341; Parameters:
342; CS:SI: Ptr to string to format
343; BP: SP before pushing parameters
344; Returns:
345; BP: Popped from stack
346; Corrupts registers:
347; AX, DI
348;--------------------------------------------------------------------
349ALIGN JUMP_ALIGN
350BootMenuPrint_FormatCSSIfromParamsInSSBP:
351 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
352 stc ; Successfull return from menu event
353 pop bp
354 ret
355
356
357;--------------------------------------------------------------------
358; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
359; Parameters:
360; BX:DX:AX: Sector count
361; Returns:
362; Size in stack
363; Corrupts registers:
364; AX, BX, CX, DX, SI
365;--------------------------------------------------------------------
366ALIGN JUMP_ALIGN
367ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
368 pop si ; Pop return address
369 call Size_ConvertSectorCountInBXDXAXtoKiB
370 mov cx, BYTE_MULTIPLES.kiB
371 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
372 push ax ; Size in magnitude
373 push cx ; Tenths
374 push dx ; Magnitude character
375 jmp si
376
377
378;--------------------------------------------------------------------
379; BootMenuPrint_ClearInformationArea
380; Parameters:
381; Nothing
382; Returns:
383; CF: Set
384; Corrupts registers:
385; AX, DI
386;--------------------------------------------------------------------
387ALIGN JUMP_ALIGN
388BootMenuPrint_ClearInformationArea:
389 CALL_MENU_LIBRARY ClearInformationArea
390 stc
391 ret
392
393
394;--------------------------------------------------------------------
395; BootMenuPrint_TheBottomOfScreen
396; Parameters:
397; DS: RAMVARS segment
398; Returns:
399; Nothing
400; Corrupts registers:
401; AX, BX, CX, DX, SI, DI
402;--------------------------------------------------------------------
403ALIGN JUMP_ALIGN
404BootMenuPrint_TheBottomOfScreen:
405 call FloppyDrive_GetCountToCX
406 mov bl, cl ; Floppy Drive count to BL
407 call RamVars_GetHardDiskCountFromBDAtoCX
408 mov bh, cl ; Hard Disk count to BH
409 ; Fall to .MoveCursorToHotkeyStrings
410
411;--------------------------------------------------------------------
412; .MoveCursorToHotkeyStrings
413; Parameters:
414; Nothing
415; Returns:
416; Nothing
417; Corrupts registers:
418; AX, DI
419;--------------------------------------------------------------------
420.MoveCursorToHotkeyStrings:
421 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
422 xor al, al
423 dec ah
424 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
425 ; Fall to .PrintHotkeyString
426
427;--------------------------------------------------------------------
428; .PrintHotkeyString
429; Parameters:
430; BL: Floppy Drives
431; BH: Hard Drives
432; Returns:
433; Nothing
434; Corrupts registers:
435; AX, CX, DX, SI, DI
436;--------------------------------------------------------------------
437.PrintHotkeyString:
438 ; Display Library should not be called like this
439 mov si, ATTRIBUTE_CHARS.cHighlightedItem
440 call MenuAttribute_GetToAXfromTypeInSI
441 xchg dx, ax
442 mov cx, MONO_BRIGHT
443
444 test bl, bl ; Any Floppy Drives?
445 jz SHORT .SkipFloppyDriveHotkeys
446 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
447 mov si, g_szFDD
448 call PushHotkeyParamsAndFormat
449
450.SkipFloppyDriveHotkeys:
451 test bh, bh ; Any Hard Drives?
452 jz SHORT .SkipHardDriveHotkeys
453 xchg ax, cx ; Store Key Attribute
454 call BootMenu_GetLetterForFirstHardDiskToCL
455 mov ch, ANGLE_QUOTE_RIGHT
456 xchg ax, cx
457 mov si, g_szHDD
458 call PushHotkeyParamsAndFormat
459
460.SkipHardDriveHotkeys:
461 ; Fall to .PrintRomBootHotkey
462
463;--------------------------------------------------------------------
464; .PrintRomBootHotkey
465; Parameters:
466; CX: Key Attribute
467; DX: Description Attribute
468; Returns:
469; Nothing
470; Corrupts registers:
471; AX, SI, DI
472;--------------------------------------------------------------------
473.PrintRomBootHotkey:
474 mov ax, 'F' | ('8'<<8) ; F8
475 mov si, g_szRomBoot
476 ; Fall to PushHotkeyParamsAndFormat
477
478;--------------------------------------------------------------------
479; PushHotkeyParamsAndFormat
480; Parameters:
481; AL: First character
482; AH: Second character
483; CX: Key Attribute
484; DX: Description Attribute
485; CS:SI: Description string
486; Returns:
487; Nothing
488; Corrupts registers:
489; AX, SI, DI
490;--------------------------------------------------------------------
491ALIGN JUMP_ALIGN
492PushHotkeyParamsAndFormat:
493 push bp
494 mov bp, sp
495
496 push cx ; Key attribute
497 push ax ; First character
498 xchg al, ah
499 push ax ; Second character
500 push dx ; Description attribute
501 push si ; Description string
502 push cx ; Key attribute for last space
503 mov si, g_szHotkey
504 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
505
506
Note: See TracBrowser for help on using the repository browser.