[57] | 1 | ; Project name : XTIDE Univeral BIOS Configurator v2 |
---|
| 2 | ; Description : Functions for loading and saving BIOS image file. |
---|
| 3 | |
---|
[376] | 4 | ; |
---|
[526] | 5 | ; XTIDE Universal BIOS and Associated Tools |
---|
| 6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team. |
---|
[376] | 7 | ; |
---|
| 8 | ; This program is free software; you can redistribute it and/or modify |
---|
| 9 | ; it under the terms of the GNU General Public License as published by |
---|
| 10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | ; (at your option) any later version. |
---|
[526] | 12 | ; |
---|
[376] | 13 | ; This program is distributed in the hope that it will be useful, |
---|
| 14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[526] | 16 | ; GNU General Public License for more details. |
---|
[376] | 17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
[526] | 18 | ; |
---|
[376] | 19 | |
---|
[57] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
| 23 | ;-------------------------------------------------------------------- |
---|
| 24 | ; BiosFile_LoadFileFromDSSItoRamBuffer |
---|
| 25 | ; Parameters: |
---|
| 26 | ; DS:SI: Name of file to open |
---|
| 27 | ; SS:BP: Menu handle |
---|
| 28 | ; Returns: |
---|
| 29 | ; Nothing |
---|
| 30 | ; Corrupts registers: |
---|
| 31 | ; AX, BX, CX, DX, SI, DI |
---|
| 32 | ;-------------------------------------------------------------------- |
---|
| 33 | ALIGN JUMP_ALIGN |
---|
| 34 | BiosFile_LoadFileFromDSSItoRamBuffer: |
---|
| 35 | push ds |
---|
| 36 | |
---|
[68] | 37 | call .OpenFileForLoadingFromDSSIandGetSizeToDXCX |
---|
[57] | 38 | jc SHORT .DisplayErrorMessage |
---|
[68] | 39 | call .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer |
---|
[57] | 40 | jc SHORT .DisplayErrorMessage |
---|
| 41 | |
---|
[596] | 42 | mov al, FLG_CFGVARS_FILELOADED |
---|
| 43 | call Buffers_NewBiosWithSizeInDXCXandSourceInALhasBeenLoadedForConfiguration |
---|
[136] | 44 | call FileIO_CloseUsingHandleFromBX |
---|
[293] | 45 | call DisplayFileLoadedSuccessfully |
---|
[592] | 46 | pop ds |
---|
| 47 | ret |
---|
[57] | 48 | |
---|
| 49 | .DisplayErrorMessage: |
---|
| 50 | call FileIO_CloseUsingHandleFromBX |
---|
| 51 | call DisplayFailedToLoadFile |
---|
| 52 | pop ds |
---|
| 53 | ret |
---|
| 54 | |
---|
| 55 | ;-------------------------------------------------------------------- |
---|
[68] | 56 | ; .OpenFileForLoadingFromDSSIandGetSizeInBytesToDXCX |
---|
[57] | 57 | ; Parameters: |
---|
| 58 | ; DS:SI: Name of file to open |
---|
| 59 | ; Returns: |
---|
[293] | 60 | ; BX: File handle (if successful) |
---|
| 61 | ; DX:CX: File size (if successful) |
---|
| 62 | ; CF: Clear if successful |
---|
[57] | 63 | ; Set if error |
---|
| 64 | ; Corrupts registers: |
---|
[68] | 65 | ; AX |
---|
[57] | 66 | ;-------------------------------------------------------------------- |
---|
| 67 | ALIGN JUMP_ALIGN |
---|
[68] | 68 | .OpenFileForLoadingFromDSSIandGetSizeToDXCX: |
---|
[57] | 69 | mov al, FILE_ACCESS.ReadOnly |
---|
| 70 | call FileIO_OpenWithPathInDSSIandFileAccessInAL |
---|
| 71 | jc SHORT .FileError |
---|
| 72 | call FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition |
---|
| 73 | jc SHORT .FileError |
---|
| 74 | |
---|
[68] | 75 | cmp dx, MAX_EEPROM_SIZE_IN_BYTES >> 16 |
---|
[589] | 76 | jb SHORT .FileNotTooBig |
---|
[57] | 77 | ja SHORT .FileTooBig |
---|
[68] | 78 | cmp ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh |
---|
| 79 | ja SHORT .FileTooBig |
---|
| 80 | .FileNotTooBig: |
---|
[57] | 81 | xchg cx, ax |
---|
| 82 | clc |
---|
| 83 | ret |
---|
| 84 | .FileTooBig: |
---|
| 85 | call DisplayFileTooBig |
---|
| 86 | stc |
---|
| 87 | .FileError: |
---|
| 88 | ret |
---|
| 89 | |
---|
| 90 | ;-------------------------------------------------------------------- |
---|
[68] | 91 | ; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer |
---|
[57] | 92 | ; Parameters: |
---|
| 93 | ; BX: File Handle |
---|
[68] | 94 | ; DX:CX: File size |
---|
[57] | 95 | ; DS:SI: File name |
---|
| 96 | ; Returns: |
---|
[293] | 97 | ; CF: Clear if successful |
---|
[57] | 98 | ; Set if error |
---|
| 99 | ; Corrupts registers: |
---|
| 100 | ; AX, SI, DI, DS |
---|
| 101 | ;-------------------------------------------------------------------- |
---|
| 102 | ALIGN JUMP_ALIGN |
---|
[68] | 103 | .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer: |
---|
[57] | 104 | push es |
---|
| 105 | |
---|
| 106 | call Buffers_GetFileBufferToESDI |
---|
| 107 | call Registers_ExchangeDSSIwithESDI |
---|
[68] | 108 | call FileIO_ReadDXCXbytesToDSSIusingHandleFromBX |
---|
[181] | 109 | jc SHORT .ReturnError |
---|
[57] | 110 | |
---|
[181] | 111 | ; Store filename to Cfgvars from ESDI |
---|
[57] | 112 | push cx |
---|
| 113 | |
---|
[107] | 114 | call Registers_CopyESDItoDSSI ; File name in DS:SI |
---|
[57] | 115 | push cs |
---|
| 116 | pop es |
---|
| 117 | mov di, g_cfgVars+CFGVARS.szOpenedFile |
---|
[592] | 118 | %ifdef CLD_NEEDED |
---|
[57] | 119 | cld |
---|
[592] | 120 | %endif |
---|
[57] | 121 | call String_CopyDSSItoESDIandGetLengthToCX |
---|
[181] | 122 | clc |
---|
[57] | 123 | |
---|
| 124 | pop cx |
---|
[181] | 125 | ALIGN JUMP_ALIGN |
---|
| 126 | .ReturnError: |
---|
[57] | 127 | pop es |
---|
| 128 | ret |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | ;-------------------------------------------------------------------- |
---|
| 132 | ; BiosFile_SaveUnsavedChanges |
---|
| 133 | ; Parameters: |
---|
| 134 | ; SS:BP: Menu handle |
---|
| 135 | ; Returns: |
---|
| 136 | ; Nothing |
---|
| 137 | ; Corrupts registers: |
---|
| 138 | ; AX, BX, CX, SI, DI |
---|
| 139 | ;-------------------------------------------------------------------- |
---|
| 140 | ALIGN JUMP_ALIGN |
---|
| 141 | BiosFile_SaveUnsavedChanges: |
---|
| 142 | push ds |
---|
| 143 | |
---|
| 144 | push cs |
---|
| 145 | pop ds |
---|
| 146 | mov si, g_cfgVars+CFGVARS.szOpenedFile |
---|
| 147 | call BiosFile_SaveRamBufferToFileInDSSI |
---|
| 148 | |
---|
| 149 | pop ds |
---|
| 150 | ret |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | ;-------------------------------------------------------------------- |
---|
| 154 | ; BiosFile_SaveRamBufferToFileInDSSI |
---|
| 155 | ; Parameters: |
---|
| 156 | ; DS:SI: Name of file to save |
---|
| 157 | ; SS:BP: Menu handle |
---|
| 158 | ; Returns: |
---|
| 159 | ; Nothing |
---|
| 160 | ; Corrupts registers: |
---|
| 161 | ; AX, BX, CX, SI, DI |
---|
| 162 | ;-------------------------------------------------------------------- |
---|
| 163 | ALIGN JUMP_ALIGN |
---|
| 164 | BiosFile_SaveRamBufferToFileInDSSI: |
---|
| 165 | push es |
---|
| 166 | push ds |
---|
| 167 | |
---|
| 168 | call Buffers_GenerateChecksum |
---|
| 169 | call Buffers_GetFileBufferToESDI |
---|
[484] | 170 | call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX |
---|
[138] | 171 | |
---|
| 172 | mov al, FILE_ACCESS.WriteOnly |
---|
| 173 | call FileIO_OpenWithPathInDSSIandFileAccessInAL |
---|
| 174 | jc SHORT .DisplayErrorMessage |
---|
| 175 | |
---|
| 176 | call Registers_CopyESDItoDSSI |
---|
[68] | 177 | call FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX |
---|
[57] | 178 | jc SHORT .DisplayErrorMessage |
---|
| 179 | |
---|
[136] | 180 | call FileIO_CloseUsingHandleFromBX |
---|
[57] | 181 | call Buffers_ClearUnsavedChanges |
---|
[293] | 182 | call DisplayFileSavedSuccessfully |
---|
[57] | 183 | jmp SHORT .Return |
---|
| 184 | |
---|
| 185 | .DisplayErrorMessage: |
---|
| 186 | call FileIO_CloseUsingHandleFromBX |
---|
| 187 | call DisplayFailedToSaveFile |
---|
| 188 | ALIGN JUMP_ALIGN |
---|
| 189 | .Return: |
---|
| 190 | pop ds |
---|
| 191 | pop es |
---|
| 192 | ret |
---|
| 193 | |
---|
| 194 | |
---|
| 195 | ;-------------------------------------------------------------------- |
---|
[293] | 196 | ; DisplayFileLoadedSuccessfully |
---|
| 197 | ; DisplayFileSavedSuccessfully |
---|
[57] | 198 | ; DisplayFailedToLoadFile |
---|
| 199 | ; DisplayFailedToSaveFile |
---|
| 200 | ; DisplayFileTooBig |
---|
| 201 | ; Parameters: |
---|
| 202 | ; SS:BP: Menu handle |
---|
| 203 | ; Returns: |
---|
| 204 | ; Nothing |
---|
| 205 | ; Corrupts registers: |
---|
| 206 | ; AX, DX |
---|
| 207 | ;-------------------------------------------------------------------- |
---|
| 208 | ALIGN JUMP_ALIGN |
---|
[293] | 209 | DisplayFileLoadedSuccessfully: |
---|
[57] | 210 | mov dx, g_szDlgMainLoadFile |
---|
| 211 | jmp Dialogs_DisplayNotificationFromCSDX |
---|
| 212 | |
---|
| 213 | ALIGN JUMP_ALIGN |
---|
[293] | 214 | DisplayFileSavedSuccessfully: |
---|
[57] | 215 | mov dx, g_szDlgMainSaveFile |
---|
| 216 | jmp Dialogs_DisplayNotificationFromCSDX |
---|
| 217 | |
---|
| 218 | DisplayFailedToLoadFile: |
---|
| 219 | mov dx, g_szDlgMainLoadErr |
---|
| 220 | jmp Dialogs_DisplayErrorFromCSDX |
---|
| 221 | |
---|
| 222 | DisplayFailedToSaveFile: |
---|
| 223 | mov dx, g_szDlgMainSaveErr |
---|
| 224 | jmp Dialogs_DisplayErrorFromCSDX |
---|
| 225 | |
---|
| 226 | DisplayFileTooBig: |
---|
| 227 | mov dx, g_szDlgMainFileTooBig |
---|
| 228 | jmp Dialogs_DisplayErrorFromCSDX |
---|