Beispiel #1
0
        public void ShouldNotReturnValue()
        {
            TestContext.WriteLine("memoryPatch, should not return a value");

            var memoryPatch = MemoryPatch.getInstance();
            var result      = memoryPatch.hasPatch(0);

            Assert.That(result, Is.EqualTo(null));
        }
Beispiel #2
0
        public void ShouldAddVolatilePatch()
        {
            TestContext.WriteLine("memoryPatch, should add a volatile patch");

            var memoryPatch = MemoryPatch.getInstance();

            memoryPatch.addPatch(0x50, 20, true);
            var result = memoryPatch.hasPatch(0x50);

            Assert.That(result?.value, Is.EqualTo(20));
        }
Beispiel #3
0
        public void ShouldReturnPatchedValue()
        {
            TestContext.WriteLine("memoryPatch, should return a patched value");

            var memoryPatch = MemoryPatch.getInstance();

            memoryPatch.addPatch(0x50, 20);
            var result = memoryPatch.hasPatch(0x50);

            Assert.That(result?.value, Is.EqualTo(20));
        }
        public void ShouldReturnPatchedGameId()
        {
            TestContext.WriteLine("MemoryPatchSkipBootCheck, should return a patched game id");

            var memoryPatch = MemoryPatch.getInstance();

            MemoryPatchSkipBootCheck.run(memoryPatch);
            var checkLo = memoryPatch.hasPatch(0xFFEC);
            var checkHi = memoryPatch.hasPatch(0xFFED);

            Assert.That(checkLo?.value, Is.EqualTo(0x00));
            Assert.That(checkHi?.value, Is.EqualTo(0xFF));
        }
        public void ShouldReturnPatchedGameId()
        {
            TestContext.WriteLine("MemoryPatchGameId, should return a patched game id");

            var memoryPatch = MemoryPatch.getInstance();

            MemoryPatchGameId.run(memoryPatch, 0x50);
            var gameIdLo = memoryPatch.hasPatch(0x50);
            var gameIdHi = memoryPatch.hasPatch(0x51);

            Assert.That(gameIdLo?.value, Is.EqualTo(20));
            Assert.That(gameIdHi?.value, Is.EqualTo(99));
        }
Beispiel #6
0
        public WpcCpuBoard(RomObject romObject)
        {
            ram         = Enumerable.Repeat((byte)0, memoryMapper.MEMORY_ADDR_HARDWARE).ToArray();
            romSizeMBit = romObject.romSizeMBit;
            systemRom   = romObject.systemRom;
            romFileName = romObject.fileName;
            gameRom     = romObject.gameRom;
            memoryPatch = MemoryPatch.getInstance();
            if (romObject.gameIdMemoryLocation != null)
            {
                MemoryPatchGameId.run(memoryPatch, (ushort)romObject.gameIdMemoryLocation);
            }
            if (romObject.skipWpcRomCheck)
            {
                Debug.Print("skipWpcRomCheck TRUE");
                MemoryPatchSkipBootCheck.run(memoryPatch);
            }
            memoryWriteHandler = MemoryHandler.getInstance(romObject.memoryPosition, ram);

            cpu = Cpu6809.getInstance(_write8, _read8);

            InterruptCallbackData interruptCallback = new InterruptCallbackData
            {
                irq         = cpu.irq,
                firqFromDmd = () =>
                {
                    cpu.firq();
                    asic.firqSourceDmd(true);
                },
                reset = cpu.reset
            };

            InitObject initObject = new InitObject
            {
                interruptCallback = interruptCallback,
                romSizeMBit       = romSizeMBit,
                romObject         = romObject,
                ram = ram,
                hasAlphanumericDisplay = romObject.hasAlphanumericDisplay
            };

            hasAlphaNumbericDisplay = romObject.hasAlphanumericDisplay;
            asic         = CpuBoardAsic.getInstance(initObject);
            soundBoard   = SoundBoard.getInstance(initObject);
            displayBoard = DisplayBoard.getInstance(initObject);
            externalIo   = ExternalIo.getInstance();

            ticksIrq = 0;
            protectedMemoryWriteAttempts = 0;
            memoryWrites = 0;
        }
Beispiel #7
0
        public void ShouldApplyPatchesToExposedMemory()
        {
            TestContext.WriteLine("memoryPatch, should applyPatchesToExposedMemory");

            var ram         = Enumerable.Repeat((byte)0x00, 20).ToArray();
            var memoryPatch = MemoryPatch.getInstance();

            memoryPatch.addPatch(10, 20, true);
            memoryPatch.addPatch(11, 21, true);

            var result = memoryPatch.applyPatchesToExposedMemory(ram);

            Assert.That(result[0], Is.EqualTo(0));
            Assert.That(result[10], Is.EqualTo(20));
            Assert.That(result[11], Is.EqualTo(21));
        }
Beispiel #8
0
        public void ShouldCleanupVolatilePatches()
        {
            TestContext.WriteLine("memoryPatch, should cleanup volatile patches");

            var memoryPatch = MemoryPatch.getInstance();

            memoryPatch.addPatch(0x50, 20, true);
            memoryPatch.addPatch(0x70, 21, true);
            memoryPatch.addPatch(0x90, 23);

            memoryPatch.removeVolatileEntries();
            var result1 = memoryPatch.hasPatch(0x50);
            var result2 = memoryPatch.hasPatch(0x70);
            var result3 = memoryPatch.hasPatch(0x90);

            Assert.That(result1, Is.EqualTo(null));
            Assert.That(result2, Is.EqualTo(null));
            Assert.That(result3?.value, Is.EqualTo(23));
        }