source: oup/releases/0.20a/Unit4_Exporters.pas@ 1139

Last change on this file since 1139 was 21, checked in by alloc, 18 years ago
File size: 5.4 KB
RevLine 
[21]1UNIT Unit4_Exporters;
2INTERFACE
3USES Classes, Dialogs, StrUtils, SysUtils, Math, Unit3_data, Unit6_imgfuncs;
4
5PROCEDURE ExportDatFile(fileid:LongWord; filename:String);
6
7FUNCTION ExportSNDD(fileid:LongWord; filename:String; convert:Boolean):Integer;
8FUNCTION ExportTRAC(fileid:LongWord; filename:String; convert:Boolean):Integer;
9FUNCTION ExportTXAN(fileid:LongWord; filename:String; convert:Boolean):Integer;
10FUNCTION ExportTXMB(fileid:LongWord; filename:String; convert:Boolean):Integer;
11FUNCTION ExportTXMP(fileid:LongWord; filename:String; convert:Boolean):Integer;
12VAR
13 ExportHandlers:Array[1..1] OF TExportHandlers=(
14// (Ext:'ABNA'; needed:False),
15 //(Ext:'AGDB'; needed:False),
16 (Ext:'SNDD'; needed:True; Handler:ExportSNDD)
17{ (Ext:'TRAC'; needed:True; Handler:ExportTRAC),
18 (Ext:'TXAN'; needed:True; Handler:ExportTXAN),
19 (Ext:'TXMB'; needed:True; Handler:ExportTXMB),
20 (Ext:'TXMP'; needed:True; Handler:ExportTXMP)
21} );
22
23
24
25IMPLEMENTATION
26USES Unit2_functions;
27
28PROCEDURE ExportDatFile(fileid:LongWord; filename:String);
29 VAR
30 filestream:TFileStream;
31 data:Tdata;
32 BEGIN
33 data:=LoadDatFile(fileid);
34 filestream:=TFileStream.Create(filename,fmCreate);
35 filestream.Write(data[0],Length(data));
36 filestream.Free;
37 END;
38
39FUNCTION ExportSNDD;
40 TYPE
41 TDatData=RECORD
42 _fileid:LongWord;
43 level:LongWord;
44 Flag:LongWord;
45 ChanNo:LongWord;
46 SampleRate:LongWord;
47 BytesPSec:LongWord;
48 BPSample:LongWord;
49 BitsPS:LongWord;
50 Unknown:Array[1..7] OF LongWord;
51 Unknown2:Word;
52 RawSize:LongWord;
53 RawPos:LongWord;
54 END;
55 VAR
56 filestream:TFileStream;
57
58 DatData:TDatData;
59 //Wave Header Stuff
60 ASCII_Group:LongWord; //RIFF
61 WAV_Len:LongWord;
62 ASCII_WAV:LongWord; //WAVE
63 ASCII_FMT:LongWord; //"fmt "
64 WAV_FMT_Len:LongWord;
65 ASCII_DATA:LongWord; //DATA
66 WAV_FolLen:LongWord;
67
68 data:Tdata;
69 BEGIN
70 Result:=export_noerror;
71 LoadDatFilePart(fileid,0,SizeOf(DatData),@DatData);
72 WITH DatData DO BEGIN
73 //Initializing Header vars
74 ASCII_Group:=1179011410;
75 WAV_Len:=RAWSize+70;
76 ASCII_WAV:=1163280727;
77 ASCII_FMT:=544501094;
78 WAV_FMT_Len:=50;
79 ASCII_DATA:=1635017060;
80 WAV_FolLen:=RAWSize;
81 SetLength(data,RAWSize);
82 LoadRawFile(fileid,68,Length(data),data);
83
84 filestream:=TFileStream.Create(filename+'.raw',fmCreate);
85 filestream.Write(data[0],Length(data));
86 filestream.Free;
87
88 IF convert THEN BEGIN
89 //Now start packing this into a neat wave...
90 filestream:=TFileStream.Create(filename+'.wav',fmCreate);
91 filestream.Write(ASCII_Group,SizeOf(ASCII_Group));
92 filestream.Write(WAV_Len,SizeOf(WAV_Len));
93 filestream.Write(ASCII_WAV,SizeOf(ASCII_WAV));
94 filestream.Write(ASCII_FMT,SizeOf(ASCII_FMT));
95 filestream.Write(WAV_FMT_Len,SizeOf(WAV_FMT_Len));
96 filestream.Write(ChanNo,SizeOf(ChanNo));
97 filestream.Write(Samplerate,SizeOf(Samplerate));
98 filestream.Write(BytesPSec,SizeOf(BytesPSec));
99 filestream.Write(BPSample,SizeOf(BPSample));
100 filestream.Write(BitsPS,SizeOf(BitsPS));
101 filestream.Write(Unknown[1],SizeOf(Unknown));
102 filestream.Write(Unknown2,SizeOf(Unknown2));
103 filestream.Write(ASCII_DATA,SizeOf(ASCII_DATA));
104 filestream.Write(WAV_FolLen,SizeOf(WAV_FolLen));
105 filestream.Write(data[0],Length(data));
106 filestream.Free;
107 END;
108 END;
109 END;
110
111FUNCTION ExportTRAC;
112 VAR
113 link:LongWord;
114 linkcount:Word;
115 i:LongWord;
116 BEGIN
117 Result:=export_noerror;
118
119 LoadDatFilePart(fileid,$18,SizeOf(link),@link);
120 link:=link DIV 256;
121
122 LoadDatFilePart(fileid,$1E,SizeOf(linkcount),@linkcount);
123 FOR i:=1 TO linkcount DO BEGIN
124 LoadDatFilePart(fileid,$20+(i-1)*12+8,SizeOf(link),@link);
125 link:=link DIV 256;
126 END;
127 END;
128
129FUNCTION ExportTXAN;
130 VAR
131 loop_speed,unknown:Word;
132 linkcount:LongWord;
133 link:LongWord;
134 i:Byte;
135 BEGIN
136 Result:=export_noerror;
137
138 LoadDatFilePart(fileid,$14,SizeOf(loop_speed),@loop_speed);
139 LoadDatFilePart(fileid,$16,SizeOf(unknown),@unknown);
140
141 LoadDatFilePart(fileid,$1C,SizeOf(linkcount),@linkcount);
142 FOR i:=0 TO linkcount-1 DO BEGIN
143 LoadDatFilePart(fileid,$20+i*4,SizeOf(link),@link);
144 link:=link DIV 256;
145 IF link=0 THEN link:=fileid-1;
146 END;
147 END;
148
149FUNCTION ExportTXMB;
150 VAR
151 filestream:TFileStream;
152 img:TImgPackage;
153 data:Tdata;
154 BEGIN
155 Result:=export_noerror;
156 IF convert THEN BEGIN
157 img:=LoadTXMBconnected(fileid);
158 data:=ImgdataToBmp(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata);
159 filestream:=TFileStream.Create(filename+'.bmp',fmCreate);
160 filestream.Write(data[0],Length(data));
161 filestream.Free;
162 END;
163 END;
164
165FUNCTION ExportTXMP;
166 VAR
167 filestream:TFileStream;
168 img:TImgPackage;
169 BEGIN
170 Result:=export_noerror;
171 img:=LoadImgData(fileid);
172
173 filestream:=TFileStream.Create(filename+'.raw',fmCreate);
174 filestream.Write(img.imgdata[0],Length(img.imgdata));
175 filestream.Free;
176
177 IF convert THEN BEGIN
178 img.imgdata:=ImgdataToBMP(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata);
179 filestream:=TFileStream.Create(filename+'.bmp',fmCreate);
180 filestream.Write(img.imgdata[0],Length(img.imgdata));
181 filestream.Free;
182 END;
183 END;
184
185END.
Note: See TracBrowser for help on using the repository browser.