Updates to BUS

Add digital sample support to BUS.
This commit is contained in:
Darrell Spice, Jr 2017-04-25 08:38:06 -05:00
parent ea7792d57a
commit 86ecaca7d9
3 changed files with 61 additions and 42 deletions

View File

@ -279,8 +279,8 @@ void CartridgeBUSWidget::loadConfig()
} }
myMusicWaveformSizes->setList(alist, vlist, changed); myMusicWaveformSizes->setList(alist, vlist, changed);
myBusOverdrive->setState(myCart.getBusStuffFlag()); // myBusOverdrive->setState(myCart.getBusStuffFlag());
myZPSTY->setState(myCart.mySTYZeroPage); // myZPSTY->setState(myCart.mySTYZeroPage);
CartDebugWidget::loadConfig(); CartDebugWidget::loadConfig();
} }

View File

@ -33,6 +33,8 @@
#define WAVEFORM 0x07F4 #define WAVEFORM 0x07F4
#define DSRAM 0x0800 #define DSRAM 0x0800
#define BUS_STUFF_ON ((myMode & 0x0F) == 0)
#define DIGITAL_AUDIO_ON ((myMode & 0xF0) == 0)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeBUS::CartridgeBUS(const uInt8* image, uInt32 size, CartridgeBUS::CartridgeBUS(const uInt8* image, uInt32 size,
@ -63,12 +65,6 @@ CartridgeBUS::CartridgeBUS(const uInt8* image, uInt32 size,
settings.getBool("thumb.trapfatal"), Thumbulator::ConfigureFor::BUS, this); settings.getBool("thumb.trapfatal"), Thumbulator::ConfigureFor::BUS, this);
#endif #endif
setInitialState(); setInitialState();
// BUS always starts in bank 6
myStartBank = 6;
// bus stuffing is off by default
myBusStuff = false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -98,6 +94,13 @@ void CartridgeBUS::setInitialState()
for (int i=0; i < 3; ++i) for (int i=0; i < 3; ++i)
myMusicWaveformSize[i] = 27; myMusicWaveformSize[i] = 27;
// BUS always starts in bank 6
myStartBank = 6;
// Assuming mode starts out with Fast Fetch off and 3-Voice music,
// need to confirm with Chris
myMode = 0xFF;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -210,10 +213,10 @@ uInt8 CartridgeBUS::peek(uInt16 address)
return peekvalue; return peekvalue;
// save the STY's zero page address // save the STY's zero page address
if (getBusStuffFlag() && mySTYZeroPage) if (BUS_STUFF_ON && mySTYZeroPageAddress == address)
myBusOverdriveAddress = peekvalue; myBusOverdriveAddress = peekvalue;
mySTYZeroPage = false; mySTYZeroPageAddress = 0;
if(address < 0x20) if(address < 0x20)
{ {
@ -251,13 +254,26 @@ uInt8 CartridgeBUS::peek(uInt16 address)
// Update the music data fetchers (counter & flag) // Update the music data fetchers (counter & flag)
updateMusicModeDataFetchers(); updateMusicModeDataFetchers();
// using myDisplayImage[] instead of myProgramImage[] because waveforms if DIGITAL_AUDIO_ON
// can be modified during runtime. {
uInt32 i = myDisplayImage[(getWaveform(0) ) + (myMusicCounters[0] >> myMusicWaveformSize[0])] + // retrieve packed sample (max size is 2K, or 4K of unpacked data)
myDisplayImage[(getWaveform(1) ) + (myMusicCounters[1] >> myMusicWaveformSize[1])] + result = myImage[getSample() + (myMusicCounters[0] >> 21)];
myDisplayImage[(getWaveform(2) ) + (myMusicCounters[2] >> myMusicWaveformSize[2])];
//
result = uInt8(i); if ((myMusicCounters[0] & (1<<20)) == 0)
result >>= 4;
result &= 0x0f;
}
else
{
// using myDisplayImage[] instead of myProgramImage[] because waveforms
// can be modified during runtime.
uInt32 i = myDisplayImage[(getWaveform(0) ) + (myMusicCounters[0] >> myMusicWaveformSize[0])] +
myDisplayImage[(getWaveform(1) ) + (myMusicCounters[1] >> myMusicWaveformSize[1])] +
myDisplayImage[(getWaveform(2) ) + (myMusicCounters[2] >> myMusicWaveformSize[2])];
result = uInt8(i);
}
break; break;
} }
break; break;
@ -311,8 +327,8 @@ uInt8 CartridgeBUS::peek(uInt16 address)
} }
// this might not work right for STY $84 // this might not work right for STY $84
if (getBusStuffFlag()) if (BUS_STUFF_ON && peekvalue == 0x84)
mySTYZeroPage = (peekvalue == 0x84); mySTYZeroPageAddress = address + 1;
return peekvalue; return peekvalue;
} }
@ -381,8 +397,8 @@ bool CartridgeBUS::poke(uInt16 address, uInt8 value)
setDatastreamPointer(index, pointer); setDatastreamPointer(index, pointer);
break; break;
case 0x09: // 0x19 turn on STY ZP bus stuffing if value is 0 case 0x09: // 0x19 SETMODE
setBusStuffFlag(value==0); myMode = value;
break; break;
case 0x0A: // 0x1A CALLFUNCTION case 0x0A: // 0x1A CALLFUNCTION
@ -683,10 +699,10 @@ uInt32 CartridgeBUS::getWaveform(uInt8 index) const
uInt32 result; uInt32 result;
result = myBUSRAM[WAVEFORM + index*4 + 0] + // low byte result = myBUSRAM[WAVEFORM + index*4 + 0] + // low byte
(myBUSRAM[WAVEFORM + index*4 + 1] << 8) + (myBUSRAM[WAVEFORM + index*4 + 1] << 8) +
(myBUSRAM[WAVEFORM + index*4 + 2] << 16) + (myBUSRAM[WAVEFORM + index*4 + 2] << 16) +
(myBUSRAM[WAVEFORM + index*4 + 3] << 24); (myBUSRAM[WAVEFORM + index*4 + 3] << 24); // high byte
result -= 0x40000800; result -= 0x40000800;
@ -696,6 +712,19 @@ uInt32 CartridgeBUS::getWaveform(uInt8 index) const
return result; return result;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getSample()
{
uInt32 result;
result = myBUSRAM[WAVEFORM + 0] + // low byte
(myBUSRAM[WAVEFORM + 1] << 8) +
(myBUSRAM[WAVEFORM + 2] << 16) +
(myBUSRAM[WAVEFORM + 3] << 24); // high byte
return result;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeBUS::getWaveformSize(uInt8 index) const uInt32 CartridgeBUS::getWaveformSize(uInt8 index) const
{ {
@ -712,18 +741,6 @@ void CartridgeBUS::setAddressMap(uInt8 index, uInt32 value)
myBUSRAM[DSMAPS + index*4 + 3] = (value >> 24) & 0xff; // high byte myBUSRAM[DSMAPS + index*4 + 3] = (value >> 24) & 0xff; // high byte
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartridgeBUS::getBusStuffFlag(void) const
{
return myBusStuff;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeBUS::setBusStuffFlag(bool value)
{
myBusStuff = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeBUS::readFromDatastream(uInt8 index) uInt8 CartridgeBUS::readFromDatastream(uInt8 index)
{ {

View File

@ -208,13 +208,11 @@ class CartridgeBUS : public Cartridge
uInt32 getAddressMap(uInt8 index) const; uInt32 getAddressMap(uInt8 index) const;
void setAddressMap(uInt8 index, uInt32 value); void setAddressMap(uInt8 index, uInt32 value);
bool getBusStuffFlag(void) const;
void setBusStuffFlag(bool value);
uInt8 readFromDatastream(uInt8 index); uInt8 readFromDatastream(uInt8 index);
uInt32 getWaveform(uInt8 index) const; uInt32 getWaveform(uInt8 index) const;
uInt32 getWaveformSize(uInt8 index) const; uInt32 getWaveformSize(uInt8 index) const;
uInt32 getSample();
private: private:
// The 32K ROM image of the cartridge // The 32K ROM image of the cartridge
@ -246,8 +244,8 @@ class CartridgeBUS : public Cartridge
// Address to override the bus for // Address to override the bus for
uInt16 myBusOverdriveAddress; uInt16 myBusOverdriveAddress;
// Flags that last byte peeked was 84 (STY ZP) // set to address of ZP if last byte peeked was $84 (STY ZP)
bool mySTYZeroPage; uInt16 mySTYZeroPageAddress;
// System cycle count when the last update to music data fetchers occurred // System cycle count when the last update to music data fetchers occurred
Int32 mySystemCycles; Int32 mySystemCycles;
@ -266,8 +264,12 @@ class CartridgeBUS : public Cartridge
// Fractional DPC music OSC clocks unused during the last update // Fractional DPC music OSC clocks unused during the last update
double myFractionalClocks; double myFractionalClocks;
// Flags that Bus Stuffing is active // Controls mode, lower nybble sets Fast Fetch, upper nybble sets audio
bool myBusStuff; // -0 = Bus Stuffing ON
// -F = Bus Stuffing OFF
// 0- = Packed Digital Sample
// F- = 3 Voice Music
uInt8 myMode;
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported