예제 #1
0
        private void HardReset()
        {
            _ram = new byte[128];
            _mapper.HardReset();

            Cpu = new MOS6502X
            {
                ReadMemory      = ReadMemory,
                WriteMemory     = WriteMemory,
                PeekMemory      = PeekMemory,
                DummyReadMemory = ReadMemory,
                OnExecFetch     = ExecFetch
            };

            _tia.Reset();

            _m6532 = new M6532(this);
            Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8));             // set the initial PC

            // as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves.
            // some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532
            // executing a reset sequence at power on, but it's needed so let's hard code it for now
            Cpu.S = 0xFD;

            SetupMemoryDomains();
        }
        private void SyncState(Serializer ser)
        {
            ser.BeginSection("A2600");
            Cpu.SyncState(ser);
            ser.Sync("ram", ref this.Ram, false);
            ser.Sync("Lag", ref _lagcount);
            ser.Sync("Frame", ref _frame);
            ser.Sync("IsLag", ref _islag);
            ser.Sync("frameStartPending", ref _frameStartPending);
            ser.Sync("leftDifficultySwitchPressed", ref _leftDifficultySwitchPressed);
            ser.Sync("rightDifficultySwitchPressed", ref _rightDifficultySwitchPressed);
            ser.Sync("leftDifficultySwitchHeld", ref _leftDifficultySwitchHeld);
            ser.Sync("rightDifficultySwitchHeld", ref _rightDifficultySwitchHeld);

            _tia.SyncState(ser);
            M6532.SyncState(ser);
            ser.BeginSection("Mapper");
            _mapper.SyncState(ser);
            ser.EndSection();
            ser.EndSection();

            if (ser.IsReader)
            {
                SyncAllByteArrayDomains();
            }
        }
예제 #3
0
        private void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomain(
                    "Main RAM",
                    128,
                    MemoryDomain.Endian.Little,
                    addr => Ram[addr],
                    (addr, value) => Ram[addr] = value),
                new MemoryDomain(
                    "TIA",
                    16,
                    MemoryDomain.Endian.Little,
                    addr => _tia.ReadMemory((ushort)addr, true),
                    (addr, value) => this._tia.WriteMemory((ushort)addr, value)),
                new MemoryDomain(
                    "PIA",
                    1024,
                    MemoryDomain.Endian.Little,
                    addr => M6532.ReadMemory((ushort)addr, true),
                    (addr, value) => M6532.WriteMemory((ushort)addr, value)),
                new MemoryDomain(
                    "System Bus",
                    65536,
                    MemoryDomain.Endian.Little,
                    addr => _mapper.PeekMemory((ushort)addr),
                    (addr, value) => _mapper.PokeMemory((ushort)addr, value))
            };

            if (_mapper is mDPC)             // TODO: also mDPCPlus
            {
                domains.Add(new MemoryDomain(
                                "DPC",
                                2048,
                                MemoryDomain.Endian.Little,
                                addr => (_mapper as mDPC).DspData[addr],
                                (addr, value) => (_mapper as mDPC).DspData[addr] = value));
            }

            if (_mapper.HasCartRam)
            {
                domains.Add(new MemoryDomain(
                                "Cart Ram",
                                _mapper.CartRam.Len,
                                MemoryDomain.Endian.Little,
                                addr => _mapper.CartRam[(int)addr],
                                (addr, value) => _mapper.CartRam[(int)addr] = value));
            }

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
예제 #4
0
        private void HardReset()
        {
            _ram = new byte[128];
            _mapper.HardReset();

            Cpu = new MOS6502X <CpuLink>(new CpuLink(this));

            _tia.Reset();
            _m6532 = new M6532(this);
            SetupMemoryDomains();
            cyc_counter = 0;
        }
예제 #5
0
 private void SyncState(Serializer ser)
 {
     ser.BeginSection("A2600");
     Cpu.SyncState(ser);
     ser.Sync("ram", ref this.Ram, false);
     ser.Sync("Lag", ref _lagcount);
     ser.Sync("Frame", ref _frame);
     ser.Sync("IsLag", ref _islag);
     ser.Sync("frameStartPending", ref _frameStartPending);
     _tia.SyncState(ser);
     M6532.SyncState(ser);
     ser.BeginSection("Mapper");
     _mapper.SyncState(ser);
     ser.EndSection();
     ser.EndSection();
 }
