public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var export = serializer.Deserialize <CmdExport>(reader);
            GeolayoutCommand c;

            if (existingValue is object)
            {
                c = (GeolayoutCommand)existingValue;
            }
            else
            {
                c = new GeolayoutCommand();
            }

            if (export?.Buffer is object)
            {
                c.Position = 0;
                c.Write(export.Buffer, 0, export.Buffer.Length);
                c.Position = 0;
            }

            c.BankAddress = export.BankAddress;

            return(c);
        }
            public static int GetBackgroundPointer(GeolayoutCommand command)
            {
                command.Position = 0x4;
                int value = command.ReadInt32();

                command.Position = 0;
                return(value);
            }
            public static int GetAsmPointer(ref GeolayoutCommand command)
            {
                command.Position = 0x4;
                int value = command.ReadInt32();

                command.Position = 0;
                return(value);
            }
            public static uint GetSegGeopointer(ref GeolayoutCommand command)
            {
                command.Position = 0x8;
                uint value = command.ReadUInt32();

                command.Position = 0;
                return(value);
            }
 public static void SetOffset(ref GeolayoutCommand Command, Vector3 value)
 {
     Command.Position = 2;
     Command.Write(Conversions.ToShort(value.X));
     Command.Write(Conversions.ToShort(value.Y));
     Command.Write(Conversions.ToShort(value.Z));
     Command.Position = 0;
 }
            public static byte GetCameraPreset(ref GeolayoutCommand command)
            {
                command.Position = 0x3;
                byte value = command.ReadByte();

                command.Position = 0;
                return(value);
            }
            public static ushort GetParam1(ref GeolayoutCommand command)
            {
                command.Position = 0x2;
                ushort value = command.ReadUInt16();

                command.Position = 0;
                return(value);
            }
            public static byte GetDrawingLayer(ref GeolayoutCommand command)
            {
                command.Position = 0x1;
                byte value = command.ReadByte();

                command.Position = 0;
                return(value);
            }
            public static short GetBackgroundID(GeolayoutCommand command)
            {
                command.Position = 0x2;
                short value = command.ReadInt16();

                command.Position = 0;
                return(value);
            }
            public static System.Drawing.Color GetRrgbaColor(GeolayoutCommand command)
            {
                command.Position = 0x2;
                byte b1 = command.ReadByte();
                byte b2 = command.ReadByte();

                command.Position = 0;
                return(N64Graphics.N64Graphics.RGBA16Color(b1, b2));
            }
            public static void SetRgbaColor(GeolayoutCommand command, System.Drawing.Color color)
            {
                byte b1, b2;

                N64Graphics.N64Graphics.ColorRGBA16(color, out b1, out b2);
                command.Position = 0x2;
                command.WriteByte(b1);
                command.WriteByte(b2);
                command.Position = 0;
            }
            public static Vector3 GetOffset(ref GeolayoutCommand command)
            {
                command.Position = 2;
                var value = new Vector3();

                value.X          = command.ReadInt16();
                value.Y          = command.ReadInt16();
                value.Z          = command.ReadInt16();
                command.Position = 0;
                return(value);
            }
Example #13
0
        public void Write(Stream s, int StartOffset)
        {
            NewGeoOffset = StartOffset;
            var commandsToRemove    = new List <GeolayoutCommand>();
            int tIndexForGeoPointer = IndexForGeopointers;

            // Einstellungen übernehmen
            int currentPosition = 0;

            foreach (GeolayoutCommand fec in Geolayoutscript)
            {
                var c          = fec;
                var switchExpr = c.CommandType;

                switch (switchExpr)
                {
                case GeolayoutCommandTypes.CameraPreset:
                    cgCameraPreset.SetCameraPreset(ref c, Conversions.ToByte(CameraPreset));
                    break;

                case GeolayoutCommandTypes.x18:
                    var switchExpr1 = cgx18.GetAsmPointer(ref c);
                    switch ((GeoAsmPointer)switchExpr1)
                    {
                    case GeoAsmPointer.EnvironmentEffect:
                    {
                        cgx18.SetParam1(ref c, (ushort)EnvironmentEffect);
                        break;
                    }
                    }

                    break;
                }

                currentPosition += (int)c.Length;
                // If Not IndexForGeopointersFound Then IndexForGeopointers += 1
            }

            // Insert Geopointers
            foreach (Geopointer g in Geopointers)
            {
                var tcommand = new GeolayoutCommand(new byte[] { 0x15, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 });
                cgLoadDisplayList.SetDrawingLayer(ref tcommand, g.Layer);
                cgLoadDisplayList.SetSegGeopointer(ref tcommand, g.SegPointer);
                Geolayoutscript.Insert(tIndexForGeoPointer, tcommand);
                tIndexForGeoPointer += 1;
            }

            // Write Geolayout to ROM
            Geolayoutscript.Write(s, StartOffset);

            // Remove Geopointercommands again
            RemoveOldGeopointerCommands();
        }
 public static void SetSegGeopointer(ref GeolayoutCommand command, uint SegPointer)
 {
     command.Position = 0x8;
     command.Write(SegPointer);
     command.Position = 0;
 }
 public static void SetAsmPointer(ref GeolayoutCommand command, int AsmPointer)
 {
     command.Position = 0x4;
     command.Write(AsmPointer);
     command.Position = 0;
 }
 public static void SetParam1(ref GeolayoutCommand command, ushort ID)
 {
     command.Position = 0x2;
     command.Write(ID);
     command.Position = 0;
 }
 public static void SetDrawingLayer(ref GeolayoutCommand command, byte Layer)
 {
     command.Position = 0x1;
     command.Write(Layer);
     command.Position = 0;
 }
 public static void SetCameraPreset(ref GeolayoutCommand command, byte Preset)
 {
     command.Position = 0x3;
     command.Write(Preset);
     command.Position = 0;
 }
 public static void SetBackgroundID(GeolayoutCommand command, short ID)
 {
     command.Position = 0x2;
     command.Write(ID);
     command.Position = 0;
 }
 public static void SetOffset(ref GeolayoutCommand Command, int X, int Y, int Z)
 {
     SetOffset(ref Command, new Vector3(X, Y, Z));
 }
 public static void SetBackgroundPointer(GeolayoutCommand command, int Pointer)
 {
     command.Position = 0x4;
     command.Write(Pointer);
     command.Position = 0;
 }