dev140 - YM2612: add YMF276 mode

This commit is contained in:
tildearrow 2023-02-10 17:55:44 -05:00
parent 6a01c83a9a
commit aa5b8795ed
10 changed files with 67 additions and 22 deletions

3
extern/opn/ym3438.c vendored
View File

@ -981,6 +981,9 @@ static void OPN2_ChOutput(ym3438_t *chip)
{ {
out = (Bit16s)chip->dacdata; out = (Bit16s)chip->dacdata;
out = SIGN_EXTEND(8, out); out = SIGN_EXTEND(8, out);
if (chip->chip_type & ym3438_mode_opn) {
out <<=5;
}
} }
else else
{ {

View File

@ -32,6 +32,7 @@ these fields are 0 in format versions prior to 100 (0.6pre1).
the format versions are: the format versions are:
- 140: Furnace dev140
- 139: Furnace dev139 - 139: Furnace dev139
- 138: Furnace dev138 - 138: Furnace dev138
- 137: Furnace dev137 - 137: Furnace dev137

View File

@ -175,7 +175,7 @@ String DivConfig::getString(String key, String fallback) const {
return fallback; return fallback;
} }
bool DivConfig::has(String key) { bool DivConfig::has(String key) const {
try { try {
String test=conf.at(key); String test=conf.at(key);
} catch (std::out_of_range& e) { } catch (std::out_of_range& e) {

View File

@ -46,7 +46,7 @@ class DivConfig {
String getString(String key, String fallback) const; String getString(String key, String fallback) const;
// check for existence // check for existence
bool has(String key); bool has(String key) const;
// set a config value // set a config value
void set(String key, bool value); void set(String key, bool value);

View File

@ -47,8 +47,8 @@
#define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock(); #define BUSY_BEGIN_SOFT softLocked=true; isBusy.lock();
#define BUSY_END isBusy.unlock(); softLocked=false; #define BUSY_END isBusy.unlock(); softLocked=false;
#define DIV_VERSION "dev139" #define DIV_VERSION "dev140"
#define DIV_ENGINE_VERSION 139 #define DIV_ENGINE_VERSION 140
// for imports // for imports
#define DIV_VERSION_MOD 0xff01 #define DIV_VERSION_MOD 0xff01
#define DIV_VERSION_FC 0xff02 #define DIV_VERSION_FC 0xff02

View File

@ -190,11 +190,11 @@ void DivPlatformGenesis::acquire_nuked(short** buf, size_t len) {
} }
} }
os[0]=(os[0]<<5); if (chipType!=2) os[0]=(os[0]<<5);
if (os[0]<-32768) os[0]=-32768; if (os[0]<-32768) os[0]=-32768;
if (os[0]>32767) os[0]=32767; if (os[0]>32767) os[0]=32767;
os[1]=(os[1]<<5); if (chipType!=2) os[1]=(os[1]<<5);
if (os[1]<-32768) os[1]=-32768; if (os[1]<-32768) os[1]=-32768;
if (os[1]>32767) os[1]=32767; if (os[1]>32767) os[1]=32767;
@ -223,7 +223,7 @@ void DivPlatformGenesis::acquire_ymfm(short** buf, size_t len) {
flushFirst=false; flushFirst=false;
} }
if (ladder) { if (chipType==1) {
fm_ymfm->generate(&out_ymfm); fm_ymfm->generate(&out_ymfm);
} else { } else {
((ymfm::ym3438*)fm_ymfm)->generate(&out_ymfm); ((ymfm::ym3438*)fm_ymfm)->generate(&out_ymfm);
@ -1225,7 +1225,17 @@ void DivPlatformGenesis::reset() {
fm_ymfm->reset(); fm_ymfm->reset();
} }
OPN2_Reset(&fm); OPN2_Reset(&fm);
OPN2_SetChipType(&fm,ladder?ym3438_mode_ym2612:0); switch (chipType) {
case 1: // YM2612
OPN2_SetChipType(&fm,ym3438_mode_ym2612);
break;
case 2: // YMF276
OPN2_SetChipType(&fm,ym3438_mode_opn);
break;
default: // YM3438
OPN2_SetChipType(&fm,0);
break;
}
if (dumpWrites) { if (dumpWrites) {
addWrite(0xffffffff,0); addWrite(0xffffffff,0);
} }
@ -1325,14 +1335,28 @@ void DivPlatformGenesis::setFlags(const DivConfig& flags) {
chipClock=COLOR_NTSC*15.0/7.0; chipClock=COLOR_NTSC*15.0/7.0;
break; break;
} }
ladder=flags.getBool("ladderEffect",false); if (flags.has("chipType")) {
chipType=flags.getInt("chipType",0);
} else {
chipType=flags.getBool("ladderEffect",false)?1:0;
}
noExtMacros=flags.getBool("noExtMacros",false); noExtMacros=flags.getBool("noExtMacros",false);
fbAllOps=flags.getBool("fbAllOps",false); fbAllOps=flags.getBool("fbAllOps",false);
OPN2_SetChipType(&fm,ladder?ym3438_mode_ym2612:0); switch (chipType) {
case 1: // YM2612
OPN2_SetChipType(&fm,ym3438_mode_ym2612);
break;
case 2: // YMF276
OPN2_SetChipType(&fm,ym3438_mode_opn);
break;
default: // YM3438
OPN2_SetChipType(&fm,0);
break;
}
CHECK_CUSTOM_CLOCK; CHECK_CUSTOM_CLOCK;
if (useYMFM) { if (useYMFM) {
if (fm_ymfm!=NULL) delete fm_ymfm; if (fm_ymfm!=NULL) delete fm_ymfm;
if (ladder) { if (chipType==1) {
fm_ymfm=new ymfm::ym2612(iface); fm_ymfm=new ymfm::ym2612(iface);
} else { } else {
fm_ymfm=new ymfm::ym3438(iface); fm_ymfm=new ymfm::ym3438(iface);
@ -1349,7 +1373,7 @@ void DivPlatformGenesis::setFlags(const DivConfig& flags) {
int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { int DivPlatformGenesis::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) {
parent=p; parent=p;
dumpWrites=false; dumpWrites=false;
ladder=false; chipType=0;
skipRegisterWrites=false; skipRegisterWrites=false;
flushFirst=false; flushFirst=false;
for (int i=0; i<10; i++) { for (int i=0; i<10; i++) {

View File

@ -85,7 +85,7 @@ class DivPlatformGenesis: public DivPlatformOPN {
int softPCMTimer; int softPCMTimer;
bool extMode, softPCM, noExtMacros, useYMFM; bool extMode, softPCM, noExtMacros, useYMFM;
bool ladder; unsigned char chipType;
unsigned char dacVolTable[128]; unsigned char dacVolTable[128];

View File

@ -94,7 +94,6 @@
ImGui::TextColored(ch->extMode?colorOn:colorOff,">> ExtMode"); \ ImGui::TextColored(ch->extMode?colorOn:colorOff,">> ExtMode"); \
ImGui::TextColored(ch->softPCM?colorOn:colorOff,">> SoftPCM"); \ ImGui::TextColored(ch->softPCM?colorOn:colorOff,">> SoftPCM"); \
ImGui::TextColored(ch->useYMFM?colorOn:colorOff,">> UseYMFM"); \ ImGui::TextColored(ch->useYMFM?colorOn:colorOff,">> UseYMFM"); \
ImGui::TextColored(ch->ladder?colorOn:colorOff,">> Ladder");
#define OPNB_CHIP_DEBUG \ #define OPNB_CHIP_DEBUG \
FM_OPN_CHIP_DEBUG; \ FM_OPN_CHIP_DEBUG; \

View File

@ -2152,27 +2152,27 @@ void FurnaceGUI::initSystemPresets() {
); );
ENTRY( ENTRY(
"Yamaha YM2612 (OPN2)", { "Yamaha YM2612 (OPN2)", {
CH(DIV_SYSTEM_YM2612, 1.0f, 0, "ladderEffect=true") CH(DIV_SYSTEM_YM2612, 1.0f, 0, "chipType=1")
} }
); );
ENTRY( ENTRY(
"Yamaha YM2612 (extended channel 3)", { "Yamaha YM2612 (extended channel 3)", {
CH(DIV_SYSTEM_YM2612_EXT, 1.0f, 0, "ladderEffect=true") CH(DIV_SYSTEM_YM2612_EXT, 1.0f, 0, "chipType=1")
} }
); );
ENTRY( ENTRY(
"Yamaha YM2612 (OPN2) CSM", { "Yamaha YM2612 (OPN2) CSM", {
CH(DIV_SYSTEM_YM2612_CSM, 1.0f, 0, "ladderEffect=true") CH(DIV_SYSTEM_YM2612_CSM, 1.0f, 0, "chipType=1")
} }
); );
ENTRY( ENTRY(
"Yamaha YM2612 (OPN2) with DualPCM", { "Yamaha YM2612 (OPN2) with DualPCM", {
CH(DIV_SYSTEM_YM2612_DUALPCM, 1.0f, 0, "ladderEffect=true") CH(DIV_SYSTEM_YM2612_DUALPCM, 1.0f, 0, "chipType=1")
} }
); );
ENTRY( ENTRY(
"Yamaha YM2612 (extended channel 3) with DualPCM", { "Yamaha YM2612 (extended channel 3) with DualPCM", {
CH(DIV_SYSTEM_YM2612_DUALPCM_EXT, 1.0f, 0, "ladderEffect=true") CH(DIV_SYSTEM_YM2612_DUALPCM_EXT, 1.0f, 0, "chipType=1")
} }
); );
ENTRY( ENTRY(

View File

@ -34,10 +34,16 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
case DIV_SYSTEM_YM2612_DUALPCM_EXT: case DIV_SYSTEM_YM2612_DUALPCM_EXT:
case DIV_SYSTEM_YM2612_CSM: { case DIV_SYSTEM_YM2612_CSM: {
int clockSel=flags.getInt("clockSel",0); int clockSel=flags.getInt("clockSel",0);
bool ladder=flags.getBool("ladderEffect",0); int chipType=0;
if (flags.has("chipType")) {
chipType=flags.getInt("chipType",0);
} else {
chipType=flags.getBool("ladderEffect",0)?1:0;
}
bool noExtMacros=flags.getBool("noExtMacros",false); bool noExtMacros=flags.getBool("noExtMacros",false);
bool fbAllOps=flags.getBool("fbAllOps",false); bool fbAllOps=flags.getBool("fbAllOps",false);
ImGui::Text("Clock rate:");
if (ImGui::RadioButton("NTSC (7.67MHz)",clockSel==0)) { if (ImGui::RadioButton("NTSC (7.67MHz)",clockSel==0)) {
clockSel=0; clockSel=0;
altered=true; altered=true;
@ -58,9 +64,21 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
clockSel=4; clockSel=4;
altered=true; altered=true;
} }
if (ImGui::Checkbox("Enable DAC distortion",&ladder)) {
ImGui::Text("Chip type:");
if (ImGui::RadioButton("YM3438 (9-bit DAC)",chipType==0)) {
chipType=0;
altered=true; altered=true;
} }
if (ImGui::RadioButton("YM2612 (9-bit DAC with distortion)",chipType==1)) {
chipType=1;
altered=true;
}
if (ImGui::RadioButton("YMF276 (external DAC)",chipType==2)) {
chipType=2;
altered=true;
}
if (type==DIV_SYSTEM_YM2612_EXT || type==DIV_SYSTEM_YM2612_DUALPCM_EXT || type==DIV_SYSTEM_YM2612_CSM) { if (type==DIV_SYSTEM_YM2612_EXT || type==DIV_SYSTEM_YM2612_DUALPCM_EXT || type==DIV_SYSTEM_YM2612_CSM) {
if (ImGui::Checkbox("Disable ExtCh FM macros (compatibility)",&noExtMacros)) { if (ImGui::Checkbox("Disable ExtCh FM macros (compatibility)",&noExtMacros)) {
altered=true; altered=true;
@ -73,7 +91,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
if (altered) { if (altered) {
e->lockSave([&]() { e->lockSave([&]() {
flags.set("clockSel",clockSel); flags.set("clockSel",clockSel);
flags.set("ladderEffect",ladder); flags.set("chipType",chipType);
flags.set("noExtMacros",noExtMacros); flags.set("noExtMacros",noExtMacros);
flags.set("fbAllOps",fbAllOps); flags.set("fbAllOps",fbAllOps);
}); });