示例#1
0
        bool WriteMapConfig(Undo.UndoData undodata)
        {
            if (this.MapStyle.SelectedIndex < 0)
            {
                return(false);
            }
            uint config_plist    = this.MapEditConf[this.MapStyle.SelectedIndex].config_plist;
            uint chipset_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CONFIG, config_plist);

            byte[] chipsetConfigZ = LZ77.compress(this.ConfigUZ);
            uint   newaddr        = InputFormRef.WriteBinaryData(this, (uint)ChipsetConfigAddress.Value, chipsetConfigZ, InputFormRef.get_data_pos_callback_lz77, undodata);

            if (newaddr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }
            ChipsetConfigAddress.Value = newaddr;

            //拡張領域に書き込んでいる可能性もあるので plstを更新する.
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.CONFIG, config_plist, newaddr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }

            //書き込んだ通知.
            InputFormRef.ShowWriteNotifyAnimation(this, newaddr);
            InputFormRef.WriteButtonToYellow(this.Config_WriteButton, false);
            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
            return(true);
        }
示例#2
0
        bool PaletteImportOne(Bitmap bitmap, uint palette_plist, bool isFog)
        {
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);

            //パレット情報の書き込み.
            uint palette_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist);

            if (palette_address == 0)
            {//未割り当てならば新規確保しようか
                palette_address = InputFormRef.AppendBinaryData(PaletteFormRef.NewNullPalette(MAX_MAP_PALETTE_COUNT), undodata);
            }

            if (isFog)
            {
                PFR.MakePaletteBitmapToROM(bitmap, palette_address + (0x20 * PARTS_MAP_PALETTE_COUNT), PARTS_MAP_PALETTE_COUNT, undodata);
            }
            else
            {
                PFR.MakePaletteBitmapToROM(bitmap, palette_address, PARTS_MAP_PALETTE_COUNT, undodata);
            }


            //拡張領域に書き込んでいる可能性もあるので plstを更新する.
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist, palette_address, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }

            Program.Undo.Push(undodata);
            return(true);
        }
示例#3
0
        void InitUI()
        {
            if (MapPointerForm.IsPlistSplits())
            {
                PLISTExtendsButton.Enabled = false;
                AlreadyExtendsLabel.Show();
            }
            else if (MapPointerForm.IsExtendsPlist())
            {
                PLISTExtendsButton.Enabled = false;
                AlreadyExtendsLabel.Show();
            }
            else
            {
                PLISTExtendsButton.Enabled = true;
                AlreadyExtendsLabel.Hide();
            }

            uint max = MapPointerForm.GetDataCount(MapPointerForm.PLIST_TYPE.UNKNOWN) - 1;

            OBJ1numericUpDown.Maximum = max;
            OBJ1numericUpDown_ValueChanged(null, null);
            OBJ2numericUpDown.Maximum = max;
            OBJ2numericUpDown_ValueChanged(null, null);
            PALnumericUpDown.Maximum = max;
            PALnumericUpDown_ValueChanged(null, null);
            CONFIGnumericUpDown.Maximum = max;
            CONFIGnumericUpDown_ValueChanged(null, null);
            ANIME1numericUpDown.Maximum = max;
            ANIME1numericUpDown_ValueChanged(null, null);
            ANIME2numericUpDown.Maximum = max;
            ANIME2numericUpDown_ValueChanged(null, null);
        }
