--- nono/cli/cli_app.cpp 2026/04/29 17:04:51 1.1.1.6 +++ nono/cli/cli_app.cpp 2026/04/29 17:04:56 1.1.1.8 @@ -5,20 +5,21 @@ // #include "header.h" +#include "cuimessage.h" #include "mainapp.h" #include "mpu680x0.h" #include "pluto.h" +#include "scheduler.h" #include "vm.h" -void cli_halt_callback(void *); - // wxApp と相似にするためのクラス class CLIApp { public: int OnInit(); bool Parse(); - [[noreturn]] void OnCreate(); + int OnCreate(); + void OnHalt(); int ac; char **av; @@ -50,11 +51,6 @@ CLIApp::OnInit() return EXIT_FAILURE; } - // VM にコールバックを登録 - if (gMPU680x0) { - gMPU680x0->SetHaltCallback(cli_halt_callback, NULL); - } - // メインウィンドウに相当するところ OnCreate(); @@ -62,21 +58,29 @@ CLIApp::OnInit() } // メインウィンドウ作成後のイベントに相当するところ -void +int CLIApp::OnCreate() { + if (gMPU680x0) { + CUIMessage::Connect(UIMessage::HALT, + [&](const UIMessage&) { OnHalt(); }); + } + // UIMessage の処理を開始する。 + UIMessage::Attach(&CUIMessage::Process); + // 電源投入 gVM->PowerButton(); - // ? - for (;;) { - sleep(1); - } + // スケジューラの終了を待つ + + gScheduler->Wait(); + + return 0; } // m680x0 ダブルバスフォールト時に呼ばれるコールバック。 void -cli_halt_callback(void *dummy) +CLIApp::OnHalt() { // どうする? warnx("Double bus fault has occurred in VM");