NES: fix issue for real

This commit is contained in:
tildearrow 2022-01-26 16:07:55 -05:00
parent bf19feab89
commit a895cb9c5e
4 changed files with 11 additions and 6 deletions

View File

@ -358,7 +358,7 @@ void DivPlatformNES::reset() {
dacSample=-1;
sampleBank=0;
apu_turn_on(nes);
apu_turn_on(nes,apuType);
nes->apu.cpu_cycles=0;
nes->apu.cpu_opcode_cycle=0;
@ -375,11 +375,13 @@ void DivPlatformNES::setPAL(bool pal) {
if (pal) {
rate=1662607;
freqBase=FREQ_BASE_PAL;
nes->apu.type=1;
apuType=1;
nes->apu.type=apuType;
} else {
rate=1789773;
freqBase=FREQ_BASE;
nes->apu.type=0;
apuType=0;
nes->apu.type=apuType;
}
}
@ -391,6 +393,7 @@ void DivPlatformNES::notifyInsDeletion(void* ins) {
int DivPlatformNES::init(DivEngine* p, int channels, int sugRate, bool pal) {
parent=p;
apuType=pal;
dumpWrites=false;
skipRegisterWrites=false;
for (int i=0; i<5; i++) {

View File

@ -38,6 +38,7 @@ class DivPlatformNES: public DivDispatch {
unsigned int dacPos;
int dacSample;
unsigned char sampleBank;
unsigned char apuType;
struct NESAPU* nes;
float freqBase;

View File

@ -190,7 +190,7 @@ void apu_tick(struct NESAPU* a, BYTE *hwtick) {
a->r4011.cycles++;
}
void apu_turn_on(struct NESAPU* a) {
void apu_turn_on(struct NESAPU* a, BYTE apu_type) {
memset(&a->apu, 0x00, sizeof(a->apu));
memset(&a->r4015, 0x00, sizeof(a->r4015));
memset(&a->r4017, 0x00, sizeof(a->r4017));
@ -202,7 +202,8 @@ void apu_turn_on(struct NESAPU* a) {
memset(&a->DMC, 0x00, sizeof(a->DMC));
/* al reset e' sempre settato a 60Hz */
a->apu.mode = APU_60HZ;
a->apu.type = 0;
/* per favore non fatemi questo... e' terribile */
a->apu.type = apu_type;
apu_change_step(a->apu.step);
/* valori iniziali dei vari canali */
a->S1.frequency = 1;

View File

@ -628,7 +628,7 @@ static const WORD dmc_rate[3][16] = {
};
EXTERNC void apu_tick(struct NESAPU* a, BYTE *hwtick);
EXTERNC void apu_turn_on(struct NESAPU* a);
EXTERNC void apu_turn_on(struct NESAPU* a, BYTE apu_type);
#undef EXTERNC