1 | ; File name : Buffers.asm
|
---|
2 | ; Project name : XTIDE Universal BIOS Configurator v2
|
---|
3 | ; Created date : 6.10.2010
|
---|
4 | ; Last update : 6.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 | 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 | ;--------------------------------------------------------------------
|
---|
59 | ALIGN JUMP_ALIGN
|
---|
60 | Buffers_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 | ; DX:CX: EEPROM size in bytes
|
---|
78 | ; Returns:
|
---|
79 | ; Nothing
|
---|
80 | ; Corrupts registers:
|
---|
81 | ; AX, CX, DX
|
---|
82 | ;--------------------------------------------------------------------
|
---|
83 | ALIGN JUMP_ALIGN
|
---|
84 | Buffers_NewBiosWithSizeInDXCXandSourceInAXhasBeenLoadedForConfiguration:
|
---|
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 | shr dx, 1
|
---|
88 | rcr cx, 1
|
---|
89 | mov [cs:g_cfgVars+CFGVARS.wImageSizeInWords], cx
|
---|
90 | ret
|
---|
91 |
|
---|
92 |
|
---|
93 | ;--------------------------------------------------------------------
|
---|
94 | ; Buffers_SetUnsavedChanges
|
---|
95 | ; Buffers_ClearUnsavedChanges
|
---|
96 | ; Parameters:
|
---|
97 | ; SS:BP: Menu handle
|
---|
98 | ; Returns:
|
---|
99 | ; Nothing
|
---|
100 | ; Corrupts registers:
|
---|
101 | ; Nothing
|
---|
102 | ;--------------------------------------------------------------------
|
---|
103 | ALIGN JUMP_ALIGN
|
---|
104 | Buffers_SetUnsavedChanges:
|
---|
105 | or WORD [g_cfgVars+CFGVARS.wFlags], FLG_CFGVARS_UNSAVED
|
---|
106 | ret
|
---|
107 |
|
---|
108 | ALIGN JUMP_ALIGN
|
---|
109 | Buffers_ClearUnsavedChanges:
|
---|
110 | and WORD [g_cfgVars+CFGVARS.wFlags], ~FLG_CFGVARS_UNSAVED
|
---|
111 | ret
|
---|
112 |
|
---|
113 |
|
---|
114 | ;--------------------------------------------------------------------
|
---|
115 | ; Buffers_SaveChangesIfFileLoaded
|
---|
116 | ; Parameters:
|
---|
117 | ; Nothing
|
---|
118 | ; Returns:
|
---|
119 | ; Nothing
|
---|
120 | ; Corrupts registers:
|
---|
121 | ; AX, BX, CX, SI, DI
|
---|
122 | ;--------------------------------------------------------------------
|
---|
123 | ALIGN JUMP_ALIGN
|
---|
124 | Buffers_SaveChangesIfFileLoaded:
|
---|
125 | mov ax, [cs:g_cfgVars+CFGVARS.wFlags]
|
---|
126 | and ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
|
---|
127 | cmp ax, BYTE (FLG_CFGVARS_FILELOADED | FLG_CFGVARS_UNSAVED)
|
---|
128 | jne SHORT .NothingToSave
|
---|
129 | call Dialogs_DisplaySaveChangesDialog
|
---|
130 | jnz SHORT .NothingToSave
|
---|
131 | jmp BiosFile_SaveUnsavedChanges
|
---|
132 | ALIGN JUMP_ALIGN
|
---|
133 | .NothingToSave:
|
---|
134 | ret
|
---|
135 |
|
---|
136 |
|
---|
137 | ;--------------------------------------------------------------------
|
---|
138 | ; Buffers_AppendZeroesIfNeeded
|
---|
139 | ; Parameters:
|
---|
140 | ; Nothing
|
---|
141 | ; Returns:
|
---|
142 | ; Nothing
|
---|
143 | ; Corrupts registers:
|
---|
144 | ; AX, CX, DI
|
---|
145 | ;--------------------------------------------------------------------
|
---|
146 | ALIGN JUMP_ALIGN
|
---|
147 | Buffers_AppendZeroesIfNeeded:
|
---|
148 | push es
|
---|
149 |
|
---|
150 | eMOVZX di, BYTE [cs:g_cfgVars+CFGVARS.bEepromType]
|
---|
151 | mov cx, [cs:di+g_rgwEepromTypeToSizeInWords]
|
---|
152 | sub cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords] ; CX = WORDs to append
|
---|
153 | jle SHORT .NoNeedToAppendZeroes
|
---|
154 |
|
---|
155 | call Buffers_GetFileBufferToESDI
|
---|
156 | mov ax, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
157 | shl ax, 1
|
---|
158 | add di, ax ; ES:DI now point first unused image byte
|
---|
159 | xor ax, ax
|
---|
160 | cld
|
---|
161 | rep stosw
|
---|
162 | ALIGN JUMP_ALIGN
|
---|
163 | .NoNeedToAppendZeroes:
|
---|
164 | pop es
|
---|
165 | ret
|
---|
166 |
|
---|
167 |
|
---|
168 | ;--------------------------------------------------------------------
|
---|
169 | ; Buffers_GenerateChecksum
|
---|
170 | ; Parameters:
|
---|
171 | ; Nothing
|
---|
172 | ; Returns:
|
---|
173 | ; Nothing
|
---|
174 | ; Corrupts registers:
|
---|
175 | ; AX, BX, CX, DI
|
---|
176 | ;--------------------------------------------------------------------
|
---|
177 | ALIGN JUMP_ALIGN
|
---|
178 | Buffers_GenerateChecksum:
|
---|
179 | push es
|
---|
180 |
|
---|
181 | call Buffers_GetFileBufferToESDI
|
---|
182 | mov cx, [cs:g_cfgVars+CFGVARS.wImageSizeInWords]
|
---|
183 | shl cx, 1 ; Words to bytes
|
---|
184 | dec cx ; Leave space for checksum byte
|
---|
185 | xor ax, ax
|
---|
186 | ALIGN JUMP_ALIGN
|
---|
187 | .SumNextByte:
|
---|
188 | add al, [es:di]
|
---|
189 | inc di
|
---|
190 | loop .SumNextByte
|
---|
191 | neg al
|
---|
192 | mov [es:di], al
|
---|
193 |
|
---|
194 | pop es
|
---|
195 | ret
|
---|
196 |
|
---|
197 |
|
---|
198 | ;--------------------------------------------------------------------
|
---|
199 | ; Buffers_GetRomvarsFlagsToAX
|
---|
200 | ; Parameters:
|
---|
201 | ; Nothing
|
---|
202 | ; Returns:
|
---|
203 | ; AX: ROMVARS.wFlags
|
---|
204 | ; Corrupts registers:
|
---|
205 | ; BX
|
---|
206 | ;--------------------------------------------------------------------
|
---|
207 | ALIGN JUMP_ALIGN
|
---|
208 | Buffers_GetRomvarsFlagsToAX:
|
---|
209 | mov bx, ROMVARS.wFlags
|
---|
210 | ; Fall to Buffers_GetRomvarsValueToAXfromOffsetInBX
|
---|
211 |
|
---|
212 | ;--------------------------------------------------------------------
|
---|
213 | ; Buffers_GetRomvarsValueToAXfromOffsetInBX
|
---|
214 | ; Parameters:
|
---|
215 | ; BX: ROMVARS offset
|
---|
216 | ; Returns:
|
---|
217 | ; AX: Value
|
---|
218 | ; Corrupts registers:
|
---|
219 | ; Nothing
|
---|
220 | ;--------------------------------------------------------------------
|
---|
221 | ALIGN JUMP_ALIGN
|
---|
222 | Buffers_GetRomvarsValueToAXfromOffsetInBX:
|
---|
223 | push es
|
---|
224 | push di
|
---|
225 | call Buffers_GetFileBufferToESDI
|
---|
226 | mov ax, [es:bx+di]
|
---|
227 | pop di
|
---|
228 | pop es
|
---|
229 | ret
|
---|
230 |
|
---|
231 |
|
---|
232 | ;--------------------------------------------------------------------
|
---|
233 | ; Buffers_GetFileBufferToESDI
|
---|
234 | ; Buffers_GetFlashComparisonBufferToESDI
|
---|
235 | ; Buffers_GetFileDialogItemBufferToESDI
|
---|
236 | ; Parameters:
|
---|
237 | ; Nothing
|
---|
238 | ; Returns:
|
---|
239 | ; ES:DI: Ptr to file buffer
|
---|
240 | ; Corrupts registers:
|
---|
241 | ; Nothing
|
---|
242 | ;--------------------------------------------------------------------
|
---|
243 | ALIGN JUMP_ALIGN
|
---|
244 | Buffers_GetFlashComparisonBufferToESDI:
|
---|
245 | Buffers_GetFileDialogItemBufferToESDI:
|
---|
246 | call Buffers_GetFileBufferToESDI
|
---|
247 | push di
|
---|
248 | mov di, es
|
---|
249 | add di, 1000h ; Third 64k page
|
---|
250 | mov es, di
|
---|
251 | pop di
|
---|
252 | ret
|
---|
253 | ALIGN JUMP_ALIGN
|
---|
254 | Buffers_GetFileBufferToESDI:
|
---|
255 | mov di, cs
|
---|
256 | add di, 1000h ; Change to next 64k page
|
---|
257 | mov es, di
|
---|
258 | xor di, di ; Ptr now in ES:DI
|
---|
259 | ret
|
---|