-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Imported GMC support from older VCC repo
- Loading branch information
1 parent
08756fc
commit 4ca15ab
Showing
17 changed files
with
1,481 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#include "Cartridge.h" | ||
|
||
|
||
namespace detail | ||
{ | ||
void NullAssetCartridgeLine(unsigned char) {} | ||
void NullAddMenuItem(const char *, int, int) {} | ||
} | ||
|
||
|
||
Cartridge* Cartridge::m_Singleton(nullptr); | ||
|
||
|
||
Cartridge::Cartridge(std::string name, std::string catalogId) | ||
: | ||
m_Name(move(name)), | ||
m_CatalogId(move(catalogId)), | ||
AssetCartridgeLinePtr(detail::NullAssetCartridgeLine), | ||
AddMenuItemPtr(detail::NullAddMenuItem) | ||
{ | ||
if (m_Singleton) | ||
{ | ||
throw std::runtime_error("Cartridge instance already created."); | ||
} | ||
|
||
m_Singleton = this; | ||
} | ||
|
||
|
||
|
||
Cartridge::~Cartridge() | ||
{ | ||
m_Singleton = nullptr; | ||
} | ||
|
||
|
||
|
||
|
||
void Cartridge::LoadConfiguration(const std::string& /*filename*/) | ||
{ | ||
} | ||
|
||
|
||
void Cartridge::LoadMenu() | ||
{ | ||
} | ||
|
||
|
||
|
||
|
||
std::string Cartridge::GetName() const | ||
{ | ||
return m_Name; | ||
} | ||
|
||
|
||
std::string Cartridge::GetCatalogId() const | ||
{ | ||
return m_CatalogId; | ||
} | ||
|
||
|
||
|
||
|
||
void Cartridge::SetCartLineAssertCallback(SETCART callback) | ||
{ | ||
AssetCartridgeLinePtr = callback; | ||
} | ||
|
||
|
||
void Cartridge::SetConfigurationPath(std::string path) | ||
{ | ||
m_ConfigurationPath = move(path); | ||
LoadConfiguration(m_ConfigurationPath); | ||
LoadMenu(); | ||
} | ||
|
||
|
||
void Cartridge::SetMenuBuilderCallback(DYNAMICMENUCALLBACK callback) | ||
{ | ||
AddMenuItemPtr = callback; | ||
} | ||
|
||
|
||
|
||
std::string Cartridge::GetStatusMessage() const | ||
{ | ||
return std::string(); | ||
} | ||
|
||
|
||
void Cartridge::OnMenuItemSelected(unsigned char /*menuId*/) | ||
{ | ||
|
||
} | ||
|
||
|
||
|
||
|
||
void Cartridge::OnReset() | ||
{} | ||
|
||
|
||
|
||
|
||
unsigned short Cartridge::UpdateAudio() | ||
{ | ||
return 0; | ||
} | ||
|
||
|
||
|
||
|
||
unsigned char Cartridge::OnReadMemory(unsigned short /*address*/) const | ||
{ | ||
return 0; | ||
} | ||
|
||
|
||
void Cartridge::OnWritePort(unsigned char /*port*/, unsigned char /*data*/) | ||
{} | ||
|
||
|
||
unsigned char Cartridge::OnReadPort(unsigned char /*port*/) const | ||
{ | ||
return 0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
#pragma once | ||
#include "CartridgeTrampolines.h" | ||
#include <string> | ||
|
||
|
||
class Cartridge | ||
{ | ||
protected: | ||
|
||
explicit Cartridge(std::string name, std::string catalogId = std::string()); | ||
|
||
|
||
public: | ||
|
||
virtual ~Cartridge(); | ||
|
||
virtual std::string GetName() const; | ||
virtual std::string GetCatalogId() const; | ||
|
||
virtual void SetCartLineAssertCallback(SETCART callback); | ||
virtual void SetMenuBuilderCallback(DYNAMICMENUCALLBACK addMenuCallback); | ||
virtual void SetConfigurationPath(std::string path); | ||
|
||
virtual std::string GetStatusMessage() const; | ||
virtual void OnMenuItemSelected(unsigned char menuId); | ||
|
||
virtual void OnReset(); | ||
virtual unsigned short UpdateAudio(); | ||
virtual unsigned char OnReadMemory(unsigned short address) const; | ||
virtual void OnWritePort(unsigned char port, unsigned char data); | ||
virtual unsigned char OnReadPort(unsigned char port) const; | ||
|
||
|
||
protected: | ||
|
||
enum class ItemType | ||
{ | ||
Head, | ||
Slave, | ||
StandAlone | ||
}; | ||
|
||
void AssetCartridgeLine(bool state) | ||
{ | ||
AssetCartridgeLinePtr(state); | ||
} | ||
|
||
void AddMenuSeparator() | ||
{ | ||
AddMenuItem("", 6000, ItemType::Head); | ||
} | ||
|
||
void AddMenuItem(const std::string& name, int id, ItemType type) | ||
{ | ||
AddMenuItemPtr(name.c_str(), id, static_cast<int>(type)); | ||
} | ||
|
||
virtual void LoadConfiguration(const std::string& filename); | ||
virtual void LoadMenu(); | ||
|
||
|
||
|
||
private: | ||
|
||
friend void ModuleName(char *ModName, char *CatNumber, DYNAMICMENUCALLBACK addMenuCallback); | ||
friend void ModuleStatus(char *statusBuffer); | ||
friend void ModuleConfig(unsigned char menuId); | ||
friend void SetIniPath(const char *iniFilePath); | ||
friend void ModuleReset(void); | ||
friend void SetCart(SETCART Pointer); | ||
friend unsigned char PakMemRead8(unsigned short address); | ||
friend void PackPortWrite(unsigned char port, unsigned char data); | ||
friend unsigned char PackPortRead(unsigned char port); | ||
friend unsigned short ModuleAudioSample(void); | ||
|
||
private: | ||
|
||
static Cartridge* m_Singleton; | ||
|
||
std::string m_Name; | ||
std::string m_CatalogId; | ||
std::string m_ConfigurationPath; | ||
SETCART AssetCartridgeLinePtr; | ||
DYNAMICMENUCALLBACK AddMenuItemPtr; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#include "CartridgeTrampolines.h" | ||
#include "Cartridge.h" | ||
|
||
|
||
GMC_EXPORT void ModuleName(char *moduleName, char *catalogId, DYNAMICMENUCALLBACK addMenuCallback) | ||
{ | ||
Cartridge::m_Singleton->SetMenuBuilderCallback(addMenuCallback); | ||
|
||
strcpy(moduleName, Cartridge::m_Singleton->GetName().c_str()); | ||
strcpy(catalogId, Cartridge::m_Singleton->GetCatalogId().c_str()); | ||
} | ||
|
||
|
||
GMC_EXPORT void ModuleConfig(unsigned char menuId) | ||
{ | ||
Cartridge::m_Singleton->OnMenuItemSelected(menuId); | ||
} | ||
|
||
|
||
GMC_EXPORT void SetIniPath(const char *iniFilePath) | ||
{ | ||
Cartridge::m_Singleton->SetConfigurationPath(iniFilePath); | ||
} | ||
|
||
|
||
GMC_EXPORT void ModuleReset() | ||
{ | ||
Cartridge::m_Singleton->OnReset(); | ||
} | ||
|
||
|
||
GMC_EXPORT void SetCart(SETCART callback) | ||
{ | ||
Cartridge::m_Singleton->SetCartLineAssertCallback(callback); | ||
} | ||
|
||
|
||
|
||
GMC_EXPORT void ModuleStatus(char *statusBuffer) | ||
{ | ||
auto message(Cartridge::m_Singleton->GetStatusMessage()); | ||
if (message.size() > 63) | ||
{ | ||
message.resize(63); | ||
} | ||
|
||
strcpy(statusBuffer, message.c_str()); | ||
} | ||
|
||
|
||
GMC_EXPORT unsigned char PakMemRead8(unsigned short address) | ||
{ | ||
return Cartridge::m_Singleton->OnReadMemory(address); | ||
} | ||
|
||
|
||
|
||
|
||
GMC_EXPORT void PackPortWrite(unsigned char port, unsigned char data) | ||
{ | ||
Cartridge::m_Singleton->OnWritePort(port, data); | ||
} | ||
|
||
|
||
GMC_EXPORT unsigned char PackPortRead(unsigned char port) | ||
{ | ||
return Cartridge::m_Singleton->OnReadPort(port); | ||
} | ||
|
||
|
||
// This gets called at the end of every scan line 262 Lines * 60 Frames = 15780 Hz 15720 | ||
GMC_EXPORT unsigned short ModuleAudioSample() | ||
{ | ||
return Cartridge::m_Singleton->UpdateAudio(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include "GMC.h" | ||
|
||
|
||
GMC_EXPORT void ModuleName(char *ModName, char *CatNumber, DYNAMICMENUCALLBACK addMenuCallback); | ||
GMC_EXPORT void ModuleStatus(char *statusBuffer); | ||
GMC_EXPORT void ModuleConfig(unsigned char /*menuId*/); | ||
GMC_EXPORT void SetIniPath(const char *iniFilePath); | ||
GMC_EXPORT void ModuleReset(); | ||
GMC_EXPORT void SetCart(SETCART Pointer); | ||
GMC_EXPORT unsigned char PakMemRead8(unsigned short address); | ||
GMC_EXPORT void PackPortWrite(unsigned char port, unsigned char data); | ||
GMC_EXPORT unsigned char PackPortRead(unsigned char port); | ||
GMC_EXPORT unsigned short ModuleAudioSample(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include "Configuration.h" | ||
#include <io.h> | ||
#include <Windows.h> | ||
|
||
|
||
|
||
Configuration::Configuration(std::string filename) | ||
: m_Filename(move(filename)) | ||
{ | ||
static const auto moduleName = "GMC-SN74689"; | ||
char pathBuffer[MAX_PATH]; | ||
GetPrivateProfileStringA(moduleName, "ROM", "", pathBuffer, MAX_PATH, m_Filename.c_str()); | ||
std::string activeRom(pathBuffer); | ||
|
||
|
||
MRUListType mruROMList; | ||
for (auto i(0U); ; ++i) | ||
{ | ||
const auto keyName("ROM" + std::to_string(i)); | ||
|
||
if (!GetPrivateProfileStringA(moduleName, keyName.c_str(), "", pathBuffer, MAX_PATH, m_Filename.c_str())) | ||
{ | ||
break; | ||
} | ||
|
||
mruROMList.emplace_back(pathBuffer); | ||
} | ||
|
||
m_ActiveROM = move(activeRom); | ||
m_MRURoms = move(mruROMList); | ||
|
||
} | ||
|
||
|
||
|
||
std::string Configuration::GetActiveRom() const | ||
{ | ||
return m_ActiveROM; | ||
} | ||
|
||
|
||
void Configuration::SetActiveRom(std::string filename) | ||
{ | ||
m_MRURoms.emplace_back(m_ActiveROM); | ||
m_ActiveROM = filename; | ||
|
||
static const auto moduleName = "GMC-SN74689"; | ||
WritePrivateProfileStringA(moduleName, "ROM", filename.data(), m_Filename.c_str()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#pragma once | ||
#include <string> | ||
#include <vector> | ||
|
||
|
||
class Configuration | ||
{ | ||
public: | ||
|
||
Configuration() {} | ||
explicit Configuration(std::string filename); | ||
virtual ~Configuration() = default; | ||
|
||
std::string GetActiveRom() const; | ||
void SetActiveRom(std::string filename); | ||
|
||
|
||
private: | ||
|
||
|
||
using MRUListType = std::vector<std::string>; | ||
|
||
std::string m_Filename; | ||
MRUListType m_MRURoms; | ||
std::string m_ActiveROM; | ||
}; | ||
|
Oops, something went wrong.