예제 #6
0
        private void RebootCore()
        {
            // Regenerate mapper here to make sure its state is entirely clean
            _mapper   = CreateMapper(this, _game.GetOptions()["m"], Rom.Length);
            _lagCount = 0;
            Cpu       = new MOS6502X <CpuLink>(new CpuLink(this));

            if (_game["PAL"])
            {
                _pal = true;
            }
            else if (_game["NTSC"])
            {
                _pal = false;
            }
            else
            {
                _pal = DetectPal(_game, Rom);
            }

            // dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
            _tia = new TIA(this, _pal, Settings.SECAMColors);

            _dcfilter = new DCFilter(_tia, 256);

            _m6532 = new M6532(this);

            HardReset();

            RomDetails = $"{_game.Name}\r\n{SHA1Checksum.ComputePrefixedHex(Rom)}\r\n{MD5Checksum.ComputePrefixedHex(Rom)}\r\nMapper Impl \"{_mapper.GetType()}\"";

            // Some games (ex. 3D tic tac toe), turn off the screen for extended periods, so we need to allow for this here.
            if (_game.GetOptions().TryGetValue("SP_FRAME", out var spFrameStr) && spFrameStr == "true")
            {
                SP_FRAME = true;
            }
            // Some games wait for reset to be unpressed before turning the screen back on, hack unset it if needed
            if (_game.GetOptions().TryGetValue("SP_RESET", out var spResetStr) && spResetStr == "true")
            {
                SP_RESET = true;
            }
            // Ditto select (ex. Karate)
            if (_game.GetOptions().TryGetValue("SP_SELECT", out var spSelectStr) && spSelectStr == "true")
            {
                SP_SELECT = true;
            }
        }
        private void RebootCore()
        {
            // Regenerate mapper here to make sure its state is entirely clean
            _mapper   = CreateMapper(this, _game.GetOptions()["m"], Rom.Length);
            _lagCount = 0;
            Cpu       = new MOS6502X <CpuLink>(new CpuLink(this));

            if (_game["PAL"])
            {
                _pal = true;
            }
            else if (_game["NTSC"])
            {
                _pal = false;
            }
            else
            {
                _pal = DetectPal(_game, Rom);
            }

            // dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
            _tia = new TIA(this, _pal, Settings.SECAMColors);

            _dcfilter = new DCFilter(_tia, 256);

            _m6532 = new M6532(this);

            HardReset();

            RomDetails = $"{_game.Name}\r\nSHA1:{Rom.HashSHA1()}\r\nMD5:{Rom.HashMD5()}\r\nMapper Impl \"{_mapper.GetType()}\"";

            // Some games (ex. 3D tic tac toe), turn off the screen for extended periods, so we need to allow for this here.
            if (_game.GetOptions().ContainsKey("SP_FRAME"))
            {
                if (_game.GetOptions()["SP_FRAME"] == "true")
                {
                    SP_FRAME = true;
                }
            }
            if (_game.GetOptions().ContainsKey("SP_RESET"))
            {
                if (_game.GetOptions()["SP_RESET"] == "true")
                {
                    SP_RESET = true;
                }
            }
        }
예제 #8
0
        public void HardReset()
        {
            Ram = new byte[128];
            _mapper.HardReset();

            Cpu = new MOS6502X
            {
                ReadMemory      = this.ReadMemory,
                WriteMemory     = this.WriteMemory,
                PeekMemory      = this.PeekMemory,
                DummyReadMemory = this.ReadMemory,
                OnExecFetch     = this.ExecFetch
            };

            _tia.Reset();

            M6532  = new M6532(this);
            Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8));             // set the initial PC
        }
예제 #9
0
        private void HardReset()
        {
            _ram = new byte[128];
            _mapper.HardReset();

            Cpu = new MOS6502X
            {
                ReadMemory      = ReadMemory,
                WriteMemory     = WriteMemory,
                PeekMemory      = PeekMemory,
                DummyReadMemory = ReadMemory,
                OnExecFetch     = ExecFetch
            };

            _tia.Reset();
            _m6532 = new M6532(this);
            SetupMemoryDomains();
            cyc_counter = 0;
        }
