Beispiel #1
0
        public Gameboy(string romName)
        {
            window = new RenderWindow(new VideoMode(160 * scale, 144 * scale), "SpecBoy", Styles.Default);
            window.SetFramerateLimit(0);
            //window.SetVerticalSyncEnabled(false);

            timers    = new Timers();
            joypad    = new Joypad(window);
            ppu       = new Ppu(window, scale);
            cartridge = new Cartridge(romName);
            mem       = new Memory(timers, ppu, joypad, cartridge);
            cpu       = new Cpu(mem, ppu, timers);
        }
Beispiel #2
0
        public Memory(Timers timers, Ppu ppu, Joypad joypad, Cartridge cartridge)
        {
            this.timers    = timers;
            this.ppu       = ppu;
            this.joypad    = joypad;
            this.cartridge = cartridge;

            Mem = new byte[0x10000];

            try
            {
                BootRomEnabled = true;
                bootRom        = File.ReadAllBytes("DMG_ROM.bin");
            }
            catch (FileNotFoundException)
            {
                BootRomEnabled = false;
            }
        }
Beispiel #3
0
        public Cpu(Memory mem, Ppu ppu, Timers timers)
        {
            this.mem    = mem;
            this.timers = timers;
            this.ppu    = ppu;

            if (!mem.BootRomEnabled)
            {
                AF = 0x01b0;
                BC = 0x0013;
                DE = 0x00d8;
                HL = 0x014d;
                PC = 0x0100;
                SP = 0xfffe;

                ppu.Lcdc = 0x91;
                ppu.Bgp  = 0xfc;
                ppu.Obp0 = 0xff;
                ppu.Obp1 = 0xff;
            }
        }