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

Last change on this file since 258 was 258, checked in by gregli@…, 12 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
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    jc      .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_RefreshInformation.FormatRelay
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_RefreshInformation.FormatRelay
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    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       
120    test    dl, dl                                      ; are we a hard disk?
121    js      BootMenuPrint_HardDiskRefreshInformation       
122
123    test    di,di
124    jnz     .ours
125    call    FloppyDrive_GetType                         ; Get Floppy Drive type to BX
126    jmp     .around
127.ours:
128    call    AH8h_GetDriveParameters
129.around:               
130
131    mov     ax, g_szFddSizeOr                           ; .PrintXTFloppyType
132    test    bl, bl                                      ; Two possibilities? (FLOPPY_TYPE_525_OR_35_DD)     
133    jz      SHORT .PushAXAndOutput
134
135    mov     al, (g_szFddUnknown - $$) & 0xff            ; .PrintUnknownFloppyType
136    cmp     bl, FLOPPY_TYPE_35_ED
137    ja      SHORT .PushAXAndOutput
138       
139    ; Fall to .PrintKnownFloppyType
140
141;--------------------------------------------------------------------
142; .PrintKnownFloppyType
143;   Parameters:
144;       BX:     Floppy drive type
145;   Returns:
146;       CF:     Set since menu event was handled successfully
147;   Corrupts registers:
148;       AX, BX, SI, DI
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; 
161;--------------------------------------------------------------------
162.PrintKnownFloppyType:
163    mov     al, (g_szFddSize - $$) & 0xff
164    push    ax
165       
166    mov     al, (g_szFddThreeHalf - $$) & 0xff
167    cmp     bl, FLOPPY_TYPE_525_HD
168    ja      .ThreeHalf
169    mov     al, (g_szFddFiveQuarter - $$) & 0xff
170.ThreeHalf:     
171    push    ax                                          ; "5 1/4" or "3 1/2"
172
173    mov     al,FloppyTypes.rgbCapacityMultiplier
174    mov     bh, 0
175    mul     byte [cs:bx+FloppyTypes.rgbCapacity - 1]    ; -1 since 0 is handled above and not in the table
176
177.PushAXAndOutput:                   
178    push    ax
179
180.FormatRelay:
181    jmp     short BootMenuPrint_FormatCSSIfromParamsInSSBP
182
183
184;--------------------------------------------------------------------
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:
192;       CF:     Set since menu event was handled successfully
193;   Corrupts registers:
194;       BX, CX, DX, SI, DI, ES
195;--------------------------------------------------------------------
196ALIGN JUMP_ALIGN
197BootMenuPrint_HardDiskRefreshInformation:       
198    test    di,di
199    jz      .HardDiskMenuitemInfoForForeignDrive       
200
201.HardDiskMenuitemInfoForOurDrive:
202    ePUSH_T ax, g_szInformation
203
204    ; Get and push total LBA size
205    call    BootMenuInfo_GetTotalSectorCount
206    jmp     .ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
207       
208.HardDiskMenuitemInfoForForeignDrive:
209    call    DriveXlate_ToOrBack
210    call    AH15h_GetSectorCountFromForeignDriveToDXAX
211
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
223
224%include "BootMenuPrintCfg.asm"         ; inline of code to fill out remainder of information string
225
226;;; fall-through to BootMenuPrint_FormatCSSIfromParamsInSSBP
227
228
229;--------------------------------------------------------------------
230; BootMenuPrint_FormatCSSIfromParamsInSSBP
231;   Parameters:
232;       CS:SI:  Ptr to string to format
233;       BP:     SP before pushing parameters
234;   Returns:
235;       BP:     Popped from stack
236;       CF:     Set since menu event was handled successfully       
237;   Corrupts registers:
238;       AX, DI
239;--------------------------------------------------------------------
240ALIGN JUMP_ALIGN
241BootMenuPrint_FormatCSSIfromParamsInSSBP:
242    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
243    stc             ; Successfull return from menu event
244    pop     bp
245    ret
246       
247       
248;--------------------------------------------------------------------
249; BootMenuPrint_ClearScreen
250;   Parameters:
251;       Nothing
252;   Returns:
253;       Nothing
254;   Corrupts registers:
255;       AX, DI
256;--------------------------------------------------------------------
257ALIGN JUMP_ALIGN
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
265
266
267;--------------------------------------------------------------------
268; BootMenuPrint_TheBottomOfScreen
269;   Parameters:
270;       DS:     RAMVARS segment
271;   Returns:
272;       Nothing
273;   Corrupts registers:
274;       AX, BX, CX, DX, SI, DI
275;--------------------------------------------------------------------
276ALIGN JUMP_ALIGN
277BootMenuPrint_TheBottomOfScreen:
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
282    ; Fall to .MoveCursorToHotkeyStrings
283
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
299
300;--------------------------------------------------------------------
301; .PrintHotkeyString
302;   Parameters:
303;       BL:     Floppy Drives
304;       BH:     Hard Drives
305;   Returns:
306;       Nothing
307;   Corrupts registers:
308;       AX, CX, DX, SI, DI
309;--------------------------------------------------------------------
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
315    mov     cx, MONO_BRIGHT
316
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
322
323.SkipFloppyDriveHotkeys:
324    test    bh, bh      ; Any Hard Drives?
325    jz      SHORT .SkipHardDriveHotkeys
326    call    BootMenu_GetLetterForFirstHardDiskToAL
327    mov     ah, ANGLE_QUOTE_RIGHT
328    mov     si, g_szHDD
329    call    PushHotkeyParamsAndFormat
330
331.SkipHardDriveHotkeys:
332    ; Fall to .PrintRomBootHotkey
333
334;--------------------------------------------------------------------
335; .PrintRomBootHotkey
336;   Parameters:
337;       CX:     Key Attribute
338;       DX:     Description Attribute
339;   Returns:
340;       Nothing
341;   Corrupts registers:
342;       AX, SI, DI
343;--------------------------------------------------------------------
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:
360;       AX, SI, DI
361;--------------------------------------------------------------------
362ALIGN JUMP_ALIGN
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
375       
376BootMenuPrint_FormatCSSIfromParamsInSSBP_Relay: 
377    jmp     SHORT BootMenuPrint_FormatCSSIfromParamsInSSBP
378
379
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
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.