Ejemplo n.º 1
0
 public Actors(Generic basecmd)
     : base(basecmd)
 {
     ActorList = new List<Entry>();
     for (int i = 0; i < GetCountGeneric(); i++) ActorList.Add(new Entry(ROM, (uint)(GetAddressGeneric() + i * 16), (i + 1),
         (Command == HeaderLoader.CommandTypeIDs.Spawns), (Command == HeaderLoader.CommandTypeIDs.Transitions)));
 }
Ejemplo n.º 2
0
 public SettingsSoundScene(Generic basecmd)
     : base(basecmd)
 {
     Reverb = (byte)((this.Data >> 48) & 0xFF);
     NightSfxID = (byte)((this.Data >> 8) & 0xFF);
     TrackID = (byte)(this.Data & 0xFF);
 }
Ejemplo n.º 3
0
 public Generic(Generic basecmd)
 {
     ROM = basecmd.ROM;
     InROM = basecmd.InROM;
     Command = basecmd.Command;
     Offset = basecmd.Offset;
     Data = basecmd.Data;
     Parent = basecmd.Parent;
 }
Ejemplo n.º 4
0
        public Waypoints(Generic basecmd)
            : base(basecmd)
        {
            Paths = new List<PathHeader>();

            int i = 0;
            while (true)
            {
                PathHeader nph = new PathHeader(ROM, (uint)(GetAddressGeneric() + i * 8), i);
                if (nph.Points == null) break;
                Paths.Add(nph);
                i++;
            }
        }
Ejemplo n.º 5
0
        public Rooms(Generic basecmd)
            : base(basecmd)
        {
            RoomInformation = new List<RoomInfoClass>();

            byte seg = (byte)(GetAddressGeneric() >> 24);

            for (int i = 0; i < GetCountGeneric(); i++)
            {
                RoomInfoClass roomadr = new RoomInfoClass(ROM, basecmd.Parent, i,
                    Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[seg]), (int)((GetAddressGeneric() & 0xFFFFFF) + i * 8))),
                    Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[seg]), (int)((GetAddressGeneric() & 0xFFFFFF) + i * 8) + 4)));
                RoomInformation.Add(roomadr);
            }
        }
Ejemplo n.º 6
0
        public HeaderLoader(ROMHandler rom, IHeaderParent parent, byte seg, int ofs, int number)
        {
            Parent = parent;

            Offset = ofs;
            Segment = seg;
            Number = number;

            Commands = new List<Generic>();
            Generic cmd = null;
            while ((cmd = new Generic(rom, parent, seg, ref ofs)).Command != CommandTypeIDs.EndOfHeader)
            {
                Type cmdtype = (Type)CommandTypes[cmd.Command];
                object inst = Activator.CreateInstance((cmdtype == null ? typeof(Generic) : cmdtype), new object[] { cmd });
                Commands.Add((Generic)inst);
            }
        }
Ejemplo n.º 7
0
 public EnvironmentSettings(Generic basecmd)
     : base(basecmd)
 {
     EnvSettingList = new List<Entry>();
     for (int i = 0; i < GetCountGeneric(); i++) EnvSettingList.Add(new Entry(ROM, (uint)(GetAddressGeneric() + i * 22)));
 }
