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

Last change on this file since 206 was 206, checked in by alloc, 18 years ago
File size: 3.2 KB
Line 
1unit TXMP;
2
3interface
4
5uses
6 TypeDefs, _DataTypes, _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;
20
21{ TFile_SNDD }
22
23procedure TFile_TXMP.InitDatLinks;
24begin
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';
32end;
33
34
35procedure TFile_TXMP.InitDataFields;
36var
37 tempi: Integer;
38 temps: String;
39begin
40 FDataFields := TBlock.Create(Self, 0, 'Base', '', nil);
41 with FDataFields do
42 begin
43 AddField(TFileID, $00, 'FileID', '', nil);
44 AddField(TLevelID, $04, 'LevelID', '', nil);
45 tempi := 128;
46 AddField(TString, $08, 'FileName', '', @tempi);
47 tempi := 4;
48 AddField(TInt, $88, 'Flags', '', @tempi);
49 tempi := 2;
50 AddField(TInt, $8C, 'Width', '', @tempi);
51 tempi := 2;
52 AddField(TInt, $8E, 'Height', '', @tempi);
53 tempi := 4;
54 AddField(TInt, $90, 'StoreType', '', @tempi);
55 temps := 'TXAN';
56 AddField(TLinkByID, $94, 'TXAN', '', @temps);
57 temps := 'TXMP';
58 AddField(TLinkByID, $98, 'TXMP', '', @temps);
59 AddField(TRawLink, $9C, 'RawLink', '', nil);
60 AddField(TRawLink, $A0, 'SepLink', '', nil);
61 tempi := $1C;
62 AddField(TUnused, $A4, 'Unused', '', @tempi);
63 end;
64end;
65
66
67procedure TFile_TXMP.InitRawList;
68var
69 link_pc: Integer;
70 link_mac: Integer;
71 x, y: Word;
72 storetype: Byte;
73 datasize: Integer;
74 mipmap: Byte;
75
76 function GetImgSize(w,h, storetype: Integer): Integer;
77 begin
78 case storetype of
79 0, 1, 2:
80 Result := w*h*2;
81 8:
82 Result := w*h*4;
83 9:
84 Result := Max(1, w div 4) * Max(1, h div 4) * 8;
85 else
86 Result := -1;
87 end;
88 end;
89
90begin
91 ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $88, SizeOf(mipmap), @mipmap);
92 ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $8C, SizeOf(x), @x);
93 ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $8E, SizeOf(y), @y);
94 ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $90, SizeOf(storetype), @storetype);
95 ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $9C, 4, @link_pc);
96 ConManager.Connection[FConnectionID].LoadDatFilePart(FFileID, $A0, 4, @link_mac);
97
98 datasize := GetImgSize(x, y, storetype);
99 if (mipmap and $01) > 0 then
100 begin
101 repeat
102 x := Max(x div 2, 1);
103 y := Max(y div 2, 1);
104 datasize := datasize + GetImgSize(x, y, storetype);
105 until (x = 1) and (y = 1);
106 end;
107
108 SetLength(FRawParts, 1);
109 if ConManager.Connection[FConnectionID].DataOS = DOS_WIN then
110 begin
111 FRawParts[0].SrcOffset := $9C;
112 FRawParts[0].RawAddr := link_pc;
113 end
114 else
115 begin
116 FRawParts[0].SrcOffset := $A0;
117 FRawParts[0].RawAddr := link_mac;
118 end;
119 FRawParts[0].RawSize := datasize;
120 FRawParts[0].LocSep := not (ConManager.Connection[FConnectionID].DataOS = DOS_WIN);
121end;
122
123end.
124
Note: See TracBrowser for help on using the repository browser.