[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
|
---|
[293] | 29 | call DisplayFileLoadedSuccessfully
|
---|
[57] | 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:
|
---|
[293] | 45 | ; BX: File handle (if successful)
|
---|
| 46 | ; DX:CX: File size (if successful)
|
---|
| 47 | ; CF: Clear if successful
|
---|
[57] | 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:
|
---|
[293] | 82 | ; CF: Clear if successful
|
---|
[57] | 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
|
---|
[181] | 94 | jc SHORT .ReturnError
|
---|
[57] | 95 |
|
---|
[181] | 96 | ; Store filename to Cfgvars from ESDI
|
---|
[57] | 97 | push cx
|
---|
| 98 |
|
---|
[107] | 99 | call Registers_CopyESDItoDSSI ; File name in DS:SI
|
---|
[57] | 100 | push cs
|
---|
| 101 | pop es
|
---|
| 102 | mov di, g_cfgVars+CFGVARS.szOpenedFile
|
---|
| 103 | cld
|
---|
| 104 | call String_CopyDSSItoESDIandGetLengthToCX
|
---|
[181] | 105 | clc
|
---|
[57] | 106 |
|
---|
| 107 | pop cx
|
---|
[181] | 108 | ALIGN JUMP_ALIGN
|
---|
| 109 | .ReturnError:
|
---|
[57] | 110 | pop es
|
---|
| 111 | ret
|
---|
| 112 |
|
---|
| 113 |
|
---|
| 114 | ;--------------------------------------------------------------------
|
---|
| 115 | ; BiosFile_SaveUnsavedChanges
|
---|
| 116 | ; Parameters:
|
---|
| 117 | ; SS:BP: Menu handle
|
---|
| 118 | ; Returns:
|
---|
| 119 | ; Nothing
|
---|
| 120 | ; Corrupts registers:
|
---|
| 121 | ; AX, BX, CX, SI, DI
|
---|
| 122 | ;--------------------------------------------------------------------
|
---|
| 123 | ALIGN JUMP_ALIGN
|
---|
| 124 | BiosFile_SaveUnsavedChanges:
|
---|
| 125 | push ds
|
---|
| 126 |
|
---|
| 127 | push cs
|
---|
| 128 | pop ds
|
---|
| 129 | mov si, g_cfgVars+CFGVARS.szOpenedFile
|
---|
| 130 | call BiosFile_SaveRamBufferToFileInDSSI
|
---|
| 131 |
|
---|
| 132 | pop ds
|
---|
| 133 | ret
|
---|
| 134 |
|
---|
| 135 |
|
---|
| 136 | ;--------------------------------------------------------------------
|
---|
| 137 | ; BiosFile_SaveRamBufferToFileInDSSI
|
---|
| 138 | ; Parameters:
|
---|
| 139 | ; DS:SI: Name of file to save
|
---|
| 140 | ; SS:BP: Menu handle
|
---|
| 141 | ; Returns:
|
---|
| 142 | ; Nothing
|
---|
| 143 | ; Corrupts registers:
|
---|
| 144 | ; AX, BX, CX, SI, DI
|
---|
| 145 | ;--------------------------------------------------------------------
|
---|
| 146 | ALIGN JUMP_ALIGN
|
---|
| 147 | BiosFile_SaveRamBufferToFileInDSSI:
|
---|
| 148 | push es
|
---|
| 149 | push ds
|
---|
| 150 |
|
---|
| 151 | call Buffers_GenerateChecksum
|
---|
| 152 | call Buffers_GetFileBufferToESDI
|
---|
[118] | 153 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
| 154 | call EEPROM_GetSmallestEepromSizeInWordsToCXforImageWithWordSizeInAX
|
---|
[68] | 155 | xor dx, dx
|
---|
[65] | 156 | shl cx, 1
|
---|
[181] | 157 | rcl dx, 1 ; WORDs to BYTEs
|
---|
[138] | 158 |
|
---|
| 159 | mov al, FILE_ACCESS.WriteOnly
|
---|
| 160 | call FileIO_OpenWithPathInDSSIandFileAccessInAL
|
---|
| 161 | jc SHORT .DisplayErrorMessage
|
---|
| 162 |
|
---|
| 163 | call Registers_CopyESDItoDSSI
|
---|
[68] | 164 | call FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
|
---|
[57] | 165 | jc SHORT .DisplayErrorMessage
|
---|
| 166 |
|
---|
[136] | 167 | call FileIO_CloseUsingHandleFromBX
|
---|
[57] | 168 | call Buffers_ClearUnsavedChanges
|
---|
[293] | 169 | call DisplayFileSavedSuccessfully
|
---|
[57] | 170 | jmp SHORT .Return
|
---|
| 171 |
|
---|
| 172 | .DisplayErrorMessage:
|
---|
| 173 | call FileIO_CloseUsingHandleFromBX
|
---|
| 174 | call DisplayFailedToSaveFile
|
---|
| 175 | ALIGN JUMP_ALIGN
|
---|
| 176 | .Return:
|
---|
| 177 | pop ds
|
---|
| 178 | pop es
|
---|
| 179 | ret
|
---|
| 180 |
|
---|
| 181 |
|
---|
| 182 | ;--------------------------------------------------------------------
|
---|
[293] | 183 | ; DisplayFileLoadedSuccessfully
|
---|
| 184 | ; DisplayFileSavedSuccessfully
|
---|
[57] | 185 | ; DisplayFailedToLoadFile
|
---|
| 186 | ; DisplayFailedToSaveFile
|
---|
| 187 | ; DisplayFileTooBig
|
---|
| 188 | ; Parameters:
|
---|
| 189 | ; SS:BP: Menu handle
|
---|
| 190 | ; Returns:
|
---|
| 191 | ; Nothing
|
---|
| 192 | ; Corrupts registers:
|
---|
| 193 | ; AX, DX
|
---|
| 194 | ;--------------------------------------------------------------------
|
---|
| 195 | ALIGN JUMP_ALIGN
|
---|
[293] | 196 | DisplayFileLoadedSuccessfully:
|
---|
[57] | 197 | mov dx, g_szDlgMainLoadFile
|
---|
| 198 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|
| 199 |
|
---|
| 200 | ALIGN JUMP_ALIGN
|
---|
[293] | 201 | DisplayFileSavedSuccessfully:
|
---|
[57] | 202 | mov dx, g_szDlgMainSaveFile
|
---|
| 203 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|
| 204 |
|
---|
| 205 | DisplayFailedToLoadFile:
|
---|
| 206 | mov dx, g_szDlgMainLoadErr
|
---|
| 207 | jmp Dialogs_DisplayErrorFromCSDX
|
---|
| 208 |
|
---|
| 209 | DisplayFailedToSaveFile:
|
---|
| 210 | mov dx, g_szDlgMainSaveErr
|
---|
| 211 | jmp Dialogs_DisplayErrorFromCSDX
|
---|
| 212 |
|
---|
| 213 | DisplayFileTooBig:
|
---|
| 214 | mov dx, g_szDlgMainFileTooBig
|
---|
| 215 | jmp Dialogs_DisplayErrorFromCSDX
|
---|