1 | ; File name : Buffers.asm
|
---|
2 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
3 | ; Created date : 6.10.2010
|
---|
4 | ; Last update : 5.12.2010
|
---|
5 | ; Author : Tomi Tilli
|
---|
6 | ; Description : Functions for accessing file and flash buffers.
|
---|
7 |
|
---|
8 | ; Section containing code
|
---|
9 | SECTION .text
|
---|
10 |
|
---|
11 | ;--------------------------------------------------------------------
|
---|
12 | ; Buffers_Clear
|
---|
13 | ; Parameters:
|
---|
14 | ; Nothing
|
---|
15 | ; Returns:
|
---|
16 | ; Nothing
|
---|
17 | ; Corrupts registers:
|
---|
18 | ; AX, CX, DI, ES
|
---|
19 | ;--------------------------------------------------------------------
|
---|
20 | ALIGN JUMP_ALIGN
|
---|
21 | Buffers_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 | ;--------------------------------------------------------------------
|
---|
37 | ALIGN JUMP_ALIGN
|
---|
38 | Buffers_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 | call Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
44 | jnz SHORT .NoFileOrBiosLoaded
|
---|
45 | jmp SHORT .IsSupportedVersionOfXtideUniversalBiosLoaded
|
---|
46 | .NoFileOrBiosLoaded:
|
---|
47 | or cl, 1 ; Clear ZF
|
---|
48 | ret
|
---|
49 |
|
---|
50 |
|
---|
51 | ALIGN JUMP_ALIGN
|
---|
52 | .IsSupportedVersionOfXtideUniversalBiosLoaded:
|
---|
53 |
|
---|
54 |
|
---|
55 | ;--------------------------------------------------------------------
|
---|
56 | ; Buffers_IsXtideUniversalBiosSignatureInESDI
|
---|
57 | ; Parameters:
|
---|
58 | ; ES:DI: Ptr to possible XTIDE Universal BIOS location
|
---|
59 | ; Returns:
|
---|
60 | ; ZF: Set if supported version of XTIDE Universal BIOS is loaded
|
---|
61 | ; Cleared no file or some other file is loaded
|
---|
62 | ; Corrupts registers:
|
---|
63 | ; CX, SI
|
---|
64 | ;--------------------------------------------------------------------
|
---|
65 | ALIGN JUMP_ALIGN
|
---|
66 | Buffers_IsXtideUniversalBiosSignatureInESDI:
|
---|
67 | push di
|
---|
68 |
|
---|
69 | mov si, g_szXtideUniversalBiosSignature
|
---|
70 | add di, BYTE ROMVARS.rgbSign
|
---|
71 | mov cx, XTIDE_SIGNATURE_LENGTH / 2
|
---|
72 | cld
|
---|
73 | eSEG_STR repe, cs, cmpsw
|
---|
74 |
|
---|
75 | pop di
|
---|
76 | ret
|
---|
77 |
|
---|
78 |
|
---|
79 | ;--------------------------------------------------------------------
|
---|
80 | ; Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration
|
---|
81 | ; Parameters:
|
---|
82 | ; AX: EEPROM source (FLG_CFGVARS_FILELOADED or FLG_CFGVARS_ROMLOADED)
|
---|
83 | ; CX: EEPROM size in bytes
|
---|
84 | ; Returns:
|
---|
85 | ; Nothing
|
---|
86 | ; Corrupts registers:
|
---|
87 | ; AX, CX
|
---|
88 | ;--------------------------------------------------------------------
|
---|
89 | ALIGN JUMP_ALIGN
|
---|
90 | Buffers_NewBiosWithSizeInCXandSourceInAXhasBeenLoadedForConfiguration:
|
---|
91 | and WORD [cs:g_cfgVars+CFGVARS.wFlags], ~(FLG_CFGVARS_FILELOADED | FLG_CFGVARS_ROMLOADED | FLG_CFGVARS_UNSAVED)
|
---|
92 | or WORD [cs:g_cfgVars+CFGVARS.wFlags], ax
|
---|
93 | mov ax, (64<<10) / 2 ; 32768 WORDs
|
---|
94 | shr cx, 1 ; Bytes to WORDs
|
---|
95 | eCMOVZ cx, ax
|
---|
96 | mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
|
---|
97 | ret
|
---|
98 |
|
---|
99 |
|
---|
100 | ;--------------------------------------------------------------------
|
---|
101 | ; Buffers_SetUnsavedChanges
|
---|
102 | ; Buffers_ClearUnsavedChanges
|
---|
103 | ; Parameters:
|
---|
104 | ; SS:BP: Menu handle
|
---|
105 | ; Returns:
|
---|
106 | ; Nothing
|
---|
107 | ; Corrupts registers:
|
---|
108 | ; Nothing
|
---|
109 | ;--------------------------------------------------------------------
|
---|
110 | ALIGN JUMP_ALIGN
|
---|
111 | Buffers_SetUnsavedChanges:
|
---|
112 | or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
|
---|
113 | ret
|
---|
114 |
|
---|
115 | ALIGN JUMP_ALIGN
|
---|
116 | Buffers_ClearUnsavedChanges:
|
---|
117 | and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
|
---|
118 | ret
|
---|
119 |
|
---|
120 |
|
---|
121 | ;--------------------------------------------------------------------
|
---|
122 | ; Buffers_SaveChangesIfFileLoaded
|
---|
123 | ; Parameters:
|
---|
124 | ; Nothing
|
---|
125 | ; Returns:
|
---|
126 | ; Nothing
|
---|
127 | ; Corrupts registers:
|
---|
128 | ; AX, BX, CX, SI, DI
|
---|
129 | ;--------------------------------------------------------------------
|
---|
130 | ALIGN JUMP_ALIGN
|
---|
131 | Buffers_SaveChangesIfFileLoaded:
|
---|
132 | mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
|
---|
133 | and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
|
---|
134 | cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
|
---|
135 | jne SHORT .NothingToSave
|
---|
136 | call Dialogs_DisplaySaveChangesDialog
|
---|
137 | jnz SHORT .NothingToSave
|
---|
138 | jmp BiosFile_SaveUnsavedChanges
|
---|
139 | ALIGN JUMP_ALIGN
|
---|
140 | .NothingToSave:
|
---|
141 | ret
|
---|
142 |
|
---|
143 |
|
---|
144 | ;--------------------------------------------------------------------
|
---|
145 | ; Buffers_AppendZeroesIfNeeded
|
---|
146 | ; Parameters:
|
---|
147 | ; Nothing
|
---|
148 | ; Returns:
|
---|
149 | ; Nothing
|
---|
150 | ; Corrupts registers:
|
---|
151 | ; AX, CX, DI
|
---|
152 | ;--------------------------------------------------------------------
|
---|
153 | ALIGN JUMP_ALIGN
|
---|
154 | Buffers_AppendZeroesIfNeeded:
|
---|
155 | push es
|
---|
156 |
|
---|
157 | eMOVZX di, BYTE [cs:g_cfgVars+CFGVARS.bEepromType]
|
---|
158 | mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
|
---|
159 | sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
|
---|
160 | jle SHORT .NoNeedToAppendZeroes
|
---|
161 |
|
---|
162 | call Buffers_GetFileBufferToESDI
|
---|
163 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
164 | shl ax, 1
|
---|
165 | add di, ax ; ES:DI now point first unused image byte
|
---|
166 | xor ax, ax
|
---|
167 | cld
|
---|
168 | rep stosw
|
---|
169 | ALIGN JUMP_ALIGN
|
---|
170 | .NoNeedToAppendZeroes:
|
---|
171 | pop es
|
---|
172 | ret
|
---|
173 |
|
---|
174 |
|
---|
175 | ;--------------------------------------------------------------------
|
---|
176 | ; Buffers_GenerateChecksum
|
---|
177 | ; Parameters:
|
---|
178 | ; Nothing
|
---|
179 | ; Returns:
|
---|
180 | ; Nothing
|
---|
181 | ; Corrupts registers:
|
---|
182 | ; AX, BX, CX, DI
|
---|
183 | ;--------------------------------------------------------------------
|
---|
184 | ALIGN JUMP_ALIGN
|
---|
185 | Buffers_GenerateChecksum:
|
---|
186 | push es
|
---|
187 |
|
---|
188 | call Buffers_GetFileBufferToESDI
|
---|
189 | mov cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
190 | shl cx, 1 ; Words to bytes
|
---|
191 | dec cx ; Leave space for checksum byte
|
---|
192 | xor ax, ax
|
---|
193 | ALIGN JUMP_ALIGN
|
---|
194 | .SumNextByte:
|
---|
195 | add al, [es:di]
|
---|
196 | inc di
|
---|
197 | loop .SumNextByte
|
---|
198 | neg al
|
---|
199 | mov [es:di], al
|
---|
200 |
|
---|
201 | pop es
|
---|
202 | ret
|
---|
203 |
|
---|
204 |
|
---|
205 | ;--------------------------------------------------------------------
|
---|
206 | ; Buffers_GetRomvarsFlagsToAX
|
---|
207 | ; Parameters:
|
---|
208 | ; Nothing
|
---|
209 | ; Returns:
|
---|
210 | ; AX: ROMVARS.wFlags
|
---|
211 | ; Corrupts registers:
|
---|
212 | ; BX
|
---|
213 | ;--------------------------------------------------------------------
|
---|
214 | ALIGN JUMP_ALIGN
|
---|
215 | Buffers_GetRomvarsFlagsToAX:
|
---|
216 | mov bx, ROMVARS.wFlags
|
---|
217 | ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
|
---|
218 |
|
---|
219 | ;--------------------------------------------------------------------
|
---|
220 | ; Buffers_GetRomvarsValueToAXfromOffsetInBX
|
---|
221 | ; Parameters:
|
---|
222 | ; BX: ROMVARS offset
|
---|
223 | ; Returns:
|
---|
224 | ; AX: Value
|
---|
225 | ; Corrupts registers:
|
---|
226 | ; Nothing
|
---|
227 | ;--------------------------------------------------------------------
|
---|
228 | ALIGN JUMP_ALIGN
|
---|
229 | Buffers_GetRomvarsValueToAXfromOffsetInBX:
|
---|
230 | push es
|
---|
231 | push di
|
---|
232 | call Buffers_GetFileBufferToESDI
|
---|
233 | mov ax, [es:bx+di]
|
---|
234 | pop di
|
---|
235 | pop es
|
---|
236 | ret
|
---|
237 |
|
---|
238 |
|
---|
239 | ;--------------------------------------------------------------------
|
---|
240 | ; Buffers_GetFileBufferToESDI
|
---|
241 | ; Buffers_GetFlashComparisonBufferToESDI
|
---|
242 | ; Buffers_GetFileDialogItemBufferToESDI
|
---|
243 | ; Parameters:
|
---|
244 | ; Nothing
|
---|
245 | ; Returns:
|
---|
246 | ; ES:DI: Ptr to file buffer
|
---|
247 | ; Corrupts registers:
|
---|
248 | ; Nothing
|
---|
249 | ;--------------------------------------------------------------------
|
---|
250 | ALIGN JUMP_ALIGN
|
---|
251 | Buffers_GetFlashComparisonBufferToESDI:
|
---|
252 | Buffers_GetFileDialogItemBufferToESDI:
|
---|
253 | call Buffers_GetFileBufferToESDI
|
---|
254 | push di
|
---|
255 | mov di, es
|
---|
256 | add di, 1000h ; Third 64k page
|
---|
257 | mov es, di
|
---|
258 | pop di
|
---|
259 | ret
|
---|
260 | ALIGN JUMP_ALIGN
|
---|
261 | Buffers_GetFileBufferToESDI:
|
---|
262 | mov di, cs
|
---|
263 | add di, 1000h ; Change to next 64k page
|
---|
264 | mov es, di
|
---|
265 | xor di, di ; Ptr now in ES:DI
|
---|
266 | ret
|
---|