[57] | 1 | ; Project name : XTIDE Univeral BIOS Configurator v2
|
---|
| 2 | ; Description : Functions for loading and saving BIOS image file.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
| 8 | ; BiosFile_LoadFileFromDSSItoRamBuffer
|
---|
| 9 | ; Parameters:
|
---|
| 10 | ; DS:SI: Name of file to open
|
---|
| 11 | ; SS:BP: Menu handle
|
---|
| 12 | ; Returns:
|
---|
| 13 | ; Nothing
|
---|
| 14 | ; Corrupts registers:
|
---|
| 15 | ; AX, BX, CX, DX, SI, DI
|
---|
| 16 | ;--------------------------------------------------------------------
|
---|
| 17 | ALIGN JUMP_ALIGN
|
---|
| 18 | BiosFile_LoadFileFromDSSItoRamBuffer:
|
---|
| 19 | push ds
|
---|
| 20 |
|
---|
[68] | 21 | call .OpenFileForLoadingFromDSSIandGetSizeToDXCX
|
---|
[57] | 22 | jc SHORT .DisplayErrorMessage
|
---|
[68] | 23 | call .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
|
---|
[57] | 24 | jc SHORT .DisplayErrorMessage
|
---|
| 25 |
|
---|
| 26 | mov ax, FLG_CFGVARS_FILELOADED
|
---|
[68] | 27 | call Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
|
---|
[136] | 28 | call FileIO_CloseUsingHandleFromBX
|
---|
[57] | 29 | call DisplayFileLoadedSuccesfully
|
---|
| 30 | jmp SHORT .Return
|
---|
| 31 |
|
---|
| 32 | .DisplayErrorMessage:
|
---|
| 33 | call FileIO_CloseUsingHandleFromBX
|
---|
| 34 | call DisplayFailedToLoadFile
|
---|
| 35 | ALIGN JUMP_ALIGN
|
---|
| 36 | .Return:
|
---|
| 37 | pop ds
|
---|
| 38 | ret
|
---|
| 39 |
|
---|
| 40 | ;--------------------------------------------------------------------
|
---|
[68] | 41 | ; .OpenFileForLoadingFromDSSIandGetSizeInBytesToDXCX
|
---|
[57] | 42 | ; Parameters:
|
---|
| 43 | ; DS:SI: Name of file to open
|
---|
| 44 | ; Returns:
|
---|
| 45 | ; BX: File handle (if succesfull)
|
---|
[68] | 46 | ; DX:CX: File size (if succesfull)
|
---|
[57] | 47 | ; CF: Clear if successfull
|
---|
| 48 | ; Set if error
|
---|
| 49 | ; Corrupts registers:
|
---|
[68] | 50 | ; AX
|
---|
[57] | 51 | ;--------------------------------------------------------------------
|
---|
| 52 | ALIGN JUMP_ALIGN
|
---|
[68] | 53 | .OpenFileForLoadingFromDSSIandGetSizeToDXCX:
|
---|
[57] | 54 | mov al, FILE_ACCESS.ReadOnly
|
---|
| 55 | call FileIO_OpenWithPathInDSSIandFileAccessInAL
|
---|
| 56 | jc SHORT .FileError
|
---|
| 57 | call FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
|
---|
| 58 | jc SHORT .FileError
|
---|
| 59 |
|
---|
[68] | 60 | cmp dx, MAX_EEPROM_SIZE_IN_BYTES >> 16
|
---|
[57] | 61 | ja SHORT .FileTooBig
|
---|
[68] | 62 | jb SHORT .FileNotTooBig
|
---|
| 63 | cmp ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh
|
---|
| 64 | ja SHORT .FileTooBig
|
---|
| 65 | .FileNotTooBig:
|
---|
[57] | 66 | xchg cx, ax
|
---|
| 67 | clc
|
---|
| 68 | ret
|
---|
| 69 | .FileTooBig:
|
---|
| 70 | call DisplayFileTooBig
|
---|
| 71 | stc
|
---|
| 72 | .FileError:
|
---|
| 73 | ret
|
---|
| 74 |
|
---|
| 75 | ;--------------------------------------------------------------------
|
---|
[68] | 76 | ; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
|
---|
[57] | 77 | ; Parameters:
|
---|
| 78 | ; BX: File Handle
|
---|
[68] | 79 | ; DX:CX: File size
|
---|
[57] | 80 | ; DS:SI: File name
|
---|
| 81 | ; Returns:
|
---|
| 82 | ; CF: Clear if successfull
|
---|
| 83 | ; Set if error
|
---|
| 84 | ; Corrupts registers:
|
---|
| 85 | ; AX, SI, DI, DS
|
---|
| 86 | ;--------------------------------------------------------------------
|
---|
| 87 | ALIGN JUMP_ALIGN
|
---|
[68] | 88 | .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer:
|
---|
[57] | 89 | push es
|
---|
| 90 |
|
---|
| 91 | call Buffers_GetFileBufferToESDI
|
---|
| 92 | call Registers_ExchangeDSSIwithESDI
|
---|
[68] | 93 | call FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
|
---|
[57] | 94 | jnc SHORT .StoreFileNameToCfgvarsFromESDI
|
---|
| 95 |
|
---|
| 96 | pop es
|
---|
| 97 | ret
|
---|
| 98 |
|
---|
| 99 | ALIGN JUMP_ALIGN
|
---|
| 100 | .StoreFileNameToCfgvarsFromESDI:
|
---|
| 101 | push cx
|
---|
| 102 |
|
---|
[107] | 103 | call Registers_CopyESDItoDSSI ; File name in DS:SI
|
---|
[57] | 104 | push cs
|
---|
| 105 | pop es
|
---|
| 106 | mov di, g_cfgVars+CFGVARS.szOpenedFile
|
---|
| 107 | cld
|
---|
| 108 | call String_CopyDSSItoESDIandGetLengthToCX
|
---|
| 109 |
|
---|
| 110 | pop cx
|
---|
| 111 | pop es
|
---|
| 112 | clc
|
---|
| 113 | ret
|
---|
| 114 |
|
---|
| 115 |
|
---|
| 116 | ;--------------------------------------------------------------------
|
---|
| 117 | ; BiosFile_SaveUnsavedChanges
|
---|
| 118 | ; Parameters:
|
---|
| 119 | ; SS:BP: Menu handle
|
---|
| 120 | ; Returns:
|
---|
| 121 | ; Nothing
|
---|
| 122 | ; Corrupts registers:
|
---|
| 123 | ; AX, BX, CX, SI, DI
|
---|
| 124 | ;--------------------------------------------------------------------
|
---|
| 125 | ALIGN JUMP_ALIGN
|
---|
| 126 | BiosFile_SaveUnsavedChanges:
|
---|
| 127 | push ds
|
---|
| 128 |
|
---|
| 129 | push cs
|
---|
| 130 | pop ds
|
---|
| 131 | mov si, g_cfgVars+CFGVARS.szOpenedFile
|
---|
| 132 | call BiosFile_SaveRamBufferToFileInDSSI
|
---|
| 133 |
|
---|
| 134 | pop ds
|
---|
| 135 | ret
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | ;--------------------------------------------------------------------
|
---|
| 139 | ; BiosFile_SaveRamBufferToFileInDSSI
|
---|
| 140 | ; Parameters:
|
---|
| 141 | ; DS:SI: Name of file to save
|
---|
| 142 | ; SS:BP: Menu handle
|
---|
| 143 | ; Returns:
|
---|
| 144 | ; Nothing
|
---|
| 145 | ; Corrupts registers:
|
---|
| 146 | ; AX, BX, CX, SI, DI
|
---|
| 147 | ;--------------------------------------------------------------------
|
---|
| 148 | ALIGN JUMP_ALIGN
|
---|
| 149 | BiosFile_SaveRamBufferToFileInDSSI:
|
---|
| 150 | push es
|
---|
| 151 | push ds
|
---|
| 152 |
|
---|
| 153 | call Buffers_GenerateChecksum
|
---|
| 154 | call Buffers_GetFileBufferToESDI
|
---|
[118] | 155 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
| 156 | call EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX
|
---|
[68] | 157 | xor dx, dx
|
---|
[65] | 158 | shl cx, 1
|
---|
[138] | 159 | rcl dx, 1 ; WORDs to BYTEs
|
---|
| 160 |
|
---|
| 161 | mov al, FILE_ACCESS.WriteOnly
|
---|
| 162 | call FileIO_OpenWithPathInDSSIandFileAccessInAL
|
---|
| 163 | jc SHORT .DisplayErrorMessage
|
---|
| 164 |
|
---|
| 165 | call Registers_CopyESDItoDSSI
|
---|
[68] | 166 | call FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
|
---|
[57] | 167 | jc SHORT .DisplayErrorMessage
|
---|
| 168 |
|
---|
[136] | 169 | call FileIO_CloseUsingHandleFromBX
|
---|
[57] | 170 | call Buffers_ClearUnsavedChanges
|
---|
| 171 | call DisplayFileSavedSuccesfully
|
---|
| 172 | jmp SHORT .Return
|
---|
| 173 |
|
---|
| 174 | .DisplayErrorMessage:
|
---|
| 175 | call FileIO_CloseUsingHandleFromBX
|
---|
| 176 | call DisplayFailedToSaveFile
|
---|
| 177 | ALIGN JUMP_ALIGN
|
---|
| 178 | .Return:
|
---|
| 179 | pop ds
|
---|
| 180 | pop es
|
---|
| 181 | ret
|
---|
| 182 |
|
---|
| 183 |
|
---|
| 184 | ;--------------------------------------------------------------------
|
---|
| 185 | ; DisplayFileLoadedSuccesfully
|
---|
| 186 | ; DisplayFileSavedSuccesfully
|
---|
| 187 | ; DisplayFailedToLoadFile
|
---|
| 188 | ; DisplayFailedToSaveFile
|
---|
| 189 | ; DisplayFileTooBig
|
---|
| 190 | ; Parameters:
|
---|
| 191 | ; SS:BP: Menu handle
|
---|
| 192 | ; Returns:
|
---|
| 193 | ; Nothing
|
---|
| 194 | ; Corrupts registers:
|
---|
| 195 | ; AX, DX
|
---|
| 196 | ;--------------------------------------------------------------------
|
---|
| 197 | ALIGN JUMP_ALIGN
|
---|
| 198 | DisplayFileLoadedSuccesfully:
|
---|
| 199 | mov dx, g_szDlgMainLoadFile
|
---|
| 200 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|
| 201 |
|
---|
| 202 | ALIGN JUMP_ALIGN
|
---|
| 203 | DisplayFileSavedSuccesfully:
|
---|
| 204 | mov dx, g_szDlgMainSaveFile
|
---|
| 205 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|
| 206 |
|
---|
| 207 | DisplayFailedToLoadFile:
|
---|
| 208 | mov dx, g_szDlgMainLoadErr
|
---|
| 209 | jmp Dialogs_DisplayErrorFromCSDX
|
---|
| 210 |
|
---|
| 211 | DisplayFailedToSaveFile:
|
---|
| 212 | mov dx, g_szDlgMainSaveErr
|
---|
| 213 | jmp Dialogs_DisplayErrorFromCSDX
|
---|
| 214 |
|
---|
| 215 | DisplayFileTooBig:
|
---|
| 216 | mov dx, g_szDlgMainFileTooBig
|
---|
| 217 | jmp Dialogs_DisplayErrorFromCSDX
|
---|