Beispiel #1
0
        public static string RenderOpCode(AddressSpace addrSpace, ushort PC)
        {
            var    num_operands = GetInstructionLength(addrSpace, PC) - 1;
            var    PC1          = (ushort)(PC + 1);
            string addrmodeStr;

            switch (AddressingModeMatrix[addrSpace[PC]])
            {
            case a.REL:
                addrmodeStr = String.Format("${0:x4}", (ushort)(PC + (sbyte)(addrSpace[PC1]) + 2));
                break;

            case a.ZPG:
            case a.ABS:
                addrmodeStr = RenderEA(addrSpace, PC1, num_operands);
                break;

            case a.ZPX:
            case a.ABX:
                addrmodeStr = RenderEA(addrSpace, PC1, num_operands) + ",X";
                break;

            case a.ZPY:
            case a.ABY:
                addrmodeStr = RenderEA(addrSpace, PC1, num_operands) + ",Y";
                break;

            case a.IDX:
                addrmodeStr = "(" + RenderEA(addrSpace, PC1, num_operands) + ",X)";
                break;

            case a.IDY:
                addrmodeStr = "(" + RenderEA(addrSpace, PC1, num_operands) + "),Y";
                break;

            case a.IND:
                addrmodeStr = "(" + RenderEA(addrSpace, PC1, num_operands) + ")";
                break;

            case a.IMM:
                addrmodeStr = "#" + RenderEA(addrSpace, PC1, num_operands);
                break;

            default:
                // a.IMP, a.ACC
                addrmodeStr = string.Empty;
                break;
            }

            return(string.Format("{0} {1}", MnemonicMatrix[addrSpace[PC]], addrmodeStr));
        }
        public static string RenderOpCode(AddressSpace addrSpace, ushort PC)
        {
            var    num_operands = GetInstructionLength(addrSpace, PC) - 1;
            var    PC1          = (ushort)(PC + 1);
            string addrmodeStr  = (AddressingModeMatrix[addrSpace[PC]]) switch
            {
                a.REL => $"${(ushort)(PC + (sbyte)addrSpace[PC1] + 2):x4}",
                a.ZPG or a.ABS => RenderEA(addrSpace, PC1, num_operands),
                a.ZPX or a.ABX => RenderEA(addrSpace, PC1, num_operands) + ",X",
                a.ZPY or a.ABY => RenderEA(addrSpace, PC1, num_operands) + ",Y",
                a.IDX => "(" + RenderEA(addrSpace, PC1, num_operands) + ",X)",
                a.IDY => "(" + RenderEA(addrSpace, PC1, num_operands) + "),Y",
                a.IND => "(" + RenderEA(addrSpace, PC1, num_operands) + ")",
                a.IMM => "#" + RenderEA(addrSpace, PC1, num_operands),
                _ => string.Empty,             // a.IMP, a.ACC
            };

            return($"{MnemonicMatrix[addrSpace[PC]]} {addrmodeStr}");
        }
        public Machine7800(Cart cart, Bios7800 bios, HSC7800 hsc, ILogger logger, int scanlines, int startl, int fHZ, int sRate, ReadOnlyMemory <uint> p)
            : base(logger, scanlines, startl, fHZ, sRate, p, 320)
        {
            Mem = new AddressSpace(this, 16, 6);  // 7800: 16bit, 64byte pages

            CPU = new M6502(this, 4);

            Maria = new Maria(this, scanlines);
            Mem.Map(0x0000, 0x0040, Maria);
            Mem.Map(0x0100, 0x0040, Maria);
            Mem.Map(0x0200, 0x0040, Maria);
            Mem.Map(0x0300, 0x0040, Maria);

            PIA = new PIA(this);
            Mem.Map(0x0280, 0x0080, PIA);
            Mem.Map(0x0480, 0x0080, PIA);
            Mem.Map(0x0580, 0x0080, PIA);

            RAM1 = new RAM6116();
            RAM2 = new RAM6116();
            Mem.Map(0x1800, 0x0800, RAM1);
            Mem.Map(0x2000, 0x0800, RAM2);

            Mem.Map(0x0040, 0x00c0, RAM2); // page 0 shadow
            Mem.Map(0x0140, 0x00c0, RAM2); // page 1 shadow
            Mem.Map(0x2800, 0x0800, RAM2); // shadow1
            Mem.Map(0x3000, 0x0800, RAM2); // shadow2
            Mem.Map(0x3800, 0x0800, RAM2); // shadow3

            BIOS = bios;
            HSC  = hsc;

            if (HSC != HSC7800.Default)
            {
                Mem.Map(0x1000, 0x800, HSC.SRAM);
                Mem.Map(0x3000, 0x1000, HSC);
                Logger.WriteLine("7800 Highscore Cartridge Installed");
            }

            Cart = cart;
            Mem.Map(0x4000, 0xc000, Cart);
        }
