010 script
Code: Select all
//--------------------------------------
//--- 010 Editor v2.1.3 Script File
//
// File:
// Author: Teancum
// ZSS ripper
// 1) start with RIFF (4 bytes), record location of 'R'
// 2) next four bytes, file size (chunk_size)
// 3) add 8 bytes to chunk_size to cover header
// 4) return to this 'R' location
// 5) select from 'R' to chunk_size
// 6) export
// AUTO-FIND
// 1) Find first '.xma'
// 2) Go backward, find first 4-byte 00 set (filenames may be short or long, so we need to find the first set to ensure we're past the beginning of the name)
// 3) Go back 16 bytes
// 4) Record next 4 bytes as offset
// 5) Record next 4 bytes after that as size
// 6) Go forward 12 bytes
// 7) Record next 20 bytes as file name
//--------------------------------------
char filename[];
const char file_ext[]=".xma
uint chunk_offset;
const char find_xma[4]={'.','x','m','a'} //find XMA file name
const char chunk_type[4]={'R','I','F','F'}; // "RIFF"
char chunk_name[];
uint chunk_begin;
int i;
int filenum;
filename=InputOpenFileName(
"Open ZSM/ZSS ile",
"All files (*.zsm/zss)|*.zss",
"*.zsm" );
FileOpen(filename);
filenum = GetFileNum();
TFindResults find_chunk=FindAll(
//Find all XMA files
find_xma,
true,
true,
false,
0.0,
1,
0,
0 );
for(i = 0; i < find_chunk.count; i++ )
//Start at first RIFF chunk, iterate through until done
{
chunk_begin=find_chunk.start[i]; //.xma
chunk_offset=ReadInt(chunk_begin+4); //4 over from RIFF, read int
//chunk_name=ReadString(chunk_begin+16);
//Printf("%s\n", chunk_name+file_ext);
SetSelection( chunk_begin, chunk_offset+8); //Start at RIFF, end at chunk_offset+8 (to account for header)
CopyToClipboard(); //copy data
FileNew(); //Start a new file
PasteFromClipboard(); //paste into file
FileSave(chunk_name+file_ext); //Save here (can I get the actual names, or prompt to save?)
FileClose();
FileSelect( filenum );
};