Esempio n. 1
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);
 }
Esempio n. 2
0
        private void DrawNPCToVRAM(int[] dst, ref int x, ref int y, int spriteIndex, int moldIndex, bool dynamic)
        {
            Sprite      sprite    = Model.Sprites[spriteIndex];
            Animation   animation = Model.Animations[sprite.AnimationPacket];
            ImagePacket image     = Model.GraphicPalettes[sprite.Image];

            byte[] graphics = image.Graphics(Model.SpriteGraphics);
            int[]  palette  = Model.SpritePalettes[image.PaletteNum + sprite.PaletteIndex].Palette;
            //
            for (int i = 0; i < animation.Molds.Count; i++)
            {
                if (dynamic && i > 0)
                {
                    break;
                }
                Mold mold;
                if (dynamic)
                {
                    mold = animation.Molds[moldIndex];
                }
                else
                {
                    mold = animation.Molds[i];
                }
                int counter = 3;
                foreach (Mold.Tile tile in mold.Tiles)
                {
                    tile.DrawSubtiles(graphics, palette, mold.Gridplane);
                    Rectangle srcRegion;
                    Rectangle dstRegion;
                    int[]     src = mold.Gridplane ? tile.GetGridplanePixels() : tile.Get16x16TilePixels();
                    if (dynamic)
                    {
                        if (x + tile.Width > 128)
                        {
                            x  = 0;
                            y += 16;
                        }
                        srcRegion = new Rectangle(0, 0, tile.Width, 16);
                        dstRegion = new Rectangle(x, y, tile.Width, 16);
                        Do.PixelsToPixels(src, dst, mold.Gridplane ? 32 : 16, 128, srcRegion, dstRegion);
                        if (mold.Gridplane) // draw bottom half of sprite
                        {
                            srcRegion.Y += 16;
                            dstRegion.X += tile.Width;
                            Do.PixelsToPixels(src, dst, 32, 128, srcRegion, dstRegion);
                            x += 64;
                        }
                        else
                        {
                            x += tile.Width;
                        }
                    }
                    else
                    {
                        if (x + tile.Width > 128)
                        {
                            x  = 32;
                            y += 32;
                        }
                        if (mold.Gridplane)
                        {
                            srcRegion = new Rectangle(0, 0, tile.Width, 32);
                            dstRegion = new Rectangle(x, y, tile.Width, 32);
                            Do.PixelsToPixels(src, dst, 32, 128, srcRegion, dstRegion);
                            x += tile.Width;
                        }
                        else
                        {
                            srcRegion = new Rectangle(0, 0, tile.Width, 16);
                            if (counter == 3)
                            {
                                dstRegion = new Rectangle(x + 16, y + 16, 16, 16);
                            }
                            else if (counter == 2)
                            {
                                dstRegion = new Rectangle(x, y + 16, 16, 16);
                            }
                            else if (counter == 1)
                            {
                                dstRegion = new Rectangle(x + 16, y, 16, 16);
                            }
                            else
                            {
                                dstRegion = new Rectangle(x, y, 16, 16);
                            }
                            Do.PixelsToPixels(src, dst, 16, 128, srcRegion, dstRegion);
                            counter--;
                            if (counter < 0)
                            {
                                x += 32;
                            }
                        }
                    }
                }
            }
        }