예제 #1
0
        private void DumpMemory(bool type, ushort addr)
        {
            byte[] buf = new byte[128];

            if (type)
            {
                if (!KazzoAccess.PrgReadData(addr, ref buf))
                {
                    Logout("device not found.\n");
                    return;
                }
                Logout("PRG DUMP\n");
            }
            else
            {
                addr &= 0x3FFF;
                if (!KazzoAccess.ChrReadData(addr, ref buf))
                {
                    Logout("device not found.\n");
                    return;
                }
                Logout("CHR DUMP\n");
            }

            Logout("ADDR : +0 +1 +2 +3 +4 +5 +6 +7 +8 +9 +A +B +C +D +E +F ASCII\n" +
                   "-----+------------------------------------------------+----------------\n");
            for (int i = 0; i < 8; i++)
            {
                string str = (addr + i * 16).ToString("X4") + " : ";
                for (int j = 0; j < 16; j++)
                {
                    str = str + buf[i * 16 + j].ToString("X2") + " ";
                }
                for (int j = 0; j < 16; j++)
                {
                    char c = (char)buf[i * 16 + j];
                    if (c >= 0x20 && c <= 0x7F)
                    {
                        str = str + c.ToString();
                    }
                    else
                    {
                        str = str + ".";
                    }
                }
                str = str + "\n";
                Logout(str);
            }
        }
예제 #2
0
        private void CommandlineProcess(string cmd)
        {
            if (cmd == null)
            {
                return;
            }


            string[] cmds = cmd.Split(' ');

            switch (cmds[0].ToUpper())
            {
            case "H":
            case "?":
                DispHelp();
                break;

            case "D":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length < 2)
                {
                    DumpMemory(true, prgaddr);
                    prgaddr += 128;
                }
                else
                {
                    prgaddr = (ushort)Convert.ToInt32(cmds[1], 16);
                    DumpMemory(true, prgaddr);
                    prgaddr += 128;
                }
            }
            break;

            case "CD":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length < 2)
                {
                    DumpMemory(false, chraddr);
                    chraddr += 128;
                    chraddr &= 0x3FFF;
                }
                else
                {
                    chraddr  = (ushort)Convert.ToInt32(cmds[1], 16);
                    chraddr &= 0x3FFF;
                    DumpMemory(false, chraddr);
                    chraddr += 128;
                }
            }
            break;

            case "W":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length > 2)
                {
                    prgaddr = (ushort)Convert.ToInt32(cmds[1], 16);

                    byte[] wdata = new byte[cmds.Length - 2];
                    for (int i = 0; i < cmds.Length - 2; i++)
                    {
                        wdata[i] = (byte)Convert.ToInt32(cmds[i + 2], 16);
                    }

                    if (!KazzoAccess.PrgWriteData(prgaddr, wdata))
                    {
                        Logout("device not found.\n");
                        return;
                    }

                    Logout("PRG WRITE: " + prgaddr.ToString("X4") + " ");
                    for (int i = 0; i < cmds.Length - 2; i++)
                    {
                        Logout(wdata[i].ToString("X2") + " ");
                    }
                    Logout("\n");

                    prgaddr += (ushort)(cmds.Length - 2);
                }
            }
            break;

            case "W2":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length > 2)
                {
                    prgaddr = (ushort)Convert.ToInt32(cmds[1], 16);

                    byte[] wdata = new byte[cmds.Length - 2];
                    for (int i = 0; i < cmds.Length - 2; i++)
                    {
                        wdata[i] = (byte)Convert.ToInt32(cmds[i + 2], 16);
                    }

                    if (!KazzoAccess.PrgWriteDataLowFix(prgaddr, wdata))
                    {
                        Logout("device not found.\n");
                        return;
                    }

                    Logout("PRG WRITE: " + prgaddr.ToString("X4") + " ");
                    for (int i = 0; i < cmds.Length - 2; i++)
                    {
                        Logout(wdata[i].ToString("X2") + " ");
                    }
                    Logout("\n");

                    prgaddr += (ushort)(cmds.Length - 2);
                }
            }
            break;

            case "R":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length > 1)
                {
                    prgaddr = (ushort)Convert.ToInt32(cmds[1], 16);
                }

                byte[] buf = new byte[1];

                if (!KazzoAccess.PrgReadData(prgaddr, ref buf))
                {
                    Logout("device not found.\n");
                    return;
                }

                Logout("PRG READ: " + prgaddr.ToString("X4") + " ");
                Logout(buf[0].ToString("X2"));
                Logout("\n");

                prgaddr += 1;
            }
            break;

            case "CW":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length > 2)
                {
                    chraddr  = (ushort)Convert.ToInt32(cmds[1], 16);
                    chraddr &= 0x3FFF;

                    byte[] wdata = new byte[cmds.Length - 2];
                    for (int i = 0; i < cmds.Length - 2; i++)
                    {
                        wdata[i] = (byte)Convert.ToInt32(cmds[i + 2], 16);
                    }

                    if (!KazzoAccess.ChrWriteData(chraddr, wdata))
                    {
                        Logout("device not found.\n");
                        return;
                    }

                    Logout("CHR WRITE: " + chraddr.ToString("X4") + " ");
                    for (int i = 0; i < cmds.Length - 2; i++)
                    {
                        Logout(wdata[i].ToString("X2") + " ");
                    }
                    Logout("\n");

                    chraddr += (ushort)(cmds.Length - 2);
                }
            }
            break;

            case "CR":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                if (cmds.Length > 1)
                {
                    chraddr  = (ushort)Convert.ToInt32(cmds[1], 16);
                    chraddr &= 0x3FFF;
                }

                byte[] buf = new byte[1];

                if (!KazzoAccess.ChrReadData(chraddr, ref buf))
                {
                    Logout("device not found.\n");
                    return;
                }

                Logout("CHR READ: " + chraddr.ToString("X4") + " ");
                Logout(buf[0].ToString("X2"));
                Logout("\n");

                chraddr += 1;
                chraddr &= 0x3FFF;
            }
            break;

            case "PA":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                bool ram = false;
                if (!KazzoAccess.PpuRamAnalyze(ref ram))
                {
                    Logout("device not found.\n");
                    return;
                }

                if (ram)
                {
                    Logout("PPU CHR RAM: YES\n");
                }
                else
                {
                    Logout("PPU CHR RAM: NO\n");
                }
            }
            break;

            case "MA":
            {
                if (!CartridgeTest())
                {
                    break;
                }

                byte mirror = 0;
                if (!KazzoAccess.PpuMirrorAnalyze(ref mirror))
                {
                    Logout("device not found.\n");
                    return;
                }

                Logout("Mirror type: ");
                switch (mirror)
                {
                case 0x00:
                    Logout("One screen $2000");
                    break;

                case 0x0F:
                    Logout("One screen $2400");
                    break;

                case 0x0C:                                          // 1100
                    Logout("H Mirror");
                    break;

                case 0x0A:                                          // 1010
                    Logout("V Mirror");
                    break;

                default:
                    Logout("Unknown.");
                    break;
                }
                string s = Convert.ToString(mirror, 2);
                s = s.PadLeft(4, '0');
                Logout(" (value = " + s + ")\n");
            }
            break;

            default:
                Logout("Unknown command.\n");
                break;
            }
        }