Beispiel #1
0
        /*
         * public void OnKeyDown(Keys _key)
         * {
         *  Keyboard.OnKeyDown(_key);
         *  if (Joystick1 != null)
         *      Joystick1.OnKeyDown(_key);
         *  if (Joystick2 != null)
         *      Joystick2.OnKeyDown(_key);
         * }
         *
         * public void OnKeyUp(Keys _key)
         * {
         *  Keyboard.OnKeyUp(_key);
         *  if (Joystick1 != null)
         *      Joystick1.OnKeyUp(_key);
         *  if (Joystick2 != null)
         *      Joystick2.OnKeyUp(_key);
         * }
         */

        public void Reset()
        {
            CPU.Reset();
            MPU.Reset();
            CIA1.Reset();
            CIA2.Reset();
            SID.Reset();
            VIC.Reset();
        }
Beispiel #2
0
        public void LoadRom(Stream s)
        {
            BinaryReader br = new BinaryReader(s);

            header.valid = true;

            header.raw = br.ReadBytes(16);

            br.BaseStream.Seek(0, SeekOrigin.Begin);

            header.nes = Encoding.UTF8.GetString(br.ReadBytes(3));

            if (br.ReadByte() != 0x1A)
            {
                header.valid = false;
            }

            header.PRGBanks = br.ReadByte();
            header.CHRBanks = br.ReadByte();

            int flags  = br.ReadByte();
            int mapper = (flags >> 4);

            header.VerticalMirror  = (flags & 1) != 0;
            header.batBackedPRGRam = (flags & 2) != 0;
            header.trainerPresent  = (flags & 4) != 0;
            header.fourScreenVram  = (flags & 8) != 0;

            flags             = br.ReadByte();
            header.mapper     = ((flags & 0xF0) | mapper);
            header.VSunisys   = (flags & 1) != 0;
            header.PlayChoice = (flags & 2) != 0;
            header.NES2_0     = (flags & 12) != 8;

            header.PRGRamBanks = br.ReadByte();

            flags = br.ReadByte();

            header.NTSC         = (flags & 3) == 0;
            header.PRGRam       = (flags & 16) == 0;
            header.BusConflicts = (flags & 32) != 0;

            br.BaseStream.Seek(16, SeekOrigin.Begin);

            RawPRG = br.ReadBytes(16384 * header.PRGBanks);

            RawCHR = br.ReadBytes(8192 * header.CHRBanks);

            br.Close();

            if (Mapper.Mappers.ContainsKey(header.mapper))
            {
                Cart = Mapper.Mappers[header.mapper];
            }
            else
            {
                Cart = new NROM();
            }

            CPU.Reset();

            Reloaded?.Invoke();
        }