Пример #1
0
        public EEPROM(Machine machine) : base(machine, "EEPROM")
        {
            try
            {
                NVRAM = Convert.FromBase64String(Properties.Settings.Default.EEPROM);
                if (NVRAM.Length != 256)
                {
                    NVRAM = new byte[256];
                }
            }
            catch
            {
                NVRAM = new byte[256];
            }

            Read12xx  = new M6809E.ReadDelegate((UInt16 address) => { return((byte)(NVRAM[address & 0xFF] & 0x0F)); });
            Write12xx = new M6809E.WriteDelegate((UInt16 address, byte data) => { NVRAM[address & 0xFF] = (byte)(data & 0x0F); });
        }
Пример #2
0
        public Registers(Machine machine) : base(machine, "Regsisters")
        {
            Read10xx = new M6809E.ReadDelegate((UInt16 address) =>
            {
                if (address <= 0x103F)
                {
                    return(INRD1); // 1000
                }
                if (address <= 0x107F)
                {
                    return(INRD2); // 1040
                }
                if (address <= 0x10BF)
                {
                    return(STATRD); // 1080
                }
                //	if (address <= 0x10FF)
                return(Settings.DipSwitch3J); // 10C0
            });

            Write11xx = new M6809E.WriteDelegate((UInt16 address, byte data) =>
            {
                if (address <= 0x113F)
                {
                    CLEAR_IRQ = data; // 1100
                }
                else if (address <= 0x117F)
                {
                    STATWR = data; // 1140
                }
                else if (address <= 0x11BF)
                {
                    OUT0 = data; // 1180
                }
                else// if (address <= 0x11FF)
                {
                    OUT1 = data; // 11C0
                }
            });

            Write19xx = new M6809E.WriteDelegate((UInt16 address, byte data) => { CLEAR_WATCHDOG = data; });

            Write1Axx = new M6809E.WriteDelegate((UInt16 address, byte data) => { CLEAR_FIRQ = data; });
        }
Пример #3
0
        public ADC(Machine machine) : base(machine, "ADC")
        {
            Read13xx = new M6809E.ReadDelegate((UInt16 address) =>
            {
                // return the last ADC result
                return(ADC_RESULT);
            });

            Write1Bxx = new M6809E.WriteDelegate((UInt16 address, byte data) =>
            {
                // writes to this range kickff ADC conversions of joystick values
                if ((address & 0x1) == 0)
                {
                    //EmulatorTrace("ADC_START(Y_AXIS)");
                    ADC_RESULT = Joystick.ADC_Y;
                }
                else
                {
                    //EmulatorTrace("ADC_START(X_AXIS)");
                    ADC_RESULT = Joystick.ADC_X;
                }
            });
        }
Пример #4
0
        public Mathbox(Machine machine) : base(machine, "Mathbox")
        {
            Memory = Memory16;
            pData  = (byte *)Memory;

            //  Mathbox     CPU           hi                lo
            //  2000-2FFF   0:2000-3FFF   136029-104[0000]  136029-103[0000]
            //  3000-3FFF   1:2000-3FFF   136029-104[1000]  136029-103[1000]
            //  4000-4FFF   2:2000-3FFF   136029-102[0000]  136029-101[0000]
            //  5000-5FFF   3:2000-3FFF   136029-102[1000]  136029-101[1000]
            //  6000-6FFF   4:2000-3FFF   136029-102[2000]  136029-101[2000]
            //  7000-7FFF   5:2000-3FFF   136029-102[3000]  136029-101[3000]

            ROM?r101 = machine.Roms["136029-101"];
            ROM?r102 = machine.Roms["136029-102"];
            ROM?r103 = machine.Roms["136029-103"];
            ROM?r104 = machine.Roms["136029-104"];

            // create x86 accessable bank (low endian)
            UInt16 address;

            if (r103 != null)
            {
                address = 0x2000;
                foreach (byte b in r103)
                {
                    Memory[address++] = b;
                }
            }
            if (r104 != null)
            {
                address = 0x2000;
                foreach (byte b in r104)
                {
                    Memory[address++] |= (UInt16)(b << 8);
                }
            }
            if (r101 != null)
            {
                address = 0x4000;
                foreach (byte b in r101)
                {
                    Memory[address++] = b;
                }
            }
            if (r102 != null)
            {
                address = 0x4000;
                foreach (byte b in r102)
                {
                    Memory[address++] |= (UInt16)(b << 8);
                }
            }

            // create M6809E accessable banks (high endian)
            address = 0x2000;
            for (int bank = 0; bank < ROM.Length; bank++)
            {
                for (int n = 0; n < 0x2000;)
                {
                    ROM[bank][n++] = (byte)(Memory[address] >> 8);
                    ROM[bank][n++] = (byte)(Memory[address++] >> 0);
                }
            }

#if true
            // now patch the self test so our emulation results passs
            Array.Copy(Mathbox.SelfTestPatch, 0, Machine.ProgROM.Bank_4000[4], 0x5CAD - 0x4000, SelfTestPatch.Length);

            // adjust the value at the end of ROM bank 4 to account for the checksum change
            UInt16 checksum = 0;
            for (int n = 0; n < 0x1FFE; n += 2)
            {
                checksum -= (UInt16)(Machine.ProgROM.Bank_4000[4][n] * 256 + Machine.ProgROM.Bank_4000[4][n + 1]);
            }
            for (int n = 0; n < 0x2000; n += 2)
            {
                checksum -= (UInt16)(Machine.ProgROM.Bank_4000[5][n] * 256 + Machine.ProgROM.Bank_4000[5][n + 1]);
            }
            Machine.ProgROM.Bank_4000[4][0x1FFE] = (byte)(checksum >> 8);
            Machine.ProgROM.Bank_4000[4][0x1FFF] = (byte)(checksum >> 0);
#endif

            ReadRamFunction = new M6809E.ReadDelegate((UInt16 address) =>
            {
                // flip 6809 hi/lo, so x86 can read words
                return((byte)pData[(address & 0x1FFF) ^ 1]);
            });

            WriteRamFunction = new M6809E.WriteDelegate((UInt16 address, byte data) =>
            {
                // flip 6809 hi/lo, so x86 can read words
                pData[(address & 0x1FFF) ^ 1] = data;
            });
        }