2009-03-16 00:23:42 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2015-01-01 03:49:32 +00:00
|
|
|
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2009-03-16 00:23:42 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2009-03-16 00:23:42 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2009-03-16 00:23:42 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#ifndef KIDVID_HXX
|
|
|
|
#define KIDVID_HXX
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
|
|
|
|
#include "bspf.hxx"
|
|
|
|
#include "Control.hxx"
|
|
|
|
#include "Event.hxx"
|
|
|
|
|
|
|
|
/**
|
|
|
|
The KidVid Voice Module, created by Coleco. This class emulates the
|
|
|
|
KVVM cassette player by mixing WAV data into the sound stream. The
|
|
|
|
WAV files are located at:
|
|
|
|
|
|
|
|
http://www.atariage.com/2600/archives/KidVidAudio/index.html
|
|
|
|
|
|
|
|
This code was heavily borrowed from z26.
|
|
|
|
|
|
|
|
@author Stephen Anthony & z26 team
|
2009-05-13 13:55:40 +00:00
|
|
|
@version $Id$
|
2009-03-16 00:23:42 +00:00
|
|
|
*/
|
|
|
|
class KidVid : public Controller
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
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 system The system using this controller
|
|
|
|
@param md5sum The md5 of the ROM using this controller
|
|
|
|
*/
|
|
|
|
KidVid(Jack jack, const Event& event, const System& system,
|
|
|
|
const string& md5sum);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor
|
|
|
|
*/
|
|
|
|
virtual ~KidVid();
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Update the entire digital and analog pin state according to the
|
|
|
|
events currently set.
|
|
|
|
*/
|
|
|
|
void update();
|
|
|
|
|
|
|
|
private:
|
|
|
|
// Open/close a WAV sample file
|
|
|
|
void openSampleFile();
|
|
|
|
void closeSampleFile();
|
|
|
|
|
|
|
|
// Jump to next song in the sequence
|
|
|
|
void setNextSong();
|
|
|
|
|
|
|
|
// Generate next sample byte
|
|
|
|
// TODO - rework this, perhaps send directly to sound class
|
|
|
|
void getNextSampleByte();
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum {
|
|
|
|
KVSMURFS = 0x44,
|
|
|
|
KVBBEARS = 0x48,
|
|
|
|
KVBLOCKS = 6, /* number of bytes / block */
|
|
|
|
KVBLOCKBITS = KVBLOCKS*8 /* number of bits / block */
|
|
|
|
};
|
|
|
|
|
|
|
|
// Whether the KidVid device is enabled (only for games that it
|
|
|
|
// supports, and if it's plugged into the right port
|
|
|
|
bool myEnabled;
|
|
|
|
|
|
|
|
// The file handles for the WAV files
|
|
|
|
FILE *mySampleFile, *mySharedSampleFile;
|
|
|
|
|
|
|
|
// Indicates if sample files have been successfully opened
|
|
|
|
bool myFileOpened;
|
|
|
|
|
|
|
|
// Is the tape currently 'busy' / in use?
|
|
|
|
bool myTapeBusy;
|
|
|
|
|
|
|
|
uInt32 myFilePointer, mySongCounter;
|
|
|
|
bool myBeep, mySharedData;
|
|
|
|
uInt8 mySampleByte;
|
2011-12-28 22:38:45 +00:00
|
|
|
uInt32 myGame, myTape;
|
|
|
|
uInt32 myIdx, myBlock, myBlockIdx;
|
2009-03-16 00:23:42 +00:00
|
|
|
|
|
|
|
// Number of blocks and data on tape
|
|
|
|
static const uInt8 ourKVBlocks[6];
|
|
|
|
static const uInt8 ourKVData[6*8];
|
|
|
|
|
|
|
|
static const uInt8 ourSongPositions[44+38+42+62+80+62];
|
|
|
|
static const uInt32 ourSongStart[104];
|
2015-04-26 19:02:42 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Following constructors and assignment operators not supported
|
|
|
|
KidVid() = delete;
|
|
|
|
KidVid(const KidVid&) = delete;
|
|
|
|
KidVid(KidVid&&) = delete;
|
|
|
|
KidVid& operator=(const KidVid&) = delete;
|
|
|
|
KidVid& operator=(KidVid&&) = delete;
|
2009-03-16 00:23:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|