NES: better channel muting

This commit is contained in:
tildearrow 2022-02-20 21:54:03 -05:00
parent 1030bc13b2
commit 5ffda66f22
2 changed files with 10 additions and 11 deletions

View File

@ -428,10 +428,7 @@ int DivPlatformNES::dispatch(DivCommand c) {
void DivPlatformNES::muteChannel(int ch, bool mute) {
isMuted[ch]=mute;
rWrite(0x4015,(!isMuted[0])|((!isMuted[1])<<1)|((!isMuted[2])<<2)|((!isMuted[3])<<3)|((!isMuted[4])<<4));
if (isMuted[4]) {
rWrite(0x4011,0);
}
nes->muted[ch]=mute;
}
void DivPlatformNES::forceIns() {
@ -465,7 +462,7 @@ void DivPlatformNES::reset() {
nes->apu.cpu_cycles=0;
nes->apu.cpu_opcode_cycle=0;
rWrite(0x4015,(!isMuted[0])|((!isMuted[1])<<1)|((!isMuted[2])<<2)|((!isMuted[3])<<3)|((!isMuted[4])<<4));
rWrite(0x4015,0x1f);
rWrite(0x4001,chan[0].sweep);
rWrite(0x4005,chan[1].sweep);
}
@ -510,10 +507,11 @@ int DivPlatformNES::init(DivEngine* p, int channels, int sugRate, unsigned int f
apuType=flags;
dumpWrites=false;
skipRegisterWrites=false;
nes=new struct NESAPU;
for (int i=0; i<5; i++) {
isMuted[i]=false;
nes->muted[i]=false;
}
nes=new struct NESAPU;
setFlags(flags);
init_nla_table(500,500);

View File

@ -338,15 +338,15 @@ enum apu_mode { APU_60HZ, APU_48HZ };
#define _apu_channel_volume_adjust(ch, index)\
((ch))
#define s1_out(a)\
_apu_channel_volume_adjust(a->S1.output, APU_S1)
(a->muted[0] ? 0 : _apu_channel_volume_adjust(a->S1.output, APU_S1))
#define s2_out(a)\
_apu_channel_volume_adjust(a->S2.output, APU_S2)
(a->muted[1] ? 0 : _apu_channel_volume_adjust(a->S2.output, APU_S2))
#define tr_out(a)\
_apu_channel_volume_adjust(a->TR.output, APU_TR)
(a->muted[2] ? 0 : _apu_channel_volume_adjust(a->TR.output, APU_TR))
#define ns_out(a)\
_apu_channel_volume_adjust(a->NS.output, APU_NS)
(a->muted[3] ? 0 : _apu_channel_volume_adjust(a->NS.output, APU_NS))
#define dmc_out(a)\
_apu_channel_volume_adjust(a->DMC.output, APU_DMC)
(a->muted[4] ? 0 : _apu_channel_volume_adjust(a->DMC.output, APU_DMC))
#define extra_out(ch)\
(ch * cfg->apu.channel[APU_EXTRA])
#define pulse_output(a)\
@ -523,6 +523,7 @@ EXTERNC struct NESAPU {
_apuTriangle TR;
_apuNoise NS;
_apuDMC DMC;
unsigned char muted[5];
};
/* apuPeriod[mode][type][cycles] */