mirror of
https://github.com/open-goal/jak-project
synced 2026-08-13 20:25:20 -04:00
jak2: overlord rework (#2544)
Fixes #2545 Fixes #2546 Fixes #2547 Fixes #2548 Fixes #2549 Fixes #2550 Fixes #2551 Fixes #2552 Fixes #2553 Fixes #2554 Fixes #2555 Fixes #2556 Fixes #2557 Fixes #2558 Fixes #2559 Fixes #2560 Fixes #2561 Fixes #2562 Fixes #2563 Fixes #2564 Fixes #2565 Fixes #2567 Fixes #2566 Fixes #2568 Fixes #2569 Fixes #2570 Fixes #2522 Fixes #2571 --------- Co-authored-by: water <awaterford111445@gmail.com> Co-authored-by: Hat Kid <6624576+Hat-Kid@users.noreply.github.com> Co-authored-by: ManDude <7569514+ManDude@users.noreply.github.com>
This commit is contained in:
+115
-44
@@ -24,6 +24,7 @@
|
||||
#include "runtime.h"
|
||||
|
||||
#include "common/cross_os_debug/xdbg.h"
|
||||
#include "common/global_profiler/GlobalProfiler.h"
|
||||
#include "common/goal_constants.h"
|
||||
#include "common/log/log.h"
|
||||
#include "common/util/FileUtil.h"
|
||||
@@ -47,17 +48,30 @@
|
||||
#include "game/kernel/jak2/kboot.h"
|
||||
#include "game/kernel/jak2/klisten.h"
|
||||
#include "game/kernel/jak2/kscheme.h"
|
||||
#include "game/overlord/dma.h"
|
||||
#include "game/overlord/fake_iso.h"
|
||||
#include "game/overlord/iso.h"
|
||||
#include "game/overlord/iso_cd.h"
|
||||
#include "game/overlord/iso_queue.h"
|
||||
#include "game/overlord/overlord.h"
|
||||
#include "game/overlord/ramdisk.h"
|
||||
#include "game/overlord/sbank.h"
|
||||
#include "game/overlord/srpc.h"
|
||||
#include "game/overlord/ssound.h"
|
||||
#include "game/overlord/stream.h"
|
||||
#include "game/overlord/common/fake_iso.h"
|
||||
#include "game/overlord/common/iso.h"
|
||||
#include "game/overlord/common/sbank.h"
|
||||
#include "game/overlord/common/srpc.h"
|
||||
#include "game/overlord/common/ssound.h"
|
||||
#include "game/overlord/jak1/dma.h"
|
||||
#include "game/overlord/jak1/fake_iso.h"
|
||||
#include "game/overlord/jak1/iso.h"
|
||||
#include "game/overlord/jak1/iso_queue.h"
|
||||
#include "game/overlord/jak1/overlord.h"
|
||||
#include "game/overlord/jak1/ramdisk.h"
|
||||
#include "game/overlord/jak1/srpc.h"
|
||||
#include "game/overlord/jak1/ssound.h"
|
||||
#include "game/overlord/jak1/stream.h"
|
||||
#include "game/overlord/jak2/dma.h"
|
||||
#include "game/overlord/jak2/iso_cd.h"
|
||||
#include "game/overlord/jak2/iso_queue.h"
|
||||
#include "game/overlord/jak2/overlord.h"
|
||||
#include "game/overlord/jak2/spustreams.h"
|
||||
#include "game/overlord/jak2/srpc.h"
|
||||
#include "game/overlord/jak2/ssound.h"
|
||||
#include "game/overlord/jak2/stream.h"
|
||||
#include "game/overlord/jak2/streamlist.h"
|
||||
#include "game/overlord/jak2/vag.h"
|
||||
#include "game/system/Deci2Server.h"
|
||||
#include "game/system/iop_thread.h"
|
||||
#include "game/system/vm/dmac.h"
|
||||
@@ -183,6 +197,10 @@ void ee_runner(SystemThreadInterface& iface) {
|
||||
jak1::klisten_init_globals();
|
||||
jak2::klisten_init_globals();
|
||||
|
||||
jak2::vag_init_globals();
|
||||
|
||||
jak2::init_globals_streamlist();
|
||||
|
||||
kmemcard_init_globals();
|
||||
kprint_init_globals_common();
|
||||
|
||||
@@ -211,7 +229,9 @@ void ee_runner(SystemThreadInterface& iface) {
|
||||
/*!
|
||||
* SystemThread function for running the IOP (separate I/O Processor)
|
||||
*/
|
||||
void iop_runner(SystemThreadInterface& iface) {
|
||||
void iop_runner(SystemThreadInterface& iface, GameVersion version) {
|
||||
prof().root_event();
|
||||
prof().begin_event("iop-init");
|
||||
IOP iop;
|
||||
lg::debug("[IOP] Restart!");
|
||||
iop.reset_allocator();
|
||||
@@ -219,26 +239,41 @@ void iop_runner(SystemThreadInterface& iface) {
|
||||
iop::LIBRARY_register(&iop);
|
||||
Gfx::register_vsync_callback([&iop]() { iop.kernel.signal_vblank(); });
|
||||
|
||||
// todo!
|
||||
dma_init_globals();
|
||||
iso_init_globals();
|
||||
fake_iso_init_globals();
|
||||
// iso_api
|
||||
iso_cd_init_globals();
|
||||
iso_queue_init_globals();
|
||||
// isocommon
|
||||
// overlord
|
||||
ramdisk_init_globals();
|
||||
sbank_init_globals();
|
||||
// soundcommon
|
||||
srpc_init_globals();
|
||||
// ssound
|
||||
stream_init_globals();
|
||||
jak1::dma_init_globals();
|
||||
jak2::dma_init_globals();
|
||||
|
||||
iso_init_globals();
|
||||
jak1::iso_init_globals();
|
||||
jak2::iso_init_globals();
|
||||
|
||||
fake_iso_init_globals();
|
||||
jak1::fake_iso_init_globals();
|
||||
jak2::iso_cd_init_globals();
|
||||
|
||||
jak1::iso_queue_init_globals();
|
||||
jak2::iso_queue_init_globals();
|
||||
|
||||
jak2::spusstreams_init_globals();
|
||||
jak1::ramdisk_init_globals();
|
||||
sbank_init_globals();
|
||||
|
||||
// soundcommon
|
||||
jak1::srpc_init_globals();
|
||||
jak2::srpc_init_globals();
|
||||
srpc_init_globals();
|
||||
ssound_init_globals();
|
||||
jak2::ssound_init_globals();
|
||||
|
||||
jak1::stream_init_globals();
|
||||
jak2::stream_init_globals();
|
||||
prof().end_event();
|
||||
iface.initialization_complete();
|
||||
|
||||
lg::debug("[IOP] Wait for OVERLORD to start...");
|
||||
iop.wait_for_overlord_start_cmd();
|
||||
{
|
||||
auto p = scoped_prof("iop-wait-for-ee");
|
||||
iop.wait_for_overlord_start_cmd();
|
||||
}
|
||||
if (iop.status == IOP_OVERLORD_INIT) {
|
||||
lg::debug("[IOP] Run!");
|
||||
} else {
|
||||
@@ -251,9 +286,26 @@ void iop_runner(SystemThreadInterface& iface) {
|
||||
// init
|
||||
|
||||
bool complete = false;
|
||||
start_overlord_wrapper(iop.overlord_argc, iop.overlord_argv, &complete); // todo!
|
||||
while (complete == false) {
|
||||
iop.wait_run_iop(iop.kernel.dispatch());
|
||||
{
|
||||
auto p = scoped_prof("overlord-start");
|
||||
switch (version) {
|
||||
case GameVersion::Jak1:
|
||||
jak1::start_overlord_wrapper(iop.overlord_argc, iop.overlord_argv, &complete);
|
||||
break;
|
||||
case GameVersion::Jak2:
|
||||
jak2::start_overlord_wrapper(iop.overlord_argc, iop.overlord_argv, &complete);
|
||||
break;
|
||||
default:
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto p = scoped_prof("overlord-wait-for-init");
|
||||
while (complete == false) {
|
||||
prof().root_event();
|
||||
iop.kernel.dispatch();
|
||||
}
|
||||
}
|
||||
|
||||
// unblock the EE, the overlord is set up!
|
||||
@@ -261,9 +313,14 @@ void iop_runner(SystemThreadInterface& iface) {
|
||||
|
||||
// IOP Kernel loop
|
||||
while (!iface.get_want_exit() && !iop.want_exit) {
|
||||
prof().root_event();
|
||||
// The IOP scheduler informs us of how many microseconds are left until it has something to do.
|
||||
// So we can wait for that long or until something else needs it to wake up.
|
||||
iop.wait_run_iop(iop.kernel.dispatch());
|
||||
auto wait_duration = iop.kernel.dispatch();
|
||||
if (wait_duration &&
|
||||
*wait_duration - std::chrono::steady_clock::now() > std::chrono::microseconds(100)) {
|
||||
iop.wait_run_iop(*wait_duration);
|
||||
}
|
||||
}
|
||||
|
||||
Gfx::clear_vsync_callback();
|
||||
@@ -275,8 +332,6 @@ void iop_runner(SystemThreadInterface& iface) {
|
||||
*/
|
||||
void null_runner(SystemThreadInterface& iface) {
|
||||
iface.initialization_complete();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -303,8 +358,6 @@ void dmac_runner(SystemThreadInterface& iface) {
|
||||
}
|
||||
|
||||
VM::unsubscribe_component();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -312,6 +365,7 @@ void dmac_runner(SystemThreadInterface& iface) {
|
||||
* GOAL kernel arguments are currently ignored.
|
||||
*/
|
||||
RuntimeExitStatus exec_runtime(GameLaunchOptions game_options, int argc, const char** argv) {
|
||||
prof().root_event();
|
||||
g_argc = argc;
|
||||
g_argv = argv;
|
||||
g_main_thread_id = std::this_thread::get_id();
|
||||
@@ -323,19 +377,26 @@ RuntimeExitStatus exec_runtime(GameLaunchOptions game_options, int argc, const c
|
||||
|
||||
// set up discord stuff
|
||||
gStartTime = time(nullptr);
|
||||
init_discord_rpc();
|
||||
{
|
||||
auto p = scoped_prof("init-discord");
|
||||
init_discord_rpc();
|
||||
}
|
||||
|
||||
// initialize graphics first - the EE code will upload textures during boot and we
|
||||
// want the graphics system to catch them.
|
||||
if (enable_display) {
|
||||
auto p = scoped_prof("init-gfx");
|
||||
Gfx::Init(g_game_version);
|
||||
}
|
||||
|
||||
// step 1: sce library prep
|
||||
iop::LIBRARY_INIT();
|
||||
ee::LIBRARY_INIT_sceCd();
|
||||
ee::LIBRARY_INIT_sceDeci2();
|
||||
ee::LIBRARY_INIT_sceSif();
|
||||
{
|
||||
auto p = scoped_prof("init-library");
|
||||
iop::LIBRARY_INIT();
|
||||
ee::LIBRARY_INIT_sceCd();
|
||||
ee::LIBRARY_INIT_sceDeci2();
|
||||
ee::LIBRARY_INIT_sceSif();
|
||||
}
|
||||
|
||||
// step 2: system prep
|
||||
VM::vm_prepare(); // our fake ps2 VM needs to be prepared
|
||||
@@ -346,10 +407,20 @@ RuntimeExitStatus exec_runtime(GameLaunchOptions game_options, int argc, const c
|
||||
auto& vm_dmac_thread = tm.create_thread("VM-DMAC");
|
||||
|
||||
// step 3: start the EE!
|
||||
iop_thread.start(iop_runner);
|
||||
deci_thread.start(deci2_runner);
|
||||
ee_thread.start(ee_runner);
|
||||
{
|
||||
auto p = scoped_prof("iop-start");
|
||||
iop_thread.start([=](SystemThreadInterface& sti) { iop_runner(sti, g_game_version); });
|
||||
}
|
||||
{
|
||||
auto p = scoped_prof("deci-start");
|
||||
deci_thread.start(deci2_runner);
|
||||
}
|
||||
{
|
||||
auto p = scoped_prof("ee-start");
|
||||
ee_thread.start(ee_runner);
|
||||
}
|
||||
if (VM::use) {
|
||||
auto p = scoped_prof("dmac-start");
|
||||
vm_dmac_thread.start(dmac_runner);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user