--- nono/vm/lcd.cpp 2026/04/29 17:04:39 1.1.1.4 +++ nono/vm/lcd.cpp 2026/04/29 17:04:55 1.1.1.7 @@ -13,10 +13,11 @@ std::unique_ptr gLCD; LCDDevice::LCDDevice() + : inherited("LCD") { - logname = "lcd"; - devname = "LCD(HD44780)"; - monitor_size = nnSize(67, 3); + monitor.func = (MonitorCallback_t)&LCDDevice::MonitorUpdate; + monitor.SetSize(67, 3); + monitor.Regist(ID_MONITOR_LCD); } LCDDevice::~LCDDevice() @@ -26,14 +27,24 @@ LCDDevice::~LCDDevice() bool LCDDevice::PowerOff() { - // オフをどう表現するかはあるが、とりあえずモニタ画面での表示を消すのが - // 主目的なので空白で埋める。 + // XXX 電源オフは色を落としたほうがいい memset(ddram, 0x20, sizeof(ddram)); update++; return true; } void +LCDDevice::ResetHard() +{ + // とりあえずモニタ画面での表示を消す + memset(ddram, 0x20, sizeof(ddram)); + // XXX not yet + // CGRAM とか信号線とか + + update++; +} + +void LCDDevice::SetRW(bool val) { rw = val; @@ -183,7 +194,7 @@ LCDDevice::Peek() const } void -LCDDevice::MonitorUpdate(TextScreen &monitor) +LCDDevice::MonitorUpdate(Monitor *, TextScreen &screen) { char buf[17]; @@ -193,20 +204,20 @@ LCDDevice::MonitorUpdate(TextScreen &mon // 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |0123456789abcdef| // 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f |0123456789abcdef| - monitor.Clear(); - monitor.Print(0, 0, "RW=%c RS=%d E=%d", rw ? 'R' : 'W', rs, en); + screen.Clear(); + screen.Print(0, 0, "RW=%c RS=%d E=%d", rw ? 'R' : 'W', rs, en); for (int y = 0; y < 2; y++) { memcpy(buf, &ddram[y * 0x40], 16); buf[16] = '\0'; // 16進を表示する端から文字ダンプ用に加工していく for (int x = 0; x < 16; x++) { - monitor.Print(x * 3 + (x / 8), y + 1, "%02x", buf[x]); + screen.Print(x * 3 + (x / 8), y + 1, "%02x", buf[x]); if (buf[x] < 0x20 || buf[x] > 0x7e) { buf[x] = '.'; } } - monitor.Print(49, y + 1, "|%-16s|", buf); + screen.Print(49, y + 1, "|%-16s|", buf); } } @@ -1841,7 +1852,7 @@ LCDDevice::GetFont(int ch) const 0b000'00100, 0b000'00000, - 0b000'00000, // 0xed L=(?) + 0b000'00000, // 0xed L= (U+26c0 だろうか?) 0b000'00000, 0b000'00000, 0b000'00000,