private void ImportButton2_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this);

            if (bitmap == null)
            {
                return;
            }
            int width  = 10 * 8;
            int height = 2 * 8;

            if (bitmap.Width != width || bitmap.Height != height)
            {
                R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height);
                return;
            }


            //check palette
            {
                string palette_error =
                    ImageUtil.CheckPalette(bitmap.Palette
                                           , Program.ROM.Data
                                           , Program.ROM.RomInfo.image_chapter_title_palette()
                                           , U.NOT_FOUND
                                           );
                if (palette_error != "")
                {
                    ErrorPaletteShowForm f = (ErrorPaletteShowForm)InputFormRef.JumpFormLow <ErrorPaletteShowForm>();
                    f.SetErrorMessage(palette_error);
                    f.SetOrignalImage(ImageUtil.OverraidePalette(bitmap, Program.ROM.Data, Program.ROM.RomInfo.image_chapter_title_palette()));
                    f.SetReOrderImage1(ImageUtil.ReOrderPalette(bitmap, Program.ROM.Data, Program.ROM.RomInfo.image_chapter_title_palette()));
                    f.ShowForceButton();
                    f.ShowDialog();

                    bitmap = f.GetResultBitmap();
                    if (bitmap == null)
                    {
                        return;
                    }
                }
            }

            byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height);

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                //画像等データの書き込み
                Undo.UndoData undodata = Program.Undo.NewUndoData(this);
                this.InputFormRef.WriteImageData(this.P4, image, true, undodata);
                Program.Undo.Push(undodata);
            }
            //ポインタの書き込み
            this.WriteButton.PerformClick();
        }
Esempio n. 2
0
        //リストが拡張されたとき
        void AddressListExpandsEvent(object sender, EventArgs arg)
        {
            InputFormRef.WriteButtonToYellow(WriteButton, false);

            InputFormRef.ExpandsEventArgs eearg = (InputFormRef.ExpandsEventArgs)arg;
            Undo.UndoData undodata = Program.Undo.NewUndoData(this, "ClearAllocMenu");
            AddressListExpandsEventInner(this, eearg, undodata);
            eearg.NewDataCount -= 1;
            eearg.IsReload      = true;
            Program.Undo.Push(undodata);
        }
Esempio n. 3
0
        public void WipeJPClassReelFont(Undo.UndoData undodata)
        {
            List <Address> list = new List <FEBuilderGBA.Address>();

            ToolTranslateROMWipeJPClassReelFont jpClassReel = new ToolTranslateROMWipeJPClassReelFont(undodata);

            jpClassReel.Wipe(list);

            this.Recycle.AddRecycle(list);
            this.Recycle.RecycleOptimize();
        }
        void ImportObj(Bitmap bitmap, bool importObjWithPalette)
        {
            int       width         = 32 * 8;
            int       height        = 32 * 8;
            const int palette_count = MAX_MAP_PALETTE_COUNT;

            if (bitmap.Width != width || bitmap.Height < 128)
            {
                R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height);
                return;
            }
            height = ImageUtil.CalcHeight(width, width * bitmap.Height / 2);

            if (importObjWithPalette)
            {//パレットもインポートする場合 パレット数のチェック.
                int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap);
                if (bitmap_palette_count > palette_count)
                {
                    R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count);
                    return;
                }
                bitmap = PaletteSwapper(bitmap);
            }

            //画像
            byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height);

            //画像等データの書き込み
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);

            bool r = WriteMapChipImage(image, undodata);

            if (!r)
            {
                return;
            }

            r = WriteMapChipPalette(bitmap, importObjWithPalette, undodata);
            if (!r)
            {
                return;
            }

            Program.Undo.Push(undodata);

            //チップセットの更新.
            Chipset_Update();
            SelectedChipset_Update();
            MapStyle_SelectedIndexChanged(null, null);
            InputFormRef.WriteButtonToYellow(this.PaletteWriteButton, false);

            //マップエディタが開いていれば更新する
            MapEditorForm.UpdateMapStyleIfOpen();
        }
Esempio n. 5
0
        public void WipeJPTitle(Undo.UndoData undodata)
        {
            List <Address> list = new List <FEBuilderGBA.Address>();

            ToolTranslateROMWipeJPChapterName jpChapter = new ToolTranslateROMWipeJPChapterName(undodata);

            jpChapter.Wipe(list);

            this.Recycle.AddRecycle(list);
            this.Recycle.RecycleOptimize();
        }
