Exemplo n.º 1
0
 // main
 public TilesetEditor(Tileset tileset, Delegate update, PaletteSet paletteSet, Overlay overlay)
 {
     this.tileset    = tileset;
     this.paletteSet = paletteSet;
     this.overlay    = overlay;
     this.update     = update;
     //
     InitializeComponent();
     this.pictureBoxTilesetL1.Height = height;
     this.pictureBoxTilesetL2.Height = height;
     this.pictureBoxTilesetL3.Height = height;
     if (this.tileset.Tilesets_tiles[Layer] == null)
     {
         if (this.tileset.Tilesets_tiles[0] != null)
         {
             this.Layer = 0;
         }
         else if (this.tileset.Tilesets_tiles[1] != null)
         {
             this.Layer = 1;
         }
         else if (this.tileset.Tilesets_tiles[2] != null)
         {
             this.Layer = 2;
         }
         else
         {
             this.Layer = 0;
         }
     }
     LoadTileEditor();
     SetTileSetImage();
 }
Exemplo n.º 2
0
 public void Reload(Tileset tileset, Delegate update, PaletteSet paletteSet, Overlay overlay)
 {
     mouseDownTile = 0;
     this.pictureBoxTilesetL1.Height = height;
     this.pictureBoxTilesetL2.Height = height;
     this.pictureBoxTilesetL3.Height = height;
     //
     this.tileset    = tileset;
     this.paletteSet = paletteSet;
     this.overlay    = overlay;
     this.update     = update;
     if (this.tileset.Tilesets_tiles[Layer] == null)
     {
         if (this.tileset.Tilesets_tiles[0] != null)
         {
             this.Layer = 0;
         }
         else if (this.tileset.Tilesets_tiles[1] != null)
         {
             this.Layer = 1;
         }
         else if (this.tileset.Tilesets_tiles[2] != null)
         {
             this.Layer = 2;
         }
         else
         {
             this.Layer = 0;
         }
     }
     LoadTileEditor();
     SetTileSetImage();
 }
Exemplo n.º 3
0
 // main title tileset
 public Tileset(PaletteSet paletteSet, string type)
 {
     this.paletteSet = paletteSet;
     this.Width      = 16;
     this.Height     = 32;
     this.HeightL3   = 6;
     this.tilesize   = 2;
     this.Type       = TilesetType.Title;
     // Decompress data at offsets
     tilesets_bytes[0] = Bits.GetBytes(Model.TitleData, 0x0000, 0x1000);
     tilesets_bytes[1] = Bits.GetBytes(Model.TitleData, 0x1000, 0x1000);
     tilesets_bytes[2] = Bits.GetBytes(Model.TitleData, 0xBBE0, 0x300);
     // Create buffer the size of the combined graphicSets
     graphics   = Bits.GetBytes(Model.TitleData, 0x6C00, 0x4FE0);
     graphicsL3 = Bits.GetBytes(Model.TitleData, 0xBEA0, 0x1BC0);
     //
     tilesets_tiles[0] = new Tile[16 * 32];
     tilesets_tiles[1] = new Tile[16 * 32];
     tilesets_tiles[2] = new Tile[16 * 6];
     for (int i = 0; i < tilesets_tiles[0].Length; i++)
     {
         tilesets_tiles[0][i] = new Tile(i);
     }
     for (int i = 0; i < tilesets_tiles[1].Length; i++)
     {
         tilesets_tiles[1][i] = new Tile(i);
     }
     for (int i = 0; i < tilesets_tiles[2].Length; i++)
     {
         tilesets_tiles[2][i] = new Tile(i);
     }
     DrawTileset(tilesets_bytes[0], tilesets_tiles[0], graphics, 0x20);
     DrawTileset(tilesets_bytes[1], tilesets_tiles[1], graphics, 0x20);
     DrawTileset(tilesets_bytes[2], tilesets_tiles[2], graphicsL3, 0x20);
 }
 public BattlefieldTileset(Battlefield battlefield, PaletteSet palettes, Tile[] tileset_tiles)
 {
     this.battlefield   = battlefield;
     this.palettes      = palettes;
     this.tileset_bytes = new byte[0x2000];
     this.tileset_tiles = tileset_tiles;
     graphics           = new byte[0x6000];
     if (battlefield.GraphicSetA < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetA + 0x48], 0, graphics, 0, 0x2000);
     }
     if (battlefield.GraphicSetB < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetB + 0x48], 0, graphics, 0x2000, 0x1000);
     }
     if (battlefield.GraphicSetC < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetC + 0x48], 0, graphics, 0x3000, 0x1000);
     }
     if (battlefield.GraphicSetD < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetD + 0x48], 0, graphics, 0x4000, 0x1000);
     }
     if (battlefield.GraphicSetE < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetE + 0x48], 0, graphics, 0x5000, 0x1000);
     }
     DrawTileset(tileset_tiles, tileset_bytes);
 }
