public Cartridge(PPU ppu, int ramBanks, int romBanks, byte[] ROM)
        {
            this.ppu = ppu;

            this.ramBanks = ramBanks;
            this.romBanks = romBanks;

            rom  = ROM;
            io   = new byte[0x4C];
            ram  = new byte[RAM_BANK_SIZE * (ramBanks + 1)];
            hram = new byte[0x80];
            // Plus 1 accounts for the internal RAM
            // internal ram 0x2000
            // ram banks 0x2000 * ram banks
            // HRAM
            // internal ram 0x80
            // Plus 0x0080 accounts for the internal ram at the end of the memory range

            ramBankSelect = 0;
            romBankSelect = 0;
            ramOffset     = 0x2000;
            romOffset     = 0;
            if (ramBanks > 0)
            {
                ramBankEnable = new bool[ramBanks];
            }
        }
Beispiel #2
0
 public Clock(Timer timer, CPU cpu, PPU ppu)
 {
     this.timer   = timer;
     this.cpu     = cpu;
     this.ppu     = ppu;
     clockCycle   = 0;
     machineCycle = 0;
 }
Beispiel #3
0
        public Memory(string romPath, Registers registers, PPU ppu)
        {
            byte[] rom = File.ReadAllBytes(romPath);

            ScrapeMetaData(rom);
            reg      = registers;
            this.ppu = ppu;
        }
        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();
        }
Beispiel #5
0
        public GameBoy(string rom)
        {
            this.cart = new Cartridge(rom);
            //build the hardware and load the cartridge/

            this.clock       = new Clock();
            this.ppu         = new PPU(clock);
            this.JoyPad      = new Joypad();
            this.sound       = new Sound(clock);
            this.memory      = new MMU(this.cart, this.ppu, this.clock, sound, JoyPad);
            this.cpu         = new CPU(this.memory, clock);
            this.PowerSwitch = true;
        }
Beispiel #6
0
        public Memory(string romPath, string bootROMPath, Registers registers, PPU ppu)
        {
            byte[] rom  = File.ReadAllBytes(romPath);
            byte[] boot = File.ReadAllBytes(bootROMPath);

            ScrapeMetaData(rom);
            reg      = registers;
            reg.PC   = 0x0;           // Bootrom starts at 0x00
            this.ppu = ppu;

            cartridgeNorm = ConstructCartridge(rom);
            bootROM       = new BootRom(ppu, boot, this, cartridgeNorm);
            cartridge     = bootROM;

            cartridge.AttachRegisters(reg);
            cartridgeNorm.AttachRegisters(reg);
        }
 public BootRom(PPU ppu, byte[] rom, Memory memory, Cartridge cartridge) : base(ppu, 0, 0, rom)
 {
     this.memory    = memory;
     this.cartridge = cartridge;
 }