예제 #10
0
        private void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "TIA",
                    16,
                    MemoryDomain.Endian.Little,
                    addr => _tia.ReadMemory((ushort)addr, true),
                    (addr, value) => this._tia.WriteMemory((ushort)addr, value, true), 1),
                new MemoryDomainDelegate(
                    "PIA",
                    1024,
                    MemoryDomain.Endian.Little,
                    addr => M6532.ReadMemory((ushort)addr, true),
                    (addr, value) => M6532.WriteMemory((ushort)addr, value), 1),
                new MemoryDomainDelegate(
                    "System Bus",
                    65536,
                    MemoryDomain.Endian.Little,
                    addr => _mapper.PeekMemory((ushort)addr),
                    (addr, value) => _mapper.PokeMemory((ushort)addr, value), 1)
            };

            if (_mapper.HasCartRam)
            {
                domains.Add(new MemoryDomainDelegate(
                                "Cart Ram",
                                _mapper.CartRam.Len,
                                MemoryDomain.Endian.Little,
                                addr => _mapper.CartRam[(int)addr],
                                (addr, value) => _mapper.CartRam[(int)addr] = value, 1));
            }

            SyncAllByteArrayDomains();

            MemoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);

            _memoryDomainsInit = true;
        }
예제 #11
0
        private void HardReset()
        {
            Ram = new byte[128];
            _mapper.HardReset();

            Cpu = new MOS6502X
            {
                ReadMemory = this.ReadMemory,
                WriteMemory = this.WriteMemory,
                PeekMemory = this.PeekMemory,
                DummyReadMemory = this.ReadMemory,
                OnExecFetch = this.ExecFetch
            };

            _tia.Reset();

            M6532 = new M6532(this);
            Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8)); // set the initial PC

            // as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves.
            // some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532
            // executing a reset sequence at power on, but it's needed so let's hard code it for now
            Cpu.S = 0xFD;
        }
예제 #12
0
        private void RebootCore()
        {
            // Regenerate mapper here to make sure its state is entirely clean
            switch (_game.GetOptionsDict()["m"])
            {
            case "2IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 2);
                break;

            case "4IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 4);
                break;

            case "8IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 8);
                break;

            case "16IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 16);
                break;

            case "32IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 32);
                break;

            case "AR":
                _mapper = new mAR(this);                         // This mapper has to set up configurations in the contructor.
                break;

            case "4K":
                _mapper = new m4K();
                break;

            case "2K":
                _mapper = new m2K();
                break;

            case "CM":
                _mapper = new mCM();
                break;

            case "CV":
                _mapper = new mCV();
                break;

            case "DPC":
                _mapper = new mDPC();
                break;

            case "DPC+":
                _mapper = new mDPCPlus();
                break;

            case "F8":
                _mapper = new mF8();
                break;

            case "F8SC":
                _mapper = new mF8SC();
                break;

            case "F6":
                _mapper = new mF6();
                break;

            case "F6SC":
                _mapper = new mF6SC();
                break;

            case "F4":
                _mapper = new mF4();
                break;

            case "F4SC":
                _mapper = new mF4SC();
                break;

            case "FE":
                _mapper = new mFE();
                break;

            case "E0":
                _mapper = new mE0();
                break;

            case "3F":
                _mapper = new m3F();
                break;

            case "FA":
                _mapper = new mFA();
                break;

            case "FA2":
                _mapper = new mFA2();
                break;

            case "E7":
                _mapper = new mE7();
                break;

            case "F0":
                _mapper = new mF0();
                break;

            case "UA":
                _mapper = new mUA();
                break;

            // Special Sega Mapper which has swapped banks
            case "F8_sega":
                _mapper = new mF8_sega();
                break;

            // Homebrew mappers
            case "3E":
                _mapper = new m3E();
                break;

            case "0840":
                _mapper = new m0840();
                break;

            case "MC":
                _mapper = new mMC();
                break;

            case "EF":
                _mapper = new mEF();
                break;

            case "EFSC":
                _mapper = new mEFSC();
                break;

            case "X07":
                _mapper = new mX07();
                break;

            case "4A50":
                _mapper = new m4A50();
                break;

            case "SB":
                _mapper = new mSB();
                break;

            default:
                throw new InvalidOperationException("mapper not supported: " + _game.GetOptionsDict()["m"]);
            }

            _mapper.Core = this;

            _lagCount = 0;
            Cpu       = new MOS6502X <CpuLink>(new CpuLink(this));

            if (_game["PAL"])
            {
                _pal = true;
            }
            else if (_game["NTSC"])
            {
                _pal = false;
            }
            else
            {
                _pal = DetectPal(_game, Rom);
            }

            // dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
            _tia = new TIA(this, _pal, Settings.SECAMColors);

            _dcfilter = new DCFilter(_tia, 256);

            _m6532 = new M6532(this);

            HardReset();

            // Show mapper class on romstatusdetails
            CoreComm.RomStatusDetails = $"{this._game.Name}\r\nSHA1:{Rom.HashSHA1()}\r\nMD5:{Rom.HashMD5()}\r\nMapper Impl \"{_mapper.GetType()}\"";

            // Some games (ex. 3D tic tac toe), turn off the screen for extended periods, so we need to allow for this here.
            if (_game.GetOptionsDict().ContainsKey("SP_FRAME"))
            {
                if (_game.GetOptionsDict()["SP_FRAME"] == "true")
                {
                    SP_FRAME = true;
                }
            }
            if (_game.GetOptionsDict().ContainsKey("SP_RESET"))
            {
                if (_game.GetOptionsDict()["SP_RESET"] == "true")
                {
                    SP_RESET = true;
                }
            }
        }
