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

Last change on this file since 617 was 596, checked in by Krister Nordvall, 6 years ago

Changes:

  • Made changes to HotkeyBar.asm to give the Boot Menu and Hotkey Bar a more consistent look. It will probably seem a bit strange at first to people used to the classic theme.
  • Added the missing parts of USE_NEC_V that should have been committed with the rest in r593.
  • Removed DEFINES_ALL_FEATURES from the BIOS makefile. It didn't work anymore and never really made sense anyway. Added all the official builds to 'make unused' instead which actually uncovered some unused code in the Tiny build.
  • XTIDECFG will no longer load color themes from unrecognized versions of the BIOS.
  • Other fixes in comments and some minor optimizations.
File size: 5.9 KB
Line 
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
21SECTION .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;--------------------------------------------------------------------
33ALIGN JUMP_ALIGN
34BiosFile_LoadFileFromDSSItoRamBuffer:
35 push ds
36
37 call .OpenFileForLoadingFromDSSIandGetSizeToDXCX
38 jc SHORT .DisplayErrorMessage
39 call .LoadFileWithNameInDSSIhandleInBXandSizeInDXCXtoRamBuffer
40 jc SHORT .DisplayErrorMessage
41
42 mov al, FLG_CFGVARS_FILELOADED
43 call Buffers_NewBiosWithSizeInDXCXandSourceInALhasBeenLoadedForConfiguration
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;--------------------------------------------------------------------
67ALIGN 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;--------------------------------------------------------------------
102ALIGN 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
125ALIGN 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;--------------------------------------------------------------------
140ALIGN JUMP_ALIGN
141BiosFile_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;--------------------------------------------------------------------
163ALIGN JUMP_ALIGN
164BiosFile_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
188ALIGN 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;--------------------------------------------------------------------
208ALIGN JUMP_ALIGN
209DisplayFileLoadedSuccessfully:
210 mov dx, g_szDlgMainLoadFile
211 jmp Dialogs_DisplayNotificationFromCSDX
212
213ALIGN JUMP_ALIGN
214DisplayFileSavedSuccessfully:
215 mov dx, g_szDlgMainSaveFile
216 jmp Dialogs_DisplayNotificationFromCSDX
217
218DisplayFailedToLoadFile:
219 mov dx, g_szDlgMainLoadErr
220 jmp Dialogs_DisplayErrorFromCSDX
221
222DisplayFailedToSaveFile:
223 mov dx, g_szDlgMainSaveErr
224 jmp Dialogs_DisplayErrorFromCSDX
225
226DisplayFileTooBig:
227 mov dx, g_szDlgMainFileTooBig
228 jmp Dialogs_DisplayErrorFromCSDX
Note: See TracBrowser for help on using the repository browser.