Ejemplo n.º 1
0
 /// <summary>
 /// コンストラクタ
 /// </summary>
 /// <param name="rom"></param>
 public Nes(byte[] rom)
 {
     this.Cartridge = NesCartridge.Load(rom);
     this.Controller = new NesGameController();
     this.Ppu = new Ppu.NesPpu(this.Cartridge.GetCopyChrRom1(), this.Cartridge.GetCopyChrRom2(), this.Cartridge.IsHMirror, this.Cartridge.IsVMirror, x => this.Image = x);
     this.MemoryMap = new Cpu.NesCpuMemoryMap(this.Cartridge.GetCopyPgRom1(), this.Cartridge.GetCopyPgRom2(), this.Ppu,this.Controller);
     this.Cpu = new Cpu.NesCpu(this.MemoryMap, this.Ppu);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="map"></param>
        /// <param name="ppu"></param>
        public NesCpu(NesCpuMemoryMap map, INesPpuVBlank ppu)
        {
            this.Clock = new NesCpuClock(ppu);
            this.MemoryMap = map;
            this.PpuVblank = ppu;

            // CPU命令に対応するAction情報を作成
            this.opCodeActionDictionary = CpuCommandTable.Table
                .Select(x => x.Value.Command)
                .Distinct()
                .Select(x =>
                {
                    var instance = Expression.Constant(this, typeof(NesCpu));
                    var callMethod = Expression.Call(
                        instance,
                        instance.Type.GetMethod(x.ToString(),
                        System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
                        );
                    var lambda = Expression.Lambda<Action>(callMethod);
                    return new { Method = lambda.Compile(), Key = x };
                })
                .ToDictionary(x => x.Key, x => x.Method);
        }