Example #1
0
        /// <summary>
        /// Display constructor.
        /// </summary>
        /// <param name="interruptController">A reference to the interrupt controller.</param>
        /// <param name="Memory">A reference to the memory.</param>
        public Display(InterruptController interruptController, Memory memory)
        {
            _interruptController = interruptController;
            _memory = memory;
            _disDef = new DisplayDefinition();
            _state  = new State();
            GeneratePixelLookupTable();

            Reset();
        }
Example #2
0
 public BUS(GPU gpu, CDROM cdrom, SPU spu, JOYPAD joypad, TIMERS timers, MDEC mdec) {
     interruptController = new InterruptController();
     dma = new DMA(this);
     this.gpu = gpu;
     this.cdrom = cdrom;
     this.timers = timers;
     this.mdec = mdec;
     this.spu = spu;
     this.joypad = joypad;
 }
Example #3
0
 public Device()
 {
     CPU       = new Z80(this);
     DMA       = new DMAController(this);
     MMU       = new MemoryMapper(this);
     Cartridge = null;
     GPU       = new VideoController(this);
     IRQ       = new InterruptController();
     TIM       = new TimerController(this);
     JOYP      = new InputController(this);
 }
Example #4
0
 public BUS(IHostWindow window, Controller controller, CDROM cdrom)
 {
     interruptController = new InterruptController();
     dma        = new DMA(this);
     gpu        = new GPU(window);
     this.cdrom = cdrom;
     timers     = new TIMERS();
     joypad     = new JOYPAD(controller);
     mdec       = new MDEC();
     spu        = new SPU();
 }
Example #5
0
        private void StartButton_Click(object sender, RoutedEventArgs e)
        {
            var interruptController = new InterruptController();
            var ram         = new RandomAccessMemoryController(1 * 1024 * 1024);
            var bootManager = new BootManager(MainPage.BootImage());

            this.processor = new Processor();

            this.system = new SystemBusController()
            {
                Processor           = this.processor,
                InterruptController = interruptController
            };

            this.system.AddDevice(ram);
            this.system.AddDevice(bootManager);
            this.system.AddDevice(this.processor);
            this.system.AddDevice(interruptController);

            var stream = MainPage.DiskImage();

            stream.SetLength(8 * 1024 * 1024);
            this.system.AddDevice(new DiskDrive(stream));

            this.keyboard              = new Keyboard();
            this.InputTextBox.KeyDown += this.OnKeyDown;
            this.InputTextBox.KeyUp   += this.OnKeyUp;
            this.system.AddDevice(this.keyboard);

            this.display = new Display((ulong)this.ScreenImage.Width, (ulong)this.ScreenImage.Height);
            this.system.AddDevice(this.display);

            this.processor.DebugHandler = (a, b, c) => a.Value = (ulong)DateTime.UtcNow.Ticks;

            this.processor.BreakHandler = async() => await this.Dispatcher.InvokeTaskAsync(() => {
                this.BreakButton.IsEnabled    = false;
                this.ContinueButton.IsEnabled = true;
                this.StepButton.IsEnabled     = true;

                this.RefreshDebug();
            });

            this.system.Reset();

            this.RefreshDebug();

            this.StartButton.IsEnabled    = false;
            this.StopButton.IsEnabled     = true;
            this.BreakButton.IsEnabled    = false;
            this.ContinueButton.IsEnabled = true;
            this.StepButton.IsEnabled     = true;
            this.RefreshButton.IsEnabled  = true;
        }
Example #6
0
        public BUS()
        {
            interruptController = new InterruptController(); //refactor this to interface and callbacks
            dma    = new DMA(this);
            gpu    = new GPU();
            cdrom  = new CDROM();
            timers = new TIMERS();
            joypad = new JOYPAD();
            mdec   = new MDEC();

            initMem();
        }
        public DisplayController(InterruptController interruptController)
        {
            this.interruptController = interruptController;
            this.registers           = new Registers();

            vram        = new byte[VRAM_SIZE];
            frameBuffer = new byte[FRAME_BUFFER_SIZE];
            oam         = new ObjectAttributes[OAM_SIZE];

            currentCycle = 0;
            registers.Status.DisplayMode = DisplayMode.SEARCH_OAM;
        }
Example #8
0
 public void Setup()
 {
     mgr = new MemoryManager
     {
         RAM       = new MemoryRAM(0, 3 * 0x1_0000), // Only setup 3K of RAM - this should be tons to test our CPU
         CODEC     = new CodecRAM(1025, 1),
         INTERRUPT = new InterruptController(MemoryMap.INT_PENDING_REG0, 4)
     };
     cpu = new CPU(mgr);
     cpu.SetEmulationMode();
     Assert.AreEqual(1, cpu.A.Width);
     Assert.AreEqual(1, cpu.X.Width);
 }
