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

Last change on this file since 90 was 88, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Now uses new libraries (untested)
  • Non-working since code size is too large
File size: 15.0 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; Prints Boot Menu title strings.
9;
10; BootMenuPrint_TitleStrings
11; Parameters:
12; Nothing
13; Returns:
14; CF: Set since menu event handled
15; Corrupts registers:
16; AX, SI, DI
17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19BootMenuPrint_TitleStrings:
20 mov si, ROMVARS.szTitle
21 call PrintNullTerminatedStringFromCSSIandSetCF
22 call BootMenuPrint_Newline
23 mov si, ROMVARS.szVersion
24 jmp PrintNullTerminatedStringFromCSSIandSetCF
25
26
27;--------------------------------------------------------------------
28; BootMenuPrint_Newline
29; Parameters:
30; Nothing
31; Returns:
32; Nothing
33; Corrupts registers:
34; AX, DI
35;--------------------------------------------------------------------
36ALIGN JUMP_ALIGN
37BootMenuPrint_Newline:
38 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
39 ret
40
41
42;--------------------------------------------------------------------
43; Prints Floppy Drive hotkey string.
44;
45; BootMenuPrint_FloppyHotkeyString
46; Parameters:
47; BL: Number of floppy drives in system
48; Returns:
49; Nothing
50; Corrupts registers:
51; AX, SI
52;--------------------------------------------------------------------
53ALIGN JUMP_ALIGN
54BootMenuPrint_FloppyHotkeyString:
55 test bl, bl ; Any floppy drives?
56 jz SHORT NoFloppyDrivesOrHardDisksToPrint
57 push bp
58
59 mov bp, sp
60 mov al, 'A'
61 push ax ; 'A'
62 dec ax
63 add al, bl
64 push ax ; Last floppy drive letter
65 ePUSH_T ax, g_szFDD
66 ePUSH_T ax, g_szHDD
67 jmp SHORT PrintHotkeyString
68
69;--------------------------------------------------------------------
70; Prints Hard Disk hotkey string.
71;
72; BootMenuPrint_FloppyHotkeyString
73; Parameters:
74; BH: Number of hard disks in system
75; Returns:
76; Nothing
77; Corrupts registers:
78; AX, CX, SI
79;--------------------------------------------------------------------
80ALIGN JUMP_ALIGN
81BootMenuPrint_HardDiskHotkeyString:
82 test bh, bh ; Any hard disks?
83 jz SHORT NoFloppyDrivesOrHardDisksToPrint
84 push bp
85
86 mov bp, sp
87 call BootMenu_GetLetterForFirstHardDisk
88 push cx ; First hard disk letter
89 dec cx
90 add cl, bh
91 push cx ; Last hard disk letter
92 ePUSH_T ax, g_szHDD
93 ePUSH_T ax, g_szFDD
94 ; Fall to PrintHotkeyString
95
96ALIGN JUMP_ALIGN
97PrintHotkeyString:
98 mov si, g_szBottomScrn
99 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
100NoFloppyDrivesOrHardDisksToPrint:
101 ret
102
103;--------------------------------------------------------------------
104; BootMenuPrint_ClearScreen
105; Parameters:
106; Nothing
107; Returns:
108; Nothing
109; Corrupts registers:
110; AX
111;--------------------------------------------------------------------
112ALIGN JUMP_ALIGN
113BootMenuPrint_ClearScreen:
114 push di
115 mov ax, ' ' | (MONO_NORMAL<<8)
116 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
117 pop di
118 ret
119
120
121;--------------------------------------------------------------------
122; Translates and prints drive number.
123;
124; BootMenuPrint_TranslatedDriveNumber
125; Parameters:
126; DL: Untranslated drive number
127; DS: RAMVARS segment
128; Returns:
129; Nothing
130; Corrupts registers:
131; AX, DI
132;--------------------------------------------------------------------
133ALIGN JUMP_ALIGN
134BootMenuPrint_TranslatedDriveNumber:
135 push dx
136 push bx
137
138 call DriveXlate_ToOrBack
139 eMOVZX ax, dl ; Drive number to AL
140 CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
141 mov al, ' ' ; Print space
142 CALL_DISPLAY_LIBRARY PrintCharacterFromAL
143
144 pop bx
145 pop dx
146 ret
147
148
149;--------------------------------------------------------------------
150; BootMenuPrint_FloppyMenuitem
151; Parameters:
152; DL: Untranslated Floppy Drive number
153; Returns:
154; Nothing
155; Corrupts registers:
156; AX, DX, SI
157;--------------------------------------------------------------------
158ALIGN JUMP_ALIGN
159BootMenuPrint_FloppyMenuitem:
160 push bp
161
162 mov bp, sp
163 mov si, g_szFDLetter
164 ePUSH_T ax, g_szFloppyDrv
165 add dl, 'A'
166 push dx ; Drive letter
167 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
168
169
170;--------------------------------------------------------------------
171; BootMenuPrint_HardDiskMenuitem
172; Parameters:
173; DL: Untranslated Hard Disk number
174; DS: RAMVARS segment
175; Returns:
176; CF: Set since menu event handled
177; Corrupts registers:
178; AX, BX, SI, DI
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181BootMenuPrint_HardDiskMenuitem:
182 call FindDPT_ForDriveNumber ; DS:DI to point DPT
183 jnc SHORT .HardDiskMenuitemForForeignDrive
184 ; Fall to .HardDiskMenuitemForOurDrive
185
186;--------------------------------------------------------------------
187; .HardDiskMenuitemForOurDrive
188; Parameters:
189; DL: Untranslated Hard Disk number
190; DS: RAMVARS segment
191; Returns:
192; CF: Set since menu event handled
193; Corrupts registers:
194; AX, BX, SI, DI
195;--------------------------------------------------------------------
196;ALIGN JUMP_ALIGN
197.HardDiskMenuitemForOurDrive:
198 call BootInfo_GetOffsetToBX
199 lea si, [bx+BOOTNFO.szDrvName]
200 xor bx, bx ; BDA segment
201 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
202 stc
203 ret
204
205;--------------------------------------------------------------------
206; BootMenuPrint_HardDiskMenuitemForForeignDrive
207; Parameters:
208; DL: Untranslated Hard Disk number
209; DS: RAMVARS segment
210; Returns:
211; CF: Set since menu event handled
212; Corrupts registers:
213; AX, SI, DI
214;--------------------------------------------------------------------
215ALIGN JUMP_ALIGN
216.HardDiskMenuitemForForeignDrive:
217 mov si, g_szforeignHD
218 jmp PrintNullTerminatedStringFromCSSIandSetCF
219
220
221;--------------------------------------------------------------------
222; BootMenuPrint_FunctionMenuitem
223; Parameters:
224; DX: Function ID
225; Returns:
226; CF: Set if menu event was handled successfully
227; Corrupts registers:
228; AX, DX, SI, DI
229;--------------------------------------------------------------------
230ALIGN JUMP_ALIGN
231BootMenuPrint_FunctionMenuitem:
232 test dx, dx ; ID_BOOTFUNC_ROMBOOT
233 jz SHORT .PrintRomBootMenuitem
234 ret
235
236ALIGN JUMP_ALIGN
237.PrintRomBootMenuitem:
238 mov si, g_szRomBoot
239 jmp PrintNullTerminatedStringFromCSSIandSetCF
240
241
242;--------------------------------------------------------------------
243; BootMenuPrint_FloppyMenuitemInformation
244; Parameters:
245; DL: Untranslated Floppy Drive number
246; DS: RAMVARS segment
247; Returns:
248; CF: Set since menu event was handled successfully
249; Corrupts registers:
250; AX, BX, CX, DX, SI, DI, ES
251;--------------------------------------------------------------------
252ALIGN JUMP_ALIGN
253BootMenuPrint_FloppyMenuitemInformation:
254 call BootMenuPrint_ClearInformationArea
255 call FloppyDrive_GetType ; Get Floppy Drive type to BX
256 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
257 jz SHORT .PrintXTFloppyType
258 cmp bl, FLOPPY_TYPE_35_ED
259 ja SHORT .PrintUnknownFloppyType
260 jmp SHORT .PrintKnownFloppyType
261
262;--------------------------------------------------------------------
263; .PrintXTFloppyType
264; Parameters:
265; Nothing
266; Returns:
267; CF: Set since menu event was handled successfully
268; Corrupts registers:
269; AX, SI, DI
270;--------------------------------------------------------------------
271ALIGN JUMP_ALIGN
272.PrintXTFloppyType:
273 push bp
274 mov si, g_szFddSizeOr
275 jmp SHORT .FormatXTorUnknownTypeFloppyDrive
276
277;--------------------------------------------------------------------
278; .PrintUnknownFloppyType
279; Parameters:
280; Nothing
281; Returns:
282; CF: Set since menu event was handled successfully
283; Corrupts registers:
284; AX, SI, DI
285;--------------------------------------------------------------------
286ALIGN JUMP_ALIGN
287.PrintUnknownFloppyType:
288 push bp
289 mov si, g_szFddUnknown
290.FormatXTorUnknownTypeFloppyDrive:
291 mov bp, sp
292 ePUSH_T ax, g_szCapacity
293 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
294
295;--------------------------------------------------------------------
296; .PrintKnownFloppyType
297; Parameters:
298; BX: Floppy drive type
299; Returns:
300; CF: Set since menu event was handled successfully
301; Corrupts registers:
302; AX, BX, SI, DI
303;--------------------------------------------------------------------
304ALIGN JUMP_ALIGN
305.PrintKnownFloppyType:
306 push bp
307
308 mov bp, sp
309 mov si, g_szFddSize
310 ePUSH_T ax, g_szCapacity
311 dec bx ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
312 shl bx, 1 ; Shift for WORD lookup
313 mov ax, [cs:bx+.rgwPhysicalSize]
314 push ax ; '5' or '3'
315 mov al, ah
316 push ax ; '1/4' or '1/2'
317 push WORD [cs:bx+.rgwCapacity]
318 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
319
320ALIGN WORD_ALIGN
321.rgwCapacity:
322 dw 360
323 dw 1200
324 dw 720
325 dw 1440
326 dw 2880
327 dw 2880
328.rgwPhysicalSize:
329 db '5', 172 ; 1, FLOPPY_TYPE_525_DD
330 db '5', 172 ; 2, FLOPPY_TYPE_525_HD
331 db '3', 171 ; 3, FLOPPY_TYPE_35_DD
332 db '3', 171 ; 4, FLOPPY_TYPE_35_HD
333 db '3', 171 ; 5, 3.5" ED on some BIOSes
334 db '3', 171 ; 6, FLOPPY_TYPE_35_ED
335
336
337;--------------------------------------------------------------------
338; Prints Hard Disk Menuitem information strings.
339;
340; BootMenuPrint_HardDiskMenuitemInformation
341; Parameters:
342; DL: Untranslated Hard Disk number
343; DS: RAMVARS segment
344; Returns:
345; CF: Set since menu event was handled successfully
346; Corrupts registers:
347; BX, CX, DX, SI, DI, ES
348;--------------------------------------------------------------------
349ALIGN JUMP_ALIGN
350BootMenuPrint_HardDiskMenuitemInformation:
351 call FindDPT_ForDriveNumber ; DS:DI to point DPT
352 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
353 call .HardDiskMenuitemInfoSizeForOurDrive
354 jmp BootMenuPrintCfg_ForOurDrive
355
356;--------------------------------------------------------------------
357; .HardDiskMenuitemInfoForForeignDrive
358; Parameters:
359; DL: Untranslated Hard Disk number
360; DS: RAMVARS segment
361; Returns:
362; CF: Set since menu event was handled successfully
363; Corrupts registers:
364; AX, BX, CX, DX, SI, DI
365;--------------------------------------------------------------------
366ALIGN JUMP_ALIGN
367.HardDiskMenuitemInfoForForeignDrive:
368 push bp
369 mov bp, sp
370 ePUSH_T ax, g_szCapacity
371
372 call DriveXlate_ToOrBack
373 call HCapacity_GetSectorCountFromForeignAH08h
374 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
375
376 mov si, g_szSizeSingle
377 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
378
379;--------------------------------------------------------------------
380; .HardDiskMenuitemInfoSizeForOurDrive
381; Parameters:
382; DL: Untranslated Hard Disk number
383; DS:DI: Ptr to DPT
384; Returns:
385; Nothing
386; Corrupts registers:
387; AX, BX, CX, DX, SI, ES
388;--------------------------------------------------------------------
389ALIGN JUMP_ALIGN
390.HardDiskMenuitemInfoSizeForOurDrive:
391 push bp
392 mov bp, sp
393 ePUSH_T ax, g_szCapacity
394
395 ; Get and push L-CHS size
396 call HCapacity_GetSectorCountFromOurAH08h
397 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
398
399 ; Get and push total LBA size
400 call BootInfo_GetTotalSectorCount
401 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
402
403 mov si, g_szSizeDual
404 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
405
406
407;--------------------------------------------------------------------
408; BootMenuPrint_FormatCSSIfromParamsInSSBP
409; Parameters:
410; CS:SI: Ptr to string to format
411; SS:BP: Ptr to format parameters
412; Returns:
413; BP: Popped from stack
414; Corrupts registers:
415; AX
416;--------------------------------------------------------------------
417ALIGN JUMP_ALIGN
418BootMenuPrint_FormatCSSIfromParamsInSSBP:
419 push di
420 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
421 stc ; Successfull return from menu event
422 pop di
423 pop bp
424 ret
425
426
427;--------------------------------------------------------------------
428; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
429; Parameters:
430; BX:DX:AX: Sector count
431; Returns:
432; Size in stack
433; Corrupts registers:
434; AX, BX, CX, DX, SI
435;--------------------------------------------------------------------
436ALIGN JUMP_ALIGN
437ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
438 pop si ; Pop return address
439 call Size_ConvertSectorCountInBXDXAXtoKiB
440 mov cx, BYTE_MULTIPLES.kiB
441 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
442 push ax ; Size in magnitude
443 push cx ; Tenths
444 push dx ; Magnitude character
445 jmp si
446
447
448;--------------------------------------------------------------------
449; PrintNullTerminatedStringFromCSSIandSetCF
450; Parameters:
451; CS:SI: Ptr to NULL terminated string to print
452; Returns:
453; CF: Set since menu event was handled successfully
454; Corrupts registers:
455; AX, DI
456;--------------------------------------------------------------------
457ALIGN JUMP_ALIGN
458PrintNullTerminatedStringFromCSSIandSetCF:
459 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
460 stc
461 ret
462
463
464;--------------------------------------------------------------------
465; BootMenuPrint_ClearInformationArea
466; Parameters:
467; Nothing
468; Returns:
469; CF: Set
470; Corrupts registers:
471; AX, DI
472;--------------------------------------------------------------------
473ALIGN JUMP_ALIGN
474BootMenuPrint_ClearInformationArea:
475 CALL_MENU_LIBRARY ClearInformationArea
476 stc
477 ret
478
479
480;--------------------------------------------------------------------
481; Prints information strings to the bottom of the screen.
482;
483; BootMenuPrint_TheBottomOfScreen
484; Parameters:
485; DS: RAMVARS segment
486; Returns:
487; Nothing
488; Corrupts registers:
489; AX, BX, CX, DX, SI
490;--------------------------------------------------------------------
491ALIGN JUMP_ALIGN
492BootMenuPrint_TheBottomOfScreen:
493 call FloppyDrive_GetCount
494 mov bl, cl ; Floppy Drive count to BL
495 call RamVars_GetHardDiskCountFromBDAtoCX
496 mov bh, cl ; Hard Disk count to BH
497 call BootMenuPrint_GetCoordinatesForBottomStrings
498 call BootMenuPrint_SetCursorPosition
499 call BootMenuPrint_FloppyHotkeyString
500 jmp BootMenuPrint_HardDiskHotkeyString
501
502
503;--------------------------------------------------------------------
504; Returns coordinates for bottom strings.
505;
506; BootMenuPrint_GetCoordinatesForBottomStrings
507; Parameters:
508; BL: Number of floppy drives in system
509; BH: Number of hard disks in system
510; Returns:
511; DL: Cursor X coordinate
512; DH: Cursor Y coordinate
513; Corrupts registers:
514; Nothing
515;--------------------------------------------------------------------
516ALIGN JUMP_ALIGN
517BootMenuPrint_GetCoordinatesForBottomStrings:
518 mov dx, 1800h ; (0, 24)
519 cmp dl, bl ; Set CF if any floppy drives
520 sbb dh, dl ; Decrement Y-coordinate if necessary
521 cmp dl, bh ; Set CF if any hard disks
522 sbb dh, dl ; Decrement Y-coordinate if necessary
523 ret
524
525
526;--------------------------------------------------------------------
527; Sets cursor to wanted screen coordinates.
528;
529; BootMenuPrint_SetCursorPosition
530; Parameters:
531; DL: Cursor X coordinate
532; DH: Cursor Y coordinate
533; Returns:
534; Nothing
535; Corrupts registers:
536; AX
537;--------------------------------------------------------------------
538ALIGN JUMP_ALIGN
539BootMenuPrint_SetCursorPosition:
540 push di
541 mov ax, dx
542 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
543 pop di
544 ret
Note: See TracBrowser for help on using the repository browser.