From 4f1b1ab97e04a10a56410fdbac572ebf6ce077a6 Mon Sep 17 00:00:00 2001 From: Thomas Jentzsch Date: Sun, 4 Sep 2022 18:40:46 +0200 Subject: [PATCH] refactored KidVid code a bit updated doc --- docs/index.html | 17 +++++++++++++---- src/common/SoundSDL2.cxx | 2 +- src/emucore/KidVid.cxx | 30 ++++++++++++++++++++---------- src/emucore/KidVid.hxx | 5 +++-- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/docs/index.html b/docs/index.html index 0b1915b6a..168d97e0e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -21,7 +21,7 @@

A multi-platform Atari 2600 VCS emulator

-

Release 6.7

+

Release 7.0


User's Guide

@@ -1048,6 +1048,17 @@ +
+

Kid Vid Voice Module (can be remapped via Keyboard Controller)

+ + + + + + + +
Function Key
Start game #18 (same as Right Pad Button '1')
Start game #29 (same as Right Pad Button '2')
Start game #30 (same as Right Pad Button '3')
Skip current songP (same as Right Pad Button '6')
+

CompuMate Controller (cannot be remapped)

@@ -1072,7 +1083,6 @@ [ [ or Shift + 8 ] ] or Shift + 9 " " (Shift + ') or Shift + 0 -
@@ -5024,8 +5034,7 @@ Ms Pac-Man (Stella extended codes): CompuMate ¹Spectravideo CompuMate (if either left or right is set, CompuMate is used for both). LightgunAtari XG-1 compatible Light Gun. MindLink ¹MindLink controller. - KidVidKid Vid Voice Module (Right Keyboard controller - buttons 1, 2 and 3 start the games, default mapping is 8, 9 and 0).
+ KidVidKid Vid Voice Module.
Audio files can be downloaded e.g. from AtariAge. Put unzipped .WAV files into Stella's base directory (see properties or palette files below for details).
diff --git a/src/common/SoundSDL2.cxx b/src/common/SoundSDL2.cxx index d23f1ad52..679a7e641 100644 --- a/src/common/SoundSDL2.cxx +++ b/src/common/SoundSDL2.cxx @@ -453,7 +453,7 @@ void SoundSDL2::stopWav() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - uInt32 SoundSDL2::wavSize() const { - return myWavBuffer ? myWavLen /*SDL_GetQueuedAudioSize(myWavDevice)*/ : 0; + return myWavBuffer ? myWavLen : 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/KidVid.cxx b/src/emucore/KidVid.cxx index 5a45bf12f..0246b8691 100644 --- a/src/emucore/KidVid.cxx +++ b/src/emucore/KidVid.cxx @@ -65,7 +65,7 @@ void KidVid::update() const uInt32 songLength = ourSongStart[temp + 1] - ourSongStart[temp]; // Play the remaining WAV file - const string& fileName = (temp < 10) ? myBaseDir + "KVSHARED.WAV" : mySampleFile; + const string& fileName = myBaseDir + ((temp < 10) ? "KVSHARED.WAV" : getFileName()); mySound.playWav(fileName, ourSongStart[temp] + (songLength - mySongLength), mySongLength); myContinueSong = false; @@ -77,6 +77,10 @@ void KidVid::update() myFilesFound = mySongPlaying = false; mySound.stopWav(); } + else if(myEvent.get(Event::RightKeyboard6)) + { + mySound.stopWav(); + } if(!myTape) { if(myEvent.get(Event::RightKeyboard1)) @@ -158,7 +162,6 @@ bool KidVid::save(Serializer& out) const // Save WAV player state out.putInt(myTape); out.putBool(myFilesFound); - out.putString(mySampleFile); out.putBool(myTapeBusy); out.putBool(myBeep); out.putBool(mySongPlaying); @@ -178,7 +181,6 @@ bool KidVid::load(Serializer& in) // Load WAV player state myTape = in.getInt(); myFilesFound = in.getBool(); - mySampleFile = in.getString(); myTapeBusy = in.getBool(); myBeep = in.getBool(); mySongPlaying = in.getBool(); @@ -195,12 +197,22 @@ bool KidVid::load(Serializer& in) } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void KidVid::openSampleFiles() +const char* KidVid::getFileName() const { static constexpr const char* fileNames[6] = { "KVS3.WAV", "KVS1.WAV", "KVS2.WAV", "KVB3.WAV", "KVB1.WAV", "KVB2.WAV" }; + + int i = myGame == Game::Smurfs ? myTape - 1 : myTape + 2; + if(myTape == 4) i = 3; + + return fileNames[i]; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void KidVid::openSampleFiles() +{ static constexpr uInt32 firstSongPointer[6] = { 44 + 38, 0, @@ -215,10 +227,8 @@ void KidVid::openSampleFiles() int i = myGame == Game::Smurfs ? myTape - 1 : myTape + 2; if(myTape == 4) i = 3; - mySampleFile = myBaseDir + fileNames[i]; - std::ifstream f1, f2; - f1.open(mySampleFile); + f1.open(myBaseDir + getFileName()); f2.open(myBaseDir + "KVSHARED.WAV"); myFilesFound = f1.is_open() && f2.is_open(); @@ -226,7 +236,7 @@ void KidVid::openSampleFiles() #ifdef DEBUG_BUILD if(myFilesFound) cerr << endl - << "found file: " << fileNames[i] << endl + << "found file: " << getFileName() << endl << "found file: " << "KVSHARED.WAV" << endl; #endif @@ -247,8 +257,8 @@ void KidVid::setNextSong() mySongLength = ourSongStart[temp + 1] - ourSongStart[temp]; // Play the WAV file - const string& fileName = (temp < 10) ? myBaseDir + "KVSHARED.WAV" : mySampleFile; - mySound.playWav(fileName, ourSongStart[temp], mySongLength); + const string& fileName = (temp < 10) ? "KVSHARED.WAV" : getFileName(); + mySound.playWav(myBaseDir + fileName, ourSongStart[temp], mySongLength); #ifdef DEBUG_BUILD cerr << fileName << ": " << (ourSongPositions[mySongPointer] & 0x7f) << endl; #endif diff --git a/src/emucore/KidVid.hxx b/src/emucore/KidVid.hxx index 8ffb122a3..5f65711f6 100644 --- a/src/emucore/KidVid.hxx +++ b/src/emucore/KidVid.hxx @@ -89,6 +89,9 @@ class KidVid : public Controller string name() const override { return "KidVid"; } private: + // Get name of the current sample file + const char* getFileName() const; + // Open/close a WAV sample file void openSampleFiles(); @@ -114,8 +117,6 @@ class KidVid : public Controller string myBaseDir; Sound& mySound; - // Path and name of the current sample file - string mySampleFile; // Indicates if the sample files have been found bool myFilesFound{false};