Dudes, I find another bug in the NES Emulator, the notes from A0 to A1 in NES' Squares are unusable:
According to this table:
CODE wrote:
/* frequency limit of square channels */
static const int freq_limit[8] =
{
0x3FF, 0x555, 0x666, 0x71C, 0x787, 0x7C1, 0x7E0, 0x7F0,
};
The limit freq at position zero should be 0x3FF... BUT, at the moment of the apu_square rendering, a wild condition appears:
CODE wrote:
if ((0 == (chan->regs[1] & 8) && (chan->freq >> 16) > freq_limit[chan->regs[1] & 7])
|| (chan->freq >> 16) < 4)
return 0;
The interesting point is here:
(chan->freq >> 16) > freq_limit[chan->regs[1] & 7]
Why it is getting the information of the frequency limiter from the lower 3 bits of the APU Sweep (these 3 bits are the Shift count or speed of the sweep)?, and why it is getting from here always, even if the sweep is disabled!?.
This should be:
CODE wrote:
if(chan->regs[1] & 0x80)freq_index=chan->regs[1] & 7; //If sweeping is enabled, I choose it as normal.
else freq_index=7; //If sweeping is disabled, I choose the lower limit.
if ((0 == (chan->regs[1] & 8) && (chan->freq >> 16) > freq_limit[freq_index])
|| (chan->freq >> 16) < 4)
return 0;
Now we can hear lower notes than A-1, but there is another thing, the full range of the NES is from A-0 to B-7 (not A-1 to B-7 as it was previously configured), but with this fix we cannot use A-0 yet. So this emulator needs another fix, and it is here:
CODE wrote:
/* frequency limit of square channels */
static const int freq_limit[8] =
{
0x3FF, 0x555, 0x666, 0x71C, 0x787, 0x7C1, 0x7E0, 0x7F0,
};
The latest limit is wrong, I don't know the exact value for the limit, but the first value when the A-0 becomes audible is 0x7F2, so:
CODE wrote:
/* frequency limit of square channels */
static const int freq_limit[8] =
{
0x3FF, 0x555, 0x666, 0x71C, 0x787, 0x7C1, 0x7E0, 0x7F2,
};
You could check in Famitracker easily that the NES could reach lower notes than A-1 and even A-0, and you can check that the current emulator used by in_vgm/VGMPlay could not reach those notes by listening to the next examples (they play A1 G1 F1 E1 D1 C1 B0 A0):
A VGM example done in DefleMask (you will hear only one note, A1, and then silence)
A WAVE Rendering of DefleMask
A WAVE Rendering of Famitracker
And a NSF that you can test with different emulators:
http://www.delek.com.ar/A0Test.vgm
http://www.delek.com.ar/A0Test_DefleMask.wav
http://www.delek.com.ar/A0Test_Famitracker.wav
http://www.delek.com.ar/A0Test_NSF.nsf
Regards.