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

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

Changes to Configuration Program v2:

  • Menu structure should now be complete.
File size: 7.7 KB
Line 
1; File name : Buffers.asm
2; Project name : XTIDE Universal BIOS Configurator v2
3; Created date : 6.10.2010
4; Last update : 19.11.2010
5; Author : Tomi Tilli
6; Description : Functions for accessing file and flash buffers.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Buffers_Clear
13; Parameters:
14; Nothing
15; Returns:
16; Nothing
17; Corrupts registers:
18; AX, CX, DI, ES
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21Buffers_Clear:
22 call Buffers_GetFileBufferToESDI
23 mov cx, ROMVARS_size
24 jmp Memory_ZeroESDIwithSizeInCX
25
26
27;--------------------------------------------------------------------
28; Buffers_IsXtideUniversalBiosLoaded
29; Parameters:
30; Nothing
31; Returns:
32; ZF: Set if supported version of XTIDE Universal BIOS is loaded
33; Cleared no file or some other file is loaded
34; Corrupts registers:
35; CX, SI, DI, ES
36;--------------------------------------------------------------------
37ALIGN JUMP_ALIGN
38Buffers_IsXtideUniversalBiosLoaded:
39 test WORD [cs:g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED
40 jz SHORT .NoFileOrBiosLoaded
41
42 call Buffers_GetFileBufferToESDI
43 jmp SHORT Buffers_IsXtideUniversalBiosSignatureInESDI
44.NoFileOrBiosLoaded:
45 or cl, 1 ; Clear ZF
46 ret
47
48
49;--------------------------------------------------------------------
50; Buffers_IsXtideUniversalBiosSignatureInESDI
51; Parameters:
52; ES:DI: Ptr to possible XTIDE Universal BIOS location
53; Returns:
54; ZF: Set if supported version of XTIDE Universal BIOS is loaded
55; Cleared no file or some other file is loaded
56; Corrupts registers:
57; CX, SI
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60Buffers_IsXtideUniversalBiosSignatureInESDI:
61 push di
62
63 mov si, g_szXtideUniversalBiosSignature
64 add di, BYTE ROMVARS.rgbSign
65 mov cx, XTIDE_SIGNATURE_LENGTH / 2
66 cld
67 eSEG_STR repe, cs, cmpsw
68
69 pop di
70 ret
71
72
73;--------------------------------------------------------------------
74; Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
75; Parameters:
76; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
77; CX: EEPROM size in bytes
78; Returns:
79; Nothing
80; Corrupts registers:
81; AX, BX, CX, DX
82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
84Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration:
85 and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
86 or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
87 ; Fall to .AdjustBiosImageSizeToSupportedEepromSize
88
89;--------------------------------------------------------------------
90; .AdjustBiosImageSizeInCXtoSupportedEepromSize
91; Parameters:
92; CX: Size of loaded BIOS image
93; Returns:
94; CX: Size of BIOS image (and EEPROM required)
95; Corrupts registers:
96; AX, BX, DX
97;--------------------------------------------------------------------
98.AdjustBiosImageSizeInCXtoSupportedEepromSize:
99 mov bx, .rgwSupportedEepromSizes
100 mov dx, NUMBER_OF_SUPPORTED_EEPROM_SIZES-1
101ALIGN JUMP_ALIGN
102.CheckNextEepromSize:
103 cmp cx, [cs:bx]
104 je SHORT .StoreImageSizeFromCX
105 jb SHORT .AppendZeroesToTheEndOfBuffer
106 inc bx
107 inc bx
108 dec dx
109 jnz SHORT .CheckNextEepromSize
110 xor cx, cx
111 jmp SHORT .StoreImageSizeFromCX ; 0 = 65536
112ALIGN WORD_ALIGN
113.rgwSupportedEepromSizes:
114 dw 4<<10
115 dw 8<<10
116 dw 16<<10
117 dw 32<<10
118
119;--------------------------------------------------------------------
120; .AppendZeroesToTheEndOfBuffer
121; Parameters:
122; CX: Size of loaded BIOS image
123; CS:BX: Ptr to EEPROM size
124; Returns:
125; CX: EEPROM size
126; Corrupts registers:
127; AX
128;--------------------------------------------------------------------
129ALIGN JUMP_ALIGN
130.AppendZeroesToTheEndOfBuffer:
131 push es
132 push di
133
134 call Buffers_GetFileBufferToESDI
135 mov ax, [cs:bx]
136 sub ax, cx ; AX = zeroes to append
137 xchg ax, cx ; AX = BIOS image size, CX = zeroes to append
138 add di, ax
139 call Memory_ZeroESDIwithSizeInCX
140 mov cx, [cs:bx]
141
142 pop di
143 pop es
144 ; Fall to .StoreImageSizeFromCX
145
146;--------------------------------------------------------------------
147; .StoreImageSizeFromCX
148; Parameters:
149; CX: Size of BIOS image (and EEPROM required)
150; Returns:
151; Nothing
152; Corrupts registers:
153; Nothing
154;--------------------------------------------------------------------
155ALIGN JUMP_ALIGN
156.StoreImageSizeFromCX:
157 mov [cs:g_cfgVars+CFGVARS.wImageSize], cx
158 ret
159
160
161;--------------------------------------------------------------------
162; Buffers_SetUnsavedChanges
163; Buffers_ClearUnsavedChanges
164; Parameters:
165; SS:BP: Menu handle
166; Returns:
167; Nothing
168; Corrupts registers:
169; Nothing
170;--------------------------------------------------------------------
171ALIGN JUMP_ALIGN
172Buffers_SetUnsavedChanges:
173 or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
174 ret
175
176ALIGN JUMP_ALIGN
177Buffers_ClearUnsavedChanges:
178 and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
179 ret
180
181
182;--------------------------------------------------------------------
183; Buffers_SaveChangesIfFileLoaded
184; Parameters:
185; Nothing
186; Returns:
187; Nothing
188; Corrupts registers:
189; AX, BX, CX, SI, DI
190;--------------------------------------------------------------------
191ALIGN JUMP_ALIGN
192Buffers_SaveChangesIfFileLoaded:
193 mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
194 and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
195 cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
196 jne SHORT .NothingToSave
197 call Dialogs_DisplaySaveChangesDialog
198 jnz SHORT .NothingToSave
199 jmp BiosFile_SaveUnsavedChanges
200ALIGN JUMP_ALIGN
201.NothingToSave:
202 ret
203
204
205;--------------------------------------------------------------------
206; Buffers_GenerateChecksum
207; Parameters:
208; Nothing
209; Returns:
210; Nothing
211; Corrupts registers:
212; AX, BX, CX, DI
213;--------------------------------------------------------------------
214ALIGN JUMP_ALIGN
215Buffers_GenerateChecksum:
216 push es
217
218 call Buffers_GetFileBufferToESDI
219 mov cx, [cs:g_cfgVars+CFGVARS.wImageSize]
220 dec cx ; Leave space for checksum byte
221 xor ax, ax
222ALIGN JUMP_ALIGN
223.SumNextByte:
224 add al, [es:di]
225 inc di
226 loop .SumNextByte
227 neg al
228 mov [es:di], al
229
230 pop es
231 ret
232
233
234;--------------------------------------------------------------------
235; Buffers_GetRomvarsFlagsToAX
236; Parameters:
237; Nothing
238; Returns:
239; AX: ROMVARS.wFlags
240; Corrupts registers:
241; BX
242;--------------------------------------------------------------------
243ALIGN JUMP_ALIGN
244Buffers_GetRomvarsFlagsToAX:
245 mov bx, ROMVARS.wFlags
246 ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
247
248;--------------------------------------------------------------------
249; Buffers_GetRomvarsValueToAXfromOffsetInBX
250; Parameters:
251; BX: ROMVARS offset
252; Returns:
253; AX: Value
254; Corrupts registers:
255; Nothing
256;--------------------------------------------------------------------
257ALIGN JUMP_ALIGN
258Buffers_GetRomvarsValueToAXfromOffsetInBX:
259 push es
260 push di
261 call Buffers_GetFileBufferToESDI
262 mov ax, [es:bx+di]
263 pop di
264 pop es
265 ret
266
267
268;--------------------------------------------------------------------
269; Buffers_GetFileBufferToESDI
270; Buffers_GetFileDialogItemBufferToESDI
271; Parameters:
272; Nothing
273; Returns:
274; ES:DI: Ptr to file buffer
275; Corrupts registers:
276; Nothing
277;--------------------------------------------------------------------
278ALIGN JUMP_ALIGN
279Buffers_GetFileDialogItemBufferToESDI:
280 call Buffers_GetFileBufferToESDI
281 push di
282 mov di, es
283 add di, 1000h ; Third 64k page
284 mov es, di
285 pop di
286 ret
287Buffers_GetFileBufferToESDI:
288 mov di, cs
289 add di, 1000h ; Change to next 64k page
290 mov es, di
291 xor di, di ; Ptr now in ES:DI
292 ret
Note: See TracBrowser for help on using the repository browser.