added messages for Kid Vid

This commit is contained in:
Thomas Jentzsch 2022-09-10 15:56:25 +02:00
parent 2027882c77
commit 9d6cee710e
4 changed files with 39 additions and 9 deletions

View File

@ -1028,8 +1028,15 @@ unique_ptr<Controller> Console::getControllerPort(const Controller::Type type,
break;
case Controller::Type::KidVid:
controller = make_unique<KidVid>(port, myEvent, myOSystem, *mySystem, romMd5);
{
Controller::onMessageCallbackForced callback = [&os = myOSystem](const string& msg, bool force) {
bool devSettings = os.settings().getBool("dev.settings");
if(force || os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
os.frameBuffer().showTextMessage(msg);
};
controller = make_unique<KidVid>(port, myEvent, myOSystem, *mySystem, romMd5, callback);
break;
}
case Controller::Type::MindLink:
controller = make_unique<MindLink>(port, myEvent, *mySystem);

View File

@ -115,6 +115,7 @@ class Controller : public Serializable
Callback type for general controller messages
*/
using onMessageCallback = std::function<void(const string&)>;
using onMessageCallbackForced = std::function<void(const string&, bool force)>;
public:
/**

View File

@ -26,10 +26,12 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KidVid::KidVid(Jack jack, const Event& event, const OSystem& osystem,
const System& system, const string& romMd5)
const System& system, const string& romMd5,
const onMessageCallbackForced& callback)
: Controller(jack, event, system, Controller::Type::KidVid),
myEnabled{myJack == Jack::Right},
myOSystem{osystem}
myOSystem{osystem},
myCallback{callback}
{
// Right now, there are only two games that use the KidVid
if(romMd5 == "ee6665683ebdb539e89ba620981cb0f6")
@ -115,10 +117,21 @@ void KidVid::update()
}
if(myTape)
{
static constexpr uInt32 gameNumber[4] = { 3, 1, 2, 3 };
static constexpr const char* gameName[6] = {
"Harmony Smurf", "Handy Smurf", "Greedy Smurf",
"Big Number Hunt", "Great Letter Roundup", "Spooky Spelling Bee"
};
myIdx = myGame == Game::BBears ? NumBlockBits : 0; // KVData48/KVData44
myBlockIdx = NumBlockBits;
myBlock = 0;
openSampleFiles();
ostringstream msg;
msg << "Game #" << gameNumber[myTape - 1] << " - \""
<< gameName[gameNumber[myTape - 1] + (myGame == Game::Smurfs ? -1 : 2)] << "\"";
myCallback(msg.str(), true);
}
}
@ -281,6 +294,10 @@ void KidVid::setNextSong()
const string& fileName = (temp < 10) ? "KVSHARED.WAV" : getFileName();
myOSystem.sound().playWav(myOSystem.baseDir().getPath() + fileName,
ourSongStart[temp], mySongLength);
ostringstream msg;
msg << "Read song #" << mySongPointer << " (" << fileName << ")";
myCallback(msg.str(), false);
#ifdef DEBUG_BUILD
cerr << fileName << ": " << (ourSongPositions[mySongPointer] & 0x7f) << endl;
#endif

View File

@ -41,14 +41,16 @@ class KidVid : public Controller
/**
Create a new KidVid controller plugged into the specified jack
@param jack The jack the controller is plugged into
@param event The event object to use for events
@param osystem The OSystem object to use
@param system The system using this controller
@param romMd5 The md5 of the ROM using this controller
@param jack The jack the controller is plugged into
@param event The event object to use for events
@param osystem The OSystem object to use
@param system The system using this controller
@param romMd5 The md5 of the ROM using this controller
@param callback Called to pass messages back to the parent controller
*/
KidVid(Jack jack, const Event& event, const OSystem& osystem,
const System& system, const string& romMd5);
const System& system, const string& romMd5,
const onMessageCallbackForced& callback);
~KidVid() override = default;
public:
@ -118,6 +120,9 @@ class KidVid : public Controller
const OSystem& myOSystem;
// Sends messages back to the parent class
Controller::onMessageCallbackForced myCallback;
// Indicates if the sample files have been found
bool myFilesFound{false};