ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/oup/current/Global/RawList.pas
(Generate patch)

Comparing:
oup/rewrite/Global/RawList.pas (file contents), Revision 97 by alloc, Mon Jan 22 23:05:45 2007 UTC vs.
oup/current/Global/RawList.pas (file contents), Revision 222 by alloc, Mon Jun 18 14:22:53 2007 UTC

# Line 1 | Line 1
1   unit RawList;
2
2   interface
3 <
5 < uses TypeDefs, ConnectionManager;
3 > uses TypeDefs;
4  
5   type
6    THandler = function(ConnectionID, FileID: Integer): TRawDataList;
7 <  TRawListHandlers = record
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;
# Line 24 | Line 24 | type
24  
25   var
26    RawLists: TRawLists;
27 <  
27 >
28  
29   implementation
30  
31   uses
32 <  Template;
32 >  Template, ConnectionManager, Access_OniArchive, Classes, SysUtils, Math;
33  
34  
35   function AGDB(ConnectionID, FileID: Integer): TRawDataList;
# Line 38 | Line 38 | var
38    links: Integer;
39    i:     Integer;
40   begin
41 <  if not connection.OSisMac then
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 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
47 <    links := links * 2;
48 <    SetLength(Result, links);
49 <    for i := 0 to links - 1 do
50 <    begin
51 <      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;
46 >    Result[i].Name := '<TBD>';
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;
53   end;
54  
# Line 63 | Line 61 | var
61    links: Integer;
62    i:     Integer;
63   begin
64 <  if not connection.OSisMac then
64 >  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
65 >  SetLength(Result, links);
66 >  for i := 0 to links - 1 do
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;
68 >    Result[i].Name := '<TBD>';
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  
# Line 90 | Line 86 | 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].src_offset := $0C;
90 <  Result[0].raw_addr   := link;
91 <  Result[0].raw_size   := datasize;
92 <  Result[0].loc_sep    := connection.OSisMac;
89 >  Result[0].Name := 'BinaryData';
90 >  Result[0].SrcOffset := $0C;
91 >  Result[0].RawAddr   := link;
92 >  Result[0].RawSize   := datasize;
93 >  Result[0].LocSep    := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
94   end;
95  
96  
# Line 107 | Line 104 | begin
104    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $08, 4, @datasize);
105    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
106    SetLength(Result, 1);
107 <  Result[0].src_offset := $0C;
108 <  Result[0].raw_addr   := link;
109 <  Result[0].raw_size   := datasize;
110 <  Result[0].loc_sep    := connection.OSisMac;
107 >  Result[0].Name := 'SoundBinaryData';
108 >  Result[0].SrcOffset := $0C;
109 >  Result[0].RawAddr   := link;
110 >  Result[0].RawSize   := datasize;
111 >  Result[0].LocSep     := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
112   end;
113  
114  
# Line 122 | Line 120 | var
120    datasize: Integer;
121   begin
122    SetLength(Result, 1);
123 <  if not connection.OSisMac then
123 >  if ConManager.Connection[ConnectionID].DataOS in [DOS_MACBETA, DOS_MAC] then
124    begin
125 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $40, 4, @datasize);
126 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link);
127 <    Result[0].src_offset := $44;
125 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize);
126 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
127 >    Result[0].SrcOffset := $14;
128    end
129    else
130    begin
131 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize);
132 <    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
133 <    Result[0].src_offset := $14;
131 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $40, 4, @datasize);
132 >    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link);
133 >    Result[0].SrcOffset := $44;
134    end;
135 <  Result[0].raw_addr := link;
136 <  Result[0].raw_size := datasize;
137 <  Result[0].loc_sep  := False;
135 >  Result[0].Name := 'SoundData';
136 >  Result[0].RawAddr := link;
137 >  Result[0].RawSize := datasize;
138 >  Result[0].LocSep  := False;
139   end;
140  
141  
# Line 146 | Line 145 | function SUBT(ConnectionID, FileID: Inte
145   var
146    baselink, lastlink: Integer;
147    links: Integer;
148 <  j, k:  Integer;
149 <  Data:  TByteData;
148 >  Data:  TStream;
149 >  read:  Integer;
150 >  char:  Byte;
151 >  foundzeros: Byte;
152   begin
153 +  SetLength(Result, 0);
154 +
155    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @baselink);
156    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
157    if links > 0 then
158    begin
159      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
160 <    SetLength(Data, lastlink + 1024);
161 <    TOniDataDat(connection).LoadRawOffset(False,
162 <      baselink, lastlink + 1024, Data);
163 <    //      connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
164 <    k := 0;
165 <    for j := 0 to 1024 do
166 <    begin
167 <      if (Data[lastlink + j] = $00) or (j = 1024) then
160 >    Data := nil;
161 >    TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset(
162 >          False, baselink, lastlink + 1024, Data);
163 >    Data.Seek(lastlink, soFromBeginning);
164 >
165 >    foundzeros := 0;
166 >    repeat
167 >      read := Data.Read(char, 1);
168 >      if (read > 0) and (char = 0) then
169        begin
170 <        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;
170 >        Inc(foundzeros);
171        end;
172 +    until (read = 0) or (foundzeros = 2);
173 +
174 +    if foundzeros = 2 then
175 +    begin
176 +      SetLength(Result, 1);
177 +      Result[0].Name      := 'Subtitles';
178 +      Result[0].SrcID     := FileID;
179 +      Result[0].SrcOffset := $18;
180 +      Result[0].RawAddr   := baselink;
181 +      Result[0].RawSize   := Data.Position;
182 +      Result[0].LocSep    := False;
183      end;
184    end;
185   end;
# Line 196 | Line 197 | var
197    templ:  Integer;
198    Data:   TByteData;
199    offset: Word;
200 <  frame_count: Byte;
200 >  frame_count: Integer;
201   begin
202    SetLength(Result, 13);
203    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $16C, 2, @frames);
204    {y-pos}
205    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
206 <  Result[0].src_offset := $0C;
207 <  Result[0].raw_addr   := link;
208 <  Result[0].raw_size   := frames * 4;
206 >  Result[0].Name      := 'y-pos';
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].src_offset := $10;
213 <  Result[1].raw_addr   := link;
214 <  Result[1].raw_size   := frames * 8;
212 >  Result[1].Name      := 'x-z-pos';
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].src_offset := $14;
220 <  Result[2].raw_addr   := link;
221 <  Result[2].raw_size   := tempb * 32;
219 >  Result[2].Name      := 'Attacks';
220 >  Result[2].SrcOffset := $14;
221 >  Result[2].RawAddr   := link;
222 >  Result[2].RawSize   := tempb * 32;
223    {damage}
224    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $183, 1, @tempb);
225    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @link);
226 <  Result[3].src_offset := $18;
227 <  Result[3].raw_addr   := link;
228 <  Result[3].raw_size   := tempb * 8;
226 >  Result[3].Name      := 'Damage';
227 >  Result[3].SrcOffset := $18;
228 >  Result[3].RawAddr   := link;
229 >  Result[3].RawSize   := tempb * 8;
230    {motionblur}
231    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $184, 1, @tempb);
232    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link);
233 <  Result[4].src_offset := $1C;
234 <  Result[4].raw_addr   := link;
235 <  Result[4].raw_size   := tempb * 8;
233 >  Result[4].Name      := 'MotionBlur';
234 >  Result[4].SrcOffset := $1C;
235 >  Result[4].RawAddr   := link;
236 >  Result[4].RawSize   := tempb * 12;
237    {shortcut}
238    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb);
239    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link);
240 <  Result[5].src_offset := $20;
241 <  Result[5].raw_addr   := link;
242 <  Result[5].raw_size   := tempb * 8;
240 >  Result[5].Name      := 'Shortcut';
241 >  Result[5].SrcOffset := $20;
242 >  Result[5].RawAddr   := link;
243 >  Result[5].RawSize   := tempb * 8;
244    {throw}
245    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $24, 4, @link);
246 <  Result[6].src_offset := $24;
247 <  Result[6].raw_addr   := link;
248 <  if link > 0 then
249 <    Result[6].raw_size := 24
243 <  else
244 <    Result[6].raw_size := 0;
246 >  Result[6].Name      := 'Throw';
247 >  Result[6].SrcOffset := $24;
248 >  Result[6].RawAddr   := link;
249 >  Result[6].RawSize := 24;
250    {footstep}
251    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $186, 1, @tempb);
252    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $28, 4, @link);
253 <  Result[7].src_offset := $28;
254 <  Result[7].raw_addr   := link;
255 <  Result[7].raw_size   := tempb * 4;
253 >  Result[7].Name      := 'Footstep';
254 >  Result[7].SrcOffset := $28;
255 >  Result[7].RawAddr   := link;
256 >  Result[7].RawSize   := tempb * 4;
257    {particle}
258    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $187, 1, @tempb);
259    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $2C, 4, @link);
260 <  Result[8].src_offset := $2C;
261 <  Result[8].raw_addr   := link;
262 <  Result[8].raw_size   := tempb * 24;
260 >  Result[8].Name      := 'Particle';
261 >  Result[8].SrcOffset := $2C;
262 >  Result[8].RawAddr   := link;
263 >  Result[8].RawSize   := tempb * 24;
264    {position}
265    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $30, 4, @link);
266 <  Result[9].src_offset := $30;
267 <  Result[9].raw_addr   := link;
268 <  Result[9].raw_size   := frames * 8;
269 <  {particle}
266 >  Result[9].Name      := 'Position';
267 >  Result[9].SrcOffset := $30;
268 >  Result[9].RawAddr   := link;
269 >  Result[9].RawSize   := frames * 8;
270 >  {sound}
271    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $154, 2, @tempw);
272    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $38, 4, @link);
273 <  Result[11].src_offset := $38;
274 <  Result[11].raw_addr   := link;
275 <  Result[11].raw_size   := tempw * 34;
273 >  Result[11].Name      := 'Sound';
274 >  Result[11].SrcOffset := $38;
275 >  Result[11].RawAddr   := link;
276 >  Result[11].RawSize   := tempw * 34;
277    {extent}
278    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $138, 4, @templ);
279    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $13C, 4, @link);
280 <  Result[12].src_offset := $13C;
281 <  Result[12].raw_addr   := link;
282 <  Result[12].raw_size   := templ * 12;
280 >  Result[12].Name      := 'Extent';
281 >  Result[12].SrcOffset := $13C;
282 >  Result[12].RawAddr   := link;
283 >  Result[12].RawSize   := templ * 12;
284  
285    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $34, 4, @link);
286    if link > 0 then
# Line 279 | Line 289 | begin
289      frame_count := 0;
290      i := 0;
291      SetLength(Data, $FFFF);
292 <    TOniDataDat(connection).LoadRawOffset(False, link, $FFFF, Data);
292 >    TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset(
293 >          False, link, $FFFF, Data);
294      offset := Data[$24] + Data[$25] * 256;
295      while (offset + i < Length(Data)) and (frame_count < frames - 1) do
296      begin
# Line 290 | Line 301 | begin
301      if offset + i < Length(Data) then
302      begin
303        Inc(i, tempw);
304 <      Result[10].raw_size := offset + i;
304 >      Result[10].RawSize := offset + i;
305      end
306      else
307      begin
308 <      Result[10].raw_size := 0;
308 >      Result[10].RawSize := 0;
309      end;
310    end;
311 <  Result[10].src_offset := $34;
312 <  Result[10].raw_addr   := link;
311 >  Result[10].Name      := 'BodyParts Animation';
312 >  Result[10].SrcOffset := $34;
313 >  Result[10].RawAddr   := link;
314   end;
315  
316  
# Line 311 | Line 323 | var
323    x, y:      Word;
324    storetype: Byte;
325    datasize:  Integer;
326 +  mipmap:    Byte;
327 +
328 +  function GetImgSize(w,h, storetype: Integer): Integer;
329 +  begin
330 +    case storetype of
331 +      0, 1, 2:
332 +        Result := w*h*2;
333 +      8:
334 +        Result := w*h*4;
335 +      9:
336 +        Result :=  Max(1, w div 4) * Max(1, h div 4) * 8;
337 +    else
338 +      Result := -1;
339 +    end;
340 +  end;
341 +
342   begin
343 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap);
344    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
345    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
346    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
347    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc);
348    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
349 <  case storetype of
350 <    0, 1, 2:
351 <      datasize := x * y * 2;
352 <    8:
353 <      datasize := x * y * 4;
354 <    9:
355 <      datasize := x * y div 2;
349 >
350 >
351 >  datasize := GetImgSize(x, y, storetype);
352 >  if (mipmap and $01) > 0 then
353 >  begin
354 >    repeat
355 >      x    := Max(x div 2, 1);
356 >      y    := Max(y div 2, 1);
357 >      datasize := datasize + GetImgSize(x, y, storetype);
358 >    until (x = 1) and (y = 1);
359    end;
360 +
361    SetLength(Result, 1);
362 <  if not connection.OSisMac then
362 >  if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then
363    begin
364 <    Result[0].src_offset := $9C;
365 <    Result[0].raw_addr   := link_pc;
364 >    Result[0].SrcOffset := $9C;
365 >    Result[0].RawAddr   := link_pc;
366    end
367    else
368    begin
369 <    Result[0].src_offset := $A0;
370 <    Result[0].raw_addr   := link_mac;
369 >    Result[0].SrcOffset := $A0;
370 >    Result[0].RawAddr   := link_mac;
371    end;
372 <  Result[0].raw_size := datasize;
373 <  Result[0].loc_sep  := connection.OSisMac;
372 >  Result[0].Name    := 'ImageData';
373 >  Result[0].RawSize := datasize;
374 >  Result[0].LocSep  := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
375   end;
376  
377  
# Line 350 | Line 384 | var
384    RawList: TRawDataList;
385   begin
386    RawList          := GetRawList(ConnectionID, FileID);
387 +  Result.Name      := '';
388    Result.SrcID     := -1;
389    Result.SrcOffset := -1;
390    Result.RawAddr   := -1;
# Line 360 | Line 395 | begin
395      begin
396        if RawList[i].SrcOffset = DatOffset then
397        begin
398 +        Result.Name      := RawList[i].Name;
399          Result.SrcID     := FileID;
400          Result.SrcOffset := RawList[i].SrcOffset;
401          Result.RawAddr   := RawList[i].RawAddr;
# Line 386 | Line 422 | begin
422          Result := FRawListHandlers[i].Handler(ConnectionID, FileID);
423        Break;
424      end;
425 +  if Length(Result) > 0 then
426 +    for i := 0 to High(Result) do
427 +      if Result[i].RawAddr = 0 then
428 +        Result[i].RawSize := 0;
429   end;
430  
431   procedure TRawLists.InsertRawListHandler(ext: String; needed: Boolean; handler: THandler);
# Line 403 | Line 443 | end;
443  
444   initialization
445    RawLists := TRawLists.Create;
446 <  RawLists.InsertRawListHandler('AGDB',False,AGDB);
446 >  RawLists.InsertRawListHandler('AGDB', False, AGDB);
447    RawLists.InsertRawListHandler('AKVA', True, AKVA);
448    RawLists.InsertRawListHandler('BINA', True, BINA);
449    RawLists.InsertRawListHandler('OSBD', True, OSBD);

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)