From e73c48219a39b9e341551cb170c235fd4adc9097 Mon Sep 17 00:00:00 2001 From: brandman211 Date: Thu, 19 Jul 2012 00:05:08 +0000 Subject: [PATCH] -Loaded EROM / GROM. -Fixed disassembly for JMP: --Now it uses the parameter pc, not RegisterPC. --I was loading both the second and third value from the second's address. --Casting the calculated addresses to bytes when addresses are 16-bit was a bad idea. --Removed a closing parenthesis I accidentally stuck in the formatting. It seems that I've gotten far enough to use the Executive ROM as a test case! Now to go instruction by instruction and see if they work as planned and hope this will all eventually make something. --- BizHawk.Emulation/CPUs/CP1610/Disassembler.cs | 8 +++--- .../Consoles/Intellivision/Intellivision.cs | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/BizHawk.Emulation/CPUs/CP1610/Disassembler.cs b/BizHawk.Emulation/CPUs/CP1610/Disassembler.cs index 27f846a308..8a7ec1c3e5 100644 --- a/BizHawk.Emulation/CPUs/CP1610/Disassembler.cs +++ b/BizHawk.Emulation/CPUs/CP1610/Disassembler.cs @@ -15,7 +15,7 @@ namespace BizHawk.Emulation.CPUs.CP1610 byte register; int second, third, op1, op2; string result = ""; - int opcode = ReadMemory(RegisterPC) & 0x3FF; + int opcode = ReadMemory(pc) & 0x3FF; switch (opcode) { case 0x000: @@ -28,8 +28,8 @@ namespace BizHawk.Emulation.CPUs.CP1610 return "DIS"; case 0x004: // 0000:0000:0000:0100 0000:00rr:aaaa:aaff 0000:00aa:aaaa:aaaa - second = ReadMemory((byte)(RegisterPC + 1)); - third = ReadMemory((byte)(RegisterPC + 1)); + second = ReadMemory((ushort)(pc + 1)); + third = ReadMemory((ushort)(pc + 2)); // rr indicates the register into which to store the return address register = (byte)(((second >> 8) & 0x3) + 4); // ff indicates how to affect the Interrupt (I) flag in the CP1610 @@ -53,7 +53,7 @@ namespace BizHawk.Emulation.CPUs.CP1610 } if (register != 0x3) result += " R" + register + ","; - result += string.Format(" ${0:X4})", op2); + result += string.Format(" ${0:X4}", op2); bytesToAdvance = 3; return result; case 0x005: diff --git a/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs b/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs index f219570cc5..255e136922 100644 --- a/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs +++ b/BizHawk.Emulation/Consoles/Intellivision/Intellivision.cs @@ -12,10 +12,36 @@ namespace BizHawk.Emulation.Consoles.Intellivision CP1610 Cpu; + public void LoadExecutive_ROM() + { + FileStream fs = new FileStream("C:/erom.int", FileMode.Open, FileAccess.Read); + BinaryReader r = new BinaryReader(fs); + byte[] erom = r.ReadBytes(8192); + int index = 0; + // Combine every two bytes into a word. + while (index + 1 < erom.Length) + Executive_ROM[index / 2] = (ushort)((erom[index++] << 8) | erom[index++]); + r.Close(); + fs.Close(); + } + + public void LoadGraphics_ROM() + { + FileStream fs = new FileStream("C:/grom.int", FileMode.Open, FileAccess.Read); + BinaryReader r = new BinaryReader(fs); + byte[] grom = r.ReadBytes(2048); + for (int index = 0; index < grom.Length; index++) + Graphics_ROM[index] = grom[index]; + r.Close(); + fs.Close(); + } + public Intellivision(GameInfo game, byte[] rom) { Rom = rom; Game = game; + LoadExecutive_ROM(); + LoadGraphics_ROM(); Parse(); Cpu = new CP1610();