Example #1
0
        static uint PlistToOffsetAddr(MapPointerForm.PLIST_TYPE type, uint plist, out uint out_pointer)
        {
            InputFormRef InputFormRef = Init(null, IsPlistSplits());

            InputFormRef.ReInitPointer(GetBasePointer(type));

            uint addr = InputFormRef.IDToAddr(plist);

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

            uint p = Program.ROM.p32(addr);

            if (p == 0)
            {
                out_pointer = addr;
                return(p);
            }

            if (!U.isSafetyOffset(p))
            {
                out_pointer = U.NOT_FOUND;
                return(U.NOT_FOUND);
            }
            out_pointer = addr;
            return(p);
        }
Example #2
0
        public static uint PlistToOffsetAddrFast(MapPointerForm.PLIST_TYPE type, uint plist, out uint out_pointer)
        {
            //PLISTは何度もスキャンするので、キャッシュする.
            uint key = ((uint)type << 24) + plist;
            uint pointer;
            uint addr;

            if (PlistCache.TryGetValue(key, out pointer))
            {
                uint p = Program.ROM.p32(pointer);
                if (p != 0)
                {
                    out_pointer = pointer;
                    return(p);
                }
            }

            addr = PlistToOffsetAddr(type, plist, out pointer);
            if (addr == U.NOT_FOUND || pointer == U.NOT_FOUND)
            {
                out_pointer = pointer;
                return(addr);
            }
            PlistCache[key] = pointer;

            out_pointer = pointer;
            return(addr);
        }
Example #3
0
        public static uint GetDataCount(MapPointerForm.PLIST_TYPE type)
        {
            InputFormRef InputFormRef = Init(null, IsPlistSplits());

            InputFormRef.ReInitPointer(GetBasePointer(type));

            return(InputFormRef.DataCount);
        }
Example #4
0
        static uint GetBasePointer(MapPointerForm.PLIST_TYPE type)
        {
            if (type == PLIST_TYPE.CONFIG)
            {
                return(Program.ROM.RomInfo.map_config_pointer);
            }
            else if (type == PLIST_TYPE.ANIMATION)
            {
                return(Program.ROM.RomInfo.map_tileanime1_pointer);
            }
            else if (type == PLIST_TYPE.ANIMATION2)
            {
                return(Program.ROM.RomInfo.map_tileanime2_pointer);
            }
            else if (type == PLIST_TYPE.OBJECT)
            {
                return(Program.ROM.RomInfo.map_obj_pointer);
            }
            else if (type == PLIST_TYPE.PALETTE)
            {
                return(Program.ROM.RomInfo.map_pal_pointer);
            }
            else if (type == PLIST_TYPE.MAP)
            {
                return(Program.ROM.RomInfo.map_map_pointer_pointer);
            }
            else if (type == PLIST_TYPE.CHANGE)
            {
                return(Program.ROM.RomInfo.map_mapchange_pointer);
            }
            else if (type == PLIST_TYPE.EVENT)
            {
                return(Program.ROM.RomInfo.map_event_pointer);
            }
            else if (type == PLIST_TYPE.WORLDMAP_FE6ONLY)
            {
                Debug.Assert(Program.ROM.RomInfo.version == 6);
                return(Program.ROM.RomInfo.map_worldmapevent_pointer);
            }

            return(Program.ROM.RomInfo.map_config_pointer);
        }
Example #5
0
        //plist先へ書き込み.
        public static bool Write_Plsit(MapPointerForm.PLIST_TYPE type, uint mappointer_plist, uint newaddr, Undo.UndoData undodata)
        {
            if (mappointer_plist == 0)
            {//PLIST==0 への書き込みはできません.
                R.ShowStopError("PLIST=0 には、書き込むことができません。\r\n常に0にする必要があります。\r\n");
                return(false);
            }

            InputFormRef InputFormRef = Init(null, IsPlistSplits());

            InputFormRef.ReInitPointer(GetBasePointer(type));

            uint addr = InputFormRef.IDToAddr(mappointer_plist);

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

            Program.ROM.write_p32(addr, newaddr, undodata);
            return(true);
        }
Example #6
0
        uint PListSplitsExpandsOne(MapPointerForm.PLIST_TYPE type, Undo.UndoData undodata)
        {
            Debug.Assert(type != PLIST_TYPE.ANIMATION2); //Animation1と一緒に処理しないといけない
            Debug.Assert(type != PLIST_TYPE.PALETTE);    //OBJECTと一緒に処理しないといけない

            InputFormRef InputFormRef = Init(null, false);

            InputFormRef.ReInitPointer(GetBasePointer(type));

            byte[] newArray = new byte[4 * (256)];
            List <U.AddrResult> mapSetting = MapSettingForm.MakeMapIDList();
            int mapmax = mapSetting.Count;

            for (int mapid = 0; mapid < mapmax; mapid++)
            {
                if (type == PLIST_TYPE.WORLDMAP_FE6ONLY)
                {
                    Debug.Assert(Program.ROM.RomInfo.version == 6);
                    uint wmapevent_plist = MapSettingForm.GetWorldMapEventIDWhereAddr(mapSetting[mapid].addr);

                    PListSplitExpandsOneConvertPointer(wmapevent_plist, InputFormRef, newArray);
                    continue;
                }

                MapSettingForm.PLists plists = MapSettingForm.GetMapPListsWhereAddr(mapSetting[mapid].addr);
                if (type == PLIST_TYPE.CHANGE)
                {
                    PListSplitExpandsOneConvertPointer(plists.mapchange_plist, InputFormRef, newArray);
                }
                else if (type == PLIST_TYPE.EVENT)
                {
                    PListSplitExpandsOneConvertPointer(plists.event_plist, InputFormRef, newArray);
                }
                else if (type == PLIST_TYPE.MAP)
                {
                    PListSplitExpandsOneConvertPointer(plists.mappointer_plist, InputFormRef, newArray);
                }
                else if (type == PLIST_TYPE.CONFIG)
                {
                    PListSplitExpandsOneConvertPointer(plists.config_plist, InputFormRef, newArray);
                }
                else if (type == PLIST_TYPE.ANIMATION)
                {
                    PListSplitExpandsOneConvertPointer(plists.anime1_plist, InputFormRef, newArray);
                    PListSplitExpandsOneConvertPointer(plists.anime2_plist, InputFormRef, newArray);
                }
                else
                {
                    uint obj1_plist = (plists.obj_plist & 0xFF);
                    uint obj2_plist = (plists.obj_plist >> 8) & 0xFF; //FE8にはないが FE7は、 plistを2つ設定できることがある.

                    PListSplitExpandsOneConvertPointer(obj1_plist, InputFormRef, newArray);
                    PListSplitExpandsOneConvertPointer(obj2_plist, InputFormRef, newArray);

                    PListSplitExpandsOneConvertPointer(plists.palette_plist, InputFormRef, newArray);
                }
            }
            //終端の0xFFFFFFFFを念のため入れておきます.
//            U.write_u32(newArray, 256 * 4, U.NOT_FOUND);

            uint newpos = InputFormRef.AppendBinaryData(newArray, undodata);

            if (newpos == U.NOT_FOUND)
            {
                throw new PLISTExpandsException(R._("PLIST拡張に失敗しました。\r\ntype={0}\r\nnewaddr=NOT_FOUND", type.ToString()));
            }

            if (type == PLIST_TYPE.CONFIG)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_config_pointer, newpos, undodata);
            }
            else if (type == PLIST_TYPE.ANIMATION)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_tileanime1_pointer, newpos, undodata);
                Program.ROM.write_p32(Program.ROM.RomInfo.map_tileanime2_pointer, newpos, undodata);
            }
            else if (type == PLIST_TYPE.OBJECT)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_obj_pointer, newpos, undodata);
                Program.ROM.write_p32(Program.ROM.RomInfo.map_pal_pointer, newpos, undodata);
            }
            else if (type == PLIST_TYPE.MAP)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_map_pointer_pointer, newpos, undodata);
            }
            else if (type == PLIST_TYPE.CHANGE)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_mapchange_pointer, newpos, undodata);
            }
            else if (type == PLIST_TYPE.EVENT)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_event_pointer, newpos, undodata);
            }
            else if (type == PLIST_TYPE.WORLDMAP_FE6ONLY)
            {
                Program.ROM.write_p32(Program.ROM.RomInfo.map_worldmapevent_pointer, newpos, undodata);
            }
            else
            {
                Debug.Assert(false);
            }
            return(newpos);
        }
