--- oup/rewrite/Global/RawList.pas 2007/02/21 00:29:27 105 +++ oup/current/Global/RawList.pas 2007/04/03 03:24:51 168 @@ -1,7 +1,5 @@ unit RawList; - interface - uses TypeDefs; type @@ -31,7 +29,7 @@ var implementation uses - Template, ConnectionManager, Access_OniArchive, Classes, SysUtils; + Template, ConnectionManager, Access_OniArchive, Classes, SysUtils, Math; function AGDB(ConnectionID, FileID: Integer): TRawDataList; @@ -142,48 +140,42 @@ function SUBT(ConnectionID, FileID: Inte var baselink, lastlink: Integer; links: Integer; - j, k: Integer; -// Data: TByteData; Data: TStream; + read: Integer; + char: Byte; + foundzeros: Byte; begin + SetLength(Result, 0); + ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $18, 4, @baselink); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @links); if links > 0 then begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20 + (links - 1) * 4, 4, @lastlink); -// SetLength(Data, lastlink + 1024); Data := nil; TAccess_OniArchive(ConManager.Connection[ConnectionID]).LoadRawOffset( False, baselink, lastlink + 1024, Data); -// TOniDataDat(connection).LoadRawOffset(False, baselink, lastlink + 1024, Data); - // connection.LoadRawFile(fileid,$1C,baselink,lastlink+1024,False,@data[0]); - raise ENotImplemented.Create('RawList.SUBT'); - end; -{ - k := 0; - for j := 0 to 1024 do - begin - if (Data[lastlink + j] = $00) or (j = 1024) then + Data.Seek(lastlink, soFromBeginning); + + foundzeros := 0; + repeat + read := Data.Read(char, 1); + if (read > 0) and (char = 0) then begin - if j < 1024 then - begin - if k = 0 then - begin - k := 1; - end - else - begin - SetLength(Result, 1); - Result[0].src_offset := $18; - Result[0].raw_addr := baselink; - Result[0].raw_size := lastlink + j; - Break; - end; - end; + Inc(foundzeros); end; + until (read = 0) or (foundzeros = 2); + + if foundzeros = 2 then + begin + SetLength(Result, 1); + Result[0].SrcID := FileID; + Result[0].SrcOffset := $18; + Result[0].RawAddr := baselink; + Result[0].RawSize := Data.Position; + Result[0].LocSep := False; end; end; -} end; @@ -199,7 +191,7 @@ var templ: Integer; Data: TByteData; offset: Word; - frame_count: Byte; + frame_count: Integer; begin SetLength(Result, 13); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $16C, 2, @frames); @@ -230,7 +222,7 @@ begin ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $1C, 4, @link); Result[4].SrcOffset := $1C; Result[4].RawAddr := link; - Result[4].RawSize := tempb * 8; + Result[4].RawSize := tempb * 12; {shortcut} ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $185, 1, @tempb); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $20, 4, @link); @@ -315,20 +307,41 @@ var x, y: Word; storetype: Byte; datasize: Integer; + mipmap: Byte; + + function GetImgSize(w,h, storetype: Integer): Integer; + begin + case storetype of + 0, 1, 2: + Result := w*h*2; + 8: + Result := w*h*4; + 9: + Result := Max(1, w div 4) * Max(1, h div 4) * 8; + else + Result := -1; + end; + end; + begin + ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $88, SizeOf(mipmap), @mipmap); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8C, SizeOf(x), @x); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $8E, SizeOf(y), @y); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $90, SizeOf(storetype), @storetype); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $9C, 4, @link_pc); ConManager.Connection[ConnectionID].LoadDatFilePart(fileid, $A0, 4, @link_mac); - case storetype of - 0, 1, 2: - datasize := x * y * 2; - 8: - datasize := x * y * 4; - 9: - datasize := x * y div 2; + + + datasize := GetImgSize(x, y, storetype); + if (mipmap and $01) > 0 then + begin + repeat + x := Max(x div 2, 1); + y := Max(y div 2, 1); + datasize := datasize + GetImgSize(x, y, storetype); + until (x = 1) and (y = 1); end; + SetLength(Result, 1); if ConManager.Connection[ConnectionID].DataOS = DOS_WIN then begin @@ -407,7 +420,7 @@ end; initialization RawLists := TRawLists.Create; - RawLists.InsertRawListHandler('AGDB',False,AGDB); + RawLists.InsertRawListHandler('AGDB', False, AGDB); RawLists.InsertRawListHandler('AKVA', True, AKVA); RawLists.InsertRawListHandler('BINA', True, BINA); RawLists.InsertRawListHandler('OSBD', True, OSBD);