Example #1
0
        private void ReadParameters(byte[] file, int address, int count)
        {
            for (int i = 0; i < count; i++)
            {
                switch ((ParameterType)ByteConverter.ToInt32(file, address))
                {
                case ParameterType.VtxAttrFmt:
                    VtxAttrFmtParameter vtx_param = new VtxAttrFmtParameter();
                    vtx_param.Read(file, address + 4);
                    Parameters.Add(vtx_param);
                    break;

                case ParameterType.IndexAttributeFlags:
                    IndexAttributeParameter index_param = new IndexAttributeParameter();
                    index_param.Read(file, address + 4);
                    Parameters.Add(index_param);
                    break;

                case ParameterType.Lighting:
                    LightingParameter light_param = new LightingParameter();
                    light_param.Read(file, address + 4);
                    Parameters.Add(light_param);
                    break;

                case ParameterType.BlendAlpha:
                    BlendAlphaParameter blend_param = new BlendAlphaParameter();
                    blend_param.Read(file, address + 4);
                    Parameters.Add(blend_param);
                    break;

                case ParameterType.AmbientColor:
                    AmbientColorParameter ambient_param = new AmbientColorParameter();
                    ambient_param.Read(file, address + 4);
                    Parameters.Add(ambient_param);
                    break;

                case ParameterType.Texture:
                    TextureParameter texture_param = new TextureParameter();
                    texture_param.Read(file, address + 4);
                    Parameters.Add(texture_param);
                    break;

                case ParameterType.Unknown_9:
                    Unknown9Parameter unk9_param = new Unknown9Parameter();
                    unk9_param.Read(file, address + 4);
                    Parameters.Add(unk9_param);
                    break;

                case ParameterType.TexCoordGen:
                    TexCoordGenParameter mip_param = new TexCoordGenParameter();
                    mip_param.Read(file, address + 4);
                    Parameters.Add(mip_param);
                    break;
                }

                address += 8;
            }
        }
Example #2
0
        /// <summary>
        /// Create a parameter object from a file and address
        /// </summary>
        /// <param name="file">The file contents</param>
        /// <param name="address">The address at which the parameter is located</param>
        /// <returns>Any of the parameter types</returns>
        public static GCParameter Read(byte[] file, int address)
        {
            GCParameter   result    = null;
            ParameterType paramType = (ParameterType)BitConverter.ToUInt32(file, address);

            switch (paramType)
            {
            case ParameterType.VtxAttrFmt:
                result = new VtxAttrFmtParameter(GCVertexAttribute.Null);
                break;

            case ParameterType.IndexAttributeFlags:
                result = new IndexAttributeParameter();
                break;

            case ParameterType.Lighting:
                result = new LightingParameter();
                break;

            case ParameterType.BlendAlpha:
                result = new BlendAlphaParameter();
                break;

            case ParameterType.AmbientColor:
                result = new AmbientColorParameter();
                break;

            case ParameterType.Texture:
                result = new TextureParameter();
                break;

            case ParameterType.Unknown_9:
                result = new Unknown9Parameter();
                break;

            case ParameterType.TexCoordGen:
                result = new TexCoordGenParameter();
                break;
            }

            result.data = ByteConverter.ToUInt32(file, address + 4);

            return(result);
        }