private void DrawScreen(int gameX, int gameY, int mapx, int mapY) { // Get currentLevelIndex and screen LevelIndex level = levelMap.GetLevel(gameX, gameY); bool invalidLevel = false; if (level == LevelIndex.None || (levelFilter != LevelIndex.None && level != levelFilter)) { return; ////if(!fillEmptySpots) return; ////if(levelFilter != LevelIndex.None) //// level = levelFilter; ////else //// level = GuessLevel(gameX, gameY); ////if(level == LevelIndex.Tourian) //// level = LevelIndex.Kraid; ////invalidLevel = true; } Level levelData = rom.GetLevel(level); int screenIndex = rom.GetScreenIndex(gameX, gameY); if (screenIndex == 0xFF || invalidLevel) // Blank screen { screenIndex = GetBlankScreenIndex(level); } Screen screen = levelData.Screens[screenIndex]; // Load data into renderer renderer.Level = levelData; renderer.SelectedEnemy = -1; // Apply paletteIndex //screen.ApplyLevelPalette(screenBitmap); // Sprites //renderer.ApplyPalette(screenBitmap, levelMap.GetAltPal(gameX, gameY)); // Backgrounds ScreenEditor.ApplyPalette(levelMap.GetAltPal(gameX, gameY), levelData, screenBitmap, HighlightEffect.Invert); // Render Screen renderer.DefaultPalette = screen.ColorAttributeTable; renderer.Clear(); renderer.SelectedDoor = -1; renderer.DrawScreen(screenIndex); IList <EnemyInstance> enemies = hideEnemies ? null : screen.Enemies; renderer.Render(b, screenBitmap, enemies, screen.Doors, showPhysics); Rectangle source = new Rectangle(0, 0, ScreenWidth, ScreenHeight); Rectangle dest = new Rectangle( mapx * ScreenWidth / scale, mapY * ScreenHeight / scale, ScreenWidth / scale, ScreenHeight / scale); gMap.DrawImage(screenBitmap, dest, source, GraphicsUnit.Pixel); }
void Render() { Text = "Screen Browser [" + BaseIndex.ToString("x") + " - " + Math.Min(BaseIndex + 15, Level.Screens.Count - 1).ToString("x") + "]"; gBuffer.Clear(Color.Black); gBuffer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear; gBuffer.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half; renderer.Level = this.Level; //renderer.ApplyPalette(blitterBuffer, UseAlternatePalette); //var pal = blitterBuffer.Palette; //if (UseAlternatePalette) { // Level.BgAltPalette.ApplyTable(pal.Entries,0); // Level.BgAltPalette.ApplyTable(pal.Entries, 16); // Level.SpriteAltPalette.ApplyTable(pal.Entries, 32); //} else { // Level.BgPalette.ApplyTable(pal.Entries, 0); // Level.BgPalette.ApplyTable(pal.Entries, 16); // Level.SpritePalette.ApplyTable(pal.Entries, 32); //} //blitterBuffer.Palette = pal; ScreenEditor.ApplyPalette(UseAlternatePalette, Level, blitterBuffer, HighlightEffect.Invert); for (int x = 0; x < 4; x++) { for (int y = 0; y < 4; y++) { int index = BaseIndex + x + y * 4; if (index < Level.Screens.Count) { var screen = Level.Screens[index]; renderer.SelectedEnemy = -1; renderer.SelectedDoor = -1; renderer.DefaultPalette = screen.ColorAttributeTable; renderer.Clear(); renderer.DrawScreen(index); renderer.Render(blitter, blitterBuffer, screen.Enemies, screen.Doors, ShowPhysics); Rectangle source = new Rectangle(0, 0, 256, 240); Rectangle dest = new Rectangle(cellPadding + cellSpacingX * x, cellPadding + cellSpacingY * y, cellWidth, cellHeight); gBuffer.DrawImage(blitterBuffer, dest, source, GraphicsUnit.Pixel); if (index == HighlightedScreen) { dest.Inflate(2, 2); gBuffer.DrawRectangle(SystemPens.Highlight, dest); dest.Inflate(1, 1); gBuffer.DrawRectangle(SystemPens.Highlight, dest); } } } } }