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,16 +156,12 @@ inline void CartridgeBUS::updateMusicModeDataFetchers()
myFractionalClocks = clocks - double(wholeClocks); myFractionalClocks = clocks - double(wholeClocks);
if(wholeClocks <= 0) if(wholeClocks <= 0)
{
return; return;
}
// Let's update counters and flags of the music mode data fetchers // Let's update counters and flags of the music mode data fetchers
for(int x = 0; x <= 2; ++x) for(int x = 0; x <= 2; ++x)
{
myMusicCounters[x] += myMusicFrequencies[x] * wholeClocks; myMusicCounters[x] += myMusicFrequencies[x] * wholeClocks;
} }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
inline void CartridgeBUS::callFunction(uInt8 value) inline void CartridgeBUS::callFunction(uInt8 value)
@ -261,16 +257,23 @@ uInt8 CartridgeBUS::peek(uInt16 address)
switch(address) switch(address)
{ {
case 0xFEE: // AMPLITUDE case 0xFEE: // AMPLITUDE
// Update the music data fetchers (counter & flag) // Update the music data fetchers (counter & flag)
updateMusicModeDataFetchers(); updateMusicModeDataFetchers();
if DIGITAL_AUDIO_ON if DIGITAL_AUDIO_ON
{ {
// retrieve packed sample (max size is 2K, or 4K of unpacked data) // 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) if ((myMusicCounters[0] & (1<<20)) == 0)
peekvalue >>= 4; peekvalue >>= 4;
peekvalue &= 0x0f; peekvalue &= 0x0f;

View File

@ -249,10 +249,17 @@ uInt8 CartridgeCDF::peek(uInt16 address)
if DIGITAL_AUDIO_ON if DIGITAL_AUDIO_ON
{ {
// retrieve packed sample (max size is 2K, or 4K of unpacked data) // retrieve packed sample (max size is 2K, or 4K of unpacked data)
address = getSample() + (myMusicCounters[0] >> 21); uInt32 sampleaddress = getSample() + (myMusicCounters[0] >> 21);
peekvalue = myImage[address];
// // 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) if ((myMusicCounters[0] & (1<<20)) == 0)
peekvalue >>= 4; peekvalue >>= 4;
peekvalue &= 0x0f; peekvalue &= 0x0f;