Esempio n. 6
0
        private void ImportButton_Click(object sender, EventArgs e)
        {
            int    width         = 32 * 8;
            int    height        = 20 * 8;
            int    palette_count = 8;
            Bitmap bitmap        = ImageUtil.LoadAndConvertDecolorUI(this, null, width, height, true, palette_count);

            if (bitmap == null)
            {
                return;
            }

            byte[] image; //画像
            byte[] tsa;   //TSA
            string error_string = ImageUtil.ImageToByteHeaderPackedTSA(bitmap, width, height, out image, out tsa);

            if (error_string != "")
            {
                error_string += "\r\n" + DecreaseColorTSAToolForm.GetExplainDecreaseColor();
                R.ShowStopError(error_string);
                return;
            }

            //パレット
            byte[] palette = ImageUtil.ImageToPalette(bitmap, palette_count);

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                //パレット領域が他の領域を浸食していないか確認する
                if (IsPaletteDuplicate((uint)this.P8.Value, (uint)this.AddressList.SelectedIndex))
                {
                    //FE8のパレットはバグっていて、となりのパレットに浸食している.
                    this.P8.Value = 0;
                }
                //画像データの重複を判定する
                if (IsImageDuplicate((uint)this.P0.Value, (uint)this.AddressList.SelectedIndex))
                {
                    this.P0.Value = 0;
                }


                //画像等データの書き込み
                Undo.UndoData undodata = Program.Undo.NewUndoData(this);
                this.InputFormRef.WriteImageData10(this.P0, image, undodata);
                this.InputFormRef.WriteImageData(this.P4, tsa, false, undodata);
                this.InputFormRef.WriteImageData(this.P8, palette, false, undodata);

                Program.Undo.Push(undodata);
            }

            //ポインタの書き込み
            this.WriteButton.PerformClick();
        }
Esempio n. 7
0
        private void BORDER_ImportButton_Click(object sender, EventArgs e)
        {
            int width         = 8 * 32; //256
            int height        = 8 * 4;  //32
            int palette_count = 1;

            if (BORDER_AddressList.SelectedIndex == 1)
            {//グラドだけ //256x40
                height = 8 * 5;
            }

            Bitmap bitmap = ImageUtil.LoadAndConvertDecolorUI(this, null, width, height, true, palette_count);

            if (bitmap == null)
            {
                return;
            }

            byte[] image = ImageUtil.ImageToByte16Tile(bitmap, width, height);

            //check palette
            {
                uint   pal           = Program.ROM.p32(Program.ROM.RomInfo.worldmap_county_border_palette_pointer());
                string palette_error =
                    ImageUtil.CheckPalette(bitmap.Palette
                                           , Program.ROM.Data
                                           , (pal)
                                           , U.NOT_FOUND
                                           );
                if (palette_error != "")
                {
                    ErrorPaletteShowForm f = (ErrorPaletteShowForm)InputFormRef.JumpFormLow <ErrorPaletteShowForm>();
                    f.SetErrorMessage(palette_error);
                    f.SetOrignalImage(ImageUtil.OverraidePalette(bitmap, Program.ROM.Data, pal));
                    f.ShowForceButton();
                    f.ShowDialog();

                    bitmap = f.GetResultBitmap();
                    if (bitmap == null)
                    {
                        return;
                    }
                }
            }

            //画像等データの書き込み
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            this.Border_InputFormRef.WriteImageData(this.BORDER_P0, image, true, undodata);
            Program.Undo.Push(undodata);

            //ポインタの書き込み
            this.BORDER_WriteButton.PerformClick();
        }
Esempio n. 8
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (!U.isSafetyOffset(g_AnimeBaseAddress))
            {
                return;
            }
            uint addr = g_AnimeBaseAddress + (4 * (uint)AddressList.SelectedIndex);

            Undo.UndoData undodata = Program.Undo.NewUndoData(this, "");
            Program.ROM.write_p32(addr, (uint)AnimePointer.Value, undodata);
            Program.Undo.Push(undodata);
        }
        private void WriteButton_Click(object sender, EventArgs e)
        {
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            WMZoomOut.WritePointer(undodata);
            WMZoomNW.WritePointer(undodata);
            WMZoomNE.WritePointer(undodata);
            WMZoomSW.WritePointer(undodata);
            WMZoomSE.WritePointer(undodata);

            Program.Undo.Push(undodata);
            InputFormRef.ShowWriteNotifyAnimation(this, 0);
        }
