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);
|
||||
}
|
||||
|
||||
bool DivEngine::isSTDSystem(DivSystem sys) {
|
||||
return (sys!=DIV_SYSTEM_ARCADE && sys!=DIV_SYSTEM_YMU759);
|
||||
}
|
||||
|
||||
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
|
||||
{"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) {
|
||||
if (index<0 || index>=song.insLen) return &song.nullIns;
|
||||
return song.ins[index];
|
||||
|
@ -1244,6 +1270,7 @@ int DivEngine::addInstrument() {
|
|||
DivInstrument* ins=new DivInstrument;
|
||||
int insCount=(int)song.ins.size();
|
||||
ins->name=fmt::sprintf("Instrument %d",insCount);
|
||||
ins->mode=isFMSystem(song.system);
|
||||
song.ins.push_back(ins);
|
||||
song.insLen=insCount+1;
|
||||
isBusy.unlock();
|
||||
|
|
|
@ -129,6 +129,9 @@ class DivEngine {
|
|||
// is FM system
|
||||
bool isFMSystem(DivSystem sys);
|
||||
|
||||
// is STD system
|
||||
bool isSTDSystem(DivSystem sys);
|
||||
|
||||
// get channel name
|
||||
const char* getChannelName(int chan);
|
||||
|
||||
|
@ -195,6 +198,9 @@ class DivEngine {
|
|||
// public render samples
|
||||
void renderSamplesP();
|
||||
|
||||
// change system
|
||||
void changeSystem(DivSystem which);
|
||||
|
||||
// init dispatch
|
||||
void initDispatch();
|
||||
|
||||
|
|
|
@ -72,10 +72,10 @@ struct DivInstrumentSTD {
|
|||
struct DivInstrumentGB {
|
||||
unsigned char envVol, envDir, envLen, soundLen;
|
||||
DivInstrumentGB():
|
||||
envVol(0),
|
||||
envVol(15),
|
||||
envDir(0),
|
||||
envLen(0),
|
||||
soundLen(0) {}
|
||||
envLen(2),
|
||||
soundLen(64) {}
|
||||
};
|
||||
|
||||
struct DivInstrumentC64 {
|
||||
|
|
|
@ -315,7 +315,7 @@ void FurnaceGUI::drawInsEdit() {
|
|||
} else {
|
||||
DivInstrument* ins=e->song.ins[curIns];
|
||||
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
|
||||
ImGui::SliderScalar("Algorithm",ImGuiDataType_U8,&ins->fm.alg,&_ZERO,&_SEVEN);
|
||||
|
@ -1280,6 +1280,12 @@ int FurnaceGUI::load(String path) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
#define sysChangeOption(x) \
|
||||
if (ImGui::MenuItem(e->getSystemName(x),NULL,e->song.system==x)) { \
|
||||
e->changeSystem(x); \
|
||||
updateWindowTitle(); \
|
||||
}
|
||||
|
||||
bool FurnaceGUI::loop() {
|
||||
while (!quit) {
|
||||
SDL_Event ev;
|
||||
|
@ -1356,7 +1362,20 @@ bool FurnaceGUI::loop() {
|
|||
openFileDialog(GUI_FILE_SAVE);
|
||||
}
|
||||
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();
|
||||
if (ImGui::MenuItem("exit")) {
|
||||
quit=true;
|
||||
|
|
Loading…
Reference in New Issue