[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
|
---|
[625] | 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2023 by XTIDE Universal BIOS Team.
|
---|
[376] | 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
|
---|
| 21 | SECTION .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 | ;--------------------------------------------------------------------
|
---|
| 32 | ALIGN JUMP_ALIGN
|
---|
| 33 | MenuitemPrint_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 | ;--------------------------------------------------------------------
|
---|
| 52 | ALIGN JUMP_ALIGN
|
---|
| 53 | MenuitemPrint_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 | ;--------------------------------------------------------------------
|
---|
| 98 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
| 116 | ALIGN 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 | ;--------------------------------------------------------------------
|
---|
| 138 | ALIGN 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
|
---|
[589] | 158 | ; MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI
|
---|
[59] | 159 | ; Parameters:
|
---|
| 160 | ; DS:SI: Ptr to MENUITEM
|
---|
| 161 | ; ES:DI: Ptr to destination buffer
|
---|
| 162 | ; Returns:
|
---|
| 163 | ; DI: Updated
|
---|
| 164 | ; Corrupts registers:
|
---|
| 165 | ; AX, BX, CX
|
---|
[293] | 166 | ;--------------------------------------------------------------------
|
---|
[59] | 167 | ALIGN JUMP_ALIGN
|
---|
| 168 | MenuitemPrint_WriteLookupValueStringToBufferInESDIfromUnshiftedItemInDSSI:
|
---|
| 169 | call Menuitem_GetValueToAXfromMenuitemInDSSI
|
---|
[592] | 170 | eSHL_IM ax, 1
|
---|
[59] | 171 | jmp SHORT PrintLookupValueFromAXtoBufferInESDI
|
---|
| 172 |
|
---|
| 173 | ALIGN JUMP_ALIGN
|
---|
| 174 | MenuitemPrint_WriteLookupValueStringToBufferInESDIfromShiftedItemInDSSI:
|
---|
[233] | 175 | MenuitemPrint_WriteLookupValueStringToBufferInESDIfromRawItemInDSSI:
|
---|
[59] | 176 | call Menuitem_GetValueToAXfromMenuitemInDSSI
|
---|
| 177 | ; Fall to PrintLookupValueFromAXtoBufferInESDI
|
---|
| 178 |
|
---|
| 179 | ;--------------------------------------------------------------------
|
---|
[589] | 180 | ; PrintLookupValueFromAXtoBufferInESDI
|
---|
[57] | 181 | ; Parameters:
|
---|
[59] | 182 | ; AX: Value to print
|
---|
[57] | 183 | ; DS:SI: Ptr to MENUITEM
|
---|
| 184 | ; ES:DI: Ptr to destination buffer
|
---|
| 185 | ; Returns:
|
---|
| 186 | ; DI: Updated
|
---|
| 187 | ; Corrupts registers:
|
---|
| 188 | ; AX, BX, CX
|
---|
[293] | 189 | ;--------------------------------------------------------------------
|
---|
[57] | 190 | ALIGN JUMP_ALIGN
|
---|
[59] | 191 | PrintLookupValueFromAXtoBufferInESDI:
|
---|
[57] | 192 | push si
|
---|
[589] | 193 | test BYTE [si+MENUITEM.bFlags], FLG_MENUITEM_CHOICESTRINGS
|
---|
| 194 | jnz SHORT .LookupChoice
|
---|
[293] | 195 |
|
---|
[57] | 196 | add ax, [si+MENUITEM.itemValue+ITEM_VALUE.rgszValueToStringLookup]
|
---|
| 197 | xchg bx, ax
|
---|
[589] | 198 | .Found:
|
---|
[57] | 199 | mov si, [bx]
|
---|
[589] | 200 | .ErrorReturn:
|
---|
[57] | 201 | call String_CopyDSSItoESDIandGetLengthToCX
|
---|
| 202 | pop si
|
---|
| 203 | ret
|
---|
| 204 |
|
---|
[233] | 205 | ;
|
---|
[293] | 206 | ; With FLG_MENUITEM_CHOICESTRINGS, the array at .rgszChoiceToStringLookup is based on the
|
---|
[233] | 207 | ; Choice number (offset within .rgwChoiceToValueLookup) instead of the value stored.
|
---|
| 208 | ; Here, we scan the .rgwChoiceToValueLookup array until we find the value there, and then
|
---|
[293] | 209 | ; use the same offset in .rgszChoiceToStringLookup. If we don't find the value, we
|
---|
| 210 | ; return an "Error!" string instead.
|
---|
[233] | 211 | ;
|
---|
| 212 | ; Note that the pointer array at .rgszChoiceToStringLookup must be NULL terminated. Since the
|
---|
| 213 | ; value could be zero, we don't use the .rgwChoiceToValueLookup array to find the end.
|
---|
| 214 | ;
|
---|
[589] | 215 | .LookupChoice:
|
---|
| 216 | mov bx, [si+MENUITEM.itemValue+ITEM_VALUE.rgszChoiceToStringLookup]
|
---|
| 217 | mov si, [si+MENUITEM.itemValue+ITEM_VALUE.rgwChoiceToValueLookup]
|
---|
[293] | 218 |
|
---|
[589] | 219 | .WordLoop:
|
---|
| 220 | cmp ax, [si]
|
---|
| 221 | je SHORT .Found
|
---|
[445] | 222 | inc bx
|
---|
| 223 | inc bx
|
---|
[233] | 224 | inc si
|
---|
| 225 | inc si
|
---|
[589] | 226 | cmp WORD [bx], 0
|
---|
| 227 | jne SHORT .WordLoop
|
---|
[57] | 228 |
|
---|
[589] | 229 | mov si, g_szValueUnknownError
|
---|
| 230 | jmp SHORT .ErrorReturn
|
---|
[233] | 231 |
|
---|
[57] | 232 | ;--------------------------------------------------------------------
|
---|
| 233 | ; MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI
|
---|
| 234 | ; Parameters:
|
---|
| 235 | ; DS:SI: Ptr to MENUITEM
|
---|
| 236 | ; ES:DI: Ptr to destination buffer
|
---|
| 237 | ; Returns:
|
---|
| 238 | ; DI: Updated
|
---|
| 239 | ; Corrupts registers:
|
---|
| 240 | ; AX, BX, CX
|
---|
[293] | 241 | ;--------------------------------------------------------------------
|
---|
[57] | 242 | ALIGN JUMP_ALIGN
|
---|
| 243 | MenuitemPrint_WriteUnsignedValueStringToBufferInESDIfromItemInDSSI:
|
---|
| 244 | mov bx, di
|
---|
| 245 | mov cx, MAX_VALUE_STRING_LENGTH
|
---|
| 246 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
| 247 | CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
|
---|
| 248 |
|
---|
[65] | 249 | call Menuitem_GetValueToAXfromMenuitemInDSSI
|
---|
[590] | 250 | mov bl, 10
|
---|
| 251 | CALL_DISPLAY_LIBRARY PrintWordFromAXWithBaseInBL
|
---|
[286] | 252 | jmp SHORT MenuitemPrint_FinishPrintingUnsignedOrHexValue
|
---|
[57] | 253 |
|
---|
| 254 | ;--------------------------------------------------------------------
|
---|
| 255 | ; MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI
|
---|
| 256 | ; Parameters:
|
---|
| 257 | ; DS:SI: Ptr to MENUITEM
|
---|
| 258 | ; ES:DI: Ptr to destination buffer
|
---|
| 259 | ; Returns:
|
---|
| 260 | ; DI: Updated
|
---|
| 261 | ; Corrupts registers:
|
---|
| 262 | ; AX, BX, CX
|
---|
[293] | 263 | ;--------------------------------------------------------------------
|
---|
[57] | 264 | ALIGN JUMP_ALIGN
|
---|
| 265 | MenuitemPrint_WriteHexValueStringToBufferInESDIfromItemInDSSI:
|
---|
[625] | 266 | ; Note! Changes to this procedure might require changes to
|
---|
| 267 | ; ReadRamVars in ConfigurationMenu.asm as well!
|
---|
[57] | 268 | mov bx, di
|
---|
| 269 | mov cx, MAX_VALUE_STRING_LENGTH
|
---|
| 270 | CALL_DISPLAY_LIBRARY PushDisplayContext
|
---|
| 271 | CALL_DISPLAY_LIBRARY PrepareOffScreenBufferInESBXwithLengthInCX
|
---|
| 272 |
|
---|
[65] | 273 | call Menuitem_GetValueToAXfromMenuitemInDSSI
|
---|
[590] | 274 | mov bl, 16
|
---|
| 275 | CALL_DISPLAY_LIBRARY PrintWordFromAXWithBaseInBL
|
---|
[65] | 276 | mov al, 'h'
|
---|
| 277 | CALL_DISPLAY_LIBRARY PrintCharacterFromAL
|
---|
| 278 | ALIGN JUMP_ALIGN
|
---|
[286] | 279 | MenuitemPrint_FinishPrintingUnsignedOrHexValue:
|
---|
[57] | 280 | CALL_DISPLAY_LIBRARY GetCharacterPointerToBXAX
|
---|
| 281 | xchg bx, ax
|
---|
| 282 |
|
---|
| 283 | CALL_DISPLAY_LIBRARY PopDisplayContext
|
---|
| 284 | mov di, bx
|
---|
| 285 | ret
|
---|
| 286 |
|
---|
| 287 |
|
---|
| 288 | ; Section containing initialized data
|
---|
| 289 | SECTION .data
|
---|
| 290 |
|
---|
| 291 | ALIGN WORD_ALIGN
|
---|
| 292 | g_rgszValueToStringLookupForFlagBooleans:
|
---|
| 293 | dw g_szNo
|
---|
| 294 | dw g_szYes
|
---|