コード例 #1
0
        public void LoadStateBinary(BinaryReader reader)
        {
            Musashi.LoadStateBinary(reader);
            //SoundCPU.LoadStateBinary(reader);
            //PSG.LoadStateBinary(reader);
            VDP.LoadStateBinary(reader);
            YM2612.LoadStateBinary(reader);

            Ram    = reader.ReadBytes(Ram.Length);
            Z80Ram = reader.ReadBytes(Z80Ram.Length);

            Frame           = reader.ReadInt32();
            M68000HasZ80Bus = reader.ReadBoolean();
            Z80Reset        = reader.ReadBoolean();
            BankRegion      = reader.ReadInt32();

            for (int i = 0; i < 3; i++)
            {
                IOPorts[i].Data   = reader.ReadByte();
                IOPorts[i].TxData = reader.ReadByte();
                IOPorts[i].RxData = reader.ReadByte();
                IOPorts[i].SCtrl  = reader.ReadByte();
            }

            if (SaveRAM.Length > 0)
            {
                SaveRAM = reader.ReadBytes(SaveRAM.Length);
            }
        }
コード例 #2
0
        public void SaveStateBinary(BinaryWriter writer)
        {
            Musashi.SaveStateBinary(writer);                // 124
            //SoundCPU.SaveStateBinary(writer);   // 46     TODO fix this, there is no way to invoke this core from the UI for testing anyway.
            //PSG.SaveStateBinary(writer);        // 15
            VDP.SaveStateBinary(writer);                    // 65781
            YM2612.SaveStateBinary(writer);                 // 1785

            writer.Write(Ram);                              // 65535
            writer.Write(Z80Ram);                           // 8192

            writer.Write(Frame);                            // 4
            writer.Write(M68000HasZ80Bus);                  // 1
            writer.Write(Z80Reset);                         // 1
            writer.Write(BankRegion);                       // 4

            for (int i = 0; i < 3; i++)
            {
                writer.Write(IOPorts[i].Data);
                writer.Write(IOPorts[i].TxData);
                writer.Write(IOPorts[i].RxData);
                writer.Write(IOPorts[i].SCtrl);
            }

            if (SaveRAM.Length > 0)
            {
                writer.Write(SaveRAM);
            }

            // TODO: EEPROM/cart HW state
            // TODO: lag counter crap
        }
コード例 #3
0
        void Set68kIrq(int irq)
        {
#if MUSASHI
            Musashi.SetIRQ(irq);
#else
            MainCPU.Interrupt = irq;
#endif
        }
コード例 #4
0
        void Exec68k(int cycles)
        {
#if MUSASHI
            Musashi.Execute(cycles);
#else
            MainCPU.ExecuteCycles(cycles);
#endif
        }
コード例 #5
0
        public Genesis(CoreComm comm, GameInfo game, byte[] rom)
        {
            ServiceProvider = new BasicServiceProvider(this);
            CoreComm        = comm;
            MainCPU         = new MC68000();
            SoundCPU        = new Z80A();
            YM2612          = new YM2612()
            {
                MaxVolume = 23405
            };
            PSG = new SN76489()
            {
                MaxVolume = 4681
            };
            VDP = new GenVDP();
            VDP.DmaReadFrom68000 = ReadWord;
            (ServiceProvider as BasicServiceProvider).Register <IVideoProvider>(VDP);
            SoundMixer = new SoundMixer(YM2612, PSG);

            MainCPU.ReadByte    = ReadByte;
            MainCPU.ReadWord    = ReadWord;
            MainCPU.ReadLong    = ReadLong;
            MainCPU.WriteByte   = WriteByte;
            MainCPU.WriteWord   = WriteWord;
            MainCPU.WriteLong   = WriteLong;
            MainCPU.IrqCallback = InterruptCallback;

            // ---------------------- musashi -----------------------
#if MUSASHI
            _vdp    = vdpcallback;
            read8   = Read8;
            read16  = Read16;
            read32  = Read32;
            write8  = Write8;
            write16 = Write16;
            write32 = Write32;

            Musashi.RegisterVdpCallback(Marshal.GetFunctionPointerForDelegate(_vdp));
            Musashi.RegisterRead8(Marshal.GetFunctionPointerForDelegate(read8));
            Musashi.RegisterRead16(Marshal.GetFunctionPointerForDelegate(read16));
            Musashi.RegisterRead32(Marshal.GetFunctionPointerForDelegate(read32));
            Musashi.RegisterWrite8(Marshal.GetFunctionPointerForDelegate(write8));
            Musashi.RegisterWrite16(Marshal.GetFunctionPointerForDelegate(write16));
            Musashi.RegisterWrite32(Marshal.GetFunctionPointerForDelegate(write32));
#endif
            // ---------------------- musashi -----------------------

            SoundCPU.ReadMemory    = ReadMemoryZ80;
            SoundCPU.WriteMemory   = WriteMemoryZ80;
            SoundCPU.WriteHardware = (a, v) => { Console.WriteLine("Z80: Attempt I/O Write {0:X2}:{1:X2}", a, v); };
            SoundCPU.ReadHardware  = x => 0xFF;
            SoundCPU.IRQCallback   = () => SoundCPU.Interrupt = false;
            Z80Reset = true;
            RomData  = new byte[0x400000];
            for (int i = 0; i < rom.Length; i++)
            {
                RomData[i] = rom[i];
            }

            SetupMemoryDomains();
#if MUSASHI
            Musashi.Init();
            Musashi.Reset();
            VDP.GetPC = () => Musashi.PC;
#else
            MainCPU.Reset();
            VDP.GetPC = () => MainCPU.PC;
#endif
            InitializeCartHardware(game);
        }