MSM6295: add clock rate flag

This commit is contained in:
tildearrow 2022-05-23 03:13:22 -05:00
parent 59a722d04a
commit d3edc58cb1
4 changed files with 48 additions and 7 deletions

View file

@ -44,7 +44,7 @@ void DivPlatformMSM6295::acquire(short* bufL, short* bufR, size_t start, size_t
QueuedWrite& w=writes.front(); QueuedWrite& w=writes.front();
msm->command_w(w.val); msm->command_w(w.val);
writes.pop(); writes.pop();
delay=64; delay=32;
} }
} else { } else {
delay--; delay--;
@ -53,6 +53,11 @@ void DivPlatformMSM6295::acquire(short* bufL, short* bufR, size_t start, size_t
msm->tick(); msm->tick();
bufL[h]=msm->out()<<4; bufL[h]=msm->out()<<4;
if (++updateOsc>=64) {
updateOsc=0;
// TODO: per-channel osc
}
} }
} }
@ -295,6 +300,19 @@ void DivPlatformMSM6295::renderSamples() {
} }
} }
void DivPlatformMSM6295::setFlags(unsigned int flags) {
if (flags&1) {
chipClock=8448000;
} else {
chipClock=8000000;
}
rate=chipClock/((flags&2)?6:24);
for (int i=0; i<4; i++) {
isMuted[i]=false;
oscBuf[i]->rate=rate/22;
}
}
int DivPlatformMSM6295::init(DivEngine* p, int channels, int sugRate, unsigned int flags) { int DivPlatformMSM6295::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
parent=p; parent=p;
adpcmMem=new unsigned char[getSampleMemCapacity(0)]; adpcmMem=new unsigned char[getSampleMemCapacity(0)];
@ -303,13 +321,13 @@ int DivPlatformMSM6295::init(DivEngine* p, int channels, int sugRate, unsigned i
iface.sampleBank=0; iface.sampleBank=0;
dumpWrites=false; dumpWrites=false;
skipRegisterWrites=false; skipRegisterWrites=false;
updateOsc=0;
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
isMuted[i]=false; isMuted[i]=false;
oscBuf[i]=new DivDispatchOscBuffer; oscBuf[i]=new DivDispatchOscBuffer;
} }
chipClock=8000000;
rate=chipClock/8;
msm=new msm6295_core(iface); msm=new msm6295_core(iface);
setFlags(flags);
reset(); reset();
return 4; return 4;
} }

View file

@ -98,7 +98,7 @@ class DivPlatformMSM6295: public DivDispatch {
DivMSM6295Interface iface; DivMSM6295Interface iface;
unsigned char sampleBank; unsigned char sampleBank;
int delay; int delay, updateOsc;
bool extMode; bool extMode;
@ -123,12 +123,14 @@ class DivPlatformMSM6295: public DivDispatch {
void notifyInsDeletion(void* ins); void notifyInsDeletion(void* ins);
void poke(unsigned int addr, unsigned short val); void poke(unsigned int addr, unsigned short val);
void poke(std::vector<DivRegWrite>& wlist); void poke(std::vector<DivRegWrite>& wlist);
void setFlags(unsigned int flags);
const char** getRegisterSheet(); const char** getRegisterSheet();
const char* getEffectName(unsigned char effect); const char* getEffectName(unsigned char effect);
const void* getSampleMem(int index); const void* getSampleMem(int index);
size_t getSampleMemCapacity(int index); size_t getSampleMemCapacity(int index);
size_t getSampleMemUsage(int index); size_t getSampleMemUsage(int index);
void renderSamples(); void renderSamples();
int init(DivEngine* parent, int channels, int sugRate, unsigned int flags); int init(DivEngine* parent, int channels, int sugRate, unsigned int flags);
void quit(); void quit();
~DivPlatformMSM6295(); ~DivPlatformMSM6295();

View file

@ -53,6 +53,11 @@
#include "msm6295.hpp" #include "msm6295.hpp"
#define CORE_DIVIDER 3
#define CHANNEL_DELAY (15/CORE_DIVIDER)
#define MASTER_DELAY (33/CORE_DIVIDER)
void msm6295_core::tick() void msm6295_core::tick()
{ {
// command handler // command handler
@ -60,7 +65,7 @@ void msm6295_core::tick()
{ {
if (bitfield(m_command, 7)) // play voice if (bitfield(m_command, 7)) // play voice
{ {
if ((++m_clock) >= ((15 * (m_ss ? 5 : 4)))) if ((++m_clock) >= ((CHANNEL_DELAY * (m_ss ? 5 : 4))))
{ {
m_clock = 0; m_clock = 0;
if (bitfield(m_next_command, 4, 4) != 0) if (bitfield(m_next_command, 4, 4) != 0)
@ -84,7 +89,7 @@ void msm6295_core::tick()
} }
else if (bitfield(m_next_command, 7)) // select phrase else if (bitfield(m_next_command, 7)) // select phrase
{ {
if ((++m_clock) >= ((15 * (m_ss ? 5 : 4)))) if ((++m_clock) >= ((CHANNEL_DELAY * (m_ss ? 5 : 4))))
{ {
m_clock = 0; m_clock = 0;
m_command = m_next_command; m_command = m_next_command;
@ -154,7 +159,7 @@ void msm6295_core::voice_t::tick()
else else
{ {
// playback // playback
if ((++m_clock) >= ((33 * (m_host.m_ss ? 5 : 4)))) if ((++m_clock) >= ((MASTER_DELAY * (m_host.m_ss ? 5 : 4))))
{ {
m_clock = 0; m_clock = 0;
bool is_end = (m_command != 0); bool is_end = (m_command != 0);

View file

@ -413,6 +413,22 @@ void FurnaceGUI::drawSysConf(int chan, DivSystem type, unsigned int& flags, bool
} }
break; break;
} }
case DIV_SYSTEM_MSM6295: {
ImGui::Text("Clock rate:");
if (ImGui::RadioButton("1MHz",flags==0)) {
copyOfFlags=0;
}
if (ImGui::RadioButton("1.056MHz",flags==1)) {
copyOfFlags=1;
}
if (ImGui::RadioButton("4MHz",flags==2)) {
copyOfFlags=2;
}
if (ImGui::RadioButton("4.224MHz",flags==3)) {
copyOfFlags=3;
}
break;
}
case DIV_SYSTEM_GB: case DIV_SYSTEM_GB:
case DIV_SYSTEM_SWAN: case DIV_SYSTEM_SWAN:
case DIV_SYSTEM_VERA: case DIV_SYSTEM_VERA: