Ejemplo n.º 1
0
        /// <summary>
        /// The picture unit
        /// </summary>
        /// <param name="tv">The tv format</param>
        /// <param name="paletteFormat">Palette Format</param>
        /// <param name="engine">Engine NES</param>
        public Ppu(TvFormat tv, PaletteFormat paletteFormat, NesEngine engine)
        {
            _engine    = engine;
            _cartridge = _engine.Memory.Map.Cartridge;

            VRam   = new byte[0x2000];
            SprRam = new byte[0x100];
            SetTvFormat(tv, paletteFormat);
            Debug.WriteLine(this, "PPU initialized ok.", DebugStatus.Cool);
        }
Ejemplo n.º 2
0
 public NesEngine(TvFormat tvFormat, PaletteFormat plFormat)
 {
     AutoSaveSram = true;
     Debug.WriteLine(this, "Initializeing the nes emulation engine...", DebugStatus.None);
     TvFormat = tvFormat;
     //Initialize Engine
     Memory = new Memory.Memory(this);
     Cpu = new Cpu(Memory, tvFormat, this);
     Cpu.PauseToggle += CpuPauseToggle;
     Ppu = new Ppu(tvFormat, plFormat, this);
     Debug.WriteLine(this, "Nes initialized ok.", DebugStatus.Cool);
 }
Ejemplo n.º 3
0
        public void SetTvFormat(TvFormat format, PaletteFormat plFormat)
        {
            switch (format)
            {
            case TvFormat.Ntsc:
                ScanlinesPerFrame = 261;
                _framePeriod      = 0.01667; //60 FPS
                //FramePeriod = 2;
                ScanlineOfVblank = 244;
                if (plFormat.UseInternalPalette)
                {
                    switch (plFormat.UseInternalPaletteMode)
                    {
                    case UseInternalPaletteMode.Auto:
                        Palette = Paletter.NtscPalette;
                        break;

                    case UseInternalPaletteMode.Ntsc:
                        Palette = Paletter.NtscPalette;
                        break;

                    case UseInternalPaletteMode.Pal:
                        Palette = Paletter.PalPalette;
                        break;
                    }
                }
                else
                {
                    if (Paletter.LoadPalette(plFormat.ExternalPalettePath) != null)
                    {
                        Palette = Paletter.LoadPalette(plFormat.ExternalPalettePath);
                    }
                    else
                    {
                        Palette = Paletter.NtscPalette;
                        Debug.WriteLine(this,
                                        "Could not find the external palette file, uses the defualt palette for NTSC.",
                                        DebugStatus.Error);
                    }
                }
                break;

            case TvFormat.Pal:
                ScanlinesPerFrame = 311;
                _framePeriod      = 0.020; //50 FPS
                ScanlineOfVblank  = 290;
                if (plFormat.UseInternalPalette)
                {
                    switch (plFormat.UseInternalPaletteMode)
                    {
                    case UseInternalPaletteMode.Auto:
                        Palette = Paletter.PalPalette;
                        break;

                    case UseInternalPaletteMode.Ntsc:
                        Palette = Paletter.NtscPalette;
                        break;

                    case UseInternalPaletteMode.Pal:
                        Palette = Paletter.PalPalette;
                        break;
                    }
                }
                else
                {
                    if (Paletter.LoadPalette(plFormat.ExternalPalettePath) != null)
                    {
                        Palette = Paletter.LoadPalette(plFormat.ExternalPalettePath);
                    }
                    else
                    {
                        Palette = Paletter.PalPalette;
                        Debug.WriteLine(this,
                                        "Could not find the external palette file, uses the defualt palette for PAL.",
                                        DebugStatus.Error);
                    }
                }
                break;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The picture unit
        /// </summary>
        /// <param name="tv">The tv format</param>
        /// <param name="paletteFormat">Palette Format</param>
        /// <param name="engine">Engine NES</param>
        public Ppu(TvFormat tv, PaletteFormat paletteFormat, NesEngine engine)
        {
            _engine = engine;
            _cartridge = _engine.Memory.Map.Cartridge;

            VRam = new byte[0x2000];
            SprRam = new byte[0x100];
            SetTvFormat(tv, paletteFormat);
            Debug.WriteLine(this, "PPU initialized ok.", DebugStatus.Cool);
        }
Ejemplo n.º 5
0
 public void SetTvFormat(TvFormat format, PaletteFormat plFormat)
 {
     switch (format)
     {
         case TvFormat.Ntsc:
             ScanlinesPerFrame = 261;
             _framePeriod = 0.01667; //60 FPS
             //FramePeriod = 2;
             ScanlineOfVblank = 244;
             if (plFormat.UseInternalPalette)
             {
                 switch (plFormat.UseInternalPaletteMode)
                 {
                     case UseInternalPaletteMode.Auto:
                         Palette = Paletter.NtscPalette;
                         break;
                     case UseInternalPaletteMode.Ntsc:
                         Palette = Paletter.NtscPalette;
                         break;
                     case UseInternalPaletteMode.Pal:
                         Palette = Paletter.PalPalette;
                         break;
                 }
             }
             else
             {
                 if (Paletter.LoadPalette(plFormat.ExternalPalettePath) != null)
                 {
                     Palette = Paletter.LoadPalette(plFormat.ExternalPalettePath);
                 }
                 else
                 {
                     Palette = Paletter.NtscPalette;
                     Debug.WriteLine(this,
                                     "Could not find the external palette file, uses the defualt palette for NTSC.",
                                     DebugStatus.Error);
                 }
             }
             break;
         case TvFormat.Pal:
             ScanlinesPerFrame = 311;
             _framePeriod = 0.020; //50 FPS
             ScanlineOfVblank = 290;
             if (plFormat.UseInternalPalette)
             {
                 switch (plFormat.UseInternalPaletteMode)
                 {
                     case UseInternalPaletteMode.Auto:
                         Palette = Paletter.PalPalette;
                         break;
                     case UseInternalPaletteMode.Ntsc:
                         Palette = Paletter.NtscPalette;
                         break;
                     case UseInternalPaletteMode.Pal:
                         Palette = Paletter.PalPalette;
                         break;
                 }
             }
             else
             {
                 if (Paletter.LoadPalette(plFormat.ExternalPalettePath) != null)
                 {
                     Palette = Paletter.LoadPalette(plFormat.ExternalPalettePath);
                 }
                 else
                 {
                     Palette = Paletter.PalPalette;
                     Debug.WriteLine(this,
                                     "Could not find the external palette file, uses the defualt palette for PAL.",
                                     DebugStatus.Error);
                 }
             }
             break;
     }
 }
Ejemplo n.º 6
0
 public void SetupTv(TvFormat tvFormat, PaletteFormat palleteFormat)
 {
     Pause();
     Cpu.SetTvFormat(tvFormat);
     Ppu.SetTvFormat(tvFormat, palleteFormat);
 }