/// <summary>
    /// Reads and dumps a memcard to disc
    /// </summary>
    /// <param name="inCard">0/1</param>
    public static bool Command_MemcardDownload(UInt32 inCard, string fileName)
    {
        if (!TransferLogic.ChallengeResponse(CommandMode.MCDOWN))
        {
            return(Error("No response from Unirom. Are you using 8.0.E or higher?"));
        }

        // send the card number
        activeSerial.Write(BitConverter.GetBytes(inCard), 0, 4);

        Console.WriteLine("Reading card to ram...");

        // it'll send this when it's done dumping to ram
        if (!TransferLogic.WaitResponse("MCRD", false))
        {
            return(Error("Please see screen or SIO for error!"));
        }

        Console.WriteLine("Ready, reading....");

        UInt32 addr = TransferLogic.read32();

        Console.WriteLine("Data is 0x" + addr.ToString("x"));

        UInt32 size = TransferLogic.read32();

        Console.WriteLine("Size is 0x" + size.ToString("x"));


        Console.WriteLine("Dumping...");

        byte[] lastReadBytes = new byte[size];
        TransferLogic.ReadBytes(addr, size, lastReadBytes);


        if (System.IO.File.Exists(fileName))
        {
            string newFilename = fileName + GetSpan().TotalSeconds.ToString();

            Console.Write("\n\nWARNING: Filename " + fileName + " already exists! - Dumping to " + newFilename + " instead!\n\n");

            fileName = newFilename;
        }

        try
        {
            File.WriteAllBytes(fileName, lastReadBytes);
        }
        catch (Exception e)
        {
            return(Error("Couldn't write to the output file + " + fileName + " !\nThe error returned was: " + e, false));
        }

        Console.WriteLine("File written to: " + fileName);
        Console.WriteLine("It is raw .mcd format used by PCSX-redux, no$psx, etc");
        return(true);
    }
Esempio n. 2
0
    public static bool SetRegs()
    {
        // read the pointer to TCB[0]
        byte[] ptrBuffer = new byte[4];
        if (!TransferLogic.ReadBytes(0x80000110, 4, ptrBuffer))
        {
            return(false);
        }

        UInt32 tcbPtr = BitConverter.ToUInt32(ptrBuffer, 0);

        Console.WriteLine("TCB PTR " + tcbPtr.ToString("X"));

        // Convert regs back to a byte array and bang them back out
        byte[] tcbBytes = new byte[TCB_LENGTH_BYTES];
        Buffer.BlockCopy(tcb.regs, 0, tcbBytes, 0, TCB_LENGTH_BYTES);

        TransferLogic.Command_SendBin(tcbPtr, tcbBytes);

        return(true);
    }
Esempio n. 3
0
    public static bool GetRegs()
    {
        // read the pointer to TCB[0]
        byte[] ptrBuffer = new byte[4];
        if (!TransferLogic.ReadBytes(0x80000110, 4, ptrBuffer))
        {
            return(false);
        }

        UInt32 tcbPtr = BitConverter.ToUInt32(ptrBuffer, 0);

        Console.WriteLine("TCB PTR " + tcbPtr.ToString("X"));

        byte[] tcbBytes = new byte[TCB_LENGTH_BYTES];
        if (!TransferLogic.ReadBytes(tcbPtr, (int)GPR.COUNT * 4, tcbBytes))
        {
            return(false);
        }

        Buffer.BlockCopy(tcbBytes, 0, tcb.regs, 0, tcbBytes.Length);

        return(true);
    }