Пример #1
0
        public PokeySound(DeserializationContext input, MachineBase m) : this(m)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            input.CheckVersion(1);
            _lastUpdateCpuClock = input.ReadUInt64();
            _bufferIndex        = input.ReadInt32();
            _audf                = input.ReadBytes();
            _audc                = input.ReadBytes();
            _audctl              = input.ReadByte();
            _skctl               = input.ReadByte();
            _output              = input.ReadBytes();
            _outvol              = input.ReadBytes();
            _divideMax           = input.ReadIntegers(4);
            _divideCount         = input.ReadIntegers(4);
            _pokeyTicks          = input.ReadInt32();
            _pokeyTicksPerSample = input.ReadInt32();
            _baseMultiplier      = input.ReadInt32();
            _poly04Counter       = input.ReadInt32();
            _poly05Counter       = input.ReadInt32();
            _poly17Counter       = input.ReadInt32();
            _poly17Size          = input.ReadInt32();
        }
Пример #2
0
 public NullDevice(MachineBase m)
 {
     if (m == null)
     {
         throw new ArgumentNullException("m");
     }
     M = m;
 }
Пример #3
0
 public virtual void Attach(MachineBase m)
 {
     if (m == null)
         throw new ArgumentNullException("m");
     if (M != null && M != m)
         throw new InvalidOperationException("Cart already attached to a different machine.");
     M = m;
 }
Пример #4
0
        public TIA(MachineBase m) : this()
        {
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }

            M        = m;
            TIASound = new TIASound(M, CPU_TICKS_PER_AUDIO_SAMPLE);
        }
Пример #5
0
        public AddressSpace(DeserializationContext input, MachineBase m, int addrSpaceShift, int pageShift) : this(m, addrSpaceShift, pageShift)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            input.CheckVersion(1);
            DataBusState = input.ReadByte();
        }
Пример #6
0
        public PokeySound(MachineBase m) : this()
        {
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }

            M = m;

            // Add 8-bits of fractional representation to reduce distortion on output
            _pokeyTicksPerSample = (POKEY_FREQ << 8) / M.SoundSampleFrequency;
        }
Пример #7
0
 public virtual void Attach(MachineBase m)
 {
     if (m == null)
     {
         throw new ArgumentNullException("m");
     }
     if (M != null && M != m)
     {
         throw new InvalidOperationException("Cart already attached to a different machine.");
     }
     M = m;
 }
Пример #8
0
        public TIASound(MachineBase m, int cpuClocksPerSample) : this()
        {
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }
            if (cpuClocksPerSample <= 0)
            {
                throw new ArgumentException("cpuClocksPerSample must be positive.");
            }

            M = m;
            _cpuClocksPerSample = cpuClocksPerSample;
        }
Пример #9
0
        public M6502(MachineBase m, int runClocksMultiple) : this()
        {
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }
            if (runClocksMultiple <= 0)
            {
                throw new ArgumentException("runClocksMultiple must be greater than zero.");
            }

            M = m;
            RunClocksMultiple = runClocksMultiple;
        }
Пример #10
0
        public AddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
        {
            M = m;

            AddrSpaceShift = addrSpaceShift;
            AddrSpaceSize  = 1 << AddrSpaceShift;
            AddrSpaceMask  = AddrSpaceSize - 1;

            PageShift = pageShift;
            PageSize  = 1 << PageShift;

            MemoryMap = new IDevice[1 << addrSpaceShift >> PageShift];

            for (var pageno = 0; pageno < MemoryMap.Length; pageno++)
            {
                MemoryMap[pageno] = NullDevice.Default;
            }
        }
        public Cart ReadCart(MachineBase m)
        {
            var typeName = _binaryReader.ReadString();

            if (string.IsNullOrWhiteSpace(typeName))
            {
                throw new Emu7800SerializationException("Invalid type name.");
            }

            var type = Type.GetType(typeName);

            if (type == null)
            {
                throw new Emu7800SerializationException("Unable to resolve type name: " + typeName);
            }

            return((Cart)Activator.CreateInstance(type, new object[] { this, m }));
        }