示例#4
0
        //Plistアドレスの更新
        void Display_Plist(uint obj_plist, uint palette_plist, uint config_plist)
        {
            uint config_offset = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CONFIG, config_plist);

            ChipsetConfigAddress.Value = config_offset;

            uint obj_offset = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.OBJECT, obj_plist & 0xFF);

            ObjAddress.Value = obj_offset;

            uint obj2_plist     = (obj_plist >> 8) & 0xFF; //FE8にはないが FE7は、 plistを2つ設定できることがある.
            uint obj2_offset    = 0;
            uint palette_offset = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist);

            PaletteAddress.Value = palette_offset;

            if (obj2_plist > 0)
            {//plist2があれば
                obj2_offset         = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.OBJECT, obj2_plist);
                ObjAddress2.Value   = obj2_offset;
                ObjAddress2.Visible = true;
            }
            else
            {
                ObjAddress2.Value   = 0;
                ObjAddress2.Visible = false;
            }
        }
        void InitUI()
        {
            if (MapPointerForm.IsPlistSplits())
            {
                PLISTExtendsButton.Enabled = false;
                AlreadyExtendsLabel.Show();
                PLIST_EXPLAIN.Hide();
            }
            else if (MapPointerForm.IsExtendsPlist())
            {
                PLISTExtendsButton.Enabled = false;
                AlreadyExtendsLabel.Show();
                PLIST_EXPLAIN.Show();
            }
            else
            {
                PLISTExtendsButton.Enabled = true;
                AlreadyExtendsLabel.Hide();
                PLIST_EXPLAIN.Show();
            }

            Debug.Assert(SearchType != MapPointerForm.PLIST_TYPE.UNKNOWN);
            uint max = MapPointerForm.GetDataCount(this.SearchType) - 1;

            PLISTnumericUpDown.Maximum = max;

            PLISTnumericUpDown_ValueChanged(null, null);
        }
        static List <U.AddrResult> MakeTileAnimation2()
        {
            Dictionary <uint, bool> alreadFound = new Dictionary <uint, bool>();
            List <U.AddrResult>     ret_list    = new List <U.AddrResult>();
            uint mapmax = MapSettingForm.GetDataCount();

            for (uint i = 0; i < mapmax; i++)
            {
                MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID(i);
                if (plist.anime2_plist == 0)
                {
                    continue;
                }
                if (alreadFound.ContainsKey(plist.anime2_plist))
                {
                    continue;
                }

                uint   addr = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.ANIMATION2, plist.anime2_plist);
                string name = R._("タイルアニメーション2 パレットアニメ:{0}", U.ToHexString(plist.anime2_plist));
                if (addr == U.NOT_FOUND)
                {
                    name += R._("(破損)");
                }
                U.AddrResult ar = new U.AddrResult(addr, name, plist.anime2_plist);
                ret_list.Add(ar);

                alreadFound[plist.anime2_plist] = true;
            }
            return(ret_list);
        }
        //アニメーション2の割り当て
        public static uint PreciseMapTileAnimation2Area(uint mapid)
        {
            MapPointerNewPLISTPopupForm f = (MapPointerNewPLISTPopupForm)InputFormRef.JumpFormLow <MapPointerNewPLISTPopupForm>();

            f.Init(MapPointerForm.PLIST_TYPE.ANIMATION2);
            DialogResult dr = f.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }

            uint plist = f.GetSelectPLIST();

            Undo.UndoData undodata = Program.Undo.NewUndoData("Precise ANIMATION2 Area", mapid.ToString("X"));

            //PALデータ 4つ
            byte[] data = new byte[2 * 4];
            U.write_u16(data, 0, 0x16);
            U.write_u16(data, 2, 0x9D);
            U.write_u16(data, 4, 0x17F);
            U.write_u16(data, 6, 0xA1F);

            uint palette_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (palette_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            //パレット領域を新規に割り当てる.
            data = new byte[8 * 2];
            U.write_p32(data, 0, palette_addr);
            U.write_u8(data, 4, 0x13); //アニメ感覚
            U.write_u8(data, 5, 0x4);  //個数
            U.write_u8(data, 6, 0x3C); //書き換え開始パレット

            uint write_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (write_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.ANIMATION2, plist, write_addr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            Program.Undo.Push(undodata);

            return(plist);
        }
示例#8
0
        private void ExportGif(string filename)
        {
            uint mapid = this.MapPictureBox.GetMapID();

            if (mapid == U.NOT_FOUND)
            {
                return;
            }
            MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID(mapid);
            if (plist.palette_plist == 0)
            {
                return;
            }
            uint palette = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, plist.palette_plist);

            if (palette == U.NOT_FOUND)
            {
                return;
            }
            int palette_index = SamplePaletteComboBox.SelectedIndex;

            if (palette_index < 0)
            {
                palette_index = 0;
            }

            uint addr = InputFormRef.BaseAddress;

            if (!U.isSafetyOffset(addr))
            {
                return;
            }

            //同じアニメを何度も出力しないように記録する.
            List <ImageUtilAnimeGif.Frame> bitmaps = new List <ImageUtilAnimeGif.Frame>();

            for (int i = 0; i < InputFormRef.DataCount; i++, addr += InputFormRef.BlockSize)
            {
                uint wait   = Program.ROM.u16(addr + 0);
                uint length = Program.ROM.u16(addr + 2);
                uint p4     = Program.ROM.p32(addr + 4);
                if (!U.isSafetyOffset(p4))
                {
                    continue;
                }

                MapSettingForm.MapAnimations anime = new MapSettingForm.MapAnimations();
                anime.change_bitmap_bytes = GetTileAnime1(p4, length);

                Bitmap mapBitmap = MapSettingForm.DrawMap(mapid, anime);
                bitmaps.Add(new ImageUtilAnimeGif.Frame(mapBitmap, wait));
            }

            //アニメgif生成
            ImageUtilAnimeGif.SaveAnimatedGif(filename, bitmaps);
            U.SelectFileByExplorer(filename);
        }
