diff options
author | unknown <devnull@localhost> | 2011-03-11 17:29:14 +0000 |
---|---|---|
committer | unknown <devnull@localhost> | 2011-03-11 17:29:14 +0000 |
commit | 4948fe1e70c4aede178aad052321ba812379d61a (patch) | |
tree | 215327e20df5269e9ac1de56686c65b39aa614d1 | |
parent | 88db955bcf9e971471db769e8251e87e09724066 (diff) |
MainMemory - S2LVL: S1 common object definitions done. Added S1ObjectDefinition.zip template for Visual Studio.
-rw-r--r-- | S1LVL INI Files/Common/EggPrison.cs | 100 | ||||
-rw-r--r-- | S1LVL INI Files/Common/PointBonus.cs | 107 | ||||
-rw-r--r-- | S1LVL INI Files/Common/Spring.cs | 172 | ||||
-rw-r--r-- | S1LVL INI Files/obj.ini | 75 |
4 files changed, 385 insertions, 69 deletions
diff --git a/S1LVL INI Files/Common/EggPrison.cs b/S1LVL INI Files/Common/EggPrison.cs new file mode 100644 index 0000000..7510b4f --- /dev/null +++ b/S1LVL INI Files/Common/EggPrison.cs @@ -0,0 +1,100 @@ +using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Drawing;
+using Extensions;
+using S2LVL;
+
+namespace S1ObjectDefinitions.Common
+{
+ class EggPrison : S2LVL.ObjectDefinition
+ {
+ private string[] labels = { "@capsule", "@switch1" };
+ private Point offset;
+ private Bitmap img;
+ private int imgw, imgh;
+ private List<Point> offsets = new List<Point>();
+ private List<Bitmap> imgs = new List<Bitmap>();
+ private List<int> imgws = new List<int>();
+ private List<int> imghs = new List<int>();
+
+ public override void Init(Dictionary<string, string> data)
+ {
+ byte[] artfile = ObjectHelper.OpenArtFile("../artnem/Prison Capsule.bin", Compression.CompressionType.Nemesis);
+ img = ObjectHelper.MapASMToBmp(artfile, "../_maps/Prison Capsule.asm", "@capsule", 0, out offset);
+ imgw = img.Width;
+ imgh = img.Height;
+ Point off;
+ Bitmap im;
+ for (int i = 0; i < labels.Length; i++)
+ {
+ im = ObjectHelper.MapASMToBmp(artfile, "../_maps/Prison Capsule.asm", labels[i], 0, out off);
+ imgs.Add(im);
+ offsets.Add(off);
+ imgws.Add(im.Width);
+ imghs.Add(im.Height);
+ }
+ }
+
+ public override ReadOnlyCollection<byte> Subtypes()
+ {
+ return new ReadOnlyCollection<byte>(new byte[] { 0, 1 });
+ }
+
+ public override string Name()
+ {
+ return "Egg Prison";
+ }
+
+ public override bool RememberState()
+ {
+ return false;
+ }
+
+ public override string SubtypeName(byte subtype)
+ {
+ switch (subtype)
+ {
+ case 0:
+ return "Capsule";
+ case 1:
+ return "Button";
+ default:
+ return string.Empty;
+ }
+ }
+
+ public override string FullName(byte subtype)
+ {
+ return Name() + " - " + SubtypeName(subtype);
+ }
+
+ public override Bitmap Image()
+ {
+ return img;
+ }
+
+ public override Bitmap Image(byte subtype)
+ {
+ if (subtype < labels.Length)
+ return imgs[subtype];
+ else
+ return img;
+ }
+
+ public override void Draw(Graphics gfx, Point loc, byte subtype, bool XFlip, bool YFlip)
+ {
+ if (subtype < labels.Length)
+ gfx.DrawImageFlipped(imgs[subtype], loc.X + offsets[subtype].X, loc.Y + offsets[subtype].Y, XFlip, YFlip);
+ else
+ gfx.DrawImageFlipped(img, loc.X + offset.X, loc.Y + offset.Y, XFlip, YFlip);
+ }
+
+ public override Rectangle Bounds(Point loc, byte subtype)
+ {
+ if (subtype < labels.Length)
+ return new Rectangle(loc.X + offsets[subtype].X, loc.Y + offsets[subtype].Y, imgws[subtype], imghs[subtype]);
+ else
+ return new Rectangle(loc.X + offset.X, loc.Y + offset.Y, imgw, imgh);
+ }
+ }
+}
\ No newline at end of file diff --git a/S1LVL INI Files/Common/PointBonus.cs b/S1LVL INI Files/Common/PointBonus.cs new file mode 100644 index 0000000..1b5d42c --- /dev/null +++ b/S1LVL INI Files/Common/PointBonus.cs @@ -0,0 +1,107 @@ +using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Drawing;
+using Extensions;
+using S2LVL;
+
+namespace S1ObjectDefinitions.Common
+{
+ class PointBonus : S2LVL.ObjectDefinition
+ {
+ private string[] labels = { "@10000", "@1000", "@100" };
+ private Point offset;
+ private Bitmap img;
+ private int imgw, imgh;
+ private List<Point> offsets = new List<Point>();
+ private List<Bitmap> imgs = new List<Bitmap>();
+ private List<int> imgws = new List<int>();
+ private List<int> imghs = new List<int>();
+
+ public override void Init(Dictionary<string, string> data)
+ {
+ byte[] artfile = ObjectHelper.OpenArtFile("../artnem/Hidden Bonuses.bin", Compression.CompressionType.Nemesis);
+ img = ObjectHelper.MapASMToBmp(artfile, "../_maps/Hidden Bonuses.asm", "@100", 0, out offset);
+ imgw = img.Width;
+ imgh = img.Height;
+ Point off;
+ Bitmap im;
+ im = ObjectHelper.UnknownObject(out off);
+ imgs.Add(im);
+ offsets.Add(off);
+ imgws.Add(im.Width);
+ imghs.Add(im.Height);
+ for (int i = 0; i < labels.Length; i++)
+ {
+ im = ObjectHelper.MapASMToBmp(artfile, "../_maps/Hidden Bonuses.asm", labels[i], 0, out off);
+ imgs.Add(im);
+ offsets.Add(off);
+ imgws.Add(im.Width);
+ imghs.Add(im.Height);
+ }
+ }
+
+ public override ReadOnlyCollection<byte> Subtypes()
+ {
+ return new ReadOnlyCollection<byte>(new byte[] { 1, 2, 3 });
+ }
+
+ public override string Name()
+ {
+ return "Hidden point bonus";
+ }
+
+ public override bool RememberState()
+ {
+ return false;
+ }
+
+ public override string SubtypeName(byte subtype)
+ {
+ switch (subtype)
+ {
+ case 1:
+ return 10000.ToString("N0") + " points";
+ case 2:
+ return 1000.ToString("N0") + " points";
+ case 3:
+ return 100.ToString("N0") + " points";
+ default:
+ return string.Empty;
+ }
+ }
+
+ public override string FullName(byte subtype)
+ {
+ return Name() + " - " + SubtypeName(subtype);
+ }
+
+ public override Bitmap Image()
+ {
+ return img;
+ }
+
+ public override Bitmap Image(byte subtype)
+ {
+ if (subtype < labels.Length + 1)
+ return imgs[subtype];
+ else
+ return img;
+ }
+
+ public override void Draw(Graphics gfx, Point loc, byte subtype, bool XFlip, bool YFlip)
+ {
+ if (subtype < labels.Length + 1)
+ gfx.DrawImageFlipped(imgs[subtype], loc.X + offsets[subtype].X, loc.Y + offsets[subtype].Y, XFlip, YFlip);
+ else
+ gfx.DrawImageFlipped(img, loc.X + offset.X, loc.Y + offset.Y, XFlip, YFlip);
+ }
+
+ public override Rectangle Bounds(Point loc, byte subtype)
+ {
+ if (subtype < labels.Length + 1)
+ return new Rectangle(loc.X + offsets[subtype].X, loc.Y + offsets[subtype].Y, imgws[subtype], imghs[subtype]);
+ else
+ return new Rectangle(loc.X + offset.X, loc.Y + offset.Y, imgw, imgh);
+ }
+ }
+}
\ No newline at end of file diff --git a/S1LVL INI Files/Common/Spring.cs b/S1LVL INI Files/Common/Spring.cs new file mode 100644 index 0000000..2df7b23 --- /dev/null +++ b/S1LVL INI Files/Common/Spring.cs @@ -0,0 +1,172 @@ +using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Drawing;
+using Extensions;
+using S2LVL;
+
+namespace S1ObjectDefinitions.Common
+{
+ class Spring : ObjectDefinition
+ {
+ private Point offset;
+ private Bitmap img;
+ private int imgw, imgh;
+ private List<Point> offsets = new List<Point>();
+ private List<Bitmap> imgs = new List<Bitmap>();
+ private List<int> imgws = new List<int>();
+ private List<int> imghs = new List<int>();
+
+ public override void Init(Dictionary<string, string> data)
+ {
+ byte[] artfile1 = ObjectHelper.OpenArtFile("../artnem/Spring Horizontal.bin", Compression.CompressionType.Nemesis);
+ byte[] artfile2 = ObjectHelper.OpenArtFile("../artnem/Spring Vertical.bin", Compression.CompressionType.Nemesis);
+ string map = "../_maps/Springs.asm";
+ img = ObjectHelper.MapASMToBmp(artfile1, map, "M_Spg_Up", 0, out offset);
+ imgw = img.Width;
+ imgh = img.Height;
+ Point off = new Point();
+ Bitmap im;
+ imgs.Add(img); // 0x00
+ offsets.Add(offset);
+ imgws.Add(imgw);
+ imghs.Add(imgh);
+ im = ObjectHelper.MapASMToBmp(artfile1, map, "M_Spg_Up", 1, out off); // 0x02
+ imgs.Add(im);
+ offsets.Add(off);
+ imgws.Add(im.Width);
+ imghs.Add(im.Height);
+ im = ObjectHelper.MapASMToBmp(artfile2, map, "M_Spg_Left", 0, out off); // 0x10
+ imgs.Add(im);
+ offsets.Add(off);
+ imgws.Add(im.Width);
+ imghs.Add(im.Height);
+ im = ObjectHelper.MapASMToBmp(artfile2, map, "M_Spg_Left", 1, out off); // 0x12
+ imgs.Add(im);
+ offsets.Add(off);
+ imgws.Add(im.Width);
+ imghs.Add(im.Height);
+ imgs.Add(imgs[0]); // 0x20
+ offsets.Add(offsets[0]);
+ imgws.Add(imgws[0]);
+ imghs.Add(imghs[0]);
+ imgs.Add(imgs[1]); // 0x22
+ offsets.Add(offsets[1]);
+ imgws.Add(imgws[1]);
+ imghs.Add(imghs[1]);
+ imgs.Add(imgs[2]); // 0x30
+ offsets.Add(offsets[2]);
+ imgws.Add(imgws[2]);
+ imghs.Add(imghs[2]);
+ imgs.Add(imgs[3]); // 0x32
+ offsets.Add(offsets[3]);
+ imgws.Add(imgws[3]);
+ imghs.Add(imghs[3]);
+ }
+
+ public override ReadOnlyCollection<byte> Subtypes()
+ {
+ return new ReadOnlyCollection<byte>(new byte[] { 0x00, 0x02, 0x10, 0x12, 0x20, 0x22, 0x30, 0x32 });
+ }
+
+ public override string Name()
+ {
+ return "Spring";
+ }
+
+ public override bool RememberState()
+ {
+ return false;
+ }
+
+ public override string SubtypeName(byte subtype)
+ {
+ string result = ((SpringColor)((subtype & 2) >> 1)).ToString();
+ return result;
+ }
+
+ public override string FullName(byte subtype)
+ {
+ return SubtypeName(subtype) + " " + Name();
+ }
+
+ public override Bitmap Image()
+ {
+ return img;
+ }
+
+ private int imgindex(byte subtype)
+ {
+ int result = (subtype & 2) >> 1;
+ result |= (subtype & 0x30) >> 3;
+ return result;
+ }
+
+ public override Bitmap Image(byte subtype)
+ {
+ return imgs[imgindex(subtype)];
+ }
+
+ public override void Draw(Graphics gfx, Point loc, byte subtype, bool XFlip, bool YFlip)
+ {
+ gfx.DrawImageFlipped(imgs[imgindex(subtype)], loc.X + offsets[imgindex(subtype)].X, loc.Y + offsets[imgindex(subtype)].Y, XFlip, YFlip);
+ }
+
+ public override Rectangle Bounds(Point loc, byte subtype)
+ {
+ return new Rectangle(loc.X + offsets[imgindex(subtype)].X, loc.Y + offsets[imgindex(subtype)].Y, imgws[imgindex(subtype)], imghs[imgindex(subtype)]);
+ }
+
+ public override Type ObjectType
+ {
+ get
+ {
+ return typeof(SpringS1ObjectEntry);
+ }
+ }
+ }
+
+ public class SpringS1ObjectEntry : S1ObjectEntry
+ {
+ public SpringS1ObjectEntry() : base() { }
+ public SpringS1ObjectEntry(byte[] file, int address) : base(file, address) { }
+
+ public SpringDirection Direction
+ {
+ get
+ {
+ return (SpringDirection)((SubType & 0x30) >> 4);
+ }
+ set
+ {
+ SubType = (byte)((SubType & ~0x30) | ((int)value << 4));
+ }
+ }
+
+ public SpringColor Color
+ {
+ get
+ {
+ return (SpringColor)((SubType & 2) >> 1);
+ }
+ set
+ {
+ SubType = (byte)((SubType & ~2) | ((int)value << 1));
+ }
+ }
+ }
+
+ public enum SpringDirection
+ {
+ Up,
+ Horizontal,
+ Down,
+ Horizontal2
+ }
+
+ public enum SpringColor
+ {
+ Red,
+ Yellow
+ }
+}
\ No newline at end of file diff --git a/S1LVL INI Files/obj.ini b/S1LVL INI Files/obj.ini index 53f3036..6ed6d7f 100644 --- a/S1LVL INI Files/obj.ini +++ b/S1LVL INI Files/obj.ini @@ -25,53 +25,11 @@ pal=0 codefile=Common/Spikes.cs
codetype=S1ObjectDefinitions.Common.Spikes
[3E]
-name=Egg prison
-art=../artnem/Prison Capsule.bin
-mapasm=../_maps/Prison Capsule.asm
-mapasmlbl=@capsule
-pal=0
-[3E:00]
-name=
-art=../artnem/Prison Capsule.bin
-mapasm=../_maps/Prison Capsule.asm
-mapasmlbl=@capsule
-pal=0
-[3E:01]
-name=Button
-art=../artnem/Prison Capsule.bin
-mapasm=../_maps/Prison Capsule.asm
-mapasmlbl=@switch1
-pal=0
+codefile=Common/EggPrison.cs
+codetype=S1ObjectDefinitions.Common.EggPrison
[41]
-name=Spring
-art=../artnem/Spring Horizontal.bin
-mapasm=../_maps/Springs.asm
-mapasmlbl=M_Spg_Up
-pal=0
-[41:00]
-name=Red, vertical
-art=../artnem/Spring Horizontal.bin
-mapasm=../_maps/Springs.asm
-mapasmlbl=M_Spg_Up
-pal=0
-[41:02]
-name=Yellow, vertical
-art=../artnem/Spring Horizontal.bin
-mapasm=../_maps/Springs.asm
-mapasmlbl=M_Spg_Up
-pal=1
-[41:10]
-name=Red, horizontal
-art=../artnem/Spring Vertical.bin
-mapasm=../_maps/Springs.asm
-mapasmlbl=M_Spg_Left
-pal=0
-[41:12]
-name=Yellow, horizontal
-art=../artnem/Spring Vertical.bin
-mapasm=../_maps/Springs.asm
-mapasmlbl=M_Spg_Left
-pal=1
+codefile=Common/Spring.cs
+codetype=S1ObjectDefinitions.Common.Spring
[4B]
name=Giant ring
art=../artunc/Giant Ring.bin
@@ -92,26 +50,5 @@ mapasm=../_maps/Lamppost.asm mapasmlbl=@blue
pal=0
[7D]
-name=Hidden point bonus
-art=../artnem/Hidden Bonuses.bin
-mapasm=../_maps/Hidden Bonuses.asm
-mapasmlbl=@100
-pal=0
-[7D:01]
-name=10,000
-art=../artnem/Hidden Bonuses.bin
-mapasm=../_maps/Hidden Bonuses.asm
-mapasmlbl=@10000
-pal=0
-[7D:02]
-name=1,000
-art=../artnem/Hidden Bonuses.bin
-mapasm=../_maps/Hidden Bonuses.asm
-mapasmlbl=@1000
-pal=0
-[7D:03]
-name=100
-art=../artnem/Hidden Bonuses.bin
-mapasm=../_maps/Hidden Bonuses.asm
-mapasmlbl=@100
-pal=0
\ No newline at end of file +codefile=Common/PointBonus.cs
+codetype=S1ObjectDefinitions.Common.PointBonus
\ No newline at end of file |