Exemplo n.º 5
0
        // universal functions
        public override void Clear()
        {
            foreach (E_Sequence s in sequences)
            {
                s.Frames = new List <E_Sequence.Frame>();
            }
            int moldCount = molds.Count;

            for (int i = 1; i < moldCount; i++)
            {
                molds.RemoveAt(1);
            }
            tileset_bytes    = new byte[tileset_bytes.Length];
            paletteSetLength = 32;
            graphicSetLength = 32;
            tilesetLength    = 64;
            graphicSet       = new byte[graphicSet.Length];
            paletteSet       = new PaletteSet(new byte[256], 0, 0, 8, 16, 32);
            codec            = 0;
            width            = 1;
            height           = 1;
            foreach (Tile tile in tileset_tiles.Tileset)
            {
                for (int i = 0; i < 4; i++)
                {
                    tile.Subtiles[i] = new Subtile(0, new byte[0x20], 0, new int[16], false, false, false, codec == 1);
                }
            }
        }
 // constructors
 public BattlefieldTileset(Battlefield battlefield, PaletteSet palettes)
 {
     this.battlefield = battlefield;
     this.palettes    = palettes;
     // compile graphics
     graphics = new byte[0x6000];
     if (battlefield.GraphicSetA < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetA + 0x48], 0, graphics, 0, 0x2000);
     }
     if (battlefield.GraphicSetB < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetB + 0x48], 0, graphics, 0x2000, 0x1000);
     }
     if (battlefield.GraphicSetC < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetC + 0x48], 0, graphics, 0x3000, 0x1000);
     }
     if (battlefield.GraphicSetD < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetD + 0x48], 0, graphics, 0x4000, 0x1000);
     }
     if (battlefield.GraphicSetE < 0xC8)
     {
         Buffer.BlockCopy(Model.GraphicSets[battlefield.GraphicSetE + 0x48], 0, graphics, 0x5000, 0x1000);
     }
     // create tileset
     tileset_bytes = Model.TilesetsBF[battlefield.TileSet];
     tileset_tiles = new Tile[32 * 32];
     for (int i = 0; i < tileset_tiles.Length; i++)
     {
         tileset_tiles[i] = new Tile(i);
     }
     DrawTileset(tileset_bytes, tileset_tiles);
 }