Ejemplo n.º 8
0
        public Collision(Generic basecmd)
            : base(basecmd)
        {
            uint adr = (uint)(GetAddressGeneric() & 0xFFFFFF);

            byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(GetAddressGeneric() >> 24)];
            if (segdata == null) return;

            /* Read header */
            AbsoluteMinimum = new Vector3d(
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x2)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x4)));
            AbsoluteMaximum = new Vector3d(
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x6)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x8)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0xA)));

            VertexCount = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)adr + 0xC));
            VertexArrayOffset = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x10));
            PolygonCount = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)adr + 0x14));
            PolygonArrayOffset = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x18));
            PolygonTypeOffset = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x1C));
            CameraDataOffset = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x20));
            WaterboxCount = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)adr + 0x24));
            WaterboxOffset = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x28));

            /* Read vertices */
            byte[] vertsegdata = (byte[])ROM.SegmentMapping[(byte)(VertexArrayOffset >> 24)];
            if (vertsegdata != null)
            {
                Vertices = new List<Vector3d>();
                for (int i = 0; i < VertexCount; i++)
                {
                    Vertices.Add(new Vector3d(
                        Endian.SwapInt16(BitConverter.ToInt16(vertsegdata, (int)(VertexArrayOffset & 0xFFFFFF) + (i * 6))),
                        Endian.SwapInt16(BitConverter.ToInt16(vertsegdata, (int)(VertexArrayOffset & 0xFFFFFF) + (i * 6) + 2)),
                        Endian.SwapInt16(BitConverter.ToInt16(vertsegdata, (int)(VertexArrayOffset & 0xFFFFFF) + (i * 6) + 4))));
                }
            }

            /* Read polygons */
            Polygons = new List<Polygon>();
            for (int i = 0; i < PolygonCount; i++)
            {
                Polygons.Add(new Polygon(ROM, (uint)(PolygonArrayOffset + (i * 0x10)), i, this));
            }

            /* Read polygon types */
            PolygonTypes = new List<PolygonType>();
            int ptlen = (int)(PolygonArrayOffset - PolygonTypeOffset);                      /* Official maps */
            if (ptlen <= 0) ptlen = (int)(WaterboxOffset - PolygonTypeOffset);              /* SO imports */
            if (ptlen <= 0) ptlen = (int)(this.GetAddressGeneric() - PolygonTypeOffset);    /* HT imports */

            if (ptlen > 0)
            {
                for (uint i = PolygonTypeOffset, j = 0; i < (uint)(PolygonTypeOffset + (ptlen & 0xFFFFFF)); i += 8, j++)
                {
                    PolygonTypes.Add(new PolygonType(ROM, i, (int)j));
                }
            }

            /* Read camera data */
            //

            /* Read waterboxes */
            Waterboxes = new List<Waterbox>();
            for (int i = 0; i < WaterboxCount; i++)
            {
                Waterboxes.Add(new Waterbox(ROM, (uint)(WaterboxOffset + (i * 0x10)), i, this));
            }
        }
Ejemplo n.º 9
0
 public SpecialObjects(Generic basecmd)
     : base(basecmd)
 {
     SelectedSpecialObjects = (ushort)(GetAddressGeneric() & 0xFFFF);
 }
Ejemplo n.º 10
0
        public MeshHeader(Generic basecmd)
            : base(basecmd)
        {
            byte seg = (byte)(GetAddressGeneric() >> 24);
            uint adr = (uint)(GetAddressGeneric() & 0xFFFFFF);

            Type = ((byte[])ROM.SegmentMapping[seg])[adr];
            Count = ((byte[])ROM.SegmentMapping[seg])[adr + 1];
            DLTablePointer = Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[seg]), (int)(adr + 4)));
            OtherDataPointer = Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[seg]), (int)(adr + 8)));

            DLAddresses = new List<uint>();

            MaxClipBounds = new List<Vector3d>();
            MinClipBounds = new List<Vector3d>();

            List<uint> opaqueDLs = new List<uint>();
            List<uint> transparentDLs = new List<uint>();

            switch (Type)
            {
                case 0x00:
                    {
                        for (int i = 0; i < Count; i++)
                        {
                            opaqueDLs.Add(Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 8)))));
                            transparentDLs.Add(Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 8) + 4))));
                        }
                        break;
                    }
                case 0x01:
                    {
                        for (int i = 0; i < Count; i++)
                            opaqueDLs.Add(Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 4)))));
                        break;
                    }
                case 0x02:
                    {
                        for (int i = 0; i < Count; i++)
                        {
                            short s1 = Endian.SwapInt16(BitConverter.ToInt16(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 16))));
                            short s2 = Endian.SwapInt16(BitConverter.ToInt16(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 16) + 2)));
                            short s3 = Endian.SwapInt16(BitConverter.ToInt16(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 16) + 4)));
                            short s4 = Endian.SwapInt16(BitConverter.ToInt16(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 16) + 6)));

                            MaxClipBounds.Add(new Vector3d(s1, 0.0, s2));
                            MinClipBounds.Add(new Vector3d(s3, 0.0, s4));

                            opaqueDLs.Add(Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 16) + 8))));
                            transparentDLs.Add(Endian.SwapUInt32(BitConverter.ToUInt32(((byte[])ROM.SegmentMapping[(byte)(DLTablePointer >> 24)]), (int)((DLTablePointer & 0xFFFFFF) + (i * 16) + 12))));
                        }
                        break;
                    }

                default: throw new Exception(string.Format("Invalid mesh type 0x{0:X2}", Type));
            }

            DLAddresses.AddRange(opaqueDLs);
            DLAddresses.AddRange(transparentDLs);
            DLAddresses.RemoveAll(x => x == 0);
        }
