Merge branch 'master' into newFilePicker

This commit is contained in:
tildearrow 2025-09-30 05:57:11 -05:00
commit 919ff4a9d2
45 changed files with 152 additions and 41 deletions

View file

@ -612,6 +612,7 @@ class DivEngine {
void loadDMP(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadTFI(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadVGI(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadEIF(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadS3I(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadSBI(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);
void loadOPLI(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath);

View file

@ -27,6 +27,7 @@ enum DivInsFormats {
DIV_INSFORMAT_DMP,
DIV_INSFORMAT_TFI,
DIV_INSFORMAT_VGI,
DIV_INSFORMAT_EIF,
DIV_INSFORMAT_FTI,
DIV_INSFORMAT_BTI,
DIV_INSFORMAT_S3I,
@ -494,6 +495,48 @@ void DivEngine::loadVGI(SafeReader& reader, std::vector<DivInstrument*>& ret, St
ret.push_back(ins);
}
void DivEngine::loadEIF(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath) {
DivInstrument* ins=new DivInstrument;
try {
unsigned char bytes[29];
reader.seek(0,SEEK_SET);
ins->type=DIV_INS_FM;
ins->name=stripPath;
for (int i=0; i<29; i++) {
bytes[i] = reader.readC();
}
ins->fm.alg=bytes[0]&0x07;
ins->fm.fb=(bytes[0]>>3)&0x07;
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=ins->fm.op[i];
op.mult=bytes[1+i]&0x0F;
op.dt=(bytes[1+i]>>4)&0x07;
op.tl=bytes[5+i]&0x7F;
op.rs=(bytes[9+i]>>6)&0x03;
op.ar=bytes[9+i]&0x1F;
op.dr=bytes[13+i]&0x1F;
op.am=(bytes[13+i]&0x80)?1:0;
op.d2r=bytes[17+i]&0x1F;
op.rr=bytes[21+i]&0x0F;
op.sl=(bytes[21+i]>>4)&0x0F;
op.ssgEnv=bytes[25+i]&0x0F;
}
} catch (EndOfFileException& e) {
lastError="premature end of file";
logE("premature end of file");
delete ins;
return;
}
ret.push_back(ins);
}
void DivEngine::loadS3I(SafeReader& reader, std::vector<DivInstrument*>& ret, String& stripPath) {
DivInstrument* ins=new DivInstrument;
try {
@ -1971,6 +2014,8 @@ std::vector<DivInstrument*> DivEngine::instrumentFromFile(const char* path, bool
format=DIV_INSFORMAT_TFI;
} else if (extS==".vgi") {
format=DIV_INSFORMAT_VGI;
} else if (extS==".eif") {
format=DIV_INSFORMAT_EIF;
} else if (extS==".fti") {
format=DIV_INSFORMAT_FTI;
} else if (extS==".bti") {
@ -2015,6 +2060,9 @@ std::vector<DivInstrument*> DivEngine::instrumentFromFile(const char* path, bool
case DIV_INSFORMAT_VGI:
loadVGI(reader,ret,stripPath);
break;
case DIV_INSFORMAT_EIF:
loadEIF(reader,ret,stripPath);
break;
case DIV_INSFORMAT_FTI: // TODO
break;
case DIV_INSFORMAT_BTI: // TODO

View file

@ -933,10 +933,10 @@ void FurnaceGUI::doAction(int what) {
sample->loopEnd=waveLen;
sample->loop=true;
sample->loopMode=DIV_SAMPLE_LOOP_FORWARD;
sample->depth=DIV_SAMPLE_DEPTH_8BIT;
sample->depth=DIV_SAMPLE_DEPTH_16BIT;
if (sample->init(waveLen)) {
for (unsigned short i=0; i<waveLen; i++) {
sample->data8[i]=((wave->data[i]*256)/(wave->max+1))-128;
sample->data16[i]=((wave->data[i]*65535.0f)/(wave->max))-32768;
}
}
}

View file

@ -1903,11 +1903,12 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
if (!dirExists(workingDirIns)) workingDirIns=getHomeDir();
hasOpened=fileDialog->openLoad(
_("Load Instrument"),
{_("all compatible files"), "*.fui *.dmp *.tfi *.vgi *.s3i *.sbi *.opli *.opni *.y12 *.bnk *.ff *.gyb *.opm *.wopl *.wopn",
{_("all compatible files"), "*.fui *.dmp *.tfi *.vgi *.eif *.s3i *.sbi *.opli *.opni *.y12 *.bnk *.ff *.gyb *.opm *.wopl *.wopn",
_("Furnace instrument"), "*.fui",
_("DefleMask preset"), "*.dmp",
_("TFM Music Maker instrument"), "*.tfi",
_("VGM Music Maker instrument"), "*.vgi",
_("Echo instrument"), "*.eif",
_("Scream Tracker 3 instrument"), "*.s3i",
_("SoundBlaster instrument"), "*.sbi",
_("Wohlstand OPL instrument"), "*.opli",

View file

@ -293,7 +293,7 @@ void FurnaceGUI::drawSampleEdit() {
String alignHint=fmt::sprintf(_("NES: loop start must be a multiple of 512 (try with %d)"),tryWith);
SAMPLE_WARN(warnLoopStart,alignHint);
}
if ((sample->loopEnd-8)&127) {
if ((sample->loopEnd>0) && ((sample->loopEnd-8)&127)) {
int tryWith=(sample->loopEnd-8)&(~127);
if (tryWith>(int)sample->samples) tryWith-=128;
tryWith+=8; // +1 bc of how sample length is treated: https://www.nesdev.org/wiki/APU_DMC

View file

@ -1242,6 +1242,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
if (ImGui::Checkbox(_("Bankswitched (Seta 2)"),&isBanked)) {
altered=true;
mustRender=true;
}
if (altered) {
@ -1743,6 +1744,7 @@ bool FurnaceGUI::drawSysConf(int chan, int sysPos, DivSystem type, DivConfig& fl
if (ImGui::Checkbox(_("Bankswitched (NMK112)"),&isBanked)) {
altered=true;
mustRender=true;
}
if (altered) {