Exemplo n.º 7
0
 // main
 public WorldMaps()
 {
     fontPalettes[0] = new PaletteSet(Model.ROM, 0, 0x3DFEE0, 2, 16, 32);
     fontPalettes[1] = new PaletteSet(Model.ROM, 0, 0x3E2D55, 2, 16, 32);
     fontPalettes[2] = new PaletteSet(Model.ROM, 0, 0x01EF40, 2, 16, 32);
     for (int i = 0; i < fontDialogue.Length; i++)
     {
         fontDialogue[i] = new FontCharacter(i, FontType.Dialogue);
     }
     InitializeComponent();
     this.worldMapName.Items.AddRange(Lists.Numerize(Lists.WorldMapNames));
     this.music.Items.AddRange(Lists.Numerize(Lists.MusicNames));
     this.music.SelectedIndex = Model.ROM[0x037DCF];
     Do.AddShortcut(toolStrip3, Keys.Control | Keys.S, new EventHandler(save_Click));
     Do.AddShortcut(toolStrip3, Keys.F1, helpTips);
     Do.AddShortcut(toolStrip3, Keys.F2, baseConvertor);
     toolTip1.InitialDelay = 0;
     labelWindow           = new EditLabel(worldMapName, null, "World Maps", true);
     InitializeLocationsEditor();
     worldMapName.SelectedIndex = 0;
     //LoadPaletteEditor();
     //LoadGraphicEditor();
     //LoadLogoPaletteEditor();
     //LoadLogoGraphicEditor();
     LoadTileEditor();
     new ToolTipLabel(this, baseConvertor, helpTips);
     this.History = new History(this, worldMapName, null);
 }
Exemplo n.º 8
0
 // constructor
 public Mode7Tilemap(byte[] tilemap, Tileset tileset, PaletteSet paletteSet)
 {
     this.tileset       = tileset;
     this.paletteSet    = paletteSet;
     this.tilemap_Bytes = tilemap;
     CreateLayer(); // Create any required layers
     DrawMainscreen();
 }
Exemplo n.º 9
0
        // assemblers
        private void Disassemble()
        {
            animationOffset = Bits.GetInt24(rom, 0x252C00 + (index * 3)) - 0xC00000;
            ushort animationLength = Bits.GetShort(rom, animationOffset);

            buffer = Bits.GetBytes(rom, animationOffset, Bits.GetShort(rom, animationOffset));
            //
            int    offset                = 2;
            ushort graphicSetPointer     = Bits.GetShort(buffer, offset); offset += 2;
            ushort paletteSetPointer     = Bits.GetShort(buffer, offset); offset += 2;
            ushort sequencePacketPointer = Bits.GetShort(buffer, offset); offset += 2;
            ushort moldPacketPointer     = Bits.GetShort(buffer, offset); offset += 2;

            // skip 2 unknown bytes
            offset += 2;
            //
            width  = buffer[offset++];
            height = buffer[offset++];
            codec  = Bits.GetShort(buffer, offset); offset += 2;
            //
            int tileSetPointer = Bits.GetShort(buffer, offset);

            graphicSetLength = paletteSetPointer - graphicSetPointer;
            graphicSet       = new byte[0x2000];
            Buffer.BlockCopy(buffer, graphicSetPointer, graphicSet, 0, graphicSetLength);
            paletteSetLength = (ushort)(tileSetPointer - paletteSetPointer);
            paletteSet       = new PaletteSet(buffer, 0, paletteSetPointer, 8, 16, 32);
            tilesetLength    = sequencePacketPointer - tileSetPointer - 2;
            tileset_bytes    = new byte[64 * 4 * 2 * 4];
            Buffer.BlockCopy(buffer, tileSetPointer, tileset_bytes, 0, tilesetLength);
            //
            offset = sequencePacketPointer;
            for (int i = 0; Bits.GetShort(buffer, offset) != 0x0000; i++)
            {
                E_Sequence tSequence = new E_Sequence();
                tSequence.Disassemble(buffer, offset);
                sequences.Add(tSequence);
                offset += 2;
            }
            offset = moldPacketPointer;
            ushort end = 0;

            for (int i = 0; Bits.GetShort(buffer, offset) != 0x0000; i++)
            {
                if (Bits.GetShort(buffer, offset + 2) == 0x0000)
                {
                    end = animationLength;
                }
                else
                {
                    end = Bits.GetShort(buffer, offset + 2);
                }
                E_Mold tMold = new E_Mold();
                tMold.Disassemble(buffer, offset, end);
                molds.Add(tMold);
                offset += 2;
            }
        }
Exemplo n.º 10
0
        // spawning
        public PaletteSet Copy()
        {
            PaletteSet copy = new PaletteSet(buffer, index, offset, count, size, length);

            copy.BUFFER = Bits.Copy(buffer);
            copy.Reds   = Bits.Copy(reds);
            copy.Greens = Bits.Copy(greens);
            copy.Blues  = Bits.Copy(blues);
            return(copy);
        }
Exemplo n.º 11
0
 public void RefreshLevel()
 {
     if (Index < 2)
     {
         paletteSet = Model.MinecartM7PaletteSet;
         tileset    = new Tileset(Model.MinecartM7PaletteSet);
         if (Index == 0)
         {
             tilemap = new Mode7Tilemap(Model.MinecartM7TilemapA, tileset, paletteSet);
         }
         else
         {
             tilemap = new Mode7Tilemap(Model.MinecartM7TilemapB, tileset, paletteSet);
         }
         toolStripLabel5.Visible     = true;
         startX.Visible              = true;
         startY.Visible              = true;
         toolStripSeparator6.Visible = true;
         startX.Value = Bits.GetShort(Model.ROM, 0x039670);
         startY.Value = Bits.GetShort(Model.ROM, 0x039679);
         panelScreens.Hide();
     }
     else
     {
         paletteSet = Model.MinecartSSPaletteSet;
         tileset    = new Tileset(Model.MinecartSSTileset, Model.MinecartSSGraphics, paletteSet, 16, 16, TilesetType.SideScrolling);
         bgtileset  = new Tileset(Model.MinecartSSBGTileset, Model.MinecartSSGraphics, paletteSet, 32, 16, TilesetType.SideScrolling);
         tilemap    = new SideTilemap(Model.MinecartSSTilemap, null, tileset, paletteSet);
         //
         if (Index == 2)
         {
             screenWidth.Value = MinecartData.WidthA;
         }
         else
         {
             screenWidth.Value = MinecartData.WidthB;
         }
         toolStripLabel5.Visible     = false;
         startX.Visible              = false;
         startY.Visible              = false;
         toolStripSeparator6.Visible = false;
         InitializeScreens();
         InitializeObjects();
         panelScreens.Show();
     }
     LoadStagePaletteEditor();
     LoadStageGraphicEditor();
     LoadSpritePaletteEditor();
     LoadSpriteGraphicEditor();
     LoadTilesetEditor();
     LoadTilemapEditor();
     //
     railColorKey.Visible = state.Rails && Index < 2;
     tilesetEditor.Rails  = state.Rails && Index < 2;
 }
 // constructors
 public SerializedBattlefield(byte[] tileset, PaletteSet paletteSet, Battlefield battlefield)
 {
     this.tileset     = tileset;
     this.paletteSet  = paletteSet;
     this.battlefield = battlefield;
     this.graphicSetA = battlefield.GraphicSetA;
     this.graphicSetB = battlefield.GraphicSetB;
     this.graphicSetC = battlefield.GraphicSetC;
     this.graphicSetD = battlefield.GraphicSetD;
     this.graphicSetE = battlefield.GraphicSetE;
 }
 // constructor
 public DialogueTileset(PaletteSet palettes)
 {
     this.graphics = Model.DialogueGraphics;
     this.palettes = palettes;
     //
     tileset_tiles = new Tile[16 * 4];
     for (int i = 0; i < tileset_tiles.Length; i++)
     {
         tileset_tiles[i] = new Tile(i);
     }
     DrawTileset(tileset_tiles);
 }
 public BattleDialogueTileset(byte[] graphics, byte[] tileset_bytes, PaletteSet paletteSet)
 {
     this.graphics      = graphics;
     this.palettes      = paletteSet;
     this.tileset_bytes = tileset_bytes;
     this.tileset_tiles = new Tile[16 * 2];
     for (int i = 0; i < tileset_tiles.Length; i++)
     {
         tileset_tiles[i] = new Tile(i);
     }
     DrawTileset(tileset_bytes, tileset_tiles);
 }
Exemplo n.º 15
0
 // constructor
 public MenuTileset(PaletteSet paletteSet, byte[] tileSet, byte[] graphicSet)
 {
     this.paletteSet = paletteSet; // grab the current Palette Set
     // Create our layers for the tilesets (256x512)
     tileset = new Tile[16 * 16];
     for (int i = 0; i < tileset.Length; i++)
     {
         tileset[i] = new Tile(i);
     }
     this.tileSet    = tileSet;
     this.graphicSet = graphicSet;
     DrawTileset(tileSet, tileset);
 }
Exemplo n.º 16
0
 public TileEditor(Delegate update, Tile tile, byte[] graphics, PaletteSet paletteSet, byte format)
 {
     this.update     = update;
     this.tile       = tile;
     this.tileBackup = tile.Copy();
     this.graphics   = graphics;
     this.paletteSet = paletteSet;
     this.format     = format;
     InitializeTile();
     Do.AddShortcut(toolStrip1, Keys.F1, helpTips);
     Do.AddShortcut(toolStrip1, Keys.F2, baseConvertor);
     new ToolTipLabel(this, baseConvertor, helpTips);
 }
Exemplo n.º 17
0
 // level tileset
 public Tileset(LevelMap levelMap, PaletteSet paletteSet)
 {
     this.levelMap   = levelMap;   // grab the current LevelMap
     this.paletteSet = paletteSet; // grab the current Palette Set
     this.Width      = 16;
     this.Height     = 32;
     this.HeightL3   = 16;
     this.tilesize   = 2;
     this.Type       = TilesetType.Level;
     // set tileset byte arrays
     tilesets_bytes[0] = Model.Tilesets[levelMap.TilesetL1 + 0x20];
     tilesets_bytes[1] = Model.Tilesets[levelMap.TilesetL2 + 0x20];
     tilesets_bytes[2] = Model.Tilesets[levelMap.TilesetL3];
     // combine graphic sets into one array
     graphics = new byte[0x6000];
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetA + 0x48], 0, graphics, 0, 0x2000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetB + 0x48], 0, graphics, 0x2000, 0x1000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetC + 0x48], 0, graphics, 0x3000, 0x1000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetD + 0x48], 0, graphics, 0x4000, 0x1000);
     Buffer.BlockCopy(Model.GraphicSets[levelMap.GraphicSetE + 0x48], 0, graphics, 0x5000, 0x1000);
     if (levelMap.GraphicSetL3 != 0xFF)
     {
         graphicsL3 = Model.GraphicSets[levelMap.GraphicSetL3];
     }
     // initialize 16x16 tile arrays
     tilesets_tiles[0] = new Tile[Width * Height];
     tilesets_tiles[1] = new Tile[Width * Height];
     if (levelMap.GraphicSetL3 != 0xFF)
     {
         tilesets_tiles[2] = new Tile[Width * HeightL3];
     }
     for (int l = 0; l < 3; l++)
     {
         if (tilesets_tiles[l] == null)
         {
             continue;
         }
         for (int i = 0; i < tilesets_tiles[l].Length; i++)
         {
             tilesets_tiles[l][i] = new Tile(i);
         }
     }
     // draw all 16x16 tiles
     DrawTileset(tilesets_bytes[0], tilesets_tiles[0], graphics, 0x20);
     DrawTileset(tilesets_bytes[1], tilesets_tiles[1], graphics, 0x20);
     if (levelMap.GraphicSetL3 != 0xFF)
     {
         DrawTileset(tilesets_bytes[2], tilesets_tiles[2], graphicsL3, 0x10);
     }
 }
Exemplo n.º 18
0
 private void reset_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("You're about to undo all changes to the current sprite and animation index. Go ahead with reset?",
                         "LAZY SHELL", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
     {
         return;
     }
     animation = new Animation(sprite.AnimationPacket);
     image     = new ImagePacket(sprite.Image);
     sprite    = new Sprite(Index);
     for (int i = image.PaletteNum; i < image.PaletteNum + 8; i++)
     {
         palettes[i] = new PaletteSet(Model.ROM, i, 0x252FFE + (i * 30), 1, 16, 30);
     }
     Buffer.BlockCopy(Model.ROM, image.GraphicOffset, Model.SpriteGraphics, image.GraphicOffset - 0x280000, 0x4000);
     number_ValueChanged(null, null);
 }
