1 |
unit RawList; |
2 |
|
3 |
interface |
4 |
|
5 |
uses TypeDefs; |
6 |
|
7 |
type |
8 |
THandler = function(ConnectionID, FileID: Integer): TRawDataList; |
9 |
TRawListHandler = record |
10 |
Ext: String[4]; |
11 |
needed: Boolean; |
12 |
Handler: THandler; |
13 |
end; |
14 |
TRawListHandlers = array of TRawListHandler; |
15 |
|
16 |
TRawLists = class |
17 |
private |
18 |
FRawListHandlers: TRawListHandlers; |
19 |
public |
20 |
property RawListHandlers: TRawListHandlers read FRawListHandlers; |
21 |
procedure InsertRawListHandler(ext: String; needed: Boolean; handler: THandler); |
22 |
function GetRawList(ConnectionID, FileID: Integer): TRawDataList; |
23 |
function GetRawInfo(ConnectionID, FileID, DatOffset: Integer): TRawDataInfo; |
24 |
end; |
25 |
|
26 |
|
27 |
var |
28 |
RawLists: TRawLists; |
29 |
|
30 |
|
31 |
implementation |
32 |
|
33 |
uses |
34 |
Template, ConnectionManager, Access_OniArchive, Classes, SysUtils; |
35 |
|
36 |
|
37 |
function AGDB(ConnectionID, FileID: Integer): TRawDataList; |
38 |
var |
39 |
link: Integer; |
40 |
links: Integer; |
41 |
i: Integer; |
42 |
begin |
43 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); |
44 |
links := links * 2; |
45 |
SetLength(Result, links); |
46 |
for i := 0 to links - 1 do |
47 |
begin |
48 |
Result[i].SrcOffset := $20 + i * 4; |
49 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * 4, 4, @link); |
50 |
Result[i].RawAddr := link; |
51 |
Result[i].RawSize := 32; |
52 |
Result[i].LocSep := False; |
53 |
end; |
54 |
end; |
55 |
|
56 |
|
57 |
|
58 |
|
59 |
function AKVA(ConnectionID, FileID: Integer): TRawDataList; |
60 |
var |
61 |
link: Integer; |
62 |
links: Integer; |
63 |
i: Integer; |
64 |
begin |
65 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); |
66 |
SetLength(Result, links); |
67 |
for i := 0 to links - 1 do |
68 |
begin |
69 |
Result[i].SrcOffset := $20 + i * $74 + $24; |
70 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $24, 4, @link); |
71 |
Result[i].RawAddr := link; |
72 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + i * $74 + $28, 4, @link); |
73 |
Result[i].RawSize := link; |
74 |
Result[i].LocSep := False; |
75 |
end; |
76 |
end; |
77 |
|
78 |
|
79 |
|
80 |
|
81 |
function BINA(ConnectionID, FileID: Integer): TRawDataList; |
82 |
var |
83 |
link: Integer; |
84 |
datasize: Integer; |
85 |
begin |
86 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link); |
87 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize); |
88 |
SetLength(Result, 1); |
89 |
Result[0].SrcOffset := $0C; |
90 |
Result[0].RawAddr := link; |
91 |
Result[0].RawSize := datasize; |
92 |
Result[0].LocSep := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN); |
93 |
end; |
94 |
|
95 |
|
96 |
|
97 |
|
98 |
function OSBD(ConnectionID, FileID: Integer): TRawDataList; |
99 |
var |
100 |
link: Integer; |
101 |
datasize: Integer; |
102 |
begin |
103 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize); |
104 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link); |
105 |
SetLength(Result, 1); |
106 |
Result[0].SrcOffset := $0C; |
107 |
Result[0].RawAddr := link; |
108 |
Result[0].RawSize := datasize; |
109 |
Result[0].LocSep := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN); |
110 |
end; |
111 |
|
112 |
|
113 |
|
114 |
|
115 |
function SNDD(ConnectionID, FileID: Integer): TRawDataList; |
116 |
var |
117 |
link: Integer; |
118 |
datasize: Integer; |
119 |
begin |
120 |
SetLength(Result, 1); |
121 |
if ConManager.Connection[ConnectionID].DataOS = DOS_MAC then |
122 |
begin |
123 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize); |
124 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link); |
125 |
Result[0].SrcOffset := $14; |
126 |
end |
127 |
else |
128 |
begin |
129 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $40, 4, @datasize); |
130 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link); |
131 |
Result[0].SrcOffset := $44; |
132 |
end; |
133 |
Result[0].RawAddr := link; |
134 |
Result[0].RawSize := datasize; |
135 |
Result[0].LocSep := False; |
136 |
end; |
137 |
|
138 |
|
139 |
|
140 |
|
141 |
function SUBT(ConnectionID, FileID: Integer): TRawDataList; |
142 |
var |
143 |
baselink, lastlink: Integer; |
144 |
links: Integer; |
145 |
j, k: Integer; |
146 |
// Data: TByteData; |
147 |
Data: TStream; |
148 |
begin |
149 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @baselink); |
150 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); |
151 |
if links > 0 then |
152 |
begin |
153 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink); |
154 |
// SetLength(Data, lastlink + 1024); |
155 |
Data := nil; |
156 |
TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset( |
157 |
False, baselink, lastlink + 1024, Data); |
158 |
// TOniDataDat(connection).LoadRawOffset(False, baselink, lastlink + 1024, Data); |
159 |
// connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]); |
160 |
raise ENotImplemented.Create('RawList.SUBT'); |
161 |
end; |
162 |
{ |
163 |
k := 0; |
164 |
for j := 0 to 1024 do |
165 |
begin |
166 |
if (Data[lastlink + j] = $00) or (j = 1024) then |
167 |
begin |
168 |
if j < 1024 then |
169 |
begin |
170 |
if k = 0 then |
171 |
begin |
172 |
k := 1; |
173 |
end |
174 |
else |
175 |
begin |
176 |
SetLength(Result, 1); |
177 |
Result[0].src_offset := $18; |
178 |
Result[0].raw_addr := baselink; |
179 |
Result[0].raw_size := lastlink + j; |
180 |
Break; |
181 |
end; |
182 |
end; |
183 |
end; |
184 |
end; |
185 |
end; |
186 |
} |
187 |
end; |
188 |
|
189 |
|
190 |
|
191 |
|
192 |
function TRAM(ConnectionID, FileID: Integer): TRawDataList; |
193 |
var |
194 |
i: Integer; |
195 |
link: Integer; |
196 |
frames: Word; |
197 |
tempb: Byte; |
198 |
tempw: Word; |
199 |
templ: Integer; |
200 |
Data: TByteData; |
201 |
offset: Word; |
202 |
frame_count: Byte; |
203 |
begin |
204 |
SetLength(Result, 13); |
205 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $16C, 2, @frames); |
206 |
{y-pos} |
207 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link); |
208 |
Result[0].SrcOffset := $0C; |
209 |
Result[0].RawAddr := link; |
210 |
Result[0].RawSize := frames * 4; |
211 |
{x-z-pos} |
212 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @link); |
213 |
Result[1].SrcOffset := $10; |
214 |
Result[1].RawAddr := link; |
215 |
Result[1].RawSize := frames * 8; |
216 |
{attacks} |
217 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $182, 1, @tempb); |
218 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link); |
219 |
Result[2].SrcOffset := $14; |
220 |
Result[2].RawAddr := link; |
221 |
Result[2].RawSize := tempb * 32; |
222 |
{damage} |
223 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $183, 1, @tempb); |
224 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @link); |
225 |
Result[3].SrcOffset := $18; |
226 |
Result[3].RawAddr := link; |
227 |
Result[3].RawSize := tempb * 8; |
228 |
{motionblur} |
229 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $184, 1, @tempb); |
230 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link); |
231 |
Result[4].SrcOffset := $1C; |
232 |
Result[4].RawAddr := link; |
233 |
Result[4].RawSize := tempb * 8; |
234 |
{shortcut} |
235 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb); |
236 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link); |
237 |
Result[5].SrcOffset := $20; |
238 |
Result[5].RawAddr := link; |
239 |
Result[5].RawSize := tempb * 8; |
240 |
{throw} |
241 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $24, 4, @link); |
242 |
Result[6].SrcOffset := $24; |
243 |
Result[6].RawAddr := link; |
244 |
if link > 0 then |
245 |
Result[6].RawSize := 24 |
246 |
else |
247 |
Result[6].RawSize := 0; |
248 |
{footstep} |
249 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $186, 1, @tempb); |
250 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $28, 4, @link); |
251 |
Result[7].SrcOffset := $28; |
252 |
Result[7].RawAddr := link; |
253 |
Result[7].RawSize := tempb * 4; |
254 |
{particle} |
255 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $187, 1, @tempb); |
256 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $2C, 4, @link); |
257 |
Result[8].SrcOffset := $2C; |
258 |
Result[8].RawAddr := link; |
259 |
Result[8].RawSize := tempb * 24; |
260 |
{position} |
261 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $30, 4, @link); |
262 |
Result[9].SrcOffset := $30; |
263 |
Result[9].RawAddr := link; |
264 |
Result[9].RawSize := frames * 8; |
265 |
{particle} |
266 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $154, 2, @tempw); |
267 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $38, 4, @link); |
268 |
Result[11].SrcOffset := $38; |
269 |
Result[11].RawAddr := link; |
270 |
Result[11].RawSize := tempw * 34; |
271 |
{extent} |
272 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $138, 4, @templ); |
273 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $13C, 4, @link); |
274 |
Result[12].SrcOffset := $13C; |
275 |
Result[12].RawAddr := link; |
276 |
Result[12].RawSize := templ * 12; |
277 |
|
278 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $34, 4, @link); |
279 |
if link > 0 then |
280 |
begin |
281 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $160, 2, @tempw); |
282 |
frame_count := 0; |
283 |
i := 0; |
284 |
SetLength(Data, $FFFF); |
285 |
TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset( |
286 |
False, link, $FFFF, Data); |
287 |
offset := Data[$24] + Data[$25] * 256; |
288 |
while (offset + i < Length(Data)) and (frame_count < frames - 1) do |
289 |
begin |
290 |
Inc(i, tempw); |
291 |
frame_count := frame_count + Data[offset + i]; |
292 |
Inc(i); |
293 |
end; |
294 |
if offset + i < Length(Data) then |
295 |
begin |
296 |
Inc(i, tempw); |
297 |
Result[10].RawSize := offset + i; |
298 |
end |
299 |
else |
300 |
begin |
301 |
Result[10].RawSize := 0; |
302 |
end; |
303 |
end; |
304 |
Result[10].SrcOffset := $34; |
305 |
Result[10].RawAddr := link; |
306 |
end; |
307 |
|
308 |
|
309 |
|
310 |
|
311 |
function TXMP(ConnectionID, FileID: Integer): TRawDataList; |
312 |
var |
313 |
link_pc: Integer; |
314 |
link_mac: Integer; |
315 |
x, y: Word; |
316 |
storetype: Byte; |
317 |
datasize: Integer; |
318 |
begin |
319 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x); |
320 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y); |
321 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype); |
322 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc); |
323 |
ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac); |
324 |
case storetype of |
325 |
0, 1, 2: |
326 |
datasize := x * y * 2; |
327 |
8: |
328 |
datasize := x * y * 4; |
329 |
9: |
330 |
datasize := x * y div 2; |
331 |
end; |
332 |
SetLength(Result, 1); |
333 |
if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then |
334 |
begin |
335 |
Result[0].SrcOffset := $9C; |
336 |
Result[0].RawAddr := link_pc; |
337 |
end |
338 |
else |
339 |
begin |
340 |
Result[0].SrcOffset := $A0; |
341 |
Result[0].RawAddr := link_mac; |
342 |
end; |
343 |
Result[0].RawSize := datasize; |
344 |
Result[0].LocSep := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN); |
345 |
end; |
346 |
|
347 |
|
348 |
|
349 |
|
350 |
function TRawLists.GetRawInfo(ConnectionID, FileID, |
351 |
DatOffset: Integer): TRawDataInfo; |
352 |
var |
353 |
i: Integer; |
354 |
RawList: TRawDataList; |
355 |
begin |
356 |
RawList := GetRawList(ConnectionID, FileID); |
357 |
Result.SrcID := -1; |
358 |
Result.SrcOffset := -1; |
359 |
Result.RawAddr := -1; |
360 |
Result.RawSize := -1; |
361 |
if Length(RawList) > 0 then |
362 |
begin |
363 |
for i := 0 to High(RawList) do |
364 |
begin |
365 |
if RawList[i].SrcOffset = DatOffset then |
366 |
begin |
367 |
Result.SrcID := FileID; |
368 |
Result.SrcOffset := RawList[i].SrcOffset; |
369 |
Result.RawAddr := RawList[i].RawAddr; |
370 |
Result.RawSize := RawList[i].RawSize; |
371 |
Result.LocSep := RawList[i].LocSep; |
372 |
Break; |
373 |
end; |
374 |
end; |
375 |
end; |
376 |
end; |
377 |
|
378 |
|
379 |
function TRawLists.GetRawList(ConnectionID, FileID: Integer): TRawDataList; |
380 |
var |
381 |
i: Integer; |
382 |
fileinfo: TFileInfo; |
383 |
begin |
384 |
SetLength(Result, 0); |
385 |
fileinfo := ConManager.Connection[ConnectionID].GetFileInfo(FileID); |
386 |
for i := 0 to High(FRawListHandlers) do |
387 |
if UpperCase(FRawListHandlers[i].Ext) = UpperCase(fileinfo.extension) then |
388 |
begin |
389 |
if FRawListHandlers[i].needed then |
390 |
Result := FRawListHandlers[i].Handler(ConnectionID, FileID); |
391 |
Break; |
392 |
end; |
393 |
end; |
394 |
|
395 |
procedure TRawLists.InsertRawListHandler(ext: String; needed: Boolean; handler: THandler); |
396 |
begin |
397 |
SetLength(FRawListHandlers, Length(FRawListHandlers) + 1); |
398 |
FRawListHandlers[High(FRawListHandlers)].Ext := ext; |
399 |
FRawListHandlers[High(FRawListHandlers)].needed := needed; |
400 |
FRawListHandlers[High(FRawListHandlers)].handler := handler; |
401 |
// Raws := Raws + ext; |
402 |
AddToolListEntry('rawedit', '', ext); |
403 |
end; |
404 |
|
405 |
|
406 |
|
407 |
|
408 |
initialization |
409 |
RawLists := TRawLists.Create; |
410 |
RawLists.InsertRawListHandler('AGDB',False,AGDB); |
411 |
RawLists.InsertRawListHandler('AKVA', True, AKVA); |
412 |
RawLists.InsertRawListHandler('BINA', True, BINA); |
413 |
RawLists.InsertRawListHandler('OSBD', True, OSBD); |
414 |
RawLists.InsertRawListHandler('SNDD', True, SNDD); |
415 |
RawLists.InsertRawListHandler('SUBT', True, SUBT); |
416 |
RawLists.InsertRawListHandler('TRAM', True, TRAM); |
417 |
RawLists.InsertRawListHandler('TXMP', True, TXMP); |
418 |
end. |