Changeset 74 for oup/current/Code


Ignore:
Timestamp:
Jan 11, 2007, 11:45:20 PM (18 years ago)
Author:
alloc
Message:
 
Location:
oup/current/Code
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • oup/current/Code/Exporters.pas

    r46 r74  
    66
    77procedure ExportDatFile(fileid: LongWord; filename: String);
     8procedure ExportRawFiles(fileid: LongWord; filename: String);
    89procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String);
    9 
    10 function ExportSNDD(fileid: LongWord; filename: String; convert: Boolean): Integer;
    11 function ExportTRAC(fileid: LongWord; filename: String; convert: Boolean): Integer;
    12 function ExportTXAN(fileid: LongWord; filename: String; convert: Boolean): Integer;
    13 function ExportTXMB(fileid: LongWord; filename: String; convert: Boolean): Integer;
    14 function ExportTXMP(fileid: LongWord; filename: String; convert: Boolean): Integer;
    15 
    16 var
    17   ExportHandlers: array[1..1] of TExportHandlers = (
    18     //    (Ext:'ABNA'; needed:False),
    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:ExportTXMB),
    24     (Ext:'TXMP'; needed:True; Handler:ExportTXMP)
    25 });
     10function ExportConverted(fileid: LongWord; filename: String): Integer;
     11
     12function ExportSNDD(fileid: LongWord; filename: String): Integer;
     13function ExportTRAC(fileid: LongWord; filename: String): Integer;
     14function ExportTXAN(fileid: LongWord; filename: String): Integer;
     15function ExportImage(fileid: LongWord; filename: String): Integer;
     16
     17var
     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);
    2627
    2728
     
    3031
    3132uses Functions, DataStructures, OniDataClass;
    32 
    3333
    3434
     
    5454
    5555
    56 
     56procedure ExportRawFiles(fileid: LongWord; filename: String);
     57var
     58  i: Integer;
     59  rawlist: TRawList;
     60begin
     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);
     65end;
    5766
    5867procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String);
     
    7786end;
    7887
     88function ExportConverted(fileid: LongWord; filename: String): Integer;
     89var
     90  i: Integer;
     91  fileinfo: TFileInfo;
     92begin
     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);
     98end;
     99
    79100
    80101
    81102
    82103function 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
     104type
     105  TDatData = packed record
    90106    {0x00}
    91     _fileid:   LongWord;
    92     level:     LongWord;
    93     Flag:      LongWord;
    94     FormatTag: Word;
    95     ChanNo:    Word;
     107    _fileid:         LongWord;
     108    level:           LongWord;
     109    FormatSize:      LongWord;
     110    AudioFormat:    Word;
     111    NumChannels:     Word;
    96112    {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;
    104124    {0x40}
    105     RawSize:   LongWord;
    106     RawPos:    LongWord;
    107   end;
    108 var
    109   filestream: TFileStream;
    110 
     125    RawSize:         LongWord;
     126    RawPos:          LongWord;
     127  end;
     128var
     129  filestream: TFileStream;
    111130  DatData:     TDatData;
     131  i: Integer;
     132  Data: Tdata;
     133
    112134  //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;
    122142begin
    123143  Result := export_noerror;
     
    126146  begin
    127147    //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 bytes
    133     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;
    135155    SetLength(Data, RAWSize);
    136156    OniDataConnection.LoadRawFile(fileid, $44, Data);
    137157
    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));
    139178    filestream.Write(Data[0], Length(Data));
    140179    filestream.Free;
    141 
    142     if convert then
    143     begin
    144       //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;
    163180  end;
    164181end;
     
    214231
    215232
    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;
     233function ExportImage;
     234var
     235  filestream: TFileStream;
     236  img: TOniImage;
     237  data: Tdata;
     238begin
     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;
     249end;
    255250
    256251end.
  • oup/current/Code/Functions.pas

    r46 r74  
    44
    55uses Classes, Dialogs, SysUtils, StrUtils, Math, Data;
    6 
    7 type
    8   TExportSet = set of (DO_dat, DO_raw, DO_convert, DO_toone);
    96
    107function BoolToStr(bool: Boolean): String;
     
    1613function DataToBin(Data: Tdata): String;
    1714function BinToInt(bin: String): Byte;
    18 
    19 function ExportFile(fileid: LongWord; filename: String; settings: TExportSet;
    20   path: String): Integer;
    2115
    2216function StringSmaller(string1, string2: String): Boolean;
     
    324318
    325319
    326 
    327 function ExportFile(fileid: LongWord; filename: String; settings: TExportSet;
    328   path: String): Integer;
    329 var
    330   i: Byte;
    331   extension: String;
    332   rawlist: TRawList;
    333 begin
    334   Result    := export_noerror;
    335   extension := RightStr(filename, 4);
    336   if DO_toone in settings then
    337   begin
    338     ExportDatFile(fileid, path + '\' + GetWinFileName(filename));
    339   end
    340   else
    341   begin
    342     if DO_dat in settings then
    343       ExportDatFile(fileid, path + '\' + GetWinFileName(filename));
    344     if DO_raw in settings then
    345     begin
    346       rawlist := OniDataConnection.GetRawList(fileid);
    347       if Length(rawlist) > 0 then
    348       begin
    349         for i := 0 to High(rawlist) do
    350         begin
    351           ExportRawFile(fileid, rawlist[i].src_offset, path + '\' +
    352             GetWinFileName(filename));
    353         end;
    354       end;
    355     end;
    356   end;
    357 end;
    358 
    359 
    360 
    361 
    362320function Explode(_string: String; delimiter: Char): TStringArray;
    363321var
Note: See TracChangeset for help on using the changeset viewer.