Ejemplo n.º 1
0
        public void ShouldGetMemoryProtectionMask_256_wraparound()
        {
            TestContext.WriteLine("memoryProtection, should get memoryProtection mask for 256 (wrap around)");

            var result = MemoryProtection.getMemoryProtectionMask(256);

            Assert.That(result, Is.EqualTo(0x1000));
        }
Ejemplo n.º 2
0
        public void ShouldGetMemoryProtectionMask_0()
        {
            TestContext.WriteLine("memoryProtection, should get memoryProtection mask for 0");

            var result = MemoryProtection.getMemoryProtectionMask(0);

            Assert.That(result, Is.EqualTo(0x1000));
        }
Ejemplo n.º 3
0
        public void ShouldGetMemoryProtectionMask_255_unsure()
        {
            TestContext.WriteLine("memoryProtection, should get memoryProtection mask for 255 - unsure");

            var result = MemoryProtection.getMemoryProtectionMask(255);

            Assert.That(result, Is.EqualTo(0xF00));
        }
Ejemplo n.º 4
0
        public void write(ushort offset, byte value)
        {
            ram[offset] = value;

            switch (offset)
            {
            // save value and bail out
            case OP.WPC_RAM_LOCK:
            case OP.WPC_RAM_BANK:
            case OP.WPC_CLK_HOURS_DAYS:
            case OP.WPC_CLK_MINS:
            case OP.WPC_SHIFTADDRH:
            case OP.WPC_SHIFTADDRL:
            case OP.WPC_SHIFTBIT:
            case OP.WPC_SHIFTBIT2:
            case OP.WPC_ROM_LOCK:
            case OP.WPC_EXTBOARD1:
            case OP.WPC_EXTBOARD2:
            case OP.WPC_EXTBOARD3:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                break;

            case OP.WPC95_FLIPPER_COIL_OUTPUT:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                outputSolenoidMatrix.writeFliptronic((byte)((value) & 0xFF));
                break;

            case OP.WPC95_FLIPPER_SWITCH_INPUT:
            case OP.WPC_FLIPTRONICS_FLIPPER_PORT_A:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                outputSolenoidMatrix.writeFliptronic((byte)((~value) & 0xFF));
                break;

            case OP.WPC_RAM_LOCKSIZE:
                if (isMemoryProtectionEnabled())
                {
                    memoryProtectionMask = MemoryProtection.getMemoryProtectionMask(value);
                    Debug.Print("UPDATED_MEMORY_PROTECTION_MASK {0}", memoryProtectionMask);
                }
                else
                {
                    Debug.Print("MEMORY_PROTECTION_DISABLED", value);
                }
                break;

            case OP.WPC_SWITCH_COL_SELECT:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                if (hardwareHasSecurityPic)
                {
                    securityPic.write(value);
                    return;
                }
                inputSwitchMatrix.setActiveColumn(value);
                break;

            case OP.WPC_GI_TRIAC:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                outputGeneralIllumination.update(value, irqCountGI);
                break;

            case OP.WPC_LAMP_ROW_OUTPUT:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                outputLampMatrix.setActiveRow(value);
                break;

            case OP.WPC_LAMP_COL_STROBE:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                outputLampMatrix.setActiveColumn(value);
                break;

            case OP.WPC_PERIPHERAL_TIMER_FIRQ_CLEAR:
                Debug.Print("WRITE {0} _firqSourceDmd: {1}, {2}", REVERSEOP[offset], _firqSourceDmd, value);
                _firqSourceDmd = false;
                break;

            case OP.WPC_SOLENOID_GEN_OUTPUT:
            case OP.WPC_SOLENOID_HIGHPOWER_OUTPUT:
            case OP.WPC_SOLENOID_FLASH1_OUTPUT:
            case OP.WPC_SOLENOID_LOWPOWER_OUTPUT:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                outputSolenoidMatrix.write(offset, value);
                break;

            case OP.WPC_LEDS:
                Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);
                if (value != oldDiagnostigLedState)
                {
                    Debug.Print("DIAGNOSTIC_LED_TOGGLE {0} {1}", oldDiagnostigLedState, value);
                    diagnosticLedToggleCount++;
                    oldDiagnostigLedState = value;
                }
                break;

            case OP.WPC_ROM_BANK:
            {
                byte bank = (byte)(value & pageMask);
                Debug.Print("SELECT WPC_ROM_BANK {0}, {1}", value, bank);
                // only 6 bits
                romBank = bank;
                break;
            }

            case OP.WPC_ZEROCROSS_IRQ_CLEAR:
            {
                //Debug.Print("WRITE {0} {1}", REVERSEOP[offset], value);

                if ((value & WPC_ZC_WATCHDOG_RESET) != 0)
                {
                    // the watchdog will be tickled every 1ms by the IRQ (or after 2049 ticks)
                    watchdogTicks = Timing.WATCHDOG_ARMED_FOR_TICKS;
                    Debug.Print("WPC_ZC_WATCHDOG_RESET: RESET WATCHDOG {0}", watchdogTicks);
                }

                if (blankSignalHigh && ((value & WPC_ZC_BLANK_RESET) != 0))
                {
                    // like the watchdog, blanking is reset regulary
                    Debug.Print("CLEAR_BLANKING_SIGNAL");
                    blankSignalHigh = false;
                }

                if ((value & WPC_ZC_IRQ_CLEAR) != 0)
                {
                    Debug.Print("WRITE WPC_ZEROCROSS_IRQ_CLEAR {0}", value);
                    //Increment irq count - This is the best way to know an IRQ was serviced as this register is written immediately during the IRQ code.
                    irqCountGI++;
                    //TODO cpu_set_irq_line(WPC_CPUNO, M6809_IRQ_LINE, CLEAR_LINE); ??
                }

                bool timerEnabled = (value & WPC_ZC_IRQ_ENABLE) > 0;
                if (timerEnabled != periodicIRQTimerEnabled)
                {
                    Debug.Print("WRITE WPC_ZEROCROSS_IRQ_CLEAR periodic timer changed {0}", value);
                    //The periodic interrupt can be disabled/enabled by writing to the ASIC's WPC_ZEROCROSS_IRQ_CLEAR register.
                    periodicIRQTimerEnabled = timerEnabled;
                }

                break;
            }

            default:
                Debug.Print("W_NOT_IMPLEMENTED {0} {1}", "0x" + offset.ToString("X4"), value);
                Debug.Print("ASIC_WRITE_NOT_IMPLEMENTED {0} {1}", "0x" + offset.ToString("X4"), value);
                break;
            }
        }