public EventAssemblerForm() { InitializeComponent(); this.DebugSymbolComboBox.SelectedIndex = 3; U.ForceUpdate(FREEAREA, InputFormRef.AllocBinaryData(1024 * 1024)); //とりあえず1MBの空きがあるところ. SRCFilename.AllowDropFilename(); AllowDropFilename(); MakeExplain(); }
public ToolASMInsertForm() { InitializeComponent(); SRCFilename.AllowDropFilename(); AllowDropFilename(); this.Method.SelectedIndex = 0; this.HookRegister.SelectedIndex = 3; this.ELFComboBox.SelectedIndex = 1; this.DebugSymbolComboBox.SelectedIndex = 3; U.ForceUpdate(FREEAREA, InputFormRef.AllocBinaryData(1024 * 1024, isProgramArea: true)); //とりあえず1MBの空きがあるところ. this.ComplieBinFilename = ""; SetExplain(); }
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の空きがあるところ. }
void RedefineFreeArea() { uint freearea = 0; if (this.FreeAreaComboBox.SelectedIndex == (int)FREEAREA_DEF_ENUM.Program) { freearea = InputFormRef.AllocBinaryData(1024 * 200, isProgramArea: true); //200kbyte } else if (this.FreeAreaComboBox.SelectedIndex == (int)FREEAREA_DEF_ENUM.Data) { freearea = InputFormRef.AllocBinaryData(1024 * 200, isProgramArea: false); //200kbyte } if (freearea == U.NOT_FOUND) {//ROM末尾 freearea = (uint)Program.ROM.Data.Length; } U.ForceUpdate(FREEAREA, freearea); }
private void UndoButton_Click(object sender, EventArgs e) { string text = R._("最後の動作を取り消してよろしいですか?"); string title = R._("UNDO確認"); DialogResult r = MessageBox.Show(text , title , MessageBoxButtons.YesNo , MessageBoxIcon.Exclamation); if (r != System.Windows.Forms.DialogResult.Yes) { return; } Program.Undo.RunUndo(); //操作の取り消し UndoButton.Hide(); InputFormRef.ShowWriteNotifyAnimation(this, 0); U.ForceUpdate(FREEAREA, InputFormRef.AllocBinaryData(1024 * 1024)); //とりあえず1MBの空きがあるところ. }
void Burn(SongSt song, InstrumentMap instrument_map, List <List <byte> > trackdata) { //必要なサイズを計算する. uint use_size = 8 + (4 * (uint)trackdata.Count); //ヘッダー for (int track = 0; track < trackdata.Count; track++) { use_size += (uint)trackdata[track].Count; //楽譜 } use_size = U.Padding4(use_size); //楽譜と楽器の間は 4バイトアライメントが必要. use_size += (uint)(instrument_map.Instrument_mapping.Count * 12); //楽器 use_size += (uint)instrument_map.Sample_data.Count; //楽器データ uint write_pointer = InputFormRef.AllocBinaryData(use_size); if (write_pointer == U.NOT_FOUND) { R.ShowStopError("データサイズを({0})確保できません。\r\nROM容量がもうないか、音楽のパースに失敗しています。", use_size); return; } U.toPointer(write_pointer); byte[] data = new byte[use_size]; U.write_u8(data, 0, (uint)trackdata.Count); //トラック数 U.write_u8(data, 1, 0x0); //常にゼロ. U.write_u8(data, 2, 0x0A); //Do these values matter? U.write_u8(data, 3, 0x80); //This is just copying what the stock ROM does... uint offset = 8 + (4 * (uint)trackdata.Count); //データ構造 //ヘッダー //[track数] [0] [0x0A] [0x80] [楽器ポンタ] [楽譜1ポインタ] [楽譜2ポインタ].... [楽譜Nポインタ] // //実データ //[楽譜1データ]....... //[楽譜2データ]....... // //[楽器データ] //[楽器サンプルデータ] //楽譜 for (int track = 0; track < trackdata.Count; track++) { //楽譜ポインタの書き込み U.write_u32(data, 8 + (4 * (uint)track), U.toPointer(write_pointer + offset)); //楽譜データを書き込む. burn_track(data, offset, write_pointer, trackdata[track].ToArray()); offset += (uint)trackdata[track].Count; } offset = U.Padding4(offset); //楽譜と楽器の間は 4バイトアライメントが必要. //楽器ポインタ U.write_u32(data, 4, U.toPointer(write_pointer + offset)); uint instrument_start = offset; //楽器開始 uint instrumentdata_start = instrument_start + (12 * (uint)instrument_map.Instrument_mapping.Count); //楽器データ開始 Log.Debug("instrumentdata_start(", instrumentdata_start.ToString(), ") = instrument_start(", instrument_start.ToString(), ") + 12 * instrument_count(", instrument_map.Instrument_mapping.Count.ToString(), ")"); U.write_range(data, instrument_start, instrument_map.Instrument_codes.ToArray()); U.write_range(data, instrumentdata_start, instrument_map.Sample_data.ToArray()); //楽器 uint resyclesize = 0; for (int i = 0; i < instrument_map.Instrument_mapping.Count; i++) { uint this_instrument = instrument_start + (12 * (uint)i); Log.Debug("track:", i.ToString(), " ", data[this_instrument + 0].ToString()); uint instrumentCode = U.u8(data, this_instrument + 0); if (SongInstrumentForm.IsDirectSound(instrumentCode) || SongInstrumentForm.IsWaveMemory(instrumentCode)) { uint sample_data_start = U.u32(data, this_instrument + 4); sample_data_start += instrumentdata_start; if (sample_data_start < resyclesize) { Log.Error("BAD INSTRUMENT:", i.ToString(), (sample_data_start - instrumentdata_start).ToString(), sample_data_start.ToString(), resyclesize.ToString()); continue; } sample_data_start -= resyclesize; uint sample_data_len; if (SongInstrumentForm.IsWaveMemory(instrumentCode)) { sample_data_len = 16; } else { sample_data_len = U.u32(data, sample_data_start + 12); sample_data_len = U.Padding4(sample_data_len); } Log.Debug("d ", sample_data_start.ToString("X"), " ", sample_data_len.ToString()); uint found_address = U.Grep(Program.ROM.Data, U.subrange(data, sample_data_start, sample_data_start + sample_data_len), 100, 0, 4); if (found_address != U.NOT_FOUND) { Log.Debug("recycle ", sample_data_start.ToString("X"), " len ", sample_data_len.ToString(), " -> ", found_address.ToString("X")); //existing address in ROM. //recycle data = U.del(data, sample_data_start, sample_data_start + sample_data_len); U.write_u32(data, this_instrument + 4, U.toPointer(found_address)); resyclesize += sample_data_len; } else { //nothing to recycle, write the data. uint baseoffset = U.u32(data, this_instrument + 4); //相対アドレスが書いてあるので、それを求めに絶対値に変換する U.write_u32(data, this_instrument + 4 , U.toPointer((instrumentdata_start + write_pointer + baseoffset) - resyclesize)); } } else if (instrumentCode == 0x80) { //ドラム uint baseoffset = U.u32(data, this_instrument + 4); //相対アドレスが書いてあるので、それを求めに絶対値に変換する U.write_u32(data, this_instrument + 4 , U.toPointer(instrument_start + write_pointer + baseoffset)); } else if (instrumentCode == 0x40) { Log.Debug("MULTI TRACK!"); uint baseoffset = U.u32(data, this_instrument + 4); //相対アドレスが書いてあるので、それを求めに絶対値に変換する U.write_u32(data, this_instrument + 4 , U.toPointer(instrument_start + write_pointer + baseoffset)); baseoffset = U.u32(data, this_instrument + 8); //相対アドレスが書いてあるので、それを求めに絶対値に変換する U.write_u32(data, this_instrument + 8 , U.toPointer((instrumentdata_start + write_pointer + baseoffset) - resyclesize)); } } Log.Notify("resyclesize:", resyclesize.ToString(), U.To0xHexString(resyclesize)); string undo_name = ""; Undo.UndoData undodata = Program.Undo.NewUndoData(undo_name); undodata.list.Add(new Undo.UndoPostion(song.table, 8)); Program.ROM.write_u32(song.table, U.toPointer(write_pointer)); InputFormRef.WriteBinaryDataDirect(write_pointer, data, undodata); uint priority = GetSongPriority(trackdata.Count); Program.ROM.write_u32(song.table + 4, priority, undodata); Program.Undo.Push(undodata); }