예제 #1
0
        public SNAFile(byte[] data)
        {
            this.data = data;
            EncodedStream stream = new EncodedStream(data);
            var           r      = new BinaryReader(stream);

            stream.Seek(4, SeekOrigin.Current); // SNA's magic number is not encoded

            do
            {
                long position = stream.Position;

                var partId          = r.ReadByte();
                var memorySomething = r.ReadByte();
                var v32             = r.ReadByte();
                var v29             = r.ReadInt32();

                var v42      = r.ReadInt32();
                var v27      = r.ReadInt32();
                var v33      = r.ReadInt32();
                var dataSize = r.ReadInt32(); // 0, 0, 0, 0, 0, 0, 0, 0x0001BC4C (113740), 0x006934D0, 0x00053770

                //MessageBox.Show(toMove.ToString("X8"));

                //MessageBox.Show((10 * partId + memorySomething).ToString());
                if (!gptRelocationIdToPartPosition.ContainsKey(10 * partId + memorySomething))
                {
                    gptRelocationIdToPartPosition.Add(10 * partId + memorySomething, position);
                }
                else
                {
                    gptRelocationIdToPartPosition[10 * partId + memorySomething] = position;
                }

                if (ParseSNA3(partId, memorySomething))
                {
                    if (dataSize > 0)
                    {
                        byte[] v41 = r.ReadBytes(dataSize);

                        parts.Add(new PartStruct()
                        {
                            position = position,
                            partId   = partId,
                            size     = dataSize
                        });

                        File.WriteAllBytes($"sna_part_{partId}_{memorySomething}.bin", v41);
                    }
                }
                else if (dataSize > 0)
                {
                    // MessageBox.Show("Moving" + toMove.ToString());
                }

                // WIP - do not touch
            }while (stream.Position < stream.Length);
        }
예제 #2
0
        static void Main(string[] args)
        {
            EncodedStream stream = new EncodedStream(File.ReadAllBytes(@"D:\GOG Games\Rayman 2\Data\World\Levels\Learn_30\Learn_30.sna"));
            var r = new BinaryReader(stream);
            stream.Seek(4, SeekOrigin.Current); // SNA's magic number is not encoded

            stream.SeekWithUpdatedMagic(-4 + 0x5a242 - 0x46); // Move to portal stone structure start

            // Texture entry

            int something1 = r.ReadInt32();
            int something2 = r.ReadInt32();

            int something3 = r.ReadInt32();

            int something4 = r.ReadInt32();
            int something5 = r.ReadInt32();

            int something6 = r.ReadInt32();

            short something7 = r.ReadInt16();
            short something8 = r.ReadInt16();
            short texture_width = r.ReadInt16(); // Not sure
            short texture_height = r.ReadInt16(); // Not sure

            int something11 = r.ReadInt32();
            int something12 = r.ReadInt32();
            int something13 = r.ReadInt32();

            int something14 = r.ReadInt32();

            var something15 = r.ReadBytes(21);

            byte something16 = r.ReadByte();

            string texture_name = r.ReadNullTermStringWithLength(130);

            Console.WriteLine("something1: " + something1);
            Console.WriteLine("something2: " + something2);
            Console.WriteLine("something3: " + something3);
            Console.WriteLine("something4: " + something4);
            Console.WriteLine("something5: " + something5);
            Console.WriteLine("something6: " + something6);
            Console.WriteLine("something7: " + something7);
            Console.WriteLine("something8: " + something8);
            Console.WriteLine("texture_width: " + texture_width);
            Console.WriteLine("texture_height: " + texture_height);
            Console.WriteLine("something11: " + something11);
            Console.WriteLine("something12: " + something12);
            Console.WriteLine("something13: " + something13);
            Console.WriteLine("something14: " + something14);
            Console.WriteLine("something15: " + something15);
            Console.WriteLine("something16: " + something16);
            Console.WriteLine("texture_name: " + texture_name);

            Console.ReadLine();
        }
예제 #3
0
        public SNAFile(byte[] data)
        {
            this.data = data;
            EncodedStream stream = new EncodedStream(data);
            var r = new BinaryReader(stream);

            stream.Seek(4, SeekOrigin.Current); // SNA's magic number is not encoded

            do
            {
                long position = stream.Position;

                var partId = r.ReadByte();
                var memorySomething = r.ReadByte();
                var v32 = r.ReadByte();
                var v29 = r.ReadInt32();

                var v42 = r.ReadInt32();
                var v27 = r.ReadInt32();
                var v33 = r.ReadInt32();
                var dataSize = r.ReadInt32(); // 0, 0, 0, 0, 0, 0, 0, 0x0001BC4C (113740), 0x006934D0, 0x00053770

                //MessageBox.Show(toMove.ToString("X8"));

                //MessageBox.Show((10 * partId + memorySomething).ToString());
                if (!gptRelocationIdToPartPosition.ContainsKey(10*partId + memorySomething))
                    gptRelocationIdToPartPosition.Add(10*partId + memorySomething, position);
                else
                    gptRelocationIdToPartPosition[10*partId + memorySomething] = position;

                if (ParseSNA3(partId, memorySomething))
                {
                    if (dataSize > 0)
                    {
                        byte[] v41 = r.ReadBytes(dataSize);

                        parts.Add(new PartStruct()
                        {
                            position = position,
                            partId = partId,
                            size = dataSize
                        });

                        File.WriteAllBytes($"sna_part_{partId}_{memorySomething}.bin", v41);
                    }
                }
                else if (dataSize > 0)
                {
                    // MessageBox.Show("Moving" + toMove.ToString());
                }

                // WIP - do not touch
            }
            while (stream.Position < stream.Length);
        }
예제 #4
0
파일: Form1.cs 프로젝트: szymski/Rayman2Lib
 private void decodeButton_Click(object sender, EventArgs e)
 {
     openFileDialog1.Filter = "";
     if (openFileDialog1.ShowDialog() == DialogResult.OK && File.Exists(openFileDialog1.FileName))
     {
         saveFileDialog1.FileName = new FileInfo(openFileDialog1.FileName).Name + ".decoded";
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             var stream = new EncodedStream(File.ReadAllBytes(openFileDialog1.FileName));
             stream.Seek(4, SeekOrigin.Current);
             byte[] buff = new byte[stream.Length];
             buff[0] = 0x79;
             buff[1] = 0xCC;
             buff[2] = 0xB5;
             buff[3] = 0x6A;
             stream.Read(buff, 4, (int)stream.Length - 4);
             File.WriteAllBytes(saveFileDialog1.FileName, buff);
             stream.Close();
             MessageBox.Show("File decoded!");
         }
     }
 }