Renaming new POKEY core to AltASAP. Added core selection.

This commit is contained in:
Waldemar Pawlaszek 2022-12-22 22:40:29 +01:00
parent 3a94a7acde
commit 4a7e76c448
8 changed files with 71 additions and 23 deletions

View File

@ -425,7 +425,7 @@ src/engine/platform/sound/ymfm/ymfm_ssg.cpp
src/engine/platform/sound/lynx/Mikey.cpp src/engine/platform/sound/lynx/Mikey.cpp
src/engine/platform/sound/pokey/mzpokeysnd.c src/engine/platform/sound/pokey/mzpokeysnd.c
src/engine/platform/sound/pokey/Pokey.cpp src/engine/platform/sound/pokey/AltASAP.cpp
src/engine/platform/sound/qsound.c src/engine/platform/sound/qsound.c

View File

@ -341,6 +341,7 @@ void DivDispatchContainer::init(DivSystem sys, DivEngine* eng, int chanCount, do
break; break;
case DIV_SYSTEM_POKEY: case DIV_SYSTEM_POKEY:
dispatch=new DivPlatformPOKEY; dispatch=new DivPlatformPOKEY;
((DivPlatformPOKEY*)dispatch)->setAltASAP(eng->getConfInt("pokeyCore",0)==1);
break; break;
case DIV_SYSTEM_QSOUND: case DIV_SYSTEM_QSOUND:
dispatch=new DivPlatformQSound; dispatch=new DivPlatformQSound;

View File

@ -65,18 +65,22 @@ const char** DivPlatformPOKEY::getRegisterSheet() {
} }
void DivPlatformPOKEY::acquire(short* bufL, short* bufR, size_t start, size_t len) { void DivPlatformPOKEY::acquire(short* bufL, short* bufR, size_t start, size_t len) {
if (useAltASAP)
acquireASAP(bufL, start, len);
else
acquireMZ(bufL, start, len);
}
void DivPlatformPOKEY::acquireMZ(short* buf, size_t start, size_t len) {
for (size_t h=start; h<start+len; h++) { for (size_t h=start; h<start+len; h++) {
while (!writes.empty()) { while (!writes.empty()) {
QueuedWrite w=writes.front(); QueuedWrite w=writes.front();
mPokey2->write( w.addr, w.val );
Update_pokey_sound_mz(&pokey,w.addr,w.val,0); Update_pokey_sound_mz(&pokey,w.addr,w.val,0);
regPool[w.addr&0x0f]=w.val; regPool[w.addr&0x0f]=w.val;
writes.pop(); writes.pop();
} }
mzpokeysnd_process_16(&pokey,&bufL[h],1); mzpokeysnd_process_16(&pokey,&buf[h],1);
mPokey2->sampleAudio( &bufL[h], 1 );
bufL[h] *= 160;
if (++oscBufDelay>=14) { if (++oscBufDelay>=14) {
oscBufDelay=0; oscBufDelay=0;
@ -88,6 +92,23 @@ void DivPlatformPOKEY::acquire(short* bufL, short* bufR, size_t start, size_t le
} }
} }
void DivPlatformPOKEY::acquireASAP(short* buf, size_t start, size_t len) {
while (!writes.empty()) {
QueuedWrite w=writes.front();
altASAP->write(w.addr, w.val);
writes.pop();
}
for (size_t h=start; h<start+len; h++) {
if (++oscBufDelay>=14) {
oscBufDelay=0;
buf[h]=altASAP->sampleAudio(oscBuf);
} else {
buf[h]=altASAP->sampleAudio();
}
}
}
void DivPlatformPOKEY::tick(bool sysTick) { void DivPlatformPOKEY::tick(bool sysTick) {
for (int i=0; i<4; i++) { for (int i=0; i<4; i++) {
chan[i].std.next(); chan[i].std.next();
@ -373,8 +394,10 @@ DivDispatchOscBuffer* DivPlatformPOKEY::getOscBuffer(int ch) {
} }
unsigned char* DivPlatformPOKEY::getRegisterPool() { unsigned char* DivPlatformPOKEY::getRegisterPool() {
return const_cast<unsigned char*>( mPokey2->getRegisterPool() ); if (useAltASAP)
return regPool; return const_cast<unsigned char*>(altASAP->getRegisterPool());
else
return regPool;
} }
int DivPlatformPOKEY::getRegisterPoolSize() { int DivPlatformPOKEY::getRegisterPoolSize() {
@ -392,8 +415,10 @@ void DivPlatformPOKEY::reset() {
addWrite(0xffffffff,0); addWrite(0xffffffff,0);
} }
ResetPokeyState(&pokey); if (useAltASAP)
mPokey2->reset(); altASAP->reset();
else
ResetPokeyState(&pokey);
audctl=0; audctl=0;
audctlChanged=true; audctlChanged=true;
@ -425,7 +450,8 @@ void DivPlatformPOKEY::setFlags(const DivConfig& flags) {
oscBuf[i]->rate=rate/14; oscBuf[i]->rate=rate/14;
} }
mPokey2 = std::make_unique<Test::Pokey>( chipClock, chipClock ); if (useAltASAP)
altASAP=std::make_unique<AltASAP::Pokey>(chipClock, chipClock);
} }
@ -447,7 +473,8 @@ int DivPlatformPOKEY::init(DivEngine* p, int channels, int sugRate, const DivCon
oscBuf[i]=new DivDispatchOscBuffer; oscBuf[i]=new DivDispatchOscBuffer;
} }
MZPOKEYSND_Init(&pokey); if (!useAltASAP)
MZPOKEYSND_Init(&pokey);
setFlags(flags); setFlags(flags);
reset(); reset();
@ -460,5 +487,9 @@ void DivPlatformPOKEY::quit() {
} }
} }
void DivPlatformPOKEY::setAltASAP(bool value){
useAltASAP=value;
}
DivPlatformPOKEY::~DivPlatformPOKEY() { DivPlatformPOKEY::~DivPlatformPOKEY() {
} }