예제 #13
0
        public void RebootCore()
        {
            // Regenerate mapper here to make sure its state is entirely clean
            switch (_game.GetOptionsDict()["m"])
            {
            case "2IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 2);
                break;

            case "4IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 4);
                break;

            case "8IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 8);
                break;

            case "16IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 16);
                break;

            case "32IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 32);
                break;

            case "AR":
                _mapper = new mAR(this);                         // This mapper has to set up configurations in the contructor.
                break;

            case "4K":
                _mapper = new m4K();
                break;

            case "2K":
                _mapper = new m2K();
                break;

            case "CM":
                _mapper = new mCM();
                break;

            case "CV":
                _mapper = new mCV();
                break;

            case "DPC":
                _mapper = new mDPC();
                break;

            case "DPC+":
                _mapper = new mDPCPlus();
                break;

            case "F8":
                _mapper = new mF8();
                break;

            case "F8SC":
                _mapper = new mF8SC();
                break;

            case "F6":
                _mapper = new mF6();
                break;

            case "F6SC":
                _mapper = new mF6SC();
                break;

            case "F4":
                _mapper = new mF4();
                break;

            case "F4SC":
                _mapper = new mF4SC();
                break;

            case "FE":
                _mapper = new mFE();
                break;

            case "E0":
                _mapper = new mE0();
                break;

            case "3F":
                _mapper = new m3F();
                break;

            case "FA":
                _mapper = new mFA();
                break;

            case "FA2":
                _mapper = new mFA2();
                break;

            case "E7":
                _mapper = new mE7();
                break;

            case "F0":
                _mapper = new mF0();
                break;

            case "UA":
                _mapper = new mUA();
                break;

            // Homebrew mappers
            case "3E":
                _mapper = new m3E();
                break;

            case "0840":
                _mapper = new m0840();
                break;

            case "MC":
                _mapper = new mMC();
                break;

            case "EF":
                _mapper = new mEF();
                break;

            case "EFSC":
                _mapper = new mEFSC();
                break;

            case "X07":
                _mapper = new mX07();
                break;

            case "4A50":
                _mapper = new m4A50();
                break;

            case "SB":
                _mapper = new mSB();
                break;

            default:
                throw new InvalidOperationException("mapper not supported: " + _game.GetOptionsDict()["m"]);
            }

            _mapper.Core = this;

            _lagcount = 0;
            Cpu       = new MOS6502X
            {
                ReadMemory      = this.ReadMemory,
                WriteMemory     = this.WriteMemory,
                PeekMemory      = this.PeekMemory,
                DummyReadMemory = this.ReadMemory,
                OnExecFetch     = this.ExecFetch
            };

            if (_game["PAL"])
            {
                _pal = true;
            }
            else if (_game["NTSC"])
            {
                _pal = false;
            }
            else
            {
                _pal = DetectPal(_game, Rom);
            }

            _tia = new TIA(this, _pal, Settings.SECAMColors);
            _tia.GetFrameRate(out CoreComm.VsyncNum, out CoreComm.VsyncDen);

            // dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
            _dcfilter = DCFilter.AsISoundProvider(_tia, 256);

            M6532 = new M6532(this);

            // Set up the system state here. for instance..
            // Read from the reset vector for where to start
            Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8));             // set the initial PC

            // Show mapper class on romstatusdetails
            CoreComm.RomStatusDetails =
                string.Format(
                    "{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"",
                    this._game.Name,
                    Rom.HashSHA1(),
                    Rom.HashMD5(),
                    _mapper.GetType());
        }
