source: oup/current/FileClasses/TXMP.pas@ 212

Last change on this file since 212 was 212, checked in by alloc, 17 years ago
File size: 4.7 KB
Line 
1unit TXMP;
2
3interface
4
5uses
6 _FileTypes;
7
8type
9 TFile_TXMP = class(TFile)
10 protected
11 procedure InitDatLinks; override;
12 procedure InitDataFields; override;
13 procedure InitRawList; override;
14 end;
15
16implementation
17
18uses
19 ConnectionManager, Math, Classes, TypeDefs, _DataTypes;
20
21{ TFile_TXMP }
22
23procedure TFile_TXMP.InitDataFields;
24var
25 tempi: Integer;
26 temps: String;
27 templist: TStringList;
28begin
29 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);
30 templist := TStringList.Create;
31 with FDataFields do
32 begin
33 AddField(TFileID, $00, 'FileID', '', nil);
34
35 AddField(TLevelID, $04, 'LevelID', '', nil);
36
37 tempi := 128;
38 AddField(TString, $08, 'FileName', '', @tempi);
39
40 templist.Add('MipMapping enabled');
41 templist.Add('unknown');
42 templist.Add('U wrapping disabled');
43 templist.Add('V wrapping disabled');
44 templist.Add('EnvMapped/EnvMap');
45 templist.Add('unused');
46 templist.Add('Play anim back to back');
47 templist.Add('Random anim order + frame time');
48 AddField(TBitSet, $88, 'Flags1', '', @templist);
49
50 templist.Clear;
51 templist.Add('Random anim time offset');
52 templist.Add('High byte as EnvMap');
53 templist.Add('High byte as alpha');
54 templist.Add('Different alpha formula');
55 templist.Add('Data swapping (always set)');
56 templist.Add('used at runtime');
57 templist.Add('TXAN looping on/off');
58 templist.Add('16 bit blue');
59 AddField(TBitSet, $89, 'Flags2', '', @templist);
60
61 templist.Clear;
62 templist.Add('16 bit alpha');
63 templist.Add('16 bit red');
64 templist.Add('unknown');
65 templist.Add('unknown');
66 templist.Add('unknown');
67 templist.Add('unknown');
68 templist.Add('unknown');
69 templist.Add('unknown');
70 AddField(TBitSet, $8A, 'Flags3', '', @templist);
71
72 templist.Clear;
73 templist.Add('unknown');
74 templist.Add('unknown');
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 AddField(TBitSet, $8B, 'Flags4', '', @templist);
82
83 tempi := 2;
84 AddField(TInt, $8C, 'Width', '', @tempi);
85
86 tempi := 2;
87 AddField(TInt, $8E, 'Height', '', @tempi);
88
89 tempi := 4;
90 AddField(TInt, $90, 'StoreType', '', @tempi);
91
92 temps := '*';
93 AddField(TLinkByID, $94, 'TXAN', '', @temps);
94
95 temps := 'TXMP';
96 AddField(TLinkByID, $98, 'TXMP', '', @temps);
97
98 AddField(TRawLink, $9C, 'RawLink', '', nil);
99
100 AddField(TRawLink, $A0, 'SepLink', '', nil);
101
102 tempi := $1C;
103 AddField(TUnused, $A4, 'Unused', '', @tempi);
104 end;
105 templist.Free;
106end;
107
108
109procedure TFile_TXMP.InitDatLinks;
110begin
111 SetLength(FDatLinks, 2);
112 FDatLinks[0].SrcOffset := $94;
113 FDatLinks[0].DestID := GetDatLinkValue(FFileStream, $94);
114 FDatLinks[0].PosDestExts := '*';
115 FDatLinks[1].SrcOffset := $98;
116 FDatLinks[1].DestID := GetDatLinkValue(FFileStream, $98);
117 FDatLinks[1].PosDestExts := 'TXMP';
118end;
119
120
121procedure TFile_TXMP.InitRawList;
122var
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
144begin
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);
175end;
176
177end.
178
Note: See TracBrowser for help on using the repository browser.