Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        // Public Function LoadLz77CompressedPalette(ByRef Stream As FileStream, ByVal message As Boolean) As Color()
        // Dim colorArray2 As Color() = New Color(&H10 - 1) {}
        // Dim buffer As Byte() = RomFunctions.UncompressLZ77(Stream, message)
        // If (buffer.Length <> 0) Then
        // Dim index As Integer = 0
        // Do
        // Dim num As Integer = buffer(((index * 2) + 1))
        // num = (num << 8)
        // num = (num Or buffer((index * 2)))
        // colorArray2(index) = .RGB16ToColor(num)
        // index += 1
        // Loop While (index <= 15)
        // End If
        // Return colorArray2
        // End Function

        // Public Sub LoadLz77CompressedSprite(ByRef Stream As FileStream, ByVal offset As Integer, ByVal palette As Color(), ByRef bitmap As Bitmap)
        // Dim ary As Byte() = RomFunctions.UncompressLZ77(Stream)
        // LoadBitmapFromArray(ary, palette, bitmap, &H40, CInt(Math.Round(CDbl((CDbl(ary.Length) / 32)))))
        // End Sub

        public static Color[] LoadPaletteFromROM(ref FileStream streaminput)
        {
            var colorArray2 = new Color[16];
            var index       = 0;

            do
            {
                Stream streamvar = streaminput;
                streamvar          = (FileStream)streamvar;
                colorArray2[index] = RGB16ToColor(Conversions.ToInteger(WichuRomFunctions.GetWord(ref streamvar)));
                index += 1;
            }while (index <= 15);
            return(colorArray2);
        }
Esempio n. 3
0
        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);
        }