Ejemplo n.º 1
0
        public EmulatedCartridge(byte[] romContents, IExternalMemory externalMemory)
        {
            if (romContents == null)
            {
                throw new ArgumentNullException(nameof(romContents));
            }
            if (externalMemory == null)
            {
                throw new ArgumentNullException(nameof(externalMemory));
            }
            _romContents   = romContents;
            ExternalMemory = externalMemory;

            if (CartridgeType.IsRom())
            {
                BankController = new RomOnlyBankController(this);
            }
            else if (CartridgeType.IsMbc1())
            {
                BankController = new MemoryBankController1(this);
            }
            else if (CartridgeType.IsMbc2())
            {
                BankController = new MemoryBankController2(this);
            }
            else if (CartridgeType.IsMbc3())
            {
                BankController = new MemoryBankController3(this);
            }
            else
            {
                throw new NotSupportedException("Unsupported cartridge type " + CartridgeType + ".");
            }
        }
Ejemplo n.º 2
0
        public void LoadDevice(string romFilePath, string ramFilePath)
        {
            UnloadDevice();

            _currentExternalMemory = new BufferedExternalMemory(ramFilePath);
            var cartridge = new EmulatedCartridge(File.ReadAllBytes(romFilePath), _currentExternalMemory);

            _currentExternalMemory.SetBufferSize(cartridge.ExternalRamSize);
            CurrentDevice = new GameBoy.GameBoy(cartridge, new WinMmTimer(60), !Properties.Settings.Default.ForceOriginalGameBoy);
            ApplyColorPalettes();
            OnDeviceLoaded(new DeviceEventArgs(CurrentDevice));
        }