nes_apu.cpp: Added noise channel period table for PAL systems. (#9256)

- Fixed a value in the parallel NTSC table for the largest period (lowest freq).
- Fixed a value in the counter length table (for all channels but DMC).
This commit is contained in:
0kmg 2022-02-03 05:57:36 -09:00 committed by GitHub
parent 6c84aa7160
commit 0bedd48018
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 28 deletions

View File

@ -49,36 +49,23 @@
#include "emu.h" #include "emu.h"
#include "nes_apu.h" #include "nes_apu.h"
/* INTERNAL FUNCTIONS */ // INTERNAL FUNCTIONS
/* INITIALIZE WAVE TIMES RELATIVE TO SAMPLE RATE */ // INITIALIZE WAVE TIMES RELATIVE TO SAMPLE RATE
static void create_vbltimes(u32 *table, const u8 *vbl, unsigned int rate) static void create_vbltimes(u32 *table, const u8 *vbl, unsigned int rate)
{ {
int i; for (int i = 0; i < 0x20; i++)
for (i = 0; i < 0x20; i++)
table[i] = vbl[i] * rate; table[i] = vbl[i] * rate;
} }
/* INITIALIZE SAMPLE TIMES IN TERMS OF VSYNCS */ // INITIALIZE SAMPLE TIMES IN TERMS OF VSYNCS
void nesapu_device::create_syncs(unsigned long sps) void nesapu_device::create_syncs(unsigned long sps)
{ {
int i; for (int i = 0; i < SYNCS_MAX1; i++)
unsigned long val = sps; m_sync_times1[i] = sps * (i + 1);
for (i = 0; i < SYNCS_MAX1; i++) for (int i = 0; i < SYNCS_MAX2; i++)
{ m_sync_times2[i] = (sps * i) >> 2;
m_sync_times1[i] = val;
val += sps;
}
val = 0;
for (i = 0; i < SYNCS_MAX2; i++)
{
m_sync_times2[i] = val;
m_sync_times2[i] >>= 2;
val += sps;
}
} }
DEFINE_DEVICE_TYPE(NES_APU, nesapu_device, "nesapu", "N2A03 APU") DEFINE_DEVICE_TYPE(NES_APU, nesapu_device, "nesapu", "N2A03 APU")
@ -387,7 +374,7 @@ s8 nesapu_device::apu_noise(apu_t::noise_t *chan)
if (0 == chan->vbl_length) if (0 == chan->vbl_length)
return 0; return 0;
freq = noise_freq[chan->regs[2] & 0x0F]; freq = noise_freq[m_is_pal][chan->regs[2] & 0x0F];
chan->phaseacc -= 4; chan->phaseacc -= 4;
while (chan->phaseacc < 0) while (chan->phaseacc < 0)
{ {

View File

@ -195,7 +195,7 @@ struct apu_t
/* vblank length table used for squares, triangle, noise */ /* vblank length table used for squares, triangle, noise */
static const apu_t::uint8 vbl_length[32] = static const apu_t::uint8 vbl_length[32] =
{ {
5, 127, 10, 1, 19, 2, 40, 3, 80, 4, 30, 5, 7, 6, 13, 7, 5, 127, 10, 1, 20, 2, 40, 3, 80, 4, 30, 5, 7, 6, 13, 7,
6, 8, 12, 9, 24, 10, 48, 11, 96, 12, 36, 13, 8, 14, 16, 15 6, 8, 12, 9, 24, 10, 48, 11, 96, 12, 36, 13, 8, 14, 16, 15
}; };
@ -205,10 +205,12 @@ static const int freq_limit[8] =
0x3FF, 0x555, 0x666, 0x71C, 0x787, 0x7C1, 0x7E0, 0x7F0, 0x3FF, 0x555, 0x666, 0x71C, 0x787, 0x7C1, 0x7E0, 0x7F0,
}; };
/* table of noise frequencies */ // table of noise period
static const int noise_freq[16] = // each fundamental is determined as: freq = master / period / 93
static const int noise_freq[2][16] =
{ {
4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 2046 { 4, 8, 16, 32, 64, 96, 128, 160, 202, 254, 380, 508, 762, 1016, 2034, 4068 }, // NTSC
{ 4, 8, 14, 30, 60, 88, 118, 148, 188, 236, 354, 472, 708, 944, 1890, 3778 } // PAL
}; };
// dpcm (cpu) cycle period // dpcm (cpu) cycle period