Created
March 6, 2018 11:24
-
-
Save jpcima/171397f19721a1c40e4b72c437338f6b to your computer and use it in GitHub Desktop.
Patch->syx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DISABLE_HW_SUPPORT 1 | |
#define DISABLE_VGM_LOGGING 1 | |
#include "driver/src/OPLSynth.h" | |
typedef bool BOOLEAN; | |
#include "driver/src/patch.h" | |
//#include "driver/src/mauipatch.h" | |
//#include "driver/src/fmsynthpatch.h" | |
//#include "driver/src/2x2patchtest.h" | |
//#include "driver/src/ctmidipatch.h" | |
std::vector<BYTE> BankToSyx(const patchStruct pats[], unsigned n) | |
{ | |
std::vector<BYTE> v; | |
v.reserve(8192); | |
for (unsigned insno = 0; insno < n; ++insno) { | |
v.push_back(0xf0); | |
v.push_back(0x7d); | |
v.push_back(0x00); // device id | |
v.push_back(0x02); // send | |
for (unsigned i = 0; i < 8; ++i) | |
v.push_back("MaliceX "[i]); | |
for (unsigned i = 0; i < 8; ++i) | |
v.push_back("OP3PATCH"[i]); | |
v.push_back(insno & 15); | |
v.push_back(insno >> 4); | |
unsigned patchlen = sizeof(patchStruct); | |
v.push_back(patchlen & 15); | |
v.push_back(patchlen >> 4); | |
const BYTE *src = (const BYTE *)&glpPatch[insno]; | |
for (unsigned i = 0; i < patchlen; ++i) { | |
v.push_back(src[i] & 15); | |
v.push_back(src[i] >> 4); | |
} | |
v.push_back(0x00); // placeholder for checksum, TODO | |
v.push_back(0xf7); | |
} | |
return v; | |
} | |
#include <unistd.h> | |
int main() | |
{ | |
std::vector<BYTE> v = BankToSyx(glpPatch, 256); | |
if (isatty(1)) | |
return 1; | |
write(1, v.data(), v.size()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment