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

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

Changes to XTIDE Universal BIOS:

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