source: oup/releases/0.23a/Unit9_data_structures.pas@ 260

Last change on this file since 260 was 23, checked in by alloc, 18 years ago
File size: 3.0 KB
RevLine 
[23]1UNIT Unit9_data_structures;
2INTERFACE
3USES SysUtils;
4
5TYPE
6 Tstructure_entry=RECORD
7 name:String;
8 offset:LongWord;
9 datatype:Word; // 1..4: Integer[1..4] dec; 5..8: Integer[1..4] hex; 9: float; 10: bitset; 10000+: string[0+]
10 description:String;
11 END;
12 Tstructure_info=RECORD
13 extension:String;
14 typedesc:String;
15 entries:Array OF Tstructure_entry;
16 END;
17 Tstructures=Array OF Tstructure_info;
18
19VAR
20 structure_infos:Tstructures;
21
22
23FUNCTION GetDataType(typeid:Word):String;
24FUNCTION GetStructureInfoId(ext:String):Integer;
25FUNCTION GetTypeDataLength(datatype:Word):Word;
26
27
28
29IMPLEMENTATION
30
31FUNCTION GetTypeDataLength(datatype:Word):Word;
32 BEGIN
33 CASE datatype OF
34 1..4: Result:=datatype;
35 5..8: Result:=datatype-4;
36 9: Result:=4;
37 10: Result:=1;
38 10000..65535: Result:=datatype-10000;
39 END;
40 END;
41
42
43FUNCTION GetStructureInfoId(ext:String):Integer;
44 VAR
45 i:Integer;
46 BEGIN
47 FOR i:=0 TO High(structure_infos) DO BEGIN
48 IF structure_infos[i].extension=ext THEN BEGIN
49 Result:=i;
50 Exit;
51 END;
52 END;
53 Result:=-1;
54 END;
55
56
57FUNCTION GetDataType(typeid:Word):String;
58 BEGIN
59 CASE typeid OF
60 1..4: Result:='Int'+IntToStr(typeid*8);
61 5..8: Result:='Int'+IntToStr((typeid-4)*8);
62 9: Result:='Float';
63 10: Result:='BitSet';
64 10000..65535: Result:='String('+IntToStr(typeid-10000)+')';
65 END;
66 END;
67
68
69PROCEDURE AddEntry(_ext:String; _name:String; _offset:LongWord; _datatype:Word; _description:String);
70 VAR
71 sid:Integer;
72 BEGIN
73 sid:=GetStructureInfoId(_ext);
74 IF sid>=0 THEN BEGIN
75 WITH structure_infos[sid] DO BEGIN
76 SetLength(entries,Length(entries)+1);
77 WITH entries[High(entries)] DO BEGIN
78 name:=_name;
79 offset:=_offset;
80 datatype:=_datatype;
81 description:=_description;
82 END;
83 END;
84 END;
85 END;
86
87
88PROCEDURE AddExtension(_ext:String; _typedesc:String);
89 BEGIN
90 IF GetStructureInfoId(_ext)<0 THEN BEGIN
91 SetLength(structure_infos,Length(structure_infos)+1);
92 WITH structure_infos[High(structure_infos)] DO BEGIN
93 extension:=_ext;
94 typedesc:=_typedesc;
95 END;
96 END;
97 END;
98
99
100BEGIN
101 AddExtension('TXMP','Texture');
102 AddEntry('TXMP','ID',$00,4,'ID of this file');
103 AddEntry('TXMP','LevelID',$04,8,'ID of the level this file is in');
104 AddEntry('TXMP','FileName',$08,10128,'');
105 AddEntry('TXMP','Fading',$88,10,'Fading-Bitset');
106 AddEntry('TXMP','Depth',$89,10,'Depth-Bitset');
107 AddEntry('TXMP','Width',$8C,2,'x-resolution of image');
108 AddEntry('TXMP','Height',$8E,2,'y-resolution of image');
109 AddEntry('TXMP','Storetype',$90,10,'Storetype-Bitset');
110 AddEntry('TXMP','TXAN-Link',$94,8,'Link to the TXAN-file (if this TXMP is the first image of an animation)');
111 AddEntry('TXMP','TXMP-Link',$98,8,'Link to another TXMP-file');
112 AddEntry('TXMP','Raw-Link',$9C,8,'Address of the image data in the .raw-file');
113END.
Note: See TracBrowser for help on using the repository browser.