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

Last change on this file since 168 was 162, checked in by krille_n_@…, 13 years ago

Changes to all parts of the project:

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