Ejemplo n.º 1
0
        private static void ExtractCount(string fileName, sceModule sceModule)
        {
            string path;

            if (Path.GetDirectoryName(fileName) == "")
            {
                path = Environment.CurrentDirectory + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_count.txt";
            }
            else
            {
                path = Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_count.txt";
            }

            List <string> byteInfo = new List <string>();
            int           total    = 0;
            bool          switch1  = true;

            for (int idx = 0; idx < sceModule.Count; ++idx)
            {
                total += sceModule.GetBlock(idx).Length;
                if (total > 0xFFF && switch1)
                {
                    byteInfo.Add("-----------CUT POINT-----------------------");
                    byteInfo.Add("|       length average: " + (total / idx + 1));
                    byteInfo.Add("-----------CUT POINT-----------------------");
                    switch1 = false;
                }
                byteInfo.Add(string.Format("Block: {0:D3},", idx)
                             + string.Format(" Ptr: 0x{0:X6}", sceModule.Header.fileStrings[idx].myOffset)
                             + string.Format(" ({0:D}),", (int)sceModule.Header.fileStrings[idx].typeOffset)
                             + string.Format(" Text: 0x{0:X6}", sceModule.Header.fileStrings[idx].offset)
                             + string.Format(" | Line length: {0:D3}, ", sceModule.GetBlock(idx).Length)
                             + string.Format("total length: {0:D4}", total));
            }
            File.WriteAllLines(path, byteInfo.ToArray());
            return;
        }
Ejemplo n.º 2
0
        private static void ExtractRaw(string fileName, sceModule sceModule)
        {
            string path;

            if (Path.GetDirectoryName(fileName) == "")
            {
                path = Environment.CurrentDirectory + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_raw.txt";
            }
            else
            {
                path = Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_raw.txt";
            }

            List <byte> dump = new List <byte>();

            for (int idx = 0; idx < sceModule.Count; ++idx)
            {
                dump.AddRange(sceModule.GetBlock(idx));
                dump.AddRange(Encoding.ASCII.GetBytes("\r\n[ENDBLOCK]\r\n"));
            }
            File.WriteAllBytes(path, dump.ToArray());
            return;
        }
Ejemplo n.º 3
0
        private static void Extract(string fileName)
        {
            sceModule sceModule = new sceModule(fileName);

            if (!sceModule.isHaveText())
            {
                return;
            }
            string path      = !(Path.GetDirectoryName(fileName) != "") ? Environment.CurrentDirectory + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".txt" : Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + ".txt";
            string pathCount = !(Path.GetDirectoryName(fileName) != "") ? Environment.CurrentDirectory + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_count.txt" : Path.GetDirectoryName(fileName) + "\\" + Path.GetFileNameWithoutExtension(fileName) + "_count.txt";

            Console.WriteLine(string.Format("Extracting {0}...", Path.GetFileName(fileName)));

            if (jpcodes == null)
            {
                Console.WriteLine("No JPCODES.txt file! Dumping raw bytes...");
            }
            if (jpcodes == null || dumpRaw || dumpCount)
            {
                List <byte>   dump     = new List <byte>();
                List <string> byteInfo = new List <string>();
                int           total    = 0;
                bool          switch1  = true;
                for (int idx = 0; idx < sceModule.Count - 1; ++idx)
                {
                    if (dumpCount)
                    {
                        total += sceModule.GetBlock(idx).Length;
                        if (total > 0xFFF && switch1)
                        {
                            byteInfo.Add("-----------CUT POINT-----------------------");
                            byteInfo.Add("|       length average: " + (total / idx + 1));
                            byteInfo.Add("-----------CUT POINT-----------------------");
                            switch1 = false;
                        }
                        byteInfo.Add("Block: " + String.Format("{0:D3}", idx) + " | Line length: " + String.Format("{0:D3}", sceModule.GetBlock(idx).Length) + " total length: " + String.Format("{0:D4}", total));
                    }
                    else
                    {
                        dump.AddRange(sceModule.GetBlock(idx));
                        dump.Add(0x0D); dump.Add(0x0A);
                        dump.AddRange(Encoding.ASCII.GetBytes("[ENDBLOCK]"));
                        dump.Add(0x0D); dump.Add(0x0A);
                    }
                }
                if (dumpCount)
                {
                    File.WriteAllLines(pathCount, byteInfo.ToArray());
                }
                else
                {
                    File.WriteAllBytes(path, dump.ToArray());
                }
                return;
            }

            List <string> stringList = new List <string>();

            for (int idx = 0; idx < sceModule.Count; ++idx)
            {
                string str = sceModule.GetStringBlock(idx);
                if (codes != null)
                {
                    str = codes.ConvertNativeToTags(str);
                }
                else
                {
                    Console.WriteLine("No CODES.txt file! Special sequences will be ignored, output can get messy!");
                }
                if (jpcodes != null)
                {
                    str = jpcodes.ConvertAtoB(str);
                }
                stringList.Add(HexToAnsi(str));
                stringList.Add("[ENDBLOCK]");
            }
            if (useSJIS)
            {
                File.WriteAllLines(path, stringList.ToArray(), SJIS);
            }
            else
            {
                File.WriteAllLines(path, stringList.ToArray());
            }
        }