mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
support non-debug-mode (#1347)
This commit is contained in:
parent
3ed009924f
commit
347572d9df
|
@ -122,6 +122,11 @@ void OpenGlDebugGui::draw(const DmaStats& dma_stats) {
|
|||
ImGui::MenuItem("Dump to file", nullptr, &dump_events);
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Reboot in Debug Mode")) {
|
||||
want_reboot_in_debug = true;
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
}
|
||||
ImGui::EndMainMenuBar();
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ class OpenGlDebugGui {
|
|||
bool small_profiler = false;
|
||||
bool record_events = false;
|
||||
bool dump_events = false;
|
||||
bool want_reboot_in_debug = false;
|
||||
|
||||
private:
|
||||
FrameTimeRecorder m_frame_timer;
|
||||
|
|
|
@ -463,10 +463,16 @@ static void gl_render_display(GfxDisplay* display) {
|
|||
g_gfx_data->sync_cv.notify_all();
|
||||
}
|
||||
|
||||
// reboot whole game, if requested
|
||||
if (g_gfx_data->debug_gui.want_reboot_in_debug) {
|
||||
g_gfx_data->debug_gui.want_reboot_in_debug = false;
|
||||
MasterExit = RuntimeExitStatus::RESTART_IN_DEBUG;
|
||||
}
|
||||
|
||||
// exit if display window was closed
|
||||
if (glfwWindowShouldClose(window)) {
|
||||
std::unique_lock<std::mutex> lock(g_gfx_data->sync_mutex);
|
||||
MasterExit = 2;
|
||||
MasterExit = RuntimeExitStatus::EXIT;
|
||||
g_gfx_data->sync_cv.notify_all();
|
||||
}
|
||||
}
|
||||
|
@ -481,7 +487,9 @@ u32 gl_vsync() {
|
|||
}
|
||||
std::unique_lock<std::mutex> lock(g_gfx_data->sync_mutex);
|
||||
auto init_frame = g_gfx_data->frame_idx_of_input_data;
|
||||
g_gfx_data->sync_cv.wait(lock, [=] { return MasterExit || g_gfx_data->frame_idx > init_frame; });
|
||||
g_gfx_data->sync_cv.wait(lock, [=] {
|
||||
return (MasterExit != RuntimeExitStatus::RUNNING) || g_gfx_data->frame_idx > init_frame;
|
||||
});
|
||||
return g_gfx_data->frame_idx & 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ char DebugBootMessage[64];
|
|||
MasterConfig masterConfig;
|
||||
|
||||
// Set to 1 to kill GOAL kernel
|
||||
u32 MasterExit;
|
||||
RuntimeExitStatus MasterExit;
|
||||
|
||||
// Set to 1 to enable debug heap
|
||||
u32 MasterDebug;
|
||||
|
@ -57,7 +57,7 @@ void kboot_init_globals() {
|
|||
strcpy(DebugBootLevel, "#f"); // no specified level
|
||||
strcpy(DebugBootMessage, "play"); // play mode, the default retail mode
|
||||
|
||||
MasterExit = 0;
|
||||
MasterExit = RuntimeExitStatus::RUNNING;
|
||||
MasterDebug = 1;
|
||||
MasterUseKernel = 1;
|
||||
DebugSegment = 1;
|
||||
|
@ -144,7 +144,7 @@ s32 goal_main(int argc, const char* const* argv) {
|
|||
void KernelCheckAndDispatch() {
|
||||
u64 goal_stack = u64(g_ee_main_mem) + EE_MAIN_MEM_SIZE - 8;
|
||||
|
||||
while (!MasterExit) {
|
||||
while (MasterExit == RuntimeExitStatus::RUNNING) {
|
||||
// try to get a message from the listener, and process it if needed
|
||||
Ptr<char> new_message = WaitForMessageAndAck();
|
||||
if (new_message.offset) {
|
||||
|
@ -198,5 +198,5 @@ void KernelCheckAndDispatch() {
|
|||
* DONE, EXACT
|
||||
*/
|
||||
void KernelShutdown() {
|
||||
MasterExit = 2; // GOAL Kernel Dispatch loop will stop now.
|
||||
MasterExit = RuntimeExitStatus::EXIT; // GOAL Kernel Dispatch loop will stop now.
|
||||
}
|
||||
|
|
|
@ -22,6 +22,13 @@ struct MasterConfig {
|
|||
u16 territory; // added. this is normally burnt onto the disc executable.
|
||||
};
|
||||
|
||||
enum class RuntimeExitStatus {
|
||||
RUNNING = 0,
|
||||
RESTART_RUNTIME = 1,
|
||||
EXIT = 2,
|
||||
RESTART_IN_DEBUG = 3,
|
||||
};
|
||||
|
||||
// Level to load on boot
|
||||
extern char DebugBootLevel[64];
|
||||
|
||||
|
@ -29,7 +36,7 @@ extern char DebugBootLevel[64];
|
|||
extern char DebugBootMessage[64];
|
||||
|
||||
// Set to 1 to kill GOAL kernel
|
||||
extern u32 MasterExit;
|
||||
extern RuntimeExitStatus MasterExit;
|
||||
|
||||
// Set to 1 to enable debug heap
|
||||
extern u32 MasterDebug;
|
||||
|
|
|
@ -66,6 +66,7 @@ void ClearPending() {
|
|||
if (size > 0) {
|
||||
printf("%s", PrintBufArea.cast<char>().c() + sizeof(ListenerMessageHeader));
|
||||
}
|
||||
clear_print();
|
||||
}
|
||||
} else {
|
||||
if (ListenerStatus) {
|
||||
|
@ -134,10 +135,10 @@ void ProcessListenerMessage(Ptr<char> msg) {
|
|||
printf("[ERROR] unsupported message kind LTT_MSG_PRINT_SYMBOLS (NYI)\n");
|
||||
break;
|
||||
case LTT_MSG_RESET:
|
||||
MasterExit = 1;
|
||||
MasterExit = RuntimeExitStatus::RESTART_RUNTIME;
|
||||
break;
|
||||
case LTT_MSG_SHUTDOWN:
|
||||
MasterExit = 2;
|
||||
MasterExit = RuntimeExitStatus::EXIT;
|
||||
break;
|
||||
case LTT_MSG_CODE: {
|
||||
auto buffer = kmalloc(kdebugheap, MessCount, 0, "listener-link-block");
|
||||
|
|
|
@ -67,7 +67,7 @@ Timer ee_clock_timer;
|
|||
u32 vif1_interrupt_handler = 0;
|
||||
|
||||
void kmachine_init_globals() {
|
||||
isodrv = iso_cd;
|
||||
isodrv = fakeiso; // changed. fakeiso is the only one that works in opengoal.
|
||||
modsrc = 1;
|
||||
reboot = 1;
|
||||
memset(pad_dma_buf, 0, sizeof(pad_dma_buf));
|
||||
|
@ -88,6 +88,8 @@ void InitParms(int argc, const char* const* argv) {
|
|||
isodrv = fakeiso;
|
||||
modsrc = 0;
|
||||
reboot = 0;
|
||||
DebugSegment = 0;
|
||||
MasterDebug = 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++) {
|
||||
|
@ -367,9 +369,10 @@ int InitMachine() {
|
|||
// MsgErr("dkernel: !init pad\n");
|
||||
// }
|
||||
|
||||
if (MasterDebug) { // connect to GOAL compiler
|
||||
// do this always
|
||||
// if (MasterDebug) { // connect to GOAL compiler
|
||||
InitGoalProto();
|
||||
}
|
||||
//}
|
||||
|
||||
lg::info("InitSound");
|
||||
InitSound(); // do nothing!
|
||||
|
@ -983,7 +986,7 @@ void InitMachine_PCPort() {
|
|||
|
||||
void vif_interrupt_callback() {
|
||||
// added for the PC port for faking VIF interrupts from the graphics system.
|
||||
if (vif1_interrupt_handler && MasterExit == 0) {
|
||||
if (vif1_interrupt_handler && MasterExit == RuntimeExitStatus::RUNNING) {
|
||||
call_goal(Ptr<Function>(vif1_interrupt_handler), 0, 0, 0, s7.offset, g_ee_main_mem);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,12 +94,35 @@ int main(int argc, char** argv) {
|
|||
|
||||
setup_logging(verbose);
|
||||
|
||||
bool force_debug_next_time = false;
|
||||
while (true) {
|
||||
std::vector<std::string> args;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
args.push_back(argv[i]);
|
||||
}
|
||||
if (force_debug_next_time) {
|
||||
args.push_back("-boot");
|
||||
args.push_back("-debug");
|
||||
force_debug_next_time = false;
|
||||
}
|
||||
std::vector<char*> ptrs;
|
||||
for (auto& str : args) {
|
||||
ptrs.push_back(str.data());
|
||||
}
|
||||
|
||||
// run the runtime in a loop so we can reset the game and have it restart cleanly
|
||||
lg::info("OpenGOAL Runtime {}.{}", versions::GOAL_VERSION_MAJOR, versions::GOAL_VERSION_MINOR);
|
||||
auto exit_status = exec_runtime(ptrs.size(), ptrs.data());
|
||||
|
||||
if (exec_runtime(argc, argv) == 2) {
|
||||
switch (exit_status) {
|
||||
case RuntimeExitStatus::EXIT:
|
||||
return 0;
|
||||
case RuntimeExitStatus::RESTART_RUNTIME:
|
||||
case RuntimeExitStatus::RUNNING:
|
||||
break;
|
||||
case RuntimeExitStatus::RESTART_IN_DEBUG:
|
||||
force_debug_next_time = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -273,7 +273,7 @@ void dmac_runner(SystemThreadInterface& iface) {
|
|||
* Main function to launch the runtime.
|
||||
* GOAL kernel arguments are currently ignored.
|
||||
*/
|
||||
u32 exec_runtime(int argc, char** argv) {
|
||||
RuntimeExitStatus exec_runtime(int argc, char** argv) {
|
||||
g_argc = argc;
|
||||
g_argv = argv;
|
||||
g_main_thread_id = std::this_thread::get_id();
|
||||
|
@ -315,17 +315,17 @@ u32 exec_runtime(int argc, char** argv) {
|
|||
// step 3: start the EE!
|
||||
iop_thread.start(iop_runner);
|
||||
ee_thread.start(ee_runner);
|
||||
|
||||
deci_thread.start(deci2_runner);
|
||||
|
||||
if (VM::use) {
|
||||
vm_dmac_thread.start(dmac_runner);
|
||||
} else {
|
||||
vm_dmac_thread.start(null_runner);
|
||||
}
|
||||
|
||||
// step 4: wait for EE to signal a shutdown. meanwhile, run video loop on main thread.
|
||||
// TODO relegate this to its own function
|
||||
if (enable_display) {
|
||||
Gfx::Loop([]() { return !MasterExit; });
|
||||
Gfx::Loop([]() { return MasterExit == RuntimeExitStatus::RUNNING; });
|
||||
Gfx::Exit();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,10 +5,13 @@
|
|||
* Setup and launcher for the runtime.
|
||||
*/
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include <thread>
|
||||
|
||||
#include "common/common_types.h"
|
||||
#include "game/kernel/kboot.h"
|
||||
|
||||
extern u8* g_ee_main_mem;
|
||||
u32 exec_runtime(int argc, char** argv);
|
||||
|
||||
RuntimeExitStatus exec_runtime(int argc, char** argv);
|
||||
|
||||
extern std::thread::id g_main_thread_id;
|
||||
|
|
|
@ -270,7 +270,7 @@
|
|||
|
||||
(defun execute-math-engine ()
|
||||
(#when PC_PORT
|
||||
(with-dma-buffer-add-bucket ((debug-buf (-> (current-frame) debug-buf))
|
||||
(with-dma-buffer-add-bucket ((debug-buf (-> (current-frame) global-buf))
|
||||
(bucket-id debug-no-zbuf))
|
||||
(when (-> *pc-settings* display-actor-counts)
|
||||
(draw-string-xy (string-format "M: ~D/~D A: ~D" (-> *matrix-engine* length) MATRIX_ENGINE_AMOUNT (process-count *active-pool*)) debug-buf 8 (- 224 18) (font-color default) (font-flags shadow kerning))
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
|
||||
;; function to call in the main loop to run the debug menu
|
||||
(declare-type debug-menu-context basic)
|
||||
(define-extern *menu-hook* (function debug-menu-context))
|
||||
(define *menu-hook* (the (function debug-menu-context) nothing))
|
||||
|
||||
;; function to call in the main loop to run the progress menu
|
||||
(define *progress-hook* nothing)
|
||||
|
|
|
@ -671,7 +671,7 @@
|
|||
|
||||
(with-profiler "menu"
|
||||
(with-pc
|
||||
(if (-> *pc-settings* display-sha)
|
||||
(if (and (-> *pc-settings* display-sha) *debug-segment*)
|
||||
(draw-build-revision)))
|
||||
|
||||
(*menu-hook*)
|
||||
|
|
|
@ -568,10 +568,12 @@
|
|||
(set! (-> self spool-name) (-> *art-control* active-stream))
|
||||
(set! (-> self cur-channel) (pc-subtitle-channel movie))
|
||||
(with-proc ((handle->process (-> *art-control* spool-lock)))
|
||||
(if *debug-segment*
|
||||
(format *stdcon* "movie spool detected:~%~3L~A~0L~%current spool frame is ~3L~D~0L~%"
|
||||
(-> *art-control* active-stream) (the int (ja-aframe-num 0)))
|
||||
)
|
||||
)
|
||||
)
|
||||
(*hint-semaphore*
|
||||
;; there's a hint playing
|
||||
(set! (-> self spool-name) (-> *hint-semaphore* 0 sound-to-play))
|
||||
|
@ -581,12 +583,14 @@
|
|||
(set! (-> self cur-channel) (if (-> self spool-name)
|
||||
(pc-subtitle-channel hint-named)
|
||||
(pc-subtitle-channel hint)))
|
||||
(if *debug-segment*
|
||||
(format *stdcon* "hint detected!~%~3L~A~0L/~3L#x~X~0L~%current str pos is ~D (~3L~D~0L)~%"
|
||||
(-> self spool-name) (-> self text-id)
|
||||
(current-str-pos (-> *hint-semaphore* 0 sound-id))
|
||||
(subtitle-str-adjust (current-str-pos (-> *hint-semaphore* 0 sound-id))))
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
;; do subtitles
|
||||
|
||||
|
|
Loading…
Reference in a new issue