source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/MenuitemPrint.asm @ 445

Last change on this file since 445 was 445, checked in by krille_n_@…, 12 years ago

Changes:

  • A speed optimization to the eSHL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Memory_SumCXbytesFromESSItoAL now returns with the zero flag set/cleared according to the result.
  • Unrolled all the 8 bit READ transfer loops to do 16 bytes per iteration. Added a new macro (UNROLL_SECTORS_IN_CX_TO_OWORDS) as part of it. Size wise this is expensive but I think it should be worth the ROM space. The WRITE transfer loops were left as is since writes are rare anyway (<10% of all disk I/O IIRC).
  • Minor optimizations and fixes here and there.
File size: 8.6 KB
RevLine 
[57]1; Project name  :   XTIDE Universal BIOS Configurator v2
2; Description   :   Functions for printing MENUITEM name and value.
3
[376]4;
[445]5; XTIDE Universal BIOS and Associated Tools
[376]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
[445]12;
[376]13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
[445]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[445]18;
[376]19
[57]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; MenuitemPrint_PrintQuickInfoFromDSSI
25;   Parameters:
26;       DS:SI:  Ptr to MENUITEM
27;   Returns:
28;       Nothing
29;   Corrupts registers:
30;       AX, DI
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33MenuitemPrint_PrintQuickInfoFromDSSI:
34    push    si
35
36    mov     si, [si+MENUITEM.szQuickInfo]
37    CALL_DISPLAY_LIBRARY PrintNullTerminatedStringFromCSSI
38
39    pop     si
40    ret
41
42
43;--------------------------------------------------------------------
44; MenuitemPrint_NameWithPossibleValueFromDSSI
45;   Parameters:
46;       DS:SI:  Ptr to MENUITEM
47;   Returns:
48;       Nothing
49;   Corrupts registers:
50;       AX, BX, DX, DI
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53MenuitemPrint_NameWithPossibleValueFromDSSI:
[293]54    eMOVZX  bx, [si+MENUITEM.bType]
[57]55    cmp     bl, TYPE_MENUITEM_ACTION
56    ja      SHORT .PrintNameAndValueFromDSSI
57    ; Fall to .PrintNameWithoutValueFromDSSI
58
59;--------------------------------------------------------------------
60; .PrintNameWithoutValueFromDSSI
61;   Parameters:
62;       BX:     Menuitem type (MENUITEM.bType)
63;       DS:SI:  Ptr to MENUITEM
64;   Returns:
65;       Nothing
66;   Corrupts registers:
67;       AX, DI
68;--------------------------------------------------------------------
69.PrintNameWithoutValueFromDSSI:
70    push    bp
71    push    si
72
73    mov     bp, sp              ; BP = SP before pushing parameters
74    push    WORD [cs:bx+.rgwMenuitemTypeCharacter]
75    push    WORD [si+MENUITEM.szName]
76    mov     si, g_szFormatItemWithoutValue
77    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
78
79    pop     si
80    pop     bp
81    ret
82.rgwMenuitemTypeCharacter:
83    dw      '-'     ; TYPE_MENUITEM_PAGEBACK
84    dw      '+'     ; TYPE_MENUITEM_PAGENEXT
85    dw      '*'     ; TYPE_MENUITEM_ACTION
86
87
88;--------------------------------------------------------------------
89; .PrintNameAndValueFromDSSI
90;   Parameters:
91;       DS:SI:  Ptr to MENUITEM
92;       SS:BP:  Ptr to buffer for item value
93;   Returns:
94;       Nothing
95;   Corrupts registers:
96;       AX, BX, DX, DI
97;--------------------------------------------------------------------
98ALIGN JUMP_ALIGN
99.PrintNameAndValueFromDSSI:
100    eENTER_STRUCT   MAX_VALUE_STRING_LENGTH+2   ; +2 for NULL and alignment
101    call    .FormatValueStringFromItemInDSSItoBufferInSSBP
102    call    .FormatNameFromItemInDSSIandValueFromSSBP
103    eLEAVE_STRUCT   MAX_VALUE_STRING_LENGTH+2
104    ret
105
106;--------------------------------------------------------------------
107; .FormatValueStringFromItemInDSSItoBufferInSSBP
108;   Parameters:
109;       DS:SI:  Ptr to MENUITEM
110;       SS:BP:  Ptr to buffer for item value
111;   Returns:
112;       Nothing
113;   Corrupts registers:
114;       AX, BX, DX, DI
115;--------------------------------------------------------------------
116ALIGN JUMP_ALIGN
117.FormatValueStringFromItemInDSSItoBufferInSSBP:
118    push    es
[107]119    call    Registers_CopySSBPtoESDI
[57]120    mov     al, '['
121    stosb
122    call    [si+MENUITEM.fnFormatValue]
123    mov     ax, ']'
124    stosw   ; Also terminate with NULL
125    pop     es
126    ret
127
128;--------------------------------------------------------------------
129; .FormatNameFromItemInDSSIandValueFromSSBP
130;   Parameters:
131;       DS:SI:  Ptr to MENUITEM
132;       SS:BP:  Ptr to value string
133;   Returns:
134;       Nothing
135;   Corrupts registers:
136;       AX, BX, DX
137;--------------------------------------------------------------------
138ALIGN JUMP_ALIGN
139.FormatNameFromItemInDSSIandValueFromSSBP:
140    push    si
141
142    mov     bx, bp
143    mov     bp, sp              ; BP = SP before pushing parameters
144    push    WORD [si+MENUITEM.szName]
145    push    bx
146    push    ss
147    mov     si, g_szFormatItemNameWithValue
148    CALL_DISPLAY_LIBRARY FormatNullTerminatedStringFromCSSI
149
150    mov     bp, bx
151    pop     si
152    ret
153
[59]154
[57]155;--------------------------------------------------------------------
[59]156; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI
157; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI
158;   Parameters:
159;       DS:SI:  Ptr to MENUITEM
160;       ES:DI:  Ptr to destination buffer
161;   Returns:
162;       DI:     Updated
163;   Corrupts registers:
164;       AX, BX, CX
[293]165;--------------------------------------------------------------------
[59]166ALIGN JUMP_ALIGN
167MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI:
168    call    Menuitem_GetValueToAXfromMenuitemInDSSI
169    shl     ax, 1
170    jmp     SHORT PrintLookupValueFromAXtoBufferInESDI
171
172ALIGN JUMP_ALIGN
173MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI:
[233]174MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI:
[59]175    call    Menuitem_GetValueToAXfromMenuitemInDSSI
176    ; Fall to PrintLookupValueFromAXtoBufferInESDI
177
178;--------------------------------------------------------------------
[57]179; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromItemInDSSI
180;   Parameters:
[59]181;       AX:     Value to print
[57]182;       DS:SI:  Ptr to MENUITEM
183;       ES:DI:  Ptr to destination buffer
184;   Returns:
185;       DI:     Updated
186;   Corrupts registers:
187;       AX, BX, CX
[293]188;--------------------------------------------------------------------
[57]189ALIGN JUMP_ALIGN
[59]190PrintLookupValueFromAXtoBufferInESDI:
[57]191    push    si
[233]192    test    byte [si+MENUITEM.bFlags], FLG_MENUITEM_CHOICESTRINGS
[293]193    jnz     .lookupChoice
194
[57]195    add     ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgszValueToStringLookup]
196    xchg    bx, ax
[293]197.found:
[57]198    mov     si, [bx]
[233]199.errorReturn:
[57]200    call    String_CopyDSSItoESDIandGetLengthToCX
201    pop     si
202    ret
203
[233]204;
[293]205; With FLG_MENUITEM_CHOICESTRINGS, the array at .rgszChoiceToStringLookup is based on the
[233]206; Choice number (offset within .rgwChoiceToValueLookup) instead of the value stored.
207; Here, we scan the .rgwChoiceToValueLookup array until we find the value there, and then
[293]208; use the same offset in .rgszChoiceToStringLookup.  If we don't find the value, we
209; return an "Error!" string instead.
[233]210;
211; Note that the pointer array at .rgszChoiceToStringLookup must be NULL terminated.  Since the
212; value could be zero, we don't use the .rgwChoiceToValueLookup array to find the end.
213;
214.lookupChoice:
[293]215    mov     bx,[si+MENUITEM.itemValue+ITEM_VALUE.rgszChoiceToStringLookup]
[233]216    mov     si,[si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
[293]217
[233]218.wordLoop:
219    cmp     ax,[si]
220    jz      .found
[445]221    inc     bx
222    inc     bx
[233]223    inc     si
224    inc     si
225    cmp     word [bx],0
226    jnz     .wordLoop
[57]227
[233]228    mov     si,g_szValueUnknownError
229    jmp     .errorReturn
230
[57]231;--------------------------------------------------------------------
232; MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
233;   Parameters:
234;       DS:SI:  Ptr to MENUITEM
235;       ES:DI:  Ptr to destination buffer
236;   Returns:
237;       DI:     Updated
238;   Corrupts registers:
239;       AX, BX, CX
[293]240;--------------------------------------------------------------------
[57]241ALIGN JUMP_ALIGN
242MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI:
243    mov     bx, di
244    mov     cx, MAX_VALUE_STRING_LENGTH
245    CALL_DISPLAY_LIBRARY PushDisplayContext
246    CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
247
[65]248    call    Menuitem_GetValueToAXfromMenuitemInDSSI
[57]249    mov     bx, 10
[65]250    CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
[286]251    jmp     SHORT MenuitemPrint_FinishPrintingUnsignedOrHexValue
[57]252
253;--------------------------------------------------------------------
254; MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
255;   Parameters:
256;       DS:SI:  Ptr to MENUITEM
257;       ES:DI:  Ptr to destination buffer
258;   Returns:
259;       DI:     Updated
260;   Corrupts registers:
261;       AX, BX, CX
[293]262;--------------------------------------------------------------------
[57]263ALIGN JUMP_ALIGN
264MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI:
265    mov     bx, di
266    mov     cx, MAX_VALUE_STRING_LENGTH
267    CALL_DISPLAY_LIBRARY PushDisplayContext
268    CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
269
[65]270    call    Menuitem_GetValueToAXfromMenuitemInDSSI
[57]271    mov     bx, 16
272    CALL_DISPLAY_LIBRARY PrintWordFromAXwithBaseInBX
[65]273    mov     al, 'h'
274    CALL_DISPLAY_LIBRARY PrintCharacterFromAL
275ALIGN JUMP_ALIGN
[286]276MenuitemPrint_FinishPrintingUnsignedOrHexValue:
[57]277    CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
278    xchg    bx, ax
279
280    CALL_DISPLAY_LIBRARY PopDisplayContext
281    mov     di, bx
282    ret
283
284
285; Section containing initialized data
286SECTION .data
287
288ALIGN WORD_ALIGN
289g_rgszValueToStringLookupForFlagBooleans:
290    dw      g_szNo
291    dw      g_szYes
Note: See TracBrowser for help on using the repository browser.