public static void SaveTrainerSpriteToFreeSpace(int index, byte[] sprite, Color[] pallete) { var sOffset = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "TrainerImageTable", ""), System.Globalization.NumberStyles.HexNumber) + index * 8; var pOffset = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "TrainerPaletteTable", ""), System.Globalization.NumberStyles.HexNumber) + index * 8; string imgString; string palString; byte[] imgBytes; byte[] palBytes; string imgNewOffset; string palNewOffset; string LocalCompressLz77String() { var argsrcString = WichuRomFunctions.ConvertByteArrayToString(ref sprite); var ret = WichuRomFunctions.CompressLz77String(ref argsrcString); return(ret); } var argstr = LocalCompressLz77String(); imgBytes = WichuRomFunctions.ConvertStringToByteArray(ref argstr); string LocalCompressLz77String1() { var argsrcString = WichuSpriteFunctions.ConvertPaletteToString(ref pallete); var ret = WichuRomFunctions.CompressLz77String(ref argsrcString); return(ret); } var argstr1 = LocalCompressLz77String1(); palBytes = WichuRomFunctions.ConvertStringToByteArray(ref argstr1); imgString = ByteFunctions.ByteArrayToHexString(imgBytes); palString = ByteFunctions.ByteArrayToHexString(palBytes); imgNewOffset = modSearchFreeSpace.SearchFreeSpaceFourAligned(MainObject.LoadedRom, 0xFF, (long)(Strings.Len(imgString) / 2d), Conversions.ToLong("&H" + Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "StartSearchingForSpaceOffset", "800000"))).ToString(); var argStart = Conversions.ToInteger(imgNewOffset); HexFunctions.WriteHex(ref MainObject.LoadedRom, ref argStart, ref imgString); string LocalReverseHex() { var argHexData = Conversion.Hex(Conversions.ToDouble(imgNewOffset) + 134217728d); var ret = HexFunctions.ReverseHex(ref argHexData); return(ret); } var argData = LocalReverseHex(); HexFunctions.WriteHex(ref MainObject.LoadedRom, ref sOffset, ref argData); palNewOffset = modSearchFreeSpace.SearchFreeSpaceFourAligned(MainObject.LoadedRom, 0xFF, (long)(Strings.Len(palString) / 2d), Conversions.ToLong("&H" + Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "StartSearchingForSpaceOffset", "800000"))).ToString(); var argStart1 = Conversions.ToInteger(palNewOffset); HexFunctions.WriteHex(ref MainObject.LoadedRom, ref argStart1, ref palString); string LocalReverseHex1() { var argHexData = Conversion.Hex(Conversions.ToDouble(palNewOffset) + 134217728d); var ret = HexFunctions.ReverseHex(ref argHexData); return(ret); } var argData1 = LocalReverseHex1(); HexFunctions.WriteHex(ref MainObject.LoadedRom, ref pOffset, ref argData1); }
public static void SaveAnimationSpriteToFreeSpace(int pokemonindex, byte[] sprite) { var sOffset = int.Parse(Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "PokemonAnimations", ""), System.Globalization.NumberStyles.HexNumber) + pokemonindex * 8; // Pointer to Pokemon front sprites, + 8 = Bulbasaur. string imgString; byte[] imgBytes; string imgNewOffset; string LocalCompressLz77String() { var argsrcString = WichuRomFunctions.ConvertByteArrayToString(ref sprite); var ret = WichuRomFunctions.CompressLz77String(ref argsrcString); return(ret); } var argstr = LocalCompressLz77String(); imgBytes = WichuRomFunctions.ConvertStringToByteArray(ref argstr); imgString = ByteFunctions.ByteArrayToHexString(imgBytes); imgNewOffset = modSearchFreeSpace.SearchFreeSpaceFourAligned(MainObject.LoadedRom, 0xFF, (long)(Strings.Len(imgString) / 2d), Conversions.ToLong("&H" + Ini.GetString(Conversions.ToString(MMainFunctions.GetIniFileLocation()), MainObject.Header, "StartSearchingForSpaceOffset", "800000"))).ToString(); var argStart = Conversions.ToInteger(imgNewOffset); HexFunctions.WriteHex(ref MainObject.LoadedRom, ref argStart, ref imgString); string LocalReverseHex() { var argHexData = Conversion.Hex(Conversions.ToDouble(imgNewOffset) + 134217728d); var ret = HexFunctions.ReverseHex(ref argHexData); return(ret); } var argData = LocalReverseHex(); HexFunctions.WriteHex(ref MainObject.LoadedRom, ref sOffset, ref argData); }