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

Last change on this file since 619 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
RevLine 
[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
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
[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;--------------------------------------------------------------------
67ALIGN 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;--------------------------------------------------------------------
102ALIGN 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]125ALIGN 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;--------------------------------------------------------------------
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
[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
188ALIGN 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;--------------------------------------------------------------------
208ALIGN JUMP_ALIGN
[293]209DisplayFileLoadedSuccessfully:
[57]210 mov dx, g_szDlgMainLoadFile
211 jmp Dialogs_DisplayNotificationFromCSDX
212
213ALIGN JUMP_ALIGN
[293]214DisplayFileSavedSuccessfully:
[57]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.