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