Пример #12
0
        public TIASound(DeserializationContext input, MachineBase m, int cpuClocksPerSample) : this(m, cpuClocksPerSample)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            input.CheckVersion(1);
            Bit9               = input.ReadExpectedBytes(511);
            P4                 = input.ReadIntegers(2);
            P5                 = input.ReadIntegers(2);
            P9                 = input.ReadIntegers(2);
            DivByNCounter      = input.ReadIntegers(2);
            DivByNMaximum      = input.ReadIntegers(2);
            AUDC               = input.ReadExpectedBytes(2);
            AUDF               = input.ReadExpectedBytes(2);
            AUDV               = input.ReadExpectedBytes(2);
            OutputVol          = input.ReadExpectedBytes(2);
            LastUpdateCPUClock = input.ReadUInt64();
            BufferIndex        = input.ReadInt32();
        }
Пример #13
0
        public PIA(DeserializationContext input, MachineBase m) : this(m)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            var version = input.CheckVersion(1, 2);
            RAM          = input.ReadExpectedBytes(0x80);
            TimerTarget  = input.ReadUInt64();
            TimerShift   = input.ReadInt32();
            IRQEnabled   = input.ReadBoolean();
            IRQTriggered = input.ReadBoolean();
            DDRA         = input.ReadByte();
            WrittenPortA = input.ReadByte();
            if (version > 1)
            {
                DDRB         = input.ReadByte();
                WrittenPortB = input.ReadByte();
            }
        }
Пример #14
0
        public M6502(DeserializationContext input, MachineBase m, int runClocksMultiple) : this(m, runClocksMultiple)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            input.CheckVersion(1);
            Clock                  = input.ReadUInt64();
            RunClocks              = input.ReadInt32();
            RunClocksMultiple      = input.ReadInt32();
            EmulatorPreemptRequest = input.ReadBoolean();
            Jammed                 = input.ReadBoolean();
            IRQInterruptRequest    = input.ReadBoolean();
            NMIInterruptRequest    = input.ReadBoolean();
            PC = input.ReadUInt16();
            A  = input.ReadByte();
            X  = input.ReadByte();
            Y  = input.ReadByte();
            S  = input.ReadByte();
            P  = input.ReadByte();
        }
Пример #15
0
        public AddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
        {
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }

            M = m;

            AddrSpaceShift = addrSpaceShift;
            AddrSpaceSize  = 1 << AddrSpaceShift;
            AddrSpaceMask  = AddrSpaceSize - 1;

            PageShift = pageShift;
            PageSize  = 1 << PageShift;

            MemoryMap = new IDevice[1 << addrSpaceShift >> PageShift];
            IDevice nullDev = new NullDevice(M);

            for (var pageno = 0; pageno < MemoryMap.Length; pageno++)
            {
                MemoryMap[pageno] = nullDev;
            }
        }
