Exemplo n.º 1
0
        private void WriteButton_Click(object sender, EventArgs e)
        {
            uint addr = Program.ROM.p32(this.TSAPointer);

            byte[] tsaByte = new byte[this.Width8 * this.Height8 * 2];
            Buffer.BlockCopy(this.Map, 0, tsaByte, 0, tsaByte.Length); //(byte[])

            Undo.UndoData undodata = Program.Undo.NewUndoData(this, "TSA Editor");
            if (this.IsHeaderTSA)
            {
                uint tsaHeaderX = this.Width8;
                uint tsaHeaderY = this.Height8;

                uint tsa_width_margin = 32 - tsaHeaderX;
                tsaHeaderX += tsa_width_margin;
                tsaByte     = ImageUtil.TSAToHeaderTSA(tsaByte, (int)tsaHeaderX * 8, (int)tsaHeaderY * 8, (int)tsa_width_margin);
            }

            using (InputFormRef.AutoPleaseWait pleaseWait = new InputFormRef.AutoPleaseWait(this))
            {
                uint newAddr = ImageFormRef.WriteImageData(this, addr, this.TSAPointer, tsaByte, this.IsLZ77TSA, undodata);

                InputFormRef.WriteOnePointer(this.ZImgPointer, this.image1_ZIMAGE, undodata);
                this.Image1.WritePointer(undodata);
                ImageSystemIconForm.Fix_FE8_systemmenu_battlepreview_image(U.toOffset(this.ZImgPointer), undodata);
                Program.Undo.Push(undodata);

                //パレットも書き込む.
                PaletteFormRef.MakePaletteUIToROM(this, (uint)PALETTE_ADDRESS.Value, false, this.PaletteIndexComboBox.SelectedIndex);

                InputFormRef.WriteButtonToYellow(this.AllWriteButton, false);
                InputFormRef.ShowWriteNotifyAnimation(this, newAddr);
            }

            //チップセットを読みこむときに、最初のパレットを選択しないとダメだ.
            int selectedPalette = this.PaletteIndexComboBox.SelectedIndex;

            this.PaletteIndexComboBox.SelectedIndex = 0;
            LoadChipsetInfo();  //チップセット関係の読込
            this.PaletteIndexComboBox.SelectedIndex = selectedPalette;

            LoadBattleScreen();       //ROM TSAをメモリに読み込んで
            MakeBattleScreen();       //TSA描画
            this.Battle.Invalidate(); //キャンバスの再描画
        }