コード例 #1
0
ファイル: Registers.cs プロジェクト: cheeplusplus/nessharp
        private void FastWrite(byte i, bool value)
        {
            var updated = FastBits.Get(registerValue);

            updated[i]    = value;
            registerValue = FastBits.Write(updated);
        }
コード例 #2
0
ファイル: NesPpu.cs プロジェクト: cheeplusplus/nessharp
        public void HardReset()
        {
            Control = new ControlRegisterValues(0);
            Mask    = new MaskRegisterValues(0);
            Status  = new StatusRegisterValues(0);

            FastBits.Clear(ImageBuffer);

            isFrameOdd      = false;
            CurrentScanline = 0;
            CurrentDot      = 0;

            Memory.HardReset();
        }
コード例 #3
0
        public NesCartHeader(
            byte[] fileId,
            byte prgRomPages,
            byte chrRomPages,
            byte cartTypeLsb,
            byte cartTypeMsb,
            byte prgRamPages,
            byte tvSystem1,
            byte tvSystem2,
            byte[] padding
            )
        {
            this.FileId      = fileId;
            this.PrgRomPages = prgRomPages;
            this.ChrRomPages = chrRomPages;
            this.CartTypeLsb = FastBits.Get(cartTypeLsb);
            this.CartTypeMsb = FastBits.Get(cartTypeMsb);
            this.PrgRamPages = prgRamPages;
            this.TvSystem1   = tvSystem1;
            this.TvSystem2   = tvSystem2;
            this.Padding     = padding;

            this.MapperNumber = (byte)(((cartTypeLsb & 0xF0) >> 4) | (cartTypeMsb & 0xF0));
        }
コード例 #4
0
        protected override bool WriteRegister(ushort i, byte d)
        {
            if (i < 0x8000)
            {
                return(false);
            }

            ushort baseline = (ushort)(i & 0xE001);
            var    bits     = FastBits.Get(d);

            switch (baseline)
            {
            case 0x8000:
                // Bank select
                NextWriteBank       = (byte)(d & 0x7);
                PrgRomBankMode      = bits[6];
                ChrA12InversionMode = bits[7];
                return(true);

            case 0x8001:
                // Bank data
                if (NextWriteBank == 0 || NextWriteBank == 1)
                {
                    Registers[NextWriteBank] = (byte)(d & 0x1);
                }
                else
                {
                    Registers[NextWriteBank] = d;
                }
                return(true);

            case 0xA000:
                // Mirroring
                NametableMirroring = bits[0];
                Nes.Ppu.MirrorMode = NametableMirroring ? MirrorMode.Horizontal : MirrorMode.Vertical;
                return(true);

            case 0xA001:
                // PRG RAM protect
                PrgRamWritesDisabled = bits[6];
                PrgRamEnabled        = bits[7];
                return(true);

            case 0xC000:
                // IRQ latch
                IRQPeriod = d;
                return(true);

            case 0xC001:
                // IRQ reload
                IRQCounter = 0;
                return(true);

            case 0xE000:
                // IRQ disable
                IRQEnabled        = false;
                Nes.Cpu.ActiveIrq = false;
                return(true);

            case 0xE001:
                // IRQ enable
                IRQEnabled = true;
                return(true);
            }

            return(false);
        }
コード例 #5
0
ファイル: Registers.cs プロジェクト: cheeplusplus/nessharp
 private bool FastRead(byte i)
 {
     return(FastBits.Get(registerValue)[7 - i]);
 }
コード例 #6
0
ファイル: Registers.cs プロジェクト: cheeplusplus/nessharp
 private void FastWrite(byte i, bool value)
 {
     registerValue = FastBits.Set(registerValue, (byte)(7 - i), value);
 }
コード例 #7
0
ファイル: NesCpuMemory.cs プロジェクト: cheeplusplus/nessharp
 public void HardReset()
 {
     FastBits.Clear(BidirectionalIO, 0xFF);
     FastBits.Clear(WorkingRam, 0xFF);
 }
コード例 #8
0
 public void HardReset()
 {
     FastBits.Clear(Vram);
     FastBits.Clear(PaletteRAM);
     FastBits.Clear(OAMram);
 }