Пример #16
0
        public TIA(DeserializationContext input, MachineBase m) : this()
        {
            if (input == null)
                throw new ArgumentNullException("input");
            if (m == null)
                throw new ArgumentNullException("m");

            M = m;
            TIASound = input.ReadTIASound(M, CPU_TICKS_PER_AUDIO_SAMPLE);

            input.CheckVersion(2);
            RegW = input.ReadExpectedBytes(0x40);
            HSync = input.ReadInt32();
            HMoveCounter = input.ReadInt32();
            ScanLine = input.ReadInt32();
            FrameBufferIndex = input.ReadInt32();
            //FrameBufferElement = input.ReadBufferElement();
            StartHMOVEClock = input.ReadUInt64();
            HMoveLatch = input.ReadBoolean();
            StartClock = input.ReadUInt64();
            P0 = input.ReadInt32();
            P0mmr = input.ReadBoolean();
            EffGRP0 = input.ReadByte();
            OldGRP0 = input.ReadByte();
            P0type = input.ReadInt32();
            P0suppress = input.ReadInt32();
            P1 = input.ReadInt32();
            P1mmr = input.ReadBoolean();
            EffGRP1 = input.ReadByte();
            OldGRP1 = input.ReadByte();
            P1type = input.ReadInt32();
            P1suppress = input.ReadInt32();
            M0 = input.ReadInt32();
            M0mmr = input.ReadBoolean();
            M0type = input.ReadInt32();
            M0size = input.ReadInt32();
            m0on = input.ReadBoolean();
            M1 = input.ReadInt32();
            M1mmr = input.ReadBoolean();
            M1type = input.ReadInt32();
            M1size = input.ReadInt32();
            m1on = input.ReadBoolean();
            BL = input.ReadInt32();
            BLmmr = input.ReadBoolean();
            OldENABL = input.ReadBoolean();
            BLsize = input.ReadInt32();
            blon = input.ReadBoolean();
            PF210 = input.ReadUInt32();
            PFReflectionState = input.ReadInt32();
            colubk = input.ReadByte();
            colupf = input.ReadByte();
            colup0 = input.ReadByte();
            colup1 = input.ReadByte();
            vblankon = input.ReadBoolean();
            scoreon = input.ReadBoolean();
            pfpriority = input.ReadBoolean();
            DumpEnabled = input.ReadBoolean();
            DumpDisabledCycle = input.ReadUInt64();
            Collisions = (TIACxPairFlags)input.ReadInt32();
            WSYNCDelayClocks = input.ReadInt32();
            EndOfFrame = input.ReadBoolean();
        }
Пример #17
0
        public Cart ReadCart(MachineBase m)
        {
            var typeName = _binaryReader.ReadString();
            if (string.IsNullOrWhiteSpace(typeName))
                throw new Emu7800SerializationException("Invalid type name.");

            var type = Type.GetType(typeName);
            if (type == null)
                throw new Emu7800SerializationException("Unable to resolve type name: " + typeName);

            return (Cart)Activator.CreateInstance(type, new object[] { this, m });
        }
Пример #18
0
 public TIASound ReadTIASound(MachineBase m, int cpuClocksPerSample)
 {
     var tiaSound = new TIASound(this, m, cpuClocksPerSample);
     return tiaSound;
 }
Пример #19
0
 public PIA ReadPIA(MachineBase m)
 {
     var pia = new PIA(this, m);
     return pia;
 }
Пример #20
0
 public AddressSpace ReadAddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
 {
     var addressSpace = new AddressSpace(this, m, addrSpaceShift, pageShift);
     return addressSpace;
 }
Пример #21
0
        public AddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
        {
            if (m == null)
                throw new ArgumentNullException("m");

            M = m;

            AddrSpaceShift = addrSpaceShift;
            AddrSpaceSize  = 1 << AddrSpaceShift;
            AddrSpaceMask = AddrSpaceSize - 1;

            PageShift = pageShift;
            PageSize = 1 << PageShift;

            MemoryMap = new IDevice[1 << addrSpaceShift >> PageShift];
            IDevice nullDev = new NullDevice(M);
            for (var pageno=0; pageno < MemoryMap.Length; pageno++)
            {
                MemoryMap[pageno] = nullDev;
            }
        }
Пример #22
0
 public AddressSpace(DeserializationContext input, MachineBase m, int addrSpaceShift, int pageShift) : this(m, addrSpaceShift, pageShift)
 {
     input.CheckVersion(1);
     DataBusState = input.ReadByte();
 }
