--- nono/vm/vm_x68k.cpp 2026/04/29 17:05:17 1.1.1.10 +++ nono/vm/vm_x68k.cpp 2026/04/29 17:05:55 1.1.1.16 @@ -10,32 +10,27 @@ #include "vm_x68k.h" #include "config.h" -#include "dmac.h" -#include "extram.h" -#include "fdc.h" #include "human68k.h" -#include "interrupt.h" #include "mainapp.h" -#include "mainbus.h" -#include "mfp.h" +#include "mainbus_x68k.h" #include "mpu680x0.h" #include "nmi.h" -#include "pedec.h" -#include "pluto.h" -#include "pio.h" #include "power.h" #include "renderer.h" -#include "rp5c15.h" -#include "romimg_x68k.h" -#include "scheduler.h" -#include "spc.h" -#include "x68kio.h" +#include "sound.h" #include "x68kkbd.h" // コンストラクタ VM_X68030::VM_X68030() + : inherited("X68030") { // 機種固有パラメータ + + // 実時間同期がちゃんと動作するにはゲスト OS の設定を要するため、 + // デフォルトは仮想時間同期にしておくほうがトラブルが少なそう。 + gConfig->SetDefault("clock-sync", "virtual"); + // MPU 種別。 + gConfig->SetDefault("mpu-type", "68030"); // MPU クロックの初期値は機種ごとに異なる。単位は MHz gConfig->SetDefault("mpu-clock", 25); // RAM 初期値は MAX にしておく @@ -43,154 +38,27 @@ VM_X68030::VM_X68030() // SPC の入力クロック (5MHz = 200ns) gConfig->Add("!spc-tCLF", 200); - // デバイス (順序に注意) - // BusErrDevice は親コンストラクタで作成済み。 - NEWDV(MPU, new MPU680x0Device()); - NEWDV(Interrupt, new X68030Interrupt()); - NEWDV(MainRAM, new MainRAMDevice()); // req. by X68kIO,Human68k - NEWDV(X68kIO, new X68kIODevice()); - NEWDV(IPLROM0, new IPLROM0Device()); - NEWDV(ExtRAM, new ExtRAMDevice()); - - NEWDV(NMI, new NMIDevice()); + // デバイス + NEWDV(Power, new X68030PowerDevice()); + NEWDV(MPU, NewMPU680x0Device()); + NEWDV(Sound, new SoundRenderer()); + NEWDV(Mainbus, new X68kMainbus()); NEWDV(Keyboard, new X68030Keyboard()); - NEWDV(Renderer, new X68030Renderer()); + NEWDV(NMI, new NMIDevice()); + NEWDV(Renderer, new X68030VideoRenderer()); if (gMainApp.human_mode) { - NEWDV(Human68k, new Human68k()); + NEWDV(Human68k, new Human68kDevice()); } - // デバイスの割り当ては Init() で行っている。 + // バーストアクセスなし (回路図より) + auto mpu680x0 = GetMPU680x0Device(pMPU.get()); + if (mpu680x0) { + mpu680x0->EnableBurstAccess(false); + } } // デストラクタ VM_X68030::~VM_X68030() { } - -bool -VM_X68030::Init() -{ - if (inherited::Init() == false) { - return false; - } - - // 拡張メモリのサイズが確定したので、ここで配置。 - auto mainbus = dynamic_cast(pMainbus.get()); - auto xiospace = dynamic_cast(pX68kIO.get()); - auto extram = dynamic_cast(pExtRAM.get()); - int extsize = extram->GetSizeMB(); - - if (extsize == 0) { - // 拡張メモリがない場合は、上位8ビット全域がミラーになる。 - for (int i = 0; i < mainbus->devtable.size(); i++) { - mainbus->SetDevice(i, xiospace); - } - } else if (extsize == 16) { - // TS-6BE16 互換 (16MB) なら、 - // $00: X68kIO - // $01: ExtRAM - // で、その後ろは? - mainbus->SetDevice(0, xiospace); - mainbus->SetDevice(1, extram); - for (int i = 2; i < mainbus->devtable.size(); i++) { - mainbus->SetDevice(i, pBusErr.get()); - } - } else { - // 060turbo 互換。とりあえず 128MB/256MB のみ。この場合は - // $00: X68kIO - // $01..$0f: BusErr? - // $10..$17: ExtRAM (128MB) - // $18..$1f: ExtRAM (256MB) - // で、その後ろは? - mainbus->SetDevice(0, xiospace); - for (int i = 1; i < mainbus->devtable.size(); i++) { - mainbus->SetDevice(i, pBusErr.get()); - } - for (int i = 0x10, end = i + (extsize / 16); i < end; i++) { - mainbus->SetDevice(i, extram); - } - } - - return true; -} - -// ブートページを切り替える。 -void -VM_X68030::SwitchBootPage(Device *parent, bool isrom) -{ - if (gMainApp.human_mode) { - // Human モードではブートページを RAM に見せる。 - // 今のところ。 - return; - } - - // 共通処理 - inherited::SwitchBootPage(parent, isrom); - - // X68030 では X68kIO が担当している - auto xiospace = dynamic_cast(pX68kIO.get()); - xiospace->SwitchBootPage(isrom); -} - -// リセットについて -// -// PWRRESET -// 電源オン ----------+--> VIPS -// (7505) +--> VideoCtlr -// +--> OSCIAN2 -// | -// | +------+ -// +-->| | -// 本体 SWRESET | YUKI | -// リセット ------------->| | -// スイッチ +------+ -// | IPLRESET -// | -// +--> FPU -// | -// ▽ -// RESET | -// |<-> MPU (68030) -// +--> PPI (8255) -// +--> SPC (MB89352) -// +--> ADPCM (MSM6258) -// +--> FDC (uPD72065B) -// +--> MFP (MC68901) -// | -// | +-------+ -// +-->| PEDEC | -// | +-------+ -// | | -// | +-- OPMIC -----> OPM(YM2151) -// | +-- SCCRD/WR --> SCC(Z8530) -// | -// | EXRESET -// +---|>-----------> 外部バス -// ▽ -// SYSRESET | -// |<-> SAKI ---+ -// | | BEC0,BEC1 -// +--> DMAC <--+ -// +--> CYNTHIA -// リセットされない? -// o CACHY - -// MPU の RESET 命令によるリセット -void -VM_X68030::ResetByMPU() -{ - std::vector ids { - OBJ_DMAC, - OBJ_FDC, - OBJ_MFP, - OBJ_PEDEC, - OBJ_PLUTO, - OBJ_PPI, - OBJ_SPC, - }; - for (auto id : ids) { - auto dev = gMainApp.GetObject(id); - dev->ResetHard(false); - } -}