Esempio n. 1
0
        public void Import(ReadAndWrite rw, Bitmap bm, int frame, int pal, bool clear, bool find)
        {
            int gfx_offset = npc.gfx_table + (frame << 3);
            int img_offset;

            try {
                img_offset = rw.ReadPointer(gfx_offset);
                if (clear)
                {
                    rw.FillWith0xFF(img_offset, rw.Br.ReadInt16());
                    goto FIND;
                }
                if (clear || find)
                {
                    goto FIND;
                }
                goto NOT_FIND;
            } catch (NullReferenceException) { }
FIND:
            img_offset = rw.FindFreeOffset0xFF(PokeConfig.ini.start_offset, bm.Width * bm.Height / 2);
NOT_FIND:
            byte[] img = ImgFunction.ConvertNormalImagToGBA(bm, new List <Color>(palletes[pal]), false);
            rw.WriteBytes(img_offset, 0, img);
            rw.Seek(gfx_offset);
            rw.Bw.Write(img_offset + ReadAndWrite.ROM);
            rw.Bw.Write(bm.Width * bm.Height >> 1);
            npc.width  = (short)bm.Width;
            npc.height = (short)bm.Height;
            Save(rw);
        }
Esempio n. 2
0
        public void LoadFromGBA(ReadAndWrite rw)
        {
            preImport = false;
            int num = index << 3;

            frontdata     = GetData(rw, front_offset + num);
            backdata      = GetData(rw, back_offset + num);
            normalpallete = GetData(rw, normal_pal_off + num);
            shinypallete  = GetData(rw, shiny_pal_off + num);
            byte height = 64;

            if (frontdata.Length == 2048 * 2)
            {
                height     = 128;
                isTwoframe = true;
            }
            else
            {
                isTwoframe = false;
            }
            Color[] normalpal = ImgFunction.ConvertGBAPalTo24Bit(normalpallete);
            Color[] shinypal  = ImgFunction.ConvertGBAPalTo24Bit(shinypallete);
            front.Image      = ImgFunction.ConvertGBAImageToBitmap(frontdata, normalpal, 64, height);
            shinyfront.Image = ImgFunction.ConvertGBAImageToBitmap(frontdata, shinypal, 64, height);
            back.Image       = ImgFunction.ConvertGBAImageToBitmap(backdata, normalpal, 64, 64);
            shinyback.Image  = ImgFunction.ConvertGBAImageToBitmap(backdata, shinypal, 64, 64);
        }
Esempio n. 3
0
        public Bitmap GetIndexedBitmapNotLz(int img, Color[] pal, int width, int height)
        {
            int length = (height * width) << 1;

            Seek(img);
            byte[] img_data = Br.ReadBytes(length);
            return(ImgFunction.ConvertGBAImageToBitmapIndexed(img_data, pal, width, height));
        }
Esempio n. 4
0
 private void LoadBlockTiles()
 {
     byte[] img1 = ImgFunction.LZUncompress(Br, tileset1.tileset - ROM).Item1;
     byte[] img2 = ImgFunction.LZUncompress(Br, tileset2.tileset - ROM).Item1;
     byte[] img  = new byte[img1.Length + img2.Length];
     Buffer.BlockCopy(img1, 0, img, 0, img1.Length);
     Buffer.BlockCopy(img2, 0, img, img1.Length, img2.Length);
     tileset = ImgFunction.ConvertGBAImageToBitmapIndexed(img, map_pals, 128, img.Length * 2 / 128);
 }
Esempio n. 5
0
        public Bitmap GetIcoin(ReadAndWrite rw)
        {
            rw.Seek(icoinPalleteIndexTable + index);
            byte palindex = rw.Br.ReadByte();

            byte[] img = rw.ReadBytes(rw.ReadPointer(icoinTable + (index << 2))
                                      , 0, 0x400);
            return(ImgFunction.ConvertGBAImageToBitmap(img, icoinPalltes[palindex],
                                                       32, 64, icoinImage));
        }