Пример #23
0
        public M6502(DeserializationContext input, MachineBase m, int runClocksMultiple) : this(m, runClocksMultiple)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            input.CheckVersion(1);
            Clock = input.ReadUInt64();
            RunClocks = input.ReadInt32();
            RunClocksMultiple = input.ReadInt32();
            EmulatorPreemptRequest = input.ReadBoolean();
            Jammed = input.ReadBoolean();
            IRQInterruptRequest = input.ReadBoolean();
            NMIInterruptRequest = input.ReadBoolean();
            PC = input.ReadUInt16();
            A = input.ReadByte();
            X = input.ReadByte();
            Y = input.ReadByte();
            S = input.ReadByte();
            P = input.ReadByte();
        }
Пример #24
0
        void HardReset()
        {
            cart = Cart.Create(rom, GameInfo.CartType);
            ILogger logger = new ConsoleLogger();

            HSC7800 hsc7800 = null;
            if (hsbios != null)
            {
                hsc7800 = new HSC7800(hsbios, hsram);
            }

            Bios7800 bios7800 = new Bios7800(bios);
            theMachine = MachineBase.Create
                (GameInfo.MachineType,
                cart,
                bios7800,
                hsc7800,
                GameInfo.LController,
                GameInfo.RController,
                logger);

            theMachine.Reset();
            theMachine.InputState.InputPollCallback = InputCallbacks.Call;

            ControlAdapter = new Atari7800Control(theMachine);
            ControllerDefinition = ControlAdapter.ControlType;

            avProvider.ConnectToMachine(theMachine, GameInfo);
            // to sync exactly with audio as this emulator creates and times it, the frame rate should be exactly 60:1 or 50:1
            CoreComm.VsyncNum = theMachine.FrameHZ;
            CoreComm.VsyncDen = 1;

            SetupMemoryDomains(hsc7800);
        }
Пример #25
0
        public TIASound(MachineBase m, int cpuClocksPerSample) : this()
        {
            if (m == null)
                throw new ArgumentNullException("m");
            if (cpuClocksPerSample <= 0)
                throw new ArgumentException("cpuClocksPerSample must be positive.");

            M = m;
            _cpuClocksPerSample = cpuClocksPerSample;
        }
Пример #26
0
        public TIA(DeserializationContext input, MachineBase m) : this()
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }
            if (m == null)
            {
                throw new ArgumentNullException("m");
            }

            M        = m;
            TIASound = input.ReadTIASound(M, CPU_TICKS_PER_AUDIO_SAMPLE);

            input.CheckVersion(2);
            RegW             = input.ReadExpectedBytes(0x40);
            HSync            = input.ReadInt32();
            HMoveCounter     = input.ReadInt32();
            ScanLine         = input.ReadInt32();
            FrameBufferIndex = input.ReadInt32();
            //FrameBufferElement = input.ReadBufferElement();
            StartHMOVEClock = input.ReadUInt64();
            HMoveLatch      = input.ReadBoolean();
            StartClock      = input.ReadUInt64();
            P0                = input.ReadInt32();
            P0mmr             = input.ReadBoolean();
            EffGRP0           = input.ReadByte();
            OldGRP0           = input.ReadByte();
            P0type            = input.ReadInt32();
            P0suppress        = input.ReadInt32();
            P1                = input.ReadInt32();
            P1mmr             = input.ReadBoolean();
            EffGRP1           = input.ReadByte();
            OldGRP1           = input.ReadByte();
            P1type            = input.ReadInt32();
            P1suppress        = input.ReadInt32();
            M0                = input.ReadInt32();
            M0mmr             = input.ReadBoolean();
            M0type            = input.ReadInt32();
            M0size            = input.ReadInt32();
            m0on              = input.ReadBoolean();
            M1                = input.ReadInt32();
            M1mmr             = input.ReadBoolean();
            M1type            = input.ReadInt32();
            M1size            = input.ReadInt32();
            m1on              = input.ReadBoolean();
            BL                = input.ReadInt32();
            BLmmr             = input.ReadBoolean();
            OldENABL          = input.ReadBoolean();
            BLsize            = input.ReadInt32();
            blon              = input.ReadBoolean();
            PF210             = input.ReadUInt32();
            PFReflectionState = input.ReadInt32();
            colubk            = input.ReadByte();
            colupf            = input.ReadByte();
            colup0            = input.ReadByte();
            colup1            = input.ReadByte();
            vblankon          = input.ReadBoolean();
            scoreon           = input.ReadBoolean();
            pfpriority        = input.ReadBoolean();
            DumpEnabled       = input.ReadBoolean();
            DumpDisabledCycle = input.ReadUInt64();
            Collisions        = (TIACxPairFlags)input.ReadInt32();
            WSYNCDelayClocks  = input.ReadInt32();
            EndOfFrame        = input.ReadBoolean();
        }