Exemplo n.º 19
0
        private void RefreshFormationBattlefield()
        {
            PaletteSet         paletteSet = paletteSets[battlefields[battlefieldName.SelectedIndex].PaletteSet];
            BattlefieldTileset tileSet    = new BattlefieldTileset(battlefields[battlefieldName.SelectedIndex], paletteSet);

            int[] quadrant1 = Do.TilesetToPixels(tileSet.Tileset_tiles, 16, 16, 0, false);
            int[] quadrant2 = Do.TilesetToPixels(tileSet.Tileset_tiles, 16, 16, 256, false);
            int[] quadrant3 = Do.TilesetToPixels(tileSet.Tileset_tiles, 16, 16, 512, false);
            int[] quadrant4 = Do.TilesetToPixels(tileSet.Tileset_tiles, 16, 16, 768, false);
            int[] pixels    = new int[512 * 512];
            Do.PixelsToPixels(quadrant1, pixels, 512, new Rectangle(0, 0, 256, 256));
            Do.PixelsToPixels(quadrant2, pixels, 512, new Rectangle(256, 0, 256, 256));
            Do.PixelsToPixels(quadrant3, pixels, 512, new Rectangle(0, 256, 256, 256));
            Do.PixelsToPixels(quadrant4, pixels, 512, new Rectangle(256, 256, 256, 256));
            formationBGImage = Do.PixelsToImage(pixels, 512, 512);
            pictureBoxFormation.Invalidate();
        }
Exemplo n.º 20
0
 public void Reload(Delegate update, Tile tile, byte[] graphics, PaletteSet paletteSet, byte format)
 {
     if (this.Updating)
     {
         return;
     }
     this.update     = update;
     this.tile       = tile;
     this.tileBackup = tile.Copy();
     this.graphics   = graphics;
     this.paletteSet = paletteSet;
     this.format     = format;
     InitializeSubtile();
     SetTileImage();
     SetSubtileImage();
     this.BringToFront();
 }
Exemplo n.º 21
0
 // constructor
 public IOArchitecture(string action, int index, LevelMap levelMap, PaletteSet paletteSet, Tileset tileSet, Tilemap tileMap, PrioritySet prioritySet)
 {
     this.action      = action;
     this.index       = index;
     this.levelMap    = levelMap;
     this.paletteSet  = paletteSet;
     this.tileset     = tileSet;
     this.tilemap     = tileMap;
     this.prioritySet = prioritySet;
     InitializeComponent();
     if (action == "import")
     {
         groupBox1.Text = "Import the following elements from architecture file";
     }
     else
     {
         groupBox1.Text = "Export the following elements to architecture file";
     }
 }
Exemplo n.º 22
0
 // minecart M7 tileset
 public Tileset(PaletteSet paletteSet)
 {
     this.paletteSet = paletteSet; // grab the current Palette Set
     this.Width      = 16;
     this.Height     = 16;
     this.tilesize   = 1;
     this.Type       = TilesetType.Mode7;
     //
     subtile_bytes = Model.MinecartM7TilesetSubtiles;
     palette_bytes = Model.MinecartM7TilesetPalettes;
     graphics      = Model.MinecartM7Graphics;
     // Create our layers for the tilesets (256x512)
     Tileset_tiles = new Tile[Width * Height];
     for (int i = 0; i < Tileset_tiles.Length; i++)
     {
         Tileset_tiles[i] = new Tile(i);
     }
     DrawTileset(subtile_bytes, Tileset_tiles, graphics, 0x20);
 }
