From dbd1f56a101fc52afbc999f5659db07995a0b7dd Mon Sep 17 00:00:00 2001 From: cam900 Date: Sun, 5 Mar 2023 14:01:44 +0900 Subject: [PATCH 01/11] Add NEC D65010G031 support chip flag and instrument color is placeholder --- CMakeLists.txt | 3 + src/engine/dispatchContainer.cpp | 4 + src/engine/instrument.cpp | 2 + src/engine/instrument.h | 1 + src/engine/platform/d65010g031.cpp | 270 +++++++++++++++++++++++++ src/engine/platform/d65010g031.h | 63 ++++++ src/engine/platform/sound/d65010g031.c | 86 ++++++++ src/engine/platform/sound/d65010g031.h | 71 +++++++ src/engine/song.h | 3 +- src/engine/sysDef.cpp | 9 + src/gui/dataList.cpp | 4 + src/gui/gui.h | 1 + src/gui/guiConst.cpp | 4 + src/gui/insEdit.cpp | 8 +- src/gui/presets.cpp | 5 + src/gui/settings.cpp | 1 + src/gui/sysConf.cpp | 1 + 17 files changed, 532 insertions(+), 4 deletions(-) create mode 100644 src/engine/platform/d65010g031.cpp create mode 100644 src/engine/platform/d65010g031.h create mode 100644 src/engine/platform/sound/d65010g031.c create mode 100644 src/engine/platform/sound/d65010g031.h diff --git a/CMakeLists.txt b/CMakeLists.txt index bd93c9191..9d22d8f31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -459,6 +459,8 @@ src/engine/platform/sound/ga20/iremga20.cpp src/engine/platform/sound/sm8521.c +src/engine/platform/sound/d65010g031.c + src/engine/platform/oplAInterface.cpp src/engine/platform/ym2608Interface.cpp src/engine/platform/ym2610Interface.cpp @@ -544,6 +546,7 @@ src/engine/platform/snes.cpp src/engine/platform/k007232.cpp src/engine/platform/ga20.cpp src/engine/platform/sm8521.cpp +src/engine/platform/d65010g031.cpp src/engine/platform/pcmdac.cpp src/engine/platform/dummy.cpp ) diff --git a/src/engine/dispatchContainer.cpp b/src/engine/dispatchContainer.cpp index fe4f76e25..32bf12681 100644 --- a/src/engine/dispatchContainer.cpp +++ b/src/engine/dispatchContainer.cpp @@ -76,6 +76,7 @@ #include "platform/k007232.h" #include "platform/ga20.h" #include "platform/sm8521.h" +#include "platform/d65010g031.h" #include "platform/pcmdac.h" #include "platform/dummy.h" #include "../ta-log.h" @@ -493,6 +494,9 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do case DIV_SYSTEM_SM8521: dispatch=new DivPlatformSM8521; break; + case DIV_SYSTEM_D65010G031: + dispatch=new DivPlatformD65010G031; + break; case DIV_SYSTEM_PCM_DAC: dispatch=new DivPlatformPCMDAC; break; diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 798369782..263ad5d3e 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -928,6 +928,8 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song) { checkForWL=true; if (ws.enabled) featureWS=true; break; + case DIV_INS_D65010G031: + break; case DIV_INS_MAX: break; diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 5b48ffb4e..9d50f0ec6 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -79,6 +79,7 @@ enum DivInstrumentType: unsigned short { DIV_INS_GA20=46, DIV_INS_POKEMINI=47, DIV_INS_SM8521=48, + DIV_INS_D65010G031=49, DIV_INS_MAX, DIV_INS_NULL }; diff --git a/src/engine/platform/d65010g031.cpp b/src/engine/platform/d65010g031.cpp new file mode 100644 index 000000000..8f13ab2ad --- /dev/null +++ b/src/engine/platform/d65010g031.cpp @@ -0,0 +1,270 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2023 tildearrow and contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "d65010g031.h" +#include "../engine.h" +#include + +#define rWrite(a,v) {regPool[(a)]=(v)&0xff; d65010g031_write(&d65010g031,a,v);} + +#define CHIP_DIVIDER 1024 + +const char* regCheatSheetD65010G031[]={ + "CH1_Pitch", "00", + "CH2_Pitch", "01", + "CH3_Pitch", "02", + NULL +}; + +const char** DivPlatformD65010G031::getRegisterSheet() { + return regCheatSheetD65010G031; +} + +void DivPlatformD65010G031::acquire(short** buf, size_t len) { + for (size_t h=0; hdata[oscBuf[i]->needle++]=(d65010g031.square[i].out<<12); + } + } +} + +void DivPlatformD65010G031::tick(bool sysTick) { + for (int i=0; i<3; i++) { + chan[i].std.next(); + if (NEW_ARP_STRAT) { + chan[i].handleArp(); + } else if (chan[i].std.arp.had) { + if (!chan[i].inPorta) { + chan[i].baseFreq=NOTE_PERIODIC(parent->calcArp(chan[i].note,chan[i].std.arp.val)); + } + chan[i].freqChanged=true; + } + if (chan[i].std.pitch.had) { + if (chan[i].std.pitch.mode) { + chan[i].pitch2+=chan[i].std.pitch.val; + CLAMP_VAR(chan[i].pitch2,-32768,32767); + } else { + chan[i].pitch2=chan[i].std.pitch.val; + } + chan[i].freqChanged=true; + } + if (chan[i].freqChanged || chan[i].keyOn || chan[i].keyOff) { + chan[i].freq=0x3f-parent->calcFreq(chan[i].baseFreq,chan[i].pitch,chan[i].fixedArp?chan[i].baseNoteOverride:chan[i].arpOff,chan[i].fixedArp,true,0,chan[i].pitch2,chipClock,CHIP_DIVIDER); + if (chan[i].freq<1) chan[i].freq=1; + if (chan[i].freq>62) chan[i].freq=62; + if (isMuted[i]) chan[i].keyOn=false; + if (chan[i].keyOn) { + rWrite(i,chan[i].freq); + chan[i].keyOn=false; + } else if (chan[i].freqChanged && chan[i].active && !isMuted[i]) { + rWrite(i,chan[i].freq); + } + if (chan[i].keyOff) { + rWrite(i,0); + chan[i].keyOff=false; + } + chan[i].freqChanged=false; + } + } +} + +int DivPlatformD65010G031::dispatch(DivCommand c) { + switch (c.cmd) { + case DIV_CMD_NOTE_ON: { + DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_VIC); + if (c.value!=DIV_NOTE_NULL) { + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value); + chan[c.chan].freqChanged=true; + chan[c.chan].note=c.value; + } + chan[c.chan].active=true; + chan[c.chan].keyOn=true; + chan[c.chan].macroInit(ins); + break; + } + case DIV_CMD_NOTE_OFF: + chan[c.chan].active=false; + chan[c.chan].keyOff=true; + chan[c.chan].macroInit(NULL); + break; + case DIV_CMD_NOTE_OFF_ENV: + case DIV_CMD_ENV_RELEASE: + chan[c.chan].std.release(); + break; + case DIV_CMD_INSTRUMENT: + if (chan[c.chan].ins!=c.value || c.value2==1) { + chan[c.chan].ins=c.value; + } + break; + case DIV_CMD_GET_VOLUME: + return chan[c.chan].vol; + break; + case DIV_CMD_PITCH: + chan[c.chan].pitch=c.value; + chan[c.chan].freqChanged=true; + break; + case DIV_CMD_NOTE_PORTA: { + int destFreq=NOTE_PERIODIC(c.value2); + bool return2=false; + if (destFreq>chan[c.chan].baseFreq) { + chan[c.chan].baseFreq+=c.value; + if (chan[c.chan].baseFreq>=destFreq) { + chan[c.chan].baseFreq=destFreq; + return2=true; + } + } else { + chan[c.chan].baseFreq-=c.value; + if (chan[c.chan].baseFreq<=destFreq) { + chan[c.chan].baseFreq=destFreq; + return2=true; + } + } + chan[c.chan].freqChanged=true; + if (return2) { + chan[c.chan].inPorta=false; + return 2; + } + break; + } + case DIV_CMD_LEGATO: + chan[c.chan].baseFreq=NOTE_PERIODIC(c.value+((HACKY_LEGATO_MESS)?(chan[c.chan].std.arp.val):(0))); + chan[c.chan].freqChanged=true; + chan[c.chan].note=c.value; + break; + case DIV_CMD_PRE_PORTA: + if (chan[c.chan].active && c.value2) { + if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_VIC)); + } + if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) chan[c.chan].baseFreq=NOTE_PERIODIC(chan[c.chan].note); + chan[c.chan].inPorta=c.value; + break; + case DIV_CMD_GET_VOLMAX: + return 15; + break; + case DIV_CMD_MACRO_OFF: + chan[c.chan].std.mask(c.value,true); + break; + case DIV_CMD_MACRO_ON: + chan[c.chan].std.mask(c.value,false); + break; + case DIV_ALWAYS_SET_VOLUME: + return 1; + break; + default: + break; + } + return 1; +} + +void DivPlatformD65010G031::muteChannel(int ch, bool mute) { + isMuted[ch]=mute; + if (mute) { + chan[ch].keyOff=true; + } else if (chan[ch].active) { + chan[ch].keyOn=true; + } +} + +void DivPlatformD65010G031::forceIns() { + for (int i=0; i<3; i++) { + chan[i].insChanged=true; + chan[i].freqChanged=true; + } +} + +void* DivPlatformD65010G031::getChanState(int ch) { + return &chan[ch]; +} + +DivMacroInt* DivPlatformD65010G031::getChanMacroInt(int ch) { + return &chan[ch].std; +} + +DivDispatchOscBuffer* DivPlatformD65010G031::getOscBuffer(int ch) { + return oscBuf[ch]; +} + +unsigned char* DivPlatformD65010G031::getRegisterPool() { + return regPool; +} + +int DivPlatformD65010G031::getRegisterPoolSize() { + return 3; +} + +void DivPlatformD65010G031::reset() { + memset(regPool,0,3); + for (int i=0; i<3; i++) { + chan[i]=Channel(); + chan[i].std.setEngine(parent); + } + d65010g031_reset(&d65010g031); +} + +int DivPlatformD65010G031::getOutputCount() { + return 1; +} + +void DivPlatformD65010G031::notifyInsDeletion(void* ins) { + for (int i=0; i<3; i++) { + chan[i].std.notifyInsDeletion((DivInstrument*)ins); + } +} + +void DivPlatformD65010G031::setFlags(const DivConfig& flags) { + chipClock=COLOR_NTSC*5.0; + CHECK_CUSTOM_CLOCK; + rate=chipClock/1024; + for (int i=0; i<3; i++) { + oscBuf[i]->rate=rate; + } +} + +void DivPlatformD65010G031::poke(unsigned int addr, unsigned short val) { + rWrite(addr,val); +} + +void DivPlatformD65010G031::poke(std::vector& wlist) { + for (DivRegWrite& i: wlist) rWrite(i.addr,i.val); +} + +int DivPlatformD65010G031::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { + parent=p; + dumpWrites=false; + skipRegisterWrites=false; + for (int i=0; i<3; i++) { + isMuted[i]=false; + oscBuf[i]=new DivDispatchOscBuffer; + } + setFlags(flags); + reset(); + return 4; +} + +void DivPlatformD65010G031::quit() { + for (int i=0; i<3; i++) { + delete oscBuf[i]; + } +} + +DivPlatformD65010G031::~DivPlatformD65010G031() { +} diff --git a/src/engine/platform/d65010g031.h b/src/engine/platform/d65010g031.h new file mode 100644 index 000000000..cc46ced7d --- /dev/null +++ b/src/engine/platform/d65010g031.h @@ -0,0 +1,63 @@ +/** + * Furnace Tracker - multi-system chiptune tracker + * Copyright (C) 2021-2023 tildearrow and contributors + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef _D65010G031_H +#define _D65010G031_H + +#include "../dispatch.h" +#include "sound/d65010g031.h" +#include + +class DivPlatformD65010G031: public DivDispatch { + struct Channel: public SharedChannel { + Channel(): + SharedChannel(15) {} + }; + Channel chan[3]; + DivDispatchOscBuffer* oscBuf[3]; + bool isMuted[3]; + + unsigned char regPool[3]; + d65010g031_t d65010g031; + friend void putDispatchChip(void*,int); + friend void putDispatchChan(void*,int,int); + public: + void acquire(short** buf, size_t len); + int dispatch(DivCommand c); + void* getChanState(int chan); + DivMacroInt* getChanMacroInt(int ch); + DivDispatchOscBuffer* getOscBuffer(int chan); + unsigned char* getRegisterPool(); + int getRegisterPoolSize(); + void reset(); + void forceIns(); + void tick(bool sysTick=true); + void muteChannel(int ch, bool mute); + void setFlags(const DivConfig& flags); + void notifyInsDeletion(void* ins); + int getOutputCount(); + void poke(unsigned int addr, unsigned short val); + void poke(std::vector& wlist); + const char** getRegisterSheet(); + int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); + void quit(); + ~DivPlatformD65010G031(); +}; + +#endif diff --git a/src/engine/platform/sound/d65010g031.c b/src/engine/platform/sound/d65010g031.c new file mode 100644 index 000000000..dbcd63784 --- /dev/null +++ b/src/engine/platform/sound/d65010g031.c @@ -0,0 +1,86 @@ +/* + +============================================================================ + +NEC D65010G031 sound emulator +by cam900 + +This file is licensed under zlib license. + +============================================================================ + +zlib License + +(C) 2023-present cam900 and contributors + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +============================================================================ + +TODO: +- needs hardware test + +*/ + +#include "d65010g031.h" +#include + +static int d65010g031_max(int a, int b) { return (a > b) ? a : b; } + +int d65010g031_square_tick(struct d65010g031_square_t *square, const int cycle) +{ + if (square->period > 0) + { + int period = d65010g031_max(1, (0x3f - square->period)); + square->counter += cycle; + while (square->counter >= period) + { + square->counter -= period; + square->out ^= 1; + } + return square->out; + } + return 0; +} + +int d65010g031_sound_tick(struct d65010g031_t *d65010g031, const int cycle) +{ + int out = 0; + for (int i = 0; i < 3; i++) + { + out += d65010g031_square_tick(&d65010g031->square[i], cycle); + } + return out; +} + +void d65010g031_reset(struct d65010g031_t *d65010g031) +{ + for (int i = 0; i < 3; i++) + { + d65010g031->square[i].period = 0; + d65010g031->square[i].counter = 0; + d65010g031->square[i].out = 0; + } +} + +void d65010g031_write(struct d65010g031_t *d65010g031, const unsigned char a, const unsigned char d) +{ + if (a < 3) + { + d65010g031->square[a].period = d & 0x3f; + } +} diff --git a/src/engine/platform/sound/d65010g031.h b/src/engine/platform/sound/d65010g031.h new file mode 100644 index 000000000..49dc13a15 --- /dev/null +++ b/src/engine/platform/sound/d65010g031.h @@ -0,0 +1,71 @@ +/* + +============================================================================ + +NEC D65010G031 sound emulator +by cam900 + +This file is licensed under zlib license. + +============================================================================ + +zlib License + +(C) 2023-present cam900 and contributors + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +============================================================================ + +TODO: +- needs hardware test + +*/ + +#ifndef _D65010G031_EMU_H +#define _D65010G031_EMU_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +struct d65010g031_square_t +{ + unsigned char period; // Period (0 = Off) + int counter; // clock counter + signed short out; // output +}; + +struct d65010g031_t +{ + struct d65010g031_square_t square[3]; +}; + +int d65010g031_square_tick(struct d65010g031_square_t *square, const int cycle); + +int d65010g031_sound_tick(struct d65010g031_t *d65010g031, const int cycle); + +void d65010g031_reset(struct d65010g031_t *d65010g031); + +void d65010g031_write(struct d65010g031_t *d65010g031, const unsigned char a, const unsigned char d); + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _D65010G031_EMU_H diff --git a/src/engine/song.h b/src/engine/song.h index 0cf1f0195..e9c4058c0 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -125,7 +125,8 @@ enum DivSystem { DIV_SYSTEM_YM2610B_CSM, DIV_SYSTEM_YM2203_CSM, DIV_SYSTEM_YM2608_CSM, - DIV_SYSTEM_SM8521 + DIV_SYSTEM_SM8521, + DIV_SYSTEM_D65010G031 }; struct DivGroovePattern { diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index fe7606e0d..60e379256 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1833,6 +1833,15 @@ void DivEngine::registerSystems() { namcoEffectHandlerMap ); + sysDefs[DIV_SYSTEM_D65010G031]=new DivSysDef( + "NEC D65010G031", NULL, 0xfe/*placeholder*/, 0, 3, false, true, 0, false, 0, + "Used at Casio PV1000, Nothing but 3 square wave channels.", + {"Channel 1", "Channel 2", "Channel 3"}, + {"CH1", "CH2", "CH3"}, + {DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_PULSE}, + {DIV_INS_D65010G031, DIV_INS_D65010G031, DIV_INS_D65010G031} + ); + sysDefs[DIV_SYSTEM_DUMMY]=new DivSysDef( "Dummy System", NULL, 0xfd, 0, 8, false, true, 0, false, 0, "this is a system designed for testing purposes.", diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 63facfc33..0d99de03c 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -432,6 +432,10 @@ void FurnaceGUI::drawInsList(bool asChild) { break; case DIV_INS_SM8521: ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_SM8521]); + name=fmt::sprintf(ICON_FA_GAMEPAD "##_INS%d",i);/*placeholder*/ + break; + case DIV_INS_D65010G031: + ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_D65010G031]); name=fmt::sprintf(ICON_FA_GAMEPAD "##_INS%d",i); break; default: diff --git a/src/gui/gui.h b/src/gui/gui.h index 8b0250e0a..85dee4e39 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -190,6 +190,7 @@ enum FurnaceGUIColors { GUI_COLOR_INSTR_GA20, GUI_COLOR_INSTR_POKEMINI, GUI_COLOR_INSTR_SM8521, + GUI_COLOR_INSTR_D65010G031, GUI_COLOR_INSTR_UNKNOWN, GUI_COLOR_CHANNEL_BG, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 398e2385b..58eac2a32 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -130,6 +130,7 @@ const char* insTypes[DIV_INS_MAX+1]={ "GA20", "Pokémon Mini", "SM8521", + "D65010G031", NULL }; @@ -820,6 +821,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_INSTR_GA20,"",ImVec4(0.1f,1.0f,0.4f,1.0f)), D(GUI_COLOR_INSTR_POKEMINI,"",ImVec4(1.0f,1.0f,0.3f,1.0f)), D(GUI_COLOR_INSTR_SM8521,"",ImVec4(0.5f,0.55f,0.6f,1.0f)), + D(GUI_COLOR_INSTR_D65010G031,"",ImVec4(0.5f,0.55f,0.6f,1.0f)),/*placeholder*/ D(GUI_COLOR_INSTR_UNKNOWN,"",ImVec4(0.3f,0.3f,0.3f,1.0f)), D(GUI_COLOR_CHANNEL_BG,"",ImVec4(0.4f,0.6f,0.8f,1.0f)), @@ -1001,6 +1003,7 @@ const int availableSystems[]={ DIV_SYSTEM_K007232, DIV_SYSTEM_GA20, DIV_SYSTEM_SM8521, + DIV_SYSTEM_D65010G031, DIV_SYSTEM_PCM_DAC, DIV_SYSTEM_PONG, 0 // don't remove this last one! @@ -1050,6 +1053,7 @@ const int chipsSquare[]={ DIV_SYSTEM_VIC20, DIV_SYSTEM_MSM5232, DIV_SYSTEM_T6W28, + DIV_SYSTEM_D65010G031, 0 // don't remove this last one! }; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 43b5e3755..0d85aef83 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -5048,7 +5048,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_ES5506) { volMax=4095; } - if (ins->type==DIV_INS_MSM6258) { + if (ins->type==DIV_INS_MSM6258 || ins->type==DIV_INS_D65010G031) { volMax=0; } if (ins->type==DIV_INS_MSM6295) { @@ -5118,7 +5118,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_SCC || ins->type==DIV_INS_PET || ins->type==DIV_INS_VIC || ins->type==DIV_INS_SEGAPCM || ins->type==DIV_INS_FM || ins->type==DIV_INS_K007232 || ins->type==DIV_INS_GA20 || - ins->type==DIV_INS_SM8521) { + ins->type==DIV_INS_SM8521 || ins->type==DIV_INS_D65010G031) { dutyMax=0; } if (ins->type==DIV_INS_VBOY) { @@ -5190,7 +5190,9 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_C64 || ins->type==DIV_INS_SAA1099) { waveBitMode=true; } - if (ins->type==DIV_INS_STD || ins->type==DIV_INS_VRC6_SAW || ins->type==DIV_INS_NES || ins->type==DIV_INS_T6W28) waveMax=0; + if (ins->type==DIV_INS_STD || ins->type==DIV_INS_VRC6_SAW || ins->type==DIV_INS_NES || + ins->type==DIV_INS_T6W28 || ins->type==DIV_INS_D65010G031) + waveMax=0; if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_VIC || ins->type==DIV_INS_OPLL) waveMax=15; if (ins->type==DIV_INS_C64) waveMax=4; if (ins->type==DIV_INS_SAA1099) waveMax=2; diff --git a/src/gui/presets.cpp b/src/gui/presets.cpp index 6bd11357b..861912a8a 100644 --- a/src/gui/presets.cpp +++ b/src/gui/presets.cpp @@ -2365,6 +2365,11 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_PONG, 1.0f, 0, "") } ); + ENTRY( + "NEC D65010G031", { + CH(DIV_SYSTEM_D65010G031, 1.0f, 0, "") + } + ); CATEGORY_END; CATEGORY_BEGIN("Sample","chips/systems which use PCM or ADPCM samples for sound synthesis."); diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index c98ef7cbb..0ee6cb09a 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1929,6 +1929,7 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_INSTR_GA20,"GA20"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_POKEMINI,"Pokémon Mini"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_SM8521,"SM8521"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_D65010G031,"D65010G031"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_UNKNOWN,"Other/Unknown"); ImGui::TreePop(); } diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 76143fb8c..3a4e70f77 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -1723,6 +1723,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo case DIV_SYSTEM_PET: case DIV_SYSTEM_VBOY: case DIV_SYSTEM_GA20: + case DIV_SYSTEM_D65010G031: ImGui::Text("nothing to configure"); break; case DIV_SYSTEM_VERA: From c7bff6b24e9fc0163f3c4f72133c6ed993deff7d Mon Sep 17 00:00:00 2001 From: cam900 Date: Sun, 5 Mar 2023 14:05:22 +0900 Subject: [PATCH 02/11] Add preset for game.com and casio pv-1000 --- src/gui/presets.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/presets.cpp b/src/gui/presets.cpp index 861912a8a..dd72ac3b4 100644 --- a/src/gui/presets.cpp +++ b/src/gui/presets.cpp @@ -256,6 +256,16 @@ void FurnaceGUI::initSystemPresets() { CH(DIV_SYSTEM_POKEMINI, 0.5f, 0, "") } ); + ENTRY( + "Tiger Game.com", { + CH(DIV_SYSTEM_SM8521, 1.0f, 0, "") + } + ); + ENTRY( + "Casio PV-1000", { + CH(DIV_SYSTEM_D65010G031, 1.0f, 0, "") + } + ); CATEGORY_END; CATEGORY_BEGIN("Computers","let's get to work on chiptune today."); From 59d9900a9e80b1267654b8360bd06a098d23dd0b Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 5 Mar 2023 13:38:19 -0500 Subject: [PATCH 03/11] apply new chip ID --- src/engine/sysDef.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 52dfe6bdb..84fbce7a1 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1834,7 +1834,7 @@ void DivEngine::registerSystems() { ); sysDefs[DIV_SYSTEM_D65010G031]=new DivSysDef( - "NEC D65010G031", NULL, 0xfe/*placeholder*/, 0, 3, false, true, 0, false, 0, + "NEC D65010G031", NULL, 0xcb, 0, 3, false, true, 0, false, 0, "Used at Casio PV1000, Nothing but 3 square wave channels.", {"Channel 1", "Channel 2", "Channel 3"}, {"CH1", "CH2", "CH3"}, From 77f1ca3339aa1e0522daea40350eba19a77248e0 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 5 Mar 2023 14:01:21 -0500 Subject: [PATCH 04/11] rename D65784221391491G18414119492 to PV1000 it probably was only used there anyway --- CMakeLists.txt | 2 +- src/engine/dispatchContainer.cpp | 6 +-- src/engine/instrument.cpp | 2 +- src/engine/instrument.h | 2 +- .../platform/{d65010g031.cpp => pv1000.cpp} | 46 +++++++++---------- .../platform/{d65010g031.h => pv1000.h} | 8 ++-- src/engine/song.h | 2 +- src/engine/sysDef.cpp | 12 ++--- src/gui/dataList.cpp | 4 +- src/gui/gui.h | 2 +- src/gui/guiConst.cpp | 8 ++-- src/gui/insEdit.cpp | 6 +-- src/gui/presets.cpp | 4 +- src/gui/settings.cpp | 2 +- src/gui/sysConf.cpp | 2 +- 15 files changed, 54 insertions(+), 54 deletions(-) rename src/engine/platform/{d65010g031.cpp => pv1000.cpp} (83%) rename src/engine/platform/{d65010g031.h => pv1000.h} (94%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d22d8f31..549f5d793 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -546,7 +546,7 @@ src/engine/platform/snes.cpp src/engine/platform/k007232.cpp src/engine/platform/ga20.cpp src/engine/platform/sm8521.cpp -src/engine/platform/d65010g031.cpp +src/engine/platform/pv1000.cpp src/engine/platform/pcmdac.cpp src/engine/platform/dummy.cpp ) diff --git a/src/engine/dispatchContainer.cpp b/src/engine/dispatchContainer.cpp index 32bf12681..de37948ff 100644 --- a/src/engine/dispatchContainer.cpp +++ b/src/engine/dispatchContainer.cpp @@ -76,7 +76,7 @@ #include "platform/k007232.h" #include "platform/ga20.h" #include "platform/sm8521.h" -#include "platform/d65010g031.h" +#include "platform/pv1000.h" #include "platform/pcmdac.h" #include "platform/dummy.h" #include "../ta-log.h" @@ -494,8 +494,8 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do case DIV_SYSTEM_SM8521: dispatch=new DivPlatformSM8521; break; - case DIV_SYSTEM_D65010G031: - dispatch=new DivPlatformD65010G031; + case DIV_SYSTEM_PV1000: + dispatch=new DivPlatformPV1000; break; case DIV_SYSTEM_PCM_DAC: dispatch=new DivPlatformPCMDAC; diff --git a/src/engine/instrument.cpp b/src/engine/instrument.cpp index 263ad5d3e..faa9f86c3 100644 --- a/src/engine/instrument.cpp +++ b/src/engine/instrument.cpp @@ -928,7 +928,7 @@ void DivInstrument::putInsData2(SafeWriter* w, bool fui, const DivSong* song) { checkForWL=true; if (ws.enabled) featureWS=true; break; - case DIV_INS_D65010G031: + case DIV_INS_PV1000: break; case DIV_INS_MAX: diff --git a/src/engine/instrument.h b/src/engine/instrument.h index 9d50f0ec6..c53688ec6 100644 --- a/src/engine/instrument.h +++ b/src/engine/instrument.h @@ -79,7 +79,7 @@ enum DivInstrumentType: unsigned short { DIV_INS_GA20=46, DIV_INS_POKEMINI=47, DIV_INS_SM8521=48, - DIV_INS_D65010G031=49, + DIV_INS_PV1000=49, DIV_INS_MAX, DIV_INS_NULL }; diff --git a/src/engine/platform/d65010g031.cpp b/src/engine/platform/pv1000.cpp similarity index 83% rename from src/engine/platform/d65010g031.cpp rename to src/engine/platform/pv1000.cpp index 8f13ab2ad..37217ccb7 100644 --- a/src/engine/platform/d65010g031.cpp +++ b/src/engine/platform/pv1000.cpp @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "d65010g031.h" +#include "pv1000.h" #include "../engine.h" #include @@ -25,18 +25,18 @@ #define CHIP_DIVIDER 1024 -const char* regCheatSheetD65010G031[]={ +const char* regCheatSheetPV1000[]={ "CH1_Pitch", "00", "CH2_Pitch", "01", "CH3_Pitch", "02", NULL }; -const char** DivPlatformD65010G031::getRegisterSheet() { - return regCheatSheetD65010G031; +const char** DivPlatformPV1000::getRegisterSheet() { + return regCheatSheetPV1000; } -void DivPlatformD65010G031::acquire(short** buf, size_t len) { +void DivPlatformPV1000::acquire(short** buf, size_t len) { for (size_t h=0; hgetIns(chan[c.chan].ins,DIV_INS_VIC); @@ -175,7 +175,7 @@ int DivPlatformD65010G031::dispatch(DivCommand c) { return 1; } -void DivPlatformD65010G031::muteChannel(int ch, bool mute) { +void DivPlatformPV1000::muteChannel(int ch, bool mute) { isMuted[ch]=mute; if (mute) { chan[ch].keyOff=true; @@ -184,34 +184,34 @@ void DivPlatformD65010G031::muteChannel(int ch, bool mute) { } } -void DivPlatformD65010G031::forceIns() { +void DivPlatformPV1000::forceIns() { for (int i=0; i<3; i++) { chan[i].insChanged=true; chan[i].freqChanged=true; } } -void* DivPlatformD65010G031::getChanState(int ch) { +void* DivPlatformPV1000::getChanState(int ch) { return &chan[ch]; } -DivMacroInt* DivPlatformD65010G031::getChanMacroInt(int ch) { +DivMacroInt* DivPlatformPV1000::getChanMacroInt(int ch) { return &chan[ch].std; } -DivDispatchOscBuffer* DivPlatformD65010G031::getOscBuffer(int ch) { +DivDispatchOscBuffer* DivPlatformPV1000::getOscBuffer(int ch) { return oscBuf[ch]; } -unsigned char* DivPlatformD65010G031::getRegisterPool() { +unsigned char* DivPlatformPV1000::getRegisterPool() { return regPool; } -int DivPlatformD65010G031::getRegisterPoolSize() { +int DivPlatformPV1000::getRegisterPoolSize() { return 3; } -void DivPlatformD65010G031::reset() { +void DivPlatformPV1000::reset() { memset(regPool,0,3); for (int i=0; i<3; i++) { chan[i]=Channel(); @@ -220,17 +220,17 @@ void DivPlatformD65010G031::reset() { d65010g031_reset(&d65010g031); } -int DivPlatformD65010G031::getOutputCount() { +int DivPlatformPV1000::getOutputCount() { return 1; } -void DivPlatformD65010G031::notifyInsDeletion(void* ins) { +void DivPlatformPV1000::notifyInsDeletion(void* ins) { for (int i=0; i<3; i++) { chan[i].std.notifyInsDeletion((DivInstrument*)ins); } } -void DivPlatformD65010G031::setFlags(const DivConfig& flags) { +void DivPlatformPV1000::setFlags(const DivConfig& flags) { chipClock=COLOR_NTSC*5.0; CHECK_CUSTOM_CLOCK; rate=chipClock/1024; @@ -239,15 +239,15 @@ void DivPlatformD65010G031::setFlags(const DivConfig& flags) { } } -void DivPlatformD65010G031::poke(unsigned int addr, unsigned short val) { +void DivPlatformPV1000::poke(unsigned int addr, unsigned short val) { rWrite(addr,val); } -void DivPlatformD65010G031::poke(std::vector& wlist) { +void DivPlatformPV1000::poke(std::vector& wlist) { for (DivRegWrite& i: wlist) rWrite(i.addr,i.val); } -int DivPlatformD65010G031::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { +int DivPlatformPV1000::init(DivEngine* p, int channels, int sugRate, const DivConfig& flags) { parent=p; dumpWrites=false; skipRegisterWrites=false; @@ -260,11 +260,11 @@ int DivPlatformD65010G031::init(DivEngine* p, int channels, int sugRate, const D return 4; } -void DivPlatformD65010G031::quit() { +void DivPlatformPV1000::quit() { for (int i=0; i<3; i++) { delete oscBuf[i]; } } -DivPlatformD65010G031::~DivPlatformD65010G031() { +DivPlatformPV1000::~DivPlatformPV1000() { } diff --git a/src/engine/platform/d65010g031.h b/src/engine/platform/pv1000.h similarity index 94% rename from src/engine/platform/d65010g031.h rename to src/engine/platform/pv1000.h index cc46ced7d..59484bcdc 100644 --- a/src/engine/platform/d65010g031.h +++ b/src/engine/platform/pv1000.h @@ -17,14 +17,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef _D65010G031_H -#define _D65010G031_H +#ifndef _PV1000_H +#define _PV1000_H #include "../dispatch.h" #include "sound/d65010g031.h" #include -class DivPlatformD65010G031: public DivDispatch { +class DivPlatformPV1000: public DivDispatch { struct Channel: public SharedChannel { Channel(): SharedChannel(15) {} @@ -57,7 +57,7 @@ class DivPlatformD65010G031: public DivDispatch { const char** getRegisterSheet(); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); void quit(); - ~DivPlatformD65010G031(); + ~DivPlatformPV1000(); }; #endif diff --git a/src/engine/song.h b/src/engine/song.h index e9c4058c0..cfed6b4cf 100644 --- a/src/engine/song.h +++ b/src/engine/song.h @@ -126,7 +126,7 @@ enum DivSystem { DIV_SYSTEM_YM2203_CSM, DIV_SYSTEM_YM2608_CSM, DIV_SYSTEM_SM8521, - DIV_SYSTEM_D65010G031 + DIV_SYSTEM_PV1000 }; struct DivGroovePattern { diff --git a/src/engine/sysDef.cpp b/src/engine/sysDef.cpp index 84fbce7a1..3bf5da5ea 100644 --- a/src/engine/sysDef.cpp +++ b/src/engine/sysDef.cpp @@ -1833,13 +1833,13 @@ void DivEngine::registerSystems() { waveOnlyEffectHandlerMap ); - sysDefs[DIV_SYSTEM_D65010G031]=new DivSysDef( - "NEC D65010G031", NULL, 0xcb, 0, 3, false, true, 0, false, 0, - "Used at Casio PV1000, Nothing but 3 square wave channels.", - {"Channel 1", "Channel 2", "Channel 3"}, - {"CH1", "CH2", "CH3"}, + sysDefs[DIV_SYSTEM_PV1000]=new DivSysDef( + "Casio PV-1000", NULL, 0xcb, 0, 3, false, true, 0, false, 0, + "a game console with 3 channels of square wave. it's what happens after fusing TIA and VIC together.", + {"Square 1", "Square 2", "Square 3"}, + {"S1", "S2", "S3"}, {DIV_CH_PULSE, DIV_CH_PULSE, DIV_CH_PULSE}, - {DIV_INS_D65010G031, DIV_INS_D65010G031, DIV_INS_D65010G031} + {DIV_INS_PV1000, DIV_INS_PV1000, DIV_INS_PV1000} ); sysDefs[DIV_SYSTEM_DUMMY]=new DivSysDef( diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 0d99de03c..3715583fa 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -434,8 +434,8 @@ void FurnaceGUI::drawInsList(bool asChild) { ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_SM8521]); name=fmt::sprintf(ICON_FA_GAMEPAD "##_INS%d",i);/*placeholder*/ break; - case DIV_INS_D65010G031: - ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_D65010G031]); + case DIV_INS_PV1000: + ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_PV1000]); name=fmt::sprintf(ICON_FA_GAMEPAD "##_INS%d",i); break; default: diff --git a/src/gui/gui.h b/src/gui/gui.h index 85dee4e39..167e8236d 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -190,7 +190,7 @@ enum FurnaceGUIColors { GUI_COLOR_INSTR_GA20, GUI_COLOR_INSTR_POKEMINI, GUI_COLOR_INSTR_SM8521, - GUI_COLOR_INSTR_D65010G031, + GUI_COLOR_INSTR_PV1000, GUI_COLOR_INSTR_UNKNOWN, GUI_COLOR_CHANNEL_BG, diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index 58eac2a32..790e85470 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -130,7 +130,7 @@ const char* insTypes[DIV_INS_MAX+1]={ "GA20", "Pokémon Mini", "SM8521", - "D65010G031", + "PV-1000", NULL }; @@ -821,7 +821,7 @@ const FurnaceGUIColorDef guiColors[GUI_COLOR_MAX]={ D(GUI_COLOR_INSTR_GA20,"",ImVec4(0.1f,1.0f,0.4f,1.0f)), D(GUI_COLOR_INSTR_POKEMINI,"",ImVec4(1.0f,1.0f,0.3f,1.0f)), D(GUI_COLOR_INSTR_SM8521,"",ImVec4(0.5f,0.55f,0.6f,1.0f)), - D(GUI_COLOR_INSTR_D65010G031,"",ImVec4(0.5f,0.55f,0.6f,1.0f)),/*placeholder*/ + D(GUI_COLOR_INSTR_PV1000,"",ImVec4(0.4f,0.6f,0.7f,1.0f)), D(GUI_COLOR_INSTR_UNKNOWN,"",ImVec4(0.3f,0.3f,0.3f,1.0f)), D(GUI_COLOR_CHANNEL_BG,"",ImVec4(0.4f,0.6f,0.8f,1.0f)), @@ -1003,7 +1003,7 @@ const int availableSystems[]={ DIV_SYSTEM_K007232, DIV_SYSTEM_GA20, DIV_SYSTEM_SM8521, - DIV_SYSTEM_D65010G031, + DIV_SYSTEM_PV1000, DIV_SYSTEM_PCM_DAC, DIV_SYSTEM_PONG, 0 // don't remove this last one! @@ -1053,7 +1053,7 @@ const int chipsSquare[]={ DIV_SYSTEM_VIC20, DIV_SYSTEM_MSM5232, DIV_SYSTEM_T6W28, - DIV_SYSTEM_D65010G031, + DIV_SYSTEM_PV1000, 0 // don't remove this last one! }; diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 0d85aef83..ceb866ce8 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -5048,7 +5048,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_ES5506) { volMax=4095; } - if (ins->type==DIV_INS_MSM6258 || ins->type==DIV_INS_D65010G031) { + if (ins->type==DIV_INS_MSM6258 || ins->type==DIV_INS_PV1000) { volMax=0; } if (ins->type==DIV_INS_MSM6295) { @@ -5118,7 +5118,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_AMIGA || ins->type==DIV_INS_SCC || ins->type==DIV_INS_PET || ins->type==DIV_INS_VIC || ins->type==DIV_INS_SEGAPCM || ins->type==DIV_INS_FM || ins->type==DIV_INS_K007232 || ins->type==DIV_INS_GA20 || - ins->type==DIV_INS_SM8521 || ins->type==DIV_INS_D65010G031) { + ins->type==DIV_INS_SM8521 || ins->type==DIV_INS_PV1000) { dutyMax=0; } if (ins->type==DIV_INS_VBOY) { @@ -5191,7 +5191,7 @@ void FurnaceGUI::drawInsEdit() { waveBitMode=true; } if (ins->type==DIV_INS_STD || ins->type==DIV_INS_VRC6_SAW || ins->type==DIV_INS_NES || - ins->type==DIV_INS_T6W28 || ins->type==DIV_INS_D65010G031) + ins->type==DIV_INS_T6W28 || ins->type==DIV_INS_PV1000) waveMax=0; if (ins->type==DIV_INS_TIA || ins->type==DIV_INS_VIC || ins->type==DIV_INS_OPLL) waveMax=15; if (ins->type==DIV_INS_C64) waveMax=4; diff --git a/src/gui/presets.cpp b/src/gui/presets.cpp index 9d48dbf1c..3354914c1 100644 --- a/src/gui/presets.cpp +++ b/src/gui/presets.cpp @@ -263,7 +263,7 @@ void FurnaceGUI::initSystemPresets() { ); ENTRY( "Casio PV-1000", { - CH(DIV_SYSTEM_D65010G031, 1.0f, 0, "") + CH(DIV_SYSTEM_PV1000, 1.0f, 0, "") } ); CATEGORY_END; @@ -2377,7 +2377,7 @@ void FurnaceGUI::initSystemPresets() { ); ENTRY( "NEC D65010G031", { - CH(DIV_SYSTEM_D65010G031, 1.0f, 0, "") + CH(DIV_SYSTEM_PV1000, 1.0f, 0, "") } ); CATEGORY_END; diff --git a/src/gui/settings.cpp b/src/gui/settings.cpp index 0ee6cb09a..fef592df8 100644 --- a/src/gui/settings.cpp +++ b/src/gui/settings.cpp @@ -1929,7 +1929,7 @@ void FurnaceGUI::drawSettings() { UI_COLOR_CONFIG(GUI_COLOR_INSTR_GA20,"GA20"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_POKEMINI,"Pokémon Mini"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_SM8521,"SM8521"); - UI_COLOR_CONFIG(GUI_COLOR_INSTR_D65010G031,"D65010G031"); + UI_COLOR_CONFIG(GUI_COLOR_INSTR_PV1000,"PV-1000"); UI_COLOR_CONFIG(GUI_COLOR_INSTR_UNKNOWN,"Other/Unknown"); ImGui::TreePop(); } diff --git a/src/gui/sysConf.cpp b/src/gui/sysConf.cpp index 3a4e70f77..ef35cfc40 100644 --- a/src/gui/sysConf.cpp +++ b/src/gui/sysConf.cpp @@ -1723,7 +1723,7 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo case DIV_SYSTEM_PET: case DIV_SYSTEM_VBOY: case DIV_SYSTEM_GA20: - case DIV_SYSTEM_D65010G031: + case DIV_SYSTEM_PV1000: ImGui::Text("nothing to configure"); break; case DIV_SYSTEM_VERA: From 30448dd09c1e755715618c550bc2271f94ffc843 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sun, 5 Mar 2023 16:48:19 -0500 Subject: [PATCH 05/11] GUI: PV-1000 ought to have a vol macro at least --- src/gui/insEdit.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index ceb866ce8..76ad80a20 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -5039,7 +5039,7 @@ void FurnaceGUI::drawInsEdit() { volMax=0; } } - if (ins->type==DIV_INS_PET || ins->type==DIV_INS_BEEPER) { + if (ins->type==DIV_INS_PET || ins->type==DIV_INS_BEEPER || ins->type==DIV_INS_PV1000) { volMax=1; } if (ins->type==DIV_INS_FDS) { @@ -5048,7 +5048,7 @@ void FurnaceGUI::drawInsEdit() { if (ins->type==DIV_INS_ES5506) { volMax=4095; } - if (ins->type==DIV_INS_MSM6258 || ins->type==DIV_INS_PV1000) { + if (ins->type==DIV_INS_MSM6258) { volMax=0; } if (ins->type==DIV_INS_MSM6295) { From 6d5328beb3d493b90e5064cf70093ded4b640e0d Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 Mar 2023 08:02:31 +0900 Subject: [PATCH 06/11] Add volume (2 levels) --- src/engine/platform/pv1000.cpp | 30 +++++++++++++++++++++++++++--- src/engine/platform/pv1000.h | 4 +++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/engine/platform/pv1000.cpp b/src/engine/platform/pv1000.cpp index 37217ccb7..fdb101d28 100644 --- a/src/engine/platform/pv1000.cpp +++ b/src/engine/platform/pv1000.cpp @@ -50,6 +50,11 @@ void DivPlatformPV1000::acquire(short** buf, size_t len) { void DivPlatformPV1000::tick(bool sysTick) { for (int i=0; i<3; i++) { chan[i].std.next(); + if (chan[i].std.vol.had) { + chan[i].outVol=VOL_SCALE_LINEAR(chan[i].std.vol.val,chan[i].vol,1); + if (chan[i].outVol<0) chan[i].outVol=0; + chan[i].writeVol=true; + } if (NEW_ARP_STRAT) { chan[i].handleArp(); } else if (chan[i].std.arp.had) { @@ -73,10 +78,10 @@ void DivPlatformPV1000::tick(bool sysTick) { if (chan[i].freq>62) chan[i].freq=62; if (isMuted[i]) chan[i].keyOn=false; if (chan[i].keyOn) { - rWrite(i,chan[i].freq); + rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq); chan[i].keyOn=false; } else if (chan[i].freqChanged && chan[i].active && !isMuted[i]) { - rWrite(i,chan[i].freq); + rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq); } if (chan[i].keyOff) { rWrite(i,0); @@ -85,6 +90,12 @@ void DivPlatformPV1000::tick(bool sysTick) { chan[i].freqChanged=false; } } + for (int i=0; i<3; i++) { + if (chan[i].writeVol) { + rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq); + chan[i].writeVol=false; + } + } } int DivPlatformPV1000::dispatch(DivCommand c) { @@ -97,6 +108,7 @@ int DivPlatformPV1000::dispatch(DivCommand c) { chan[c.chan].note=c.value; } chan[c.chan].active=true; + chan[c.chan].writeVol=true; chan[c.chan].keyOn=true; chan[c.chan].macroInit(ins); break; @@ -115,6 +127,17 @@ int DivPlatformPV1000::dispatch(DivCommand c) { chan[c.chan].ins=c.value; } break; + case DIV_CMD_VOLUME: + if (chan[c.chan].vol!=c.value) { + chan[c.chan].vol=c.value; + if (!chan[c.chan].std.vol.has) { + chan[c.chan].outVol=c.value; + } + if (chan[c.chan].active) { + chan[c.chan].writeVol=true; + } + } + break; case DIV_CMD_GET_VOLUME: return chan[c.chan].vol; break; @@ -158,7 +181,7 @@ int DivPlatformPV1000::dispatch(DivCommand c) { chan[c.chan].inPorta=c.value; break; case DIV_CMD_GET_VOLMAX: - return 15; + return 1; break; case DIV_CMD_MACRO_OFF: chan[c.chan].std.mask(c.value,true); @@ -181,6 +204,7 @@ void DivPlatformPV1000::muteChannel(int ch, bool mute) { chan[ch].keyOff=true; } else if (chan[ch].active) { chan[ch].keyOn=true; + chan[ch].writeVol=true; } } diff --git a/src/engine/platform/pv1000.h b/src/engine/platform/pv1000.h index 59484bcdc..8ad463f13 100644 --- a/src/engine/platform/pv1000.h +++ b/src/engine/platform/pv1000.h @@ -26,8 +26,10 @@ class DivPlatformPV1000: public DivDispatch { struct Channel: public SharedChannel { + bool writeVol; Channel(): - SharedChannel(15) {} + SharedChannel(1), + writeVol(false) {} }; Channel chan[3]; DivDispatchOscBuffer* oscBuf[3]; From dd2d267ce15afe4343370c35afea002ae4b600ee Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 Mar 2023 08:31:16 +0900 Subject: [PATCH 07/11] Fix default instrument --- src/engine/platform/pv1000.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/platform/pv1000.cpp b/src/engine/platform/pv1000.cpp index fdb101d28..d7b5cf4d2 100644 --- a/src/engine/platform/pv1000.cpp +++ b/src/engine/platform/pv1000.cpp @@ -101,7 +101,7 @@ void DivPlatformPV1000::tick(bool sysTick) { int DivPlatformPV1000::dispatch(DivCommand c) { switch (c.cmd) { case DIV_CMD_NOTE_ON: { - DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_VIC); + DivInstrument* ins=parent->getIns(chan[c.chan].ins,DIV_INS_PV1000); if (c.value!=DIV_NOTE_NULL) { chan[c.chan].baseFreq=NOTE_PERIODIC(c.value); chan[c.chan].freqChanged=true; @@ -175,7 +175,7 @@ int DivPlatformPV1000::dispatch(DivCommand c) { break; case DIV_CMD_PRE_PORTA: if (chan[c.chan].active && c.value2) { - if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_VIC)); + if (parent->song.resetMacroOnPorta) chan[c.chan].macroInit(parent->getIns(chan[c.chan].ins,DIV_INS_PV1000)); } if (!chan[c.chan].inPorta && c.value && !parent->song.brokenPortaArp && chan[c.chan].std.arp.will && !NEW_ARP_STRAT) chan[c.chan].baseFreq=NOTE_PERIODIC(chan[c.chan].note); chan[c.chan].inPorta=c.value; From c3e616379406726c3b4d0c8458d7b225e1cda3ae Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 Mar 2023 08:40:49 +0900 Subject: [PATCH 08/11] Add debug status support for PV1000 --- src/gui/debug.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index 04d84c117..24714819a 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -52,6 +52,7 @@ #include "../engine/platform/k007232.h" #include "../engine/platform/ga20.h" #include "../engine/platform/sm8521.h" +#include "../engine/platform/pv1000.h" #include "../engine/platform/dummy.h" #define COMMON_CHIP_DEBUG \ @@ -537,6 +538,13 @@ void putDispatchChip(void* data, int type) { ImGui::TextColored(ch->antiClickEnabled?colorOn:colorOff,">> AntiClickEnabled"); break; } + case DIV_SYSTEM_PV1000: { + DivPlatformPV1000* ch=(DivPlatformPV1000*)data; + ImGui::Text("> PV1000"); + COMMON_CHIP_DEBUG; + COMMON_CHIP_DEBUG_BOOL; + break; + } default: ImGui::Text("Unimplemented chip! Help!"); break; @@ -1068,6 +1076,14 @@ void putDispatchChan(void* data, int chanNum, int type) { ImGui::TextColored(ch->volumeChanged?colorOn:colorOff,">> VolumeChanged"); break; } + case DIV_SYSTEM_PV1000: { + DivPlatformPV1000::Channel* ch=(DivPlatformPV1000::Channel*)data; + ImGui::Text("> PV1000"); + COMMON_CHAN_DEBUG; + COMMON_CHAN_DEBUG_BOOL; + ImGui::TextColored(ch->writeVol?colorOn:colorOff,">> WriteVol"); + break; + } default: ImGui::Text("Unimplemented chip! Help!"); break; From 34131e52d532b5d8477f28d24fca6b6221629228 Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 Mar 2023 12:21:57 +0900 Subject: [PATCH 09/11] Remove unnecessary value --- src/engine/platform/pv1000.cpp | 13 +++---------- src/engine/platform/pv1000.h | 4 +--- src/gui/debug.cpp | 1 - 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/src/engine/platform/pv1000.cpp b/src/engine/platform/pv1000.cpp index d7b5cf4d2..e9e1b3c24 100644 --- a/src/engine/platform/pv1000.cpp +++ b/src/engine/platform/pv1000.cpp @@ -53,7 +53,7 @@ void DivPlatformPV1000::tick(bool sysTick) { if (chan[i].std.vol.had) { chan[i].outVol=VOL_SCALE_LINEAR(chan[i].std.vol.val,chan[i].vol,1); if (chan[i].outVol<0) chan[i].outVol=0; - chan[i].writeVol=true; + chan[i].freqChanged=true; } if (NEW_ARP_STRAT) { chan[i].handleArp(); @@ -90,12 +90,6 @@ void DivPlatformPV1000::tick(bool sysTick) { chan[i].freqChanged=false; } } - for (int i=0; i<3; i++) { - if (chan[i].writeVol) { - rWrite(i,(isMuted[i] || (chan[i].outVol<=0)) ? 0 : chan[i].freq); - chan[i].writeVol=false; - } - } } int DivPlatformPV1000::dispatch(DivCommand c) { @@ -108,7 +102,6 @@ int DivPlatformPV1000::dispatch(DivCommand c) { chan[c.chan].note=c.value; } chan[c.chan].active=true; - chan[c.chan].writeVol=true; chan[c.chan].keyOn=true; chan[c.chan].macroInit(ins); break; @@ -134,7 +127,7 @@ int DivPlatformPV1000::dispatch(DivCommand c) { chan[c.chan].outVol=c.value; } if (chan[c.chan].active) { - chan[c.chan].writeVol=true; + chan[c.chan].freqChanged=true; } } break; @@ -204,7 +197,7 @@ void DivPlatformPV1000::muteChannel(int ch, bool mute) { chan[ch].keyOff=true; } else if (chan[ch].active) { chan[ch].keyOn=true; - chan[ch].writeVol=true; + chan[ch].freqChanged=true; } } diff --git a/src/engine/platform/pv1000.h b/src/engine/platform/pv1000.h index 8ad463f13..953709abe 100644 --- a/src/engine/platform/pv1000.h +++ b/src/engine/platform/pv1000.h @@ -26,10 +26,8 @@ class DivPlatformPV1000: public DivDispatch { struct Channel: public SharedChannel { - bool writeVol; Channel(): - SharedChannel(1), - writeVol(false) {} + SharedChannel(1) {} }; Channel chan[3]; DivDispatchOscBuffer* oscBuf[3]; diff --git a/src/gui/debug.cpp b/src/gui/debug.cpp index 24714819a..49d568b3c 100644 --- a/src/gui/debug.cpp +++ b/src/gui/debug.cpp @@ -1081,7 +1081,6 @@ void putDispatchChan(void* data, int chanNum, int type) { ImGui::Text("> PV1000"); COMMON_CHAN_DEBUG; COMMON_CHAN_DEBUG_BOOL; - ImGui::TextColored(ch->writeVol?colorOn:colorOff,">> WriteVol"); break; } default: From 1e8ad16a680b54257c789f0b518f022f41e8ee88 Mon Sep 17 00:00:00 2001 From: cam900 Date: Mon, 6 Mar 2023 12:26:31 +0900 Subject: [PATCH 10/11] More simpler --- src/engine/platform/pv1000.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/engine/platform/pv1000.cpp b/src/engine/platform/pv1000.cpp index e9e1b3c24..823ca871b 100644 --- a/src/engine/platform/pv1000.cpp +++ b/src/engine/platform/pv1000.cpp @@ -51,8 +51,7 @@ void DivPlatformPV1000::tick(bool sysTick) { for (int i=0; i<3; i++) { chan[i].std.next(); if (chan[i].std.vol.had) { - chan[i].outVol=VOL_SCALE_LINEAR(chan[i].std.vol.val,chan[i].vol,1); - if (chan[i].outVol<0) chan[i].outVol=0; + chan[i].outVol=(chan[i].vol && chan[i].std.vol.val); chan[i].freqChanged=true; } if (NEW_ARP_STRAT) { From 969ebe9d273a7aedd928868ddc91640e87c3c34e Mon Sep 17 00:00:00 2001 From: tildearrow Date: Mon, 6 Mar 2023 03:16:23 -0500 Subject: [PATCH 11/11] not placeholder --- src/gui/dataList.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/dataList.cpp b/src/gui/dataList.cpp index 3715583fa..73197a815 100644 --- a/src/gui/dataList.cpp +++ b/src/gui/dataList.cpp @@ -432,7 +432,7 @@ void FurnaceGUI::drawInsList(bool asChild) { break; case DIV_INS_SM8521: ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_SM8521]); - name=fmt::sprintf(ICON_FA_GAMEPAD "##_INS%d",i);/*placeholder*/ + name=fmt::sprintf(ICON_FA_GAMEPAD "##_INS%d",i); break; case DIV_INS_PV1000: ImGui::PushStyleColor(ImGuiCol_Text,uiColors[GUI_COLOR_INSTR_PV1000]);