Add support for custom ROMs.
Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
parent
1c94fd7150
commit
a059fad539
6 changed files with 48 additions and 9 deletions
|
@ -96,6 +96,8 @@ namespace common2
|
|||
("fixed-speed", "Fixed (non-adaptive) speed")
|
||||
("ntsc,nt", "NTSC: execute NTSC code")
|
||||
("benchmark,b", "Benchmark emulator")
|
||||
("rom", po::value<std::string>(), "Custom 12k/16k ROM")
|
||||
("f8rom", po::value<std::string>(), "Custom 2k ROM")
|
||||
;
|
||||
desc.add(emulatorDesc);
|
||||
|
||||
|
@ -159,6 +161,16 @@ namespace common2
|
|||
options.loadSnapshot = false;
|
||||
}
|
||||
|
||||
if (vm.count("rom"))
|
||||
{
|
||||
options.customRom = vm["rom"].as<std::string>();
|
||||
}
|
||||
|
||||
if (vm.count("f8rom"))
|
||||
{
|
||||
options.customRomF8 = vm["f8rom"].as<std::string>();
|
||||
}
|
||||
|
||||
const int memclear = vm["memclear"].as<int>();
|
||||
if (memclear >=0 && memclear < NUM_MIP)
|
||||
options.memclear = memclear;
|
||||
|
@ -196,6 +208,8 @@ namespace common2
|
|||
|
||||
void applyOptions(const EmulatorOptions & options)
|
||||
{
|
||||
g_nMemoryClearType = options.memclear;
|
||||
|
||||
bool disksOk = true;
|
||||
if (!options.disk1.empty())
|
||||
{
|
||||
|
@ -216,6 +230,26 @@ namespace common2
|
|||
setSnapshotFilename(options.snapshotFilename, options.loadSnapshot);
|
||||
}
|
||||
|
||||
if (!options.customRom.empty())
|
||||
{
|
||||
CloseHandle(g_hCustomRom);
|
||||
g_hCustomRom = CreateFile(options.customRom.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, nullptr);
|
||||
if (g_hCustomRom == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LogFileOutput("Init: Failed to load Custom ROM: %s\n", options.customRom.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.customRomF8.empty())
|
||||
{
|
||||
CloseHandle(g_hCustomRomF8);
|
||||
g_hCustomRomF8 = CreateFile(options.customRomF8.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_READONLY, nullptr);
|
||||
if (g_hCustomRomF8 == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
LogFileOutput("Init: Failed to load custom F8 ROM: %s\n", options.customRomF8.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
Paddle::setSquaring(options.paddleSquaring);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ namespace common2
|
|||
Geometry geometry; // must be initialised with defaults
|
||||
int glSwapInterval = 1; // SDL_GL_SetSwapInterval
|
||||
|
||||
std::string customRomF8;
|
||||
std::string customRom;
|
||||
|
||||
std::vector<std::string> registryOptions;
|
||||
};
|
||||
|
||||
|
|
|
@ -148,15 +148,14 @@ namespace
|
|||
|
||||
const Logger logger(options.log);
|
||||
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
|
||||
const std::shared_ptr<na2::EvDevPaddle> paddle(new na2::EvDevPaddle(options.paddleDeviceName));
|
||||
|
||||
const std::shared_ptr<na2::NFrame> frame(new na2::NFrame(paddle));
|
||||
|
||||
const Initialisation init(registry, frame, paddle);
|
||||
applyOptions(options);
|
||||
frame->Initialize();
|
||||
|
||||
na2::SetCtrlCHandler(options.headless);
|
||||
applyOptions(options);
|
||||
|
||||
if (options.benchmark)
|
||||
{
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace
|
|||
{A2TYPE_APPLE2JPLUS, "A2TYPE_APPLE2JPLUS"},
|
||||
{A2TYPE_APPLE2E, "A2TYPE_APPLE2E"},
|
||||
{A2TYPE_APPLE2EENHANCED, "A2TYPE_APPLE2EENHANCED"},
|
||||
{A2TYPE_APPLE2C, "A2TYPE_APPLE2C"},
|
||||
{A2TYPE_PRAVETS8M, "A2TYPE_PRAVETS8M"},
|
||||
{A2TYPE_PRAVETS82, "A2TYPE_PRAVETS82"},
|
||||
{A2TYPE_BASE64A, "A2TYPE_BASE64A"},
|
||||
|
|
|
@ -103,7 +103,6 @@ void run_sdl(int argc, const char * argv [])
|
|||
|
||||
const Logger logger(options.log);
|
||||
const std::shared_ptr<Registry> registry = CreateFileRegistry(options);
|
||||
g_nMemoryClearType = options.memclear;
|
||||
|
||||
std::shared_ptr<sa2::SDLFrame> frame;
|
||||
if (options.imgui)
|
||||
|
@ -117,11 +116,11 @@ void run_sdl(int argc, const char * argv [])
|
|||
|
||||
std::shared_ptr<Paddle> paddle(new sa2::Gamepad(0));
|
||||
const Initialisation init(registry, frame, paddle);
|
||||
applyOptions(options);
|
||||
frame->Initialize();
|
||||
|
||||
std::cerr << "Default GL swap interval: " << SDL_GL_GetSwapInterval() << std::endl;
|
||||
|
||||
applyOptions(options);
|
||||
|
||||
const int fps = getRefreshRate();
|
||||
std::cerr << "Video refresh rate: " << fps << " Hz, " << 1000.0 / fps << " ms" << std::endl;
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ Initialisation::Initialisation(
|
|||
Registry::instance = registry;
|
||||
SetFrame(frame);
|
||||
Paddle::instance = paddle;
|
||||
|
||||
frame->Initialize();
|
||||
}
|
||||
|
||||
Initialisation::~Initialisation()
|
||||
|
@ -56,6 +54,11 @@ Initialisation::~Initialisation()
|
|||
|
||||
Paddle::instance.reset();
|
||||
Registry::instance.reset();
|
||||
|
||||
CloseHandle(g_hCustomRomF8);
|
||||
g_hCustomRomF8 = INVALID_HANDLE_VALUE;
|
||||
CloseHandle(g_hCustomRom);
|
||||
g_hCustomRom = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
Logger::Logger(const bool log)
|
||||
|
|
Loading…
Add table
Reference in a new issue