[57] | 1 | ; Project name : XTIDE Universal BIOS Configurator v2 |
---|
| 2 | ; Description : Functions for accessing file and flash buffers. |
---|
| 3 | |
---|
| 4 | ; Section containing code |
---|
| 5 | SECTION .text |
---|
| 6 | |
---|
| 7 | ;-------------------------------------------------------------------- |
---|
| 8 | ; Buffers_Clear |
---|
| 9 | ; Parameters: |
---|
| 10 | ; Nothing |
---|
| 11 | ; Returns: |
---|
| 12 | ; Nothing |
---|
| 13 | ; Corrupts registers: |
---|
| 14 | ; AX, CX, DI, ES |
---|
| 15 | ;-------------------------------------------------------------------- |
---|
| 16 | ALIGN JUMP_ALIGN |
---|
| 17 | Buffers_Clear: |
---|
| 18 | call Buffers_GetFileBufferToESDI |
---|
| 19 | mov cx, ROMVARS_size |
---|
| 20 | jmp Memory_ZeroESDIwithSizeInCX |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; Buffers_IsXtideUniversalBiosLoaded |
---|
| 25 | ; Parameters: |
---|
| 26 | ; Nothing |
---|
| 27 | ; Returns: |
---|
| 28 | ; ZF: Set if supported version of XTIDE Universal BIOS is loaded |
---|
| 29 | ; Cleared no file or some other file is loaded |
---|
| 30 | ; Corrupts registers: |
---|
| 31 | ; CX, SI, DI, ES |
---|
| 32 | ;-------------------------------------------------------------------- |
---|
| 33 | ALIGN JUMP_ALIGN |
---|
| 34 | Buffers_IsXtideUniversalBiosLoaded: |
---|
| 35 | test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED |
---|
| 36 | jz SHORT .NoFileOrBiosLoaded |
---|
| 37 | |
---|
| 38 | call Buffers_GetFileBufferToESDI |
---|
[68] | 39 | jmp SHORT Buffers_IsXtideUniversalBiosSignatureInESDI |
---|
[57] | 40 | .NoFileOrBiosLoaded: |
---|
| 41 | or cl, 1 ; Clear ZF |
---|
| 42 | ret |
---|
| 43 | |
---|
| 44 | |
---|
| 45 | ;-------------------------------------------------------------------- |
---|
| 46 | ; Buffers_IsXtideUniversalBiosSignatureInESDI |
---|
| 47 | ; Parameters: |
---|
| 48 | ; ES:DI: Ptr to possible XTIDE Universal BIOS location |
---|
| 49 | ; Returns: |
---|
| 50 | ; ZF: Set if supported version of XTIDE Universal BIOS is loaded |
---|
| 51 | ; Cleared no file or some other file is loaded |
---|
| 52 | ; Corrupts registers: |
---|
| 53 | ; CX, SI |
---|
| 54 | ;-------------------------------------------------------------------- |
---|
| 55 | ALIGN JUMP_ALIGN |
---|
| 56 | Buffers_IsXtideUniversalBiosSignatureInESDI: |
---|
| 57 | push di |
---|
| 58 | |
---|
| 59 | mov si, g_szXtideUniversalBiosSignature |
---|
| 60 | add di, BYTE ROMVARS.rgbSign |
---|
| 61 | mov cx, XTIDE_SIGNATURE_LENGTH / 2 |
---|
| 62 | cld |
---|
| 63 | eSEG_STR repe, cs, cmpsw |
---|
| 64 | |
---|
| 65 | pop di |
---|
| 66 | ret |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | ;-------------------------------------------------------------------- |
---|
[145] | 70 | ; Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration |
---|
[57] | 71 | ; Parameters: |
---|
| 72 | ; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED) |
---|
[68] | 73 | ; DX:CX: EEPROM size in bytes |
---|
[57] | 74 | ; Returns: |
---|
| 75 | ; Nothing |
---|
| 76 | ; Corrupts registers: |
---|
[68] | 77 | ; AX, CX, DX |
---|
[57] | 78 | ;-------------------------------------------------------------------- |
---|
| 79 | ALIGN JUMP_ALIGN |
---|
[68] | 80 | Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration: |
---|
[57] | 81 | and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED) |
---|
| 82 | or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax |
---|
[68] | 83 | shr dx, 1 |
---|
| 84 | rcr cx, 1 |
---|
[144] | 85 | adc cx, BYTE 0 ; Round up to next WORD |
---|
[65] | 86 | mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx |
---|
[57] | 87 | ret |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | ;-------------------------------------------------------------------- |
---|
| 91 | ; Buffers_SetUnsavedChanges |
---|
| 92 | ; Buffers_ClearUnsavedChanges |
---|
| 93 | ; Parameters: |
---|
| 94 | ; SS:BP: Menu handle |
---|
| 95 | ; Returns: |
---|
| 96 | ; Nothing |
---|
| 97 | ; Corrupts registers: |
---|
| 98 | ; Nothing |
---|
| 99 | ;-------------------------------------------------------------------- |
---|
| 100 | ALIGN JUMP_ALIGN |
---|
| 101 | Buffers_SetUnsavedChanges: |
---|
| 102 | or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED |
---|
| 103 | ret |
---|
| 104 | |
---|
| 105 | ALIGN JUMP_ALIGN |
---|
| 106 | Buffers_ClearUnsavedChanges: |
---|
| 107 | and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED |
---|
| 108 | ret |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | ;-------------------------------------------------------------------- |
---|
[59] | 112 | ; Buffers_SaveChangesIfFileLoaded |
---|
| 113 | ; Parameters: |
---|
| 114 | ; Nothing |
---|
| 115 | ; Returns: |
---|
| 116 | ; Nothing |
---|
| 117 | ; Corrupts registers: |
---|
| 118 | ; AX, BX, CX, SI, DI |
---|
| 119 | ;-------------------------------------------------------------------- |
---|
| 120 | ALIGN JUMP_ALIGN |
---|
| 121 | Buffers_SaveChangesIfFileLoaded: |
---|
| 122 | mov ax, [cs:g_cfgVars+CFGVARS.wFlags] |
---|
| 123 | and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED) |
---|
| 124 | cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED) |
---|
| 125 | jne SHORT .NothingToSave |
---|
| 126 | call Dialogs_DisplaySaveChangesDialog |
---|
| 127 | jnz SHORT .NothingToSave |
---|
| 128 | jmp BiosFile_SaveUnsavedChanges |
---|
| 129 | ALIGN JUMP_ALIGN |
---|
| 130 | .NothingToSave: |
---|
| 131 | ret |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | ;-------------------------------------------------------------------- |
---|
[65] | 135 | ; Buffers_AppendZeroesIfNeeded |
---|
| 136 | ; Parameters: |
---|
| 137 | ; Nothing |
---|
| 138 | ; Returns: |
---|
| 139 | ; Nothing |
---|
| 140 | ; Corrupts registers: |
---|
| 141 | ; AX, CX, DI |
---|
| 142 | ;-------------------------------------------------------------------- |
---|
| 143 | ALIGN JUMP_ALIGN |
---|
| 144 | Buffers_AppendZeroesIfNeeded: |
---|
| 145 | push es |
---|
| 146 | |
---|
| 147 | eMOVZX di, BYTE [cs:g_cfgVars+CFGVARS.bEepromType] |
---|
| 148 | mov cx, [cs:di+g_rgwEepromTypeToSizeInWords] |
---|
| 149 | sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append |
---|
| 150 | jle SHORT .NoNeedToAppendZeroes |
---|
| 151 | |
---|
| 152 | call Buffers_GetFileBufferToESDI |
---|
| 153 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] |
---|
| 154 | shl ax, 1 |
---|
| 155 | add di, ax ; ES:DI now point first unused image byte |
---|
| 156 | xor ax, ax |
---|
| 157 | cld |
---|
| 158 | rep stosw |
---|
| 159 | ALIGN JUMP_ALIGN |
---|
| 160 | .NoNeedToAppendZeroes: |
---|
| 161 | pop es |
---|
| 162 | ret |
---|
| 163 | |
---|
| 164 | |
---|
| 165 | ;-------------------------------------------------------------------- |
---|
[57] | 166 | ; Buffers_GenerateChecksum |
---|
| 167 | ; Parameters: |
---|
| 168 | ; Nothing |
---|
| 169 | ; Returns: |
---|
| 170 | ; Nothing |
---|
| 171 | ; Corrupts registers: |
---|
| 172 | ; AX, BX, CX, DI |
---|
| 173 | ;-------------------------------------------------------------------- |
---|
| 174 | ALIGN JUMP_ALIGN |
---|
| 175 | Buffers_GenerateChecksum: |
---|
| 176 | push es |
---|
| 177 | |
---|
| 178 | call Buffers_GetFileBufferToESDI |
---|
[118] | 179 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] |
---|
| 180 | call EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX |
---|
[65] | 181 | shl cx, 1 ; Words to bytes |
---|
[57] | 182 | dec cx ; Leave space for checksum byte |
---|
| 183 | xor ax, ax |
---|
| 184 | ALIGN JUMP_ALIGN |
---|
| 185 | .SumNextByte: |
---|
| 186 | add al, [es:di] |
---|
| 187 | inc di |
---|
| 188 | loop .SumNextByte |
---|
| 189 | neg al |
---|
| 190 | mov [es:di], al |
---|
| 191 | |
---|
| 192 | pop es |
---|
| 193 | ret |
---|
| 194 | |
---|
| 195 | |
---|
| 196 | ;-------------------------------------------------------------------- |
---|
[59] | 197 | ; Buffers_GetRomvarsFlagsToAX |
---|
| 198 | ; Parameters: |
---|
| 199 | ; Nothing |
---|
| 200 | ; Returns: |
---|
| 201 | ; AX: ROMVARS.wFlags |
---|
| 202 | ; Corrupts registers: |
---|
| 203 | ; BX |
---|
| 204 | ;-------------------------------------------------------------------- |
---|
| 205 | ALIGN JUMP_ALIGN |
---|
| 206 | Buffers_GetRomvarsFlagsToAX: |
---|
| 207 | mov bx, ROMVARS.wFlags |
---|
| 208 | ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX |
---|
| 209 | |
---|
| 210 | ;-------------------------------------------------------------------- |
---|
[57] | 211 | ; Buffers_GetRomvarsValueToAXfromOffsetInBX |
---|
| 212 | ; Parameters: |
---|
| 213 | ; BX: ROMVARS offset |
---|
| 214 | ; Returns: |
---|
| 215 | ; AX: Value |
---|
| 216 | ; Corrupts registers: |
---|
| 217 | ; Nothing |
---|
| 218 | ;-------------------------------------------------------------------- |
---|
| 219 | ALIGN JUMP_ALIGN |
---|
| 220 | Buffers_GetRomvarsValueToAXfromOffsetInBX: |
---|
| 221 | push es |
---|
| 222 | push di |
---|
| 223 | call Buffers_GetFileBufferToESDI |
---|
| 224 | mov ax, [es:bx+di] |
---|
| 225 | pop di |
---|
| 226 | pop es |
---|
| 227 | ret |
---|
| 228 | |
---|
| 229 | |
---|
| 230 | ;-------------------------------------------------------------------- |
---|
[204] | 231 | ; Buffers_GetIdeControllerCountToCX |
---|
| 232 | ; Parameters: |
---|
| 233 | ; SS:BP: Menu handle |
---|
| 234 | ; Returns: |
---|
| 235 | ; CX: Number of IDE controllers to configure |
---|
| 236 | ; ES:DI: Ptr to file buffer |
---|
| 237 | ; Corrupts registers: |
---|
| 238 | ; AX |
---|
| 239 | ;-------------------------------------------------------------------- |
---|
| 240 | ALIGN JUMP_ALIGN |
---|
| 241 | Buffers_GetIdeControllerCountToCX: |
---|
| 242 | call Buffers_GetFileBufferToESDI |
---|
| 243 | mov al, [es:di+ROMVARS.bIdeCnt] |
---|
| 244 | |
---|
| 245 | ; Limit controller count for lite mode |
---|
| 246 | test BYTE [es:di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE |
---|
| 247 | jnz SHORT .ReturnControllerCountInCX |
---|
| 248 | MIN_U al, MAX_LITE_MODE_CONTROLLERS |
---|
| 249 | |
---|
| 250 | .ReturnControllerCountInCX: |
---|
| 251 | cbw ; A maximum of 127 controllers should be sufficient |
---|
| 252 | xchg cx, ax |
---|
| 253 | ret |
---|
| 254 | |
---|
| 255 | |
---|
| 256 | ;-------------------------------------------------------------------- |
---|
[57] | 257 | ; Buffers_GetFileBufferToESDI |
---|
[65] | 258 | ; Buffers_GetFlashComparisonBufferToESDI |
---|
[57] | 259 | ; Buffers_GetFileDialogItemBufferToESDI |
---|
| 260 | ; Parameters: |
---|
| 261 | ; Nothing |
---|
| 262 | ; Returns: |
---|
| 263 | ; ES:DI: Ptr to file buffer |
---|
| 264 | ; Corrupts registers: |
---|
| 265 | ; Nothing |
---|
| 266 | ;-------------------------------------------------------------------- |
---|
| 267 | ALIGN JUMP_ALIGN |
---|
[65] | 268 | Buffers_GetFlashComparisonBufferToESDI: |
---|
[57] | 269 | Buffers_GetFileDialogItemBufferToESDI: |
---|
[59] | 270 | call Buffers_GetFileBufferToESDI |
---|
| 271 | push di |
---|
| 272 | mov di, es |
---|
| 273 | add di, 1000h ; Third 64k page |
---|
| 274 | mov es, di |
---|
| 275 | pop di |
---|
| 276 | ret |
---|
[65] | 277 | ALIGN JUMP_ALIGN |
---|
[57] | 278 | Buffers_GetFileBufferToESDI: |
---|
| 279 | mov di, cs |
---|
| 280 | add di, 1000h ; Change to next 64k page |
---|
| 281 | mov es, di |
---|
| 282 | xor di, di ; Ptr now in ES:DI |
---|
| 283 | ret |
---|