Exemplo n.º 1
0
        public Memory(Form _form1_reference, Video _video_reference)
        {
            form1_reference = _form1_reference;
            video_reference = _video_reference;

            memory = new byte[0x41B9];
            temp_storage = new byte[0x800];

            Initialize_Memory();
            Load_Rom();
        }
Exemplo n.º 2
0
        public Cpu(Form form1_reference, ref Memory memory, ref Video video, ref Sound sound, ref Input input)
        {
            _memory = memory;
            _video = video;
            _sound = sound;
            _input = input;
            cycles = 0;
            extra_cycles = 0;
            frame = 0;
            byte_temp1 = byte_temp2 = 0;
            ushort_temp1 = ushort_temp2 = 0;
            shift_register = 0;
            shift_register_offset = 0;

            regs.A = regs.B = regs.C = regs.D = regs.E = regs.H = regs.L = 0;
            regs.F = 6;
            pc = 0;
            sp = 0;
            opcode = 0;
            INTE = 0;
            try
            {
                DipSwitch = byte.Parse(((Form1)form1_reference).main_settings.read_config_setting("Game", "Dip_Switch_Total"), System.Globalization.NumberStyles.HexNumber);
            }
            catch
            {
                DipSwitch = 0;
            }

            parity_loopup = new byte[0x100];
            cycles_lookup = new byte[] {
            4, 10,7, 5, 5, 5, 7, 4, 0, 10,7, 5, 5, 5, 7, 4,
            0, 10,7, 5, 5, 5, 7, 4, 0, 10,7, 5, 5, 5, 7, 4,
            0, 10,16,5, 5, 5, 7, 4, 0, 10,16,5, 5, 5, 7, 4,
            0, 10,13,5, 10,10,10,4, 0, 10,13,5, 5, 5, 7, 4,
            5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 7, 5,
            5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 7, 5,
            5, 5, 5, 5, 5, 5, 7, 5, 5, 5, 5, 5, 5, 5, 7, 5,
            7, 7, 7, 7, 7, 7, 7, 7, 5, 5, 5, 5, 5, 5, 7, 5,
            4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
            4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
            4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
            4, 4, 4, 4, 4, 4, 7, 4, 4, 4, 4, 4, 4, 4, 7, 4,
            5, 10,10,10,11,11,7, 11,5, 10,10,0, 11,17,7, 11,
            5, 10,10,10,11,11,7, 11,5, 0, 10,10,11,0, 7, 11,
            5, 10,10,18,11,11,7, 11,5, 5, 10,4, 11,0, 7, 11,
            5, 10,10,4, 11,11,7, 11,5, 5, 10,4, 11,0, 7, 11
            };

            for (int i = 0; i < parity_loopup.Length; i++)
            {
                parity_loopup[i] = (byte)(4 & (4 ^ (i << 2) ^ (i << 1) ^ i ^ (i >> 1) ^ (i >> 2) ^ (i >> 3) ^ (i >> 4) ^ (i >> 5)));
            }
        }