예제 #14
0
        private void RebootCore()
        {
            // Regenerate mapper here to make sure its state is entirely clean
            switch (_game.GetOptionsDict()["m"])
            {
            case "2IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 2);
                break;

            case "4IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 4);
                break;

            case "8IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 8);
                break;

            case "16IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 16);
                break;

            case "32IN1":
                _mapper = SetMultiCartMapper(Rom.Length, 32);
                break;

            case "AR":
                _mapper = new mAR(this);                         // This mapper has to set up configurations in the contructor.
                break;

            case "4K":
                _mapper = new m4K();
                break;

            case "2K":
                _mapper = new m2K();
                break;

            case "CM":
                _mapper = new mCM();
                break;

            case "CV":
                _mapper = new mCV();
                break;

            case "DPC":
                _mapper = new mDPC();
                break;

            case "DPC+":
                _mapper = new mDPCPlus();
                break;

            case "F8":
                _mapper = new mF8();
                break;

            case "F8SC":
                _mapper = new mF8SC();
                break;

            case "F6":
                _mapper = new mF6();
                break;

            case "F6SC":
                _mapper = new mF6SC();
                break;

            case "F4":
                _mapper = new mF4();
                break;

            case "F4SC":
                _mapper = new mF4SC();
                break;

            case "FE":
                _mapper = new mFE();
                break;

            case "E0":
                _mapper = new mE0();
                break;

            case "3F":
                _mapper = new m3F();
                break;

            case "FA":
                _mapper = new mFA();
                break;

            case "FA2":
                _mapper = new mFA2();
                break;

            case "E7":
                _mapper = new mE7();
                break;

            case "F0":
                _mapper = new mF0();
                break;

            case "UA":
                _mapper = new mUA();
                break;

            // Special Sega Mapper which has swapped banks
            case "F8_sega":
                _mapper = new mF8_sega();
                break;

            // Homebrew mappers
            case "3E":
                _mapper = new m3E();
                break;

            case "0840":
                _mapper = new m0840();
                break;

            case "MC":
                _mapper = new mMC();
                break;

            case "EF":
                _mapper = new mEF();
                break;

            case "EFSC":
                _mapper = new mEFSC();
                break;

            case "X07":
                _mapper = new mX07();
                break;

            case "4A50":
                _mapper = new m4A50();
                break;

            case "SB":
                _mapper = new mSB();
                break;

            default:
                throw new InvalidOperationException("mapper not supported: " + _game.GetOptionsDict()["m"]);
            }

            _mapper.Core = this;

            _lagcount = 0;
            Cpu       = new MOS6502X
            {
                ReadMemory      = this.ReadMemory,
                WriteMemory     = this.WriteMemory,
                PeekMemory      = this.PeekMemory,
                DummyReadMemory = this.ReadMemory,
                OnExecFetch     = this.ExecFetch
            };

            if (_game["PAL"])
            {
                _pal = true;
            }
            else if (_game["NTSC"])
            {
                _pal = false;
            }
            else
            {
                _pal = DetectPal(_game, Rom);
            }

            // dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
            _tia = new TIA(this, _pal, Settings.SECAMColors, CoreComm.VsyncRate > 55.0 ? 735 : 882);
            _tia.GetFrameRate(out CoreComm.VsyncNum, out CoreComm.VsyncDen);

            _dcfilter = new DCFilter(_tia, 256);

            M6532 = new M6532(this);

            // Set up the system state here. for instance..
            // Read from the reset vector for where to start
            Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8));             // set the initial PC

            // Show mapper class on romstatusdetails
            CoreComm.RomStatusDetails =
                string.Format(
                    "{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"",
                    this._game.Name,
                    Rom.HashSHA1(),
                    Rom.HashMD5(),
                    _mapper.GetType());


            // as it turns out, the stack pointer cannot be set to 0 for some games as they do not initilize it themselves.
            // some documentation seems to indicate it should beset to FD, but currently there is no documentation of the 6532
            // executing a reset sequence at power on, but it's needed so let's hard code it for now
            Cpu.S = 0xFD;
        }
