示例#1
0
        // 0 - OAM Search
        // 1 - Pixel Transfer
        // 2 - H-Blank
        // 3 - V-Blank

        public PPU(InterruptController interruptController, LCD display)
        {
            vram = new byte[0x2000];
            oam  = new byte[40 * 4];
            // 4 bytes of data for each of 40 sprites
            output = new byte[256 * 256];
            // one color for each pixel

            lcd      = display;
            finished = new DirectBitmap(160, 144);

            // Assign Default Values
            lcdControl         = new DataBus <byte>(0);
            lcdStatus          = new DataBus <byte>(0);
            scrollY            = new DataBus <byte>(0);
            scrollX            = new DataBus <byte>(0);
            scanLine           = new DataBus <byte>(0);
            scanLineCompare    = new DataBus <byte>(0);
            dmaTransferAddress = new DataBus <byte>(0);
            bgPalette          = new DataBus <byte>(0);
            obj0Palette        = new DataBus <byte>(0);
            obj1Palette        = new DataBus <byte>(0);
            windowY            = new DataBus <byte>(0);
            windowX            = new DataBus <byte>(0);

            ppuState = 0;
            ppuClock = 0;
            rendered = false;
        }
示例#2
0
        public Timer(InterruptController interruptController)
        {
            dividerRegister = new DataBus <byte>((byte)0);
            timerCounter    = new DataBus <byte>((byte)0);
            timerModulo     = new DataBus <byte>((byte)0);
            timerControl    = new DataBus <byte>((byte)0);

            ic = interruptController;
        }
示例#3
0
        public CPU(InterruptController interruptController, Memory mem, Registers registers)
        {
            memory = mem;
            ic     = interruptController;
            reg    = registers;

            opcode = DefaultFunc().GetEnumerator();
            alive  = true;
        }
        private void Setup()
        {
            LCD lcd = new LCD(160 * 4, 144 * 4);

            interruptController = new InterruptController();
            timer     = new Timer(interruptController);
            ppu       = new PPU(interruptController, lcd);
            registers = new Registers(timer.TimerRegisters, ppu.DisplayRegisters);

            stopwatch = new Stopwatch();
            lcd.Start();
        }
示例#5
0
        public Mini8086Emulator()
        {
            var components = new List <BaseComponent>();

            _memMapper  = new MemoryMapper(512);
            _portMapper = new PortMapper();

            _cpu          = new Cpu8086(_memMapper, _portMapper);
            _disassembler = new Disassembler(_cpu, _memMapper);

            components.Add(_bios = new Rom(Config.BiosMemAddress));
            _memMapper.Register(Config.BiosMemAddress, Config.BiosMemAddress + Config.BiosMemSize - 1, _bios);

            components.Add(_pic = new InterruptController(Config.PicBasePort));
            _portMapper.Register(Config.PicBasePort, Config.PicBasePort + 0x07, _pic);

            components.Add(_timer = new Timer(Config.TimerBasePort, _pic));
            _portMapper.Register(Config.TimerBasePort, Config.TimerBasePort + 0x07, _timer);

            components.Add(_graphicsAdapter = new GraphicsAdapter(Config.VgaBasePort, Config.VgaMemAddress, _pic, @"..\..\..\ROMs\charrom.bin"));
            _portMapper.Register(Config.VgaBasePort, Config.VgaBasePort + 0x07, _graphicsAdapter);
            _memMapper.Register(Config.VgaMemAddress, Config.VgaMemAddress + Config.VgaMemSize - 1, _graphicsAdapter);

            components.Add(_lcd = new Lcd44780(Config.LcdBasePort));
            _portMapper.Register(Config.LcdBasePort, Config.LcdBasePort + 0x07, _lcd);

            //components.Add(_ppi = new Ppi(Config.PpiBasePort));
            //_portMapper.Register(Config.PpiBasePort, Config.PpiBasePort + 0x07, _ppi);

            components.Add(_keybController = new KeybController(Config.KeybControllerBasePort, _pic));
            _portMapper.Register(Config.KeybControllerBasePort, Config.KeybControllerBasePort + 0x07, _keybController);

            components.Add(_sdController = new SdController(Config.SdControllerBasePort, Config.SdImagePath));
            _portMapper.Register(Config.SdControllerBasePort, Config.SdControllerBasePort + 0x07, _sdController);

            _memMapper.FinishRegistration();

            components.ForEach(_ =>
            {
                _.EventTimer     = _cpu;
                _.DoCpuInterrupt = _cpu.DoInterrupt;
            });
        }