Beispiel #4
0
        static int GetInstructionLength(AddressSpace addrSpace, ushort PC)
        {
            switch (AddressingModeMatrix[addrSpace[PC]])
            {
            case a.ACC:
            case a.IMP:
                return(1);

            case a.REL:
            case a.ZPG:
            case a.ZPX:
            case a.ZPY:
            case a.IDX:
            case a.IDY:
            case a.IMM:
                return(2);

            default:
                return(3);
            }
        }
        public Machine2600(Cart cart, ILogger logger, int slines, int startl, int fHZ, int sRate, ReadOnlyMemory <uint> p)
            : base(logger, slines, startl, fHZ, sRate, p, 160)
        {
            Mem = new AddressSpace(this, 13, 6);  // 2600: 13bit, 64byte pages

            CPU = new M6502(this, 1);

            TIA = new TIA(this);
            for (ushort i = 0; i < 0x1000; i += 0x100)
            {
                Mem.Map(i, 0x0080, TIA);
            }

            PIA = new PIA(this);
            for (ushort i = 0x0080; i < 0x1000; i += 0x100)
            {
                Mem.Map(i, 0x0080, PIA);
            }

            Cart = cart;
            Mem.Map(0x1000, 0x1000, Cart);
        }
        public static string MemDump(AddressSpace addrSpace, ushort atAddr, ushort untilAddr)
        {
            var dSB = new StringBuilder();
            var len = untilAddr - atAddr;

            while (len-- >= 0)
            {
                dSB.Append($"{atAddr:x4}: ");
                for (var i = 0; i < 8; i++)
                {
                    dSB.Append($"{addrSpace[atAddr++]:x2} ");
                    if (i == 3)
                    {
                        dSB.Append(' ');
                    }
                }
                dSB.Append('\n');
            }
            if (dSB.Length > 0)
            {
                dSB.Length--;  // Trim trailing newline
            }
            return(dSB.ToString());
        }
 public AddressSpace ReadAddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
 {
     var addressSpace = new AddressSpace(this, m, addrSpaceShift, pageShift);
     return addressSpace;
 }
        public AddressSpace ReadAddressSpace(MachineBase m, int addrSpaceShift, int pageShift)
        {
            var addressSpace = new AddressSpace(this, m, addrSpaceShift, pageShift);

            return(addressSpace);
        }
