Exemplo n.º 1
0
    public static void DumpDataFromPointerTab(string romfile, string outfolder)
    {
        int offset    = 0x05e234 - 8;
        int maxOffset = offset + 0x918; // 0x918 = 2328 dec

        byte[]        mF     = File.ReadAllBytes(romfile);
        List <string> outcsv = new List <string>();

        outcsv.Add("Pointer Offset;HIROM Offset;PC Offset;CType;Block Size;Description;");
        for (int c = offset; c < maxOffset; c += 8)
        {
            byte   cType   = 0;
            byte[] outSize = new byte[2];
            byte[] pData   = new byte[3];

            byte[] oF     = new byte[buffersize];
            byte[] outBuf = new byte[buffersize];

            cType = mF[c];
            Array.Copy(mF, c + 3, outSize, 0, 2);
            Array.Copy(mF, c + 5, pData, 0, 3);

            ushort DataLength = (ushort)((ushort)(outSize[1] << 8) | (ushort)(outSize[0]));

            uint HIROMOffset = (uint)pData[2] << 16;
            HIROMOffset = (uint)(HIROMOffset | (((uint)(pData[1])) << 8));
            HIROMOffset = (uint)(HIROMOffset | (uint)pData[0]);

            uint DataOffset = ConvPCHiROMBank((uint)pData[2]) << 16;
            DataOffset = (uint)(DataOffset | (((uint)(pData[1])) << 8));
            DataOffset = (uint)(DataOffset | (uint)pData[0]);
            string dt = "";
            if (DataOffset < mF.Length)
            {
                if ((cType > 0x01) && (cType < 0x06))
                {
                    Array.Copy(mF, DataOffset, oF, 0, buffersize);
                    BM5RLE.Decompress(oF, DataLength, "SBM5_" + cType.ToString("X").PadLeft(2, '0') + "_0x" + DataOffset.ToString("X") + ".bin");

                    //byte[] final = new byte[DataLength];
                    //Array.Copy(outBuf, 0, final, 0, DataLength);
                    //File.WriteAllBytes(, final);
                    dt = "X";
                }
                else
                {
                    //dump unknown data
                    byte[] final = new byte[DataLength];
                    Array.Copy(mF, DataOffset, final, 0, DataLength);
                    File.WriteAllBytes("SBM5_" + cType.ToString("X").PadLeft(2, '0') + "_0x" + DataOffset.ToString("X") + ".bin", final);
                    dt = "?";
                }
            }
            outcsv.Add(c.ToString("X") + ";" + HIROMOffset.ToString("X") + ";" + DataOffset.ToString("X") + ";" + cType.ToString("X").PadLeft(2, '0') + ";" + DataLength.ToString() + ";\"" + dt + "\";");
        }
        if (outcsv.Count > 1)
        {
            File.WriteAllLines("SBM5_PointerTableDocumentation.csv", outcsv);
        }
    }
Exemplo n.º 2
0
        static byte[] RLECompression(byte[] indata, string type)
        {
            switch (type.ToUpper())
            {
            case "BM5":
                return(BM5RLE.Compress(indata));

            case "SFCW":
                return(SFCWRLE.Compress(indata));

            default:
                return(BM5RLE.Compress(indata));
            }
        }
Exemplo n.º 3
0
        static void OutputDecompressedFile(string input, string output, string type, int lztype, int offset, int length)
        {
            if (File.Exists(input))
            {
                if (!(output == ""))
                {
                    byte[] file = File.ReadAllBytes(input);

                    if (lztype > -1)
                    {//then use lunar compress...
                        Console.WriteLine("Commencing decompression with Lunar Compress Type " + lztype.ToString() + "...");
                        byte[] d1 = LCompress.Decompress(file, offset, 0x10000, (uint)lztype);
                        byte[] d2 = new byte[LCompress.LastDecompressedSize];
                        Array.Copy(d1, d2, LCompress.LastDecompressedSize);
                        File.WriteAllBytes(output, d2);
                    }
                    else
                    {
                        switch (type.ToLower())
                        {
                        case "sbm5":
                            Console.WriteLine("Commencing decompression with Super Bomberman 5 RLE Type...");
                            BM5RLE.Decompress(file, length, output);
                            break;

                        case "sfcw":
                            Console.WriteLine("Commencing decompression with Super Famicom Wars RLE Type...");
                            byte[] data = SFCWRLE.Decompress(file);
                            File.WriteAllBytes(output, data);
                            break;

                        default:
                            Console.WriteLine("Type argument was invalid. Failed.");
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Missing output file argument. Failed.");
                    //message - output file required
                }
            }
            else
            {
                Console.WriteLine("Invalid input file argument. Failed.");
                //message- input file required
            }
        }
Exemplo n.º 4
0
        static void OutputCompressedFile(string input, string output, string type)
        {
            if (File.Exists(input))
            {
                if (!(output == ""))
                {
                    int lztype = -1;
                    try
                    {//if there is no error, then its an LZ type (Lunar)
                        lztype = int.Parse(type);
                        byte[] file    = File.ReadAllBytes(input);
                        byte[] outbyte = null;
                        LCompress.Compress(file, out outbyte, LCompress.GetLZType(type));
                        File.WriteAllBytes(output, outbyte);
                    }
                    catch
                    {
                        switch (type.ToLower())
                        {
                        case "sbm5":
                            Console.WriteLine("Commencing Compression with Super Bomberman 5 RLE Type...");
                            BM5RLE.Compress(input, output);
                            break;

                        case "sfcw":
                            Console.WriteLine("Commencing Compression with Super Famicom Wars LZ/RLE Type...");
                            byte[] data = SFCWRLE.Compress(File.ReadAllBytes(input));
                            File.WriteAllBytes(output, data);
                            break;

                        default:
                            Console.WriteLine("Type argument was invalid. Failed.");
                            break;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Missing output file argument. Failed.");
                    //message - output file required
                }
            }
            else
            {
                Console.WriteLine("Invalid input file argument. Failed.");
                //message- input file required
            }
        }