NES: prepare for DPCM

This commit is contained in:
tildearrow 2022-05-02 02:12:14 -05:00
parent b92ce84b34
commit a7b8f81da7
3 changed files with 17 additions and 3 deletions

View file

@ -53,6 +53,10 @@ const char* regCheatSheetNES[]={
NULL NULL
}; };
unsigned char _readDMC(void* user, unsigned short addr) {
return ((DivPlatformNES*)user)->readDMC(addr);
}
const char** DivPlatformNES::getRegisterSheet() { const char** DivPlatformNES::getRegisterSheet() {
return regCheatSheetNES; return regCheatSheetNES;
} }
@ -633,6 +637,11 @@ void DivPlatformNES::setNSFPlay(bool use) {
useNP=use; useNP=use;
} }
unsigned char DivPlatformNES::readDMC(unsigned short addr) {
printf("read from DMC! %x\n",addr);
return 0;
}
int DivPlatformNES::init(DivEngine* p, int channels, int sugRate, unsigned int flags) { int DivPlatformNES::init(DivEngine* p, int channels, int sugRate, unsigned int flags) {
parent=p; parent=p;
apuType=flags; apuType=flags;
@ -643,12 +652,14 @@ int DivPlatformNES::init(DivEngine* p, int channels, int sugRate, unsigned int f
nes1_NP->SetOption(xgm::NES_APU::OPT_NONLINEAR_MIXER,1); nes1_NP->SetOption(xgm::NES_APU::OPT_NONLINEAR_MIXER,1);
nes2_NP=new xgm::NES_DMC; nes2_NP=new xgm::NES_DMC;
nes2_NP->SetOption(xgm::NES_DMC::OPT_NONLINEAR_MIXER,1); nes2_NP->SetOption(xgm::NES_DMC::OPT_NONLINEAR_MIXER,1);
nes2_NP->SetMemory([](unsigned short addr, unsigned int& data) { nes2_NP->SetMemory([this](unsigned short addr, unsigned int& data) {
data=0; data=readDMC(addr);
}); });
nes2_NP->SetAPU(nes1_NP); nes2_NP->SetAPU(nes1_NP);
} else { } else {
nes=new struct NESAPU; nes=new struct NESAPU;
nes->readDMC=_readDMC;
nes->readDMCUser=this;
} }
writeOscBuf=0; writeOscBuf=0;
for (int i=0; i<5; i++) { for (int i=0; i<5; i++) {

View file

@ -93,6 +93,7 @@ class DivPlatformNES: public DivDispatch {
void muteChannel(int ch, bool mute); void muteChannel(int ch, bool mute);
bool keyOffAffectsArp(int ch); bool keyOffAffectsArp(int ch);
float getPostAmp(); float getPostAmp();
unsigned char readDMC(unsigned short addr);
void setNSFPlay(bool use); void setNSFPlay(bool use);
void setFlags(unsigned int flags); void setFlags(unsigned int flags);
void notifyInsDeletion(void* ins); void notifyInsDeletion(void* ins);

View file

@ -207,7 +207,7 @@ enum apu_mode { APU_60HZ, APU_48HZ };
break;\ break;\
}\ }\
{\ {\
a->DMC.buffer = 0;\ a->DMC.buffer = a->readDMC(a->readDMCUser,a->DMC.address);\
}\ }\
/* incremento gli hwtick da compiere */\ /* incremento gli hwtick da compiere */\
if (hwtick) { hwtick[0] += tick; }\ if (hwtick) { hwtick[0] += tick; }\
@ -525,6 +525,8 @@ EXTERNC struct NESAPU {
_apuTriangle TR; _apuTriangle TR;
_apuNoise NS; _apuNoise NS;
_apuDMC DMC; _apuDMC DMC;
void* readDMCUser;
unsigned char (*readDMC)(void*,unsigned short);
unsigned char muted[5]; unsigned char muted[5];
}; };