示例#1
0
文件: GameBoy.cs 项目: Scott-Klein/GB
        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;
        }
示例#2
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);
        }
示例#3
0
        public Memory(string romPath)
        {
            byte[] rom = File.ReadAllBytes(romPath);

            ROM_TITLE     = GetROMTitle(rom);
            gameType      = GetGameType(rom);
            cartridgeType = GetCartridgeType(rom);

            int romBanks = GetNumROMBanks(rom);
            int ramBanks = GetNumRAMBanks(rom);

            destinationCode = GetDestinationCode(rom);
            memoryModel     = MemoryModel.MM16x8;

            cartridge = AssembleCartridge(ramBanks, romBanks, rom);

            Console.WriteLine(ROM_TITLE);
            Console.WriteLine(gameType);
            Console.WriteLine(cartridgeType);
            Console.WriteLine("ROM Banks: {0}", romBanks);
            Console.WriteLine("RAM Banks: {0}", ramBanks);
            Console.WriteLine(destinationCode);
        }
 public BootRom(PPU ppu, byte[] rom, Memory memory, Cartridge cartridge) : base(ppu, 0, 0, rom)
 {
     this.memory    = memory;
     this.cartridge = cartridge;
 }
示例#5
0
 public void DetachBootROM()
 {
     cartridge = cartridgeNorm;
 }