source: oup/releases/0.17a/Unit9_data_structures.pas@ 156

Last change on this file since 156 was 21, checked in by alloc, 18 years ago
File size: 2.4 KB
RevLine 
[21]1UNIT Unit9_data_structures;
2INTERFACE
3USES SysUtils;
4
5TYPE
6 Tstructure_entry=RECORD
7 name:String;
8 offset:LongWord;
9 datatype:Byte; // 1..4: Integer[1..4] dec; 5..8: Integer[1..4] hex; 9: float; 10: bitset; 11+: string[1+]
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:Byte):String;
24FUNCTION GetStructureInfoId(ext:String):Integer;
25
26
27
28IMPLEMENTATION
29
30FUNCTION GetStructureInfoId(ext:String):Integer;
31 VAR
32 i:Integer;
33 BEGIN
34 FOR i:=0 TO High(structure_infos) DO BEGIN
35 IF structure_infos[i].extension=ext THEN BEGIN
36 Result:=i;
37 Exit;
38 END;
39 END;
40 Result:=-1;
41 END;
42
43FUNCTION GetDataType(typeid:Byte):String;
44 BEGIN
45 CASE typeid OF
46 1..4: Result:='Int'+IntToStr(typeid*8);
47 5..8: Result:='Int'+IntToStr((typeid-4)*8);
48 9: Result:='Float';
49 10: Result:='BitSet';
50 11..255: Result:='String('+IntToStr(typeid-10)+')';
51 END;
52 END;
53
54PROCEDURE AddEntry(_ext:String; _name:String; _offset:LongWord; _datatype:Byte; _description:String);
55 VAR
56 sid:Word;
57 BEGIN
58 sid:=GetStructureInfoId(_ext);
59 IF sid>=0 THEN BEGIN
60 WITH structure_infos[sid] DO BEGIN
61 SetLength(entries,Length(entries)+1);
62 WITH entries[High(entries)] DO BEGIN
63 name:=_name;
64 offset:=_offset;
65 datatype:=_datatype;
66 description:=_description;
67 END;
68 END;
69 END;
70 END;
71
72PROCEDURE AddExtension(_ext:String; _typedesc:String);
73 BEGIN
74 IF GetStructureInfoId(_ext)<0 THEN BEGIN
75 SetLength(structure_infos,Length(structure_infos)+1);
76 WITH structure_infos[High(structure_infos)] DO BEGIN
77 extension:='TXMP';
78 typedesc:='Texture';
79 END;
80 END;
81 END;
82
83BEGIN
84 AddExtension('TXMP','Texture');
85 AddEntry('TXMP','Fading',$88,10,'Fading-Bitset');
86 AddEntry('TXMP','Depth',$89,10,'Depth-Bitset');
87 AddEntry('TXMP','Width',$8C,2,'x-resolution of image');
88 AddEntry('TXMP','Height',$8E,2,'y-resolution of image');
89 AddEntry('TXMP','Storetype',$90,10,'Storetype-Bitset');
90 AddEntry('TXMP','Raw-Link',$9C,8,'Address of the image data in the .raw-file');
91END.
Note: See TracBrowser for help on using the repository browser.