Esempio n. 1
0
        /// <summary>
        /// Connects to the gameboy a new cartridge with the given contents.
        /// </summary>
        /// <param name="cartridgeData"></param>
        public bool LoadCartridge(string cartridgeFullFilename, byte[] cartridgeData)
        {
            if (_state.Run)
            {
                Reset();
            }
            _cartridge = new Cartridge.Cartridge();
            _cartridge.Load(cartridgeData);

            _cpu.ResetBreakpoints();
            CartridgeFilename      = Path.GetFileNameWithoutExtension(cartridgeFullFilename);
            CartridgeDirectory     = Path.GetDirectoryName(cartridgeFullFilename);
            _apu.CartridgeFilename = this.CartridgeFilename;
            // We create the MemoryHandler according to the data
            // from the cartridge and set it to the memory.
            // From this point onwards, all the access to memory
            // are done throught the MemoryHandler
            MemoryHandler memoryHandler = MemoryHandlerFactory.CreateMemoryHandler(this);

            if (memoryHandler == null)
            {
                // We destroy all the info
                _cartridge             = null;
                CartridgeFilename      = "";
                CartridgeDirectory     = "";
                _apu.CartridgeFilename = "";

                return(false);
            }
            _memory.SetMemoryHandler(memoryHandler);

            return(true);
        }
Esempio n. 2
0
        /// <summary>
        /// Connects to the gameboy a new cartridge with the given contents.
        /// </summary>
        /// <param name="cartridgeData"></param>
        public bool LoadCartridge(string cartridgeFullFilename, byte[] cartridgeData)
        {
            if (_state.Run) { Reset(); }
            _cartridge = new Cartridge.Cartridge();
            _cartridge.Load(cartridgeData);

            _cpu.ResetBreakpoints();
            CartridgeFilename = Path.GetFileNameWithoutExtension(cartridgeFullFilename);
            CartridgeDirectory = Path.GetDirectoryName(cartridgeFullFilename);
            _apu.CartridgeFilename = this.CartridgeFilename;
            // We create the MemoryHandler according to the data
            // from the cartridge and set it to the memory.
            // From this point onwards, all the access to memory
            // are done throught the MemoryHandler
            MemoryHandler memoryHandler = MemoryHandlerFactory.CreateMemoryHandler(this);
            if (memoryHandler == null)
            {
                // We destroy all the info
                _cartridge = null;
                CartridgeFilename = "";
                CartridgeDirectory = "";
                _apu.CartridgeFilename = "";

                return false;
            }
            _memory.SetMemoryHandler(memoryHandler);

            return true;
        }