Example #1
0
        public override void AtVsyncNMI()
        {
            if (Patch_Vectors)
            {
                NES.cpu.NMI = true;
            }

            //strobe pad
            NES.WriteMemory(0x4016, 1);
            NES.WriteMemory(0x4016, 0);

            //read pad and create rising edge button signals so we dont trigger events as quickly as we hold the button down
            int currButtons = 0;

            for (int i = 0; i < 8; i++)
            {
                currButtons <<= 1;
                currButtons  |= (NES.ReadMemory(0x4016) & 1);
            }
            int justDown = (~ButtonState) & currButtons;
            Bit a        = (justDown >> 7) & 1;
            Bit b        = (justDown >> 6) & 1;
            Bit sel      = (justDown >> 5) & 1;
            Bit start    = (justDown >> 4) & 1;
            Bit up       = (justDown >> 3) & 1;
            Bit down     = (justDown >> 2) & 1;
            Bit left     = (justDown >> 1) & 1;
            Bit right    = (justDown >> 0) & 1;

            ButtonState = currButtons;

            //RIGHT: next song
            //LEFT: prev song
            //A: restart song

            bool reset = false;

            if (right)
            {
                CurrentSong++;
                reset = true;
            }
            if (left)
            {
                CurrentSong--;
                reset = true;
            }

            if (a)
            {
                reset = true;
            }

            if (reset)
            {
                ReplayInit();
            }
        }
Example #2
0
        public override void AtVsyncNmi()
        {
            if (Patch_Vectors)
            {
                NES.cpu.NMI = true;
            }

            //strobe pad
            NES.WriteMemory(0x4016, 1);
            NES.WriteMemory(0x4016, 0);

            //read pad and create rising edge button signals so we don't trigger events as quickly as we hold the button down
            int currButtons = 0;

            for (int i = 0; i < 8; i++)
            {
                currButtons <<= 1;
                currButtons  |= (NES.ReadMemory(0x4016) & 1);
            }
            int justDown = (~ButtonState) & currButtons;
            Bit a        = (justDown >> 7) & 1;
            Bit b        = (justDown >> 6) & 1;
            Bit sel      = (justDown >> 5) & 1;
            Bit start    = (justDown >> 4) & 1;
            Bit up       = (justDown >> 3) & 1;
            Bit down     = (justDown >> 2) & 1;
            Bit left     = (justDown >> 1) & 1;
            Bit right    = (justDown >> 0) & 1;

            ButtonState = currButtons;

            //RIGHT: next song
            //LEFT: prev song
            //A: restart song

            //RTC_Hijack :: control NSF from System Bus 0x00CE
            ushort songChangeAdress = 0x00CE;                           //RTC_Hijack
            byte   songValue        = NES.ReadMemory(songChangeAdress); //RTC_Hijack
            bool   reset            = false;

            if (right || (songValue == 0xFB))             //RTC_Hijack
            {
                NES.WriteMemory(songChangeAdress, 0xFF);  //RTC_Hijack
                if (CurrentSong < nsf.TotalSongs - 1)
                {
                    CurrentSong++;
                    reset = true;
                }
            }
            if (left || (songValue == 0xFA))             //RTC_Hijack
            {
                NES.WriteMemory(songChangeAdress, 0xFF); //RTC_Hijack
                if (CurrentSong > 0)
                {
                    CurrentSong--;
                    reset = true;
                }
            }

            if (a)
            {
                reset = true;
            }

            if (reset)
            {
                ReplayInit();
            }
        }
Example #3
0
 public byte DummyReadMemory(ushort address) => _nes.ReadMemory(address);