示例#9
0
        private void PLISTExtendsButton_Click(object sender, EventArgs e)
        {
            MapPointerForm f = (MapPointerForm)InputFormRef.JumpForm <MapPointerForm>();

            f.PushSplitButton((s, ee) => {
                InitUI();
                f.Close();
                return;
            });
        }
        string PlistToName(uint plist)
        {
            Debug.Assert(SearchType != MapPointerForm.PLIST_TYPE.UNKNOWN);

            if (plist == 0)
            {
                IsAlreadyUse = true;
                return(R._("PLIST=0は、書き込み禁止です。"));
            }
            List <uint> maps;

            if (MapPointerForm.IsPlistSplits())
            {//分割しているので、マップ変化だけを調べる.
                maps = MapSettingForm.GetMapIDsWherePlist(this.SearchType, plist);
                if (maps.Count < 1)
                {
                    if (this.SearchType == MapPointerForm.PLIST_TYPE.PALETTE)
                    {//パレットはオブジェクトも調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.OBJECT, plist);
                    }
                    else if (this.SearchType == MapPointerForm.PLIST_TYPE.OBJECT)
                    {//オブジェクトはパレットも調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.PALETTE, plist);
                    }
                    if (this.SearchType == MapPointerForm.PLIST_TYPE.ANIMATION)
                    {//ANIMATION1はANIMATION2も調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.ANIMATION2, plist);
                    }
                    else if (this.SearchType == MapPointerForm.PLIST_TYPE.ANIMATION2)
                    {//ANIMATION2はANIMATION1も調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.ANIMATION, plist);
                    }
                }
            }
            else
            {//分割していないので、全部調べる必要がある
                maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.UNKNOWN, plist);
            }
            if (maps.Count >= 1)
            {
                IsAlreadyUse = true;
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < maps.Count; i++)
                {
                    if (i != 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append(MapSettingForm.GetMapName(maps[i]));
                }
                return(R._("既に利用されています。\r\n利用マップ:{0}", sb.ToString()));
            }
            IsAlreadyUse = false;
            return(R._("マップ設定では参照されていません。\r\n(このPLISTの利用を推奨します)"));
        }
示例#11
0
        public static uint GetEventByMapID(uint mapid)
        {
            uint wmapid = MapSettingForm.GetWorldMapEventIDWhereMapID(mapid);

            if (wmapid == 0)
            {//存在しない
                return(U.NOT_FOUND);
            }
            //FE6はPLISTが格納されている.
            return(MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.WORLDMAP_FE6ONLY, wmapid));
        }
示例#12
0
        //マップ領域のベース領域の強制割り当て
        public static uint PreciseMapDataArea(uint mapid)
        {
            MapPointerNewPLISTPopupForm f = (MapPointerNewPLISTPopupForm)InputFormRef.JumpFormLow <MapPointerNewPLISTPopupForm>();

            f.Init(MapPointerForm.PLIST_TYPE.MAP);
            DialogResult dr = f.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }

            uint plist = f.GetSelectPLIST();

            Undo.UndoData undodata = Program.Undo.NewUndoData("Precise MapDataArea", mapid.ToString("X"));


            //マップ領域を新規に割り当てる
            byte[] data = new byte[2 + (15 * 10)];
            data[0] = 15;
            data[1] = 10;

            data = LZ77.compress(data);

            MapSettingForm.PLists plists = MapSettingForm.GetMapPListsWhereMapID(mapid);
            uint map_addr = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.MAP, plists.mappointer_plist);

            if (U.isSafetyOffset(map_addr))
            {//既存マップがあればコピーする.
                uint length = LZ77.getCompressedSize(Program.ROM.Data, map_addr);
                data = Program.ROM.getBinaryData(map_addr, length);
            }

            uint write_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (write_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.MAP, plist, write_addr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            Program.Undo.Push(undodata);

            return(plist);
        }
示例#13
0
        //アニメーションの割り当て
        public static uint PreciseMapTileAnimation1Area(uint mapid)
        {
            MapPointerNewPLISTPopupForm f = (MapPointerNewPLISTPopupForm)InputFormRef.JumpFormLow <MapPointerNewPLISTPopupForm>();

            f.Init(MapPointerForm.PLIST_TYPE.ANIMATION);
            DialogResult dr = f.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }

            uint plist = f.GetSelectPLIST();

            Undo.UndoData undodata = Program.Undo.NewUndoData("Precise ANIMATION1 Area", mapid.ToString("X"));

            //無圧縮bit mapdata
            byte[] data        = new byte[0x1000];
            uint   bitmap_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (bitmap_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            //アニメーション領域を新規に割り当てる.
            data = new byte[8 * 2];
            U.write_u16(data, 0, 0x1C);
            U.write_u16(data, 2, 0x1000);
            U.write_p32(data, 4, bitmap_addr);

            uint write_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (write_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.ANIMATION, plist, write_addr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            Program.Undo.Push(undodata);

            return(plist);
        }
示例#14
0
        //OBJECTの割り当て
        public static uint PreciseObjectArea(uint mapid)
        {
            MapPointerNewPLISTPopupForm f = (MapPointerNewPLISTPopupForm)InputFormRef.JumpFormLow <MapPointerNewPLISTPopupForm>();

            f.Init(MapPointerForm.PLIST_TYPE.OBJECT);
            DialogResult dr = f.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }

            uint plist = f.GetSelectPLIST();

            Undo.UndoData undodata = Program.Undo.NewUndoData("Precise ObjectArea", mapid.ToString("X"));

            //OBJECT領域を新規に割り当てる.
            MapSettingForm.PLists plists = MapSettingForm.GetMapPListsWhereMapID(mapid);
            Bitmap bmp;

            if (plists.obj_plist >= 0x100)
            {//2つのplistが必要だからコピーできない
                bmp = ImageUtil.Blank(32 * 8, 32 * 8);
            }
            else
            {
                bmp = DrawMapChipOnly(plists.obj_plist, plists.palette_plist, null);
            }

            byte[] data = ImageUtil.ImageToByte16Tile(bmp, bmp.Width, bmp.Height);
            data = LZ77.compress(data);

            uint write_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (write_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.OBJECT, plist, write_addr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            Program.Undo.Push(undodata);

            return(plist);
        }
示例#15
0
        static void ExportAll(string filename, InputFormRef ifr, uint mapid, int palette_index)
        {
            uint addr = ifr.BaseAddress;

            if (!U.isSafetyOffset(addr))
            {
                return;
            }

            string dir  = Path.GetDirectoryName(filename);
            string file = Path.GetFileNameWithoutExtension(filename);

            MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID(mapid);
            if (plist.palette_plist == 0)
            {
                return;
            }
            uint palette = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, plist.palette_plist);

            if (palette == U.NOT_FOUND)
            {
                return;
            }

            List <string> lines = new List <string>();

            {
                string line = "//wait\tfilename";
                lines.Add(line);
            }
            for (int i = 0; i < ifr.DataCount; i++, addr += ifr.BlockSize)
            {
                uint w0     = Program.ROM.u16(addr + 0);
                uint length = Program.ROM.u16(addr + 2);
                uint p4     = Program.ROM.p32(addr + 4);
                if (!U.isSafetyOffset(p4))
                {
                    continue;
                }

                Bitmap bitmap      = GetTileAnime1(p4, length, palette, palette_index);
                string imgfilename = file + "_" + i.ToString("000") + ".png";
                bitmap.Save(Path.Combine(dir, imgfilename));

                string line = w0 + "\t" + imgfilename + "\t" + length;
                lines.Add(line);
            }

            File.WriteAllLines(filename, lines);
        }
示例#16
0
        void SelectMapID(uint mapid)
        {
            MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID((uint)mapid);
            uint change_plist_addr      = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CHANGE, plist.mapchange_plist);

            uint selected = InputFormRef.AddrToSelect(this.AddressList, change_plist_addr);

            if (selected == U.NOT_FOUND)
            {
                return;
            }

            U.SelectedIndexSafety(this.AddressList, selected);
        }
