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