Exemplo n.º 23
0
 // constructor
 public SideTilemap(byte[] tilemapL1, byte[] tilemapL2, Tileset tileset, PaletteSet paletteSet)
 {
     this.tileset           = tileset;
     this.paletteSet        = paletteSet;
     this.tilemaps_Bytes[0] = tilemapL1;
     this.tilemaps_Bytes[1] = tilemapL2;
     if (tilemapL2 == null)  // if the editable map
     {
         Width       = 256;
         pixels      = new int[Width_p * Height_p];
         L1Priority0 = new int[Width_p * Height_p];
         L1Priority1 = new int[Width_p * Height_p];
         L2Priority0 = new int[Width_p * Height_p];
         L2Priority1 = new int[Width_p * Height_p];
     }
     CreateLayer(0); // Create any required layers
     CreateLayer(1); // Create any required layers
     DrawAllLayers();
     CreateMainscreen();
 }
Exemplo n.º 24
0
        // constructors
        // default tileset
        public Tileset(byte[] tileset_Bytes, byte[] graphics, PaletteSet paletteSet, int width, int height, TilesetType type)
        {
            this.paletteSet    = paletteSet;
            this.Tileset_bytes = tileset_Bytes;
            this.Width         = width;
            this.Height        = height;
            this.tilesize      = 2;
            this.Type          = type;
            //
            this.graphics = graphics;
            //
            Tileset_tiles = new Tile[Width * Height];
            for (int i = 0; i < Tileset_tiles.Length; i++)
            {
                Tileset_tiles[i] = new Tile(i);
            }
            byte format = (byte)(type != TilesetType.Opening ? 0x20 : 0x10);

            DrawTileset(Tileset_bytes, Tileset_tiles, graphics, format);
            this.tilesets_bytes[0] = this.Tileset_bytes;
            this.tilesets_tiles[0] = this.Tileset_tiles;
        }
Exemplo n.º 25
0
 public void CopyTo(PaletteSet copyTo)
 {
     reds.CopyTo(copyTo.Reds, 0);
     greens.CopyTo(copyTo.Greens, 0);
     blues.CopyTo(copyTo.Blues, 0);
 }