Beispiel #9
0
 public void Write(AddressSpace mem)
 {
     mem.GetObjectData(this);
 }
 static int GetInstructionLength(AddressSpace addrSpace, ushort PC)
 => (AddressingModeMatrix[addrSpace[PC]]) switch
 {
Beispiel #11
0
 static string RenderEA(AddressSpace addrSpace, ushort PC, int bytes)
 {
     var lsb = addrSpace[PC];
     var msb = (bytes == 2) ? addrSpace[(ushort)(PC + 1)] : (byte)0;
     var ea = (ushort)(lsb | (msb << 8));
     return string.Format((bytes == 1) ? "${0:x2}" : "${0:x4}", ea);
 }
Beispiel #12
0
 static int GetInstructionLength(AddressSpace addrSpace, ushort PC)
 {
     switch (AddressingModeMatrix[addrSpace[PC]])
     {
         case a.ACC:
         case a.IMP:
             return 1;
         case a.REL:
         case a.ZPG:
         case a.ZPX:
         case a.ZPY:
         case a.IDX:
         case a.IDY:
         case a.IMM:
             return 2;
         default:
             return 3;
     }
 }
Beispiel #13
0
        public static string RenderOpCode(AddressSpace addrSpace, ushort PC)
        {
            var num_operands = GetInstructionLength(addrSpace, PC) - 1;
            var PC1 = (ushort)(PC + 1);
            string addrmodeStr;

            switch (AddressingModeMatrix[addrSpace[PC]])
            {
                case a.REL:
                    addrmodeStr = String.Format("${0:x4}", (ushort)(PC + (sbyte)(addrSpace[PC1]) + 2));
                    break;
                case a.ZPG:
                case a.ABS:
                    addrmodeStr = RenderEA(addrSpace, PC1, num_operands);
                    break;
                case a.ZPX:
                case a.ABX:
                    addrmodeStr = RenderEA(addrSpace, PC1, num_operands) + ",X";
                    break;
                case a.ZPY:
                case a.ABY:
                    addrmodeStr = RenderEA(addrSpace, PC1, num_operands) + ",Y";
                    break;
                case a.IDX:
                    addrmodeStr = "(" + RenderEA(addrSpace, PC1, num_operands) + ",X)";
                    break;
                case a.IDY:
                    addrmodeStr = "(" + RenderEA(addrSpace, PC1, num_operands) + "),Y";
                    break;
                case a.IND:
                    addrmodeStr = "(" + RenderEA(addrSpace, PC1, num_operands) + ")";
                    break;
                case a.IMM:
                    addrmodeStr = "#" + RenderEA(addrSpace, PC1, num_operands);
                    break;
                default:
                    // a.IMP, a.ACC
                    addrmodeStr = string.Empty;
                    break;
            }

            return string.Format("{0} {1}", MnemonicMatrix[addrSpace[PC]], addrmodeStr);
        }
Beispiel #14
0
 public static string MemDump(AddressSpace addrSpace, ushort atAddr, ushort untilAddr)
 {
     var dSB = new StringBuilder();
     var len = untilAddr - atAddr;
     while (len-- >= 0)
     {
         dSB.AppendFormat("{0:x4}: ", atAddr);
         for (var i = 0; i < 8; i++)
         {
             dSB.AppendFormat("{0:x2} ", addrSpace[atAddr++]);
             if (i == 3)
             {
                 dSB.Append(" ");
             }
         }
         dSB.Append("\n");
     }
     if (dSB.Length > 0)
     {
         dSB.Length--;  // Trim trailing newline
     }
     return dSB.ToString();
 }
Beispiel #15
0
 public static string Disassemble(AddressSpace addrSpace, ushort atAddr, ushort untilAddr)
 {
     var dSB = new StringBuilder();
     var dPC = atAddr;
     while (atAddr < untilAddr)
     {
         dSB.AppendFormat("{0:x4}: ", dPC);
         var len = GetInstructionLength(addrSpace, dPC);
         for (var i = 0; i < 3; i++)
         {
             if (i < len)
             {
                 dSB.AppendFormat("{0:x2} ", addrSpace[atAddr++]);
             }
             else
             {
                 dSB.Append("   ");
             }
         }
         dSB.AppendFormat("{0,-15}{1}", RenderOpCode(addrSpace, dPC), Environment.NewLine);
         dPC += (ushort)len;
     }
     if (dSB.Length > 0)
     {
         dSB.Length--;  // Trim trailing newline
     }
     return dSB.ToString();
 }
 public void Write(AddressSpace mem)
 {
     mem.GetObjectData(this);
 }