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

Last change on this file since 184 was 182, checked in by gregli@…, 13 years ago

General code size optimizations, preparing for string compression, consolidating all strings into strings.asm. Note that some changes resulted in slightly larger size now uncompressed, but will be net win when compressed.

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