add ability to change system
This commit is contained in:
parent
289dd3e565
commit
8c57eb9696
|
@ -176,6 +176,10 @@ bool DivEngine::isFMSystem(DivSystem sys) {
|
||||||
sys==DIV_SYSTEM_YMU759);
|
sys==DIV_SYSTEM_YMU759);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DivEngine::isSTDSystem(DivSystem sys) {
|
||||||
|
return (sys!=DIV_SYSTEM_ARCADE && sys!=DIV_SYSTEM_YMU759);
|
||||||
|
}
|
||||||
|
|
||||||
const char* chanNames[11][17]={
|
const char* chanNames[11][17]={
|
||||||
{"Channel 1", "Channel 2", "Channel 3", "Channel 4", "Channel 5", "Channel 6", "Channel 7", "Channel 8", "Channel 9", "Channel 10", "Channel 11", "Channel 12", "Channel 13", "Channel 14", "Channel 15", "Channel 16", "PCM"}, // YMU759
|
{"Channel 1", "Channel 2", "Channel 3", "Channel 4", "Channel 5", "Channel 6", "Channel 7", "Channel 8", "Channel 9", "Channel 10", "Channel 11", "Channel 12", "Channel 13", "Channel 14", "Channel 15", "Channel 16", "PCM"}, // YMU759
|
||||||
{"FM 1", "FM 2", "FM 3", "FM 4", "FM 5", "FM 6", "Square 1", "Square 2", "Square 3", "Noise"}, // Genesis
|
{"FM 1", "FM 2", "FM 3", "FM 4", "FM 5", "FM 6", "Square 1", "Square 2", "Square 3", "Noise"}, // Genesis
|
||||||
|
@ -1176,6 +1180,28 @@ void DivEngine::renderSamples() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DivEngine::changeSystem(DivSystem which) {
|
||||||
|
quitDispatch();
|
||||||
|
isBusy.lock();
|
||||||
|
song.system=which;
|
||||||
|
chans=getChannelCount(song.system);
|
||||||
|
// instrument safety check
|
||||||
|
for (DivInstrument* i: song.ins) {
|
||||||
|
if (!isFMSystem(song.system) && i->mode) {
|
||||||
|
i->mode=false;
|
||||||
|
}
|
||||||
|
if (!isSTDSystem(song.system) && !i->mode) {
|
||||||
|
i->mode=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isBusy.unlock();
|
||||||
|
initDispatch();
|
||||||
|
isBusy.lock();
|
||||||
|
renderSamples();
|
||||||
|
reset();
|
||||||
|
isBusy.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
DivInstrument* DivEngine::getIns(int index) {
|
DivInstrument* DivEngine::getIns(int index) {
|
||||||
if (index<0 || index>=song.insLen) return &song.nullIns;
|
if (index<0 || index>=song.insLen) return &song.nullIns;
|
||||||
return song.ins[index];
|
return song.ins[index];
|
||||||
|
@ -1244,6 +1270,7 @@ int DivEngine::addInstrument() {
|
||||||
DivInstrument* ins=new DivInstrument;
|
DivInstrument* ins=new DivInstrument;
|
||||||
int insCount=(int)song.ins.size();
|
int insCount=(int)song.ins.size();
|
||||||
ins->name=fmt::sprintf("Instrument %d",insCount);
|
ins->name=fmt::sprintf("Instrument %d",insCount);
|
||||||
|
ins->mode=isFMSystem(song.system);
|
||||||
song.ins.push_back(ins);
|
song.ins.push_back(ins);
|
||||||
song.insLen=insCount+1;
|
song.insLen=insCount+1;
|
||||||
isBusy.unlock();
|
isBusy.unlock();
|
||||||
|
|
|
@ -129,6 +129,9 @@ class DivEngine {
|
||||||
// is FM system
|
// is FM system
|
||||||
bool isFMSystem(DivSystem sys);
|
bool isFMSystem(DivSystem sys);
|
||||||
|
|
||||||
|
// is STD system
|
||||||
|
bool isSTDSystem(DivSystem sys);
|
||||||
|
|
||||||
// get channel name
|
// get channel name
|
||||||
const char* getChannelName(int chan);
|
const char* getChannelName(int chan);
|
||||||
|
|
||||||
|
@ -195,6 +198,9 @@ class DivEngine {
|
||||||
// public render samples
|
// public render samples
|
||||||
void renderSamplesP();
|
void renderSamplesP();
|
||||||
|
|
||||||
|
// change system
|
||||||
|
void changeSystem(DivSystem which);
|
||||||
|
|
||||||
// init dispatch
|
// init dispatch
|
||||||
void initDispatch();
|
void initDispatch();
|
||||||
|
|
||||||
|
|
|
@ -72,10 +72,10 @@ struct DivInstrumentSTD {
|
||||||
struct DivInstrumentGB {
|
struct DivInstrumentGB {
|
||||||
unsigned char envVol, envDir, envLen, soundLen;
|
unsigned char envVol, envDir, envLen, soundLen;
|
||||||
DivInstrumentGB():
|
DivInstrumentGB():
|
||||||
envVol(0),
|
envVol(15),
|
||||||
envDir(0),
|
envDir(0),
|
||||||
envLen(0),
|
envLen(2),
|
||||||
soundLen(0) {}
|
soundLen(64) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DivInstrumentC64 {
|
struct DivInstrumentC64 {
|
||||||
|
|
|
@ -315,7 +315,7 @@ void FurnaceGUI::drawInsEdit() {
|
||||||
} else {
|
} else {
|
||||||
DivInstrument* ins=e->song.ins[curIns];
|
DivInstrument* ins=e->song.ins[curIns];
|
||||||
ImGui::InputText("Name",&ins->name);
|
ImGui::InputText("Name",&ins->name);
|
||||||
if (e->isFMSystem(e->song.system)) ImGui::Checkbox("FM",&ins->mode);
|
if (e->isFMSystem(e->song.system) && e->isSTDSystem(e->song.system)) ImGui::Checkbox("FM",&ins->mode);
|
||||||
|
|
||||||
if (ins->mode) { // FM
|
if (ins->mode) { // FM
|
||||||
ImGui::SliderScalar("Algorithm",ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&_SEVEN);
|
ImGui::SliderScalar("Algorithm",ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&_SEVEN);
|
||||||
|
@ -1280,6 +1280,12 @@ int FurnaceGUI::load(String path) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define sysChangeOption(x) \
|
||||||
|
if (ImGui::MenuItem(e->getSystemName(x),NULL,e->song.system==x)) { \
|
||||||
|
e->changeSystem(x); \
|
||||||
|
updateWindowTitle(); \
|
||||||
|
}
|
||||||
|
|
||||||
bool FurnaceGUI::loop() {
|
bool FurnaceGUI::loop() {
|
||||||
while (!quit) {
|
while (!quit) {
|
||||||
SDL_Event ev;
|
SDL_Event ev;
|
||||||
|
@ -1356,7 +1362,20 @@ bool FurnaceGUI::loop() {
|
||||||
openFileDialog(GUI_FILE_SAVE);
|
openFileDialog(GUI_FILE_SAVE);
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
ImGui::MenuItem("change platform...");
|
if (ImGui::BeginMenu("change platform...")) {
|
||||||
|
sysChangeOption(DIV_SYSTEM_GENESIS);
|
||||||
|
sysChangeOption(DIV_SYSTEM_GENESIS_EXT);
|
||||||
|
sysChangeOption(DIV_SYSTEM_SMS);
|
||||||
|
sysChangeOption(DIV_SYSTEM_GB);
|
||||||
|
sysChangeOption(DIV_SYSTEM_PCE);
|
||||||
|
sysChangeOption(DIV_SYSTEM_NES);
|
||||||
|
sysChangeOption(DIV_SYSTEM_C64_8580);
|
||||||
|
sysChangeOption(DIV_SYSTEM_C64_6581);
|
||||||
|
sysChangeOption(DIV_SYSTEM_ARCADE);
|
||||||
|
sysChangeOption(DIV_SYSTEM_YM2610);
|
||||||
|
sysChangeOption(DIV_SYSTEM_YM2610_EXT);
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::MenuItem("exit")) {
|
if (ImGui::MenuItem("exit")) {
|
||||||
quit=true;
|
quit=true;
|
||||||
|
|
Loading…
Reference in a new issue