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

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