Ejemplo n.º 1
0
        public CPU(string romPath)
        {
            memory = new Memory(romPath);
            OpcodeTable.GenerateOpcodeTable();
            opcodeTable = OpcodeTable.OPCODE_TABLE;

            // Test
            //A = 0x11;
            memory[0xFF44] = 0x91;
        }
Ejemplo n.º 2
0
        public CPU(string romPath, string savePath)
        {
            memory = new Memory(romPath);
            OpcodeTable.GenerateOpcodeTable();
            opcodeTable = OpcodeTable.OPCODE_TABLE;

            Debug.Log("\nLoading save state from file...");
            byte[] stateDump   = File.ReadAllBytes(savePath);
            int    lenCpuState = 2 + 2 + 1 + reg.Length;

            PC               = stateDump[0] | (stateDump[1] << 8);
            SP               = stateDump[2] | (stateDump[3] << 8);
            interrupts       = (stateDump[4] & 0x1) == 0x1;
            toggleInterrupts = (stateDump[4] & 0x2) == 0x2;
            Debug.Log("\nLoading register values from state dump...");
            Array.Copy(stateDump, 5, reg, 0, reg.Length);

            Debug.Log("\nCreating new array with ram dump data...");
            byte[] ramDump = new byte[stateDump.Length - lenCpuState];
            Array.Copy(stateDump, lenCpuState, ramDump, 0, ramDump.Length);
            Debug.Log("\nPassing ram dump to memory class...");
            memory.loadRAM(ramDump);
        }