Namco WSG: add ROM mode

This commit is contained in:
tildearrow 2023-03-16 05:27:43 -05:00
parent 9a672196fd
commit 8fd26289a2
4 changed files with 56 additions and 9 deletions

View File

@ -183,6 +183,7 @@ void DivPlatformNamcoWSG::acquire(short** buf, size_t len) {
}
void DivPlatformNamcoWSG::updateWave(int ch) {
if (romMode) return;
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]);
@ -291,9 +292,9 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
rWrite(0x1d,(chan[2].freq>>12)&15);
rWrite(0x1e,(chan[2].freq>>16)&15);
rWrite(0x05,0);
rWrite(0x0a,1);
rWrite(0x0f,2);
rWrite(0x05,romMode?(chan[0].wave&7):0);
rWrite(0x0a,romMode?(chan[1].wave&7):1);
rWrite(0x0f,romMode?(chan[2].wave&7):2);
break;
case 15:
for (int i=0; i<8; i++) {
@ -304,7 +305,7 @@ void DivPlatformNamcoWSG::tick(bool sysTick) {
}
rWrite((i<<3)+0x04,chan[i].freq&0xff);
rWrite((i<<3)+0x05,(chan[i].freq>>8)&0xff);
rWrite((i<<3)+0x06,((chan[i].freq>>16)&15)|(i<<4));
rWrite((i<<3)+0x06,((chan[i].freq>>16)&15)|((romMode?(chan[i].wave&7):i)<<4));
}
break;
case 30:
@ -496,10 +497,11 @@ void DivPlatformNamcoWSG::reset() {
if (dumpWrites) {
addWrite(0xffffffff,0);
}
// TODO: wave memory
namco->set_voices(chans);
namco->set_stereo((devType==2 || devType==30));
namco->device_start(NULL);
updateROMWaves();
}
int DivPlatformNamcoWSG::getOutputCount() {
@ -510,6 +512,27 @@ bool DivPlatformNamcoWSG::keyOffAffectsArp(int ch) {
return true;
}
void DivPlatformNamcoWSG::updateROMWaves() {
if (romMode) {
// copy wavetables
for (int i=0; i<8; i++) {
int data=0;
DivWavetable* w=parent->getWave(i);
for (int j=0; j<32; j++) {
if (w->max<1 || w->len<1) {
data=0;
} else {
data=w->data[j*w->len/32]*15/w->max;
if (data<0) data=0;
if (data>15) data=15;
}
namco->update_namco_waveform(i*32+j,data);
}
}
}
}
void DivPlatformNamcoWSG::notifyWaveChange(int wave) {
for (int i=0; i<chans; i++) {
if (chan[i].wave==wave) {
@ -517,6 +540,7 @@ void DivPlatformNamcoWSG::notifyWaveChange(int wave) {
updateWave(i);
}
}
updateROMWaves();
}
void DivPlatformNamcoWSG::notifyInsDeletion(void* ins) {
@ -552,6 +576,8 @@ void DivPlatformNamcoWSG::setFlags(const DivConfig& flags) {
oscBuf[i]->rate=rate;
}
newNoise=flags.getBool("newNoise",true);
romMode=flags.getBool("romMode",true);
if (devType==30) romMode=false;
}
void DivPlatformNamcoWSG::poke(unsigned int addr, unsigned short val) {

View File

@ -50,8 +50,10 @@ class DivPlatformNamcoWSG: public DivDispatch {
namco_audio_device* namco;
int devType, chans;
bool newNoise;
bool romMode;
unsigned char regPool[512];
void updateWave(int ch);
void updateROMWaves();
friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int);
public:

View File

@ -20,6 +20,7 @@
#include "waveSynth.h"
#include "engine.h"
#include "instrument.h"
#include "../ta-log.h"
bool DivWaveSynth::activeChanged() {
if (activeChangedB) {
@ -211,6 +212,7 @@ void DivWaveSynth::setWidth(int val) {
void DivWaveSynth::changeWave1(int num) {
DivWavetable* w1=e->getWave(num);
logV("changeWave1 (%d)",width);
if (width<1) return;
for (int i=0; i<width; i++) {
if (w1->max<1 || w1->len<1) {

View File

@ -1735,6 +1735,27 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
}
break;
}
case DIV_SYSTEM_NAMCO:
case DIV_SYSTEM_NAMCO_15XX: {
bool romMode=flags.getBool("romMode",false);
ImGui::Text("Waveform storage mode:");
if (ImGui::RadioButton("RAM",!romMode)) {
romMode=false;
altered=true;
}
if (ImGui::RadioButton("ROM (up to 8 waves)",romMode)) {
romMode=true;
altered=true;
}
if (altered) {
e->lockSave([&]() {
flags.set("romMode",romMode);
});
}
break;
}
case DIV_SYSTEM_NAMCO_CUS30: {
bool newNoise=flags.getBool("newNoise",true);
@ -1769,10 +1790,6 @@ bool FurnaceGUI::drawSysConf(int chan, DivSystem type, DivConfig& flags, bool mo
case DIV_SYSTEM_VBOY:
case DIV_SYSTEM_GA20:
case DIV_SYSTEM_PV1000:
case DIV_SYSTEM_NAMCO:
case DIV_SYSTEM_NAMCO_15XX:
ImGui::Text("nothing to configure");
break;
case DIV_SYSTEM_VERA:
case DIV_SYSTEM_YMU759:
supportsCustomRate=false;