Sample playback update for BUS & CDF.

This commit is contained in:
Stephen Anthony 2017-05-28 14:40:51 -02:30
parent 79d8ed0010
commit e419bbbcab
2 changed files with 66 additions and 56 deletions

View File

@ -156,15 +156,11 @@ inline void CartridgeBUS::updateMusicModeDataFetchers()
myFractionalClocks = clocks - double(wholeClocks);
if(wholeClocks <= 0)
{
return;
}
// Let's update counters and flags of the music mode data fetchers
for(int x = 0; x <= 2; ++x)
{
myMusicCounters[x] += myMusicFrequencies[x] * wholeClocks;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -261,16 +257,23 @@ uInt8 CartridgeBUS::peek(uInt16 address)
switch(address)
{
case 0xFEE: // AMPLITUDE
// Update the music data fetchers (counter & flag)
updateMusicModeDataFetchers();
if DIGITAL_AUDIO_ON
{
// retrieve packed sample (max size is 2K, or 4K of unpacked data)
peekvalue = myImage[getSample() + (myMusicCounters[0] >> 21)];
uInt32 sampleaddress = getSample() + (myMusicCounters[0] >> 21);
//
// get sample value from ROM or RAM
if (sampleaddress < 0x8000)
peekvalue = myImage[sampleaddress];
else if (sampleaddress >= 0x40000000 && sampleaddress < 0x40002000) // check for RAM
peekvalue = myBUSRAM[sampleaddress - 0x40000000];
else
peekvalue = 0;
// make sure current volume value is in the lower nybble
if ((myMusicCounters[0] & (1<<20)) == 0)
peekvalue >>= 4;
peekvalue &= 0x0f;

View File

@ -249,10 +249,17 @@ uInt8 CartridgeCDF::peek(uInt16 address)
if DIGITAL_AUDIO_ON
{
// retrieve packed sample (max size is 2K, or 4K of unpacked data)
address = getSample() + (myMusicCounters[0] >> 21);
peekvalue = myImage[address];
uInt32 sampleaddress = getSample() + (myMusicCounters[0] >> 21);
//
// get sample value from ROM or RAM
if (sampleaddress < 0x8000)
peekvalue = myImage[sampleaddress];
else if (sampleaddress >= 0x40000000 && sampleaddress < 0x40002000) // check for RAM
peekvalue = myCDFRAM[sampleaddress - 0x40000000];
else
peekvalue = 0;
// make sure current volume value is in the lower nybble
if ((myMusicCounters[0] & (1<<20)) == 0)
peekvalue >>= 4;
peekvalue &= 0x0f;