コード例 #1
0
        public byte[] ToArrayBoxData()
        {
            var ms = new MemoryStream(0x20);
            var bw = new BinaryWriter(ms);

            ms.Position = 0;

            // Stand: SM64 Editor v2.0.7

            bw.Write(SwapInts.SwapInt32(InvisibleWater ? 0x0 : 0x10000)); // Type = SpecialBoxType.ToxicHaze OrElse
            bw.Write(SwapInts.SwapInt16(0xF));
            bw.Write(SwapInts.SwapInt16(Scale));
            bw.Write(SwapInts.SwapInt16(X1));
            bw.Write(SwapInts.SwapInt16(Z1));
            bw.Write(SwapInts.SwapInt16(X2));
            bw.Write(SwapInts.SwapInt16(Z1));
            bw.Write(SwapInts.SwapInt16(X2));
            bw.Write(SwapInts.SwapInt16(Z2));
            bw.Write(SwapInts.SwapInt16(X1));
            bw.Write(SwapInts.SwapInt16(Z2));
            if (Type == SpecialBoxType.ToxicHaze)
            {
                bw.Write(SwapInts.SwapInt32(Alpha)); // &HB4
                bw.Write(SwapInts.SwapInt32(0x10000));
            }
            else
            {
                bw.Write(SwapInts.SwapInt32(0x10000 | Alpha));
                bw.Write(SwapInts.SwapInt32((int)WaterType));
            }

            ms.Close();
            return(ms.GetBuffer());
        }
コード例 #2
0
        public static SpecialBox[] ReadTable(Stream s, SpecialBoxType Type, int Levelscriptstart, int TabelStart)
        {
            var br      = new BinaryReader(s);
            var boxlist = new List <SpecialBox>();

            s.Position = TabelStart;

            if (SwapInts.SwapInt32(br.ReadInt32()) == 0x1010101)
            {
                return(Array.Empty <SpecialBox>());
            }
            else
            {
                s.Position -= 0x4;
            }

            while (SwapInts.SwapUInt16(br.ReadUInt16()) != 0xFFFF)
            {
                s.Position += 0x2;
                var tbox = new SpecialBox();
                tbox.Type = Type;
                int lastpos = (int)(s.Position + 0x4);
                s.Position = SwapInts.SwapInt32(br.ReadInt32()) - 0x19000000 + Levelscriptstart;

                if (Type == SpecialBoxType.Water)
                {
                    tbox.InvisibleWater = SwapInts.SwapInt32(br.ReadInt32()) == 0x0;
                }
                else
                {
                    s.Position += 0x4;
                }

                s.Position    += 0x2;
                tbox.Scale     = SwapInts.SwapInt16(br.ReadInt16());
                tbox.X1        = SwapInts.SwapInt16(br.ReadInt16());
                tbox.Z1        = SwapInts.SwapInt16(br.ReadInt16());
                tbox.X2        = SwapInts.SwapInt16(br.ReadInt16());
                s.Position    += 0x4;
                tbox.Z2        = SwapInts.SwapInt16(br.ReadInt16());
                s.Position    += 0x7;
                tbox.Alpha     = br.ReadByte();
                tbox.WaterType = (WaterType)SwapInts.SwapInt32(br.ReadInt32());
                s.Position     = lastpos;
                boxlist.Add(tbox);
            }

            return(boxlist.ToArray());
        }
コード例 #3
0
 public short ReadInt16()
 {
     return(SwapInts.SwapInt16(Reader.ReadInt16()));
 }
コード例 #4
0
 public void Write(short value)
 {
     Writer.Write(SwapInts.SwapInt16(value));
 }