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

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

Added floppy drive emulation over the serial connection (MODULE_SERIAL_FLOPPY). Along the way, various optimizations were made to stay within the 8K ROM size target. Also, serial code now returns the number of sectors transferred.

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