예제 #15
0
        public Atari2600(CoreComm comm, GameInfo game, byte[] rom, object settings, object syncSettings)
        {
            Ram          = new byte[128];
            CoreComm     = comm;
            Settings     = (A2600Settings)settings ?? new A2600Settings();
            SyncSettings = (A2600SyncSettings)syncSettings ?? new A2600SyncSettings();

            var domains = new List <MemoryDomain>
            {
                new MemoryDomain(
                    "Main RAM",
                    128,
                    MemoryDomain.Endian.Little,
                    addr => Ram[addr],
                    (addr, value) => Ram[addr] = value),
                new MemoryDomain(
                    "TIA",
                    16,
                    MemoryDomain.Endian.Little,
                    addr => _tia.ReadMemory((ushort)addr, true),
                    (addr, value) => this._tia.WriteMemory((ushort)addr, value)),
                new MemoryDomain(
                    "PIA",
                    1024,
                    MemoryDomain.Endian.Little,
                    addr => M6532.ReadMemory((ushort)addr, true),
                    (addr, value) => M6532.WriteMemory((ushort)addr, value)),
                new MemoryDomain(
                    "System Bus",
                    8192,
                    MemoryDomain.Endian.Little,
                    addr => _mapper.PeekMemory((ushort)addr),
                    (addr, value) => _mapper.PokeMemory((ushort)addr, value))
            };

            CoreComm.CpuTraceAvailable = true;
            Rom   = rom;
            _game = game;

            if (!game.GetOptionsDict().ContainsKey("m"))
            {
                game.AddOption("m", DetectMapper(rom));
            }

            Console.WriteLine("Game uses mapper " + game.GetOptionsDict()["m"]);
            RebootCore();

            if (_mapper is mDPC)             // TODO: also mDPCPlus
            {
                domains.Add(new MemoryDomain(
                                "DPC",
                                2048,
                                MemoryDomain.Endian.Little,
                                addr => (_mapper as mDPC).DspData[addr],
                                (addr, value) => (_mapper as mDPC).DspData[addr] = value));
            }

            if (_mapper.HasCartRam)
            {
                domains.Add(new MemoryDomain(
                                "Cart Ram",
                                _mapper.CartRam.Len,
                                MemoryDomain.Endian.Little,
                                addr => _mapper.CartRam[addr],
                                (addr, value) => _mapper.CartRam[addr] = value));
            }

            MemoryDomains = new MemoryDomainList(domains);
        }
