source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/BiosFile.asm@ 93

Last change on this file since 93 was 68, checked in by Tomi Tilli, 14 years ago

Changes to Configurator v2:

  • Finally ready for testing.
File size: 5.4 KB
Line 
1; File name : BiosFile.asm
2; Project name : XTIDE Univeral BIOS Configurator v2
3; Created date : 10.10.2010
4; Last update : 6.12.2010
5; Author : Tomi Tilli
6; Description : Functions for loading and saving BIOS image file.
7
8; Section containing code
9SECTION .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;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22BiosFile_LoadFileFromDSSItoRamBuffer:
23 push ds
24
25 call .OpenFileForLoadingFromDSSIandGetSizeToDXCX
26 jc SHORT .DisplayErrorMessage
27 call .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
28 jc SHORT .DisplayErrorMessage
29
30 mov ax, FLG_CFGVARS_FILELOADED
31 call Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
32 call DisplayFileLoadedSuccesfully
33 call FileIO_CloseUsingHandleFromBX
34 jmp SHORT .Return
35
36.DisplayErrorMessage:
37 call FileIO_CloseUsingHandleFromBX
38 call DisplayFailedToLoadFile
39ALIGN JUMP_ALIGN
40.Return:
41 pop ds
42 ret
43
44;--------------------------------------------------------------------
45; .OpenFileForLoadingFromDSSIandGetSizeInBytesToDXCX
46; Parameters:
47; DS:SI: Name of file to open
48; Returns:
49; BX: File handle (if succesfull)
50; DX:CX: File size (if succesfull)
51; CF: Clear if successfull
52; Set if error
53; Corrupts registers:
54; AX
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57.OpenFileForLoadingFromDSSIandGetSizeToDXCX:
58 mov al, FILE_ACCESS.ReadOnly
59 call FileIO_OpenWithPathInDSSIandFileAccessInAL
60 jc SHORT .FileError
61 call FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition
62 jc SHORT .FileError
63
64 cmp dx, MAX_EEPROM_SIZE_IN_BYTES >> 16
65 ja SHORT .FileTooBig
66 jb SHORT .FileNotTooBig
67 cmp ax, MAX_EEPROM_SIZE_IN_BYTES & 0FFFFh
68 ja SHORT .FileTooBig
69.FileNotTooBig:
70 xchg cx, ax
71 clc
72 ret
73.FileTooBig:
74 call DisplayFileTooBig
75 stc
76.FileError:
77 ret
78
79;--------------------------------------------------------------------
80; .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
81; Parameters:
82; BX: File Handle
83; DX:CX: File size
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;--------------------------------------------------------------------
91ALIGN JUMP_ALIGN
92.LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer:
93 push es
94
95 call Buffers_GetFileBufferToESDI
96 call Registers_ExchangeDSSIwithESDI
97 call FileIO_ReadDXCXbytesToDSSIusingHandleFromBX
98 jnc SHORT .StoreFileNameToCfgvarsFromESDI
99
100 pop es
101 ret
102
103ALIGN 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;--------------------------------------------------------------------
129ALIGN JUMP_ALIGN
130BiosFile_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;--------------------------------------------------------------------
152ALIGN JUMP_ALIGN
153BiosFile_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
164 xor dx, dx
165 mov cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
166 shl cx, 1
167 rcl dx, 1 ; WORDs to BYTEs
168 call FileIO_WriteDXCXbytesFromDSSIusingHandleFromBX
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
178ALIGN 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;--------------------------------------------------------------------
198ALIGN JUMP_ALIGN
199DisplayFileLoadedSuccesfully:
200 mov dx, g_szDlgMainLoadFile
201 jmp Dialogs_DisplayNotificationFromCSDX
202
203ALIGN JUMP_ALIGN
204DisplayFileSavedSuccesfully:
205 mov dx, g_szDlgMainSaveFile
206 jmp Dialogs_DisplayNotificationFromCSDX
207
208DisplayFailedToLoadFile:
209 mov dx, g_szDlgMainLoadErr
210 jmp Dialogs_DisplayErrorFromCSDX
211
212DisplayFailedToSaveFile:
213 mov dx, g_szDlgMainSaveErr
214 jmp Dialogs_DisplayErrorFromCSDX
215
216DisplayFileTooBig:
217 mov dx, g_szDlgMainFileTooBig
218 jmp Dialogs_DisplayErrorFromCSDX
Note: See TracBrowser for help on using the repository browser.