--- nono/vm/x68kkbd.cpp 2026/04/29 17:05:10 1.1.1.10 +++ nono/vm/x68kkbd.cpp 2026/04/29 17:05:14 1.1.1.11 @@ -38,6 +38,10 @@ X68030Keyboard::X68030Keyboard() mouse_event.func = ToEventCallback(&X68030Keyboard::MouseCallback); mouse_event.Regist("Mouse"); + + monitor.func = ToMonitorCallback(&X68030Keyboard::MonitorUpdate); + monitor.SetSize(47, 5); + monitor.Regist(ID_MONITOR_KEYBOARD); } // デストラクタ @@ -49,7 +53,9 @@ X68030Keyboard::~X68030Keyboard() void X68030Keyboard::MDConnect() { + rept_delay_data = 3; rept_delay = 500_msec; + rept_time_data = 4; rept_time = 110_msec; rept_key = KC_none; gScheduler->StopEvent(rept_event); @@ -70,6 +76,71 @@ X68030Keyboard::MDDisconnect() mouse_event.code = 0; } +// モニター +void +X68030Keyboard::MonitorUpdate(Monitor *, TextScreen& screen) +{ + int y; + + screen.Clear(); + y = 0; + + // 0 1 2 3 4 + // 01234567890123456789012345678901234567890123456 + // Key Enable: % MSCTRL: % + // Ctrl Enable: OPT.2 Enable: % + // Key Repeat: Delay $x(????msec) + // Repeat $x(????msec) + // LED: Zen Hira INS CAPS Code Roma Kana ($xx) + // LED Darkness: x + + // KEY_EN, CTRL_EN, OPT2_EN, MSCTRL は未実装 + + // キーリピート + screen.Puts(0, y, "Key Repeat:"); + screen.Print(12, y++, "Delay $%x(%4dmsec)", + rept_delay_data, (int)(rept_delay / 1_msec)); + screen.Print(12, y++, "Repeat $%x(%4dmsec)", + rept_time_data, (int)(rept_time / 1_msec)); + + // マウス + int mx = mouse_x; + int my = mouse_y; + if (mx < -999) + mx = -999; + if (mx > 999) + mx = 999; + if (my < -999) + my = -999; + if (my > 999) + my = 999; + + screen.Puts(0, y, "Mouse:"); + screen.Print(12, y, "x=%-4d y=%-4d", mx, my); + screen.Print(27, y, TA::OnOff(mouse_l), "L"); + screen.Print(29, y, TA::OnOff(mouse_r), "R"); + y++; + + // LED + screen.Puts(0, y, "LED:"); + static const char * const ledname[] = { + "Zen", "Hira", "INS", "CAPS", "Code", "Roma", "Kana" + }; + uint val = 0x80; + for (int i = 0; i < 7; i++) { + int n = 6 - i; + screen.Puts(7 + i * 5, y, TA::OnOff(led[n]), ledname[i]); + if (led[n] == 0) { + val |= 1 << n; + } + } + screen.Print(42, y, "($%02x)", val); + y++; + + // LED の明るさ (というより暗さ) + screen.Print(0, y++, "LED Darkness: %d", led_darkness); +} + // 共通 keystat を X680x0 キーコードに変換して返す。 // 対応する X680x0 のキーがなければ 0 を返す。 uint @@ -314,54 +385,56 @@ X68030Keyboard::Command(uint32 data) if (data < 0x40) { // $00-$3f TV 制御 // (実装不要) - putlog(2, "Command TV 制御 $%02x", (data & 0x1f)); + putlog(2, "Command TV control $%02x", (data & 0x1f)); } else if (data < 0x48) { // $40-$47 MSCTRL 信号制御 // こいつは頻度が高いのでログレベルを上げておく - putlog(3, "Command MSCTRL 制御 %d", (data & 1)); + putlog(3, "Command MSCTRL control %d", (data & 1)); } else if (data < 0x50) { // $48-$4f キーデータ送出許可 - putlog(1, "Command キー送出許可 %d (未実装)", (data & 1)); + putlog(1, "Command Key send enable %d (NOT IMPLEMENTED)", (data & 1)); } else if (data < 0x54) { // $50-$53 ディスプレイ制御モード選択 // (実装不要) - putlog(2, "Command ディスプレイ制御 X68000モード %d", (data & 1)); + putlog(2, "Command Display control mode %d", (data & 1)); } else if (data < 0x58) { // $54-$57 LED 明るさ選択 // 0 が明るく 3 が暗いので、明るさというより暗さ。 led_darkness = (data & 3); - putlog(1, "Command LED 明るさ %d", led_darkness); + putlog(1, "Command LED brightness %d", led_darkness); } else if (data < 0x5c) { // $58-$5b 本体からのディスプレイ制御許可 // (実装不要) - putlog(2, "Command 本体からディスプレイ制御 %d", (data & 1)); + putlog(2, "Command Display control enable %d", (data & 1)); } else if (data < 0x60) { // $5c-$5f OPT.2 によるディスプレイ制御許可 // (実装不要) - putlog(2, "Command OPT2からディスプレイ制御 %d", (data & 1)); + putlog(2, "Command OPT2 control enable %d", (data & 1)); } else if (data < 0x70) { // $60-$6f リピートまでの時間 - rept_delay = 200_msec + (data & 15) * 100_msec; - putlog(1, "Command Repeat Delay %d (%d msec)", (data & 15), + rept_delay_data = data & 15; + rept_delay = 200_msec + rept_delay_data * 100_msec; + putlog(1, "Command Repeat Delay %d (%d msec)", rept_delay_data, (int)(rept_delay / 1_msec)); } else if (data < 0x80) { // $70-$7f リピート間隔 - rept_time = 30_msec + (data & 15) * (data & 15) * 5_msec; - putlog(1, "Command Repeat time %d (%d msec)", (data & 15), + rept_time_data = data & 15; + rept_time = 30_msec + rept_time_data * rept_time_data * 5_msec; + putlog(1, "Command Repeat time %d (%d msec)", rept_time_data, (int)(rept_time / 1_msec)); } else { // $80-$ff LED 制御 data &= 0x7f; - putlog(1, "Command LED 制御 $%02x", data); + putlog(1, "Command LED control $%02x", data); uint32 b = 0x01; for (int i = 0; i < led.size(); i++) { // data は %0 で点灯、led[] は true で点灯