Exemplo n.º 26
0
 private void Export_Worker_DoWork(object sender, DoWorkEventArgs e, string fullPath,
                                   bool crop, bool contact, bool gif, int maxwidth, int start, int end, bool current)
 {
     for (int a = start; a < end; a++)
     {
         if (Export_Worker.CancellationPending)
         {
             break;
         }
         Sprite s = null;
         if (element == "levels")
         {
             Export_Worker.ReportProgress(a);
         }
         else
         {
             s = sprites[a];
             Export_Worker.ReportProgress(s.Index);
         }
         // if NOT sprite sheet or animated gif (ie. if NOT single image for each element)
         if (!contact && element == "sprites")
         {
             DirectoryInfo di = new DirectoryInfo(fullPath + "Sprite #" + s.Index.ToString("d4"));
             if (!di.Exists)
             {
                 di.Create();
             }
         }
         int index = 0;
         int x = 0, y = 0;
         if (this.element == "levels")
         {
             LevelMap     lmap = levelMaps[levels[a].LevelMap];
             LevelLayer   layr = levels[a].Layer;
             PaletteSet   pset = paletteSets[levelMaps[levels[a].LevelMap].PaletteSet];
             Tileset      tset = new Tileset(lmap, pset);
             LevelTilemap tmap = new LevelTilemap(levels[a], tset);
             int[]        pixels;
             Rectangle    region;
             if (crop)
             {
                 region = new Rectangle(
                     layr.MaskLowX * 16, layr.MaskLowY * 16,
                     (layr.MaskHighX - layr.MaskLowX) * 16 + 16,
                     (layr.MaskHighY - layr.MaskLowY) * 16 + 16);
                 pixels = Do.GetPixelRegion(tmap.Pixels, region, 1024, 1024);
             }
             else
             {
                 region = new Rectangle(0, 0, 1024, 1024);
                 pixels = tmap.Pixels;
             }
             Bitmap image = Do.PixelsToImage(pixels, region.Width, region.Height);
             if (!current)
             {
                 image.Save(fullPath + "Level #" + a.ToString("d3") + ".png", ImageFormat.Png);
             }
             else
             {
                 image.Save(fullPath, ImageFormat.Png);
             }
             continue;
         }
         // sprites
         if (gif)
         {
             Animation animation = animations[s.AnimationPacket];
             foreach (Mold m in animation.Molds)
             {
                 foreach (Mold.Tile t in m.Tiles)
                 {
                     t.DrawSubtiles(s.Graphics, s.Palette, m.Gridplane);
                 }
             }
             foreach (Sequence sequence in animation.Sequences)
             {
                 List <int> durations     = new List <int>();
                 Bitmap[]   croppedFrames = sequence.GetSequenceImages(animation, ref durations);
                 //
                 string path = fullPath + "Sprite #" + s.Index.ToString("d4") + "\\sequence." + index.ToString("d2") + ".gif";
                 if (croppedFrames.Length > 0)
                 {
                     Do.ImagesToAnimatedGIF(croppedFrames, durations.ToArray(), path);
                 }
                 index++;
             }
             continue;
         }
         int[][]          molds = new int[animations[s.AnimationPacket].Molds.Count][];
         int[]            sheet;
         int              biggestHeight = 0;
         int              biggestWidth = 0;
         List <Rectangle> sheetRegions = new List <Rectangle>();
         foreach (Mold m in animations[s.AnimationPacket].Molds)
         {
             foreach (Mold.Tile t in m.Tiles)
             {
                 t.DrawSubtiles(
                     images[s.Image].Graphics(spriteGraphics),
                     palettes[images[s.Image].PaletteNum + s.PaletteIndex].Palette,
                     m.Gridplane);
             }
             Rectangle region;
             if (crop)
             {
                 if (m.Gridplane)
                 {
                     region = Do.Crop(m.GridplanePixels(), out molds[index], 32, 32);
                 }
                 else
                 {
                     region = Do.Crop(m.MoldPixels(), out molds[index], 256, 256);
                 }
                 m.MoldTilesPerPixel = null;
                 if (x + region.Width < maxwidth && biggestWidth < x + region.Width)
                 {
                     biggestWidth = x + region.Width;
                 }
                 // if reached far right boundary of a row, add current row's height
                 if (x + region.Width >= maxwidth)
                 {
                     x  = region.Width; // reset width counter
                     y += biggestHeight;
                     sheetRegions.Add(new Rectangle(x - region.Width, y, region.Width, region.Height));
                     biggestHeight = 0; // start next row
                 }
                 else
                 {
                     sheetRegions.Add(new Rectangle(x, y, region.Width, region.Height));
                     x += region.Width;
                 }
                 if (biggestHeight < region.Height)
                 {
                     biggestHeight = region.Height;
                 }
             }
             else
             {
                 region       = new Rectangle(new Point(0, 0), m.Gridplane ? new Size(32, 32) : new Size(256, 256));
                 molds[index] = m.Gridplane ? m.GridplanePixels() : m.MoldPixels();
             }
             if (!contact)
             {
                 Do.PixelsToImage(molds[index], region.Width, region.Height).Save(
                     fullPath + "Sprite #" + s.Index.ToString("d4") + "\\mold." + index.ToString("d2") + ".png", ImageFormat.Png);
             }
             index++;
         }
         if (contact)
         {
             sheet = new int[biggestWidth * (y + biggestHeight)];
             for (int i = 0; i < molds.Length; i++)
             {
                 Do.PixelsToPixels(molds[i], sheet, biggestWidth, sheetRegions[i]);
             }
             string path = fullPath + (current ? "" : "Sprite #" + s.Index.ToString("d4") + ".png");
             Do.PixelsToImage(sheet, biggestWidth, y + biggestHeight).Save(path, ImageFormat.Png);
         }
     }
 }