mirror of https://github.com/stella-emu/stella.git
allow playing KidVid without tapes
This commit is contained in:
parent
98b06cffc0
commit
59c1b21b01
|
@ -42,7 +42,22 @@ KidVid::~KidVid()
|
||||||
closeSampleFile();
|
closeSampleFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "System.hxx"
|
|
||||||
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
void KidVid::write(DigitalPin pin, bool value)
|
||||||
|
{
|
||||||
|
// Change the pin state based on value
|
||||||
|
switch(pin)
|
||||||
|
{
|
||||||
|
// Pin 1: Signal tape running or stopped
|
||||||
|
case DigitalPin::One:
|
||||||
|
setPin(DigitalPin::One, value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::update()
|
void KidVid::update()
|
||||||
|
@ -92,26 +107,10 @@ void KidVid::update()
|
||||||
openSampleFile();
|
openSampleFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert separate pin states into a 'register'
|
|
||||||
uInt8 IOPortA = 0b11110000;
|
|
||||||
if(getPin(DigitalPin::One)) IOPortA |= 0b0001;
|
|
||||||
if(getPin(DigitalPin::Two)) IOPortA |= 0b0010;
|
|
||||||
if(getPin(DigitalPin::Three)) IOPortA |= 0b0100;
|
|
||||||
if(getPin(DigitalPin::Four)) IOPortA |= 0b1000;
|
|
||||||
|
|
||||||
// Is the tape running?
|
// Is the tape running?
|
||||||
if((myTape != 0) && ((IOPortA & 0b0001) == 0b0001) && !myTapeBusy)
|
if(myTape != 0 && getPin(DigitalPin::One) && !myTapeBusy)
|
||||||
{
|
{
|
||||||
IOPortA = (IOPortA & 0b11110111) | (((ourKVData[myIdx >> 3] << (myIdx & 0x07)) & 0x80) >> 4);
|
setPin(DigitalPin::Four, (ourKVData[myIdx >> 3] << (myIdx & 0x07)) & 0x80);
|
||||||
|
|
||||||
//cerr << endl << std::dec << IOPortA << " ";
|
|
||||||
// Now convert the register back into separate boolean values
|
|
||||||
//setPin(DigitalPin::One, IOPortA & 0b0001);
|
|
||||||
//setPin(DigitalPin::Two, IOPortA & 0b0010);
|
|
||||||
//setPin(DigitalPin::Three, IOPortA & 0b0100);
|
|
||||||
//if(IOPortA != 0xff)
|
|
||||||
// int i = 0;
|
|
||||||
setPin(DigitalPin::Four, IOPortA & 0b1000);
|
|
||||||
|
|
||||||
// increase to next bit
|
// increase to next bit
|
||||||
++myIdx;
|
++myIdx;
|
||||||
|
@ -131,7 +130,7 @@ void KidVid::update()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myIdx = 36 * 8;//KVPause-KVData=36
|
myIdx = 36 * 8;//KVPause-KVData=36
|
||||||
cerr << endl << "Auto ";
|
//cerr << endl << "Auto ";
|
||||||
setNextSong();
|
setNextSong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,26 +149,10 @@ void KidVid::update()
|
||||||
myBlockIdx = KVBLOCKBITS;
|
myBlockIdx = KVBLOCKBITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef KID_TAPE
|
// emulate playing the songs (but MUCH faster!)
|
||||||
else
|
// TODO: this has to be done by an Audio class
|
||||||
myTapeBusy = false;
|
for(int i = mySongCounter / 8; i >= 0; --i)
|
||||||
//if(myFileOpened && ((IOPortA & 0b1000) == 0b1000) || myTapeBusy)
|
getNextSampleByte();
|
||||||
//{
|
|
||||||
// for(int i = 0; i < 266 * 2; ++i)
|
|
||||||
// getNextSampleByte();
|
|
||||||
// cerr << mySongCounter << " ";
|
|
||||||
//}
|
|
||||||
////else
|
|
||||||
//{
|
|
||||||
// if((myTape != 0) && ((IOPortA & 0b1000) == 0b0000) && myTapeBusy)
|
|
||||||
// {
|
|
||||||
// //while(myBeep && myTapeBusy && ((IOPortA & 0b0001) == 0b0001)) // mySongCounter; ++i)
|
|
||||||
// for(int i = mySongCounter / 8; i >= 0; --i)
|
|
||||||
// getNextSampleByte();
|
|
||||||
// cerr << mySongCounter << " ";
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -235,6 +218,7 @@ void KidVid::closeSampleFile()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::setNextSong()
|
void KidVid::setNextSong()
|
||||||
{
|
{
|
||||||
|
#ifdef KID_TAPE
|
||||||
if(myFileOpened)
|
if(myFileOpened)
|
||||||
{
|
{
|
||||||
cerr << endl << std::dec << mySongCounter << ", " << myFilePointer << endl;
|
cerr << endl << std::dec << mySongCounter << ", " << myFilePointer << endl;
|
||||||
|
@ -244,33 +228,34 @@ void KidVid::setNextSong()
|
||||||
mySharedData = (temp < 10);
|
mySharedData = (temp < 10);
|
||||||
mySongCounter = ourSongStart[temp+1] - ourSongStart[temp];
|
mySongCounter = ourSongStart[temp+1] - ourSongStart[temp];
|
||||||
|
|
||||||
#ifdef KID_TAPE
|
|
||||||
if(mySharedData)
|
if(mySharedData)
|
||||||
fseek(mySharedSampleFile, ourSongStart[temp], SEEK_SET);
|
fseek(mySharedSampleFile, ourSongStart[temp], SEEK_SET);
|
||||||
else
|
else
|
||||||
fseek(mySampleFile, ourSongStart[temp], SEEK_SET);
|
fseek(mySampleFile, ourSongStart[temp], SEEK_SET);
|
||||||
#endif
|
|
||||||
|
|
||||||
++myFilePointer;
|
++myFilePointer;
|
||||||
myTapeBusy = true;
|
myTapeBusy = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
myBeep = true;
|
myBeep = true;
|
||||||
myTapeBusy = true;
|
myTapeBusy = true;
|
||||||
mySongCounter = 80*262; /* delay needed for Harmony without tape */
|
mySongCounter = 10 * 80*262; /* delay needed for Harmony without tape */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::getNextSampleByte()
|
void KidVid::getNextSampleByte()
|
||||||
{
|
{
|
||||||
#ifdef KID_TAPE
|
|
||||||
static int oddeven = 0;
|
static int oddeven = 0;
|
||||||
#endif
|
|
||||||
if(mySongCounter == 0)
|
if(mySongCounter == 0)
|
||||||
mySampleByte = 0x80;
|
{
|
||||||
#ifdef KID_TAPE
|
#ifdef KID_TAPE
|
||||||
|
mySampleByte = 0x80;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oddeven = oddeven^1;
|
oddeven = oddeven^1;
|
||||||
|
@ -279,6 +264,7 @@ void KidVid::getNextSampleByte()
|
||||||
mySongCounter--;
|
mySongCounter--;
|
||||||
myTapeBusy = (mySongCounter > 262 * 48) || !myBeep;
|
myTapeBusy = (mySongCounter > 262 * 48) || !myBeep;
|
||||||
|
|
||||||
|
#ifdef KID_TAPE
|
||||||
if(myFileOpened)
|
if(myFileOpened)
|
||||||
{
|
{
|
||||||
if(mySharedData)
|
if(mySharedData)
|
||||||
|
@ -288,12 +274,12 @@ void KidVid::getNextSampleByte()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mySampleByte = 0x80;
|
mySampleByte = 0x80;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(!myBeep && (mySongCounter == 0))
|
if(!myBeep && (mySongCounter == 0))
|
||||||
setNextSong();
|
setNextSong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -54,6 +54,16 @@ class KidVid : public Controller
|
||||||
~KidVid() override;
|
~KidVid() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
Write the given value to the specified digital pin for this
|
||||||
|
controller. Writing is only allowed to the pins associated
|
||||||
|
with the PIA. Therefore you cannot write to pin six.
|
||||||
|
|
||||||
|
@param pin The pin of the controller jack to write to
|
||||||
|
@param value The value to write to the pin
|
||||||
|
*/
|
||||||
|
void write(DigitalPin pin, bool value) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Update the entire digital and analog pin state according to the
|
Update the entire digital and analog pin state according to the
|
||||||
events currently set.
|
events currently set.
|
||||||
|
@ -95,17 +105,19 @@ class KidVid : public Controller
|
||||||
#ifdef KID_TAPE
|
#ifdef KID_TAPE
|
||||||
// The file handles for the WAV files
|
// The file handles for the WAV files
|
||||||
FILE *mySampleFile{nullptr}, *mySharedSampleFile{nullptr};
|
FILE *mySampleFile{nullptr}, *mySharedSampleFile{nullptr};
|
||||||
#endif
|
|
||||||
|
|
||||||
// Indicates if sample files have been successfully opened
|
// Indicates if sample files have been successfully opened
|
||||||
bool myFileOpened{false};
|
bool myFileOpened{false};
|
||||||
|
|
||||||
|
uInt32 myFilePointer{0};
|
||||||
|
bool mySharedData{false};
|
||||||
|
uInt8 mySampleByte{0};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Is the tape currently 'busy' / in use?
|
// Is the tape currently 'busy' / in use?
|
||||||
bool myTapeBusy{false};
|
bool myTapeBusy{false};
|
||||||
|
|
||||||
uInt32 myFilePointer{0}, mySongCounter{0};
|
uInt32 mySongCounter{0};
|
||||||
bool myBeep{false}, mySharedData{false};
|
bool myBeep{false};
|
||||||
uInt8 mySampleByte{0};
|
|
||||||
uInt32 myGame{0}, myTape{0};
|
uInt32 myGame{0}, myTape{0};
|
||||||
uInt32 myIdx{0}, myBlock{0}, myBlockIdx{0};
|
uInt32 myIdx{0}, myBlock{0}, myBlockIdx{0};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue