private Tilemap getTilemap() { getFiles(); if (GFXFile == null) { return(null); } if (PalFile == null) { return(null); } if (LayoutFile == null) { return(null); } LayoutFile = new LZFile(LayoutFile, LZFile.CompressionType.LZ); Image2D i = new Image2D(GFXFile, 256, false); LZFile PalFileLz = new LZFile(PalFile, LZFile.CompressionType.LZ); Palette pal1 = new FilePalette(new InlineFile(PalFileLz, 0, 512, PalFile.name)); Palette pal2 = new FilePalette(new InlineFile(PalFileLz, 512, 512, PalFile.name)); Tilemap t = new Tilemap(LayoutFile, 64, i, new Palette[] { pal1, pal2 }, bg.topLayer ? 256 : 576, bg.topLayer ? 8 : 10); return(t); }
public void SetTileset(NSMBTileset t) { this.t = t; tileCount = t.Map16Buffer.Width / 16; map16Image = Image2D.CutImage(t.Map16Buffer, 256, 1); pictureBox1.Size = map16Image.Size; pictureBox1.Invalidate(true); }
private void editZone_Paint(object sender, PaintEventArgs e) { if (tls == null) { return; } if (obj == null) { return; } Graphics g = e.Graphics; g.FillRectangle(Brushes.LightSteelBlue, 0, 0, editZone.Width, editZone.Height); int x = 16; int y = 0; foreach (List <NSMBTileset.ObjectDefTile> row in obj.tiles) { foreach (NSMBTileset.ObjectDefTile t in row) { if (t.controlTile) { g.FillRectangle(Brushes.White, x, y, 15, 15); g.DrawRectangle(Pens.Black, x, y, 15, 15); g.DrawString(String.Format("{0:X2}", t.controlByte), NSMBGraphics.InfoFont, Brushes.Black, x, y); } else if (!t.emptyTile) { g.DrawImage(tls.Map16Buffer, x, y, Image2D.getTileRectangle(tls.Map16Buffer, 16, t.tileID), GraphicsUnit.Pixel); if ((t.controlByte & 1) != 0) { g.DrawRectangle(Pens.Red, x, y, 15, 15); } if ((t.controlByte & 2) != 0) { g.DrawRectangle(Pens.Blue, x + 1, y + 1, 13, 13); } } if (t == selTile) { g.DrawRectangle(Pens.White, x, y, 15, 15); } x += 16; } g.DrawString((y / 16) + "", NSMBGraphics.InfoFont, Brushes.White, 0, y); if (selRow == row && selTile == null) { g.DrawRectangle(Pens.White, 0, y, 15, 15); } x = 16; y += 16; } }
public Bitmap reRender(int xMin, int yMin, int width, int height) { for (int x = xMin; x < xMin + width; x++) { for (int y = yMin; y < yMin + height; y++) { if (x >= this.width) { continue; } if (y >= this.height) { continue; } Tile t = tiles[x, y]; if (t.tileNum < 0 || t.tileNum >= tileCount) { bufferGx.SetClip(new Rectangle(x * 8, y * 8, 8, 8)); bufferGx.Clear(NSMBGraphics.ReallyTransparent); bufferGx.ResetClip(); continue; } if (t.palNum >= palettes.Length) { continue; } if (t.palNum < 0) { continue; } // if (t.hflip == false && t.vflip == false) Rectangle rect = Image2D.getTileRectangle(buffers[t.palNum], 8, t.tileNum); Bitmap tile = new Bitmap(8, 8, System.Drawing.Imaging.PixelFormat.Format32bppPArgb); Graphics g = Graphics.FromImage(tile); g.DrawImage(buffers[t.palNum], new Rectangle(0, 0, 8, 8), rect, GraphicsUnit.Pixel); if (t.hflip == true && t.vflip == false) { tile.RotateFlip(RotateFlipType.RotateNoneFlipX); } else if (t.hflip == false && t.vflip == true) { tile.RotateFlip(RotateFlipType.RotateNoneFlipY); } else if (t.hflip == true && t.vflip == true) { tile.RotateFlip(RotateFlipType.RotateNoneFlipXY); } bufferGx.DrawImage(tile, new Rectangle(x * 8, y * 8, 8, 8), new Rectangle(0, 0, 8, 8), GraphicsUnit.Pixel); } } return(buffer); }
private Bitmap RenderBackground(File GFXFile, File PalFile, File LayoutFile, int offs, int palOffs) { LayoutFile = new LZFile(LayoutFile, LZFile.CompressionType.LZ); Image2D i = new Image2D(GFXFile, 256, false); Palette pal1 = new FilePalette(new InlineFile(PalFile, 0, 512, PalFile.name)); Palette pal2 = new FilePalette(new InlineFile(PalFile, 512, 512, PalFile.name)); Tilemap t = new Tilemap(LayoutFile, 64, i, new Palette[] { pal1, pal2 }, offs, palOffs); t.render(); return(t.buffer); }
public Tilemap(File f, int tileWidth, Image2D i, Palette[] pals, int tileOffset, int paletteOffset) { this.f = f; this.width = tileWidth; this.tileOffset = tileOffset; this.paletteOffset = paletteOffset; this.tileset = i; this.palettes = pals; this.tileCount = tileset.getWidth() * tileset.getHeight() / 64; load(); }
public void load() { //Palettes int palCount = ROM.LZ77_GetDecompressedSize(PalFile.getContents()) / 512; palettes = new Palette[palCount]; LZFile PalFileLz = new LZFile(PalFile, LZFile.CompressionType.LZ); for (int i = 0; i < palCount; i++) { palettes[i] = new FilePalette(new InlineFile(PalFileLz, i * 512, 512, "Palette " + i)); } //Graphics graphics = new Image2D(GFXFile, 256, false); //Map16 map16 = new Map16Tilemap(Map16File, 32, graphics, palettes, Map16TileOffset, Map16PaletteOffset); Overrides = new short[map16.getMap16TileCount()]; Map16Buffer = map16.render(); /* * TilemapEditorTest t = new TilemapEditorTest(); * t.load(map16); * t.Show(); */ //Tile Behaviors loadTileBehaviors(); //Objects loadObjects(); /* // Finally, load overrides * if (overrideFlag) * { * UseOverrides = true; * OverrideBitmap = Properties.Resources.tileoverrides; * * Overrides = new short[Map16.Length]; * EditorOverrides = new short[Map16.Length]; * * for (int idx = 0; idx < Map16.Length; idx++) * { * Overrides[idx] = -1; * EditorOverrides[idx] = -1; * } * }*/ }
public static void gotSection(File f, int offs, int size) { uint magic = f.getUintAt(offs); if (magic == 0x504C5454) //PLTT { new PaletteViewer(new InlineFile(f, offs + 0x18, size - 0x18, f.name)).Show(); } else if (magic == 0x43484152) //CHAR { LevelChooser.showImgMgr(); int tileWidth = f.getUshortAt(offs + 0xA); if (tileWidth == 0xFFFF) { tileWidth = 8; } LevelChooser.imgMgr.m.addImage(new Image2D(new InlineFile(f, offs + 0x20, size - 0x20, f.name), 8 * tileWidth, true, false)); } else if (magic == 0x5343524E) //SCRN { if (LevelChooser.imgMgr == null) { return; } Image2D img = LevelChooser.imgMgr.m.getSelectedImage(); Palette[] pals = LevelChooser.imgMgr.m.getPalettes(); if (img == null) { return; } if (pals == null) { return; } if (pals.Length == 0) { return; } InlineFile ff = new InlineFile(f, offs + 0x14, size - 0x14, f.name); Tilemap t = new Tilemap(ff, 32, img, pals, 0, 0); new TilemapEditorWindow(t).Show(); } else { Console.WriteLine(String.Format("Unknown magic: {0:X8}", magic)); } }
private Bitmap RenderBackground(File GFXFile, File PalFile, File LayoutFile, int offs, int palOffs) { LayoutFile = new LZFile(LayoutFile, LZFile.CompressionType.LZ); PalFile = new LZFile(PalFile, LZFile.CompressionType.LZ); Image2D i = new Image2D(GFXFile, 256, false); Palette pal1 = new FilePalette(new InlineFile(PalFile, 0, 512, PalFile.name)); Palette pal2 = new FilePalette(new InlineFile(PalFile, 512, 512, PalFile.name)); Tilemap t = new Tilemap(LayoutFile, 64, i, new Palette[] { pal1, pal2 }, offs, palOffs); t.render(); return t.buffer; }
public void load() { //Palettes int palCount = ROM.LZ77_GetDecompressedSize(PalFile.getContents()) / 512; palettes = new Palette[palCount]; for(int i = 0; i < palCount; i++) palettes[i] = new FilePalette(new InlineFile(PalFile, i*512, 512, "Palette "+i, null, InlineFile.CompressionType.LZComp)); //Graphics graphics = new Image2D(GFXFile, 256, false); //Map16 map16 = new Map16Tilemap(Map16File, 32, graphics, palettes, Map16TileOffset, Map16PaletteOffset); Overrides = new short[map16.getMap16TileCount()]; Map16Buffer = map16.render(); /* TilemapEditorTest t = new TilemapEditorTest(); t.load(map16); t.Show(); */ //Tile Behaviors loadTileBehaviors(); //Objects loadObjects(); /* // Finally, load overrides if (overrideFlag) { UseOverrides = true; OverrideBitmap = Properties.Resources.tileoverrides; Overrides = new short[Map16.Length]; EditorOverrides = new short[Map16.Length]; for (int idx = 0; idx < Map16.Length; idx++) { Overrides[idx] = -1; EditorOverrides[idx] = -1; } }*/ }
private Tilemap getTilemap() { getFiles(); if (GFXFile == null) return null; if (PalFile == null) return null; if (LayoutFile == null) return null; LayoutFile = new LZFile(LayoutFile, LZFile.CompressionType.LZ); Image2D i = new Image2D(GFXFile, 256, false); LZFile PalFileLz = new LZFile(PalFile, LZFile.CompressionType.LZ); Palette pal1 = new FilePalette(new InlineFile(PalFileLz, 0, 512, PalFile.name)); Palette pal2 = new FilePalette(new InlineFile(PalFileLz, 512, 512, PalFile.name)); Tilemap t = new Tilemap(LayoutFile, 64, i, new Palette[] { pal1, pal2 }, bg.topLayer ? 256 : 576, bg.topLayer ? 8 : 10); return t; }
public Map16Tilemap(File f, int tileWidth, Image2D i, Palette[] pals, int a, int b) : base(f, tileWidth, i, pals, a, b) { }