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 113 by alloc, Sun Feb 25 17:20:22 2007 UTC vs.
Revision 168 by alloc, Tue Apr 3 03:24:51 2007 UTC

# Line 29 | Line 29 | var
29   implementation
30  
31   uses
32 <  Template, ConnectionManager, Access_OniArchive, Classes, SysUtils;
32 >  Template, ConnectionManager, Access_OniArchive, Classes, SysUtils, Math;
33  
34  
35   function AGDB(ConnectionID, FileID: Integer): TRawDataList;
# Line 141 | Line 141 | var
141    baselink, lastlink: Integer;
142    links: Integer;
143    Data:  TStream;
144 +  read:  Integer;
145 +  char:  Byte;
146 +  foundzeros: Byte;
147   begin
148 +  SetLength(Result, 0);
149 +
150    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @baselink);
151    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links);
152    if links > 0 then
153    begin
154      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink);
150 //    SetLength(Data, lastlink + 1024);
155      Data := nil;
156      TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset(
157            False, baselink, lastlink + 1024, Data);
158 < //    TOniDataDat(connection).LoadRawOffset(False, baselink, lastlink + 1024, Data);
159 <    //      connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]);
160 <    raise ENotImplemented.Create('RawList.SUBT');
161 <  end;
162 < {
163 <    k := 0;
160 <    for j := 0 to 1024 do
161 <    begin
162 <      if (Data[lastlink + j] = $00) or (j = 1024) then
158 >    Data.Seek(lastlink, soFromBeginning);
159 >
160 >    foundzeros := 0;
161 >    repeat
162 >      read := Data.Read(char, 1);
163 >      if (read > 0) and (char = 0) then
164        begin
165 <        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;
165 >        Inc(foundzeros);
166        end;
167 +    until (read = 0) or (foundzeros = 2);
168 +
169 +    if foundzeros = 2 then
170 +    begin
171 +      SetLength(Result, 1);
172 +      Result[0].SrcID     := FileID;
173 +      Result[0].SrcOffset := $18;
174 +      Result[0].RawAddr   := baselink;
175 +      Result[0].RawSize   := Data.Position;
176 +      Result[0].LocSep    := False;
177      end;
178    end;
182 }
179   end;
180  
181  
# Line 195 | Line 191 | var
191    templ:  Integer;
192    Data:   TByteData;
193    offset: Word;
194 <  frame_count: Byte;
194 >  frame_count: Integer;
195   begin
196    SetLength(Result, 13);
197    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $16C, 2, @frames);
# Line 226 | Line 222 | begin
222    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link);
223    Result[4].SrcOffset := $1C;
224    Result[4].RawAddr   := link;
225 <  Result[4].RawSize   := tempb * 8;
225 >  Result[4].RawSize   := tempb * 12;
226    {shortcut}
227    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb);
228    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link);
# Line 311 | Line 307 | var
307    x, y:      Word;
308    storetype: Byte;
309    datasize:  Integer;
310 +  mipmap:    Byte;
311 +
312 +  function GetImgSize(w,h, storetype: Integer): Integer;
313 +  begin
314 +    case storetype of
315 +      0, 1, 2:
316 +        Result := w*h*2;
317 +      8:
318 +        Result := w*h*4;
319 +      9:
320 +        Result :=  Max(1, w div 4) * Max(1, h div 4) * 8;
321 +    else
322 +      Result := -1;
323 +    end;
324 +  end;
325 +
326   begin
327 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap);
328    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
329    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
330    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
331    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc);
332    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
333 <  case storetype of
334 <    0, 1, 2:
335 <      datasize := x * y * 2;
336 <    8:
337 <      datasize := x * y * 4;
338 <    9:
339 <      datasize := x * y div 2;
333 >
334 >
335 >  datasize := GetImgSize(x, y, storetype);
336 >  if (mipmap and $01) > 0 then
337 >  begin
338 >    repeat
339 >      x    := Max(x div 2, 1);
340 >      y    := Max(y div 2, 1);
341 >      datasize := datasize + GetImgSize(x, y, storetype);
342 >    until (x = 1) and (y = 1);
343    end;
344 +
345    SetLength(Result, 1);
346    if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then
347    begin
# Line 403 | Line 420 | end;
420  
421   initialization
422    RawLists := TRawLists.Create;
423 <  RawLists.InsertRawListHandler('AGDB',False,AGDB);
423 >  RawLists.InsertRawListHandler('AGDB', False, AGDB);
424    RawLists.InsertRawListHandler('AKVA', True, AKVA);
425    RawLists.InsertRawListHandler('BINA', True, BINA);
426    RawLists.InsertRawListHandler('OSBD', True, OSBD);

Diff Legend

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