Ejemplo n.º 1
0
        static void CompileM12MiscStringCollection(string name, ref int referenceAddress)
        {
            int baseAddress = referenceAddress;
            var buffer      = new List <byte>();

            // Read the JSON
            MiscStringCollection stringCollection = JsonConvert.DeserializeObject <MiscStringCollection>(
                File.ReadAllText(Path.Combine(options.WorkingDirectory, name + ".json")));

            // Open the offset ASM file
            using (var offsetFile = File.CreateText(Path.Combine(options.WorkingDirectory, name + ".asm")))
            {
                // Include the binfile
                offsetFile.WriteLine(String.Format(".org 0x{0:X} :: .incbin \"{1}.bin\"",
                                                   baseAddress | 0x8000000, name));
                offsetFile.WriteLine();

                // Compile all strings
                foreach (var str in stringCollection.StringRefs.OrderBy(s => s.Index))
                {
                    offsetFile.WriteLine(String.Format(".org 0x{0:X} :: dw 0x{1:X8}",
                                                       str.OffsetLocation | 0x8000000, referenceAddress - stringCollection.StringsLocation));

                    m12Compiler.CompileString(str.New, buffer, ref referenceAddress, ebCharLookup);
                }
            }

            // Write the buffer
            File.WriteAllBytes(Path.Combine(options.WorkingDirectory, name + ".bin"), buffer.ToArray());

            // Add to the include file
            IncludeFile.WriteLine(".include \"" + name + ".asm\"");
        }
Ejemplo n.º 2
0
        static void DecompileM12MiscStringCollection(string name, MiscStringCollection miscStringCollection)
        {
            // Decompile the strings
            foreach (var miscStringRef in miscStringCollection.StringRefs)
            {
                string decompiledString;

                if (miscStringRef.BasicMode)
                {
                    decompiledString = m12Decompiler.ReadFFString(m12Rom, miscStringRef.OldPointer);
                }
                else
                {
                    decompiledString = m12Decompiler.DecompileString(m12Rom, miscStringRef.OldPointer, false);
                }

                miscStringRef.Old     =
                    miscStringRef.New = decompiledString;
            }

            // Write JSON
            File.WriteAllText(Path.Combine(options.WorkingDirectory, name + ".json"),
                              JsonConvert.SerializeObject(miscStringCollection, Formatting.Indented));
        }