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

Last change on this file since 161 was 161, checked in by krille_n_@…, 14 years ago

Changes to XTIDE Universal BIOS:

  • Minor size optimizations.
  • Tried to minimize the time spent with interrupts disabled in IdeIrq.asm and Int13h.asm
File size: 14.2 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 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 RamVars_IsDriveHandledByThisBIOS
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 SHORT 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 push bp
190 mov bp, sp
191 jz SHORT .PrintXTFloppyType
192 cmp bl, FLOPPY_TYPE_35_ED
193 ja SHORT .PrintUnknownFloppyType
194 ; Fall to .PrintKnownFloppyType
195
196
197;--------------------------------------------------------------------
198; .PrintKnownFloppyType
199; Parameters:
200; BX: Floppy drive type
201; Returns:
202; CF: Set since menu event was handled successfully
203; Corrupts registers:
204; AX, BX, SI, DI
205;--------------------------------------------------------------------
206ALIGN JUMP_ALIGN
207.PrintKnownFloppyType:
208 mov si, g_szFddSize
209 ePUSH_T ax, g_szCapacity
210 dec bx ; Cannot be 0 (FLOPPY_TYPE_525_OR_35_DD)
211 shl bx, 1 ; Shift for WORD lookup
212 mov ax, [cs:bx+FloppyTypes.rgwPhysicalSize]
213 push ax ; '5' or '3'
214 mov al, ah
215 push ax ; '1/4' or '1/2'
216 push WORD [cs:bx+FloppyTypes.rgwCapacity]
217 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
218
219
220;--------------------------------------------------------------------
221; .PrintXTFloppyType
222; .PrintUnknownFloppyType
223; Parameters:
224; Nothing
225; Returns:
226; CF: Set since menu event was handled successfully
227; Corrupts registers:
228; AX, SI, DI
229;--------------------------------------------------------------------
230ALIGN JUMP_ALIGN
231.PrintXTFloppyType:
232 mov si, g_szFddSizeOr
233 jmp SHORT .FormatXTorUnknownTypeFloppyDrive
234ALIGN JUMP_ALIGN
235.PrintUnknownFloppyType:
236 mov si, g_szFddUnknown
237.FormatXTorUnknownTypeFloppyDrive:
238 ePUSH_T ax, g_szCapacity
239 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
240
241
242;--------------------------------------------------------------------
243; Prints Hard Disk Menuitem information strings.
244;
245; BootMenuPrint_HardDiskMenuitemInformation
246; Parameters:
247; DL: Untranslated Hard Disk number
248; DS: RAMVARS segment
249; Returns:
250; CF: Set since menu event was handled successfully
251; Corrupts registers:
252; BX, CX, DX, SI, DI, ES
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255BootMenuPrint_HardDiskMenuitemInformation:
256 call RamVars_IsDriveHandledByThisBIOS
257 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
258 call FindDPT_ForDriveNumber ; DS:DI to point DPT
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 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
281 call AH15h_GetSectorCountToDXAX
282 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
283
284 ; Get and push total LBA size
285 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
286 call BootInfo_GetTotalSectorCount
287 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
288
289 mov si, g_szSizeDual
290 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
291
292
293;--------------------------------------------------------------------
294; .HardDiskMenuitemInfoForForeignDrive
295; Parameters:
296; DL: Untranslated Hard Disk number
297; DS: RAMVARS segment
298; Returns:
299; CF: Set since menu event was handled successfully
300; Corrupts registers:
301; AX, BX, CX, DX, SI, DI
302;--------------------------------------------------------------------
303ALIGN JUMP_ALIGN
304.HardDiskMenuitemInfoForForeignDrive:
305 push bp
306 mov bp, sp
307 ePUSH_T ax, g_szCapacity
308
309 call DriveXlate_ToOrBack
310 call AH15h_GetSectorCountFromForeignDriveToDXAX
311 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
312
313 mov si, g_szSizeSingle
314 ; Fall to BootMenuPrint_FormatCSSIfromParamsInSSBP
315
316
317;--------------------------------------------------------------------
318; BootMenuPrint_FormatCSSIfromParamsInSSBP
319; Parameters:
320; CS:SI: Ptr to string to format
321; BP: SP before pushing parameters
322; Returns:
323; BP: Popped from stack
324; Corrupts registers:
325; AX, DI
326;--------------------------------------------------------------------
327ALIGN JUMP_ALIGN
328BootMenuPrint_FormatCSSIfromParamsInSSBP:
329 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
330 stc ; Successfull return from menu event
331 pop bp
332 ret
333
334
335;--------------------------------------------------------------------
336; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
337; Parameters:
338; BX:DX:AX: Sector count
339; Returns:
340; Size in stack
341; Corrupts registers:
342; AX, BX, CX, DX, SI
343;--------------------------------------------------------------------
344ALIGN JUMP_ALIGN
345ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
346 pop si ; Pop return address
347 call Size_ConvertSectorCountInBXDXAXtoKiB
348 mov cx, BYTE_MULTIPLES.kiB
349 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
350 push ax ; Size in magnitude
351 push cx ; Tenths
352 push dx ; Magnitude character
353 jmp si
354
355
356;--------------------------------------------------------------------
357; BootMenuPrint_ClearInformationArea
358; Parameters:
359; Nothing
360; Returns:
361; CF: Set
362; Corrupts registers:
363; AX, DI
364;--------------------------------------------------------------------
365ALIGN JUMP_ALIGN
366BootMenuPrint_ClearInformationArea:
367 CALL_MENU_LIBRARY ClearInformationArea
368 stc
369 ret
370
371
372;--------------------------------------------------------------------
373; BootMenuPrint_TheBottomOfScreen
374; Parameters:
375; DS: RAMVARS segment
376; Returns:
377; Nothing
378; Corrupts registers:
379; AX, BX, CX, DX, SI, DI
380;--------------------------------------------------------------------
381ALIGN JUMP_ALIGN
382BootMenuPrint_TheBottomOfScreen:
383 call FloppyDrive_GetCountToCX
384 mov bl, cl ; Floppy Drive count to BL
385 call RamVars_GetHardDiskCountFromBDAtoCX
386 mov bh, cl ; Hard Disk count to BH
387 ; Fall to .MoveCursorToHotkeyStrings
388
389;--------------------------------------------------------------------
390; .MoveCursorToHotkeyStrings
391; Parameters:
392; Nothing
393; Returns:
394; Nothing
395; Corrupts registers:
396; AX, DI
397;--------------------------------------------------------------------
398.MoveCursorToHotkeyStrings:
399 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
400 xor al, al
401 dec ah
402 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
403 ; Fall to .PrintHotkeyString
404
405;--------------------------------------------------------------------
406; .PrintHotkeyString
407; Parameters:
408; BL: Floppy Drives
409; BH: Hard Drives
410; Returns:
411; Nothing
412; Corrupts registers:
413; AX, CX, DX, SI, DI
414;--------------------------------------------------------------------
415.PrintHotkeyString:
416 ; Display Library should not be called like this
417 mov si, ATTRIBUTE_CHARS.cHighlightedItem
418 call MenuAttribute_GetToAXfromTypeInSI
419 xchg dx, ax
420 mov cx, MONO_BRIGHT
421
422 test bl, bl ; Any Floppy Drives?
423 jz SHORT .SkipFloppyDriveHotkeys
424 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
425 mov si, g_szFDD
426 call PushHotkeyParamsAndFormat
427
428.SkipFloppyDriveHotkeys:
429 test bh, bh ; Any Hard Drives?
430 jz SHORT .SkipHardDriveHotkeys
431 xchg ax, cx ; Store Key Attribute
432 call BootMenu_GetLetterForFirstHardDiskToCL
433 mov ch, ANGLE_QUOTE_RIGHT
434 xchg ax, cx
435 mov si, g_szHDD
436 call PushHotkeyParamsAndFormat
437
438.SkipHardDriveHotkeys:
439 ; Fall to .PrintRomBootHotkey
440
441;--------------------------------------------------------------------
442; .PrintRomBootHotkey
443; Parameters:
444; CX: Key Attribute
445; DX: Description Attribute
446; Returns:
447; Nothing
448; Corrupts registers:
449; AX, SI, DI
450;--------------------------------------------------------------------
451.PrintRomBootHotkey:
452 mov ax, 'F' | ('8'<<8) ; F8
453 mov si, g_szRomBoot
454 ; Fall to PushHotkeyParamsAndFormat
455
456;--------------------------------------------------------------------
457; PushHotkeyParamsAndFormat
458; Parameters:
459; AL: First character
460; AH: Second character
461; CX: Key Attribute
462; DX: Description Attribute
463; CS:SI: Description string
464; Returns:
465; Nothing
466; Corrupts registers:
467; AX, SI, DI
468;--------------------------------------------------------------------
469ALIGN JUMP_ALIGN
470PushHotkeyParamsAndFormat:
471 push bp
472 mov bp, sp
473
474 push cx ; Key attribute
475 push ax ; First character
476 xchg al, ah
477 push ax ; Second character
478 push dx ; Description attribute
479 push si ; Description string
480 push cx ; Key attribute for last space
481 mov si, g_szHotkey
482 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
483
484ALIGN WORD_ALIGN
485FloppyTypes:
486.rgwCapacity:
487 dw 360
488 dw 1200
489 dw 720
490 dw 1440
491 dw 2880
492 dw 2880
493.rgwPhysicalSize:
494 db '5', 172 ; 1, FLOPPY_TYPE_525_DD
495 db '5', 172 ; 2, FLOPPY_TYPE_525_HD
496 db '3', 171 ; 3, FLOPPY_TYPE_35_DD
497 db '3', 171 ; 4, FLOPPY_TYPE_35_HD
498 db '3', 171 ; 5, 3.5" ED on some BIOSes
499 db '3', 171 ; 6, FLOPPY_TYPE_35_ED
Note: See TracBrowser for help on using the repository browser.