Exemplo n.º 1
0
 public Assembler(Mos6502 processor)
 {
     Processor                 = processor;
     WriteAddress              = 0x0000;
     labelToAddress            = new Dictionary <string, ushort>();
     unresolvedLabelReferences = new Dictionary <string, List <LabelReference> >();
 }
Exemplo n.º 2
0
        public CheatSystem(Mos6502 processor)
        {
            this.processor = processor;
            cheats         = new Dictionary <ushort, Cheat>();

            PatchCheats();
        }
        public void Initialize()
        {
            System.Setup(x => x.Ready).Returns(true);
            System.Setup(x => x.Nmi).Returns(false);
            System.Setup(x => x.Irq).Returns(false);
            System.Setup(x => x.Read(It.IsAny <int>())).Returns(0xFF);
            System.Setup(x => x.Write(It.IsAny <int>(), It.IsAny <int>()));

            _config = new Mos6502Configuration(0xFF, true, System.Object.Read, System.Object.Write, () => System.Object.Ready, () => System.Object.Irq, () => System.Object.Nmi);
            Cpu     = new Mos6502(_config);
        }
Exemplo n.º 4
0
        public void TestInstructionDefinitions()
        {
            Mos6502 processor = new Mos6502();
            byte    opCode    = 0;

            foreach (Instruction instruction in processor.InstructionSet)
            {
                Assert.IsNotNull(instruction, "Opcode instruction " + ToHex(opCode) + " not defined");
                System.Console.WriteLine(ToHex(opCode) + ": " + instruction);

                Assert.IsTrue(opCode == instruction.Code,
                              "Instruction mapping mismatch: " + ToHex(opCode) + " / " + ToHex(instruction.Code));

                opCode++;
            }
        }
Exemplo n.º 5
0
        public void ProfileCpu()
        {
            // 64kb setup
            var memory = new byte[0x10000];

            // Program setup
            var program = new byte[]
            {
                // INC $0200,X
                0xFE, 0x00, 0x02,

                // DEX
                0xCA,

                // DEC $0400,Y
                0xDE, 0x00, 0x04,

                // INY
                0xC8,

                // LDA $0300
                0xAD, 0x00, 0x03,

                // ADC #$03
                0x69, 0x03,

                // STA $0300
                0x8D, 0x00, 0x03,

                // PHP
                0x08,

                // JMP $0000
                0x4C, 0x00, 0x00
            };

            // Load program into memory
            Array.Copy(program, memory, program.Length);

            // Cpu setup
            var cpu = new Mos6502(new Mos6502Configuration(0xFF, true, a => memory[a], (a, d) => memory[a] = unchecked ((byte)d), () => true, () => false, () => false));

            // Run some cycles.
            cpu.SetPC(0x0000);
            cpu.ClockMultiple(10000000);
        }
Exemplo n.º 6
0
        public Console()
        {
            // create main components
            Processor = new Mos6502();
            Video     = new RicohRP2C0X();
            Audio     = new Apu();
            ControllerMultiplexor1 = new ControllerMultiplexor();
            ControllerMultiplexor2 = new ControllerMultiplexor();
            Memory = new ConfigurableMemoryMap();

            allocatedCycles = 0;

            // configure hardware and connect components
            ConfigureMemoryMap();

            // connect processor to memory
            Processor.ReadByte  = (ushort address) => { return(Memory[address]); };
            Processor.WriteByte = (ushort address, byte value) => { Memory[address] = value; };

            // wire NMI between video and processor
            Video.TriggerNonMaskableInterupt = () => Processor.TriggerNonMaskableInterrupt();

            // connect video to memory for DMA operations
            Video.ReadByte = (ushort address) => { return(Memory[address]); };

            // connect APU DMC to memory
            Audio.Dmc.ReadMemorySample = (address) =>
            {
                Processor.State.StallCycles += 4;
                return(Memory[address]);
            };

            // wire IRQ between audio and processor
            Audio.TriggerInterruptRequest     = () => Processor.TriggerInterruptRequest();
            Audio.Dmc.TriggerInterruptRequest = () => Processor.TriggerInterruptRequest();

            // connect default first controller
            ConnectController(1, new Joypad());
        }
Exemplo n.º 7
0
 /// <summary>
 /// Create a CPU device using the specified device as a read/write target.
 /// </summary>
 /// <param name="name">Name of the CPU device.</param>
 /// <param name="busDevice">Device to target with read/write operations.</param>
 public Cpu6502Device(string name, IBusDevice busDevice) : base(name)
 {
     _cpu      = new Mos6502(new Mos6502Configuration(0xFF, false, _busRead, _busWrite, () => busDevice.Rdy, () => busDevice.Irq, () => busDevice.Nmi));
     _busWrite = busDevice.CpuWrite;
     _busRead  = busDevice.CpuRead;
 }