Example #9
0
        private FoenixSystem()
        {
            gpu = new Gpu();

            MemoryManager = new MemoryManager();


            //RAM = new BasicMemory("Ram", MemoryMap.RAM_START, MemoryMap.RAM_SIZE);   // 2MB RAM - extensible to 4MB
            //MemoryManager.AddDevice(RAM);
            //VICKY = new BasicMemory("Vicky", MemoryMap.VICKY_START, MemoryMap.VICKY_SIZE);   // 60K
            //MemoryManager.AddDevice(VICKY);
            //VIDEO = new BasicMemory("Video", MemoryMap.VIDEO_START, MemoryMap.VIDEO_SIZE - 1); // 4MB Video
            //MemoryManager.AddDevice(VIDEO);
            FLASH = new BasicMemory("Flash", MemoryMap.FLASH_START, MemoryMap.FLASH_SIZE);         // 8MB RAM
            MemoryManager.AddDevice(FLASH);
            BEATRIX = new BasicMemory("Beatrix", MemoryMap.BEATRIX_START, MemoryMap.BEATRIX_SIZE); // 4K
            MemoryManager.AddDevice(BEATRIX);

            // Special devices
            MATH = new MathCoproRegisters(MemoryMap.MATH_START);
            MemoryManager.AddDevice(MATH); // 47 bytes

            // This register is only a single byte but we allow writing a word
            CODEC = new Codec(MemoryMap.CODEC_START);
            MemoryManager.AddDevice(CODEC);     // 4 bytes
            KEYBOARD = new KeyboardRegister(MemoryMap.KBD_DATA_BUF);
            MemoryManager.AddDevice(KEYBOARD);  // 5 bytes
            SDCARD = new SDCardRegister(MemoryMap.SDCARD_DATA);
            MemoryManager.AddDevice(SDCARD);    // 2 bytes
            INTERRUPT = new InterruptController(MemoryMap.INT_PENDING_REG0);
            MemoryManager.AddDevice(INTERRUPT); // 3 bytes
            UART1 = new UART(1, MemoryMap.UART1_REGISTERS);
            MemoryManager.AddDevice(UART1);     // 8 bytes
            UART2 = new UART(2, MemoryMap.UART2_REGISTERS);
            MemoryManager.AddDevice(UART2);     // 8 bytes
            OPL2 = new OPL2(MemoryMap.OPL2_S_BASE);
            //MemoryManager.AddDevice(OPL2); // 256 bytes
            MPU401 = new MPU401(MemoryMap.MPU401_REGISTERS);
            MemoryManager.AddDevice(MPU401); // 2 bytes

            this.CPU = new CPU(MemoryManager);
            this.CPU.SimulatorCommand += CPU_SimulatorCommand;

            //gpu.VRAM = VIDEO;
            //gpu.RAM = RAM;
            //gpu.VICKY = VICKY;

            // This fontset is loaded just in case the kernel doesn't provide one.
            gpu.LoadFontSet("Foenix", @"Resources\Bm437_PhoenixEGA_8x8.bin", 0, CharacterSet.CharTypeCodes.ASCII_PET, CharacterSet.SizeCodes.Size8x8);
        }
Example #10
0
        public Processor(
            IMemoryMap memoryMap,
            Registers registers,
            FlagProcessor flagProcessor,
            OpcodeCycles opcodeCycles,
            InterruptController interruptController)
        {
            this.memoryMap           = memoryMap;
            this.registers           = registers;
            this.flagProcessor       = flagProcessor;
            this.opcodeCycles        = opcodeCycles;
            this.interruptController = interruptController;

            flags             = registers.Flags;
            interruptsEnabled = true;
        }
        /// <summary>
        /// Class constructor.
        /// </summary>
        public SerialController(InterruptController interruptController, Memory memory)
        {
            this.interruptController = interruptController;
            this.memory = memory;

            // Always try to serial connect for now
            SerialAdapter uart        = new UARTSerialAdapter();
            var           connections = uart.Discover();

            if (connections.Length > 0)
            {
                // Connect to the first one, this is awesome!
                uart.Connect(connections[0]);
                this.adapter = uart;
                return;
            }
        }
Example #12
0
        public BUS()
        {
            interruptController = new InterruptController(); //refactor this to interface and callbacks
            dma    = new DMA();
            gpu    = new GPU();
            cdrom  = new CDROM();
            timers = new TIMERS();
            joypad = new JOYPAD();

            dma.setDMA_Transfer(this);

            try {
                initMem();
            } finally {
                ramHandle.Free();
            }
        }
Example #13
0
        public ProjectPSX(IHostWindow window, string diskFilename)
        {
            controller = new DigitalController();
            memoryCard = new MemoryCard();

            interruptController = new InterruptController();

            cd     = new CD(diskFilename);
            spu    = new SPU(window, interruptController);
            gpu    = new GPU(window);
            cdrom  = new CDROM(cd, spu);
            joypad = new JOYPAD(controller, memoryCard);
            timers = new TIMERS();
            mdec   = new MDEC();
            bus    = new BUS(gpu, cdrom, spu, joypad, timers, mdec, interruptController);
            cpu    = new CPU(bus);

            bus.loadBios();
            if (diskFilename.EndsWith(".exe"))
            {
                bus.loadEXE(diskFilename);
            }
        }
Example #14
0
 public VirtualMachine(int size)
 {
     memory = new Memory(size);
     interruptController = new InterruptController();
 }