...
 
Commits (3)
/**
* A2600EmulatorController - Support for the Atari 2600
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "A2600EmulatorController.h"
namespace DCE
{
A2600EmulatorController::A2600EmulatorController(Game_Player *pGame_Player, A2600EmulatorModel *pEmulatorModel)
: MAMEEmulatorController(pGame_Player, pEmulatorModel)
{
m_pGame_Player = pGame_Player;
m_pEmulatorModel = pEmulatorModel;
}
A2600EmulatorController::~A2600EmulatorController()
{
}
}
/**
* A2600EmulatorController - Support for Atari 2600
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef A2600EMULATORCONTROLLER_H
#define A2600EMULATORCONTROLLER_H
#include "MAMEEmulatorController.h"
#include "A2600EmulatorModel.h"
using namespace std;
namespace DCE
{
class A2600EmulatorController : public MAMEEmulatorController
{
public:
A2600EmulatorController(Game_Player *pGame_Player, A2600EmulatorModel *pEmulatorModel); // ctor
virtual ~A2600EmulatorController(); // dtor
A2600EmulatorModel *m_pEmulatorModel;
};
}
#endif
/**
* A2600EmulatorModel - Atari 2600 System support
*
* Author: Thom Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "A2600EmulatorModel.h"
namespace DCE
{
A2600EmulatorModel::A2600EmulatorModel() : MAMEEmulatorModel()
{
m_sSystemName = "a2600";
}
A2600EmulatorModel::~A2600EmulatorModel()
{
}
}
/**
* A2600EmulatorModel - Atari 2600 Game support
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#ifndef A2600EMULATORMODEL_H
#define A2600EMULATORMODEL_H
#include "MAMEEmulatorModel.h"
namespace DCE
{
class A2600EmulatorModel : public MAMEEmulatorModel
{
public:
A2600EmulatorModel();
virtual ~A2600EmulatorModel();
};
}
#endif
/**
* A5200EmulatorController - Support for the A5200
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "A5200EmulatorController.h"
namespace DCE
{
A5200EmulatorController::A5200EmulatorController(Game_Player *pGame_Player, A5200EmulatorModel *pEmulatorModel)
: SecondGenEmulatorController(pGame_Player, pEmulatorModel)
{
m_pGame_Player = pGame_Player;
m_pEmulatorModel = pEmulatorModel;
}
A5200EmulatorController::~A5200EmulatorController()
{
}
}
/**
* A5200EmulatorController - Support for A5200
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef A5200EMULATORCONTROLLER_H
#define A5200EMULATORCONTROLLER_H
#include "A5200EmulatorModel.h"
#include "SecondGenEmulatorController.h"
using namespace std;
namespace DCE
{
class A5200EmulatorController : public SecondGenEmulatorController
{
public:
A5200EmulatorController(Game_Player *pGame_Player, A5200EmulatorModel *pEmulatorModel); // ctor
virtual ~A5200EmulatorController(); // dtor
A5200EmulatorModel *m_pEmulatorModel;
};
}
#endif
/**
* A5200EmulatorModel - Based on SecondGenEmulatorModel
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#include "A5200EmulatorModel.h"
#include <X11/keysym.h>
#include "DCE/Logger.h"
#include "pluto_main/Define_Button.h"
namespace DCE
{
A5200EmulatorModel::A5200EmulatorModel() : SecondGenEmulatorModel()
{
m_sSystemName = "a5200";
// initializeActionstoKeysyms();
// initializeButtontoKeysyms();
}
A5200EmulatorModel::~A5200EmulatorModel()
{
}
void A5200EmulatorModel::initializeButtontoKeysyms()
{
// SecondGenEmulatorModel::initializeButtontoKeysyms();
// m_mapButtonToKeysyms[BUTTON_Asterisk_CONST] = XK_KP_Add;
}
void A5200EmulatorModel::initializeActionstoKeysyms()
{
/* MESSEmulatorModel::initializeActionstoKeysyms();
m_mapActionsToKeysyms["*"] = make_pair(XK_KP_Add,0);
m_mapActionsToKeysyms["#"] = make_pair(XK_KP_Enter,0);
*/
}
}
/**
* A5200EmulatorModel - Based on SecondGenEmulatorModel
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#ifndef A5200EMULATORMODEL_H
#define A5200EMULATORMODEL_H
#include "SecondGenEmulatorModel.h"
namespace DCE
{
class A5200EmulatorModel : public SecondGenEmulatorModel
{
public:
A5200EmulatorModel();
virtual ~A5200EmulatorModel();
virtual void initializeActionstoKeysyms();
virtual void initializeButtontoKeysyms();
};
}
#endif
/**
* A7800EmulatorController - Support for the Atari 7800
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "A7800EmulatorController.h"
namespace DCE
{
A7800EmulatorController::A7800EmulatorController(Game_Player *pGame_Player, A7800EmulatorModel *pEmulatorModel)
: MAMEEmulatorController(pGame_Player, pEmulatorModel)
{
m_pGame_Player = pGame_Player;
m_pEmulatorModel = pEmulatorModel;
}
A7800EmulatorController::~A7800EmulatorController()
{
}
}
/**
* A7800EmulatorController - Support for Atari 7800
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef A7800EMULATORCONTROLLER_H
#define A7800EMULATORCONTROLLER_H
#include "MAMEEmulatorController.h"
#include "A7800EmulatorModel.h"
using namespace std;
namespace DCE
{
class A7800EmulatorController : public MAMEEmulatorController
{
public:
A7800EmulatorController(Game_Player *pGame_Player, A7800EmulatorModel *pEmulatorModel); // ctor
virtual ~A7800EmulatorController(); // dtor
A7800EmulatorModel *m_pEmulatorModel;
};
}
#endif
/**
* A7800EmulatorModel - Atari 2600 System support
*
* Author: Thom Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "A7800EmulatorModel.h"
namespace DCE
{
A7800EmulatorModel::A7800EmulatorModel() : A2600EmulatorModel()
{
m_sSystemName = "a7800";
}
A7800EmulatorModel::~A7800EmulatorModel()
{
}
}
/**
* A7800EmulatorModel - Atari 7800 Game support
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#ifndef A7800EMULATORMODEL_H
#define A7800EMULATORMODEL_H
#include "A2600EmulatorModel.h"
namespace DCE
{
class A7800EmulatorModel : public A2600EmulatorModel
{
public:
A7800EmulatorModel();
virtual ~A7800EmulatorModel();
};
}
#endif
/**
* Apple2EmulatorController - Support for the Apple //e
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "Apple2EmulatorController.h"
namespace DCE
{
Apple2EmulatorController::Apple2EmulatorController(Game_Player *pGame_Player, Apple2EmulatorModel *pEmulatorModel)
: MAMEEmulatorController(pGame_Player, pEmulatorModel)
{
m_pGame_Player = pGame_Player;
m_pEmulatorModel = pEmulatorModel;
m_pEmulatorModel->m_sSystemName="apple2e";
}
Apple2EmulatorController::~Apple2EmulatorController()
{
}
/* string Apple2EmulatorController::getRomPathFromSlot()
{
string sMedia;
if (!this->getMediaInSlot(sMedia,"flop1"))
{
return "";
}
else
{
return FileUtils::BasePath(sMedia);
}
} */
void Apple2EmulatorController::insertMediaNamed(string sMediaFile, string sSlot)
{
EmulatorController::insertMediaNamed(sMediaFile,"flop1");
}
}
/**
* Apple2EmulatorController - Support for Apple //e
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef APPLE2EMULATORCONTROLLER_H
#define APPLE2EMULATORCONTROLLER_H
#include "MAMEEmulatorController.h"
#include "Apple2EmulatorModel.h"
using namespace std;
namespace DCE
{
class Apple2EmulatorController : public MAMEEmulatorController
{
public:
Apple2EmulatorController(Game_Player *pGame_Player, Apple2EmulatorModel *pEmulatorModel); // ctor
virtual ~Apple2EmulatorController(); // dtor
Apple2EmulatorModel *m_pEmulatorModel;
virtual void insertMediaNamed(string sMediaFile, string sSlot);
// virtual string getRomPathFromSlot();
};
}
#endif
/**
* Apple2EmulatorModel - Apple //e System support
*
* Author: Thom Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "Apple2EmulatorModel.h"
namespace DCE
{
Apple2EmulatorModel::Apple2EmulatorModel() : MAMEEmulatorModel()
{
m_sSystemName = "apple2e";
}
Apple2EmulatorModel::~Apple2EmulatorModel()
{
}
}
/**
* Apple2EmulatorModel - Apple //e support
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#ifndef APPLE2EMULATORMODEL_H
#define APPLE2EMULATORMODEL_H
#include "MAMEEmulatorModel.h"
namespace DCE
{
class Apple2EmulatorModel : public MAMEEmulatorModel
{
public:
Apple2EmulatorModel();
virtual ~Apple2EmulatorModel();
};
}
#endif
This diff is collapsed.
/**
* ATARI800EmulatorController - Support to control the ATARI800 emulator.
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef ATARI800EMULATORCONTROLLER_H
#define ATARI800EMULATORCONTROLLER_H
#include "X11EmulatorController.h"
#include "Atari800EmulatorModel.h"
using namespace std;
namespace DCE
{
class Atari800EmulatorController : public X11EmulatorController
{
public:
Atari800EmulatorController(Game_Player *pGame_Player, Atari800EmulatorModel *pEmulatorModel); // ctor
virtual ~Atari800EmulatorController(); // dtor
Atari800EmulatorModel *m_pEmulatorModel;
virtual bool init();
virtual bool run();
virtual bool stop();
virtual bool pause();
virtual bool unpause();
virtual bool getSnap(long int iPK_Device, int iWidth, int iHeight, char **pData, int& iData_Size);
virtual bool setSpeed(int iSpeed);
virtual bool gotoMenu(int iMenu);
virtual void setMediaPosition(string sMediaPosition);
virtual bool saveState(string& sPosition, string& sText, bool bAutoSave=false, string sAutoSaveName="");
virtual bool loadState(string sPosition);
virtual void insertMediaNamed(string sMediaFile, string sSlot);
bool getRecordingFilename(string sPath, string &sFilename);
virtual bool record();
virtual bool pressButton(int iPK_Button, Message *pMessage);
protected:
private:
virtual string getSlotsAndRoms();
};
}
#endif
/**
* Atari800EmulatorModel - Hold configuration state for emulations based on Atari800
* (http://atari800.sf.net/)
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
* Version: 1.0
*/
#include "Atari800EmulatorModel.h"
#include <X11/keysym.h>
#include "PlutoUtils/FileUtils.h"
#include "PlutoUtils/StringUtils.h"
#include "DCE/Logger.h"
#include "pluto_main/Define_Button.h"
namespace DCE
{
Atari800EmulatorModel::Atari800EmulatorModel()
: X11EmulatorModel()
{
m_sConfigFile = ATARI800_CONFIG_FILE;
m_sConfigFileTemplate = ATARI800_CONFIG_FILE_TEMPLATE;
m_sWindowName = "atari800.atari800";
initializeActionstoKeysyms();
initializeButtontoKeysyms();
m_sEmulatorBinary = "/usr/bin/atari800";
m_sProcessName = "atari800";
m_bChangeRequiresRestart=true;
m_bRunning=false;
m_bHasArgs=true;
m_bCapsLockPressed=false;
m_sArgs="";
m_bCanSaveState=true;
}
Atari800EmulatorModel::~Atari800EmulatorModel()
{
}
string Atari800EmulatorModel::getVideoAccelleration()
{
// come back here later and actually flesh this out.
return "opengl";
}
/**
* Update the /root/.mame/mame.ini file as needed.
*/
bool Atari800EmulatorModel::updateConfig()
{
ConfigurationWriter config(ATARI800_CONFIG_FILE_TEMPLATE, ATARI800_CONFIG_FILE, m_sSystemConfiguration);
config.Add("###WIDTH###",StringUtils::itos(m_iScreenWidth));
config.Add("###HEIGHT###",StringUtils::itos(m_iScreenHeight));
return config.Write();
}
void Atari800EmulatorModel::initializeActionstoKeysyms()
{
m_mapActionsToKeysyms["0"] = make_pair(XK_0,0);
m_mapActionsToKeysyms["1"] = make_pair(XK_1,0);
m_mapActionsToKeysyms["2"] = make_pair(XK_2,0);
m_mapActionsToKeysyms["3"] = make_pair(XK_3,0);
m_mapActionsToKeysyms["4"] = make_pair(XK_4,0);
m_mapActionsToKeysyms["5"] = make_pair(XK_5,0);
m_mapActionsToKeysyms["6"] = make_pair(XK_6,0);
m_mapActionsToKeysyms["7"] = make_pair(XK_7,0);
m_mapActionsToKeysyms["8"] = make_pair(XK_8,0);
m_mapActionsToKeysyms["9"] = make_pair(XK_9,0);
m_mapActionsToKeysyms["LOAD_STATE"] = make_pair(XK_F11,0);
m_mapActionsToKeysyms["SAVE_STATE"] = make_pair(XK_F11,XK_Shift_L);
m_mapActionsToKeysyms["UI_ENTER"] = make_pair(XK_F1,0);
m_mapActionsToKeysyms["UI_EXIT"] = make_pair(XK_F1,0);
m_mapActionsToKeysyms["GET_SNAPSHOT"] = make_pair(XK_F10,0);
m_mapActionsToKeysyms["PAUSE"] = make_pair(XK_Pause,0);
m_mapActionsToKeysyms["UNPAUSE"] = make_pair(XK_Scroll_Lock,0);
m_mapActionsToKeysyms["RESET"] = make_pair(XK_F5,XK_Shift_L);
m_mapActionsToKeysyms["OPTION"] = make_pair(XK_F2,0);
m_mapActionsToKeysyms["SELECT"] = make_pair(XK_F3,0);
m_mapActionsToKeysyms["START"] = make_pair(XK_F4,0);
// overridden by subclass.
// todo: come back here and fill this in.
}
void Atari800EmulatorModel::initializeButtontoKeysyms()
{
// Because Atari800 doesn't do "authentic" key mapping ala MAME/MESS/UME,
// I have decided instead to override pressButton, and handle the crazy
// logic entirely there. I know I will regret it. -tschak
}
}
/**
* Atari800EmulatorModel - Model for Atari 8-bit machines.
*/
#ifndef ATARI800EMULATORMODEL_H
#define ATARI800EMULATORMODEL_H
#include "X11EmulatorModel.h"
#define ATARI800_CONFIG_FILE_TEMPLATE "/usr/pluto/templates/atari800.cfg.template"
#define ATARI800_CONFIG_FILE "/root/.atari800.cfg"
namespace DCE
{
class Atari800EmulatorModel : public X11EmulatorModel
{
public:
Atari800EmulatorModel();
virtual ~Atari800EmulatorModel();
bool m_bCapsLockPressed;
protected:
virtual void initializeActionstoKeysyms(); // set key mappings for ATARI800.
virtual void initializeButtontoKeysyms(); // keyboard mappings
virtual bool updateConfig();
virtual string getVideoAccelleration();
};
}
#endif
/**
*
* C64EmulatorController - C-64 Emulation Support
*
* Author: Thom Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "C64EmulatorController.h"
namespace DCE
{
C64EmulatorController::C64EmulatorController(Game_Player *pGame_Player, C64EmulatorModel *pEmulatorModel)
: VICEEmulatorController(pGame_Player, pEmulatorModel)
{
m_pGame_Player = pGame_Player;
m_pEmulatorModel = pEmulatorModel;
}
C64EmulatorController::~C64EmulatorController()
{
}
void C64EmulatorController::insertMediaNamed(string sMediaFile, string sSlot)
{
if (StringUtils::ToLower(sMediaFile).find(".crt") != string::npos)
{
sSlot = "cartcrt";
}
if (StringUtils::ToLower(sMediaFile).find(".d64") != string::npos)
{
sSlot = "autostart";
}
if (StringUtils::ToLower(sMediaFile).find(".g64") != string::npos)
{
sSlot = "autostart";
}
if (StringUtils::ToLower(sMediaFile).find(".t64") != string::npos)
{
sSlot = "autostart";
}
EmulatorController::insertMediaNamed(sMediaFile,sSlot);
}
}
/**
*
* C64EmulatorController - Support for C64
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef C64EMULATORCONTROLLER_H
#define C64EMULATORCONTROLLER_H
#include "VICEEmulatorController.h"
#include "C64EmulatorModel.h"
using namespace std;
namespace DCE
{
class C64EmulatorController : public VICEEmulatorController
{
public:
C64EmulatorController(Game_Player *pGame_Player, C64EmulatorModel *pEmulatorModel); // ctor
virtual ~C64EmulatorController(); // dtor
C64EmulatorModel *m_pEmulatorModel;
virtual void insertMediaNamed(string sMediaFile, string sSlot);
};
}
#endif
/**
*
* C64EmulatorModel - C-64 Emulation Support
*
* Author: Thom Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "C64EmulatorModel.h"
namespace DCE
{
C64EmulatorModel::C64EmulatorModel() : VICEEmulatorModel()
{
m_sEmulatorBinary += "x64";
m_sProcessName = "x64";
}
C64EmulatorModel::~C64EmulatorModel()
{
}
bool C64EmulatorModel::updateConfig()
{
return VICEEmulatorModel::updateConfig();
}
}
/**
*
* C64EmulatorModel - Commodore 64 Emulation Support
*
* Author: Thom Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef C64EMULATORMODEL_H
#define C64EMULATORMODEL_H
#include "VICEEmulatorModel.h"
namespace DCE
{
class C64EmulatorModel : public VICEEmulatorModel
{
public:
C64EmulatorModel();
virtual ~C64EmulatorModel();
virtual bool updateConfig();
};
}
#endif
2011-11-22 Thom Cherryhomes <thom.cherryhomes@gmail.com>
* Fix crash caused by CMD_Stop_Media being called (due to pending message) when Game Player
restarts
* Implement CMD_Pause_Media, CMD_Restart_Media, and initial CMD_Change_Playback_Speed
in Game Player, and associated models and controllers for MAME.
* Clean up spurious logging messages for parts that I know works (demoting them from
LV_CRITICAL, to LV_WARNING or LV_STATUS
* Remove spurious check for App Server in EmulatorController, as the relevant function
is now being called inside Game_Player
/**
* ColecoVisionEmulatorController - Support for the ColecoVision
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "ColecoVisionEmulatorController.h"
namespace DCE
{
ColecoVisionEmulatorController::ColecoVisionEmulatorController(Game_Player *pGame_Player, ColecoVisionEmulatorModel *pEmulatorModel)
: SecondGenEmulatorController(pGame_Player, pEmulatorModel)
{
m_pGame_Player = pGame_Player;
m_pEmulatorModel = pEmulatorModel;
}
ColecoVisionEmulatorController::~ColecoVisionEmulatorController()
{
}
}
/**
* ColecoVisionEmulatorController - Support for ColecoVision
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef COLECOVISIONEMULATORCONTROLLER_H
#define COLECOVISIONEMULATORCONTROLLER_H
#include "ColecoVisionEmulatorModel.h"
#include "SecondGenEmulatorController.h"
using namespace std;
namespace DCE
{
class ColecoVisionEmulatorController : public SecondGenEmulatorController
{
public:
ColecoVisionEmulatorController(Game_Player *pGame_Player, ColecoVisionEmulatorModel *pEmulatorModel); // ctor
virtual ~ColecoVisionEmulatorController(); // dtor
ColecoVisionEmulatorModel *m_pEmulatorModel;
};
}
#endif
/**
* ColecoVisionEmulatorModel - Based on SecondGenEmulatorModel
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#include "ColecoVisionEmulatorModel.h"
#include <X11/keysym.h>
#include "DCE/Logger.h"
#include "pluto_main/Define_Button.h"
namespace DCE
{
ColecoVisionEmulatorModel::ColecoVisionEmulatorModel() : SecondGenEmulatorModel()
{
m_sSystemName = "coleco";
initializeActionstoKeysyms();
initializeButtontoKeysyms();
}
ColecoVisionEmulatorModel::~ColecoVisionEmulatorModel()
{
}
void ColecoVisionEmulatorModel::initializeActionstoKeysyms()
{
/* MESSEmulatorModel::initializeActionstoKeysyms();
m_mapActionsToKeysyms["*"] = make_pair(XK_KP_Add,0);
m_mapActionsToKeysyms["#"] = make_pair(XK_KP_Subtract,0); */
}
void ColecoVisionEmulatorModel::initializeButtontoKeysyms()
{
/* m_mapButtonToKeysyms[BUTTON_asterisk_CONST] = XK_KP_Add;
m_mapButtonToKeysyms[BUTTON_Pound_CONST] = XK_KP_Subtract; */
}
bool ColecoVisionEmulatorModel::updateConfig()
{
MAMEEmulatorModel::updateConfig();
/*
ConfigurationWriter keypadConfig(COLECO_CONFIG_FILE_TEMPLATE, COLECO_CONFIG_FILE, "");
return keypadConfig.Write(); */
}
}
/**
* ColecoVisionEmulatorModel - Based on SecondGenEmulatorModel
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*/
#ifndef COLECOVISIONEMULATORMODEL_H
#define COLECOVISIONEMULATORMODEL_H
#include "SecondGenEmulatorModel.h"
#define COLECO_CONFIG_FILE_TEMPLATE "/usr/pluto/templates/coleco.cfg.template"
#define COLECO_CONFIG_FILE "/usr/pluto/templates/coleco.cfg"
namespace DCE
{
class ColecoVisionEmulatorModel : public SecondGenEmulatorModel
{
public:
ColecoVisionEmulatorModel();
virtual ~ColecoVisionEmulatorModel();
virtual void initializeActionstoKeysyms();
virtual void initializeButtontoKeysyms();
virtual bool updateConfig();
};
}
#endif
/**
* ConfigurationWriter - A dirt simple engine for dealing with
* text based configuration files common to emulator engines.
* offers a simple method to replace placeholder items with
* model state.
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#include "DCE/Logger.h"
#include "PlutoUtils/FileUtils.h"
#include "PlutoUtils/StringUtils.h"
#include "ConfigurationWriter.h"
namespace DCE
{
ConfigurationWriter::ConfigurationWriter(string sTemplateFilename, string sTargetFilename, string sSystemConfiguration)
{
m_sTargetFilename = sTargetFilename;
m_sTemplateFilename = sTemplateFilename;
m_sSystemConfiguration = sSystemConfiguration;
m_bStopIfItemMissing=false;
m_mapConfigurationItems.clear();
}
ConfigurationWriter::~ConfigurationWriter()
{
m_sTargetFilename="";
m_sTemplateFilename="";
m_mapConfigurationItems.clear();
}
bool ConfigurationWriter::Process()
{
string sBuffer;
if (m_sTemplateFilename.empty() && m_sTargetFilename.empty())
{
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"ConfigurationWriter::process() Both Config File Template and Destination Config File names were not specified, bailing.");
return false;
}
if (m_sTemplateFilename.empty())
{
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"ConfigurationWriter::process() Config file template not specified, bailing.");
return false;
}
if (m_sTargetFilename.empty())
{
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"ConfigurationWriter::process() Config file destination not specified, bailing.");
return false;
}
if (!FileUtils::ReadTextFile(m_sTemplateFilename, sBuffer))
{
// Could not read file.
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"ConfigurationWriter::process() Could not read config template file %s",m_sTemplateFilename.c_str());
return false;
}
else
{
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() read config file template %s successfully.",m_sTemplateFilename.c_str());
}
// Merge in System Configuration Items
if (!m_sSystemConfiguration.empty())
{
vector<string> vectLines;
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() - System Configuration part of URL, parsing.");
// Split into \n and then split each into values.
StringUtils::Tokenize(m_sSystemConfiguration,"\n",vectLines);
for (vector<string>::iterator it=vectLines.begin(); it!=vectLines.end(); ++it)
{
string sItem = *it;
string::size_type pos=0;
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() - Line %s",sItem.c_str());
string sParameter = StringUtils::Tokenize(sItem,"|",pos);
string sValue = StringUtils::Tokenize(sItem,"|",pos);
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() - sParameter %s sValue %s",
sParameter.c_str(),
sValue.c_str());
m_mapConfigurationItems[sParameter] = sValue;
}
}
// Substitute template variables, as needed.
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() - template file %s - %d config items found.",m_sTemplateFilename.c_str(),m_mapConfigurationItems.size());
for (map<string, string>::iterator it=m_mapConfigurationItems.begin();
it != m_mapConfigurationItems.end();
++it)
{
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() Replacing %s, with %s",it->first.c_str(), it->second.c_str());
sBuffer = StringUtils::Replace(sBuffer,it->first, it->second);
}
// Finally, write out the file.
if (!FileUtils::DirExists(FileUtils::BasePath(m_sTargetFilename)))
{
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"ConfigurationWriter::process() - Configuration File Path %s does not exist, creating.",FileUtils::BasePath(m_sTargetFilename).c_str());
string sCmd = "mkdir -p "+FileUtils::BasePath(m_sTargetFilename);
system(sCmd.c_str());
}
if (!FileUtils::WriteTextFile(m_sTargetFilename, sBuffer))
{
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"ConfigurationWriter::process() - Could not write text file %s",m_sTargetFilename.c_str());
}
else
{
// Config file written successfully.
LoggerWrapper::GetInstance()->Write(LV_STATUS,"ConfigurationWriter::process() - Config file %s written successfully.",m_sTargetFilename.c_str());
}
return true;
}
bool ConfigurationWriter::Write()
{
LoggerWrapper::GetInstance()->Write(LV_STATUS,"Attempting to write configuration file %s from template %s",
m_sTargetFilename.c_str(),
m_sTemplateFilename.c_str());
return Process();
}
void ConfigurationWriter::StopIfItemMissing_set(bool bStopIfItemMissing)
{
m_bStopIfItemMissing=bStopIfItemMissing;
}
}
/**
* ConfigurationWriter - A dirt simple engine for dealing with
* text based configuration files common to emulator engines.
* offers a simple method to replace placeholder items with
* model state.
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef CONFIGURATIONWRITER_H
#define CONFIGURATIONWRITER_H
#include <vector>
#include <string>
using namespace std;
namespace DCE
{
class ConfigurationWriter
{
private:
string m_sSystemConfiguration;
map<string, string> m_mapConfigurationItems;
string m_sTargetFilename;
string m_sTemplateFilename;
bool m_bStopIfItemMissing;
bool Process();
public:
ConfigurationWriter(string sTemplateFilename, string sTargetFilename, string sSystemConfiguration = "");
~ConfigurationWriter();
void Add(string sKey, string sVal) { m_mapConfigurationItems[sKey] = sVal; };
void Delete(string sKey) { m_mapConfigurationItems.erase(sKey); }
bool Write();
void StopIfItemMissing_set(bool bStopIfItemMissing);
};
}
#endif
This diff is collapsed.
/**
* EmulatorController - A base class to implement a controller
* to control emulation engines.
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
*/
#ifndef EMULATORCONTROLLER_H
#define EMULATORCONTROLLER_H
#include "EmulatorModel.h"
#include "Game_Player.h"
#include "Gen_Devices/AllCommandsRequests.h"
#include "DCE/Message.h"
#include <list>
namespace DCE
{
class EmulatorModel;
class Game_Player;
class EmulatorController
{
friend class Game_Player;
private:
protected:
Game_Player *m_pGame_Player;
EmulatorModel *m_pEmulatorModel;
virtual bool sanityCheck(string sFuncName);
public:
EmulatorController(Game_Player *pGame_Player, EmulatorModel *pEmulatorModel);
virtual ~EmulatorController();
// not so pure virtuals. :P
virtual bool init();
virtual bool run();
virtual bool stop();
virtual void EmulatorHasExited(int iExit_Code);
virtual void insertMediaNamed(string sMediaFile, string sSlot="default");
virtual void ejectMediaFromSlot(string sSlot="default");
virtual void ejectAllMedia();
virtual bool getMediaInSlot(string& sMediaFile, string sSlot="default");
virtual void updateDisks(string sMediaFile);
virtual void setStreaming(bool bStreaming);
virtual void setStreamingMaster(bool bStreamingMaster);
virtual void setHostName(string sHostName);
virtual void setStreamID(int iStreamID);
virtual void setMediaPosition(string sMediaPosition);
virtual void setOrbiter(long int dwPK_Device_Orbiter);
virtual void setSystemConfiguration(string sSystemConfiguration);
// Pure virtuals
virtual bool doAction(string sAction) = 0;
virtual void doMediaSwap(string sMediaFilename, string sSlot) = 0;
virtual void pleaseResend() = 0;
// actions
virtual bool P1Start();
virtual bool P2Start();
virtual bool P3Start();
virtual bool P4Start();
virtual bool coin1();
virtual bool coin2();
virtual bool pause();
virtual bool unpause();
virtual bool pressButton(int iPK_Button, Message *pMessage) = 0;
virtual bool pressClick(int iPositionX, int iPositionY, Message *pMessage) = 0;
virtual bool setSpeed(int iSpeed);
virtual bool getSnap(long int iPK_Device, int iWidth, int iHeight, char **pData, int& iData_Size) = 0;
virtual bool gotoMenu(int iMenu);
virtual bool uiUp();
virtual bool uiDown();
virtual bool uiLeft();
virtual bool uiRight();
virtual bool uiOK();
virtual bool press0(Message *pMessage);
virtual bool press1(Message *pMessage);
virtual bool press2(Message *pMessage);
virtual bool press3(Message *pMessage);
virtual bool press4(Message *pMessage);
virtual bool press5(Message *pMessage);
virtual bool press6(Message *pMessage);
virtual bool press7(Message *pMessage);
virtual bool press8(Message *pMessage);
virtual bool press9(Message *pMessage);
virtual bool pressAsterisk();
virtual bool pressPound();
virtual bool uiBack();
virtual bool saveState(string& sPosition, string& sText,bool bAutoSave=false,string sAutoSaveName="") = 0;
virtual bool loadState(string sPosition) = 0;
virtual bool emulatorExited();
virtual bool service1();
virtual bool service2();
virtual bool start();
virtual bool select();
virtual bool option();
virtual bool reset();
virtual bool record();
virtual bool gracefulExit();
virtual bool selectA();
virtual bool selectB();
bool canSaveState();
virtual void getOption(string sPath, string &sValue_To_Assign, Message *pMessage);
virtual void setOption(string sPath, string sValue_To_Assign, Message *pMessage);
virtual void waitForEmulatorExit();
virtual void swapMedia(int iSlot_Number, string sSlot);
};
}
#endif
/**
* EmulatorFactory - given a media type, instantiate the needed controller
* and model.
*
* return the controller object.
*
*/
#include "EmulatorFactory.h"
#include "pluto_main/Define_MediaType.h"
#include "MAMEEmulatorController.h"
#include "MAMEEmulatorModel.h"
#include "A2600EmulatorModel.h"
#include "A2600EmulatorController.h"
#include "StellaEmulatorModel.h"
#include "StellaEmulatorController.h"
#include "A7800EmulatorController.h"
#include "IntellivisionEmulatorModel.h"
#include "IntellivisionEmulatorController.h"
#include "A5200EmulatorModel.h"
#include "A5200EmulatorController.h"
#include "ColecoVisionEmulatorModel.h"
#include "ColecoVisionEmulatorController.h"
#include "NESEmulatorModel.h"
#include "NESEmulatorController.h"
#include "FamicomEmulatorModel.h"
#include "FamicomEmulatorController.h"
#include "SG1000EmulatorModel.h"
#include "SG1000EmulatorController.h"
#include "SMSEmulatorModel.h"
#include "SMSEmulatorController.h"
#include "GenesisEmulatorModel.h"
#include "GenesisEmulatorController.h"
#include "MegadriveEmulatorModel.h"
#include "MegadriveEmulatorController.h"
#include "PCEngineEmulatorModel.h"
#include "PCEngineEmulatorController.h"
#include "TG16EmulatorModel.h"
#include "TG16EmulatorController.h"
#include "SGXEmulatorModel.h"
#include "SGXEmulatorController.h"
#include "SNESEmulatorModel.h"
#include "SNESEmulatorController.h"
#include "VectrexEmulatorModel.h"
#include "VectrexEmulatorController.h"
#include "VIC20EmulatorModel.h"
#include "VIC20EmulatorController.h"
#include "C64EmulatorModel.h"
#include "C64EmulatorController.h"
#include "Apple2EmulatorModel.h"
#include "Apple2EmulatorController.h"
#include "Atari800EmulatorModel.h"
#include "Atari800EmulatorController.h"
#include "TI994AEmulatorModel.h"
#include "TI994AEmulatorController.h"
#
using namespace std;
namespace DCE
{
EmulatorFactory::EmulatorFactory(Game_Player *pGamePlayer)
{
m_pGame_Player = pGamePlayer;
}
EmulatorFactory::~EmulatorFactory()
{
for (map<int, EmulatorController *>::iterator it = m_mapEmulatorControllerForMediaType.begin();
it != m_mapEmulatorControllerForMediaType.end();
++it)
{
delete (*it).second;
}
m_mapEmulatorControllerForMediaType.clear();
}
void EmulatorFactory::addEmulatorForMediaType(int iPK_MediaType, EmulatorController *pEmulatorController)
{
if (!pEmulatorController)
{
LoggerWrapper::GetInstance()->Write(LV_CRITICAL,"EmulatorFactory::addEmulatorForMediaType(%d) pEmulatorController was null. Not adding.",iPK_MediaType);
}
else
{
m_mapEmulatorControllerForMediaType[iPK_MediaType] = pEmulatorController;
pEmulatorController->init(); // call any house cleaning functions needed.
}
}
EmulatorController* EmulatorFactory::getEmulatorForMediaType(int iPK_MediaType)
{
map<int, EmulatorController*>::iterator it=m_mapEmulatorControllerForMediaType.find(iPK_MediaType);
return it == m_mapEmulatorControllerForMediaType.end() ? NULL : (*it).second;
}
/** Register Game model/controllers here. Remember to add the headers up top! */
bool EmulatorFactory::init()
{
addEmulatorForMediaType(MEDIATYPE_lmce_Game_CONST,new MAMEEmulatorController(m_pGame_Player, new MAMEEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_a2600_CONST,new StellaEmulatorController(m_pGame_Player, new StellaEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_a7800_CONST,new A7800EmulatorController(m_pGame_Player, new A7800EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_intv_CONST,new IntellivisionEmulatorController(m_pGame_Player, new IntellivisionEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_a5200_CONST,new A5200EmulatorController(m_pGame_Player, new A5200EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_coleco_CONST,new ColecoVisionEmulatorController(m_pGame_Player, new ColecoVisionEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_nes_CONST,new NESEmulatorController(m_pGame_Player, new NESEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_famicom_CONST,new FamicomEmulatorController(m_pGame_Player, new FamicomEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_sg1000_CONST,new SG1000EmulatorController(m_pGame_Player, new SG1000EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_sms_CONST,new SMSEmulatorController(m_pGame_Player, new SMSEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_genesis_CONST,new GenesisEmulatorController(m_pGame_Player, new GenesisEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_megadriv_CONST,new MegadriveEmulatorController(m_pGame_Player, new MegadriveEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_pce_CONST,new PCEngineEmulatorController(m_pGame_Player, new PCEngineEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_tg16_CONST,new TG16EmulatorController(m_pGame_Player, new TG16EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_sgx_CONST,new SGXEmulatorController(m_pGame_Player, new SGXEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_snes_CONST,new SNESEmulatorController(m_pGame_Player, new SNESEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_vectrex_CONST,new VectrexEmulatorController(m_pGame_Player, new VectrexEmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_vic20_CONST,new VIC20EmulatorController(m_pGame_Player, new VIC20EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_c64_CONST,new C64EmulatorController(m_pGame_Player, new C64EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_apple2_CONST,new Apple2EmulatorController(m_pGame_Player, new Apple2EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_Atari800_CONST,new Atari800EmulatorController(m_pGame_Player, new Atari800EmulatorModel()));
addEmulatorForMediaType(MEDIATYPE_lmce_Game_TI99_CONST,new TI994AEmulatorController(m_pGame_Player, new TI994AEmulatorModel()));
return true;
}
}
/**
* EmulatorFactory - given a media type, instantiate the needed controller
* and model.
*
* return the controller object.
*
*/
#ifndef EMULATORFACTORY_H
#define EMULATORFACTORY_H
#include "EmulatorController.h"
#include "Game_Player.h"
namespace DCE
{
class Game_Player;
class EmulatorController;
class EmulatorFactory
{
public:
Game_Player *m_pGame_Player;
EmulatorFactory(Game_Player *pGamePlayer);
~EmulatorFactory();
bool init();
void addEmulatorForMediaType(int iPK_MediaType, EmulatorController *pEmulatorController);
EmulatorController* getEmulatorForMediaType(int iPK_MediaType);
private:
map<int, EmulatorController *> m_mapEmulatorControllerForMediaType;
bool createEmulatorForMediaType(int iPK_MediaType);
};
}
#endif
/**
* EmulatorModel - Creates a simple model that can be used
* to hold configuration and state information for the
* emulator in question
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
* Version: 1.0
*/
#include "EmulatorModel.h"
#include "DCE/Logger.h"
#include "PlutoUtils/FileUtils.h"
#include "PlutoUtils/StringUtils.h"
using namespace std;
namespace DCE
{
EmulatorModel::EmulatorModel()
{
m_bRunning_set(false);
m_bHasArgs=true;
m_bIsPaused=false;
m_sArgs="";
m_sConfigFile="";
m_sConfigFileTemplate="";
m_sVideoAccelleration="";
m_bChangeRequiresRestart=true;
m_iSpeed=1000; // 1x speed when initialized.
m_iActiveMenu=0;
m_iStreamID=0;
m_sMediaPosition="";
m_bIsStreaming=false;
m_bIsStreamingSource=false;
m_tStreamingClientLaunchDelay=3000000; // 3 sec delay by default.
m_bIsRecording=false;
m_bCanSaveState=false; // assume that emulator can't save state unless overriden.
m_iExit_Code=-1; // -1 = hasn't started yet.
m_bEmitsMenuChanges=false; // assume emulator can't emit menu changes unless patched.
m_iCurrentDisk=0;
}
EmulatorModel::~EmulatorModel()
{
m_bRunning_set(false);
m_bIsPaused=false;
m_sConfigFile.clear();
m_sConfigFileTemplate.clear();
m_mapMedia.clear();
m_iActiveMenu=0;
m_iStreamID=0;
m_iSpeed=0;
m_sMediaPosition="";
m_bIsStreaming=false;
m_bIsStreamingSource=false;
m_sHostName="";
m_bIsRecording=false;
m_iExit_Code=-1;
m_dequeDisks.clear();
m_iCurrentDisk=0;
}
void EmulatorModel::coldReset()
{
m_bRunning_set(false);
m_bIsPaused=false;
m_iSpeed=1000; // 1x speed when initialized.
m_iActiveMenu=0;
m_iStreamID=0;
m_bIsStreaming=false;
m_bIsStreamingSource=false;
m_bIsRecording=false;
}
}
/**
* EmulatorModel - Creates a simple model that can be used
* to hold configuration and state information for the
* emulator in question
*
* Author: Thomas Cherryhomes <thom.cherryhomes@gmail.com>
*
* Version: 1.0
*/
#ifndef EMULATORMODEL_H
#define EMULATORMODEL_H
using namespace std;