Esempio n. 1
0
        public EmulatorMain(Dictionary<int, Opcode> program)
        {
            Program = program;
            Register = new Register[16];
            for (int i = 0; i < 16; i++)
                Register[i] = new Register(i, 0xffff);

            Memory = new UInt16[16 * 1024]; // 32K memory
            Array.Clear(Memory, 0, 16 * 1024);

            Display = new byte[256, 256];
            Array.Clear(Display, 0, 256 * 256);

            foreach (int address in program.Keys)
            {
                UInt16[] m = program[address].GetOpcodeMemoryValue();
                Array.Copy(m, 0, Memory, address, m.Length);
            }
        }
Esempio n. 2
0
        public EmulatorMain(UInt16[] memory)
        {
            Register = new Register[16];
            for (int i = 0; i < 16; i++)
                Register[i] = new Register(i, 0xffff);

            Memory = memory;

            Display = new byte[256, 256];
            Array.Clear(Display, 0, 256 * 256);

            UInt16 o;
            Opcode op;
            Program = new Dictionary<int, Opcode>();
            for (int address = 0; address < 32768; address += 2)
            {
                o = Convert.ToUInt16((Memory[address + 1] << 8) | Memory[address]);
                op = OpcodeDictionary.Get(o);
                Program.Add(address, op);
            }
        }
Esempio n. 3
0
        private bool CheckIsRegister(string s, out Register r)
        {
            r = null;

            bool b = RegisterDictionary.Contains(s);
            if (b)
                r = RegisterDictionary.Get(s);

            return b;
        }
Esempio n. 4
0
        private void DisplayRegisters(Register[] list)
        {
            Program.MainWindow.lstRegister.Items.Clear();

            foreach (Register reg in list)
                Program.MainWindow.lstRegister.Items.Add(reg.ListViewItem);
        }
Esempio n. 5
0
 public object Clone()
 {
     Register r = new Register(Number, 0);
     return r;
 }
Esempio n. 6
0
        // Display
        private void SetDisplayPixel(Register reg1, Register reg2, Register reg3)
        {
            // Set the new Pixel value
            int oldColor = Display[reg1.Value.UValue, reg2.Value.UValue];
            Display[reg1.Value.UValue, reg2.Value.UValue] = (byte)reg3.Value.UValue;

            // Moved to wait command to emulate the VSync
            FireDisplayMemoryChanged(reg1.Value.UValue, reg2.Value.UValue, oldColor, reg3.Value.UValue);

            // Return the previous Pixel value
            UInt16 oldValue = reg3.Value.UValue;
            reg3.Value.UValue = (ushort)oldColor;
            FireRegisterChanged(reg3, oldValue);
        }
Esempio n. 7
0
        private void FireRegisterChanged(Register register, int oldvalue)
        {
            if (register.Value.SValue == oldvalue || register.Value.UValue == oldvalue)
                return;

            RegisterChangedEventArgs args = new RegisterChangedEventArgs();
            args.Register = register;
            OnRegisterChanged(args);
        }