Changeset 74 for oup/current/Code
- Timestamp:
- Jan 11, 2007, 11:45:20 PM (18 years ago)
- Location:
- oup/current/Code
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
oup/current/Code/Exporters.pas
r46 r74 6 6 7 7 procedure ExportDatFile(fileid: LongWord; filename: String); 8 procedure ExportRawFiles(fileid: LongWord; filename: String); 8 9 procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); 9 10 function ExportSNDD(fileid: LongWord; filename: String; convert: Boolean): Integer; 11 function Export TRAC(fileid: LongWord; filename: String; convert: Boolean): Integer;12 function ExportT XAN(fileid: LongWord; filename: String; convert: Boolean): Integer;13 function ExportTX MB(fileid: LongWord; filename: String; convert: Boolean): Integer;14 function Export TXMP(fileid: LongWord; filename: String; convert: Boolean): Integer;15 16 var 17 ExportHandlers: array[1.. 1] of TExportHandlers = (18 19 //(Ext:'AGDB'; needed:False),20 (Ext: 'SNDD'; needed: True; Handler: ExportSNDD) 21 {(Ext:'TRAC'; needed:True; Handler:ExportTRAC),22 (Ext:'TXAN'; needed:True; Handler:ExportTXAN),23 (Ext:'TXMB'; needed:True; Handler:Export TXMB),24 (Ext:'TXMP'; needed:True; Handler:Export TXMP)25 });10 function ExportConverted(fileid: LongWord; filename: String): Integer; 11 12 function ExportSNDD(fileid: LongWord; filename: String): Integer; 13 function ExportTRAC(fileid: LongWord; filename: String): Integer; 14 function ExportTXAN(fileid: LongWord; filename: String): Integer; 15 function ExportImage(fileid: LongWord; filename: String): Integer; 16 17 var 18 ExportHandlers: array[1..3] of TExportHandlers = ( 19 // (Ext:'ABNA'; needed:False), 20 // (Ext:'AGDB'; needed:False), 21 (Ext: 'SNDD'; needed: True; Handler: ExportSNDD), 22 // (Ext:'TRAC'; needed:True; Handler:ExportTRAC), 23 // (Ext:'TXAN'; needed:True; Handler:ExportTXAN), 24 (Ext:'TXMB'; needed:True; Handler:ExportImage), 25 (Ext:'TXMP'; needed:True; Handler:ExportImage) 26 ); 26 27 27 28 … … 30 31 31 32 uses Functions, DataStructures, OniDataClass; 32 33 33 34 34 … … 54 54 55 55 56 56 procedure ExportRawFiles(fileid: LongWord; filename: String); 57 var 58 i: Integer; 59 rawlist: TRawList; 60 begin 61 rawlist := OniDataConnection.GetRawList(fileid); 62 if Length(rawlist) > 0 then 63 for i := 0 to High(rawlist) do 64 ExportRawFile(fileid, rawlist[i].src_offset, filename); 65 end; 57 66 58 67 procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); … … 77 86 end; 78 87 88 function ExportConverted(fileid: LongWord; filename: String): Integer; 89 var 90 i: Integer; 91 fileinfo: TFileInfo; 92 begin 93 fileinfo := OniDataConnection.GetFileInfo(fileid); 94 if Length(ExportHandlers) > 0 then 95 for i := 0 to High(ExportHandlers) do 96 if ExportHandlers[i].Ext = fileinfo.Extension then 97 ExportHandlers[i].Handler(fileid, filename); 98 end; 99 79 100 80 101 81 102 82 103 function ExportSNDD; 83 { CONST 84 WAVheader:Array[0..0] OF Byte=( 85 Ord('R'),Ord('I'),Ord('F'),Ord('F'),0,0,0,0,Ord('W'),Ord('A'),Ord('V'),Ord('E'), 86 Ord('f'),Ord('m'),Ord('t'),Ord(' '),24,0,0,0, 87 ); 88 } type 89 TDatData = record 104 type 105 TDatData = packed record 90 106 {0x00} 91 _fileid: LongWord;92 level: LongWord;93 F lag: LongWord;94 FormatTag:Word;95 ChanNo:Word;107 _fileid: LongWord; 108 level: LongWord; 109 FormatSize: LongWord; 110 AudioFormat: Word; 111 NumChannels: Word; 96 112 {0x10} 97 SampleRate: LongWord; 98 BytesPSec: LongWord; 99 BPSample: LongWord; 100 BitsPS: LongWord; 101 {0x20} 102 Unknown: array[1..7] of LongWord; 103 Unknown2: Word; 113 SampleRate: LongWord; 114 ByteRate: LongWord; 115 BlockAlign: Word; 116 BitsPerSample: Word; 117 {0x1C} 118 SizeExtHeader: Word; 119 SamplesPerBlock: Word; 120 NumCoefficients: Word; 121 Coefficients: array[0..6] of LongWord; 122 {0x3E} 123 Duration: Word; 104 124 {0x40} 105 RawSize: LongWord; 106 RawPos: LongWord; 107 end; 108 var 109 filestream: TFileStream; 110 125 RawSize: LongWord; 126 RawPos: LongWord; 127 end; 128 var 129 filestream: TFileStream; 111 130 DatData: TDatData; 131 i: Integer; 132 Data: Tdata; 133 112 134 //Wave Header Stuff 113 ASCII_Group: LongWord; //"RIFF" 114 WAV_Len: LongWord; 115 ASCII_WAV: LongWord; //"WAVE" 116 ASCII_FMT: LongWord; //"fmt " 117 WAV_FMT_Len: LongWord; 118 ASCII_DATA: LongWord; //"data" 119 WAV_FolLen: LongWord; 120 121 Data: Tdata; 135 ASCII_RIFF: LongWord; //"RIFF" 136 WAVE_Len: LongWord; 137 ASCII_WAVE: LongWord; //"WAVE" 138 ASCII_FMT: LongWord; //"fmt " 139 WAVE_FMT_Len: LongWord; 140 ASCII_DATA: LongWord; //"data" 141 WAVE_DataLen: LongWord; 122 142 begin 123 143 Result := export_noerror; … … 126 146 begin 127 147 //Initializing Header vars 128 ASCII_ Group:= 1179011410; // 'RIFF'129 WAV _Len := RAWSize + 70;130 ASCII_WAV := 1163280727; // 'WAVE'131 ASCII_FMT := 544501094; // 'fmt '132 WAV _FMT_Len := 50; // 50 bytes133 ASCII_DATA := 1635017060; // 'data'134 WAV _FolLen:= RAWSize;148 ASCII_RIFF := 1179011410; // 'RIFF' 149 WAVE_Len := RAWSize + 70; 150 ASCII_WAVE := 1163280727; // 'WAVE' 151 ASCII_FMT := 544501094; // 'fmt ' 152 WAVE_FMT_Len := 50; // 50 bytes 153 ASCII_DATA := 1635017060; // 'data' 154 WAVE_DataLen := RAWSize; 135 155 SetLength(Data, RAWSize); 136 156 OniDataConnection.LoadRawFile(fileid, $44, Data); 137 157 138 filestream := TFileStream.Create(filename + '.raw', fmCreate); 158 //Now start packing this into a neat wave... 159 filestream := TFileStream.Create(filename + '.wav', fmCreate); 160 filestream.Write(ASCII_RIFF, SizeOf(ASCII_RIFF)); 161 filestream.Write(WAVE_Len, SizeOf(WAVE_Len)); 162 filestream.Write(ASCII_WAVE, SizeOf(ASCII_WAVE)); 163 filestream.Write(ASCII_FMT, SizeOf(ASCII_FMT)); 164 filestream.Write(WAVE_FMT_Len, SizeOf(WAVE_FMT_Len)); 165 filestream.Write(AudioFormat, SizeOf(AudioFormat)); 166 filestream.Write(NumChannels, SizeOf(NumChannels)); 167 filestream.Write(Samplerate, SizeOf(Samplerate)); 168 filestream.Write(ByteRate, SizeOf(ByteRate)); 169 filestream.Write(BlockAlign, SizeOf(BlockAlign)); 170 filestream.Write(BitsPerSample, SizeOf(BitsPerSample)); 171 filestream.Write(SizeExtHeader, SizeOf(SizeExtHeader)); 172 filestream.Write(SamplesPerBlock, SizeOf(SamplesPerBlock)); 173 filestream.Write(NumCoefficients, SizeOf(NumCoefficients)); 174 for i := 0 to High(Coefficients) do 175 filestream.Write(Coefficients[i], SizeOf(Coefficients[i])); 176 filestream.Write(ASCII_DATA, SizeOf(ASCII_DATA)); 177 filestream.Write(WAVE_DataLen, SizeOf(WAVE_DataLen)); 139 178 filestream.Write(Data[0], Length(Data)); 140 179 filestream.Free; 141 142 if convert then143 begin144 //Now start packing this into a neat wave...145 filestream := TFileStream.Create(filename + '.wav', fmCreate);146 filestream.Write(ASCII_Group, SizeOf(ASCII_Group));147 filestream.Write(WAV_Len, SizeOf(WAV_Len));148 filestream.Write(ASCII_WAV, SizeOf(ASCII_WAV));149 filestream.Write(ASCII_FMT, SizeOf(ASCII_FMT));150 filestream.Write(WAV_FMT_Len, SizeOf(WAV_FMT_Len));151 filestream.Write(ChanNo, SizeOf(ChanNo));152 filestream.Write(Samplerate, SizeOf(Samplerate));153 filestream.Write(BytesPSec, SizeOf(BytesPSec));154 filestream.Write(BPSample, SizeOf(BPSample));155 filestream.Write(BitsPS, SizeOf(BitsPS));156 filestream.Write(Unknown[1], SizeOf(Unknown));157 filestream.Write(Unknown2, SizeOf(Unknown2));158 filestream.Write(ASCII_DATA, SizeOf(ASCII_DATA));159 filestream.Write(WAV_FolLen, SizeOf(WAV_FolLen));160 filestream.Write(Data[0], Length(Data));161 filestream.Free;162 end;163 180 end; 164 181 end; … … 214 231 215 232 216 function ExportTXMB; 217 var 218 filestream: TFileStream; 219 // img:TImgPackage; 220 Data: Tdata; 221 begin 222 Result := export_noerror; 223 if convert then 224 begin 225 { img:=LoadTXMBconnected(fileid); 226 data:=ImgdataToBmp(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata); 227 filestream:=TFileStream.Create(filename+'.bmp',fmCreate); 228 filestream.Write(data[0],Length(data)); 229 filestream.Free; 230 } end; 231 end; 232 233 234 235 236 function ExportTXMP; 237 var 238 filestream: TFileStream; 239 // img:TImgPackage; 240 begin 241 Result := export_noerror; 242 { img:=LoadImgData(fileid); 243 244 filestream:=TFileStream.Create(filename+'.raw',fmCreate); 245 filestream.Write(img.imgdata[0],Length(img.imgdata)); 246 filestream.Free; 247 248 IF convert THEN BEGIN 249 img.imgdata:=ImgdataToBMP(img.imgx,img.imgy,img.imgdepth,img.storetype,img.imgdata); 250 filestream:=TFileStream.Create(filename+'.bmp',fmCreate); 251 filestream.Write(img.imgdata[0],Length(img.imgdata)); 252 filestream.Free; 253 END; 254 } end; 233 function ExportImage; 234 var 235 filestream: TFileStream; 236 img: TOniImage; 237 data: Tdata; 238 begin 239 Result := export_noerror; 240 241 img := TOniImage.Create; 242 img.Load(fileid); 243 data := img.GetAsBMP; 244 img.Free; 245 246 filestream:=TFileStream.Create(filename+'.bmp',fmCreate); 247 filestream.Write(data[0],Length(data)); 248 filestream.Free; 249 end; 255 250 256 251 end. -
oup/current/Code/Functions.pas
r46 r74 4 4 5 5 uses Classes, Dialogs, SysUtils, StrUtils, Math, Data; 6 7 type8 TExportSet = set of (DO_dat, DO_raw, DO_convert, DO_toone);9 6 10 7 function BoolToStr(bool: Boolean): String; … … 16 13 function DataToBin(Data: Tdata): String; 17 14 function BinToInt(bin: String): Byte; 18 19 function ExportFile(fileid: LongWord; filename: String; settings: TExportSet;20 path: String): Integer;21 15 22 16 function StringSmaller(string1, string2: String): Boolean; … … 324 318 325 319 326 327 function ExportFile(fileid: LongWord; filename: String; settings: TExportSet;328 path: String): Integer;329 var330 i: Byte;331 extension: String;332 rawlist: TRawList;333 begin334 Result := export_noerror;335 extension := RightStr(filename, 4);336 if DO_toone in settings then337 begin338 ExportDatFile(fileid, path + '\' + GetWinFileName(filename));339 end340 else341 begin342 if DO_dat in settings then343 ExportDatFile(fileid, path + '\' + GetWinFileName(filename));344 if DO_raw in settings then345 begin346 rawlist := OniDataConnection.GetRawList(fileid);347 if Length(rawlist) > 0 then348 begin349 for i := 0 to High(rawlist) do350 begin351 ExportRawFile(fileid, rawlist[i].src_offset, path + '\' +352 GetWinFileName(filename));353 end;354 end;355 end;356 end;357 end;358 359 360 361 362 320 function Explode(_string: String; delimiter: Char): TStringArray; 363 321 var
Note:
See TracChangeset
for help on using the changeset viewer.