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 169 by alloc, Tue Apr 3 15:43:53 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 208 | Line 204 | begin
204    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @link);
205    Result[1].SrcOffset := $10;
206    Result[1].RawAddr   := link;
207 <  Result[1].RawSize   := frames * 8;
207 >  if link > 0 then
208 >    Result[1].RawSize := frames * 8
209 >  else
210 >    Result[1].RawSize := 0;
211    {attacks}
212    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $182, 1, @tempb);
213    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
# Line 226 | Line 225 | begin
225    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link);
226    Result[4].SrcOffset := $1C;
227    Result[4].RawAddr   := link;
228 <  Result[4].RawSize   := tempb * 8;
228 >  Result[4].RawSize   := tempb * 12;
229    {shortcut}
230    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb);
231    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link);
# Line 311 | Line 310 | var
310    x, y:      Word;
311    storetype: Byte;
312    datasize:  Integer;
313 +  mipmap:    Byte;
314 +
315 +  function GetImgSize(w,h, storetype: Integer): Integer;
316 +  begin
317 +    case storetype of
318 +      0, 1, 2:
319 +        Result := w*h*2;
320 +      8:
321 +        Result := w*h*4;
322 +      9:
323 +        Result :=  Max(1, w div 4) * Max(1, h div 4) * 8;
324 +    else
325 +      Result := -1;
326 +    end;
327 +  end;
328 +
329   begin
330 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap);
331    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
332    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
333    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
334    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc);
335    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
336 <  case storetype of
337 <    0, 1, 2:
338 <      datasize := x * y * 2;
339 <    8:
340 <      datasize := x * y * 4;
341 <    9:
342 <      datasize := x * y div 2;
336 >
337 >
338 >  datasize := GetImgSize(x, y, storetype);
339 >  if (mipmap and $01) > 0 then
340 >  begin
341 >    repeat
342 >      x    := Max(x div 2, 1);
343 >      y    := Max(y div 2, 1);
344 >      datasize := datasize + GetImgSize(x, y, storetype);
345 >    until (x = 1) and (y = 1);
346    end;
347 +
348    SetLength(Result, 1);
349    if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then
350    begin
# Line 403 | Line 423 | end;
423  
424   initialization
425    RawLists := TRawLists.Create;
426 <  RawLists.InsertRawListHandler('AGDB',False,AGDB);
426 >  RawLists.InsertRawListHandler('AGDB', False, AGDB);
427    RawLists.InsertRawListHandler('AKVA', True, AKVA);
428    RawLists.InsertRawListHandler('BINA', True, BINA);
429    RawLists.InsertRawListHandler('OSBD', True, OSBD);

Diff Legend

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