示例#17
0
        //マップIDからマップ変化addrを取得する.
        public static uint GetMapChangeAddrWhereMapID(uint mapid, out uint out_pointer)
        {
            InputFormRef InputFormRef = Init(null);
            uint         addr         = InputFormRef.IDToAddr(mapid);

            if (!U.isSafetyOffset(addr))
            {
                out_pointer = U.NOT_FOUND;
                return(U.NOT_FOUND);
            }
            uint mapchange_plist = (uint)Program.ROM.u8(addr + 11);
            uint mapchangeaddr   = MapPointerForm.PlistToOffsetAddrFast(MapPointerForm.PLIST_TYPE.CHANGE, mapchange_plist, out out_pointer);

            return(mapchangeaddr);
        }
示例#18
0
        //マップの配置データの読込
        public static byte[] UnLZ77MapData(uint mappointer_plist)
        {
            uint mappointer_offset = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.MAP, mappointer_plist);

            if (!U.isSafetyOffset(mappointer_offset))
            {
                return(null);
            }

            byte[] mappointerUZ = LZ77.decompress(Program.ROM.Data, mappointer_offset); //tsa
            if (mappointerUZ.Length <= 0)
            {
                return(null);
            }
            return(mappointerUZ);
        }
示例#19
0
        //チップセットの読込(マップチップの画像をどう解釈するか定義するデータ)
        public static byte[] UnLZ77ChipsetData(uint config_plist)
        {
            uint config_offset = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CONFIG, config_plist);

            if (!U.isSafetyOffset(config_offset))
            {
                return(null);
            }

            byte[] configUZ = LZ77.decompress(Program.ROM.Data, config_offset);
            if (configUZ.Length <= 0)//TSA
            {
                return(null);
            }
            return(configUZ);
        }
示例#20
0
        //マップIDからイベントaddrを取得する.
        public static uint GetEventAddrWhereMapID(uint mapid, out uint pointer)
        {
            InputFormRef InputFormRef = Init(null);
            uint         addr         = InputFormRef.IDToAddr(mapid);

            if (!U.isSafetyOffset(addr))
            {
                pointer = U.NOT_FOUND;
                return(U.NOT_FOUND);
            }

            uint event_plist = Program.ROM.u8(addr + Program.ROM.RomInfo.map_setting_event_plist_pos());
            uint eventaddr   = MapPointerForm.PlistToOffsetAddrFast(MapPointerForm.PLIST_TYPE.EVENT, event_plist, out pointer);

            return(eventaddr);
        }
示例#21
0
        //パレットの割り当て
        public static uint PrecisePaletteArea(uint mapid)
        {
            MapPointerNewPLISTPopupForm f = (MapPointerNewPLISTPopupForm)InputFormRef.JumpFormLow <MapPointerNewPLISTPopupForm>();

            f.Init(MapPointerForm.PLIST_TYPE.PALETTE);
            DialogResult dr = f.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }

            uint plist = f.GetSelectPLIST();

            Undo.UndoData undodata = Program.Undo.NewUndoData("Precise PaletteArea", mapid.ToString("X"));


            //パレット領域を新規に割り当てる.
            byte[] data = new byte[5 * 2 * 16];

            MapSettingForm.PLists plists = MapSettingForm.GetMapPListsWhereMapID(mapid);
            uint palette_addr            = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, plists.palette_plist);

            if (U.isSafetyOffset(palette_addr))
            {//既存パレットがあればコピーする.
                data = Program.ROM.getBinaryData(palette_addr, data.Length);
            }

            uint write_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (write_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, plist, write_addr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            Program.Undo.Push(undodata);

            return(plist);
        }
示例#22
0
        //マップ変化のベース領域の強制割り当て
        public static uint PreciseChangeListForce(uint mapid)
        {
            MapPointerNewPLISTPopupForm f = (MapPointerNewPLISTPopupForm)InputFormRef.JumpFormLow <MapPointerNewPLISTPopupForm>();

            f.Init(MapPointerForm.PLIST_TYPE.CHANGE);
            DialogResult dr = f.ShowDialog();

            if (dr != System.Windows.Forms.DialogResult.OK)
            {
                return(0);
            }

            uint plist = f.GetSelectPLIST();

            Undo.UndoData undodata = Program.Undo.NewUndoData("Precise MapChange", mapid.ToString("X"));

            byte[] data = new byte[12];
            data[0] = 0xFF; //終端.
            uint write_addr = InputFormRef.AppendBinaryData(data, undodata);

            if (write_addr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.CHANGE, plist, write_addr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }
            r = MapSettingForm.WriteMapChangePlist(mapid, plist, undodata);
            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(0);
            }

            Program.Undo.Push(undodata);

            return(plist);
        }
示例#23
0
        static InputFormRef Init(Form self)
        {
            return(new InputFormRef(self
                                    , ""
                                    , Program.ROM.RomInfo.map_setting_pointer()
                                    , Program.ROM.RomInfo.map_setting_datasize()
                                    , (int i, uint addr) =>
            {
                //0 がポインタであればデータがあると考える.
                return U.isPointer(Program.ROM.u32(addr + 0));
            }
                                    , (int i, uint addr) =>
            {
                MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID((uint)i);
                uint change_plist_addr = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CHANGE, plist.mapchange_plist);
                string name = MapSettingForm.GetMapName((uint)i);

                return new U.AddrResult(change_plist_addr, name, (uint)i);
            }
                                    ));
        }
        bool WriteMapChipPalette(Bitmap bitmap, bool importObjWithPalette, Undo.UndoData undodata)
        {
            const int palette_count = MAX_MAP_PALETTE_COUNT;

            if (importObjWithPalette)
            {//パレットもインポートする場合
                //パレットの交換
                this.MapObjImage = bitmap;
                U.ForceUpdate(this.PaletteTypeCombo, 0);
                U.ForceUpdate(this.PaletteCombo, 0);

                //パレット情報の書き込み.
                uint palette_plist   = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist;
                uint palette_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist);
                if (palette_address == 0)
                {//未割り当てならば新規確保しようか
                    palette_address = InputFormRef.AppendBinaryData(PaletteFormRef.NewNullPalette(palette_count), undodata);
                }
                PFR.MakePaletteBitmapToROM(bitmap, palette_address, palette_count, undodata);

                //拡張領域に書き込んでいる可能性もあるので plstを更新する.
                bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist, palette_address, undodata);
                if (!r)
                {
                    Program.Undo.Rollback(undodata);
                    return(false);
                }

                PaletteAddress.Value = palette_address;
            }
            else
            {//パレットはインポートしない場合
                //パレット情報の継承.
                bitmap.Palette = this.MapObjImage.Palette;
                //obj Bitmap交換
                this.MapObjImage = bitmap;
            }

            return(true);
        }
示例#25
0
        private void AddressList_SelectedIndexChanged(object sender, EventArgs e)
        {
            uint mapid = this.MapPictureBox.GetMapID();

            if (mapid == U.NOT_FOUND)
            {
                return;
            }
            MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID(mapid);
            if (plist.palette_plist == 0)
            {
                return;
            }
            uint palette = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, plist.palette_plist);

            if (palette == U.NOT_FOUND)
            {
                return;
            }

            int palette_index = SamplePaletteComboBox.SelectedIndex;

            if (palette_index < 0)
            {
                palette_index = 0;
            }



            this.ChangePaletteBitmap    = GetTileAnime1((uint)P4.Value, (uint)W2.Value, palette, palette_index);
            this.X_SAMPLE_BIG_PIC.Image = this.ChangePaletteBitmap;

            MapSettingForm.MapAnimations anime = new MapSettingForm.MapAnimations();
            anime.change_bitmap_bytes = GetTileAnime1((uint)P4.Value, (uint)W2.Value);

            //マップの再描画
            this.MapPictureBox.UpdateAnime(anime);
        }
示例#26
0
        //エラー検出
        public static void MakeCheckErrors(uint mapid, List <FELint.ErrorSt> errors)
        {
            List <uint> tracelist = new List <uint>();
            uint        wmapid    = MapSettingForm.GetWorldMapEventIDWhereMapID(mapid);

            if (wmapid == 0)
            {//存在しない
                return;
            }
            //FE6はPLISTが格納されている.
            uint p;
            uint event_addr = MapPointerForm.PlistToOffsetAddrFast(MapPointerForm.PLIST_TYPE.WORLDMAP_FE6ONLY, wmapid, out p);

            if (event_addr == U.NOT_FOUND)
            {
                errors.Add(new FELint.ErrorSt(FELint.Type.MAPSETTING_WORLDMAP, U.NOT_FOUND
                                              , R._("対応するワールドマップイベント({0})が存在しません。", U.To0xHexString(wmapid))));
            }
            else
            {
                FELint.CheckEvent(event_addr, errors, FELint.Type.WORLDMAP_EVENT, p, true, tracelist);
            }
        }
示例#27
0
        //全データの取得
        public static void MakeAllDataLength(List <Address> list)
        {
            List <uint> tracelist = new List <uint>();
            uint        mapmax    = MapSettingForm.GetDataCount();

            for (uint mapid = 0; mapid < mapmax; mapid++)
            {
                uint wmapid = MapSettingForm.GetWorldMapEventIDWhereMapID(mapid);
                if (wmapid == 0)
                {//存在しない
                    continue;
                }
                //FE6はPLISTが格納されている.
                uint p;
                uint event_addr = MapPointerForm.PlistToOffsetAddrFast(MapPointerForm.PLIST_TYPE.WORLDMAP_FE6ONLY, wmapid, out p);
                if (event_addr == U.NOT_FOUND)
                {
                    continue;
                }

                string name = "WorldMapEvent " + U.To0xHexString(mapid) + " ";
                EventScriptForm.ScanScript(list, p, true, true, name, tracelist);
            }
        }
示例#28
0
        private void PaletteWriteButton_Click(object sender, EventArgs e)
        {
            if (this.MapStyle.SelectedIndex < 0)
            {
                return;
            }
            uint palette_plist = this.MapEditConf[this.MapStyle.SelectedIndex].palette_plist;
            int  palette_count = MAX_MAP_PALETTE_COUNT;

            Undo.UndoData undodata = Program.Undo.NewUndoData(this);

            //パレット情報の書き込み.
            uint palette_address = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist);

            if (palette_address == 0)
            {//未割り当てならば新規確保しようか
                palette_address = InputFormRef.AppendBinaryData(PaletteFormRef.NewNullPalette(palette_count), undodata);
            }

            PFR.MakePaletteColorPaletteToROM(this.MapObjImage.Palette, palette_address, palette_count, undodata);
            InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false);

            //拡張領域に書き込んでいる可能性もあるので plstを更新する.
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.PALETTE, palette_plist, palette_address, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return;
            }

            Program.Undo.Push(undodata);

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }
示例#29
0
        public static void MakeCheckError(uint mapid, List <FELint.ErrorSt> errors)
        {
            InputFormRef N_InputFormRef = N_Init(null);

            MapSettingForm.PLists plists = MapSettingForm.GetMapPListsWhereMapID(mapid);
            if (plists.mapchange_plist == 0)
            {//マップ変化がない
                return;
            }

            uint change_addr = MapPointerForm.PlistToOffsetAddr(MapPointerForm.PLIST_TYPE.CHANGE, plists.mapchange_plist);

            if (!U.isSafetyOffset(change_addr))
            {//マップ設定の方でトラップするので不要.
                return;
            }
            byte[] configUZ = ImageUtilMap.UnLZ77ChipsetData(plists.config_plist);
            if (configUZ == null)
            {//マップ設定の方でトラップするので不要.
                return;
            }

            //マップサイズ
            int mapwidth;
            int mapheight;

            ImageUtilMap.UnLZ77MapDataUShort(plists.mappointer_plist, out mapwidth, out mapheight);

            bool isFE6 = Program.ROM.RomInfo.version() == 6;

            N_InputFormRef.ReInit(change_addr);

            List <uint> useNumber = new List <uint>();
            uint        addr      = N_InputFormRef.BaseAddress;

            for (int i = 0; i < N_InputFormRef.DataCount; i++, addr += N_InputFormRef.BlockSize)
            {
                uint number = Program.ROM.u8(0 + addr);
                if (useNumber.IndexOf(number) >= 0)
                {
                    errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
                                                  , R._("マップ変化({0})のIDが重複しています", U.To0xHexString(number))));
                    continue;
                }
                if (number > 0x7f)
                {
                    errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
                                                  , R._("マップ変化({0})のIDが、0x7Fを超えています。\r\nマップ変化IDは、0x7F以下でなければなりません。", U.To0xHexString(number))));
                    continue;
                }
                uint x       = Program.ROM.u8(1 + addr);
                uint y       = Program.ROM.u8(2 + addr);
                uint width   = Program.ROM.u8(3 + addr);
                uint height  = Program.ROM.u8(4 + addr);
                uint pointer = Program.ROM.u32(8 + addr);

