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

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

Bug fix in BootMenuPrint, introduced in r241, where floppy disk information was not being properly displayed.

File size: 12.8 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_RefreshItem
9;
10; Parameters:
11; DL: Untranslated Floppy Drive number
12; Returns:
13; Nothing
14; Corrupts registers:
15; AX, BX, DX, SI, DI
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18BootMenuPrint_RefreshItem:
19 call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
20 jnc BootMenuEvent_EventCompleted ; if no menu item selected, out we go
21
22 push bp
23 mov bp, sp
24
25 call RamVars_IsDriveHandledByThisBIOS
26 jnc .notOurs
27
28 call FindDPT_ForDriveNumber ; if it is one of ours, print the string in bootnfo
29 call BootMenuInfo_ConvertDPTtoBX
30 mov si, g_szDriveNumBOOTNFO ; special g_szDriveNum that prints from BDA
31 jmp .go
32
33.notOurs:
34 mov si,g_szDriveNum
35 mov bx,g_szForeignHD ; assume a hard disk for the moment
36
37 test dl,80h
38 js .go
39 mov bl,((g_szFloppyDrv)-$$ & 0xff) ; and revisit the earlier assumption...
40
41.go:
42 mov ax, dx ; preserve DL for the floppy drive letter addition
43 call DriveXlate_ToOrBack
44 push dx ; translated drive number
45 push bx ; sub string
46 add al, 'A' ; floppy drive letter (we always push this although
47 push ax ; the hard disks don't ever use it, but it does no harm)
48
49 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
50
51;--------------------------------------------------------------------
52; Prints Boot Menu title strings.
53;
54; BootMenuPrint_TitleStrings
55; Parameters:
56; Nothing
57; Returns:
58; CF: Set since menu event handled
59; Corrupts registers:
60; AX, SI, DI
61;--------------------------------------------------------------------
62ALIGN JUMP_ALIGN
63BootMenuPrint_TitleStrings:
64 mov si, ROMVARS.szTitle
65 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
66 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
67 mov si, ROMVARS.szVersion
68 ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
69
70;--------------------------------------------------------------------
71; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
72; Parameters:
73; CS:SI: Ptr to NULL terminated string to print
74; Returns:
75; CF: Set since menu event was handled successfully
76; Corrupts registers:
77; AX, DI
78;--------------------------------------------------------------------
79ALIGN JUMP_ALIGN
80BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
81;
82; We send all CSSI strings through the Format routine for the case of
83; compressed strings, but this doesn't hurt in the non-compressed case either
84; (perhaps a little slower, but shouldn't be noticeable to the user)
85; and results in smaller code size.
86;
87 push bp
88 mov bp,sp
89 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
90
91
92;--------------------------------------------------------------------
93; BootMenuPrint_FloppyMenuitemInformation
94; Parameters:
95; DL: Untranslated Floppy Drive number
96; DS: RAMVARS segment
97; Returns:
98; CF: Set since menu event was handled successfully
99; Corrupts registers:
100; AX, BX, CX, DX, SI, DI, ES
101;--------------------------------------------------------------------
102ALIGN JUMP_ALIGN
103BootMenuPrint_RefreshInformation:
104 CALL_MENU_LIBRARY ClearInformationArea
105
106 call BootMenu_GetDriveToDXforMenuitemInCX_And_RamVars_GetSegmentToDS
107 jnc BootMenuEvent_EventCompleted ; if no menu selection, abort
108
109 push bp
110 mov bp, sp
111
112 test dl, dl ; are we a hard disk?
113 js BootMenuPrint_HardDiskRefreshInformation
114
115 call FloppyDrive_GetType ; Get Floppy Drive type to BX
116
117 mov ax, g_szFddSizeOr ; .PrintXTFloppyType
118 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
119 jz SHORT .PushAXAndOutput
120
121 mov al, (g_szFddUnknown - $$) & 0xff ; .PrintUnknownFloppyType
122 cmp bl, FLOPPY_TYPE_35_ED
123 ja SHORT .PushAXAndOutput
124
125 ; Fall to .PrintKnownFloppyType
126
127;--------------------------------------------------------------------
128; .PrintKnownFloppyType
129; Parameters:
130; BX: Floppy drive type
131; Returns:
132; CF: Set since menu event was handled successfully
133; Corrupts registers:
134; AX, BX, SI, DI
135;
136; Floppy Drive Types:
137;
138; 0 Handled above
139; 1 FLOPPY_TYPE_525_DD 5 1/4 360K
140; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M
141; 3 FLOPPY_TYPE_35_DD 3 1/2 720K
142; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M
143; 5 3.5" ED on some BIOSes 3 1/2 2.88M
144; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M
145; >6 Unknwon, handled above
146;
147;--------------------------------------------------------------------
148.PrintKnownFloppyType:
149 mov al, (g_szFddSize - $$) & 0xff
150 push ax
151
152 mov al, (g_szFddThreeHalf - $$) & 0xff
153 cmp bl, FLOPPY_TYPE_525_HD
154 ja .ThreeHalf
155 mov al, (g_szFddFiveQuarter - $$) & 0xff
156.ThreeHalf:
157 push ax ; "5 1/4" or "3 1/2"
158
159 mov al,FloppyTypes.rgbCapacityMultiplier
160 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table
161
162.PushAXAndOutput:
163 push ax
164
165 jmp short BootMenuPrint_HardDiskRefreshInformation.output
166
167
168;--------------------------------------------------------------------
169; Prints Hard Disk Menuitem information strings.
170;
171; BootMenuPrint_HardDiskMenuitemInformation
172; Parameters:
173; DL: Untranslated Hard Disk number
174; DS: RAMVARS segment
175; Returns:
176; CF: Set since menu event was handled successfully
177; Corrupts registers:
178; BX, CX, DX, SI, DI, ES
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181BootMenuPrint_HardDiskRefreshInformation:
182 call RamVars_IsDriveHandledByThisBIOS
183 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
184 call FindDPT_ForDriveNumber ; DS:DI to point DPT
185 ; Fall to .HardDiskMenuitemInfoForOurDrive
186
187;--------------------------------------------------------------------
188; .HardDiskMenuitemInfoForOurDrive
189; Parameters:
190; DL: Untranslated Hard Disk number
191; DS:DI: Ptr to DPT
192; Returns:
193; Nothing
194; Corrupts registers:
195; AX, BX, CX, DX, SI, DI, ES
196;--------------------------------------------------------------------
197.HardDiskMenuitemInfoForOurDrive:
198 ePUSH_T ax, g_szInformation
199
200 ; Get and push total LBA size
201 call BootMenuInfo_GetTotalSectorCount
202 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
203 jmp BootMenuPrintCfg_ForOurDrive
204
205;--------------------------------------------------------------------
206; .HardDiskMenuitemInfoForForeignDrive
207; Parameters:
208; DL: Untranslated Hard Disk number
209; DS: RAMVARS segment
210; Returns:
211; CF: Set since menu event was handled successfully
212; Corrupts registers:
213; AX, BX, CX, DX, SI, DI
214;--------------------------------------------------------------------
215ALIGN JUMP_ALIGN
216.HardDiskMenuitemInfoForForeignDrive:
217 call DriveXlate_ToOrBack
218 call AH15h_GetSectorCountFromForeignDriveToDXAX
219 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
220
221ALIGN JUMP_ALIGN
222.output:
223 mov si, g_szCapacity
224;;; fall-through
225
226;--------------------------------------------------------------------
227; BootMenuPrint_FormatCSSIfromParamsInSSBP
228; Parameters:
229; CS:SI: Ptr to string to format
230; BP: SP before pushing parameters
231; Returns:
232; BP: Popped from stack
233; CF: Set since menu event was handled successfully
234; Corrupts registers:
235; AX, DI
236;--------------------------------------------------------------------
237ALIGN JUMP_ALIGN
238BootMenuPrint_FormatCSSIfromParamsInSSBP:
239 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
240 stc ; Successfull return from menu event
241 pop bp
242 ret
243
244
245;--------------------------------------------------------------------
246; BootMenuPrint_ClearScreen
247; Parameters:
248; Nothing
249; Returns:
250; Nothing
251; Corrupts registers:
252; AX, DI
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255BootMenuPrint_ClearScreen:
256 call BootMenuPrint_InitializeDisplayContext
257 xor ax, ax
258 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
259 mov ax, ' ' | (MONO_NORMAL<<8)
260 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
261 ret
262
263
264;--------------------------------------------------------------------
265; BootMenuPrint_TheBottomOfScreen
266; Parameters:
267; DS: RAMVARS segment
268; Returns:
269; Nothing
270; Corrupts registers:
271; AX, BX, CX, DX, SI, DI
272;--------------------------------------------------------------------
273ALIGN JUMP_ALIGN
274BootMenuPrint_TheBottomOfScreen:
275 call FloppyDrive_GetCountToCX
276 mov bl, cl ; Floppy Drive count to BL
277 call RamVars_GetHardDiskCountFromBDAtoCX
278 mov bh, cl ; Hard Disk count to BH
279 ; Fall to .MoveCursorToHotkeyStrings
280
281;--------------------------------------------------------------------
282; .MoveCursorToHotkeyStrings
283; Parameters:
284; Nothing
285; Returns:
286; Nothing
287; Corrupts registers:
288; AX, DI
289;--------------------------------------------------------------------
290.MoveCursorToHotkeyStrings:
291 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
292 xor al, al
293 dec ah
294 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
295 ; Fall to .PrintHotkeyString
296
297;--------------------------------------------------------------------
298; .PrintHotkeyString
299; Parameters:
300; BL: Floppy Drives
301; BH: Hard Drives
302; Returns:
303; Nothing
304; Corrupts registers:
305; AX, CX, DX, SI, DI
306;--------------------------------------------------------------------
307.PrintHotkeyString:
308 ; Display Library should not be called like this
309 mov si, ATTRIBUTE_CHARS.cHighlightedItem
310 call MenuAttribute_GetToAXfromTypeInSI
311 xchg dx, ax
312 mov cx, MONO_BRIGHT
313
314 test bl, bl ; Any Floppy Drives?
315 jz SHORT .SkipFloppyDriveHotkeys
316 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
317 mov si, g_szFDD
318 call PushHotkeyParamsAndFormat
319
320.SkipFloppyDriveHotkeys:
321 test bh, bh ; Any Hard Drives?
322 jz SHORT .SkipHardDriveHotkeys
323 xchg ax, cx ; Store Key Attribute
324 call BootMenu_GetLetterForFirstHardDiskToCL
325 mov ch, ANGLE_QUOTE_RIGHT
326 xchg ax, cx
327 mov si, g_szHDD
328 call PushHotkeyParamsAndFormat
329
330.SkipHardDriveHotkeys:
331 ; Fall to .PrintRomBootHotkey
332
333;--------------------------------------------------------------------
334; .PrintRomBootHotkey
335; Parameters:
336; CX: Key Attribute
337; DX: Description Attribute
338; Returns:
339; Nothing
340; Corrupts registers:
341; AX, SI, DI
342;--------------------------------------------------------------------
343.PrintRomBootHotkey:
344 mov ax, 'F' | ('8'<<8) ; F8
345 mov si, g_szRomBoot
346 ; Fall to PushHotkeyParamsAndFormat
347
348;--------------------------------------------------------------------
349; PushHotkeyParamsAndFormat
350; Parameters:
351; AL: First character
352; AH: Second character
353; CX: Key Attribute
354; DX: Description Attribute
355; CS:SI: Description string
356; Returns:
357; Nothing
358; Corrupts registers:
359; AX, SI, DI
360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
362PushHotkeyParamsAndFormat:
363 push bp
364 mov bp, sp
365
366 push cx ; Key attribute
367 push ax ; First character
368 xchg al, ah
369 push ax ; Second character
370 push dx ; Description attribute
371 push si ; Description string
372 push cx ; Key attribute for last space
373 mov si, g_szHotkey
374
375BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
376 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
377
378
379;--------------------------------------------------------------------
380; BootMenuPrint_InitializeDisplayContext
381; Parameters:
382; Nothing
383; Returns:
384; Nothing
385; Corrupts registers:
386; AX, DI
387;--------------------------------------------------------------------
388ALIGN JUMP_ALIGN
389BootMenuPrint_InitializeDisplayContext:
390 CALL_DISPLAY_LIBRARY InitializeDisplayContext
391 ret
392
393
394;--------------------------------------------------------------------
395; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
396; Parameters:
397; BX:DX:AX: Sector count
398; Returns:
399; Size in stack
400; Corrupts registers:
401; AX, BX, CX, DX, SI
402;--------------------------------------------------------------------
403ALIGN JUMP_ALIGN
404ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
405 pop si ; Pop return address
406 ePUSH_T cx, g_szCapacityNum ; Push format substring
407 call Size_ConvertSectorCountInBXDXAXtoKiB
408 mov cx, BYTE_MULTIPLES.kiB
409 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
410 push ax ; Size in magnitude
411 push cx ; Tenths
412 push dx ; Magnitude character
413 jmp si
414
415
416FloppyTypes:
417.rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size
418.rgbCapacity:
419 db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1
420 db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2
421 db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3
422 db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4
423 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5
424 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6
Note: See TracBrowser for help on using the repository browser.