Example #7
0
        public static uint PlistToOffsetAddr(MapPointerForm.PLIST_TYPE type, uint plist)
        {
            uint pointer;

            return(PlistToOffsetAddrFast(type, plist, out pointer));
        }
Example #8
0
        static string GetPListNameSplited(uint plist, uint baseaddr, List <U.AddrResult> mapSetting)
        {
            //分割している場合
            if (plist == 0)
            {//0番はnull
                return("NULL");
            }

            MapPointerForm.PLIST_TYPE type = ConvertBaseAddrToType(baseaddr);
            for (int mapid = 0; mapid < mapSetting.Count; mapid++)
            {
                uint addr = mapSetting[mapid].addr;
                MapSettingForm.PLists plists = MapSettingForm.GetMapPListsWhereAddr(addr);
                if (plists.anime1_plist == plist && type == PLIST_TYPE.ANIMATION)
                {
                    return("ANIME1 " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.anime2_plist == plist && type == PLIST_TYPE.ANIMATION)
                {//ANIME2はANIMEと共有
                    return("ANIME2 " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.config_plist == plist && type == PLIST_TYPE.CONFIG)
                {
                    return("CONFIG " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.event_plist == plist && type == PLIST_TYPE.EVENT)
                {
                    return("EVENT " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.mapchange_plist == plist && type == PLIST_TYPE.CHANGE)
                {
                    return("MAPCHANGE " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.mappointer_plist == plist && type == PLIST_TYPE.MAP)
                {
                    return("MAP " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.palette_plist == plist && type == PLIST_TYPE.OBJECT)
                {//OBJECTとPALは共有
                    return("PAL " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (plists.palette2_plist == plist && type == PLIST_TYPE.OBJECT)
                {//OBJECTとPALは共有
                    return("PAL2 " + MapSettingForm.GetMapNameWhereAddr(addr));
                }

                uint obj_plist_low  = (plists.obj_plist & 0xFF);
                uint obj_plist_high = ((plists.obj_plist >> 8) & 0xFF);
                if (obj_plist_low == plist && type == PLIST_TYPE.OBJECT)
                {
                    return("OBJ " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (obj_plist_high == plist && type == PLIST_TYPE.OBJECT)
                {
                    return("OBJ " + MapSettingForm.GetMapNameWhereAddr(addr));
                }
                if (Program.ROM.RomInfo.version == 6)
                {
                    uint wmapevent_plist = MapSettingForm.GetWorldMapEventIDWhereAddr(addr);
                    if (wmapevent_plist == 0 && type == PLIST_TYPE.WORLDMAP_FE6ONLY)
                    {
                        return("WMEVENT " + MapSettingForm.GetMapNameWhereAddr(addr));
                    }
                }
            }
            return("-EMPTY-");
        }
        //PLSITからマップIDを検索します.
        public static List <uint> GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE type, uint plist)
        {
            Debug.Assert(plist >= 1);

            List <uint>  useMapID     = new List <uint>();
            InputFormRef InputFormRef = Init(null);

            uint addr = InputFormRef.BaseAddress;

            for (int i = 0; i < InputFormRef.DataCount; i++)
            {
                uint obj_plist        = (uint)Program.ROM.u32(addr + 4);
                uint palette_plist    = (uint)Program.ROM.u8(addr + 6);
                uint config_plist     = (uint)Program.ROM.u8(addr + 7);
                uint mappointer_plist = (uint)Program.ROM.u8(addr + 8);
                uint anime1_plist     = (uint)Program.ROM.u8(addr + 9);
                uint anime2_plist     = (uint)Program.ROM.u8(addr + 10);
                uint mapchange_plist  = (uint)Program.ROM.u8(addr + 11);

                uint event_plist         = Program.ROM.u8(addr + Program.ROM.RomInfo.map_setting_event_plist_pos());
                uint worldmapevent_plist = Program.ROM.u8(addr + Program.ROM.RomInfo.map_setting_worldmap_plist_pos());

                if (type == MapPointerForm.PLIST_TYPE.UNKNOWN)
                {//UNKNOWNだと全部知らべます
                    if ((obj_plist & 0xff) == plist ||
                        ((obj_plist >> 8) & 0xff) == plist ||
                        palette_plist == plist ||
                        config_plist == plist ||
                        mappointer_plist == plist ||
                        anime1_plist == plist ||
                        anime2_plist == plist ||
                        mapchange_plist == plist ||
                        event_plist == plist ||
                        worldmapevent_plist == plist
                        )
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.ANIMATION)
                {
                    if (anime1_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.ANIMATION2)
                {
                    if (anime2_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.CHANGE)
                {
                    if (mapchange_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.CONFIG)
                {
                    if (config_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.EVENT)
                {
                    if (event_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.WORLDMAP_FE6ONLY)
                {
                    if (worldmapevent_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.PALETTE)
                {
                    if (palette_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.MAP)
                {
                    if (mappointer_plist == plist)
                    {
                        useMapID.Add((uint)i);
                    }
                }
                else if (type == MapPointerForm.PLIST_TYPE.OBJECT)
                {
                    if ((obj_plist & 0xff) == plist ||
                        ((obj_plist >> 8) & 0xff) == plist
                        )
                    {
                        useMapID.Add((uint)i);
                    }
                }

                addr += InputFormRef.BlockSize;
            }
            return(useMapID);
        }
Example #10
0
        string PlistToName(uint plist, MapPointerForm.PLIST_TYPE type)
        {
            Debug.Assert(type != MapPointerForm.PLIST_TYPE.UNKNOWN);

            if (plist == 0)
            {
                return("");
            }
            List <uint> maps;

            if (MapPointerForm.IsPlistSplits())
            {//分割しているので、マップ変化だけを調べる.
                maps = MapSettingForm.GetMapIDsWherePlist(type, plist);
                if (maps.Count < 1)
                {
                    if (type == MapPointerForm.PLIST_TYPE.PALETTE)
                    {//パレットはオブジェクトも調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.OBJECT, plist);
                    }
                    else if (type == MapPointerForm.PLIST_TYPE.OBJECT)
                    {//オブジェクトはパレットも調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.PALETTE, plist);
                    }
                    if (type == MapPointerForm.PLIST_TYPE.ANIMATION)
                    {//ANIMATION1はANIMATION2も調べる
                        maps = MapSettingForm.GetMapIDsWherePlist(MapPointerForm.PLIST_TYPE.ANIMATION2, plist);
                    }
                    else if (type == 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)
            {
                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._("利用マップ:{0}", sb.ToString()));
            }

            if (type == MapPointerForm.PLIST_TYPE.PALETTE)
            {
                if (this.OBJ1numericUpDown.Value == plist ||
                    this.OBJ2numericUpDown.Value == plist
                    )
                {
                    return(R._("{0}と重複しています。\r\n未使用のPLISTですが、データを共有する{1}と同じ番号を利用しているため、利用できません。", R._("オブジェクト"), R._("パレット")));
                }
            }
            else if (type == MapPointerForm.PLIST_TYPE.OBJECT)
            {
                if (this.PALnumericUpDown.Value == plist)
                {
                    return(R._("{0}と重複しています。\r\n未使用のPLISTですが、データを共有する{1}と同じ番号を利用しているため、利用できません。", R._("パレット"), R._("オブジェクト")));
                }
            }
            else if (type == MapPointerForm.PLIST_TYPE.ANIMATION)
            {
                if (this.ANIME2numericUpDown.Value == plist)
                {
                    return(R._("{0}と重複しています。\r\n未使用のPLISTですが、データを共有する{1}と同じ番号を利用しているため、利用できません。", R._("タイルアニメーション2"), R._("タイルアニメーション1")));
                }
            }
            else if (type == MapPointerForm.PLIST_TYPE.ANIMATION2)
            {
                if (this.ANIME1numericUpDown.Value == plist)
                {
                    return(R._("{0}と重複しています。\r\n未使用のPLISTですが、データを共有する{1}と同じ番号を利用しているため、利用できません。", R._("タイルアニメーション1"), R._("タイルアニメーション2")));
                }
            }

            return(R._("未使用のPLISTです。新規にデザインを作りたいときに利用します。データはマップスタイルエディタからインポートしてください。"));
        }
 public void Init(MapPointerForm.PLIST_TYPE searchType)
 {
     this.SearchType = searchType;
     InitUI();
 }