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

Last change on this file since 214 was 214, checked in by alloc, 17 years ago
File size: 4.7 KB
RevLine 
[206]1unit TXMP;
2
3interface
4
5uses
[209]6 _FileTypes;
[206]7
8type
9 TFile_TXMP = class(TFile)
10 protected
11 procedure InitDatLinks; override;
[214]12 procedure InitRawList; override;
13 public
[206]14 procedure InitDataFields; override;
15 end;
16
17implementation
18
19uses
[209]20 ConnectionManager, Math, Classes, TypeDefs, _DataTypes;
[206]21
[209]22{ TFile_TXMP }
[206]23
24procedure TFile_TXMP.InitDataFields;
25var
26 tempi: Integer;
27 temps: String;
[207]28 templist: TStringList;
[206]29begin
[213]30 inherited;
[212]31 FDataFields := TBlock.Create(Self, nil, 0, 'Base', '', nil);
[207]32 templist := TStringList.Create;
[206]33 with FDataFields do
34 begin
35 AddField(TFileID, $00, 'FileID', '', nil);
[207]36
[206]37 AddField(TLevelID, $04, 'LevelID', '', nil);
[207]38
[206]39 tempi := 128;
40 AddField(TString, $08, 'FileName', '', @tempi);
[207]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
[206]85 tempi := 2;
86 AddField(TInt, $8C, 'Width', '', @tempi);
[207]87
[206]88 tempi := 2;
89 AddField(TInt, $8E, 'Height', '', @tempi);
[207]90
[206]91 tempi := 4;
92 AddField(TInt, $90, 'StoreType', '', @tempi);
[207]93
94 temps := '*';
[206]95 AddField(TLinkByID, $94, 'TXAN', '', @temps);
[207]96
[206]97 temps := 'TXMP';
98 AddField(TLinkByID, $98, 'TXMP', '', @temps);
[207]99
[206]100 AddField(TRawLink, $9C, 'RawLink', '', nil);
[207]101
[206]102 AddField(TRawLink, $A0, 'SepLink', '', nil);
[207]103
[206]104 tempi := $1C;
105 AddField(TUnused, $A4, 'Unused', '', @tempi);
106 end;
[207]107 templist.Free;
[206]108end;
109
110
[209]111procedure TFile_TXMP.InitDatLinks;
112begin
113 SetLength(FDatLinks, 2);
114 FDatLinks[0].SrcOffset := $94;
[210]115 FDatLinks[0].DestID := GetDatLinkValue(FFileStream, $94);
[209]116 FDatLinks[0].PosDestExts := '*';
117 FDatLinks[1].SrcOffset := $98;
[210]118 FDatLinks[1].DestID := GetDatLinkValue(FFileStream, $98);
[209]119 FDatLinks[1].PosDestExts := 'TXMP';
120end;
121
122
[206]123procedure TFile_TXMP.InitRawList;
124var
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
146begin
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);
177end;
178
179end.
180
Note: See TracBrowser for help on using the repository browser.