--- nono/vm/bitmap.cpp 2026/04/29 17:04:35 1.1.1.4 +++ nono/vm/bitmap.cpp 2026/04/29 17:04:52 1.1.1.6 @@ -7,6 +7,7 @@ #include "bitmap.h" #include "bt454.h" #include "cgrom.h" +#include "mpu.h" // // ビットマッププレーン @@ -49,16 +50,30 @@ BitmapDevice::BitmapDevice() logname = "bitmap"; devname = "Bitmap"; devaddr = 0xb1000000; - monitor.Init(42, 11); + monitor_size = nnSize(42, 11); +} + +BitmapDevice::~BitmapDevice() +{ +} +bool +BitmapDevice::Init() +{ // XXX とりあえず。実際は設定による nplane = 1; // プレーン数によってメモリを確保 mem.reset(new uint8 [0x40000 * nplane]); + + return true; } -BitmapDevice::~BitmapDevice() +bool +BitmapDevice::PowerOn() { + // XXX 実際は不定値だと思うけど、観測手段がないのでとりあえず。 + memset(&mem[0], 0xff, 0x40000 * nplane); + return true; } void @@ -67,7 +82,10 @@ BitmapDevice::ResetHard() // 厳密にどの時点でリセットされるのかは知らないけど bmsel = 0; - // RFCNT の初期値は観測困難なので、とりあえず無視。 + // XXX 初期値の観測は困難なので適当 + rfcnt = 0; + hscroll = 0; + vscroll = 0; for (int i = 0; i < MAX_PLANES; i++) { fcs[i] = 5; @@ -81,6 +99,9 @@ BitmapDevice::ResetHard() uint64 BitmapDevice::Read8(uint32 addr) { + // XXX とりあえず RAM と同じウェイトを入れておく (未調査) + gMPU->AddCycle(1); + if (addr < plane0base) { // 書き込み専用 return 0xff; @@ -96,6 +117,9 @@ BitmapDevice::Read8(uint32 addr) uint64 BitmapDevice::Read16(uint32 addr) { + // XXX とりあえず RAM と同じウェイトを入れておく (未調査) + gMPU->AddCycle(1); + if (addr < plane0base) { // 書き込み専用 return 0xffff; @@ -111,6 +135,9 @@ BitmapDevice::Read16(uint32 addr) uint64 BitmapDevice::Read32(uint32 addr) { + // XXX とりあえず RAM と同じウェイトを入れておく (未調査) + gMPU->AddCycle(1); + if (addr < plane0base) { // 書き込み専用 return 0xffffffff; @@ -126,6 +153,9 @@ BitmapDevice::Read32(uint32 addr) uint64 BitmapDevice::Write8(uint32 addr, uint32 data) { + // XXX とりあえず RAM と同じウェイトを入れておく (未調査) + gMPU->AddCycle(1); + switch (addr) { case 0xb1000000: case 0xb1000001: @@ -178,6 +208,9 @@ BitmapDevice::Write8(uint32 addr, uint32 uint64 BitmapDevice::Write16(uint32 addr, uint32 data) { + // XXX とりあえず RAM と同じウェイトを入れておく (未調査) + gMPU->AddCycle(1); + switch (addr) { case 0xb1000000: case 0xb1000002: @@ -226,6 +259,9 @@ BitmapDevice::Write16(uint32 addr, uint3 uint64 BitmapDevice::Write32(uint32 addr, uint32 data) { + // XXX とりあえず RAM と同じウェイトを入れておく (未調査) + gMPU->AddCycle(1); + switch (addr) { case 0xb1000000: // RFCNT @@ -319,8 +355,8 @@ BitmapDevice::Peek8(uint32 addr) return 0xff; } -bool -BitmapDevice::MonitorUpdate() +void +BitmapDevice::MonitorUpdate(TextScreen& monitor) { int i; @@ -359,8 +395,6 @@ BitmapDevice::MonitorUpdate() ((pal[i * 3 + 2] & 0xf0) >> 4); monitor.Print(29 + (i / 8) * 7, (i % 8) + 3, "$%x:%03x", i, rgb); } - - return true; } // 全画面の更新フラグを立てる @@ -587,7 +621,7 @@ BitmapDevice::EmuConsoleOpen(TextScreen screen_w = textscr->GetCol(); screen_h = textscr->GetRow(); - prev.reset(new uint16[screen_w * screen_h]); + prev.resize(screen_w * screen_h); for (int i = 0; i < screen_w * screen_h; i++) { prev[i] = 0x0020; } @@ -620,7 +654,7 @@ BitmapDevice::EmuConsoleClose() bmsel = 0; textscr = NULL; - prev.reset(); + prev.clear(); } // エミュレータによる出力 @@ -628,7 +662,7 @@ BitmapDevice::EmuConsoleClose() void BitmapDevice::EmuConsoleUpdate() { - const uint16 *text = textscr->GetBuf(); + auto& text = textscr->GetBuf(); // 12ドットフォントなので2文字ずつ (24ビットずつ) 更新する for (int y = 0; y < screen_h; y++) {