[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 | ;-------------------------------------------------------------------- |
---|
| 70 | ; Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration |
---|
| 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 |
---|
[65] | 85 | mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx |
---|
[57] | 86 | ret |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | ;-------------------------------------------------------------------- |
---|
| 90 | ; Buffers_SetUnsavedChanges |
---|
| 91 | ; Buffers_ClearUnsavedChanges |
---|
| 92 | ; Parameters: |
---|
| 93 | ; SS:BP: Menu handle |
---|
| 94 | ; Returns: |
---|
| 95 | ; Nothing |
---|
| 96 | ; Corrupts registers: |
---|
| 97 | ; Nothing |
---|
| 98 | ;-------------------------------------------------------------------- |
---|
| 99 | ALIGN JUMP_ALIGN |
---|
| 100 | Buffers_SetUnsavedChanges: |
---|
| 101 | or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED |
---|
| 102 | ret |
---|
| 103 | |
---|
| 104 | ALIGN JUMP_ALIGN |
---|
| 105 | Buffers_ClearUnsavedChanges: |
---|
| 106 | and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED |
---|
| 107 | ret |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | ;-------------------------------------------------------------------- |
---|
[59] | 111 | ; Buffers_SaveChangesIfFileLoaded |
---|
| 112 | ; Parameters: |
---|
| 113 | ; Nothing |
---|
| 114 | ; Returns: |
---|
| 115 | ; Nothing |
---|
| 116 | ; Corrupts registers: |
---|
| 117 | ; AX, BX, CX, SI, DI |
---|
| 118 | ;-------------------------------------------------------------------- |
---|
| 119 | ALIGN JUMP_ALIGN |
---|
| 120 | Buffers_SaveChangesIfFileLoaded: |
---|
| 121 | mov ax, [cs:g_cfgVars+CFGVARS.wFlags] |
---|
| 122 | and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED) |
---|
| 123 | cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED) |
---|
| 124 | jne SHORT .NothingToSave |
---|
| 125 | call Dialogs_DisplaySaveChangesDialog |
---|
| 126 | jnz SHORT .NothingToSave |
---|
| 127 | jmp BiosFile_SaveUnsavedChanges |
---|
| 128 | ALIGN JUMP_ALIGN |
---|
| 129 | .NothingToSave: |
---|
| 130 | ret |
---|
| 131 | |
---|
| 132 | |
---|
| 133 | ;-------------------------------------------------------------------- |
---|
[65] | 134 | ; Buffers_AppendZeroesIfNeeded |
---|
| 135 | ; Parameters: |
---|
| 136 | ; Nothing |
---|
| 137 | ; Returns: |
---|
| 138 | ; Nothing |
---|
| 139 | ; Corrupts registers: |
---|
| 140 | ; AX, CX, DI |
---|
| 141 | ;-------------------------------------------------------------------- |
---|
| 142 | ALIGN JUMP_ALIGN |
---|
| 143 | Buffers_AppendZeroesIfNeeded: |
---|
| 144 | push es |
---|
| 145 | |
---|
| 146 | eMOVZX di, BYTE [cs:g_cfgVars+CFGVARS.bEepromType] |
---|
| 147 | mov cx, [cs:di+g_rgwEepromTypeToSizeInWords] |
---|
| 148 | sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append |
---|
| 149 | jle SHORT .NoNeedToAppendZeroes |
---|
| 150 | |
---|
| 151 | call Buffers_GetFileBufferToESDI |
---|
| 152 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] |
---|
| 153 | shl ax, 1 |
---|
| 154 | add di, ax ; ES:DI now point first unused image byte |
---|
| 155 | xor ax, ax |
---|
| 156 | cld |
---|
| 157 | rep stosw |
---|
| 158 | ALIGN JUMP_ALIGN |
---|
| 159 | .NoNeedToAppendZeroes: |
---|
| 160 | pop es |
---|
| 161 | ret |
---|
| 162 | |
---|
| 163 | |
---|
| 164 | ;-------------------------------------------------------------------- |
---|
[57] | 165 | ; Buffers_GenerateChecksum |
---|
| 166 | ; Parameters: |
---|
| 167 | ; Nothing |
---|
| 168 | ; Returns: |
---|
| 169 | ; Nothing |
---|
| 170 | ; Corrupts registers: |
---|
| 171 | ; AX, BX, CX, DI |
---|
| 172 | ;-------------------------------------------------------------------- |
---|
| 173 | ALIGN JUMP_ALIGN |
---|
| 174 | Buffers_GenerateChecksum: |
---|
| 175 | push es |
---|
| 176 | |
---|
| 177 | call Buffers_GetFileBufferToESDI |
---|
[118] | 178 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] |
---|
| 179 | call EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX |
---|
[65] | 180 | shl cx, 1 ; Words to bytes |
---|
[57] | 181 | dec cx ; Leave space for checksum byte |
---|
| 182 | xor ax, ax |
---|
| 183 | ALIGN JUMP_ALIGN |
---|
| 184 | .SumNextByte: |
---|
| 185 | add al, [es:di] |
---|
| 186 | inc di |
---|
| 187 | loop .SumNextByte |
---|
| 188 | neg al |
---|
| 189 | mov [es:di], al |
---|
| 190 | |
---|
| 191 | pop es |
---|
| 192 | ret |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | ;-------------------------------------------------------------------- |
---|
[59] | 196 | ; Buffers_GetRomvarsFlagsToAX |
---|
| 197 | ; Parameters: |
---|
| 198 | ; Nothing |
---|
| 199 | ; Returns: |
---|
| 200 | ; AX: ROMVARS.wFlags |
---|
| 201 | ; Corrupts registers: |
---|
| 202 | ; BX |
---|
| 203 | ;-------------------------------------------------------------------- |
---|
| 204 | ALIGN JUMP_ALIGN |
---|
| 205 | Buffers_GetRomvarsFlagsToAX: |
---|
| 206 | mov bx, ROMVARS.wFlags |
---|
| 207 | ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX |
---|
| 208 | |
---|
| 209 | ;-------------------------------------------------------------------- |
---|
[57] | 210 | ; Buffers_GetRomvarsValueToAXfromOffsetInBX |
---|
| 211 | ; Parameters: |
---|
| 212 | ; BX: ROMVARS offset |
---|
| 213 | ; Returns: |
---|
| 214 | ; AX: Value |
---|
| 215 | ; Corrupts registers: |
---|
| 216 | ; Nothing |
---|
| 217 | ;-------------------------------------------------------------------- |
---|
| 218 | ALIGN JUMP_ALIGN |
---|
| 219 | Buffers_GetRomvarsValueToAXfromOffsetInBX: |
---|
| 220 | push es |
---|
| 221 | push di |
---|
| 222 | call Buffers_GetFileBufferToESDI |
---|
| 223 | mov ax, [es:bx+di] |
---|
| 224 | pop di |
---|
| 225 | pop es |
---|
| 226 | ret |
---|
| 227 | |
---|
| 228 | |
---|
| 229 | ;-------------------------------------------------------------------- |
---|
| 230 | ; Buffers_GetFileBufferToESDI |
---|
[65] | 231 | ; Buffers_GetFlashComparisonBufferToESDI |
---|
[57] | 232 | ; Buffers_GetFileDialogItemBufferToESDI |
---|
| 233 | ; Parameters: |
---|
| 234 | ; Nothing |
---|
| 235 | ; Returns: |
---|
| 236 | ; ES:DI: Ptr to file buffer |
---|
| 237 | ; Corrupts registers: |
---|
| 238 | ; Nothing |
---|
| 239 | ;-------------------------------------------------------------------- |
---|
| 240 | ALIGN JUMP_ALIGN |
---|
[65] | 241 | Buffers_GetFlashComparisonBufferToESDI: |
---|
[57] | 242 | Buffers_GetFileDialogItemBufferToESDI: |
---|
[59] | 243 | call Buffers_GetFileBufferToESDI |
---|
| 244 | push di |
---|
| 245 | mov di, es |
---|
| 246 | add di, 1000h ; Third 64k page |
---|
| 247 | mov es, di |
---|
| 248 | pop di |
---|
| 249 | ret |
---|
[65] | 250 | ALIGN JUMP_ALIGN |
---|
[57] | 251 | Buffers_GetFileBufferToESDI: |
---|
| 252 | mov di, cs |
---|
| 253 | add di, 1000h ; Change to next 64k page |
---|
| 254 | mov es, di |
---|
| 255 | xor di, di ; Ptr now in ES:DI |
---|
| 256 | ret |
---|