Exemple #1
0
        public VideoGdiHiRes(TvFormat tvFormat, Control surface, string pPath, int chrPages)
        {
            if (surface == null)
                return;
            Debug.WriteLine(this, "Initializeing GDI ...", DebugStatus.None);
            switch (tvFormat)
            {
                case TvFormat.Ntsc:
                    _scanlinesToCut = 8;
                    _scanlines = 224;
                    _bitmap = new Bitmap(512, 448);
                    break;
                case TvFormat.Pal:
                    _scanlinesToCut = 0;
                    _scanlines = 240;
                    _bitmap = new Bitmap(512, 480);
                    break;
            }
            _surface = surface;
            UpdateSize(0, 0, _surface.Width + 1, _surface.Height + 1);

            if (pPath != "")
                ReadHiResPack(
                    Path.GetDirectoryName(pPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(pPath),
                    chrPages);

            Debug.WriteLine(this, "Video device " + @"""" + "GDI Hi Res" + @"""" + " Ok !!", DebugStatus.Cool);
        }
Exemple #2
0
        public VideoGdiHiRes(TvFormat tvFormat, Control surface, string pPath, int chrPages)
        {
            if (surface == null)
            {
                return;
            }
            Debug.WriteLine(this, "Initializeing GDI ...", DebugStatus.None);
            switch (tvFormat)
            {
            case TvFormat.Ntsc:
                _scanlinesToCut = 8;
                _scanlines      = 224;
                _bitmap         = new Bitmap(512, 448);
                break;

            case TvFormat.Pal:
                _scanlinesToCut = 0;
                _scanlines      = 240;
                _bitmap         = new Bitmap(512, 480);
                break;
            }
            _surface = surface;
            UpdateSize(0, 0, _surface.Width + 1, _surface.Height + 1);


            if (pPath != "")
            {
                ReadHiResPack(
                    Path.GetDirectoryName(pPath) + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(pPath),
                    chrPages);
            }

            Debug.WriteLine(this, "Video device " + @"""" + "GDI Hi Res" + @"""" + " Ok !!", DebugStatus.Cool);
        }
Exemple #3
0
        public VideoSlimDx(TvFormat tvFormat, Control surface, byte multi)
        {
            _multi = multi;
            _width = 256 * multi;

            if (surface == null)
            {
                return;
            }
            _surface = surface;
            switch (tvFormat)
            {
            case TvFormat.Ntsc:
                _height         = 224 * _multi;
                _firstLinesTCut = 8;
                break;

            case TvFormat.Pal:
                _height         = 240 * _multi;
                _firstLinesTCut = 0;
                break;
            }
            var sett = new VideoModeSettings();

            sett.Reload();
            ApplaySettings(sett);
            //InitializeDirect3D();
        }
Exemple #4
0
        public VideoGdi(TvFormat tvFormat, Control surface)
        {
            if (surface == null)
            {
                return;
            }
            Debug.WriteLine(this, "Initializeing GDI ...", DebugStatus.None);
            switch (tvFormat)
            {
            case TvFormat.Ntsc:
                _scanlinesToCut = 8;
                _scanlines      = 224;
                _bitmap         = new Bitmap(256, 224);
                break;

            case TvFormat.Pal:
                _scanlinesToCut = 0;
                _scanlines      = 240;
                _bitmap         = new Bitmap(256, 240);
                break;
            }
            _buffer  = new int[256 * _scanlines];
            _surface = surface;
            UpdateSize(0, 0, _surface.Width + 1, _surface.Height + 1);
            Debug.WriteLine(this, "Video device " + @"""" + "GDI" + @"""" + " Ok !!", DebugStatus.Cool);
        }
Exemple #5
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);
        }
Exemple #6
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);
 }
Exemple #7
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);
 }
Exemple #8
0
 public VideoGdi(TvFormat tvFormat, Control surface)
 {
     if (surface == null)
         return;
     Debug.WriteLine(this, "Initializeing GDI ...", DebugStatus.None);
     switch (tvFormat)
     {
         case TvFormat.Ntsc:
             _scanlinesToCut = 8;
             _scanlines = 224;
             _bitmap = new Bitmap(256, 224);
             break;
         case TvFormat.Pal:
             _scanlinesToCut = 0;
             _scanlines = 240;
             _bitmap = new Bitmap(256, 240);
             break;
     }
     _buffer = new int[256*_scanlines];
     _surface = surface;
     UpdateSize(0, 0, _surface.Width + 1, _surface.Height + 1);
     Debug.WriteLine(this, "Video device " + @"""" + "GDI" + @"""" + " Ok !!", DebugStatus.Cool);
 }
Exemple #9
0
        public VideoSlimDx(TvFormat tvFormat, Control surface, byte multi)
        {
            _multi = multi;
            _width = 256 * multi;

            if (surface == null)
                return;
            _surface = surface;
            switch (tvFormat)
            {
                case TvFormat.Ntsc:
                    _height = 224 * _multi;
                    _firstLinesTCut = 8;
                    break;
                case TvFormat.Pal:
                    _height = 240 * _multi;
                    _firstLinesTCut = 0;
                    break;
            }
            var sett = new VideoModeSettings();
            sett.Reload();
            ApplaySettings(sett);
            //InitializeDirect3D();
        }
Exemple #10
0
 public void SetTvFormat(TvFormat format)
 {
     if (!_Pause)
         return;
     switch (format)
     {
         case TvFormat.Ntsc:
             CyclesPerScanline = 113;
             break;
         case TvFormat.Pal:
             CyclesPerScanline = 106;
             break;
     }
 }
Exemple #11
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;
            }
        }
Exemple #12
0
        private bool _paused; //To ensure the cpu is paused

        #endregion Fields

        #region Constructors

        /// <summary>
        /// The 6502
        /// </summary>
        /// <param name="memory">The memory</param>
        /// <param name="tvFormat">The TV format</param>
        public Cpu(Memory.Memory memory, TvFormat tvFormat, NesEngine engine)
        {
            _engine = engine;
            MEM = memory;
            InitializeCPU(tvFormat);
        }
Exemple #13
0
 public void SetupTv(TvFormat tvFormat, PaletteFormat palleteFormat)
 {
     Pause();
     Cpu.SetTvFormat(tvFormat);
     Ppu.SetTvFormat(tvFormat, palleteFormat);
 }
Exemple #14
0
 public void SetupTv(TvFormat tvFormat, PaletteFormat palleteFormat)
 {
     Pause();
     Cpu.SetTvFormat(tvFormat);
     Ppu.SetTvFormat(tvFormat, palleteFormat);
 }
Exemple #15
0
 /// <summary>
 /// Initialize and set the timing of the cpu
 /// </summary>
 /// <param name="FORMAT">The tv format to set the cpu emulation for</param>
 private void InitializeCPU(TvFormat FORMAT)
 {
     switch (FORMAT)
     {
         case TvFormat.Ntsc:
             CyclesPerScanline = 113;
             break;
         case TvFormat.Pal:
             CyclesPerScanline = 106;
             break;
     }
     REG_S = 0xFF;
     REG_A = 0;
     REG_X = 0;
     REG_Y = 0;
     Debug.WriteLine(this, "CPU initialized ok.", DebugStatus.Cool);
 }
Exemple #16
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);
        }
Exemple #17
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;
     }
 }