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

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

Changes to XTIDE Universal BIOS Configurator v2:

  • All necessary features should now be implemented.
File size: 5.3 KB
Line 
1; File name : BiosFile.asm
2; Project name : XTIDE Univeral BIOS Configurator v2
3; Created date : 10.10.2010
4; Last update : 30.11.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 .OpenFileForLoadingFromDSSIandGetSizeToCX
26 jc SHORT .DisplayErrorMessage
27 call .LoadFileWithNameInDSSIhandleInBXandSizeInCXtoRamBuffer
28 jc SHORT .DisplayErrorMessage
29
30 mov ax, FLG_CFGVARS_FILELOADED
31 call Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
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; .OpenFileForLoadingFromDSSIandGetSizeToCX
46; Parameters:
47; DS:SI: Name of file to open
48; Returns:
49; BX: File handle (if succesfull)
50; CX: File size (if succesfull)
51; CF: Clear if successfull
52; Set if error
53; Corrupts registers:
54; AX, DX
55;--------------------------------------------------------------------
56ALIGN JUMP_ALIGN
57.OpenFileForLoadingFromDSSIandGetSizeToCX:
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, BYTE 1 ; File size over 65536 bytes?
65 ja SHORT .FileTooBig
66 jb SHORT .CopyFileSizeToCX
67 test ax, ax
68 jnz SHORT .FileTooBig
69 dec ax ; Prepare to load 65535 bytes
70.CopyFileSizeToCX:
71 xchg cx, ax
72 clc
73 ret
74.FileTooBig:
75 call DisplayFileTooBig
76 stc
77.FileError:
78 ret
79
80;--------------------------------------------------------------------
81; .LoadFileWithNameInDSSIhandleInBXandSizeInCXtoRamBuffer
82; Parameters:
83; BX: File Handle
84; CX: File size
85; DS:SI: File name
86; Returns:
87; CF: Clear if successfull
88; Set if error
89; Corrupts registers:
90; AX, SI, DI, DS
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93.LoadFileWithNameInDSSIhandleInBXandSizeInCXtoRamBuffer:
94 push es
95
96 call Buffers_GetFileBufferToESDI
97 call Registers_ExchangeDSSIwithESDI
98 call FileIO_ReadCXbytesToDSSIusingHandleFromBX
99 jnc SHORT .StoreFileNameToCfgvarsFromESDI
100
101 pop es
102 ret
103
104ALIGN JUMP_ALIGN
105.StoreFileNameToCfgvarsFromESDI:
106 push cx
107
108 call Registers_CopyESDItoDSSI ; File name in DS:SI
109 push cs
110 pop es
111 mov di, g_cfgVars+CFGVARS.szOpenedFile
112 cld
113 call String_CopyDSSItoESDIandGetLengthToCX
114
115 pop cx
116 pop es
117 clc
118 ret
119
120
121;--------------------------------------------------------------------
122; BiosFile_SaveUnsavedChanges
123; Parameters:
124; SS:BP: Menu handle
125; Returns:
126; Nothing
127; Corrupts registers:
128; AX, BX, CX, SI, DI
129;--------------------------------------------------------------------
130ALIGN JUMP_ALIGN
131BiosFile_SaveUnsavedChanges:
132 push ds
133
134 push cs
135 pop ds
136 mov si, g_cfgVars+CFGVARS.szOpenedFile
137 call BiosFile_SaveRamBufferToFileInDSSI
138
139 pop ds
140 ret
141
142
143;--------------------------------------------------------------------
144; BiosFile_SaveRamBufferToFileInDSSI
145; Parameters:
146; DS:SI: Name of file to save
147; SS:BP: Menu handle
148; Returns:
149; Nothing
150; Corrupts registers:
151; AX, BX, CX, SI, DI
152;--------------------------------------------------------------------
153ALIGN JUMP_ALIGN
154BiosFile_SaveRamBufferToFileInDSSI:
155 push es
156 push ds
157
158 mov al, FILE_ACCESS.WriteOnly
159 call FileIO_OpenWithPathInDSSIandFileAccessInAL
160 jc SHORT .DisplayErrorMessage
161
162 call Buffers_GenerateChecksum
163 call Buffers_GetFileBufferToESDI
164 call Registers_CopyESDItoDSSI
165 mov cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
166 shl cx, 1
167 call FileIO_WriteCXbytesFromDSSIusingHandleFromBX
168 jc SHORT .DisplayErrorMessage
169
170 call Buffers_ClearUnsavedChanges
171 call DisplayFileSavedSuccesfully
172 jmp SHORT .Return
173
174.DisplayErrorMessage:
175 call FileIO_CloseUsingHandleFromBX
176 call DisplayFailedToSaveFile
177ALIGN JUMP_ALIGN
178.Return:
179 pop ds
180 pop es
181 ret
182
183
184;--------------------------------------------------------------------
185; DisplayFileLoadedSuccesfully
186; DisplayFileSavedSuccesfully
187; DisplayFailedToLoadFile
188; DisplayFailedToSaveFile
189; DisplayFileTooBig
190; Parameters:
191; SS:BP: Menu handle
192; Returns:
193; Nothing
194; Corrupts registers:
195; AX, DX
196;--------------------------------------------------------------------
197ALIGN JUMP_ALIGN
198DisplayFileLoadedSuccesfully:
199 mov dx, g_szDlgMainLoadFile
200 jmp Dialogs_DisplayNotificationFromCSDX
201
202ALIGN JUMP_ALIGN
203DisplayFileSavedSuccesfully:
204 mov dx, g_szDlgMainSaveFile
205 jmp Dialogs_DisplayNotificationFromCSDX
206
207DisplayFailedToLoadFile:
208 mov dx, g_szDlgMainLoadErr
209 jmp Dialogs_DisplayErrorFromCSDX
210
211DisplayFailedToSaveFile:
212 mov dx, g_szDlgMainSaveErr
213 jmp Dialogs_DisplayErrorFromCSDX
214
215DisplayFileTooBig:
216 mov dx, g_szDlgMainFileTooBig
217 jmp Dialogs_DisplayErrorFromCSDX
Note: See TracBrowser for help on using the repository browser.