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 105 by alloc, Wed Feb 21 00:29:27 2007 UTC vs.
oup/current/Global/RawList.pas (file contents), Revision 209 by alloc, Mon Jun 4 22:07:29 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 118 | Line 116 | var
116    datasize: Integer;
117   begin
118    SetLength(Result, 1);
119 <  if ConManager.Connection[ConnectionID].DataOS = DOS_MAC then
119 >  if ConManager.Connection[ConnectionID].DataOS in [DOS_MACBETA, DOS_MAC] then
120    begin
121      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $10, 4, @datasize);
122      ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
# 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 >    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
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;
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;
186 }
179   end;
180  
181  
# Line 199 | 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);
198 <  {y-pos}
198 >  {x-z-pos}
199    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $0C, 4, @link);
200    Result[0].SrcOffset := $0C;
201    Result[0].RawAddr   := link;
202 <  Result[0].RawSize   := frames * 4;
203 <  {x-z-pos}
202 >  Result[0].RawSize := frames * 4;
203 >  {y-pos}
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 >  Result[1].RawSize := frames * 8;
208    {attacks}
209    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $182, 1, @tempb);
210    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $14, 4, @link);
# Line 230 | 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 241 | Line 233 | begin
233    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $24, 4, @link);
234    Result[6].SrcOffset := $24;
235    Result[6].RawAddr   := link;
236 <  if link > 0 then
245 <    Result[6].RawSize := 24
246 <  else
247 <    Result[6].RawSize := 0;
236 >  Result[6].RawSize := 24;
237    {footstep}
238    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $186, 1, @tempb);
239    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $28, 4, @link);
# Line 315 | Line 304 | var
304    x, y:      Word;
305    storetype: Byte;
306    datasize:  Integer;
307 +  mipmap:    Byte;
308 +
309 +  function GetImgSize(w,h, storetype: Integer): Integer;
310 +  begin
311 +    case storetype of
312 +      0, 1, 2:
313 +        Result := w*h*2;
314 +      8:
315 +        Result := w*h*4;
316 +      9:
317 +        Result :=  Max(1, w div 4) * Max(1, h div 4) * 8;
318 +    else
319 +      Result := -1;
320 +    end;
321 +  end;
322 +
323   begin
324 +  ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap);
325    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x);
326    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y);
327    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype);
328    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc);
329    ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac);
330 <  case storetype of
331 <    0, 1, 2:
332 <      datasize := x * y * 2;
333 <    8:
334 <      datasize := x * y * 4;
335 <    9:
336 <      datasize := x * y div 2;
330 >
331 >
332 >  datasize := GetImgSize(x, y, storetype);
333 >  if (mipmap and $01) > 0 then
334 >  begin
335 >    repeat
336 >      x    := Max(x div 2, 1);
337 >      y    := Max(y div 2, 1);
338 >      datasize := datasize + GetImgSize(x, y, storetype);
339 >    until (x = 1) and (y = 1);
340    end;
341 +
342    SetLength(Result, 1);
343    if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then
344    begin
# Line 390 | Line 400 | begin
400          Result := FRawListHandlers[i].Handler(ConnectionID, FileID);
401        Break;
402      end;
403 +  if Length(Result) > 0 then
404 +    for i := 0 to High(Result) do
405 +      if Result[i].RawAddr = 0 then
406 +        Result[i].RawSize := 0;
407   end;
408  
409   procedure TRawLists.InsertRawListHandler(ext: String; needed: Boolean; handler: THandler);
# Line 407 | Line 421 | end;
421  
422   initialization
423    RawLists := TRawLists.Create;
424 <  RawLists.InsertRawListHandler('AGDB',False,AGDB);
424 >  RawLists.InsertRawListHandler('AGDB', False, AGDB);
425    RawLists.InsertRawListHandler('AKVA', True, AKVA);
426    RawLists.InsertRawListHandler('BINA', True, BINA);
427    RawLists.InsertRawListHandler('OSBD', True, OSBD);

Diff Legend

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