Add emulation settings for YRW801, TG100 and MU5 sample ROMs.

This commit is contained in:
Laurens Holst 2022-05-11 23:39:36 +02:00
parent 05af3c147a
commit c29f18dfc2
5 changed files with 170 additions and 3 deletions

View file

@ -491,6 +491,77 @@ void DivEngine::notifyWaveChange(int wave) {
BUSY_END;
}
int DivEngine::loadSampleRom(String path, ssize_t expectedSize, unsigned char*& ret) {
ret = NULL;
if (path.empty()) {
return 0;
}
logI("loading ROM %s...",path);
FILE* f=ps_fopen(path.c_str(),"rb");
if (f==NULL) {
logE("error: %s",strerror(errno));
lastError=strerror(errno);
return -1;
}
if (fseek(f,0,SEEK_END)<0) {
logE("size error: %s",strerror(errno));
lastError=fmt::sprintf("on seek: %s",strerror(errno));
fclose(f);
return -1;
}
ssize_t len=ftell(f);
if (len==(SIZE_MAX>>1)) {
logE("could not get file length: %s",strerror(errno));
lastError=fmt::sprintf("on pre tell: %s",strerror(errno));
fclose(f);
return -1;
}
if (len<1) {
if (len==0) {
logE("that file is empty!");
lastError="file is empty";
} else {
logE("tell error: %s",strerror(errno));
lastError=fmt::sprintf("on tell: %s",strerror(errno));
}
fclose(f);
return -1;
}
if (len!=expectedSize) {
logE("ROM size mismatch, expected: %d bytes, was: %d bytes", expectedSize, len);
lastError=fmt::sprintf("ROM size mismatch, expected: %d bytes, was: %d", expectedSize, len);
return -1;
}
if (fseek(f,0,SEEK_SET)<0) {
logE("size error: %s",strerror(errno));
lastError=fmt::sprintf("on get size: %s",strerror(errno));
fclose(f);
return -1;
}
unsigned char* file=new unsigned char[len];
if (fread(file,1,(size_t)len,f)!=(size_t)len) {
logE("read error: %s",strerror(errno));
lastError=fmt::sprintf("on read: %s",strerror(errno));
fclose(f);
delete[] file;
return -1;
}
fclose(f);
ret = file;
return 0;
}
int DivEngine::loadSampleRoms() {
delete[] yrw801Rom;
delete[] tg100Rom;
delete[] mu5Rom;
int error = 0;
error += loadSampleRom(getConfString("yrw801Path",""), 0x200000, yrw801Rom);
error += loadSampleRom(getConfString("tg100Path",""), 0x200000, tg100Rom);
error += loadSampleRom(getConfString("mu5Path",""), 0x200000, mu5Rom);
return error;
}
void DivEngine::renderSamplesP() {
BUSY_BEGIN;
renderSamples();
@ -2662,6 +2733,8 @@ bool DivEngine::init() {
loadConf();
loadSampleRoms();
// set default system preset
if (!hasLoadedSomething) {
logD("setting default preset");
@ -2735,5 +2808,8 @@ bool DivEngine::quit() {
active=false;
delete[] oscBuf[0];
delete[] oscBuf[1];
delete[] yrw801Rom;
delete[] tg100Rom;
delete[] mu5Rom;
return true;
}

View file

@ -397,6 +397,8 @@ class DivEngine {
void loadOPM(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadFF(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
int loadSampleRom(String path, ssize_t expectedSize, unsigned char*& ret);
bool initAudioBackend();
bool deinitAudioBackend();
@ -783,6 +785,9 @@ class DivEngine {
// get register cheatsheet
const char** getRegisterSheet(int sys);
// load sample ROMs
int loadSampleRoms();
// UNSAFE render samples - only execute when locked
void renderSamples();
@ -853,6 +858,10 @@ class DivEngine {
// terminate the engine.
bool quit();
unsigned char* yrw801Rom;
unsigned char* tg100Rom;
unsigned char* mu5Rom;
DivEngine():
output(NULL),
exportThread(NULL),
@ -927,7 +936,10 @@ class DivEngine {
oscReadPos(0),
oscWritePos(0),
tickMult(1),
processTime(0) {
processTime(0),
yrw801Rom(NULL),
tg100Rom(NULL),
mu5Rom(NULL) {
memset(isMuted,0,DIV_MAX_CHANS*sizeof(bool));
memset(keyHit,0,DIV_MAX_CHANS*sizeof(bool));
memset(dispatchChanOfChan,0,DIV_MAX_CHANS*sizeof(int));