Esempio n. 10
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            if (this.SelectFontBitmapByte == null || this.SelectFontBitmapByte.Length != 64)
            {
                return;
            }


            string undo_name = "FONT " + this.SearchChar.Text;

            PatchUtil.PRIORITY_CODE priorityCode = PatchUtil.SearchPriorityCode();
            uint search_char = U.ConvertMojiCharToUnitFast(this.SearchChar.Text, priorityCode);

            uint fontlist_pointer = GetFontPointer(this.FontType.SelectedIndex == 0);

            uint prevaddr;
            uint fontaddr = FindFontData(fontlist_pointer, search_char, out prevaddr, priorityCode);

            if (fontaddr == U.NOT_FOUND)
            {     //末尾に追加.
                if (prevaddr == U.NOT_FOUND)
                { //このフォントはルールにより登録できない.日本語フォントで 0x100以下とか.
                    return;
                }
                byte[] newFontData = MakeNewFontData(search_char
                                                     , (uint)this.FontWidth.Value
                                                     , this.SelectFontBitmapByte
                                                     , Program.ROM
                                                     , priorityCode
                                                     );

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

                uint newaddr = InputFormRef.AppendBinaryData(newFontData, undodata);
                if (newaddr == U.NOT_FOUND)
                {//エラー
                    return;
                }

                //ひとつ前のフォントリストのポインタを、現在追加した最後尾にすげかえる.
                Program.ROM.write_u32(prevaddr + 0, U.toPointer(newaddr), undodata);
                fontaddr = newaddr;
            }
            else
            {//更新
                Program.Undo.Push(undo_name, fontaddr, 8 + 64);
                Program.ROM.write_u8(fontaddr + 5, (uint)this.FontWidth.Value);
                Program.ROM.write_range(fontaddr + 8, this.SelectFontBitmapByte); //64バイト書き込み
            }
            this.Address.Value = U.toPointer(fontaddr);
            InputFormRef.ShowWriteNotifyAnimation(this, fontaddr);
        }
Esempio n. 11
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);
        }
Esempio n. 12
0
        private void ImportButton_Click(object sender, EventArgs e)
        {
            Bitmap bitmap = ImageFormRef.ImportFilenameDialog(this);

            if (bitmap == null)
            {
                return;
            }
            int width         = 32 * 8;
            int height        = 20 * 8;
            int palette_count = 1;

            if (bitmap.Width != width || bitmap.Height != height)
            {
                if (bitmap.Width != 30 * 8 || bitmap.Height != height)
                {
                    R.ShowStopError("画像サイズが正しくありません。\r\nWidth:{2} Height:{3} でなければなりません。\r\n\r\n選択された画像のサイズ Width:{0} Height:{1}", bitmap.Width, bitmap.Height, width, height);
                    return;
                }
                //右側に余白がない場合、自動的に挿入する
                bitmap = ImageUtil.Copy(bitmap, 0, 0, width, height);
            }
            int bitmap_palette_count = ImageUtil.GetPalette16Count(bitmap);

            if (bitmap_palette_count > palette_count)
            {
                R.ShowStopError("パレット数が正しくありません。\r\n{1}種類以下(16色*{1}種類) でなければなりません。\r\n\r\n選択された画像のパレット種類:{0}種類", bitmap_palette_count, palette_count);
                return;
            }

            byte[] image; //画像
            byte[] tsa;   //TSA
            string error_string = ImageUtil.ImageToByteHeaderPackedTSA(bitmap, width, height, out image, out tsa);

            if (error_string != "")
            {
                R.ShowStopError(error_string);
                return;
            }

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                //画像等データの書き込み
                Undo.UndoData undodata = Program.Undo.NewUndoData(this);
                this.InputFormRef.WriteImageData(this.P0, image, true, undodata);
                this.InputFormRef.WriteImageData(this.P4, tsa, true, undodata);
                Program.Undo.Push(undodata);
            }

            //ポインタの書き込み
            this.WriteButton.PerformClick();
        }
Esempio n. 13
0
        //日本語フォントを上書きしてもいい場合
        public void WipeJPFont(Form self, Undo.UndoData undodata)
        {
            List <Address> list = new List <FEBuilderGBA.Address>();

            ToolTranslateROMWipeJPFont jpfont = new ToolTranslateROMWipeJPFont(undodata);

            jpfont.AddJPFonts(list);

            this.Recycle.AddRecycle(list);
            this.Recycle.RecycleOptimize();

            jpfont.WriteBackFont(this.Recycle);
        }
Esempio n. 14
0
        public static bool Write_OneData(ChangeSt changest, Undo.UndoData undodata)
        {
            undodata.list.Add(new Undo.UndoPostion(changest.self_change_addr, 12));

            Program.ROM.write_u8(changest.self_change_addr + 0, changest.no);
            Program.ROM.write_u8(changest.self_change_addr + 1, changest.x);
            Program.ROM.write_u8(changest.self_change_addr + 2, changest.y);
            Program.ROM.write_u8(changest.self_change_addr + 3, changest.width);
            Program.ROM.write_u8(changest.self_change_addr + 4, changest.height);
            Program.ROM.write_p32(changest.self_change_addr + 8, changest.addr);

            return(true);
        }
Esempio n. 15
0
        public uint WriteAndWritePointer(uint write_pointer, byte[] write_data, Undo.UndoData undodata)
        {
            uint use_addr = Write(write_data, undodata);

            if (use_addr == U.NOT_FOUND)
            {
                return(U.NOT_FOUND);
            }
            //ポインタ先に書き込んで領域を入れる
            Program.ROM.write_p32(write_pointer, use_addr, undodata);

            return(use_addr);
        }
Esempio n. 16
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            InputFormRef.WriteOnePointer(Program.ROM.RomInfo.worldmap_big_image_pointer(), WMImageMap, undodata);
            InputFormRef.WriteOnePointer(Program.ROM.RomInfo.worldmap_big_image_pointer(), WMImageMap, undodata);
            InputFormRef.WriteOnePointer(Program.ROM.RomInfo.worldmap_big_palette_pointer(), WMPalette, undodata);
            InputFormRef.WriteOnePointer(Program.ROM.RomInfo.worldmap_big_palettemap_pointer(), WMtsaMap, undodata);

            WMEvent.WritePointer(undodata);

            Program.Undo.Push(undodata);
            InputFormRef.ShowWriteNotifyAnimation(this, 0);
        }
        private void IndependenceButton_Click(object sender, EventArgs e)
        {
            if (this.N2_AddressList.SelectedIndex < 0)
            {
                return;
            }
            string name = this.N2_AddressList.Text;

            uint pointer = InputFormRef.SelectToAddr(N2_AddressList);

            if (pointer == U.NOT_FOUND)
            {
                return;
            }
            if (pointer == 0)
            {
                return;
            }
            uint currentP = Program.ROM.p32(U.toOffset(pointer));

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

            if (InputFormRef.BaseAddress != currentP)
            {
                return;
            }

            if (InputFormRef.DataCount == 0)
            {
                DialogResult dr = R.ShowNoYes("リストが0件です。\r\n空のリストを分離させても意味がないのですが、それでも分離独立させますか?");
                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }

            Undo.UndoData undodata = Program.Undo.NewUndoData(this, this.Name + " Independence");

            uint dataSize = (InputFormRef.DataCount + 1) * InputFormRef.BlockSize;

            PatchUtil.WriteIndependence(currentP, dataSize, pointer, name, undodata);
            Program.Undo.Push(undodata);

            InputFormRef.ShowWriteNotifyAnimation(this, currentP);

            this.ReloadListButton.PerformClick();
            U.ReSelectList(N2_AddressList);
        }
