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

Comparing oup/current/Global/RawList.pas (file contents):
Revision 122 by alloc, Fri Mar 23 01:41:15 2007 UTC vs.
Revision 226 by alloc, Tue Jun 19 19:57:39 2007 UTC

# Line 29 | Line 29 | var
29   implementation
30  
31   uses
32 <  Template, ConnectionManager, Access_OniArchive, Classes, SysUtils;
32 >  ConnectionManager, Access_OniArchive, Classes, SysUtils, Math, _TemplateFile;
33  
34  
35   function AGDB(ConnectionID, FileID: Integer): TRawDataList;
# Line 43 | Line 43 | begin
43    SetLength(Result, links);
44    for i := 0 to links - 1 do
45    begin
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;
# Line 64 | Line 65 | begin
65    SetLength(Result, links);
66    for i := 0 to links - 1 do
67    begin
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;
# Line 84 | 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].Name := 'BinaryData';
90    Result[0].SrcOffset := $0C;
91    Result[0].RawAddr   := link;
92    Result[0].RawSize   := datasize;
# Line 101 | 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].Name := 'SoundBinaryData';
108    Result[0].SrcOffset := $0C;
109    Result[0].RawAddr   := link;
110    Result[0].RawSize   := datasize;
# Line 116 | Line 120 | var
120    datasize: Integer;
121   begin
122    SetLength(Result, 1);
123 <  if ConManager.Connection[ConnectionID].DataOS = DOS_MAC then
123 >  if ConManager.Connection[ConnectionID].DataOS in [DOS_MACBETA, DOS_MAC] then
124    begin
125      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize);
126      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
# Line 128 | Line 132 | begin
132      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $44, 4, @link);
133      Result[0].SrcOffset := $44;
134    end;
135 +  Result[0].Name := 'SoundData';
136    Result[0].RawAddr := link;
137    Result[0].RawSize := datasize;
138    Result[0].LocSep  := False;
# Line 141 | Line 146 | var
146    baselink, lastlink: Integer;
147    links: Integer;
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);
150 //    SetLength(Data, lastlink + 1024);
160      Data := nil;
161      TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset(
162            False, baselink, lastlink + 1024, Data);
163 < //    TOniDataDat(connection).LoadRawOffset(False, baselink, lastlink + 1024, Data);
164 <    //      connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
165 <    raise ENotImplemented.Create('RawList.SUBT');
166 <  end;
167 < {
168 <    k := 0;
160 <    for j := 0 to 1024 do
161 <    begin
162 <      if (Data[lastlink + j] = $00) or (j = 1024) then
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
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;
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;
182 }
185   end;
186  
187  
# Line 195 | 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].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].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].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].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].Name      := 'MotionBlur';
234    Result[4].SrcOffset := $1C;
235    Result[4].RawAddr   := link;
236 <  Result[4].RawSize   := tempb * 8;
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].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].Name      := 'Throw';
247    Result[6].SrcOffset := $24;
248    Result[6].RawAddr   := link;
249 <  if link > 0 then
241 <    Result[6].RawSize := 24
242 <  else
243 <    Result[6].RawSize := 0;
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].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].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].Name      := 'Position';
267    Result[9].SrcOffset := $30;
268    Result[9].RawAddr   := link;
269    Result[9].RawSize   := frames * 8;
270 <  {particle}
270 >  {sound}
271    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $154, 2, @tempw);
272    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $38, 4, @link);
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].Name      := 'Extent';
281    Result[12].SrcOffset := $13C;
282    Result[12].RawAddr   := link;
283    Result[12].RawSize   := templ * 12;
# Line 297 | Line 308 | begin
308        Result[10].RawSize := 0;
309      end;
310    end;
311 +  Result[10].Name      := 'BodyParts Animation';
312    Result[10].SrcOffset := $34;
313    Result[10].RawAddr   := link;
314   end;
# Line 312 | Line 324 | var
324    storetype: Byte;
325    datasize:  Integer;
326    mipmap:    Byte;
327 <  bpp:       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);
# Line 322 | Line 348 | begin
348    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
349  
350  
351 <  case storetype of
326 <    0, 1, 2:
327 <      bpp := 16;
328 < //      datasize := x * y * 2;
329 <    8:
330 <      bpp := 32;
331 < //      datasize := x * y * 4;
332 <    9:
333 <      bpp := 4;
334 < //      datasize := x * y div 2;
335 <  end;
336 <
337 <  datasize := (x * y * bpp) div 8;
351 >  datasize := GetImgSize(x, y, storetype);
352    if (mipmap and $01) > 0 then
353    begin
354      repeat
355 <      x    := x div 2;
356 <      y    := y div 2;
357 <      datasize := datasize + (x * y * bpp) div 8;
358 <    until (x = 1) or (y = 1);
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);
# Line 355 | Line 369 | begin
369      Result[0].SrcOffset := $A0;
370      Result[0].RawAddr   := link_mac;
371    end;
372 +  Result[0].Name    := 'ImageData';
373    Result[0].RawSize := datasize;
374    Result[0].LocSep  := not (ConManager.Connection[ConnectionID].DataOS = DOS_WIN);
375   end;
# Line 369 | 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 379 | 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 405 | 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 422 | 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)