Пример #27
0
 public PIA(MachineBase m)
 {
     if (m == null)
         throw new ArgumentNullException("m");
     M = m;
 }
Пример #28
0
        public PIA(DeserializationContext input, MachineBase m) : this(m)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            var version = input.CheckVersion(1, 2);
            RAM = input.ReadExpectedBytes(0x80);
            TimerTarget = input.ReadUInt64();
            TimerShift = input.ReadInt32();
            IRQEnabled = input.ReadBoolean();
            IRQTriggered = input.ReadBoolean();
            DDRA = input.ReadByte();
            WrittenPortA = input.ReadByte();
            if (version > 1)
            {
                DDRB = input.ReadByte();
                WrittenPortB = input.ReadByte();
            }
        }
Пример #29
0
 public virtual void Attach(MachineBase m)
 {
     M = m;
 }
Пример #30
0
 public void Write(MachineBase m)
 {
     WriteTypeName(m);
     m.GetObjectData(this);
 }
Пример #31
0
        public M6502(MachineBase m, int runClocksMultiple) : this()
        {
            if (m == null)
                throw new ArgumentNullException("m");
            if (runClocksMultiple <= 0)
                throw new ArgumentException("runClocksMultiple must be greater than zero.");

            M = m;
            RunClocksMultiple = runClocksMultiple;
        }
Пример #32
0
        public AddressSpace(DeserializationContext input, MachineBase m, int addrSpaceShift, int pageShift) : this(m, addrSpaceShift, pageShift)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            input.CheckVersion(1);
            DataBusState = input.ReadByte();
        }
 public void Write(MachineBase m)
 {
     _binaryWriter.Write(m.ToString() ?? string.Empty);
     m.GetObjectData(this);
 }
Пример #34
0
			public void ConnectToMachine(MachineBase m, EMU7800.Win.GameProgram g)
			{
				framebuffer = m.CreateFrameBuffer();
				BufferWidth = framebuffer.VisiblePitch;
				BufferHeight = framebuffer.Scanlines;
				vidbuffer = new int[BufferWidth * BufferHeight];

				uint newsamplerate = (uint)m.SoundSampleFrequency;
				if (newsamplerate != samplerate)
				{
					// really shouldn't happen (after init), but if it does, we're ready
					if (resampler != null)
						resampler.Dispose();
					resampler = new SpeexResampler(3, newsamplerate, 44100, newsamplerate, 44100, null, null);
					samplerate = newsamplerate;
					dcfilter = DCFilter.DetatchedMode(256);
				}
				if (g.MachineType == MachineType.A7800PAL || g.MachineType == MachineType.A2600PAL)
					palette = TIATables.PALPalette;
				else
					palette = TIATables.NTSCPalette;
			}
        public AddressSpace ReadAddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
        {
            var addressSpace = new AddressSpace(this, m, addrSpaceShift, pageShift);

            return(addressSpace);
        }
Пример #36
0
 public M6502 ReadM6502(MachineBase m, int runClocksMultiple)
 {
     var cpu = new M6502(this, m, runClocksMultiple);
     return cpu;
 }
        public M6502 ReadM6502(MachineBase m, int runClocksMultiple)
        {
            var cpu = new M6502(this, m, runClocksMultiple);

            return(cpu);
        }
