mirror of https://github.com/stella-emu/stella.git
reworked KidVid code a little bit (still not working)
This commit is contained in:
parent
f8bcfc3c64
commit
601287f8c7
|
@ -1028,7 +1028,7 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Controller::Type::KidVid:
|
case Controller::Type::KidVid:
|
||||||
controller = make_unique<KidVid>(port, myEvent, *mySystem, romMd5);
|
controller = make_unique<KidVid>(port, myEvent, *mySystem, myOSystem.baseDir().getPath(), romMd5);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Controller::Type::MindLink:
|
case Controller::Type::MindLink:
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
KidVid::KidVid(Jack jack, const Event& event, const System& system,
|
KidVid::KidVid(Jack jack, const Event& event, const System& system,
|
||||||
const string& romMd5)
|
const string& baseDir, const string& romMd5)
|
||||||
: Controller(jack, event, system, Controller::Type::KidVid),
|
: Controller(jack, event, system, Controller::Type::KidVid),
|
||||||
myEnabled{myJack == Jack::Right}
|
myEnabled{myJack == Jack::Right},
|
||||||
|
myBaseDir{baseDir}
|
||||||
{
|
{
|
||||||
// Right now, there are only two games that use the KidVid
|
// Right now, there are only two games that use the KidVid
|
||||||
if(romMd5 == "ee6665683ebdb539e89ba620981cb0f6")
|
if(romMd5 == "ee6665683ebdb539e89ba620981cb0f6")
|
||||||
|
@ -41,6 +42,8 @@ KidVid::~KidVid()
|
||||||
closeSampleFile();
|
closeSampleFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "System.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::update()
|
void KidVid::update()
|
||||||
{
|
{
|
||||||
|
@ -59,7 +62,7 @@ void KidVid::update()
|
||||||
myBlockIdx = KVBLOCKBITS;
|
myBlockIdx = KVBLOCKBITS;
|
||||||
myBlock = 0;
|
myBlock = 0;
|
||||||
openSampleFile();
|
openSampleFile();
|
||||||
//cerr << "myTape = " << myTape << endl;
|
//cerr << "myTape = " << myTape << endl;
|
||||||
}
|
}
|
||||||
else if(myEvent.get(Event::RightKeyboard2))
|
else if(myEvent.get(Event::RightKeyboard2))
|
||||||
{
|
{
|
||||||
|
@ -68,7 +71,7 @@ void KidVid::update()
|
||||||
myBlockIdx = KVBLOCKBITS;
|
myBlockIdx = KVBLOCKBITS;
|
||||||
myBlock = 0;
|
myBlock = 0;
|
||||||
openSampleFile();
|
openSampleFile();
|
||||||
//cerr << "myTape = " << myTape << endl;
|
//cerr << "myTape = " << myTape << endl;
|
||||||
}
|
}
|
||||||
else if(myEvent.get(Event::RightKeyboard3))
|
else if(myEvent.get(Event::RightKeyboard3))
|
||||||
{
|
{
|
||||||
|
@ -76,13 +79,13 @@ void KidVid::update()
|
||||||
{
|
{
|
||||||
myTape = 4;
|
myTape = 4;
|
||||||
myIdx = KVBLOCKBITS;
|
myIdx = KVBLOCKBITS;
|
||||||
//cerr << "myTape = " << myTape << endl;
|
//cerr << "myTape = " << myTape << endl;
|
||||||
}
|
}
|
||||||
else /* no, Smurf Save The Day */
|
else /* no, Smurf Save The Day */
|
||||||
{
|
{
|
||||||
myTape = 1;
|
myTape = 1;
|
||||||
myIdx = 0;
|
myIdx = 0;
|
||||||
//cerr << "myTape = " << myTape << endl;
|
//cerr << "myTape = " << myTape << endl;
|
||||||
}
|
}
|
||||||
myBlockIdx = KVBLOCKBITS;
|
myBlockIdx = KVBLOCKBITS;
|
||||||
myBlock = 0;
|
myBlock = 0;
|
||||||
|
@ -101,6 +104,15 @@ void KidVid::update()
|
||||||
{
|
{
|
||||||
IOPortA = (IOPortA & 0b11110111) | (((ourKVData[myIdx >> 3] << (myIdx & 0x07)) & 0x80) >> 4);
|
IOPortA = (IOPortA & 0b11110111) | (((ourKVData[myIdx >> 3] << (myIdx & 0x07)) & 0x80) >> 4);
|
||||||
|
|
||||||
|
//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;
|
||||||
--myBlockIdx;
|
--myBlockIdx;
|
||||||
|
@ -119,6 +131,7 @@ void KidVid::update()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myIdx = 36 * 8;//KVPause-KVData=36
|
myIdx = 36 * 8;//KVPause-KVData=36
|
||||||
|
cerr << endl << "Auto ";
|
||||||
setNextSong();
|
setNextSong();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,18 +150,32 @@ void KidVid::update()
|
||||||
myBlockIdx = KVBLOCKBITS;
|
myBlockIdx = KVBLOCKBITS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#ifdef KID_TAPE
|
||||||
// Now convert the register back into separate boolean values
|
else
|
||||||
setPin(DigitalPin::One, IOPortA & 0b0001);
|
myTapeBusy = false;
|
||||||
setPin(DigitalPin::Two, IOPortA & 0b0010);
|
//if(myFileOpened && ((IOPortA & 0b1000) == 0b1000) || myTapeBusy)
|
||||||
setPin(DigitalPin::Three, IOPortA & 0b0100);
|
//{
|
||||||
setPin(DigitalPin::Four, IOPortA & 0b1000);
|
// 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
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::openSampleFile()
|
void KidVid::openSampleFile()
|
||||||
{
|
{
|
||||||
#if 0
|
#ifdef KID_TAPE
|
||||||
static const char* const kvNameTable[6] = {
|
static const char* const kvNameTable[6] = {
|
||||||
"kvs3.wav", "kvs1.wav", "kvs2.wav", "kvb3.wav", "kvb1.wav", "kvb2.wav"
|
"kvs3.wav", "kvs1.wav", "kvs2.wav", "kvb3.wav", "kvb1.wav", "kvb2.wav"
|
||||||
};
|
};
|
||||||
|
@ -165,11 +192,11 @@ void KidVid::openSampleFile()
|
||||||
i += myTape - 1;
|
i += myTape - 1;
|
||||||
if(myTape == 4) i -= 3;
|
if(myTape == 4) i -= 3;
|
||||||
|
|
||||||
mySampleFile = fopen(kvNameTable[i], "rb");
|
mySampleFile = fopen((myBaseDir + kvNameTable[i]).c_str(), "rb");
|
||||||
if(mySampleFile != nullptr)
|
if(mySampleFile != nullptr)
|
||||||
{
|
{
|
||||||
cerr << "opened file: " << kvNameTable[i] << endl;
|
cerr << "opened file: " << kvNameTable[i] << endl;
|
||||||
mySharedSampleFile = fopen("kvshared.wav", "rb");
|
mySharedSampleFile = fopen((myBaseDir + "kvshared.wav").c_str(), "rb");
|
||||||
if(mySharedSampleFile == nullptr)
|
if(mySharedSampleFile == nullptr)
|
||||||
{
|
{
|
||||||
fclose(mySampleFile);
|
fclose(mySampleFile);
|
||||||
|
@ -178,7 +205,7 @@ cerr << "opened file: " << kvNameTable[i] << endl;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cerr << "opened file: " << "kvshared.wav" << endl;
|
cerr << "opened file: " << "kvshared.wav" << endl;
|
||||||
// fseek(mySampleFile, 45, SEEK_SET);
|
fseek(mySampleFile, 45, SEEK_SET);
|
||||||
myFileOpened = true;
|
myFileOpened = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +222,7 @@ cerr << "opened file: " << "kvshared.wav" << endl;
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::closeSampleFile()
|
void KidVid::closeSampleFile()
|
||||||
{
|
{
|
||||||
#if 0
|
#ifdef KID_TAPE
|
||||||
if(myFileOpened)
|
if(myFileOpened)
|
||||||
{
|
{
|
||||||
fclose(mySampleFile);
|
fclose(mySampleFile);
|
||||||
|
@ -210,17 +237,18 @@ void KidVid::setNextSong()
|
||||||
{
|
{
|
||||||
if(myFileOpened)
|
if(myFileOpened)
|
||||||
{
|
{
|
||||||
|
cerr << endl << std::dec << mySongCounter << ", " << myFilePointer << endl;
|
||||||
myBeep = (ourSongPositions[myFilePointer] & 0x80) == 0;
|
myBeep = (ourSongPositions[myFilePointer] & 0x80) == 0;
|
||||||
|
|
||||||
const uInt8 temp = ourSongPositions[myFilePointer] & 0x7f;
|
const uInt8 temp = ourSongPositions[myFilePointer] & 0x7f;
|
||||||
mySharedData = (temp < 10);
|
mySharedData = (temp < 10);
|
||||||
mySongCounter = ourSongStart[temp+1] - ourSongStart[temp];
|
mySongCounter = ourSongStart[temp+1] - ourSongStart[temp];
|
||||||
|
|
||||||
#if 0
|
#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
|
#endif
|
||||||
|
|
||||||
++myFilePointer;
|
++myFilePointer;
|
||||||
|
@ -237,17 +265,19 @@ void KidVid::setNextSong()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void KidVid::getNextSampleByte()
|
void KidVid::getNextSampleByte()
|
||||||
{
|
{
|
||||||
// static int oddeven = 0;
|
#ifdef KID_TAPE
|
||||||
|
static int oddeven = 0;
|
||||||
|
#endif
|
||||||
if(mySongCounter == 0)
|
if(mySongCounter == 0)
|
||||||
mySampleByte = 0x80;
|
mySampleByte = 0x80;
|
||||||
#if 0
|
#ifdef KID_TAPE
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
oddeven = oddeven^1;
|
oddeven = oddeven^1;
|
||||||
if(oddeven & 1)
|
if(oddeven & 1)
|
||||||
{
|
{
|
||||||
mySongCounter--;
|
mySongCounter--;
|
||||||
myTapeBusy = (mySongCounter > 262*48) || !myBeep;
|
myTapeBusy = (mySongCounter > 262 * 48) || !myBeep;
|
||||||
|
|
||||||
if(myFileOpened)
|
if(myFileOpened)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#ifndef KIDVID_HXX
|
#ifndef KIDVID_HXX
|
||||||
#define KIDVID_HXX
|
#define KIDVID_HXX
|
||||||
|
|
||||||
|
//#define KID_TAPE
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
class Event;
|
class Event;
|
||||||
|
@ -48,7 +50,7 @@ class KidVid : public Controller
|
||||||
@param romMd5 The md5 of the ROM using this controller
|
@param romMd5 The md5 of the ROM using this controller
|
||||||
*/
|
*/
|
||||||
KidVid(Jack jack, const Event& event, const System& system,
|
KidVid(Jack jack, const Event& event, const System& system,
|
||||||
const string& romMd5);
|
const string& baseDir, const string& romMd5);
|
||||||
~KidVid() override;
|
~KidVid() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -89,8 +91,11 @@ class KidVid : public Controller
|
||||||
// supports, and if it's plugged into the right port
|
// supports, and if it's plugged into the right port
|
||||||
bool myEnabled{false};
|
bool myEnabled{false};
|
||||||
|
|
||||||
|
string myBaseDir;
|
||||||
|
#ifdef KID_TAPE
|
||||||
// The file handles for the WAV files
|
// The file handles for the WAV files
|
||||||
// FILE *mySampleFile, *mySharedSampleFile;
|
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};
|
||||||
|
|
Loading…
Reference in New Issue