Esempio n. 18
0
        private void MapChipImportButton_Click(object sender, EventArgs e)
        {
            if (MapStyleEditorFormWarningVanillaTileOverraideForm.CheckWarningUI((uint)ChipsetConfigAddress.Value))
            {
                return;
            }

            string title  = R._("読み込むファイル名を選択してください");
            string filter = R._("mapchip_config|*.mapchip_config|All files|*");

            string filename;

            if (ImageFormRef.GetDragFilePath(out filename))
            {
            }
            else
            {
                OpenFileDialog open = new OpenFileDialog();
                open.Title  = title;
                open.Filter = filter;
                Program.LastSelectedFilename.Load(this, "mapchip_config", open);
                DialogResult dr = open.ShowDialog();
                if (dr != DialogResult.OK)
                {
                    return;
                }
                if (!U.CanReadFileRetry(open))
                {
                    return;
                }
                Program.LastSelectedFilename.Save(this, "mapchip_config", open);
                filename = open.FileNames[0];
            }

            byte[] map_config = File.ReadAllBytes(filename);
            if (map_config.Length < 9216)
            {
                R.ShowStopError("ファイルサイズが小さすぎます. 9216バイト必要です。");
                return;
            }

            Undo.UndoData undodata = Program.Undo.NewUndoData(this);
            bool          r        = OverraideMapConfig(map_config, undodata);

            if (!r)
            {
                return;
            }

            Program.Undo.Push(undodata);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        private void BORDER_ImportButton_Click(object sender, EventArgs e)
        {
            uint origin_x = (uint)BORDER_W8.Value;
            uint origin_y = (uint)BORDER_W10.Value;

            if (origin_x >= 60)
            {
                origin_x = 60;
            }
            if (origin_y >= 50)
            {
                origin_y = 50;
            }

            byte[] image;
            byte[] oam;
            bool   r = ImageUtilBorderAP.ImportBorder(this,
                                                      origin_x,
                                                      origin_y,
                                                      out image, out oam);

            if (!r)
            {
                return;
            }

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

            //画像の書き込み
            this.Border_InputFormRef.WriteImageData(this.BORDER_P0, image, true, undodata);

            //APの書き込み
            uint newaddr = InputFormRef.WriteBinaryData(this
                                                        , (uint)this.BORDER_P4.Value
                                                        , oam
                                                        , InputFormRef.get_data_pos_callback_ap
                                                        , undodata
                                                        );

            if (newaddr == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return;
            }
            this.BORDER_P4.Value = U.toPointer(newaddr);
            Program.Undo.Push(undodata);

            //ポインタの書き込み
            this.BORDER_WriteButton.PerformClick();
            return;
        }
Esempio n. 21
0
        private void ReCompressButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }
            if (Program.ROM.Modified)
            {
                R.ShowYesNo("編集中のデータがあります。\r\n危険なので、一度ROMを保存してから再度試してください。\r\n");
                return;
            }

            DialogResult dr = R.ShowNoYes("lz77再圧縮を実行してもよろしいですか?");

            if (dr != DialogResult.Yes)
            {
                return;
            }

            uint totalSize  = 0;
            uint totalCount = 0;

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                List <Address> list = SearchAllLZ77Data(pleaseWait);
                pleaseWait.DoEvents("...");

                Undo.UndoData undodata = Program.Undo.NewUndoData("ReCompressLZ77");
                foreach (Address a in list)
                {
                    uint diff = RecompressOne(pleaseWait, a, undodata);
                    if (diff == 0)
                    {
                        pleaseWait.DoEvents();
                        continue;
                    }
                    totalSize += diff;
                    totalCount++;
                }
                Program.Undo.Push(undodata);
            }

            if (totalSize == 0)
            {
                R.ShowOK("再圧縮しても容量を増やすことができませんでした。\r\nすべてのデータは新しいルーチンで圧縮されているものだと思われます。");
            }
            else
            {
                R.ShowOK("{0}個のデータを再圧縮し、{1}バイトの追加の余白を得ました。\r\nこの余白を最大限利用するには、動作テストの後にrebuildを実行してください。", totalCount, totalSize);
            }
        }
Esempio n. 22
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);
        }
Esempio n. 23
0
        //MAPCHANGEのPLISTの書き込み
        public static bool WriteMapChangePlist(uint mapid, uint plist, Undo.UndoData undodata)
        {
            InputFormRef InputFormRef = Init(null);
            uint         addr         = InputFormRef.IDToAddr(mapid);

            if (!U.isSafetyOffset(addr))
            {
                return(false);
            }
            undodata.list.Add(new Undo.UndoPostion(addr + 11, 1));
            Program.ROM.write_u8(addr + 11, plist);

            return(true);
        }