Пример #38
0
 public TIA ReadTIA(MachineBase m)
 {
     var tia = new TIA(this, m);
     return tia;
 }
        public PIA ReadPIA(MachineBase m)
        {
            var pia = new PIA(this, m);

            return(pia);
        }
Пример #40
0
 public PokeySound ReadOptionalPokeySound(MachineBase m)
 {
     var exist = ReadBoolean();
     return exist ? new PokeySound(this, m) : null;
 }
        public TIA ReadTIA(MachineBase m)
        {
            var tia = new TIA(this, m);

            return(tia);
        }
Пример #42
0
 public void Write(MachineBase m)
 {
     WriteTypeName(m);
     m.GetObjectData(this);
 }
        public TIASound ReadTIASound(MachineBase m, int cpuClocksPerSample)
        {
            var tiaSound = new TIASound(this, m, cpuClocksPerSample);

            return(tiaSound);
        }
Пример #44
0
        public TIA(MachineBase m) : this()
        {
            if (m == null)
                throw new ArgumentNullException("m");

            M = m;
            TIASound = new TIASound(M, CPU_TICKS_PER_AUDIO_SAMPLE);
        }
        public PokeySound ReadOptionalPokeySound(MachineBase m)
        {
            var exist = ReadBoolean();

            return(exist ? new PokeySound(this, m) : null);
        }
Пример #46
0
        public PokeySound(MachineBase m) : this()
        {
            if (m == null)
                throw new ArgumentNullException("m");

            M = m;

            // Add 8-bits of fractional representation to reduce distortion on output
            _pokeyTicksPerSample = (POKEY_FREQ << 8) / M.SoundSampleFrequency;
        }
Пример #47
0
        public TIASound(DeserializationContext input, MachineBase m, int cpuClocksPerSample) : this(m, cpuClocksPerSample)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            input.CheckVersion(1);
            Bit9 = input.ReadExpectedBytes(511);
            P4 = input.ReadIntegers(2);
            P5 = input.ReadIntegers(2);
            P9 = input.ReadIntegers(2);
            DivByNCounter = input.ReadIntegers(2);
            DivByNMaximum = input.ReadIntegers(2);
            AUDC = input.ReadExpectedBytes(2);
            AUDF = input.ReadExpectedBytes(2);
            AUDV = input.ReadExpectedBytes(2);
            OutputVol = input.ReadExpectedBytes(2);
            LastUpdateCPUClock = input.ReadUInt64();
            BufferIndex = input.ReadInt32();
        }
Пример #48
0
		public Atari7800Control(MachineBase mac)
		{
			var l = mac.InputState.LeftControllerJack;
			var r = mac.InputState.RightControllerJack;

			foreach (var a in Adapters)
			{
				if (a.Left == l && a.Right == r)
				{
					Convert = a.Convert;
					ControlType = a.Type;
					return;
				}
			}
			throw new Exception(string.Format("Couldn't connect Atari 7800 controls \"{0}\" and \"{1}\"", l.ToString(), r.ToString()));
		}
Пример #49
0
        public PokeySound(DeserializationContext input, MachineBase m) : this(m)
        {
            if (input == null)
                throw new ArgumentNullException("input");

            input.CheckVersion(1);
            _lastUpdateCpuClock = input.ReadUInt64();
            _bufferIndex = input.ReadInt32();
            _audf = input.ReadBytes();
            _audc = input.ReadBytes();
            _audctl = input.ReadByte();
            _skctl = input.ReadByte();
            _output = input.ReadBytes();
            _outvol = input.ReadBytes();
            _divideMax = input.ReadIntegers(4);
            _divideCount = input.ReadIntegers(4);
            _pokeyTicks = input.ReadInt32();
            _pokeyTicksPerSample = input.ReadInt32();
            _baseMultiplier = input.ReadInt32();
            _poly04Counter = input.ReadInt32();
            _poly05Counter = input.ReadInt32();
            _poly17Counter = input.ReadInt32();
            _poly17Size = input.ReadInt32();
        }