diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index ebe3d43b4..20ffc7748 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -1028,8 +1028,15 @@ unique_ptr Console::getControllerPort(const Controller::Type type, break; case Controller::Type::KidVid: - controller = make_unique(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(port, myEvent, myOSystem, *mySystem, romMd5, callback); break; + } case Controller::Type::MindLink: controller = make_unique(port, myEvent, *mySystem); diff --git a/src/emucore/Control.hxx b/src/emucore/Control.hxx index 62e1b8747..1e7bbfa7e 100644 --- a/src/emucore/Control.hxx +++ b/src/emucore/Control.hxx @@ -115,6 +115,7 @@ class Controller : public Serializable Callback type for general controller messages */ using onMessageCallback = std::function; + using onMessageCallbackForced = std::function; public: /** diff --git a/src/emucore/KidVid.cxx b/src/emucore/KidVid.cxx index 02141b2e0..c06043eb9 100644 --- a/src/emucore/KidVid.cxx +++ b/src/emucore/KidVid.cxx @@ -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 diff --git a/src/emucore/KidVid.hxx b/src/emucore/KidVid.hxx index 2fc854f17..b4c9cbacd 100644 --- a/src/emucore/KidVid.hxx +++ b/src/emucore/KidVid.hxx @@ -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};