source: oup/rewrite/Global/RawList.pas@ 103

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