Ejemplo n.º 11
0
 public Objects(Generic basecmd)
     : base(basecmd)
 {
     ObjectList = new List<Entry>();
     for (int i = 0; i < GetCountGeneric(); i++) ObjectList.Add(new Entry(ROM, (uint)(GetAddressGeneric() + i * 2)));
 }
Ejemplo n.º 12
0
        public Collision(Generic basecmd)
            : base(basecmd)
        {
            uint adr = (uint)(GetAddressGeneric() & 0xFFFFFF);

            byte[] segdata = (byte[])ROM.SegmentMapping[(byte)(GetAddressGeneric() >> 24)];
            if (segdata == null)
            {
                return;
            }

            /* Read header */
            AbsoluteMinimum = new Vector3d(
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x2)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x4)));
            AbsoluteMaximum = new Vector3d(
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x6)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0x8)),
                Endian.SwapInt16(BitConverter.ToInt16(segdata, (int)adr + 0xA)));

            VertexCount        = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)adr + 0xC));
            VertexArrayOffset  = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x10));
            PolygonCount       = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)adr + 0x14));
            PolygonArrayOffset = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x18));
            PolygonTypeOffset  = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x1C));
            CameraDataOffset   = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x20));
            WaterboxCount      = Endian.SwapUInt16(BitConverter.ToUInt16(segdata, (int)adr + 0x24));
            WaterboxOffset     = Endian.SwapUInt32(BitConverter.ToUInt32(segdata, (int)adr + 0x28));

            /* Read vertices */
            byte[] vertsegdata = (byte[])ROM.SegmentMapping[(byte)(VertexArrayOffset >> 24)];
            if (vertsegdata != null)
            {
                Vertices = new List <Vector3d>();
                for (int i = 0; i < VertexCount; i++)
                {
                    Vertices.Add(new Vector3d(
                                     Endian.SwapInt16(BitConverter.ToInt16(vertsegdata, (int)(VertexArrayOffset & 0xFFFFFF) + (i * 6))),
                                     Endian.SwapInt16(BitConverter.ToInt16(vertsegdata, (int)(VertexArrayOffset & 0xFFFFFF) + (i * 6) + 2)),
                                     Endian.SwapInt16(BitConverter.ToInt16(vertsegdata, (int)(VertexArrayOffset & 0xFFFFFF) + (i * 6) + 4))));
                }
            }

            /* Read polygons */
            Polygons = new List <Polygon>();
            for (int i = 0; i < PolygonCount; i++)
            {
                Polygons.Add(new Polygon(ROM, (uint)(PolygonArrayOffset + (i * 0x10)), i, this));
            }

            /* Read polygon types */
            PolygonTypes = new List <PolygonType>();
            int ptlen = (int)(PolygonArrayOffset - PolygonTypeOffset);                      /* Official maps */

            if (ptlen <= 0)
            {
                ptlen = (int)(WaterboxOffset - PolygonTypeOffset);                          /* SO imports */
            }
            if (ptlen <= 0)
            {
                ptlen = (int)(this.GetAddressGeneric() - PolygonTypeOffset);                /* HT imports */
            }
            if (ptlen > 0)
            {
                for (uint i = PolygonTypeOffset, j = 0; i < (uint)(PolygonTypeOffset + (ptlen & 0xFFFFFF)); i += 8, j++)
                {
                    PolygonTypes.Add(new PolygonType(ROM, i, (int)j));
                }
            }

            /* Read camera data */
            //

            /* Read waterboxes */
            Waterboxes = new List <Waterbox>();
            for (int i = 0; i < WaterboxCount; i++)
            {
                Waterboxes.Add(new Waterbox(ROM, (uint)(WaterboxOffset + (i * 0x10)), i, this));
            }
        }