Use g_fxo for global ppu_module instance

Also fix autonomous PRX/SPU loading sequence.
This commit is contained in:
Nekotekina 2019-09-26 17:06:43 +03:00
parent 240b4a8bd8
commit b48cdc2260
4 changed files with 13 additions and 8 deletions

View file

@ -68,7 +68,7 @@ struct ppu_segment
// PPU Module Information
struct ppu_module
{
uchar sha1[20];
uchar sha1[20]{};
std::string name;
std::string path;
std::string cache;

View file

@ -992,7 +992,7 @@ std::shared_ptr<lv2_prx> ppu_load_prx(const ppu_prx_object& elf, const std::stri
LOG_NOTICE(LOADER, "PRX library hash: %s (<- %u)", hash, applied);
if (Emu.IsReady() && fxm::import<ppu_module>([&] { return prx; }))
if (Emu.IsReady() && g_fxo->get<ppu_module>()->segs.empty())
{
// Special loading mode
ppu_thread_params p{};
@ -1043,7 +1043,7 @@ void ppu_unload_prx(const lv2_prx& prx)
void ppu_load_exec(const ppu_exec_object& elf)
{
// Set for delayed initialization in ppu_initialize()
const auto _main = fxm::make<ppu_module>();
const auto _main = g_fxo->get<ppu_module>();
// Access linkage information object
const auto link = g_fxo->init<ppu_linkage_info>();

View file

@ -1304,7 +1304,7 @@ extern bool ppu_stdcx(ppu_thread& ppu, u32 addr, u64 reg_value)
extern void ppu_initialize()
{
const auto _main = fxm::get<ppu_module>();
const auto _main = g_fxo->get<ppu_module>();
if (!_main)
{
@ -1317,7 +1317,10 @@ extern void ppu_initialize()
}
// Initialize main module
ppu_initialize(*_main);
if (!_main->segs.empty())
{
ppu_initialize(*_main);
}
std::vector<lv2_prx*> prx_list;

View file

@ -605,7 +605,7 @@ const std::string Emulator::GetBackgroundPicturePath() const
std::string Emulator::PPUCache() const
{
const auto _main = fxm::check_unlocked<ppu_module>();
const auto _main = g_fxo->get<ppu_module>();
if (!_main || _main->cache.empty())
{
@ -1557,9 +1557,9 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa
LOG_NOTICE(LOADER, "Elf path: %s", argv[0]);
}
ppu_load_exec(ppu_exec);
const auto _main = g_fxo->init<ppu_module>();
const auto _main = fxm::get<ppu_module>();
ppu_load_exec(ppu_exec);
_main->cache = fs::get_cache_dir() + "cache/";
@ -1594,6 +1594,7 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa
m_state = system_state::ready;
GetCallbacks().on_ready();
vm::init();
g_fxo->init();
ppu_load_prx(ppu_prx, m_path);
}
else if (spu_exec.open(elf_file) == elf_error::ok)
@ -1602,6 +1603,7 @@ void Emulator::Load(const std::string& title_id, bool add_only, bool force_globa
m_state = system_state::ready;
GetCallbacks().on_ready();
vm::init();
g_fxo->init();
spu_load_exec(spu_exec);
}
else