--- nono/vm/dmac.cpp 2026/04/29 17:04:50 1.1.1.7 +++ nono/vm/dmac.cpp 2026/04/29 17:04:55 1.1.1.8 @@ -12,14 +12,11 @@ std::unique_ptr gDMAC; DMACDevice::DMACDevice() + : inherited("DMAC") { - logname = "dmac"; - devname = "DMAC"; devaddr = baseaddr; devlen = 0x2000; - monitor_size = nnSize(80, 30); - for (int i = 0; i < countof(dmac.chan); i++) { dmac.chan[i].ch = i; dmac.chan[i].parent = this; @@ -35,6 +32,10 @@ DMACDevice::DMACDevice() event[i].SetName(string_format("DMAC #%d", i)); event[i].code = i; } + + monitor.func = (MonitorCallback_t)&DMACDevice::MonitorUpdate; + monitor.SetSize(80, 30); + monitor.Regist(ID_MONITOR_DMAC); } DMACDevice::~DMACDevice() @@ -514,40 +515,40 @@ DMACDevice::Peek(uint32 offset) } void -DMACDevice::MonitorUpdate(TextScreen& monitor) +DMACDevice::MonitorUpdate(Monitor *, TextScreen& screen) { int x; int y; - monitor.Clear(); + screen.Clear(); y = 1; - monitor.Puts(0, y++, "CSR"); + screen.Puts(0, y++, "CSR"); y += 2; - monitor.Puts(0, y++, "CER"); - monitor.Puts(0, y++, "DCR:XRM"); - monitor.Puts(0, y++, "DCR:DTYP"); - monitor.Puts(0, y++, "DCR:DPS"); - monitor.Puts(0, y++, "DCR:PCL"); - monitor.Puts(0, y++, "OCR:DIR"); - monitor.Puts(0, y++, "OCR:SIZE"); - monitor.Puts(0, y++, "OCR:CHAIN"); - monitor.Puts(0, y++, "OCR:REQG"); - monitor.Puts(0, y++, "SCR:MAC"); - monitor.Puts(0, y++, "SCR:DAC"); - monitor.Puts(0, y++, "CCR"); + screen.Puts(0, y++, "CER"); + screen.Puts(0, y++, "DCR:XRM"); + screen.Puts(0, y++, "DCR:DTYP"); + screen.Puts(0, y++, "DCR:DPS"); + screen.Puts(0, y++, "DCR:PCL"); + screen.Puts(0, y++, "OCR:DIR"); + screen.Puts(0, y++, "OCR:SIZE"); + screen.Puts(0, y++, "OCR:CHAIN"); + screen.Puts(0, y++, "OCR:REQG"); + screen.Puts(0, y++, "SCR:MAC"); + screen.Puts(0, y++, "SCR:DAC"); + screen.Puts(0, y++, "CCR"); y += 2; - monitor.Puts(0, y++, "MTC"); - monitor.Puts(0, y++, "MAR"); - monitor.Puts(0, y++, "DAR"); - monitor.Puts(0, y++, "BTC"); - monitor.Puts(0, y++, "BAR"); - monitor.Puts(0, y++, "NIV"); - monitor.Puts(0, y++, "EIV"); - monitor.Puts(0, y++, "MFC"); - monitor.Puts(0, y++, "CPR"); - monitor.Puts(0, y++, "DFC"); - monitor.Puts(0, y++, "BFC"); + screen.Puts(0, y++, "MTC"); + screen.Puts(0, y++, "MAR"); + screen.Puts(0, y++, "DAR"); + screen.Puts(0, y++, "BTC"); + screen.Puts(0, y++, "BAR"); + screen.Puts(0, y++, "NIV"); + screen.Puts(0, y++, "EIV"); + screen.Puts(0, y++, "MFC"); + screen.Puts(0, y++, "CPR"); + screen.Puts(0, y++, "DFC"); + screen.Puts(0, y++, "BFC"); for (int ch = 0; ch < 4; ch++) { DMAC::Channel *chan = &dmac.chan[ch]; @@ -556,17 +557,17 @@ DMACDevice::MonitorUpdate(TextScreen& mo y = 0; // 地味だけど有効なチャンネルをハイライトしてみる - monitor.Print(x, y++, (chan->active ? TA::Em : TA::Normal), + screen.Print(x, y++, (chan->active ? TA::Em : TA::Normal), "#%d (%s)", chan->ch, chan->desc); // CSR val = chan->PeekCSR(); - monitor.Print(x, y++, "$%02x", val); + screen.Print(x, y++, "$%02x", val); static const char * const csrname[] = { "COC", "BTC", "NDT", "ERR", "ACT", "---", "PCT", "PCS", }; - MonitorReg4(monitor, x, y++, val >> 4, &csrname[0]); - MonitorReg4(monitor, x, y++, val & 0xff, &csrname[4]); + MonitorReg4(screen, x, y++, val >> 4, &csrname[0]); + MonitorReg4(screen, x, y++, val & 0xff, &csrname[4]); // CER val = chan->cer & 0x1f; @@ -576,9 +577,9 @@ DMACDevice::MonitorUpdate(TextScreen& mo } else { e = "?"; } - monitor.Print(x, y, "$%02x", chan->cer); + screen.Print(x, y, "$%02x", chan->cer); if (val > 0) { - monitor.Print(x + 3, y, ":%s", e); + screen.Print(x + 3, y, ":%s", e); } y++; @@ -591,7 +592,7 @@ DMACDevice::MonitorUpdate(TextScreen& mo "CycleWithHold", }; val = chan->dcr >> 6; - monitor.Print(x, y++, "%d:%s", val, dcr_xrm[val]); + screen.Print(x, y++, "%d:%s", val, dcr_xrm[val]); // DCR:DTYP static const char * const dcr_dtyp[] = { @@ -602,7 +603,7 @@ DMACDevice::MonitorUpdate(TextScreen& mo "ACK+READY", }; val = (chan->dcr >> 4) & 3; - monitor.Print(x, y++, "%d:%s", val, dcr_dtyp[val]); + screen.Print(x, y++, "%d:%s", val, dcr_dtyp[val]); // DCR:DPS static const char * const dcr_dps[] = { @@ -611,10 +612,10 @@ DMACDevice::MonitorUpdate(TextScreen& mo "16bit", }; val = (chan->dcr >> 3) & 1; - monitor.Print(x, y++, "%d:%s", val, dcr_dps[val]); + screen.Print(x, y++, "%d:%s", val, dcr_dps[val]); // DCR:PCL - monitor.Print(x, y++, "XXX PCL"); + screen.Print(x, y++, "XXX PCL"); // OCR:DIR static const char * const ocr_dir[] = { @@ -623,7 +624,7 @@ DMACDevice::MonitorUpdate(TextScreen& mo "DeviceToMemory", }; val = (chan->ocr >> 7); - monitor.Print(x, y++, "%d:%s", val, ocr_dir[val]); + screen.Print(x, y++, "%d:%s", val, ocr_dir[val]); // OCR:SIZE static const char * const ocr_size[] = { @@ -634,7 +635,7 @@ DMACDevice::MonitorUpdate(TextScreen& mo "8bit Unpacked", }; val = (chan->ocr >> 4) & 3; - monitor.Print(x, y++, "%d:%s", val, ocr_size[val]); + screen.Print(x, y++, "%d:%s", val, ocr_size[val]); // OCR:CHAIN static const char * const ocr_chain[] = { @@ -645,7 +646,7 @@ DMACDevice::MonitorUpdate(TextScreen& mo "LinkArrayChain", }; val = (chan->ocr >> 2) & 3; - monitor.Print(x, y++, "%d:%s", val, ocr_chain[val]); + screen.Print(x, y++, "%d:%s", val, ocr_chain[val]); // OCR:REQG static const char * const ocr_reqg[] = { @@ -656,7 +657,7 @@ DMACDevice::MonitorUpdate(TextScreen& mo "AutoThenExt", }; val = (chan->ocr & 3); - monitor.Print(x, y++, "%d:%s", val, ocr_reqg[val]); + screen.Print(x, y++, "%d:%s", val, ocr_reqg[val]); // SCR:MAC static const char * const scr_xac[] = { @@ -667,71 +668,71 @@ DMACDevice::MonitorUpdate(TextScreen& mo "undefined", }; val = (chan->scr >> 2) & 3; - monitor.Print(x, y++, "%d:%s", val, scr_xac[val]); + screen.Print(x, y++, "%d:%s", val, scr_xac[val]); val = chan->scr & 3; - monitor.Print(x, y++, "%d:%s", val, scr_xac[val]); + screen.Print(x, y++, "%d:%s", val, scr_xac[val]); // CCR val = chan->ccr; - monitor.Print(x, y++, "$%02x", val); + screen.Print(x, y++, "$%02x", val); static const char * const ccrnames[] = { "STR", "CNT", "HLT", "SAB", "INT", "---", "---", "---", }; - MonitorReg4(monitor, x, y++, (val >> 4), &ccrnames[0]); - MonitorReg4(monitor, x, y++, (val & 0xff), &ccrnames[4]); + MonitorReg4(screen, x, y++, (val >> 4), &ccrnames[0]); + MonitorReg4(screen, x, y++, (val & 0xff), &ccrnames[4]); // MTC - monitor.Print(x, y++, "$%04x", chan->mtc); + screen.Print(x, y++, "$%04x", chan->mtc); // MAR // X680x0 がターゲットなので24bit超える設定は目立たせる if (chan->mar > 0xffffff) { - monitor.Print(x, y++, TA::On, "$%08x", chan->mar); + screen.Print(x, y++, TA::On, "$%08x", chan->mar); } else { - monitor.Print(x, y++, "$%06x", chan->mar); + screen.Print(x, y++, "$%06x", chan->mar); } // DAR if (chan->dar > 0xffffff) { - monitor.Print(x, y++, TA::On, "$%08x", chan->dar); + screen.Print(x, y++, TA::On, "$%08x", chan->dar); } else { - monitor.Print(x, y++, "$%06x", chan->dar); + screen.Print(x, y++, "$%06x", chan->dar); } // BTC - monitor.Print(x, y++, "$%04x", chan->btc); + screen.Print(x, y++, "$%04x", chan->btc); // BAR if (chan->bar > 0xffffff) { - monitor.Print(x, y++, TA::On, "$%08x", chan->bar); + screen.Print(x, y++, TA::On, "$%08x", chan->bar); } else { - monitor.Print(x, y++, "$%06x", chan->bar); + screen.Print(x, y++, "$%06x", chan->bar); } // NIV - monitor.Print(x, y++, "$%02x", chan->niv); + screen.Print(x, y++, "$%02x", chan->niv); // EIV - monitor.Print(x, y++, "$%02x", chan->eiv); + screen.Print(x, y++, "$%02x", chan->eiv); // MFC - monitor.Print(x, y++, "$%02x", chan->mfc); + screen.Print(x, y++, "$%02x", chan->mfc); // CPR - monitor.Print(x, y++, "$%02x", chan->cpr); + screen.Print(x, y++, "$%02x", chan->cpr); // DFC - monitor.Print(x, y++, "$%02x", chan->dfc); + screen.Print(x, y++, "$%02x", chan->dfc); // BFC - monitor.Print(x, y++, "$%02x", chan->bfc); + screen.Print(x, y++, "$%02x", chan->bfc); if (ch == 3) { - monitor.Print(x - 5, y++, "GCR: $%02x", dmac.gcr); + screen.Print(x - 5, y++, "GCR: $%02x", dmac.gcr); } } } // 4ビット分を表示する。MonitorUpdate の下請け void -DMACDevice::MonitorReg4(TextScreen& monitor, +DMACDevice::MonitorReg4(TextScreen& screen, int x, int y, uint32 reg, const char * const *names) { for (int i = 0; i < 4; i++) { bool b = reg & (1 << (3 - i)); - monitor.Puts(x + i * 4, y, TA::OnOff(b), names[i]); + screen.Puts(x + i * 4, y, TA::OnOff(b), names[i]); } }