/// <summary> /// Draws the flag to a bitmap, at position 80x176. /// </summary> /// <param name="bitmap">The Bitmap object to draw the flag object to.</param> /// <param name="flag"></param> public void DrawFlag(ref Bitmap bitmap, LevelDisplayFlag flag) { NESRender pat = new NESRender(48, 32); int InitialX = 80; int InitialY = 176; byte PaletteIndex; // If the function is drawing the fortified flag, a different // palette index is needed. if ((flag & LevelDisplayFlag.ViewFortifiedFlag) == LevelDisplayFlag.ViewFortifiedFlag) PaletteIndex = 3; else PaletteIndex =0; for (byte i = 0; i < 4; i++) { for (byte x = 0; x < 6; x++) { fixed (byte* pPal = &Palette[PaletteIndex, 0]) { byte FlagData; // If the flag we are drawing is the fortified flag, retrieve the TSA for it if ((flag & LevelDisplayFlag.ViewFortifiedFlag) == LevelDisplayFlag.ViewFortifiedFlag) FlagData = GetFortifiedFlagTSAData(i, x); else FlagData = GetFlagTSAData(i, x); fixed (byte* pPat = &_PatternTable[BGPATTERNTABLE + (FlagData * 0x10)]) { pat.DrawTile((x * 8), (i * 8), pPat, pPal); } } } } // Render the flags data to the main level bitmap at 80 x 176 pat.DrawBitmap(ref bitmap, new Rectangle(0, 0, pat.Width, pat.Height), new Rectangle(InitialX, InitialY, pat.Width, pat.Height)); }
/// <summary> /// Draws a specific tank to a bitmap at co-ordinates 0,0. /// </summary> /// <param name="bitmap">The bitmap to draw the tank object to.</param> /// <param name="tankIndex">The index of the tank to draw.</param> public void DrawTank(ref Bitmap bitmap, Byte tankIndex) { NESRender pat = new NESRender(bitmap.Width, bitmap.Height); fixed (byte* pPal = &Palette[4, 0]) { fixed (byte* pPat = &_PatternTable[((tankIndex * 0x20) * 16)]) { pat.DrawTile(0, 0, pPat, pPal); } fixed (byte* pPat = &_PatternTable[((tankIndex * 0x20) * 16) + 0x10]) { pat.DrawTile(0, 8, pPat, pPal); } fixed (byte* pPat = &_PatternTable[((tankIndex * 0x20) * 16) + 0x20]) { pat.DrawTile(8, 0, pPat, pPal); } fixed (byte* pPat = &_PatternTable[((tankIndex * 0x20) * 16) + 0x30]) { pat.DrawTile(8, 8, pPat, pPal); } } pat.DrawBitmap(ref bitmap); }
/// <summary> /// Draws the background pattern table to a Bitmap object, using the specified palette colour. /// </summary> /// <param name="bitmap">The Bitmap object to draw the background pattern table to.</param> /// <param name="paletteIndex">The palette index to use when rendering the pattern table.</param> public void DrawBGPatternTable(ref Bitmap bitmap, byte paletteIndex) { NESRender pat = new NESRender(bitmap.Width, bitmap.Height); for (int i = 0; i < 16; i++) { for (int x = 0; x < 16; x++) { fixed (byte* pPal = &Palette[paletteIndex, 0]) { fixed (byte* pPat = &_PatternTable[BGPATTERNTABLE + (((i * 16) + x) * 0x10)]) { pat.DrawTile(x * 8, i * 8, pPat, pPal); } } } } pat.DrawBitmap(ref bitmap); }