예제 #16
0
		public void RebootCore()
		{
			// Regenerate mapper here to make sure its state is entirely clean
			switch (_game.GetOptionsDict()["m"])
			{
				case "2IN1":
					_mapper = SetMultiCartMapper(Rom.Length, 2);
					break;
				case "4IN1":
					_mapper = SetMultiCartMapper(Rom.Length, 4);
					break;
				case "8IN1":
					_mapper = SetMultiCartMapper(Rom.Length, 8);
					break;
				case "16IN1":
					_mapper = SetMultiCartMapper(Rom.Length, 16);
					break;
				case "32IN1":
					_mapper = SetMultiCartMapper(Rom.Length, 32);
					break;
				case "AR":
					_mapper = new mAR(this); // This mapper has to set up configurations in the contructor.
					break;
				case "4K":
					_mapper = new m4K();
					break;
				case "2K":
					_mapper = new m2K();
					break;
				case "CM":
					_mapper = new mCM();
					break;
				case "CV":
					_mapper = new mCV();
					break;
				case "DPC":
					_mapper = new mDPC();
					break;
				case "DPC+":
					_mapper = new mDPCPlus();
					break;
				case "F8":
					_mapper = new mF8();
					break;
				case "F8SC":
					_mapper = new mF8SC();
					break;
				case "F6":
					_mapper = new mF6();
					break;
				case "F6SC":
					_mapper = new mF6SC();
					break;
				case "F4":
					_mapper = new mF4();
					break;
				case "F4SC":
					_mapper = new mF4SC();
					break;
				case "FE":
					_mapper = new mFE();
					break;
				case "E0":
					_mapper = new mE0();
					break;
				case "3F":
					_mapper = new m3F();
					break;
				case "FA":
					_mapper = new mFA();
					break;
				case "FA2":
					_mapper = new mFA2();
					break;
				case "E7":
					_mapper = new mE7();
					break;
				case "F0":
					_mapper = new mF0();
					break;
				case "UA":
					_mapper = new mUA();
					break;

				// Homebrew mappers
				case "3E":
					_mapper = new m3E();
					break;
				case "0840":
					_mapper = new m0840();
					break;
				case "MC":
					_mapper = new mMC();
					break;
				case "EF":
					_mapper = new mEF();
					break;
				case "EFSC":
					_mapper = new mEFSC();
					break;
				case "X07":
					_mapper = new mX07();
					break;
				case "4A50":
					_mapper = new m4A50();
					break;
				case "SB":
					_mapper = new mSB();
					break;

				default:
					throw new InvalidOperationException("mapper not supported: " + _game.GetOptionsDict()["m"]);
			}

			_mapper.Core = this;

			_lagcount = 0;
			Cpu = new MOS6502X
			{
				ReadMemory = this.ReadMemory,
				WriteMemory = this.WriteMemory,
				PeekMemory = this.PeekMemory,
				DummyReadMemory = this.ReadMemory,
				OnExecFetch = this.ExecFetch
			};

			if (_game["PAL"])
			{
				_pal = true;
			}
			else if (_game["NTSC"])
			{
				_pal = false;
			}
			else
			{
				_pal = DetectPal(_game, Rom);
			}

			_tia = new TIA(this, _pal, Settings.SECAMColors);
			_tia.GetFrameRate(out CoreComm.VsyncNum, out CoreComm.VsyncDen);

			// dcfilter coefficent is from real observed hardware behavior: a latched "1" will fully decay by ~170 or so tia sound cycles
			_dcfilter = DCFilter.AsISoundProvider(_tia, 256);

			M6532 = new M6532(this);

			// Set up the system state here. for instance..
			// Read from the reset vector for where to start
			Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8)); // set the initial PC

			// Show mapper class on romstatusdetails
			CoreComm.RomStatusDetails =
				string.Format(
					"{0}\r\nSHA1:{1}\r\nMD5:{2}\r\nMapper Impl \"{3}\"",
					this._game.Name,
					Rom.HashSHA1(),
					Rom.HashMD5(),
					_mapper.GetType());
		}
예제 #17
0
		public void HardReset()
		{
			Ram = new byte[128];
			_mapper.HardReset();

			Cpu = new MOS6502X
			{
				ReadMemory = this.ReadMemory,
				WriteMemory = this.WriteMemory,
				PeekMemory = this.PeekMemory,
				DummyReadMemory = this.ReadMemory,
				OnExecFetch = this.ExecFetch
			};

			_tia.Reset();

			M6532 = new M6532(this);
			Cpu.PC = (ushort)(ReadMemory(0x1FFC) + (ReadMemory(0x1FFD) << 8)); // set the initial PC
		}