Play-/Source/ui_shared/arcadedrivers/NamcoSys147Driver.cpp

53 lines
1.8 KiB
C++
Raw Normal View History

#include "NamcoSys147Driver.h"
#include "string_format.h"
#include "AppConfig.h"
#include "PS2VM.h"
#include "PS2VM_Preferences.h"
#include "../ArcadeDefinition.h"
#include "iop/namco_sys147/Iop_NamcoNANDDevice.h"
#include "iop/namco_sys147/Iop_NamcoSys147.h"
void CNamcoSys147Driver::PrepareEnvironment(CPS2VM* virtualMachine, const ARCADE_MACHINE_DEF& def)
{
auto baseId = def.parent.empty() ? def.id : def.parent;
fs::path arcadeRomPath = CAppConfig::GetInstance().GetPreferencePath(PREF_PS2_ARCADEROMS_DIRECTORY);
fs::path nandPath = arcadeRomPath / baseId / def.nandFileName;
if(!fs::exists(nandPath))
{
throw std::runtime_error(string_format("Failed to find '%s' in game's directory.", def.nandFileName.c_str()));
}
auto iopBios = dynamic_cast<CIopBios*>(virtualMachine->m_iop->m_bios.get());
2024-03-18 10:08:35 -04:00
for(const auto& mount : def.nandMounts)
{
2024-03-18 10:08:35 -04:00
iopBios->GetIoman()->RegisterDevice(mount.first.c_str(), std::make_shared<Iop::Namco::CNamcoNANDDevice>(std::make_unique<Framework::CStdStream>(nandPath.string().c_str(), "rb"), mount.second));
}
2023-12-20 19:41:12 -05:00
{
auto sys147Module = std::make_shared<Iop::Namco::CSys147>(*iopBios->GetSifman(), def.id);
switch(def.ioMode)
{
case ARCADE_MACHINE_DEF::IO_MODE::SYS147_AI:
sys147Module->SetIoMode(Iop::Namco::CSys147::IO_MODE::AI);
break;
default:
assert(false);
break;
}
iopBios->RegisterModule(sys147Module);
iopBios->RegisterHleModuleReplacement("S147LINK", sys147Module);
virtualMachine->m_pad->InsertListener(sys147Module.get());
for(const auto& button : def.buttons)
{
sys147Module->SetButton(button.first, button.second.first, button.second.second);
}
}
}
void CNamcoSys147Driver::Launch(CPS2VM* virtualMachine, const ARCADE_MACHINE_DEF& def)
{
virtualMachine->m_ee->m_os->BootFromVirtualPath(def.boot.c_str(), {});
}