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

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

Commit 2/2 (BIOS):

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