1 | ; Project name : XTIDE Univeral BIOS Configurator v2
|
---|
2 | ; Description : Functions for loading and saving BIOS image file.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
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.
|
---|
12 | ;
|
---|
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
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
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 |
|
---|
37 | call .OpenFileForLoadingFromDSSIandGetSizeToDXCX
|
---|
38 | jc SHORT .DisplayErrorMessage
|
---|
39 | call .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
|
---|
40 | jc SHORT .DisplayErrorMessage
|
---|
41 |
|
---|
42 | mov ax, FLG_CFGVARS_FILELOADED
|
---|
43 | call Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
|
---|
44 | call FileIO_CloseUsingHandleFromBX
|
---|
45 | call DisplayFileLoadedSuccessfully
|
---|
46 | pop ds
|
---|
47 | ret
|
---|
48 |
|
---|
49 | .DisplayErrorMessage:
|
---|
50 | call FileIO_CloseUsingHandleFromBX
|
---|
51 | call DisplayFailedToLoadFile
|
---|
52 | pop ds
|
---|
53 | ret
|
---|
54 |
|
---|
55 | ;--------------------------------------------------------------------
|
---|
56 | ; .OpenFileForLoadingFromDSSIandGetSizeInBytesToDXCX
|
---|
57 | ; Parameters:
|
---|
58 | ; DS:SI: Name of file to open
|
---|
59 | ; Returns:
|
---|
60 | ; BX: File handle (if successful)
|
---|
61 | ; DX:CX: File size (if successful)
|
---|
62 | ; CF: Clear if successful
|
---|
63 | ; Set if error
|
---|
64 | ; Corrupts registers:
|
---|
65 | ; AX
|
---|
66 | ;--------------------------------------------------------------------
|
---|
67 | ALIGN JUMP_ALIGN
|
---|
68 | .OpenFileForLoadingFromDSSIandGetSizeToDXCX:
|
---|
69 | mov al, FILE_ACCESS.ReadOnly
|
---|
70 | call FileIO_OpenWithPathInDSSIandFileAccessInAL
|
---|
71 | jc SHORT .FileError
|
---|
72 | call FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
|
---|
73 | jc SHORT .FileError
|
---|
74 |
|
---|
75 | cmp dx, MAX_EEPROM_SIZE_IN_BYTES >> 16
|
---|
76 | jb SHORT .FileNotTooBig
|
---|
77 | ja SHORT .FileTooBig
|
---|
78 | cmp ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh
|
---|
79 | ja SHORT .FileTooBig
|
---|
80 | .FileNotTooBig:
|
---|
81 | xchg cx, ax
|
---|
82 | clc
|
---|
83 | ret
|
---|
84 | .FileTooBig:
|
---|
85 | call DisplayFileTooBig
|
---|
86 | stc
|
---|
87 | .FileError:
|
---|
88 | ret
|
---|
89 |
|
---|
90 | ;--------------------------------------------------------------------
|
---|
91 | ; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
|
---|
92 | ; Parameters:
|
---|
93 | ; BX: File Handle
|
---|
94 | ; DX:CX: File size
|
---|
95 | ; DS:SI: File name
|
---|
96 | ; Returns:
|
---|
97 | ; CF: Clear if successful
|
---|
98 | ; Set if error
|
---|
99 | ; Corrupts registers:
|
---|
100 | ; AX, SI, DI, DS
|
---|
101 | ;--------------------------------------------------------------------
|
---|
102 | ALIGN JUMP_ALIGN
|
---|
103 | .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer:
|
---|
104 | push es
|
---|
105 |
|
---|
106 | call Buffers_GetFileBufferToESDI
|
---|
107 | call Registers_ExchangeDSSIwithESDI
|
---|
108 | call FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
|
---|
109 | jc SHORT .ReturnError
|
---|
110 |
|
---|
111 | ; Store filename to Cfgvars from ESDI
|
---|
112 | push cx
|
---|
113 |
|
---|
114 | call Registers_CopyESDItoDSSI ; File name in DS:SI
|
---|
115 | push cs
|
---|
116 | pop es
|
---|
117 | mov di, g_cfgVars+CFGVARS.szOpenedFile
|
---|
118 | %ifdef CLD_NEEDED
|
---|
119 | cld
|
---|
120 | %endif
|
---|
121 | call String_CopyDSSItoESDIandGetLengthToCX
|
---|
122 | clc
|
---|
123 |
|
---|
124 | pop cx
|
---|
125 | ALIGN JUMP_ALIGN
|
---|
126 | .ReturnError:
|
---|
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
|
---|
170 | call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
|
---|
171 |
|
---|
172 | mov al, FILE_ACCESS.WriteOnly
|
---|
173 | call FileIO_OpenWithPathInDSSIandFileAccessInAL
|
---|
174 | jc SHORT .DisplayErrorMessage
|
---|
175 |
|
---|
176 | call Registers_CopyESDItoDSSI
|
---|
177 | call FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
|
---|
178 | jc SHORT .DisplayErrorMessage
|
---|
179 |
|
---|
180 | call FileIO_CloseUsingHandleFromBX
|
---|
181 | call Buffers_ClearUnsavedChanges
|
---|
182 | call DisplayFileSavedSuccessfully
|
---|
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 | ;--------------------------------------------------------------------
|
---|
196 | ; DisplayFileLoadedSuccessfully
|
---|
197 | ; DisplayFileSavedSuccessfully
|
---|
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
|
---|
209 | DisplayFileLoadedSuccessfully:
|
---|
210 | mov dx, g_szDlgMainLoadFile
|
---|
211 | jmp Dialogs_DisplayNotificationFromCSDX
|
---|
212 |
|
---|
213 | ALIGN JUMP_ALIGN
|
---|
214 | DisplayFileSavedSuccessfully:
|
---|
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
|
---|