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