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

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

Changes to XTIDE Universal BIOS:

  • Boot menu now displays drive number (untested)
  • Timeout counter implemented to boot menu (untested)
File size: 14.3 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 through 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
69;--------------------------------------------------------------------
70ALIGN JUMP_ALIGN
71BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
72 push di
73 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
74 pop di
75 stc
76 ret
77
78
79;--------------------------------------------------------------------
80; BootMenuPrint_FloppyMenuitem
81; Parameters:
82; DL: Untranslated Floppy Drive number
83; Returns:
84; Nothing
85; Corrupts registers:
86; AX, DX, SI, DI
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89BootMenuPrint_FloppyMenuitem:
90 call PrintDriveNumberAfterTranslationFromDL
91 push bp
92 mov bp, sp
93 mov si, g_szFDLetter
94 ePUSH_T ax, g_szFloppyDrv
95 add dl, 'A'
96 push dx ; Drive letter
97 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
98
99
100;--------------------------------------------------------------------
101; BootMenuPrint_HardDiskMenuitem
102; Parameters:
103; DL: Untranslated Hard Disk number
104; DS: RAMVARS segment
105; Returns:
106; CF: Set since menu event handled
107; Corrupts registers:
108; AX, BX, SI, DI
109;--------------------------------------------------------------------
110ALIGN JUMP_ALIGN
111BootMenuPrint_HardDiskMenuitem:
112 call PrintDriveNumberAfterTranslationFromDL
113 call FindDPT_ForDriveNumber ; DS:DI to point DPT
114 jnc SHORT .HardDiskMenuitemForForeignDrive
115 ; Fall to .HardDiskMenuitemForOurDrive
116
117;--------------------------------------------------------------------
118; .HardDiskMenuitemForOurDrive
119; Parameters:
120; DL: Untranslated Hard Disk number
121; DS: RAMVARS segment
122; Returns:
123; CF: Set since menu event handled
124; Corrupts registers:
125; AX, BX, SI, DI
126;--------------------------------------------------------------------
127.HardDiskMenuitemForOurDrive:
128 call BootInfo_GetOffsetToBX
129 lea si, [bx+BOOTNFO.szDrvName]
130 xor bx, bx ; BDA segment
131 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
132 stc
133 ret
134
135;--------------------------------------------------------------------
136; BootMenuPrint_HardDiskMenuitemForForeignDrive
137; Parameters:
138; DL: Untranslated Hard Disk number
139; DS: RAMVARS segment
140; Returns:
141; CF: Set since menu event handled
142; Corrupts registers:
143; AX, SI, DI
144;--------------------------------------------------------------------
145ALIGN JUMP_ALIGN
146.HardDiskMenuitemForForeignDrive:
147 mov si, g_szforeignHD
148 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
149
150
151;--------------------------------------------------------------------
152; PrintDriveNumberAfterTranslationFromDL
153; Parameters:
154; DL: Untranslated Floppy Drive number
155; DS: RAMVARS segment
156; Returns:
157; Nothing
158; Corrupts registers:
159; AX, DI
160;--------------------------------------------------------------------
161ALIGN JUMP_ALIGN
162PrintDriveNumberAfterTranslationFromDL:
163 mov ax, dx
164 call DriveXlate_ToOrBack
165 xchg dx, ax ; Restore DX, WORD to print in AL
166 xor ah, ah
167 push bp
168 mov bp, sp
169 mov si, g_szDriveNum
170 push ax
171 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
172
173
174;--------------------------------------------------------------------
175; BootMenuPrint_FloppyMenuitemInformation
176; Parameters:
177; DL: Untranslated Floppy Drive number
178; DS: RAMVARS segment
179; Returns:
180; CF: Set since menu event was handled successfully
181; Corrupts registers:
182; AX, BX, CX, DX, SI, DI, ES
183;--------------------------------------------------------------------
184ALIGN JUMP_ALIGN
185BootMenuPrint_FloppyMenuitemInformation:
186 call BootMenuPrint_ClearInformationArea
187 call FloppyDrive_GetType ; Get Floppy Drive type to BX
188 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
189 jz SHORT .PrintXTFloppyType
190 cmp bl, FLOPPY_TYPE_35_ED
191 ja SHORT .PrintUnknownFloppyType
192 jmp SHORT .PrintKnownFloppyType
193
194;--------------------------------------------------------------------
195; .PrintXTFloppyType
196; Parameters:
197; Nothing
198; Returns:
199; CF: Set since menu event was handled successfully
200; Corrupts registers:
201; AX, SI, DI
202;--------------------------------------------------------------------
203ALIGN JUMP_ALIGN
204.PrintXTFloppyType:
205 push bp
206 mov si, g_szFddSizeOr
207 jmp SHORT .FormatXTorUnknownTypeFloppyDrive
208
209;--------------------------------------------------------------------
210; .PrintUnknownFloppyType
211; Parameters:
212; Nothing
213; Returns:
214; CF: Set since menu event was handled successfully
215; Corrupts registers:
216; AX, SI, DI
217;--------------------------------------------------------------------
218ALIGN JUMP_ALIGN
219.PrintUnknownFloppyType:
220 push bp
221 mov si, g_szFddUnknown
222.FormatXTorUnknownTypeFloppyDrive:
223 mov bp, sp
224 ePUSH_T ax, g_szCapacity
225 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
226
227;--------------------------------------------------------------------
228; .PrintKnownFloppyType
229; Parameters:
230; BX: Floppy drive type
231; Returns:
232; CF: Set since menu event was handled successfully
233; Corrupts registers:
234; AX, BX, SI, DI
235;--------------------------------------------------------------------
236ALIGN JUMP_ALIGN
237.PrintKnownFloppyType:
238 push bp
239 mov bp, sp
240 mov si, g_szFddSize
241 ePUSH_T ax, g_szCapacity
242 dec bx ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
243 shl bx, 1 ; Shift for WORD lookup
244 mov ax, [cs:bx+.rgwPhysicalSize]
245 push ax ; '5' or '3'
246 mov al, ah
247 push ax ; '1/4' or '1/2'
248 push WORD [cs:bx+.rgwCapacity]
249 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
250
251ALIGN WORD_ALIGN
252.rgwCapacity:
253 dw 360
254 dw 1200
255 dw 720
256 dw 1440
257 dw 2880
258 dw 2880
259.rgwPhysicalSize:
260 db '5', 172 ; 1, FLOPPY_TYPE_525_DD
261 db '5', 172 ; 2, FLOPPY_TYPE_525_HD
262 db '3', 171 ; 3, FLOPPY_TYPE_35_DD
263 db '3', 171 ; 4, FLOPPY_TYPE_35_HD
264 db '3', 171 ; 5, 3.5" ED on some BIOSes
265 db '3', 171 ; 6, FLOPPY_TYPE_35_ED
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 FindDPT_ForDriveNumber ; DS:DI to point DPT
283 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
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;--------------------------------------------------------------------
296ALIGN JUMP_ALIGN
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 call HCapacity_GetSectorCountFromOurAH08h
306 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
307
308 ; Get and push total LBA size
309 mov dl, [di+DPT.bDrvNum]
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 HCapacity_GetSectorCountFromForeignAH08h
335 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
336
337 mov si, g_szSizeSingle
338 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
339
340
341;--------------------------------------------------------------------
342; BootMenuPrint_FormatCSSIfromParamsInSSBP
343; Parameters:
344; CS:SI: Ptr to string to format
345; BP: SP before pushing parameters
346; Returns:
347; BP: Popped from stack
348; Corrupts registers:
349; AX, DI
350;--------------------------------------------------------------------
351ALIGN JUMP_ALIGN
352BootMenuPrint_FormatCSSIfromParamsInSSBP:
353 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
354 stc ; Successfull return from menu event
355 pop bp
356 ret
357
358
359;--------------------------------------------------------------------
360; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
361; Parameters:
362; BX:DX:AX: Sector count
363; Returns:
364; Size in stack
365; Corrupts registers:
366; AX, BX, CX, DX, SI
367;--------------------------------------------------------------------
368ALIGN JUMP_ALIGN
369ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
370 pop si ; Pop return address
371 call Size_ConvertSectorCountInBXDXAXtoKiB
372 mov cx, BYTE_MULTIPLES.kiB
373 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
374 push ax ; Size in magnitude
375 push cx ; Tenths
376 push dx ; Magnitude character
377 jmp si
378
379
380;--------------------------------------------------------------------
381; BootMenuPrint_ClearInformationArea
382; Parameters:
383; Nothing
384; Returns:
385; CF: Set
386; Corrupts registers:
387; AX, DI
388;--------------------------------------------------------------------
389ALIGN JUMP_ALIGN
390BootMenuPrint_ClearInformationArea:
391 CALL_MENU_LIBRARY ClearInformationArea
392 stc
393 ret
394
395
396;--------------------------------------------------------------------
397; BootMenuPrint_TheBottomOfScreen
398; Parameters:
399; DS: RAMVARS segment
400; Returns:
401; Nothing
402; Corrupts registers:
403; AX, BX, CX, DX, SI, DI
404;--------------------------------------------------------------------
405ALIGN JUMP_ALIGN
406BootMenuPrint_TheBottomOfScreen:
407 call FloppyDrive_GetCountToCX
408 mov bl, cl ; Floppy Drive count to BL
409 call RamVars_GetHardDiskCountFromBDAtoCX
410 mov bh, cl ; Hard Disk count to BH
411 ; Fall to .MoveCursorToHotkeyStrings
412
413;--------------------------------------------------------------------
414; .MoveCursorToHotkeyStrings
415; Parameters:
416; Nothing
417; Returns:
418; Nothing
419; Corrupts registers:
420; AX, DI
421;--------------------------------------------------------------------
422.MoveCursorToHotkeyStrings:
423 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
424 xor al, al
425 dec ah
426 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
427 ; Fall to .PrintHotkeyString
428
429;--------------------------------------------------------------------
430; .PrintHotkeyString
431; Parameters:
432; BL: Floppy Drives
433; BH: Hard Drives
434; Returns:
435; Nothing
436; Corrupts registers:
437; AX, CX, DX, SI, DI
438;--------------------------------------------------------------------
439.PrintHotkeyString:
440 ; Display Library should not be called like this
441 mov si, ATTRIBUTE_CHARS.cHighlightedItem
442 call MenuAttribute_GetToAXfromTypeInSI
443 xchg dx, ax
444 mov cx, MONO_BRIGHT
445
446 test bl, bl ; Any Floppy Drives?
447 jz SHORT .SkipFloppyDriveHotkeys
448 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
449 mov si, g_szFDD
450 call PushHotkeyParamsAndFormat
451
452.SkipFloppyDriveHotkeys:
453 test bh, bh ; Any Hard Drives?
454 jz SHORT .SkipHardDriveHotkeys
455 xchg ax, cx ; Store Key Attribute
456 call BootMenu_GetLetterForFirstHardDiskToCL
457 mov ch, ANGLE_QUOTE_RIGHT
458 xchg ax, cx
459 mov si, g_szHDD
460 call PushHotkeyParamsAndFormat
461
462.SkipHardDriveHotkeys:
463 ; Fall to .PrintRomBootHotkey
464
465;--------------------------------------------------------------------
466; .PrintRomBootHotkey
467; Parameters:
468; CX: Key Attribute
469; DX: Description Attribute
470; Returns:
471; Nothing
472; Corrupts registers:
473; AX, SI, DI
474;--------------------------------------------------------------------
475.PrintRomBootHotkey:
476 mov ax, 'F' | ('8'<<8) ; F8
477 mov si, g_szRomBoot
478 ; Fall to PushHotkeyParamsAndFormat
479
480;--------------------------------------------------------------------
481; PushHotkeyParamsAndFormat
482; Parameters:
483; AL: First character
484; AH: Second character
485; CX: Key Attribute
486; DX: Description Attribute
487; CS:SI: Description string
488; Returns:
489; Nothing
490; Corrupts registers:
491; AX, SI, DI
492;--------------------------------------------------------------------
493ALIGN JUMP_ALIGN
494PushHotkeyParamsAndFormat:
495 push bp
496 mov bp, sp
497
498 push cx ; Key attribute
499 push ax ; First character
500 xchg al, ah
501 push ax ; Second character
502 push dx ; Description attribute
503 push si ; Description string
504 push cx ; Key attribute for last space
505 mov si, g_szHotkey
506 jmp BootMenuPrint_FormatCSSIfromParamsInSSBP
Note: See TracBrowser for help on using the repository browser.