View File

@ -27,7 +27,7 @@ extern "C" {
#include "sound/pokey/mzpokeysnd.h" #include "sound/pokey/mzpokeysnd.h"
} }
#include "sound/pokey/Pokey.hpp" #include "sound/pokey/AltASAP.hpp"
class DivPlatformPOKEY: public DivDispatch { class DivPlatformPOKEY: public DivDispatch {
@ -52,12 +52,15 @@ class DivPlatformPOKEY: public DivDispatch {
bool audctlChanged; bool audctlChanged;
unsigned char oscBufDelay; unsigned char oscBufDelay;
PokeyState pokey; PokeyState pokey;
std::unique_ptr<Test::Pokey> mPokey2; std::unique_ptr<AltASAP::Pokey> altASAP;
bool useAltASAP;
unsigned char regPool[16]; unsigned char regPool[16];
friend void putDispatchChip(void*,int); friend void putDispatchChip(void*,int);
friend void putDispatchChan(void*,int,int); friend void putDispatchChan(void*,int,int);
public: public:
void acquire(short* bufL, short* bufR, size_t start, size_t len); void acquire(short* bufL, short* bufR, size_t start, size_t len);
void acquireMZ(short* buf, size_t start, size_t len);
void acquireASAP(short* buf, size_t start, size_t len);
int dispatch(DivCommand c); int dispatch(DivCommand c);
void* getChanState(int chan); void* getChanState(int chan);
DivMacroInt* getChanMacroInt(int ch); DivMacroInt* getChanMacroInt(int ch);
@ -77,6 +80,7 @@ class DivPlatformPOKEY: public DivDispatch {
const char** getRegisterSheet(); const char** getRegisterSheet();
int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags); int init(DivEngine* parent, int channels, int sugRate, const DivConfig& flags);
void quit(); void quit();
void setAltASAP(bool useAltASAP);
~DivPlatformPOKEY(); ~DivPlatformPOKEY();
}; };

View File

@ -20,14 +20,14 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#include "Pokey.hpp" #include "AltASAP.hpp"
#include <array> #include <array>
#include <vector> #include <vector>
#include <cassert> #include <cassert>
#include <algorithm> #include <algorithm>
#include <limits> #include <limits>
namespace Test namespace AltASAP
{ {
namespace namespace
@ -631,12 +631,9 @@ void Pokey::write( uint8_t address, uint8_t value )
mPokey->write( address, value ); mPokey->write( address, value );
} }
void Pokey::sampleAudio( int16_t* buf, size_t size, DivDispatchOscBuffer** oscb ) int16_t Pokey::sampleAudio( DivDispatchOscBuffer** oscb )
{ {
for ( size_t i = 0; i < size; ++i ) return mPokey->sampleAudio( oscb ) * 160; //just some magick value to match the audio level of mzpokeysnd
{
buf[i] = mPokey->sampleAudio( oscb );
}
} }
uint8_t const* Pokey::getRegisterPool() uint8_t const* Pokey::getRegisterPool()

View File

@ -6,7 +6,7 @@
// can you forgive me // can you forgive me
#include "../../../dispatch.h" #include "../../../dispatch.h"
namespace Test namespace AltASAP
{ {
class PokeyPimpl; class PokeyPimpl;
@ -19,7 +19,7 @@ public:
~Pokey(); ~Pokey();
void write( uint8_t address, uint8_t value ); void write( uint8_t address, uint8_t value );
void sampleAudio( int16_t* buf, size_t size, DivDispatchOscBuffer** oscb = NULL ); int16_t sampleAudio( DivDispatchOscBuffer** oscb = nullptr );
uint8_t const* getRegisterPool(); uint8_t const* getRegisterPool();

View File

@ -1177,6 +1177,7 @@ class FurnaceGUI {
int nesCore; int nesCore;
int fdsCore; int fdsCore;
int c64Core; int c64Core;
int pokeyCore;
int pcSpeakerOutMethod; int pcSpeakerOutMethod;
String yrw801Path; String yrw801Path;
String tg100Path; String tg100Path;
@ -1309,6 +1310,7 @@ class FurnaceGUI {
nesCore(0), nesCore(0),
fdsCore(0), fdsCore(0),
c64Core(1), c64Core(1),
pokeyCore(0),
pcSpeakerOutMethod(0), pcSpeakerOutMethod(0),
yrw801Path(""), yrw801Path(""),
tg100Path(""), tg100Path(""),

View File

@ -102,6 +102,11 @@ const char* c64Cores[]={
"reSIDfp" "reSIDfp"
}; };
const char* pokeyCores[]={
"mzpokeysnd",
"altASAP"
};
const char* pcspkrOutMethods[]={ const char* pcspkrOutMethods[]={
"evdev SND_TONE", "evdev SND_TONE",
"KIOCSOUND on /dev/tty1", "KIOCSOUND on /dev/tty1",
@ -1069,6 +1074,10 @@ void FurnaceGUI::drawSettings() {
ImGui::SameLine(); ImGui::SameLine();
ImGui::Combo("##C64Core",&settings.c64Core,c64Cores,2); ImGui::Combo("##C64Core",&settings.c64Core,c64Cores,2);
ImGui::Text("POKEY core");
ImGui::SameLine();
ImGui::Combo("##POKEYCore",&settings.pokeyCore,pokeyCores,2);
ImGui::Separator(); ImGui::Separator();
ImGui::Text("PC Speaker strategy"); ImGui::Text("PC Speaker strategy");
@ -2336,6 +2345,7 @@ void FurnaceGUI::syncSettings() {
settings.nesCore=e->getConfInt("nesCore",0); settings.nesCore=e->getConfInt("nesCore",0);
settings.fdsCore=e->getConfInt("fdsCore",0); settings.fdsCore=e->getConfInt("fdsCore",0);
settings.c64Core=e->getConfInt("c64Core",1); settings.c64Core=e->getConfInt("c64Core",1);
settings.pokeyCore=e->getConfInt("pokeyCore",0);
settings.pcSpeakerOutMethod=e->getConfInt("pcSpeakerOutMethod",0); settings.pcSpeakerOutMethod=e->getConfInt("pcSpeakerOutMethod",0);
settings.yrw801Path=e->getConfString("yrw801Path",""); settings.yrw801Path=e->getConfString("yrw801Path","");
settings.tg100Path=e->getConfString("tg100Path",""); settings.tg100Path=e->getConfString("tg100Path","");
@ -2461,6 +2471,7 @@ void FurnaceGUI::syncSettings() {
clampSetting(settings.nesCore,0,1); clampSetting(settings.nesCore,0,1);
clampSetting(settings.fdsCore,0,1); clampSetting(settings.fdsCore,0,1);
clampSetting(settings.c64Core,0,1); clampSetting(settings.c64Core,0,1);
clampSetting(settings.pokeyCore,0,1);
clampSetting(settings.pcSpeakerOutMethod,0,4); clampSetting(settings.pcSpeakerOutMethod,0,4);
clampSetting(settings.mainFont,0,6); clampSetting(settings.mainFont,0,6);
clampSetting(settings.patFont,0,6); clampSetting(settings.patFont,0,6);
@ -2604,7 +2615,8 @@ void FurnaceGUI::commitSettings() {
settings.snCore!=e->getConfInt("snCore",0) || settings.snCore!=e->getConfInt("snCore",0) ||
settings.nesCore!=e->getConfInt("nesCore",0) || settings.nesCore!=e->getConfInt("nesCore",0) ||
settings.fdsCore!=e->getConfInt("fdsCore",0) || settings.fdsCore!=e->getConfInt("fdsCore",0) ||
settings.c64Core!=e->getConfInt("c64Core",1) settings.c64Core!=e->getConfInt("c64Core",1) ||
settings.pokeyCore!=e->getConfInt("pokeyCore",0)
); );
e->setConf("mainFontSize",settings.mainFontSize); e->setConf("mainFontSize",settings.mainFontSize);
@ -2624,6 +2636,7 @@ void FurnaceGUI::commitSettings() {
e->setConf("nesCore",settings.nesCore); e->setConf("nesCore",settings.nesCore);
e->setConf("fdsCore",settings.fdsCore); e->setConf("fdsCore",settings.fdsCore);
e->setConf("c64Core",settings.c64Core); e->setConf("c64Core",settings.c64Core);
e->setConf("pokeyCore",settings.pokeyCore);
e->setConf("pcSpeakerOutMethod",settings.pcSpeakerOutMethod); e->setConf("pcSpeakerOutMethod",settings.pcSpeakerOutMethod);
e->setConf("yrw801Path",settings.yrw801Path); e->setConf("yrw801Path",settings.yrw801Path);
e->setConf("tg100Path",settings.tg100Path); e->setConf("tg100Path",settings.tg100Path);