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 109 by alloc, Wed Feb 21 03:12:33 2007 UTC vs.
Revision 147 by alloc, Sun Apr 1 16:15:47 2007 UTC

# Line 1 | Line 1
1   unit RawList;
2
2   interface
4
3   uses TypeDefs;
4  
5   type
# Line 31 | 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 142 | Line 140 | function SUBT(ConnectionID, FileID: Inte
140   var
141    baselink, lastlink: Integer;
142    links: Integer;
145  j, k:  Integer;
146 //  Data:  TByteData;
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);
154 //    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;
164 <    for j := 0 to 1024 do
165 <    begin
166 <      if (Data[lastlink + j] = $00) or (j = 1024) then
158 >
159 >    foundzeros := 0;
160 >    repeat
161 >      read := Data.Read(char, 1);
162 >      if (read > 0) and (char = 0) then
163        begin
164 <        if j < 1024 then
169 <        begin
170 <          if k = 0 then
171 <          begin
172 <            k := 1;
173 <          end
174 <          else
175 <          begin
176 <            SetLength(Result, 1);
177 <            Result[0].src_offset := $18;
178 <            Result[0].raw_addr   := baselink;
179 <            Result[0].raw_size   := lastlink + j;
180 <            Break;
181 <          end;
182 <        end;
164 >        Inc(foundzeros);
165        end;
166 +    until (read = 0) or (foundzeros = 2);
167 +
168 +    if foundzeros = 2 then
169 +    begin
170 +      SetLength(Result, 1);
171 +      Result[0].SrcID     := FileID;
172 +      Result[0].SrcOffset := $18;
173 +      Result[0].RawAddr   := baselink;
174 +      Result[0].RawSize   := Data.Position;
175 +      Result[0].LocSep    := False;
176      end;
177    end;
186 }
178   end;
179  
180  
# Line 315 | Line 306 | var
306    x, y:      Word;
307    storetype: Byte;
308    datasize:  Integer;
309 +  mipmap:    Byte;
310 +
311 +  function GetImgSize(w,h, storetype: Integer): Integer;
312 +  begin
313 +    case storetype of
314 +      0, 1, 2:
315 +        Result := w*h*2;
316 +      8:
317 +        Result := w*h*4;
318 +      9:
319 +        Result :=  Max(1, w div 4) * Max(1, h div 4) * 8;
320 +    else
321 +      Result := -1;
322 +    end;
323 +  end;
324 +
325   begin
326 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap);
327    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
328    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
329    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
330    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc);
331    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
332 <  case storetype of
333 <    0, 1, 2:
334 <      datasize := x * y * 2;
335 <    8:
336 <      datasize := x * y * 4;
337 <    9:
338 <      datasize := x * y div 2;
332 >
333 >
334 >  datasize := GetImgSize(x, y, storetype);
335 >  if (mipmap and $01) > 0 then
336 >  begin
337 >    repeat
338 >      x    := Max(x div 2, 1);
339 >      y    := Max(y div 2, 1);
340 >      datasize := datasize + GetImgSize(x, y, storetype);
341 >    until (x = 1) and (y = 1);
342    end;
343 +
344    SetLength(Result, 1);
345    if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then
346    begin
# Line 407 | Line 419 | end;
419  
420   initialization
421    RawLists := TRawLists.Create;
422 <  RawLists.InsertRawListHandler('AGDB',False,AGDB);
422 >  RawLists.InsertRawListHandler('AGDB', False, AGDB);
423    RawLists.InsertRawListHandler('AKVA', True, AKVA);
424    RawLists.InsertRawListHandler('BINA', True, BINA);
425    RawLists.InsertRawListHandler('OSBD', True, OSBD);

Diff Legend

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