refactored KidVid code a bit

updated doc
This commit is contained in:
Thomas Jentzsch 2022-09-04 18:40:46 +02:00
parent 01e8d29190
commit 69e61fb4e5
4 changed files with 37 additions and 17 deletions

View File

@ -21,7 +21,7 @@
<img src="graphics/stella_icon.png">
<h2><b>A multi-platform Atari 2600 VCS emulator</b></h2>
<h4><b>Release 6.7</b></h4>
<h4><b>Release 7.0</b></h4>
<br>
<h2><b>User's Guide</b></h2>
@ -1048,6 +1048,17 @@
</tr>
</table>
</br>
<p><b>Kid Vid Voice Module (can be remapped via Keyboard Controller)</b></p>
<table BORDER=2>
<tr><th>Function</th> <th>Key</th></tr>
<tr><td>Start game #1</td><td>8 (same as Right Pad Button '1')</td></tr>
<tr><td>Start game #2</td><td>9 (same as Right Pad Button '2')</td></tr>
<tr><td>Start game #3</td><td>0 (same as Right Pad Button '3')</td></tr>
<tr><td>Skip current song</td><td>P (same as Right Pad Button '6')</td></tr>
</table>
</br>
<p><b>CompuMate Controller (cannot be remapped)</b></p>
@ -1072,7 +1083,6 @@
<tr><td>[ </td><td>[ or Shift + 8 </td></tr>
<tr><td>] </td><td>] or Shift + 9 </td></tr>
<tr><td>&quot; </td><td>" (Shift + ') or Shift + 0 </td></tr>
</table>
</br>
@ -5024,8 +5034,7 @@ Ms Pac-Man (Stella extended codes):
<tr><td>CompuMate &#185</td><td>Spectravideo CompuMate (if either left or right is set, CompuMate is used for both).</td></tr>
<tr><td>Lightgun</td><td>Atari XG-1 compatible Light Gun.</td></tr>
<tr><td>MindLink &#185</td><td>MindLink controller.</td></tr>
<tr><td>KidVid</td><td>Kid Vid Voice Module (Right Keyboard controller
buttons 1, 2 and 3 start the games, default mapping is 8, 9 and 0).</br>
<tr><td>KidVid</td><td>Kid Vid Voice Module.</br>
Audio files can be downloaded e.g. from <a href="https://www.atariage.com/2600/archives/KidVidAudio/">AtariAge</a>.
Put unzipped .WAV files into Stella's base directory (see properties
or palette files below for details).</br>

View File

@ -453,7 +453,7 @@ void SoundSDL2::stopWav()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 SoundSDL2::wavSize() const
{
return myWavBuffer ? myWavLen /*SDL_GetQueuedAudioSize(myWavDevice)*/ : 0;
return myWavBuffer ? myWavLen : 0;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -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

View File

@ -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};