Esempio n. 24
0
        static void WriteClassAs(uint cid, uint skip, uint newValue, Undo.UndoData undodata)
        {
            if (!U.isSafetyOffset(ClassTag))
            {
                return;
            }
            uint a = ClassTag + (cid * 4) + skip;

            if (!U.isSafetyOffset(a))
            {
                return;
            }
            Program.ROM.write_u8(a, newValue, undodata);
        }
Esempio n. 25
0
        //リストが拡張されたとき
        void AddressListExpandsEvent(object sender, EventArgs arg)
        {
            InputFormRef.ExpandsEventArgs eearg = (InputFormRef.ExpandsEventArgs)arg;
            uint addr  = eearg.NewBaseAddress;
            int  count = (int)eearg.NewDataCount;

            //件数を書く必要があるらしい.
            uint write_count_addr = Program.ROM.RomInfo.status_game_option_order_count_address();

            Undo.UndoData undodata = Program.Undo.NewUndoData(this, "StatusOptionOrder");
            Program.ROM.write_u8(write_count_addr, (uint)(count));

            Program.Undo.Push(undodata);
        }
Esempio n. 26
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            int selected = AddressList.SelectedIndex;

            if (selected < 0)
            {
                return;
            }
            uint flagAddr = GetFlagAddr(selected);

            Undo.UndoData undodata = Program.Undo.NewUndoData(this, "FLAG");
            Program.ROM.write_u8(flagAddr, (uint)FLAG.Value, undodata);
            Program.Undo.Push(undodata);
        }
Esempio n. 27
0
        static void WriteUnitAs(uint uid, uint skip, uint newValue, Undo.UndoData undodata)
        {
            if (!U.isSafetyOffset(UnitTag))
            {
                return;
            }
            uint a = UnitTag + (uid * 2) + skip;

            if (!U.isSafetyOffset(a))
            {
                return;
            }
            Program.ROM.write_u8(a, newValue, undodata);
        }
Esempio n. 28
0
        private void ImportButton_Click(object sender, EventArgs e)
        {
            if (!File.Exists(SRCFilename.Text))
            {
                SRCSelectButton_Click(sender, e);
            }
            string EAFilename = SRCFilename.Text;

            if (!File.Exists(SRCFilename.Text))
            {
                return;
            }

            if (this.AutoReCompile.Checked)
            {//自動コンパイル
                string error = RunAutoReCompile(EAFilename);
                if (error != "")
                {
                    R.ShowStopError(error);
                    return;
                }
            }

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

            try
            {
                uint freearea = (uint)FREEAREA.Value;
                if (!this.FREEAREA_DEF.Checked)
                {//フリーエリアを利用しない.
                    freearea = 0;
                }
                SymbolUtil.DebugSymbol storeSymbol = (SymbolUtil.DebugSymbol)(DebugSymbolComboBox.SelectedIndex);
                WriteEA(EAFilename, freearea, U.NOT_FOUND, undodata, storeSymbol);
            }
            catch (PatchForm.PatchException exception)
            {
                Program.Undo.Rollback(undodata);

                R.ShowStopError(exception.Message);
                return;
            }

            Program.Undo.Push(undodata);
            InputFormRef.ShowWriteNotifyAnimation(this, 0);

            UndoButton.Show();
//            U.ForceUpdate(FREEAREA, InputFormRef.AllocBinaryData(1024 * 1024)); //とりあえず1MBの空きがあるところ.
        }
Esempio n. 29
0
        public static uint WriteCString(uint pointer, string text)
        {
            string undoname = text + ":" + U.ToHexString(pointer);

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

            pointer = WriteCString(pointer, text, undodata);
            if (pointer == U.NOT_FOUND)
            {
                Program.Undo.Rollback(undodata);
                return(U.NOT_FOUND);
            }
            Program.Undo.Push(undodata);
            return(pointer);
        }
        private void ImportFontButton_Click(object sender, EventArgs e)
        {
            if (InputFormRef.IsPleaseWaitDialog(this))
            {//2重割り込み禁止
                return;
            }

            Undo.UndoData undodata = Program.Undo.NewUndoData("ImportFont");

            ToolTranslateROM trans = new ToolTranslateROM();

            trans.ImportFont(this, this.FontROMTextBox.Text, FontAutoGenelateCheckBox.Checked, UseFontNameTextEdit.Font, undodata);
            trans.BlackOut(undodata);
            Program.Undo.Push(undodata);
        }