| 2 |
|
|
| 3 |
|
interface |
| 4 |
|
|
| 5 |
< |
uses Classes, Dialogs, StrUtils, SysUtils, Math, Data, OniImgClass; |
| 5 |
> |
uses Classes, Dialogs, StrUtils, SysUtils, Math, Data, OniImgClass, OniDataClass; |
| 6 |
|
|
| 7 |
< |
procedure ExportDatFile(fileid: LongWord; filename: String); |
| 8 |
< |
procedure ExportRawFiles(fileid: LongWord; filename: String); |
| 9 |
< |
procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); |
| 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; |
| 7 |
> |
type |
| 8 |
> |
TExportHandlers = record |
| 9 |
> |
Ext: String[4]; |
| 10 |
> |
needed: Boolean; |
| 11 |
> |
Handler: function(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 12 |
> |
end; |
| 13 |
> |
|
| 14 |
> |
procedure ExportDatFile(connection: TOniData; fileid: LongWord; filename: String); |
| 15 |
> |
procedure ExportRawFiles(connection: TOniData; fileid: LongWord; filename: String); |
| 16 |
> |
procedure ExportRawFile(connection: TOniData; fileid: LongWord; dat_offset: LongWord; filename: String); |
| 17 |
> |
function ExportConverted(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 18 |
> |
|
| 19 |
> |
function ExportSNDD(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 20 |
> |
function ExportTRAC(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 21 |
> |
function ExportTXAN(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 22 |
> |
function ExportImage(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 23 |
|
|
| 24 |
|
var |
| 25 |
|
ExportHandlers: array[1..3] of TExportHandlers = ( |
| 36 |
|
|
| 37 |
|
implementation |
| 38 |
|
|
| 39 |
< |
uses Functions, DataStructures, OniDataClass; |
| 39 |
> |
uses Functions, DataStructures; |
| 40 |
|
|
| 41 |
|
|
| 42 |
|
|
| 43 |
< |
procedure ExportDatFile(fileid: LongWord; filename: String); |
| 43 |
> |
procedure ExportDatFile(connection: TOniData; fileid: LongWord; filename: String); |
| 44 |
|
var |
| 45 |
|
filestream: TFileStream; |
| 46 |
|
Data: Tdata; |
| 47 |
|
begin |
| 48 |
< |
Data := OniDataConnection.LoadDatFile(fileid); |
| 48 |
> |
Data := connection.LoadDatFile(fileid); |
| 49 |
|
if FileExists(filename) then |
| 50 |
|
begin |
| 51 |
|
filestream := TFileStream.Create(filename, fmOpenReadWrite); |
| 60 |
|
end; |
| 61 |
|
|
| 62 |
|
|
| 63 |
< |
procedure ExportRawFiles(fileid: LongWord; filename: String); |
| 63 |
> |
procedure ExportRawFiles(connection: TOniData; fileid: LongWord; filename: String); |
| 64 |
|
var |
| 65 |
|
i: Integer; |
| 66 |
|
rawlist: TRawList; |
| 67 |
|
begin |
| 68 |
< |
rawlist := OniDataConnection.GetRawList(fileid); |
| 68 |
> |
rawlist := connection.GetRawList(fileid); |
| 69 |
|
if Length(rawlist) > 0 then |
| 70 |
|
for i := 0 to High(rawlist) do |
| 71 |
< |
ExportRawFile(fileid, rawlist[i].src_offset, filename); |
| 71 |
> |
ExportRawFile(connection, fileid, rawlist[i].src_offset, filename); |
| 72 |
|
end; |
| 73 |
|
|
| 74 |
< |
procedure ExportRawFile(fileid: LongWord; dat_offset: LongWord; filename: String); |
| 74 |
> |
procedure ExportRawFile(connection: TOniData; fileid: LongWord; dat_offset: LongWord; filename: String); |
| 75 |
|
var |
| 76 |
|
filestream: TFileStream; |
| 77 |
|
Data: Tdata; |
| 78 |
|
begin |
| 79 |
< |
SetLength(Data, OniDataConnection.GetRawInfo(fileid, dat_offset).raw_size); |
| 80 |
< |
OniDataConnection.LoadRawFile(fileid, dat_offset, @Data[0]); |
| 79 |
> |
SetLength(Data, connection.GetRawInfo(fileid, dat_offset).raw_size); |
| 80 |
> |
connection.LoadRawFile(fileid, dat_offset, @Data[0]); |
| 81 |
|
if FileExists(filename + '.raw0x' + IntToHex(dat_offset, 8)) then |
| 82 |
|
begin |
| 83 |
|
filestream := TFileStream.Create(filename + '.raw0x' + IntToHex( |
| 92 |
|
filestream.Free; |
| 93 |
|
end; |
| 94 |
|
|
| 95 |
< |
function ExportConverted(fileid: LongWord; filename: String): Integer; |
| 95 |
> |
function ExportConverted(connection: TOniData; fileid: LongWord; filename: String): Integer; |
| 96 |
|
var |
| 97 |
|
i: Integer; |
| 98 |
|
fileinfo: TFileInfo; |
| 99 |
|
begin |
| 100 |
< |
fileinfo := OniDataConnection.GetFileInfo(fileid); |
| 100 |
> |
fileinfo := connection.GetFileInfo(fileid); |
| 101 |
|
if Length(ExportHandlers) > 0 then |
| 102 |
|
for i := 0 to High(ExportHandlers) do |
| 103 |
|
if ExportHandlers[i].Ext = fileinfo.Extension then |
| 104 |
< |
ExportHandlers[i].Handler(fileid, filename); |
| 104 |
> |
ExportHandlers[i].Handler(connection, fileid, filename); |
| 105 |
|
end; |
| 106 |
|
|
| 107 |
|
|
| 148 |
|
WAVE_DataLen: LongWord; |
| 149 |
|
begin |
| 150 |
|
Result := export_noerror; |
| 151 |
< |
OniDataConnection.LoadDatFilePart(fileid, 0, SizeOf(DatData), @DatData); |
| 151 |
> |
connection.LoadDatFilePart(fileid, 0, SizeOf(DatData), @DatData); |
| 152 |
|
with DatData do |
| 153 |
|
begin |
| 154 |
|
//Initializing Header vars |
| 160 |
|
ASCII_DATA := 1635017060; // 'data' |
| 161 |
|
WAVE_DataLen := RAWSize; |
| 162 |
|
SetLength(Data, RAWSize); |
| 163 |
< |
OniDataConnection.LoadRawFile(fileid, $44, Data); |
| 163 |
> |
connection.LoadRawFile(fileid, $44, Data); |
| 164 |
|
|
| 165 |
|
//Now start packing this into a neat wave... |
| 166 |
|
filestream := TFileStream.Create(filename + '.wav', fmCreate); |
| 198 |
|
begin |
| 199 |
|
Result := export_noerror; |
| 200 |
|
|
| 201 |
< |
OniDataConnection.LoadDatFilePart(fileid, $18, SizeOf(link), @link); |
| 201 |
> |
connection.LoadDatFilePart(fileid, $18, SizeOf(link), @link); |
| 202 |
|
link := link div 256; |
| 203 |
|
|
| 204 |
< |
OniDataConnection.LoadDatFilePart(fileid, $1E, SizeOf(linkcount), @linkcount); |
| 204 |
> |
connection.LoadDatFilePart(fileid, $1E, SizeOf(linkcount), @linkcount); |
| 205 |
|
for i := 1 to linkcount do |
| 206 |
|
begin |
| 207 |
< |
OniDataConnection.LoadDatFilePart(fileid, $20 + (i - 1) * 12 + 8, SizeOf(link), @link); |
| 207 |
> |
connection.LoadDatFilePart(fileid, $20 + (i - 1) * 12 + 8, SizeOf(link), @link); |
| 208 |
|
link := link div 256; |
| 209 |
|
end; |
| 210 |
|
end; |
| 221 |
|
begin |
| 222 |
|
Result := export_noerror; |
| 223 |
|
|
| 224 |
< |
OniDataConnection.LoadDatFilePart(fileid, $14, SizeOf(loop_speed), @loop_speed); |
| 225 |
< |
OniDataConnection.LoadDatFilePart(fileid, $16, SizeOf(unknown), @unknown); |
| 224 |
> |
connection.LoadDatFilePart(fileid, $14, SizeOf(loop_speed), @loop_speed); |
| 225 |
> |
connection.LoadDatFilePart(fileid, $16, SizeOf(unknown), @unknown); |
| 226 |
|
|
| 227 |
< |
OniDataConnection.LoadDatFilePart(fileid, $1C, SizeOf(linkcount), @linkcount); |
| 227 |
> |
connection.LoadDatFilePart(fileid, $1C, SizeOf(linkcount), @linkcount); |
| 228 |
|
for i := 0 to linkcount - 1 do |
| 229 |
|
begin |
| 230 |
< |
OniDataConnection.LoadDatFilePart(fileid, $20 + i * 4, SizeOf(link), @link); |
| 230 |
> |
connection.LoadDatFilePart(fileid, $20 + i * 4, SizeOf(link), @link); |
| 231 |
|
link := link div 256; |
| 232 |
|
if link = 0 then |
| 233 |
|
link := fileid - 1; |
| 246 |
|
Result := export_noerror; |
| 247 |
|
|
| 248 |
|
img := TOniImage.Create; |
| 249 |
< |
img.Load(fileid); |
| 249 |
> |
img.Load(connection, fileid); |
| 250 |
|
data := img.GetAsBMP; |
| 251 |
|
img.Free; |
| 252 |
|
|