source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/Buffers.asm@ 514

Last change on this file since 514 was 484, checked in by aitotat@…, 12 years ago

Changes to Configurator v2:

  • Large builds are now saved to correct size.
File size: 8.7 KB
Line 
1; Project name : XTIDE Universal BIOS Configurator v2
2; Description : Functions for accessing file and flash buffers.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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; Buffers_Clear
25; Parameters:
26; Nothing
27; Returns:
28; Nothing
29; Corrupts registers:
30; AX, CX, DI, ES
31;--------------------------------------------------------------------
32ALIGN JUMP_ALIGN
33Buffers_Clear:
34 call Buffers_GetFileBufferToESDI
35 mov cx, ROMVARS_size
36 jmp Memory_ZeroESDIwithSizeInCX
37
38
39;--------------------------------------------------------------------
40; Buffers_IsXtideUniversalBiosLoaded
41; Parameters:
42; Nothing
43; Returns:
44; ZF: Set if supported version of XTIDE Universal BIOS is loaded
45; Cleared no file or some other file is loaded
46; Corrupts registers:
47; CX, SI, DI, ES
48;--------------------------------------------------------------------
49ALIGN JUMP_ALIGN
50Buffers_IsXtideUniversalBiosLoaded:
51 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
52 jz SHORT .NoFileOrBiosLoaded
53
54 call Buffers_GetFileBufferToESDI
55 jmp SHORT Buffers_IsXtideUniversalBiosSignatureInESDI
56.NoFileOrBiosLoaded:
57 or cl, 1 ; Clear ZF
58 ret
59
60
61;--------------------------------------------------------------------
62; Buffers_IsXtideUniversalBiosSignatureInESDI
63; Parameters:
64; ES:DI: Ptr to possible XTIDE Universal BIOS location
65; Returns:
66; ZF: Set if supported version of XTIDE Universal BIOS is loaded
67; Cleared no file or some other file is loaded
68; Corrupts registers:
69; CX, SI
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72Buffers_IsXtideUniversalBiosSignatureInESDI:
73 push di
74
75 mov si, g_szXtideUniversalBiosSignature
76 add di, BYTE ROMVARS.rgbSign
77 mov cx, XTIDE_SIGNATURE_LENGTH / 2
78 cld
79 eSEG_STR repe, cs, cmpsw
80
81 pop di
82 ret
83
84
85;--------------------------------------------------------------------
86; Buffers_IsXTbuildLoaded
87; Parameters:
88; Nothing
89; Returns:
90; ZF: Set if XT or XT+ build is loaded
91; Cleared if some other (AT, 386) build is loaded
92; Corrupts registers:
93; DI, ES
94;--------------------------------------------------------------------
95ALIGN JUMP_ALIGN
96Buffers_IsXTbuildLoaded:
97%strlen BUILD_TYPE_OFFSET TITLE_STRING_START
98 call Buffers_GetFileBufferToESDI
99 cmp WORD [es:di+ROMVARS.szTitle+BUILD_TYPE_OFFSET+1], 'XT' ; +1 is for '('
100 ret
101%undef BUILD_TYPE_OFFSET
102
103
104;--------------------------------------------------------------------
105; Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration
106; Parameters:
107; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
108; DX:CX: EEPROM size in bytes
109; Returns:
110; Nothing
111; Corrupts registers:
112; AX, CX, DX
113;--------------------------------------------------------------------
114ALIGN JUMP_ALIGN
115Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration:
116 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
117 or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
118 shr dx, 1
119 rcr cx, 1
120 adc cx, BYTE 0 ; Round up to next WORD
121 mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
122 ret
123
124
125;--------------------------------------------------------------------
126; Buffers_SetUnsavedChanges
127; Buffers_ClearUnsavedChanges
128; Parameters:
129; SS:BP: Menu handle
130; Returns:
131; Nothing
132; Corrupts registers:
133; Nothing
134;--------------------------------------------------------------------
135ALIGN JUMP_ALIGN
136Buffers_SetUnsavedChanges:
137 or WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
138 ret
139
140ALIGN JUMP_ALIGN
141Buffers_ClearUnsavedChanges:
142 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
143 ret
144
145
146;--------------------------------------------------------------------
147; Buffers_SaveChangesIfFileLoaded
148; Parameters:
149; Nothing
150; Returns:
151; Nothing
152; Corrupts registers:
153; AX, BX, CX, SI, DI
154;--------------------------------------------------------------------
155ALIGN JUMP_ALIGN
156Buffers_SaveChangesIfFileLoaded:
157 mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
158 and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
159 cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
160 jne SHORT .NothingToSave
161 call Dialogs_DisplaySaveChangesDialog
162 jnz SHORT .NothingToSave
163 jmp BiosFile_SaveUnsavedChanges
164ALIGN JUMP_ALIGN
165.NothingToSave:
166 ret
167
168
169;--------------------------------------------------------------------
170; Buffers_AppendZeroesIfNeeded
171; Parameters:
172; Nothing
173; Returns:
174; Nothing
175; Corrupts registers:
176; AX, CX, DI
177;--------------------------------------------------------------------
178ALIGN JUMP_ALIGN
179Buffers_AppendZeroesIfNeeded:
180 push es
181
182 eMOVZX di, [cs:g_cfgVars+CFGVARS.bEepromType]
183 mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
184 sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
185 jle SHORT .NoNeedToAppendZeroes
186
187 call Buffers_GetFileBufferToESDI
188 mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
189 shl ax, 1
190 add di, ax ; ES:DI now point first unused image byte
191 xor ax, ax
192 cld
193 rep stosw
194ALIGN JUMP_ALIGN
195.NoNeedToAppendZeroes:
196 pop es
197 ret
198
199
200;--------------------------------------------------------------------
201; Buffers_GenerateChecksum
202; Parameters:
203; Nothing
204; Returns:
205; Nothing
206; Corrupts registers:
207; AX, BX, CX, DI
208;--------------------------------------------------------------------
209ALIGN JUMP_ALIGN
210Buffers_GenerateChecksum:
211 push es
212 push dx
213
214 call Buffers_GetFileBufferToESDI
215 call EEPROM_GetXtideUniversalBiosSizeFromESDItoDXCX
216 dec cx ; Leave space for checksum byte
217 xor ax, ax
218ALIGN JUMP_ALIGN
219.SumNextByte:
220 add al, [es:di]
221 inc di
222 loop .SumNextByte
223 neg al
224 mov [es:di], al
225
226 pop dx
227 pop es
228 ret
229
230
231;--------------------------------------------------------------------
232; Buffers_GetRomvarsFlagsToAX
233; Parameters:
234; Nothing
235; Returns:
236; AX: ROMVARS.wFlags
237; Corrupts registers:
238; BX
239;--------------------------------------------------------------------
240ALIGN JUMP_ALIGN
241Buffers_GetRomvarsFlagsToAX:
242 mov bx, ROMVARS.wFlags
243 ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
244
245;--------------------------------------------------------------------
246; Buffers_GetRomvarsValueToAXfromOffsetInBX
247; Parameters:
248; BX: ROMVARS offset
249; Returns:
250; AX: Value
251; Corrupts registers:
252; Nothing
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255Buffers_GetRomvarsValueToAXfromOffsetInBX:
256 push es
257 push di
258 call Buffers_GetFileBufferToESDI
259 mov ax, [es:bx+di]
260 pop di
261 pop es
262 ret
263
264
265;--------------------------------------------------------------------
266; Buffers_GetIdeControllerCountToCX
267; Parameters:
268; SS:BP: Menu handle
269; Returns:
270; CX: Number of IDE controllers to configure
271; ES:DI: Ptr to file buffer
272; Corrupts registers:
273; AX
274;--------------------------------------------------------------------
275ALIGN JUMP_ALIGN
276Buffers_GetIdeControllerCountToCX:
277 call Buffers_GetFileBufferToESDI
278 mov al, [es:di+ROMVARS.bIdeCnt]
279
280 ; Limit controller count for lite mode
281 test BYTE [es:di+ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
282 jnz SHORT .ReturnControllerCountInCX
283 MIN_U al, MAX_LITE_MODE_CONTROLLERS
284
285.ReturnControllerCountInCX:
286 cbw ; A maximum of 127 controllers should be sufficient
287 xchg cx, ax
288 ret
289
290
291;--------------------------------------------------------------------
292; Buffers_GetFileBufferToESDI
293; Buffers_GetFlashComparisonBufferToESDI
294; Buffers_GetFileDialogItemBufferToESDI
295; Parameters:
296; Nothing
297; Returns:
298; ES:DI: Ptr to file buffer
299; Corrupts registers:
300; Nothing
301;--------------------------------------------------------------------
302ALIGN JUMP_ALIGN
303Buffers_GetFlashComparisonBufferToESDI:
304Buffers_GetFileDialogItemBufferToESDI:
305 call Buffers_GetFileBufferToESDI
306 push di
307 mov di, es
308 add di, 1000h ; Third 64k page
309 mov es, di
310 pop di
311 ret
312ALIGN JUMP_ALIGN
313Buffers_GetFileBufferToESDI:
314 mov di, cs
315 add di, 1000h ; Change to next 64k page
316 mov es, di
317 xor di, di ; Ptr now in ES:DI
318 ret
Note: See TracBrowser for help on using the repository browser.