1 |
unit TXMP; |
2 |
|
3 |
interface |
4 |
|
5 |
uses |
6 |
TypeDefs, _DataTypes, _FileTypes; |
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 |
19 |
ConnectionManager, Math; |
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; |
39 |
begin |
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; |
64 |
end; |
65 |
|
66 |
|
67 |
procedure TFile_TXMP.InitRawList; |
68 |
var |
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 |
|
90 |
begin |
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); |
121 |
end; |
122 |
|
123 |
end. |
124 |
|