Ejemplo n.º 1
0
        public void load()
        {
            //Palettes
            int palCount = ROM.LZ77_GetDecompressedSize(PalFile.getContents(), false) / 512;

            palettes = new Palette[palCount];

            CompressedFile PalFileLz = new CompressedFile(PalFile, CompressedFile.CompressionType.LZ);

            for (int i = 0; i < palCount; i++)
            {
                palettes[i] = new FilePalette(new InlineFile(PalFileLz, i * 512, 512, "Palette " + i));
            }

            //Graphics
            CompressedFile GFXFileLz = new CompressedFile(GFXFile, CompressedFile.CompressionType.LZ);

            graphics = new Image2D(GFXFileLz, 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;
 *              }
 *          }*/
        }
Ejemplo n.º 2
0
        private Bitmap RenderBackground(File GFXFile, File PalFile, File LayoutFile, int offs, int palOffs)
        {
            LayoutFile = new CompressedFile(LayoutFile, CompressedFile.CompressionType.LZ);
            PalFile    = new CompressedFile(PalFile, CompressedFile.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);
        }
Ejemplo n.º 3
0
 public PaletteViewer(File f)
 {
     InitializeComponent();
     LanguageManager.ApplyToContainer(this, "PaletteViewer");
     this.MdiParent = MdiParentForm.instance;
     this.f         = f;
     this.pal       = FilePalette.arrayToPalette(f.getContents());
     if (pal.Length < 256)
     {
         is4bpp.Checked = true;
     }
     updatePalettes();
     pictureBox1.Invalidate();
     this.Icon = Properties.Resources.nsmbe;
 }
Ejemplo n.º 4
0
        private Tilemap getTilemap()
        {
            getFiles();
            if (GFXFile == null)
            {
                return(null);
            }
            if (PalFile == null)
            {
                return(null);
            }
            if (LayoutFile == null)
            {
                return(null);
            }

            LayoutFile = new CompressedFile(LayoutFile, CompressedFile.CompressionType.LZ);

            Image2D        image       = new Image2D(new CompressedFile(GFXFile, CompressedFile.CompressionType.MaybeCompressed), 256, false);
            CompressedFile paletteFile = new CompressedFile(PalFile, CompressedFile.CompressionType.MaybeCompressed);

            int palSize = 256;

            Color[] pal = FilePalette.arrayToPalette(paletteFile.getContents());
            if (pal.Length < 256)
            {
                palSize = 16;
            }
            List <Palette> palettes = new List <Palette>();

            for (int i = 0; i + palSize <= pal.Length; i += palSize)
            {
                int palOffs = i;
                int palLen  = palSize;
                if (palOffs + palLen > pal.Length)
                {
                    palLen = pal.Length - palOffs;
                }

                palettes.Add(new FilePalette(new InlineFile(paletteFile, palOffs * 2, palLen * 2, paletteFile.name)));
            }

            Tilemap t = new Tilemap(LayoutFile, 64, image, palettes.ToArray(), bg.BitmapOffset, bg.PaletteOffsets);

            return(t);
        }