Ejemplo n.º 1
0
        public static Bitmap GetOam(int bank, int index, int subindex, int oam, int palnum = -1, bool transparent = true)
        {
            // Get the palette
            var pal = SpritePalettes.GetPalette(index, palnum);

            // Get the graphics pointer
            int gfxpointer = SpriteGfx.GetPointer(bank, index);

            // Get the sprite info
            var si = SpriteInfo.InfoEntries[bank][index].Sprites[subindex].Sprites[oam];

            // Bail out if we need to
            if ((pal == null) || (gfxpointer == -1) || (si == null))
            {
                return(null);
            }

            return(GfxProvider.RenderSprites(new OamSprite[] { si }, Rom, gfxpointer, pal, transparent));
        }
Ejemplo n.º 2
0
        public static Bitmap GetSprites(int canvas0Width, int canvas0Height, int room, CheckBox[] chkTable, out Bitmap Enemies, out Bitmap Enemies2)
        {
            var rInfo   = RoomInfo.RoomInfoEntries[room];
            var rGfxPal = SpritePalettes.DefaultPals;

            // Get the width and height (in 16*16 tiles)
            int w = rInfo.Width;
            int h = rInfo.Height;

            // Create the bitmap
            Bitmap bmp = new Bitmap(canvas0Width, canvas0Height, PixelFormat.Format8bppIndexed);

            Enemies  = new Bitmap(canvas0Width, canvas0Height, PixelFormat.Format8bppIndexed);
            Enemies2 = new Bitmap(canvas0Width, canvas0Height, PixelFormat.Format8bppIndexed);
            Enemies.CopyPalette(rGfxPal, true);
            Enemies2.CopyPalette(rGfxPal, true);
            int        Last = 0, palettenum = 0;
            List <int> Palettenum = new List <int>();
            BitmapData bd         = bmp.LockBits(ImageLockMode.WriteOnly);
            BitmapData be         = Enemies.LockBits(ImageLockMode.WriteOnly);
            BitmapData be2        = Enemies2.LockBits(ImageLockMode.WriteOnly);

            bmp.CopyPalette(rGfxPal, true);
            for (int j = 0; j <= 4; j++)
            {
                if (chkTable[j].Checked == true)
                {
                    for (int i = 0; i < RoomSprites.Sprites[(room * 5) + j].Count; i++)
                    {
                        var rs = RoomSprites.Sprites[(room * 5) + j][i];
                        if (!((rs.Sprite <= 0xFF) || (rs.Sprite >= 0x26C)))
                        {
                            MPalette[] NewestPalette;
                            MPalette[] NewestPalette2;
                            RenderPalette(SpritePalettes.GetPalette(rs.Sprite), Enemies.Palette, Enemies2.Palette, Last, out NewestPalette, out Last, out NewestPalette2, out palettenum);
                            Palettenum.Add(palettenum);
                            Enemies.CopyPalette(NewestPalette, true);
                            Enemies2.CopyPalette(NewestPalette2, true);
                        }
                    }
                }
            }
            int count = 0;

            for (int j = 0; j <= 4; j++)
            {
                if (chkTable[j].Checked == true)
                {
                    for (int i = 0; i < RoomSprites.Sprites[(room * 5) + j].Count; i++)
                    {
                        var rs = RoomSprites.Sprites[(room * 5) + j][i];
                        var si = SpriteInfo.InfoEntries[0][rs.Sprite];
                        if ((rs.Sprite == 0) || (rs.Sprite == 0xC0))
                        {
                            continue;
                        }
                        if ((rs.Sprite >= 0x2D0) && (rs.Sprite < 0x3D0))
                        {
                            // All item images are stored nice and linearly
                            // Each item image is 3x3 tiles
                            var index = rs.Sprite - 0x2D0;
                            RenderItems(bd, index, rs.X, rs.Y, SpritePalettes.GetPalNum(rs.Sprite));
                        }
                        else
                        {
                            var s = si.Sprites[rs.Direction % si.Sprites.Length];
                            if ((rs.Sprite <= 0xFF) || (rs.Sprite >= 0x26C))
                            {
                                GfxProvider.RenderSprites(bd, rs.X, rs.Y, s.Sprites,
                                                          Rom, SpriteGfx.GetPointer(0, rs.Sprite),
                                                          SpritePalettes.GetPalNum(rs.Sprite));
                            }
                            else
                            {
                                RenderEnemies(be, be2, rs.X, rs.Y, s.Sprites,
                                              Rom, SpriteGfx.GetPointer(0, rs.Sprite),
                                              Palettenum[count]);
                                count++;
                            }
                        }
                    }
                }
            }
            Enemies2.UnlockBits(be2);
            Enemies.UnlockBits(be);
            bmp.UnlockBits(bd);
            return(bmp);
        }
Ejemplo n.º 3
0
 public static void Init()
 {
     SpriteGfx.Init();
     SpritePalettes.Init();
     SpriteInfo.Init();
 }