//マップ変化を使いまわしているところが軒並みエラーになるのでやめておこう...
//                if (x + width > mapwidth)
//                {
//                    errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
//                        , R._("マップ変化({0})の幅(X:{1} Width:{2})は、マップの幅({3})より大きいです", number, x , width, mapwidth)));
//                }
//                if (y + height > mapheight)
//                {
//                    if (isFE6 && mapid == 0x28 && addr == 0x687A94)
//                    {
//                        //FE6にはマップ変化リストを間違えて指定している場所があるので無視する.
//                        continue;
//                    }
//                    errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
                //                        , R._("マップ変化({0})の高さ(Y:{1} Height:{2})は、マップの高さ({3})より大きいです", U.To0xHexString(number), y, height, mapheight)));
//                }

                if (pointer == 0)
                {//マップ変化ポインタ 0 を容認する.
                    continue;
                }
                if (!U.isSafetyPointer(pointer))
                {
                    errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
                                                  , R._("マップ変化({0})のポインタ({1})が危険です。", U.To0xHexString(number), U.To0xHexString(pointer))));
                    continue;
                }

                //ポインタ先の検証.
                uint mapAddr   = U.toOffset(pointer);
                uint limitAddr = mapAddr + (2 * width * height);
                if (!U.isSafetyOffset(limitAddr - 1))
                {
                    errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
                                                  , R._("マップ変化({0})のポインタ({1})か、マップ変化のサイズの指定が正しくありません。", U.To0xHexString(number), U.To0xHexString(pointer))));
                    continue;
                }

                for (; mapAddr < limitAddr; mapAddr += 2)
                {
                    int mapData = (int)Program.ROM.u16(mapAddr);
                    if (!ImageUtilMap.IsCorrectMapChip(mapData, configUZ, isFE6))
                    {
                        errors.Add(new FELint.ErrorSt(FELint.Type.MAPCHANGE, addr
                                                      , R._("マップ変化({0})のポインタ({1})先のデータで、不正なタイルデータ({2})。", U.To0xHexString(number), U.To0xHexString(pointer), U.To0xHexString(mapData))));
                        break;
                    }
                }
            }
        }
示例#30
0
        //プログラムからのデータ拡張
        public static bool ResizeChangeList(uint mapid, uint newcount)
        {
            List <ChangeSt> changeList = new List <ChangeSt>();

            uint change_addr = MapSettingForm.GetMapChangeAddrWhereMapID(mapid);

            if (change_addr == U.NOT_FOUND)
            {
                return(false);
            }

            InputFormRef N_InputFormRef = N_Init(null);

            N_InputFormRef.ReInit(change_addr);

            uint olddatasize = N_InputFormRef.DataCount * N_InputFormRef.BlockSize;
            uint newdatasize = (newcount + 1) * N_InputFormRef.BlockSize;

            if (newdatasize < olddatasize)
            {//新しく確保するテーブル数が小さい場合
             //特に何もしない.
                return(true);
            }

            //既存データの取得
            byte[] oldDataByte = Program.ROM.getBinaryData(change_addr, olddatasize);
            //新規
            byte[] newDataByte = new byte[newdatasize];
            Array.Copy(oldDataByte, newDataByte, olddatasize);

            //新規に確保した領域にindex番号等を振る.
            int i = (int)N_InputFormRef.DataCount;

            for (; i < newcount; i++)
            {
                uint offset = (uint)(i * N_InputFormRef.BlockSize);
                U.write_u8(newDataByte, (uint)offset + 0, (uint)i);
                U.write_u8(newDataByte, (uint)offset + 3, 1); //サイズw
                U.write_u8(newDataByte, (uint)offset + 4, 1); //サイズh
            }
            //終端データ(newdata+1で確保しているため安全)
            U.write_u8(newDataByte, (uint)(i * N_InputFormRef.BlockSize), (uint)0xff);

            Undo.UndoData undodata = Program.Undo.NewUndoData("Resize MapChange", mapid.ToString("X"), newcount.ToString("X"));

            //新規領域の確保
            uint newaddr = InputFormRef.AppendBinaryData(newDataByte, undodata);

            if (newaddr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }

            //PLISTのポインタを書き換える.
            MapSettingForm.PLists plist = MapSettingForm.GetMapPListsWhereMapID(mapid);
            bool r = MapPointerForm.Write_Plsit(MapPointerForm.PLIST_TYPE.CHANGE, plist.mapchange_plist, newaddr, undodata);

            if (!r)
            {
                Program.Undo.Rollback(undodata);
                return(false);
            }

            Program.Undo.Push(undodata);

            return(true);
        }