Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void SetLearnSet(ReadAndWrite rw, int index)
        {
            offset = rw.ReadPointer(learn_offset + 4 * index);
            BinaryReader br = rw.Br;

            br.BaseStream.Seek(offset, SeekOrigin.Begin);
            grid.Rows.Clear();
            if (expanded_learnset)
            {
                for (int x = 0; x < 50; x++)
                {
                    short s = br.ReadInt16();
                    learnmove_buffer[x] = s;
                    byte m = br.ReadByte();
                    learnlvl_buffer[x] = m;
                    if (s == 0)
                    {
                        break;
                    }
                    grid.Rows.Add();
                    grid.Rows[x].Cells[0].Value = m;
                    grid.Rows[x].Cells[1].Value = dataSource[s];
                }
            }
            else
            {
            }
        }
Exemplo n.º 4
0
 public void SavePos(ReadAndWrite rw, int index)
 {
     rw.Seek(enymyyTable + index * 4 + 1);
     rw.Bw.Write(pos[1]);
     rw.Seek(playeryTable + index * 4 + 1);
     rw.Bw.Write(pos[0]);
     rw.Seek(altitudeTable + index);
     rw.Bw.Write(pos[2]);
 }
Exemplo n.º 5
0
 public void GetPos(ReadAndWrite rw, int index)
 {
     rw.Seek(enymyyTable + index * 4 + 1);
     pos[1] = rw.Br.ReadByte();
     rw.Seek(playeryTable + index * 4 + 1);
     pos[0] = rw.Br.ReadByte();
     rw.Seek(altitudeTable + index);
     pos[2] = rw.Br.ReadByte();
 }
Exemplo n.º 6
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));
        }
Exemplo n.º 7
0
 private Evo[] getEvo(ReadAndWrite rw, int num)
 {
     //Console.WriteLine(Operation.Hex(rw.getStructOffset(typeof(Evo), evo_table, num * EVO_PER_POKE)));
     rw.Seek(rw.getStructOffset(typeof(Evo), evo_table, num * EVO_PER_POKE));
     for (int x = 0; x < EVO_PER_POKE; x++)
     {
         byte[] data = rw.Br.ReadBytes(8);
         evo[x] = (Evo)StructsUtil.ByteToStruct(data, typeof(Evo));
     }
     return(evo);
 }
Exemplo n.º 8
0
 public void SaveAll(ReadAndWrite rw, bool fill)
 {
     if (!preImport)
     {
         return;
     }
     Save(rw, frontdata, front_offset + index * 8, fill);
     Save(rw, backdata, back_offset + index * 8, fill);
     Save(rw, normalpallete, normal_pal_off + index * 8, fill);
     Save(rw, shinypallete, shiny_pal_off + index * 8, fill);
     preImport = false;
 }
Exemplo n.º 9
0
        public void SetPos(ReadAndWrite rw)
        {
            int enymyyTable = 0xa5f54;

            this.enymyyTable = rw.ReadPointer(enymyyTable);
            int playeryTable = 0xa5ebc;

            this.playeryTable = rw.ReadPointer(playeryTable);
            int altitudeTable = 0xa5ff4;

            this.altitudeTable = rw.ReadPointer(altitudeTable);
        }
Exemplo n.º 10
0
 public void setGridEvoInfo(ReadAndWrite rw, int num, string[] pokeNames)
 {
     Evo[] e = getEvo(rw, num);
     for (int i = 0; i < EVO_PER_POKE; i++)
     {
         Evo e0 = e[i];
         grid.Rows[i].Cells[0].Value = (int)e0.method;
         grid.Rows[i].Cells[1].Value = Operation.Hex(e0.padd0);
         grid.Rows[i].Cells[2].Value = WordsDecoding.PreFixString(pokeNames, e0.poke);
         grid.Rows[i].Cells[3].Value = Operation.Hex(e0.parameter);
         grid.Rows[i].Cells[4].Value = Operation.Hex(e0.padd1);
     }
 }
Exemplo n.º 11
0
 private npc_type GetNpc(ReadAndWrite rw, int num)
 {
     if (num > MAX_NUM)
     {
         num  -= MAX_NUM;
         table = TABLE_EXPANDED;
     }
     else
     {
         table = TABLE_DEAFAULT;
     }
     this.num = num;
     return((npc_type)rw.GetStruct(table, num, typeof(npc_type)));
 }
Exemplo n.º 12
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);
            }
        }
Exemplo n.º 13
0
 public void Save(ReadAndWrite rw, int num)
 {
     rw.Seek(rw.getStructOffset(typeof(Evo), evo_table, num * EVO_PER_POKE));
     for (int i = 0; i < EVO_PER_POKE; i++)
     {
         Evo e = evo[i];
         DataGridViewCellCollection cell = grid.Rows[i].Cells;
         e.method    = (byte)(int)cell[0].Value;
         e.padd0     = Operation.ParseByte((string)cell[1].Value);
         e.parameter = (ushort)Operation.ParseShort((string)cell[3].Value);
         e.padd1     = Operation.ParseShort((string)cell[4].Value);
         rw.Bw.Write(StructsUtil.StructToByte(e));
     }
 }
Exemplo n.º 14
0
 public void Validate(ReadAndWrite rw)
 {
     /*
      *          rw.Seek(0xAC);
      *          byte[] data = rw.Br.ReadBytes(10);
      *          if (Compare(data, WordsDecoding.ULTRA))
      *                  section = "802";
      *          else if (Compare(data, WordsDecoding.BPEE))
      *                  section = "rom";
      *          else
      *                  throw new Exception("unknown rom_id");
      */
     section = "802";
 }
Exemplo n.º 15
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);
     }
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
0
        public Bitmap GetImg(ReadAndWrite rw, int frames)
        {
            if (palletes[0] == null)
            {
                LoadPalletes(rw);
            }
            int off;

            try {
                off = rw.ReadPointer(npc.gfx_table + (frames << 3));
            } catch (Exception) {
                return(null);
            }

            Bitmap p = rw.GetIndexedBitmapNotLz(off, palletes[(byte)npc.pal_tag], npc.width, npc.height);

            return(p);
        }
Exemplo n.º 18
0
        public void Resize(ReadAndWrite rw, int old, int new_, bool clear)
        {
            if (new_ < old)
            {
                return;
            }
            int start = rw.FindFreeOffset0xFF(new_ * 8);

            rw.Seek(start);
            for (int i = 0; i < new_; i++)
            {
                rw.Bw.Write(0x1010101010001000);
            }
            byte[] a = rw.ReadAndClear(npc.gfx_table, 8 * old, clear);
            rw.WriteBytes(start, 0, a);
            npc.gfx_table = start + ReadAndWrite.ROM;
            Save(rw);
        }
Exemplo n.º 19
0
 public void setNpc(ReadAndWrite rw, int num)
 {
     npc = GetNpc(rw, num);
 }
Exemplo n.º 20
0
 public byte[] GetData(ReadAndWrite rw, int offset)
 {
     offset = rw.ReadPointer(offset);
     return(ImgFunction.LZUncompress(rw.Br, offset).Item1);
 }
Exemplo n.º 21
0
 public void Save(ReadAndWrite rw)
 {
     rw.Save(table, num, npc);
 }