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

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

Added logic to skip scanning COM ports if a COM port was already found during the normal detection process, to avoid finding the same serial drive twice and preseting the OS with two drives which in reality point to the same physical file on the server. Also added logic to skip scanning for the slave serial drive if the master was not found. And various small optimizations.

File size: 15.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;;; 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; CF: Set since menu event was handled successfully
257; Corrupts registers:
258; AX, DI
259;--------------------------------------------------------------------
260ALIGN JUMP_ALIGN
261BootMenuPrint_FormatCSSIfromParamsInSSBP:
262 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
263 stc ; Successfull return from menu event
264 pop bp
265 ret
266
267
268;--------------------------------------------------------------------
269; Prints Hard Disk Menuitem information strings.
270;
271; BootMenuPrint_HardDiskMenuitemInformation
272; Parameters:
273; DL: Untranslated Hard Disk number
274; DS: RAMVARS segment
275; Returns:
276; CF: Set since menu event was handled successfully
277; Corrupts registers:
278; BX, CX, DX, SI, DI, ES
279;--------------------------------------------------------------------
280ALIGN JUMP_ALIGN
281BootMenuPrint_HardDiskMenuitemInformation:
282 call RamVars_IsDriveHandledByThisBIOS
283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
284 call FindDPT_ForDriveNumber ; DS:DI to point DPT
285 ; Fall to .HardDiskMenuitemInfoForOurDrive
286
287;--------------------------------------------------------------------
288; .HardDiskMenuitemInfoForOurDrive
289; Parameters:
290; DL: Untranslated Hard Disk number
291; DS:DI: Ptr to DPT
292; Returns:
293; Nothing
294; Corrupts registers:
295; AX, BX, CX, DX, SI, DI, ES
296;--------------------------------------------------------------------
297.HardDiskMenuitemInfoForOurDrive:
298 push di
299 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
300 push bp
301 mov bp, sp
302 ePUSH_T ax, g_szCapacity
303
304 ; Get and push L-CHS size
305 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
306 call AH15h_GetSectorCountToDXAX
307 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
308
309 ; Get and push total LBA size
310 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
311 call BootInfo_GetTotalSectorCount
312 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
313
314 mov si, g_szSizeDual
315 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
316
317
318;--------------------------------------------------------------------
319; .HardDiskMenuitemInfoForForeignDrive
320; Parameters:
321; DL: Untranslated Hard Disk number
322; DS: RAMVARS segment
323; Returns:
324; CF: Set since menu event was handled successfully
325; Corrupts registers:
326; AX, BX, CX, DX, SI, DI
327;--------------------------------------------------------------------
328ALIGN JUMP_ALIGN
329.HardDiskMenuitemInfoForForeignDrive:
330 push bp
331 mov bp, sp
332 ePUSH_T ax, g_szCapacity
333
334 call DriveXlate_ToOrBack
335 call AH15h_GetSectorCountFromForeignDriveToDXAX
336 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
337
338 mov si, g_szSizeSingle
339 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
340
341
342;--------------------------------------------------------------------
343; BootMenuPrint_ClearInformationArea
344; Parameters:
345; Nothing
346; Returns:
347; CF: Set
348; Corrupts registers:
349; AX, DI
350;--------------------------------------------------------------------
351ALIGN JUMP_ALIGN
352BootMenuPrint_ClearInformationArea:
353 CALL_MENU_LIBRARY ClearInformationArea
354 stc
355 ret
356
357
358;--------------------------------------------------------------------
359; BootMenuPrint_ClearScreen
360; Parameters:
361; Nothing
362; Returns:
363; Nothing
364; Corrupts registers:
365; AX, DI
366;--------------------------------------------------------------------
367ALIGN JUMP_ALIGN
368BootMenuPrint_ClearScreen:
369 call BootMenuPrint_InitializeDisplayContext
370 xor ax, ax
371 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
372 mov ax, ' ' | (MONO_NORMAL<<8)
373 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
374 ret
375
376
377;--------------------------------------------------------------------
378; PrintDriveNumberAfterTranslationFromDL
379; Parameters:
380; DL: Untranslated Floppy Drive number
381; DS: RAMVARS segment
382; Returns:
383; Nothing
384; Corrupts registers:
385; AX, DI
386;--------------------------------------------------------------------
387ALIGN JUMP_ALIGN
388PrintDriveNumberAfterTranslationFromDL:
389 mov ax, dx
390 call DriveXlate_ToOrBack
391 xchg dx, ax ; Restore DX, WORD to print in AL
392 xor ah, ah
393 push bp
394 mov bp, sp
395 mov si, g_szDriveNum
396 push ax
397
398BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
399 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
400
401
402;--------------------------------------------------------------------
403; BootMenuPrint_TheBottomOfScreen
404; Parameters:
405; DS: RAMVARS segment
406; Returns:
407; Nothing
408; Corrupts registers:
409; AX, BX, CX, DX, SI, DI
410;--------------------------------------------------------------------
411ALIGN JUMP_ALIGN
412BootMenuPrint_TheBottomOfScreen:
413 call FloppyDrive_GetCountToCX
414 mov bl, cl ; Floppy Drive count to BL
415 call RamVars_GetHardDiskCountFromBDAtoCX
416 mov bh, cl ; Hard Disk count to BH
417 ; Fall to .MoveCursorToHotkeyStrings
418
419;--------------------------------------------------------------------
420; .MoveCursorToHotkeyStrings
421; Parameters:
422; Nothing
423; Returns:
424; Nothing
425; Corrupts registers:
426; AX, DI
427;--------------------------------------------------------------------
428.MoveCursorToHotkeyStrings:
429 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
430 xor al, al
431 dec ah
432 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
433 ; Fall to .PrintHotkeyString
434
435;--------------------------------------------------------------------
436; .PrintHotkeyString
437; Parameters:
438; BL: Floppy Drives
439; BH: Hard Drives
440; Returns:
441; Nothing
442; Corrupts registers:
443; AX, CX, DX, SI, DI
444;--------------------------------------------------------------------
445.PrintHotkeyString:
446 ; Display Library should not be called like this
447 mov si, ATTRIBUTE_CHARS.cHighlightedItem
448 call MenuAttribute_GetToAXfromTypeInSI
449 xchg dx, ax
450 mov cx, MONO_BRIGHT
451
452 test bl, bl ; Any Floppy Drives?
453 jz SHORT .SkipFloppyDriveHotkeys
454 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
455 mov si, g_szFDD
456 call PushHotkeyParamsAndFormat
457
458.SkipFloppyDriveHotkeys:
459 test bh, bh ; Any Hard Drives?
460 jz SHORT .SkipHardDriveHotkeys
461 xchg ax, cx ; Store Key Attribute
462 call BootMenu_GetLetterForFirstHardDiskToCL
463 mov ch, ANGLE_QUOTE_RIGHT
464 xchg ax, cx
465 mov si, g_szHDD
466 call PushHotkeyParamsAndFormat
467
468.SkipHardDriveHotkeys:
469 ; Fall to .PrintRomBootHotkey
470
471;--------------------------------------------------------------------
472; .PrintRomBootHotkey
473; Parameters:
474; CX: Key Attribute
475; DX: Description Attribute
476; Returns:
477; Nothing
478; Corrupts registers:
479; AX, SI, DI
480;--------------------------------------------------------------------
481.PrintRomBootHotkey:
482 mov ax, 'F' | ('8'<<8) ; F8
483 mov si, g_szRomBoot
484 ; Fall to PushHotkeyParamsAndFormat
485
486;--------------------------------------------------------------------
487; PushHotkeyParamsAndFormat
488; Parameters:
489; AL: First character
490; AH: Second character
491; CX: Key Attribute
492; DX: Description Attribute
493; CS:SI: Description string
494; Returns:
495; Nothing
496; Corrupts registers:
497; AX, SI, DI
498;--------------------------------------------------------------------
499ALIGN JUMP_ALIGN
500PushHotkeyParamsAndFormat:
501 push bp
502 mov bp, sp
503
504 push cx ; Key attribute
505 push ax ; First character
506 xchg al, ah
507 push ax ; Second character
508 push dx ; Description attribute
509 push si ; Description string
510 push cx ; Key attribute for last space
511 mov si, g_szHotkey
512 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
513
514
515;--------------------------------------------------------------------
516; BootMenuPrint_InitializeDisplayContext
517; Parameters:
518; Nothing
519; Returns:
520; Nothing
521; Corrupts registers:
522; AX, DI
523;--------------------------------------------------------------------
524ALIGN JUMP_ALIGN
525BootMenuPrint_InitializeDisplayContext:
526 CALL_DISPLAY_LIBRARY InitializeDisplayContext
527 ret
528
529
530
531
532
533
Note: See TracBrowser for help on using the repository browser.