From 9162e8e2418aad3c38868d2626f6431f565f6cd0 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 21 May 2022 02:16:38 -0500 Subject: [PATCH] Namco WSG: 8 channel WSG (CUS30) now works --- src/engine/platform/namcowsg.cpp | 22 ++++++++++++++++++++-- src/engine/platform/namcowsg.h | 6 ++---- src/engine/platform/sound/namco.cpp | 13 ++++++++----- src/gui/guiConst.cpp | 3 +++ src/gui/insEdit.cpp | 6 ++++-- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/engine/platform/namcowsg.cpp b/src/engine/platform/namcowsg.cpp index f9813209..006e2597 100644 --- a/src/engine/platform/namcowsg.cpp +++ b/src/engine/platform/namcowsg.cpp @@ -83,8 +83,14 @@ void DivPlatformNamcoWSG::acquire(short* bufL, short* bufR, size_t start, size_t } void DivPlatformNamcoWSG::updateWave(int ch) { - for (int i=0; i<32; i++) { - namco->update_namco_waveform(i+ch*32,chan[ch].ws.output[i]); + if (devType==30) { + for (int i=0; i<32; i++) { + ((namco_cus30_device*)namco)->namcos1_cus30_w(i+ch*32,chan[ch].ws.output[i]); + } + } else { + for (int i=0; i<32; i++) { + namco->update_namco_waveform(i+ch*32,chan[ch].ws.output[i]); + } } } @@ -212,6 +218,18 @@ void DivPlatformNamcoWSG::tick(bool sysTick) { } break; case 30: + for (int i=0; i<8; i++) { + if (chan[i].active && !isMuted[i]) { + rWrite((i<<3)+0x100,(chan[i].outVol*((chan[i].pan>>4)&15))/15); + rWrite((i<<3)+0x104,((chan[i].outVol*(chan[i].pan&15))/15)|(chan[(i+1)&7].noise?0x80:0)); + } else { + rWrite((i<<3)+0x100,0); + rWrite((i<<3)+0x104,(chan[(i+1)&7].noise?0x80:0)); + } + rWrite((i<<3)+0x103,chan[i].freq&0xff); + rWrite((i<<3)+0x102,(chan[i].freq>>8)&0xff); + rWrite((i<<3)+0x101,((chan[i].freq>>15)&15)|(i<<4)); + } break; } } diff --git a/src/engine/platform/namcowsg.h b/src/engine/platform/namcowsg.h index 0f5a1c36..28d3f365 100644 --- a/src/engine/platform/namcowsg.h +++ b/src/engine/platform/namcowsg.h @@ -62,16 +62,14 @@ class DivPlatformNamcoWSG: public DivDispatch { DivDispatchOscBuffer* oscBuf[8]; bool isMuted[8]; struct QueuedWrite { - unsigned char addr; + unsigned short addr; unsigned char val; - QueuedWrite(unsigned char a, unsigned char v): addr(a), val(v) {} + QueuedWrite(unsigned short a, unsigned char v): addr(a), val(v) {} }; std::queue writes; unsigned char lastPan; int cycles, curChan, delay; - int tempL[32]; - int tempR[32]; namco_audio_device* namco; int devType, chans; unsigned char regPool[512]; diff --git a/src/engine/platform/sound/namco.cpp b/src/engine/platform/sound/namco.cpp index 851c314b..82141301 100644 --- a/src/engine/platform/sound/namco.cpp +++ b/src/engine/platform/sound/namco.cpp @@ -87,6 +87,8 @@ void namco_audio_device::device_start(unsigned char* wavePtr) m_wave_ptr = wavePtr; + memset(m_waveram_alloc,0,1024); + /* build the waveform table */ build_decoded_waveform(m_wave_ptr); @@ -581,8 +583,9 @@ void namco_cus30_device::namcos1_cus30_w(int offset, uint8_t data) update_namco_waveform(offset, data); } } - else if (offset < 0x140) + else if (offset < 0x140) { namcos1_sound_w(offset - 0x100,data); + } else m_wavedata[offset] = data; } @@ -653,13 +656,13 @@ void namco_audio_device::sound_stream_update(short** outputs, int len) if (voice->noise_state) { - lmix[i]=l_noise_data; - rmix[i]=r_noise_data; + lmix[i]+=l_noise_data; + rmix[i]+=r_noise_data; } else { - lmix[i]=-l_noise_data; - rmix[i]=-r_noise_data; + lmix[i]+=-l_noise_data; + rmix[i]+=-r_noise_data; } if (hold) diff --git a/src/gui/guiConst.cpp b/src/gui/guiConst.cpp index c4106991..949d1c8c 100644 --- a/src/gui/guiConst.cpp +++ b/src/gui/guiConst.cpp @@ -881,6 +881,9 @@ const int availableSystems[]={ DIV_SYSTEM_SCC, DIV_SYSTEM_SCC_PLUS, DIV_SYSTEM_YMZ280B, + DIV_SYSTEM_NAMCO, + DIV_SYSTEM_NAMCO_15XX, + DIV_SYSTEM_NAMCO_CUS30, DIV_SYSTEM_MSM6258, DIV_SYSTEM_MSM6295, DIV_SYSTEM_RF5C68, diff --git a/src/gui/insEdit.cpp b/src/gui/insEdit.cpp index 17f581ce..3f954574 100644 --- a/src/gui/insEdit.cpp +++ b/src/gui/insEdit.cpp @@ -2757,7 +2757,8 @@ void FurnaceGUI::drawInsEdit() { ins->type==DIV_INS_FDS || ins->type==DIV_INS_SWAN || ins->type==DIV_INS_PCE || - ins->type==DIV_INS_SCC) { + ins->type==DIV_INS_SCC || + ins->type==DIV_INS_NAMCO) { if (ImGui::BeginTabItem("Wavetable")) { ImGui::Checkbox("Enable synthesizer",&ins->ws.enabled); ImGui::SameLine(); @@ -2926,7 +2927,8 @@ 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) { dutyMax=0; } - if (ins->type==DIV_INS_PCE) { + if (ins->type==DIV_INS_PCE || ins->type==DIV_INS_NAMCO) { + dutyLabel="Noise"; dutyMax=1; } if (ins->type==DIV_INS_SWAN) {