Esempio n. 6
0
        public void LoadMapData(int map_no, int map_bank)
        {
            int offset = ReadPointer(MAP_BANK_PONTER);

            offset   = ReadPointer(offset + 4 * map_no);
            offset   = ReadPointer(offset + 4 * map_bank);
            header   = GetStruct <mapheader>(offset, 0);
            offset   = ReadPointer(MAP_FOOTER_POINTER);
            offset   = ReadPointer(offset + 4 * header.footer_id);
            footer   = GetStruct <footer>(offset, 0);
            tileset1 = GetStruct <blockset>(footer.primary_blockset, 0);
            tileset2 = GetStruct <blockset>(footer.secondary_blockset, 0);
            map_pals = ImgFunction.ConvertGBAPalTo24Bit(ReadBytes(tileset1.pals, 0, 12 * 0x20));
        }
Esempio n. 7
0
        public void LoadPalletes(ReadAndWrite rw)
        {
            byte[] data = new byte[0x20];
            Stream s    = rw.Br.BaseStream;

            for (int x = 0; x < PAL_NUM - 1; x++)
            {
                int off = rw.ReadPointer(PAL_SPRITE + (x << 3));
                int num = s.ReadByte();
                rw.Seek(off);
                s.Read(data, 0, 0x20);
                palletes[num] = ImgFunction.ConvertGBAPalTo24Bit(data);
            }
        }
Esempio n. 8
0
 public void InIt(ReadAndWrite rw, INI_init ini)
 {
     front_offset           = rw.ReadPointer(ini.frontspritetable);
     back_offset            = rw.ReadPointer(ini.backspritetable);
     normal_pal_off         = rw.ReadPointer(ini.frontpalettetable);
     shiny_pal_off          = rw.ReadPointer(ini.shinypalettetable);
     icoinTable             = rw.ReadPointer(ini.icointable);
     icoinPalleteIndexTable = rw.ReadPointer(ini.icoinindextable);
     icoinPalltes           = new Color[3][];
     rw.Seek(ini.icoinpallete);
     for (byte x = 0; x < 3; x++)
     {
         byte[] pal = rw.Br.ReadBytes(32);
         icoinPalltes[x] = ImgFunction.ConvertGBAPalTo24Bit(pal);
     }
 }
Esempio n. 9
0
        public void PreImport(Bitmap front, Bitmap shinyfront, Bitmap back, Bitmap shinyback)
        {
            this.front.Image      = front;
            this.shinyfront.Image = shinyfront;
            this.back.Image       = back;
            this.shinyback.Image  = shinyback;
            List <Color> normal = new List <Color>(16);
            List <Color> shiny  = new List <Color>(16);

            ImgFunction.GetImgColor(front, shinyfront, normal, shiny);
            frontdata     = ImgFunction.ConvertNormalImagToGBA(front, normal);
            backdata      = ImgFunction.ConvertNormalImagToGBA(back, normal);
            normalpallete = ImgFunction.LZCompress(ImgFunction.ConvertToGBAPal(normal));
            shinypallete  = ImgFunction.LZCompress(ImgFunction.ConvertToGBAPal(shiny));
            preImport     = true;
        }
Esempio n. 10
0
        /// <summary>
        /// 保存任意压缩数据,需要提供原始指针所在地址。
        /// </summary>
        /// <param name="rw"></param>
        /// <param name="data">所需要写入的数据</param>
        /// <param name="offset">指针所在地址</param>
        /// <param name="fill">是否将原来的数据填充为0xFF</param>
        public int Save(ReadAndWrite rw, byte[] data, int offset_to_repoint, bool fill)
        {
            //指针所在地址
            int offset_old = rw.ReadPointer(offset_to_repoint);
            //新地址
            int offset_new = rw.FindFreeOffset(start, data.Length);

            rw.WriteBytes(offset_new, 0, data);
            start = rw.Position;
            rw.Repoint(offset_to_repoint, offset_new);
            int length = ImgFunction.LZUncompress(rw.Br, offset_old).Item2;

            if (fill)
            {
                rw.FillWith0xFF(offset_old, length);
            }
            return(offset_new);
        }
Esempio n. 11
0
 public byte[] GetData(ReadAndWrite rw, int offset)
 {
     offset = rw.ReadPointer(offset);
     return(ImgFunction.LZUncompress(rw.Br, offset).Item1);
 }