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

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

Optimized away some long jumps, by rearranging routines within files, and file order within main.asm. Also added some 'relay' entry points for popular destinations, so that a short jump can go to an existing short jump and then on to the final destination, instead of using a long jump - clearly space over speed optimization. All 'relay's are limited to the UI code, and will not have an impact on IDE operational performance.

File size: 15.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;;; Fall-through from BootMenuEvent.asm!
9;;; BootMenuPrint_FloppyMenuitem must be the first routine in this file
10;;; (checked at assembler time with the code after BootMenuPrint_FloppyMenuitem)
11;;;
12;--------------------------------------------------------------------
13; BootMenuPrint_FloppyMenuitem
14; Parameters:
15; DL: Untranslated Floppy Drive number
16; SF: set for Information, clear for Item
17; Returns:
18; Nothing
19; Corrupts registers:
20; AX, DX, SI, DI
21;--------------------------------------------------------------------
22ALIGN JUMP_ALIGN
23BootMenuPrint_FloppyMenuitem:
24 js short BootMenuPrint_FloppyMenuitemInformation
25 call PrintDriveNumberAfterTranslationFromDL
26 push bp
27 mov bp, sp
28 mov si, g_szFDLetter
29 ePUSH_T ax, g_szFloppyDrv
30 add dl, 'A'
31 push dx ; Drive letter
32 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
33
34%if BootMenuPrint_FloppyMenuitem <> BootMenuEvent_FallThroughToFloppyMenuitem
35%error "BootMenuPrint.asm must follow BootMenuEvent.asm, and BootMenuPrint_FloppyMenuitem must be the first routine in BootMenuPrint.asm"
36%endif
37
38
39;--------------------------------------------------------------------
40; ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
41; Parameters:
42; BX:DX:AX: Sector count
43; Returns:
44; Size in stack
45; Corrupts registers:
46; AX, BX, CX, DX, SI
47;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
49ConvertSectorCountInBXDXAXtoSizeAndPushForFormat:
50 pop si ; Pop return address
51 call Size_ConvertSectorCountInBXDXAXtoKiB
52 mov cx, BYTE_MULTIPLES.kiB
53 call Size_GetSizeToAXAndCharToDLfromBXDXAXwithMagnitudeInCX
54 push ax ; Size in magnitude
55 push cx ; Tenths
56 push dx ; Magnitude character
57 jmp si
58
59
60;--------------------------------------------------------------------
61; Prints Boot Menu title strings.
62;
63; BootMenuPrint_TitleStrings
64; Parameters:
65; Nothing
66; Returns:
67; CF: Set since menu event handled
68; Corrupts registers:
69; AX, SI, DI
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72BootMenuPrint_TitleStrings:
73 mov si, ROMVARS.szTitle
74 call BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
75 CALL_DISPLAY_LIBRARY PrintNewlineCharacters
76 mov si, ROMVARS.szVersion
77 ; Fall to BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
78
79
80;--------------------------------------------------------------------
81; BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
82; Parameters:
83; CS:SI: Ptr to NULL terminated string to print
84; Returns:
85; CF: Set since menu event was handled successfully
86; Corrupts registers:
87; AX, DI
88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
90BootMenuPrint_NullTerminatedStringFromCSSIandSetCF:
91;
92; We send all CSSI strings through the Format routine for the case of
93; compressed strings, but this doesn't hurt in the non-compressed case either
94; (perhaps a little slower, but shouldn't be noticeable to the user)
95; and results in smaller code size.
96;
97 push bp
98 mov bp,sp
99 jmp short BootMenuPrint_FormatCSSIfromParamsInSSBP
100
101
102;--------------------------------------------------------------------
103; BootMenuPrint_HardDiskMenuitem
104; Parameters:
105; DL: Untranslated Hard Disk number
106; DS: RAMVARS segment
107; SF: set for Information, clear for Item
108; Returns:
109; CF: Set since menu event handled
110; Corrupts registers:
111; AX, BX, SI, DI
112;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114BootMenuPrint_HardDiskMenuitem:
115 js short BootMenuPrint_HardDiskMenuitemInformation
116 call PrintDriveNumberAfterTranslationFromDL
117 call RamVars_IsDriveHandledByThisBIOS
118 jnc SHORT .HardDiskMenuitemForForeignDrive
119 ; Fall to .HardDiskMenuitemForOurDrive
120
121;--------------------------------------------------------------------
122; .HardDiskMenuitemForOurDrive
123; Parameters:
124; DL: Untranslated Hard Disk number
125; DS: RAMVARS segment
126; Returns:
127; CF: Set since menu event handled
128; Corrupts registers:
129; AX, BX, SI, DI
130;--------------------------------------------------------------------
131.HardDiskMenuitemForOurDrive:
132 call BootInfo_GetOffsetToBX
133 lea si, [bx+BOOTNFO.szDrvName]
134 xor bx, bx ; BDA segment
135 CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromBXSI
136 stc
137 ret
138
139;--------------------------------------------------------------------
140; BootMenuPrint_HardDiskMenuitemForForeignDrive
141; Parameters:
142; DL: Untranslated Hard Disk number
143; DS: RAMVARS segment
144; Returns:
145; CF: Set since menu event handled
146; Corrupts registers:
147; AX, SI, DI
148;--------------------------------------------------------------------
149ALIGN JUMP_ALIGN
150.HardDiskMenuitemForForeignDrive:
151 mov si, g_szforeignHD
152 jmp SHORT BootMenuPrint_NullTerminatedStringFromCSSIandSetCF
153
154
155;--------------------------------------------------------------------
156; BootMenuPrint_FloppyMenuitemInformation
157; Parameters:
158; DL: Untranslated Floppy Drive number
159; DS: RAMVARS segment
160; Returns:
161; CF: Set since menu event was handled successfully
162; Corrupts registers:
163; AX, BX, CX, DX, SI, DI, ES
164;--------------------------------------------------------------------
165
166FloppyTypes:
167.rgbCapacityMultiplier equ 20 ; Multiplier to reduce word sized values to byte size
168.rgbCapacity:
169 db 360 / FloppyTypes.rgbCapacityMultiplier ; type 1
170 db 1200 / FloppyTypes.rgbCapacityMultiplier ; type 2
171 db 720 / FloppyTypes.rgbCapacityMultiplier ; type 3
172 db 1440 / FloppyTypes.rgbCapacityMultiplier ; type 4
173 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 5
174 db 2880 / FloppyTypes.rgbCapacityMultiplier ; type 6
175
176%if g_szFddFiveQuarter <> g_szFddThreeHalf+g_szFddThreeFive_Displacement
177%error "FddThreeFive_Displacement incorrect"
178%endif
179
180ALIGN JUMP_ALIGN
181BootMenuPrint_FloppyMenuitemInformation:
182 call BootMenuPrint_ClearInformationArea
183 call FloppyDrive_GetType ; Get Floppy Drive type to BX
184
185 push bp
186 mov bp, sp
187 ePUSH_T ax, g_szCapacity
188
189 mov si, g_szFddSizeOr ; .PrintXTFloppyType
190 test bx, bx ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)
191 jz SHORT .output
192
193 mov si, g_szFddUnknown ; .PrintUnknownFloppyType
194 cmp bl, FLOPPY_TYPE_35_ED
195 ja SHORT .output
196
197 ; Fall to .PrintKnownFloppyType
198
199
200;--------------------------------------------------------------------
201; .PrintKnownFloppyType
202; Parameters:
203; BX: Floppy drive type
204; Returns:
205; CF: Set since menu event was handled successfully
206; Corrupts registers:
207; AX, BX, SI, DI
208;
209; Floppy Drive Types:
210;
211; 0 Handled above
212; 1 FLOPPY_TYPE_525_DD 5 1/4 360K
213; 2 FLOPPY_TYPE_525_HD 5 1/4 1.2M
214; 3 FLOPPY_TYPE_35_DD 3 1/2 720K
215; 4 FLOPPY_TYPE_35_HD 3 1/2 1.44M
216; 5 3.5" ED on some BIOSes 3 1/2 2.88M
217; 6 FLOPPY_TYPE_35_ED 3 1/2 2.88M
218; >6 Unknwon, handled above
219;
220;--------------------------------------------------------------------
221.PrintKnownFloppyType:
222 mov si, g_szFddSize
223
224 mov ax, g_szFddThreeHalf
225 cmp bl, FLOPPY_TYPE_525_HD
226 ja .ThreeHalf
227%if g_szFddThreeFive_Displacement = 2
228 inc ax ; compressed string case
229 inc ax
230%else
231 add ax, g_szFddThreeFive_Displacement
232%endif
233.ThreeHalf:
234 push ax ; "5 1/4" or "3 1/2"
235
236 mov al,FloppyTypes.rgbCapacityMultiplier
237 mul byte [cs:bx+FloppyTypes.rgbCapacity - 1] ; -1 since 0 is handled above and not in the table
238 push ax
239
240ALIGN JUMP_ALIGN
241.output:
242;;; fall-through
243
244;--------------------------------------------------------------------
245; BootMenuPrint_FormatCSSIfromParamsInSSBP
246; Parameters:
247; CS:SI: Ptr to string to format
248; BP: SP before pushing parameters
249; Returns:
250; BP: Popped from stack
251; Corrupts registers:
252; AX, DI
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255BootMenuPrint_FormatCSSIfromParamsInSSBP:
256 CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
257 stc ; Successfull return from menu event
258 pop bp
259 ret
260
261
262;--------------------------------------------------------------------
263; Prints Hard Disk Menuitem information strings.
264;
265; BootMenuPrint_HardDiskMenuitemInformation
266; Parameters:
267; DL: Untranslated Hard Disk number
268; DS: RAMVARS segment
269; Returns:
270; CF: Set since menu event was handled successfully
271; Corrupts registers:
272; BX, CX, DX, SI, DI, ES
273;--------------------------------------------------------------------
274ALIGN JUMP_ALIGN
275BootMenuPrint_HardDiskMenuitemInformation:
276 call RamVars_IsDriveHandledByThisBIOS
277 jnc SHORT .HardDiskMenuitemInfoForForeignDrive
278 call FindDPT_ForDriveNumber ; DS:DI to point DPT
279 ; Fall to .HardDiskMenuitemInfoForOurDrive
280
281;--------------------------------------------------------------------
282; .HardDiskMenuitemInfoForOurDrive
283; Parameters:
284; DL: Untranslated Hard Disk number
285; DS:DI: Ptr to DPT
286; Returns:
287; Nothing
288; Corrupts registers:
289; AX, BX, CX, DX, SI, DI, ES
290;--------------------------------------------------------------------
291.HardDiskMenuitemInfoForOurDrive:
292 push di
293 ePUSH_T ax, BootMenuPrintCfg_ForOurDrive ; Return from BootMenuPrint_FormatCSSIfromParamsInSSBP
294 push bp
295 mov bp, sp
296 ePUSH_T ax, g_szCapacity
297
298 ; Get and push L-CHS size
299 mov [RAMVARS.bTimeoutTicksLeft], dl ; Store drive number
300 call AH15h_GetSectorCountToDXAX
301 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
302
303 ; Get and push total LBA size
304 mov dl, [RAMVARS.bTimeoutTicksLeft] ; Restore drive number
305 call BootInfo_GetTotalSectorCount
306 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
307
308 mov si, g_szSizeDual
309 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
310
311
312;--------------------------------------------------------------------
313; .HardDiskMenuitemInfoForForeignDrive
314; Parameters:
315; DL: Untranslated Hard Disk number
316; DS: RAMVARS segment
317; Returns:
318; CF: Set since menu event was handled successfully
319; Corrupts registers:
320; AX, BX, CX, DX, SI, DI
321;--------------------------------------------------------------------
322ALIGN JUMP_ALIGN
323.HardDiskMenuitemInfoForForeignDrive:
324 push bp
325 mov bp, sp
326 ePUSH_T ax, g_szCapacity
327
328 call DriveXlate_ToOrBack
329 call AH15h_GetSectorCountFromForeignDriveToDXAX
330 call ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
331
332 mov si, g_szSizeSingle
333 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
334
335
336;--------------------------------------------------------------------
337; BootMenuPrint_ClearInformationArea
338; Parameters:
339; Nothing
340; Returns:
341; CF: Set
342; Corrupts registers:
343; AX, DI
344;--------------------------------------------------------------------
345ALIGN JUMP_ALIGN
346BootMenuPrint_ClearInformationArea:
347 CALL_MENU_LIBRARY ClearInformationArea
348 stc
349 ret
350
351
352;--------------------------------------------------------------------
353; BootMenuPrint_ClearScreen
354; Parameters:
355; Nothing
356; Returns:
357; Nothing
358; Corrupts registers:
359; AX, DI
360;--------------------------------------------------------------------
361ALIGN JUMP_ALIGN
362BootMenuPrint_ClearScreen:
363 call BootMenuPrint_InitializeDisplayContext
364 xor ax, ax
365 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
366 mov ax, ' ' | (MONO_NORMAL<<8)
367 CALL_DISPLAY_LIBRARY ClearScreenWithCharInALandAttrInAH
368 ret
369
370
371;--------------------------------------------------------------------
372; PrintDriveNumberAfterTranslationFromDL
373; Parameters:
374; DL: Untranslated Floppy Drive number
375; DS: RAMVARS segment
376; Returns:
377; Nothing
378; Corrupts registers:
379; AX, DI
380;--------------------------------------------------------------------
381ALIGN JUMP_ALIGN
382PrintDriveNumberAfterTranslationFromDL:
383 mov ax, dx
384 call DriveXlate_ToOrBack
385 xchg dx, ax ; Restore DX, WORD to print in AL
386 xor ah, ah
387 push bp
388 mov bp, sp
389 mov si, g_szDriveNum
390 push ax
391
392BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay:
393 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
394
395
396;--------------------------------------------------------------------
397; BootMenuPrint_TheBottomOfScreen
398; Parameters:
399; DS: RAMVARS segment
400; Returns:
401; Nothing
402; Corrupts registers:
403; AX, BX, CX, DX, SI, DI
404;--------------------------------------------------------------------
405ALIGN JUMP_ALIGN
406BootMenuPrint_TheBottomOfScreen:
407 call FloppyDrive_GetCountToCX
408 mov bl, cl ; Floppy Drive count to BL
409 call RamVars_GetHardDiskCountFromBDAtoCX
410 mov bh, cl ; Hard Disk count to BH
411 ; Fall to .MoveCursorToHotkeyStrings
412
413;--------------------------------------------------------------------
414; .MoveCursorToHotkeyStrings
415; Parameters:
416; Nothing
417; Returns:
418; Nothing
419; Corrupts registers:
420; AX, DI
421;--------------------------------------------------------------------
422.MoveCursorToHotkeyStrings:
423 CALL_DISPLAY_LIBRARY GetColumnsToALandRowsToAH
424 xor al, al
425 dec ah
426 CALL_DISPLAY_LIBRARY SetCursorCoordinatesFromAX
427 ; Fall to .PrintHotkeyString
428
429;--------------------------------------------------------------------
430; .PrintHotkeyString
431; Parameters:
432; BL: Floppy Drives
433; BH: Hard Drives
434; Returns:
435; Nothing
436; Corrupts registers:
437; AX, CX, DX, SI, DI
438;--------------------------------------------------------------------
439.PrintHotkeyString:
440 ; Display Library should not be called like this
441 mov si, ATTRIBUTE_CHARS.cHighlightedItem
442 call MenuAttribute_GetToAXfromTypeInSI
443 xchg dx, ax
444 mov cx, MONO_BRIGHT
445
446 test bl, bl ; Any Floppy Drives?
447 jz SHORT .SkipFloppyDriveHotkeys
448 mov ax, 'A' | (ANGLE_QUOTE_RIGHT<<8)
449 mov si, g_szFDD
450 call PushHotkeyParamsAndFormat
451
452.SkipFloppyDriveHotkeys:
453 test bh, bh ; Any Hard Drives?
454 jz SHORT .SkipHardDriveHotkeys
455 xchg ax, cx ; Store Key Attribute
456 call BootMenu_GetLetterForFirstHardDiskToCL
457 mov ch, ANGLE_QUOTE_RIGHT
458 xchg ax, cx
459 mov si, g_szHDD
460 call PushHotkeyParamsAndFormat
461
462.SkipHardDriveHotkeys:
463 ; Fall to .PrintRomBootHotkey
464
465;--------------------------------------------------------------------
466; .PrintRomBootHotkey
467; Parameters:
468; CX: Key Attribute
469; DX: Description Attribute
470; Returns:
471; Nothing
472; Corrupts registers:
473; AX, SI, DI
474;--------------------------------------------------------------------
475.PrintRomBootHotkey:
476 mov ax, 'F' | ('8'<<8) ; F8
477 mov si, g_szRomBoot
478 ; Fall to PushHotkeyParamsAndFormat
479
480;--------------------------------------------------------------------
481; PushHotkeyParamsAndFormat
482; Parameters:
483; AL: First character
484; AH: Second character
485; CX: Key Attribute
486; DX: Description Attribute
487; CS:SI: Description string
488; Returns:
489; Nothing
490; Corrupts registers:
491; AX, SI, DI
492;--------------------------------------------------------------------
493ALIGN JUMP_ALIGN
494PushHotkeyParamsAndFormat:
495 push bp
496 mov bp, sp
497
498 push cx ; Key attribute
499 push ax ; First character
500 xchg al, ah
501 push ax ; Second character
502 push dx ; Description attribute
503 push si ; Description string
504 push cx ; Key attribute for last space
505 mov si, g_szHotkey
506 jmp SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay
507
508
509;--------------------------------------------------------------------
510; BootMenuPrint_InitializeDisplayContext
511; Parameters:
512; Nothing
513; Returns:
514; Nothing
515; Corrupts registers:
516; AX, DI
517;--------------------------------------------------------------------
518ALIGN JUMP_ALIGN
519BootMenuPrint_InitializeDisplayContext:
520 CALL_DISPLAY_LIBRARY InitializeDisplayContext
521 ret
522
523
524
525
526
527
Note: See TracBrowser for help on using the repository browser.