[206] | 1 | unit TXMP;
|
---|
| 2 |
|
---|
| 3 | interface
|
---|
| 4 |
|
---|
| 5 | uses
|
---|
[207] | 6 | TypeDefs, _FileTypes, _DataTypes;
|
---|
[206] | 7 |
|
---|
| 8 | type
|
---|
| 9 | TFile_TXMP = class(TFile)
|
---|
| 10 | protected
|
---|
| 11 | procedure InitDatLinks; override;
|
---|
| 12 | procedure InitDataFields; override;
|
---|
| 13 | procedure InitRawList; override;
|
---|
| 14 | end;
|
---|
| 15 |
|
---|
| 16 | implementation
|
---|
| 17 |
|
---|
| 18 | uses
|
---|
[207] | 19 | ConnectionManager, Math, Classes;
|
---|
[206] | 20 |
|
---|
| 21 | { TFile_SNDD }
|
---|
| 22 |
|
---|
| 23 | procedure TFile_TXMP.InitDatLinks;
|
---|
| 24 | begin
|
---|
| 25 | SetLength(FDatLinks, 2);
|
---|
| 26 | FDatLinks[0].SrcOffset := $94;
|
---|
| 27 | FDatLinks[0].DestID := -1;
|
---|
| 28 | FDatLinks[0].PosDestExts := '*';
|
---|
| 29 | FDatLinks[1].SrcOffset := $98;
|
---|
| 30 | FDatLinks[1].DestID := -1;
|
---|
| 31 | FDatLinks[1].PosDestExts := 'TXMP';
|
---|
| 32 | end;
|
---|
| 33 |
|
---|
| 34 |
|
---|
| 35 | procedure TFile_TXMP.InitDataFields;
|
---|
| 36 | var
|
---|
| 37 | tempi: Integer;
|
---|
| 38 | temps: String;
|
---|
[207] | 39 | templist: TStringList;
|
---|
[206] | 40 | begin
|
---|
| 41 | FDataFields := TBlock.Create(Self, 0, 'Base', '', nil);
|
---|
[207] | 42 | templist := TStringList.Create;
|
---|
[206] | 43 | with FDataFields do
|
---|
| 44 | begin
|
---|
| 45 | AddField(TFileID, $00, 'FileID', '', nil);
|
---|
[207] | 46 |
|
---|
[206] | 47 | AddField(TLevelID, $04, 'LevelID', '', nil);
|
---|
[207] | 48 |
|
---|
[206] | 49 | tempi := 128;
|
---|
| 50 | AddField(TString, $08, 'FileName', '', @tempi);
|
---|
[207] | 51 |
|
---|
| 52 | templist.Add('MipMapping enabled');
|
---|
| 53 | templist.Add('unknown');
|
---|
| 54 | templist.Add('U wrapping disabled');
|
---|
| 55 | templist.Add('V wrapping disabled');
|
---|
| 56 | templist.Add('EnvMapped/EnvMap');
|
---|
| 57 | templist.Add('unused');
|
---|
| 58 | templist.Add('Play anim back to back');
|
---|
| 59 | templist.Add('Random anim order + frame time');
|
---|
| 60 | AddField(TBitSet, $88, 'Flags1', '', @templist);
|
---|
| 61 |
|
---|
| 62 | templist.Clear;
|
---|
| 63 | templist.Add('Random anim time offset');
|
---|
| 64 | templist.Add('High byte as EnvMap');
|
---|
| 65 | templist.Add('High byte as alpha');
|
---|
| 66 | templist.Add('Different alpha formula');
|
---|
| 67 | templist.Add('Data swapping (always set)');
|
---|
| 68 | templist.Add('used at runtime');
|
---|
| 69 | templist.Add('TXAN looping on/off');
|
---|
| 70 | templist.Add('16 bit blue');
|
---|
| 71 | AddField(TBitSet, $89, 'Flags2', '', @templist);
|
---|
| 72 |
|
---|
| 73 | templist.Clear;
|
---|
| 74 | templist.Add('16 bit alpha');
|
---|
| 75 | templist.Add('16 bit red');
|
---|
| 76 | templist.Add('unknown');
|
---|
| 77 | templist.Add('unknown');
|
---|
| 78 | templist.Add('unknown');
|
---|
| 79 | templist.Add('unknown');
|
---|
| 80 | templist.Add('unknown');
|
---|
| 81 | templist.Add('unknown');
|
---|
| 82 | AddField(TBitSet, $8A, 'Flags3', '', @templist);
|
---|
| 83 |
|
---|
| 84 | templist.Clear;
|
---|
| 85 | templist.Add('unknown');
|
---|
| 86 | templist.Add('unknown');
|
---|
| 87 | templist.Add('unknown');
|
---|
| 88 | templist.Add('unknown');
|
---|
| 89 | templist.Add('unknown');
|
---|
| 90 | templist.Add('unknown');
|
---|
| 91 | templist.Add('unknown');
|
---|
| 92 | templist.Add('unknown');
|
---|
| 93 | AddField(TBitSet, $8B, 'Flags4', '', @templist);
|
---|
| 94 |
|
---|
[206] | 95 | tempi := 2;
|
---|
| 96 | AddField(TInt, $8C, 'Width', '', @tempi);
|
---|
[207] | 97 |
|
---|
[206] | 98 | tempi := 2;
|
---|
| 99 | AddField(TInt, $8E, 'Height', '', @tempi);
|
---|
[207] | 100 |
|
---|
[206] | 101 | tempi := 4;
|
---|
| 102 | AddField(TInt, $90, 'StoreType', '', @tempi);
|
---|
[207] | 103 |
|
---|
| 104 | temps := '*';
|
---|
[206] | 105 | AddField(TLinkByID, $94, 'TXAN', '', @temps);
|
---|
[207] | 106 |
|
---|
[206] | 107 | temps := 'TXMP';
|
---|
| 108 | AddField(TLinkByID, $98, 'TXMP', '', @temps);
|
---|
[207] | 109 |
|
---|
[206] | 110 | AddField(TRawLink, $9C, 'RawLink', '', nil);
|
---|
[207] | 111 |
|
---|
[206] | 112 | AddField(TRawLink, $A0, 'SepLink', '', nil);
|
---|
[207] | 113 |
|
---|
[206] | 114 | tempi := $1C;
|
---|
| 115 | AddField(TUnused, $A4, 'Unused', '', @tempi);
|
---|
| 116 | end;
|
---|
[207] | 117 | templist.Free;
|
---|
[206] | 118 | end;
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | procedure TFile_TXMP.InitRawList;
|
---|
| 122 | var
|
---|
| 123 | link_pc: Integer;
|
---|
| 124 | link_mac: Integer;
|
---|
| 125 | x, y: Word;
|
---|
| 126 | storetype: Byte;
|
---|
| 127 | datasize: Integer;
|
---|
| 128 | mipmap: Byte;
|
---|
| 129 |
|
---|
| 130 | function GetImgSize(w,h, storetype: Integer): Integer;
|
---|
| 131 | begin
|
---|
| 132 | case storetype of
|
---|
| 133 | 0, 1, 2:
|
---|
| 134 | Result := w*h*2;
|
---|
| 135 | 8:
|
---|
| 136 | Result := w*h*4;
|
---|
| 137 | 9:
|
---|
| 138 | Result := Max(1, w div 4) * Max(1, h div 4) * 8;
|
---|
| 139 | else
|
---|
| 140 | Result := -1;
|
---|
| 141 | end;
|
---|
| 142 | end;
|
---|
| 143 |
|
---|
| 144 | begin
|
---|
| 145 | ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $88, SizeOf(mipmap), @mipmap);
|
---|
| 146 | ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $8C, SizeOf(x), @x);
|
---|
| 147 | ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $8E, SizeOf(y), @y);
|
---|
| 148 | ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $90, SizeOf(storetype), @storetype);
|
---|
| 149 | ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $9C, 4, @link_pc);
|
---|
| 150 | ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $A0, 4, @link_mac);
|
---|
| 151 |
|
---|
| 152 | datasize := GetImgSize(x, y, storetype);
|
---|
| 153 | if (mipmap and $01) > 0 then
|
---|
| 154 | begin
|
---|
| 155 | repeat
|
---|
| 156 | x := Max(x div 2, 1);
|
---|
| 157 | y := Max(y div 2, 1);
|
---|
| 158 | datasize := datasize + GetImgSize(x, y, storetype);
|
---|
| 159 | until (x = 1) and (y = 1);
|
---|
| 160 | end;
|
---|
| 161 |
|
---|
| 162 | SetLength(FRawParts, 1);
|
---|
| 163 | if ConManager.Connection[FConnectionID].DataOS = DOS_WIN then
|
---|
| 164 | begin
|
---|
| 165 | FRawParts[0].SrcOffset := $9C;
|
---|
| 166 | FRawParts[0].RawAddr := link_pc;
|
---|
| 167 | end
|
---|
| 168 | else
|
---|
| 169 | begin
|
---|
| 170 | FRawParts[0].SrcOffset := $A0;
|
---|
| 171 | FRawParts[0].RawAddr := link_mac;
|
---|
| 172 | end;
|
---|
| 173 | FRawParts[0].RawSize := datasize;
|
---|
| 174 | FRawParts[0].LocSep := not (ConManager.Connection[FConnectionID].DataOS = DOS_WIN);
|
---|
| 175 | end;
|
---|
| 176 |
|
---|
| 177 | end.
|
---|
| 178 |
|
---|