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