--- nono/cli/cli_app.cpp 2026/04/29 17:04:40 1.1.1.4 +++ nono/cli/cli_app.cpp 2026/04/29 17:04:56 1.1.1.8 @@ -5,21 +5,21 @@ // #include "header.h" +#include "cuimessage.h" #include "mainapp.h" #include "mpu680x0.h" #include "pluto.h" -#include "rtc.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; @@ -42,11 +42,12 @@ CLIApp::OnInit() { int rv; - rv = gMainApp.Init(true, ac, av); + // CLI 側では関係ないが wx 側で必要なので初期化は2ステージに分かれている + rv = gMainApp.Init1(true, ac, av); if (rv != MainApp::PASS) { return rv; } - if (!gMainApp.Start()) { + if (!gMainApp.Init2()) { return EXIT_FAILURE; } @@ -57,30 +58,29 @@ CLIApp::OnInit() } // メインウィンドウ作成後のイベントに相当するところ -void +int CLIApp::OnCreate() { - // VM にコールバックを登録 if (gMPU680x0) { - gMPU680x0->SetHaltCallback(cli_halt_callback, NULL); + CUIMessage::Connect(UIMessage::HALT, + [&](const UIMessage&) { OnHalt(); }); } + // UIMessage の処理を開始する。 + UIMessage::Attach(&CUIMessage::Process); - // 時刻開始? - // なるべく VM が開始する直前にしたい。 - gRTC->InitRTC(); - - // VM 実行開始 + // 電源投入 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");