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

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

ifdef'd out more unused code. Also added a tool for looking through the listing and the output of the precompiler to aid in finding dead code. Some changes in the files are to add annotations for the tool to avoid false positives.

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