Annotation of nono/vm/vm_news.cpp, revision 1.1

1.1     ! root        1: //
        !             2: // nono
        !             3: // Copyright (C) 2022 nono project
        !             4: // Licensed under nono-license.txt
        !             5: //
        !             6: 
        !             7: //
        !             8: // VM (NEWS)
        !             9: //
        !            10: 
        !            11: #include "vm_news.h"
        !            12: #include "busio.h"
        !            13: #include "config.h"
        !            14: #include "dipsw.h"
        !            15: #include "interrupt.h"
        !            16: #include "mainapp.h"
        !            17: #include "mainbus.h"
        !            18: #include "mainram.h"
        !            19: #include "mpu680x0.h"
        !            20: #include "newsctlr.h"
        !            21: #include "newsfb.h"
        !            22: #include "newsio.h"
        !            23: #include "prom.h"
        !            24: #include "renderer.h"
        !            25: #include "romemu_news.h"
        !            26: #include "scheduler.h"
        !            27: 
        !            28: // コンストラクタ
        !            29: VM_NEWS::VM_NEWS()
        !            30: {
        !            31:        // 機種固有パラメータ
        !            32:        // MPU クロックの初期値は機種ごとに異なる。単位は MHz
        !            33:        gConfig->SetDefault("mpu-clock", 25);
        !            34:        // RAM 初期値は?
        !            35:        gConfig->SetDefault("ram-size", 16);
        !            36:        // RTC epoch は 1900年。
        !            37:        gConfig->SetDefault("rtc-epoch-year", 1900);
        !            38: 
        !            39:        NEWDV(MPU, new MPU680x0Device());
        !            40:        NEWDV(Interrupt, new NewsInterrupt());
        !            41:        NEWDV(PROM, new NewsROMEmuDevice());
        !            42:        NEWDV(MainRAM, new MainRAMDevice());
        !            43:        NEWDV(NewsCtlr, new NewsCtlrDevice());
        !            44:        NEWDV(NewsIO, new NewsIODevice());
        !            45: 
        !            46:        NEWDV(Renderer, new NewsRenderer());
        !            47:        NEWDV(Newsfb, new NewsfbDevice());
        !            48:        NEWDV(Dipsw, new NewsDipswDevice());
        !            49: 
        !            50:        // 全域をバスエラーで埋める。
        !            51:        // XXX バスエラーが起きるかどうかは知らないが
        !            52:        auto mainbus = dynamic_cast<MainbusDevice *>(pMainbus.get());
        !            53:        for (int i = 0; i < mainbus->devtable.size() / 4; i++) {
        !            54:                auto buserr = dynamic_cast<IODevice *>(pBusErr.get());
        !            55:                mainbus->SetDevice(i, buserr);
        !            56:        }
        !            57: 
        !            58:        // 少ないので手動で置いていく。
        !            59:        auto newsio = dynamic_cast<IODevice *>(pNewsIO.get());
        !            60:        auto newsctlr = dynamic_cast<IODevice *>(pNewsCtlr.get());
        !            61:        auto prom = dynamic_cast<IODevice *>(pPROM.get());
        !            62: #define A(addr)        (((addr) >> 24) & 0x3f)
        !            63:        mainbus->SetDevice(A(0xe0'000000), newsio);
        !            64:        mainbus->SetDevice(A(0xe1'000000), newsctlr);
        !            65:        mainbus->SetDevice(A(0xf8'000000), prom);
        !            66: }
        !            67: 
        !            68: // デストラクタ
        !            69: VM_NEWS::~VM_NEWS()
        !            70: {
        !            71: }
        !            72: 
        !            73: // 初期化
        !            74: bool
        !            75: VM_NEWS::Init()
        !            76: {
        !            77:        if (inherited::Init() == false) {
        !            78:                return false;
        !            79:        }
        !            80: 
        !            81:        auto mainbus = dynamic_cast<MainbusDevice *>(pMainbus.get());
        !            82:        auto mainram = dynamic_cast<MainRAMDevice *>(pMainRAM.get());
        !            83: 
        !            84:        // RAM 容量が確定したので、ここで devtable に RAM を配置。
        !            85:        int ram_size_MB = mainram->GetSizeMB();
        !            86:        int i = 0;
        !            87:        while (ram_size_MB >= 16) {
        !            88:                // 16MB 単位にとりあえずしとく
        !            89:                mainbus->SetDevice(i++, mainram);
        !            90:                ram_size_MB -= 16;
        !            91:        }
        !            92: 
        !            93:        // $40'000000〜、$80'000000〜、$c0'000000〜はミラーっぽい。
        !            94:        mainbus->CopyDevtable(0x40, 0, 0x40);
        !            95:        mainbus->CopyDevtable(0x80, 0, 0x40);
        !            96:        mainbus->CopyDevtable(0xc0, 0, 0x40);
        !            97: 
        !            98:        return true;
        !            99: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.