diff --git a/BizHawk.Emulation/Disc/CUE_format.cs b/BizHawk.Emulation/Disc/CUE_format.cs index 330eca9133..668eeaf51c 100644 --- a/BizHawk.Emulation/Disc/CUE_format.cs +++ b/BizHawk.Emulation/Disc/CUE_format.cs @@ -160,7 +160,10 @@ namespace BizHawk.DiscSystem var toc_index = new DiscTOC.Index(); toc_index.num = index; toc_track.Indexes.Add(toc_index); - if (index == 0) toc_index.lba = track_disc_pregap_lba; + if (index == 0) + { + toc_index.lba = track_disc_pregap_lba - (cue_track.Indexes[1].Timestamp.LBA - cue_track.Indexes[0].Timestamp.LBA); + } else toc_index.lba = Sectors.Count; //calculate length of the index @@ -231,7 +234,7 @@ namespace BizHawk.DiscSystem //we're done with the track now. //record its length: - toc_track.length_lba = Sectors.Count - track_disc_lba_start; + toc_track.length_lba = Sectors.Count - toc_track.Indexes[1].lba; curr_track++; } //track loop @@ -249,7 +252,7 @@ namespace BizHawk.DiscSystem //firstTrack.Indexes[0].lba -= 150; var lastTrack = toc_session.Tracks[toc_session.Tracks.Count - 1]; - session.length_lba = lastTrack.Indexes[0].lba + lastTrack.length_lba - firstTrack.Indexes[0].lba; + session.length_lba = lastTrack.Indexes[1].lba + lastTrack.length_lba - firstTrack.Indexes[0].lba; TOC.length_lba += toc_session.length_lba; } } @@ -507,6 +510,13 @@ namespace BizHawk.DiscSystem track_has_postgap = true; currTrack.PostGap = new CueTimestamp(clp.ReadToken()); break; + case "CATALOG": + case "PERFORMER": + case "SONGWRITER": + case "TITLE": + case "ISRC": + //TODO - keep these for later? + break; default: throw new CueBrokenException("unsupported cue command: " + key); } diff --git a/DiscoHawk/DiscoHawk.cs b/DiscoHawk/DiscoHawk.cs index 8c80a25d90..cd1a7e2784 100644 --- a/DiscoHawk/DiscoHawk.cs +++ b/DiscoHawk/DiscoHawk.cs @@ -31,9 +31,9 @@ namespace BizHawk { var dialog = new DiscoHawkDialog(); dialog.ShowDialog(); + return; } - return; //string exedir = BizHawk.MultiClient.PathManager.GetExeDirectoryAbsolute(); //ffMpeg.Converter._ffExe = Path.Combine(exedir, "ffmpeg.exe"); @@ -90,18 +90,17 @@ namespace BizHawk // } //} - //notes: daemon tools does not like INDEX 00 00:00:00 / INDEX 01 00:00:00 in track 1 (audio track) - //obviously, this is because the lead-in is supposed to be specified. we need to write that out - //DiscSystem.Disc disc = DiscSystem.Disc.FromCuePath("D:\\discs\\Bomberman_'94_Taikenban_(SCD)(JPN)_-_wav'd\\Bomberman '94 Taikenban (SCD)(JPN).cue"); - //DiscSystem.Disc disc = DiscSystem.Disc.FromCuePath("D:\\discs\\Syd Mead's Terra Forming [U][CD.SCD][TGXCD1040][Syd Mead][1993][PCE][rigg].cue"); - //var prefs = new DiscSystem.CueBinPrefs(); - //prefs.AnnotateCue = false; - //prefs.OneBlobPerTrack = true; - //prefs.ReallyDumpBin = true; - //prefs.OmitRedundantIndex0 = true; - //prefs.SingleSession = true; - //var cueBin = disc.DumpCueBin("testroundtrip", prefs); - //cueBin.Dump("d:\\", prefs); + //DiscSystem.Disc disc = DiscSystem.Disc.FromCuePath(@"D:\discs\Bomberman_'94_Taikenban_(SCD)(JPN)_-_wav'd\Bomberman '94 Taikenban (SCD)(JPN)_hawked.cue"); + DiscSystem.Disc disc = DiscSystem.Disc.FromCuePath(@"D:\discs\Bomberman_'94_Taikenban_(SCD)(JPN)_-_wav'd\Bomberman '94 Taikenban (SCD)(JPN).cue"); + var prefs = new DiscSystem.CueBinPrefs(); + prefs.AnnotateCue = false; + prefs.OneBlobPerTrack = false; + prefs.ReallyDumpBin = true; + prefs.OmitRedundantIndex0 = true; + prefs.SingleSession = true; + //var cueBin = disc.DumpCueBin("Bomberman '94 Taikenban (SCD)(JPN)_hawked_hawked", prefs); + var cueBin = disc.DumpCueBin("Bomberman '94 Taikenban (SCD)(JPN)_hawked", prefs); + cueBin.Dump(@"D:\discs\Bomberman_'94_Taikenban_(SCD)(JPN)_-_wav'd", prefs); } } diff --git a/DiscoHawk/DiscoHawkDialog.Designer.cs b/DiscoHawk/DiscoHawkDialog.Designer.cs index 996fcbe471..35b0c34933 100644 --- a/DiscoHawk/DiscoHawkDialog.Designer.cs +++ b/DiscoHawk/DiscoHawkDialog.Designer.cs @@ -63,6 +63,7 @@ this.label11 = new System.Windows.Forms.Label(); this.label12 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); + this.lblMagicDragArea = new System.Windows.Forms.Label(); this.groupBox1.SuspendLayout(); this.tableLayoutPanel1.SuspendLayout(); this.panel1.SuspendLayout(); @@ -416,11 +417,24 @@ this.label13.Text = "Wouldnt it be cool if you could edit the disc by deleting and moving and adding t" + "racks and such .. yeahhhhhh"; // + // lblMagicDragArea + // + this.lblMagicDragArea.AllowDrop = true; + this.lblMagicDragArea.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.lblMagicDragArea.Location = new System.Drawing.Point(665, 384); + this.lblMagicDragArea.Name = "lblMagicDragArea"; + this.lblMagicDragArea.Size = new System.Drawing.Size(147, 70); + this.lblMagicDragArea.TabIndex = 21; + this.lblMagicDragArea.Text = "Drag a cue into the DRAG HERE FOR MAGIC area for magic"; + this.lblMagicDragArea.DragDrop += new System.Windows.Forms.DragEventHandler(this.handleDragDrop); + this.lblMagicDragArea.DragEnter += new System.Windows.Forms.DragEventHandler(this.handleDragEnter); + // // DiscoHawkDialog // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1151, 645); + this.Controls.Add(this.lblMagicDragArea); this.Controls.Add(this.label13); this.Controls.Add(this.label12); this.Controls.Add(this.label11); @@ -490,5 +504,6 @@ private System.Windows.Forms.Label label11; private System.Windows.Forms.Label label12; private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label lblMagicDragArea; } } \ No newline at end of file diff --git a/DiscoHawk/DiscoHawkDialog.cs b/DiscoHawk/DiscoHawkDialog.cs index 060a18b64e..90b27f50b7 100644 --- a/DiscoHawk/DiscoHawkDialog.cs +++ b/DiscoHawk/DiscoHawkDialog.cs @@ -114,7 +114,7 @@ namespace BizHawk } void PresetCanonical() { - checkCueProp_Annotations.Checked = true; + checkCueProp_Annotations.Checked = false; checkCueProp_OmitRedundantIndex0.Checked = false; checkCueProp_OneBlobPerTrack.Checked = false; } @@ -134,22 +134,65 @@ namespace BizHawk UpdateCue(); } - private void btnExportCue_Click(object sender, EventArgs e) + private void Form1_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { - SaveFileDialog sfd = new SaveFileDialog(); - sfd.Filter = "CUE files (*.cue)|*.cue"; - sfd.OverwritePrompt = true; - if (sfd.ShowDialog() != DialogResult.OK) - return; - string baseName = Path.GetFileNameWithoutExtension(sfd.FileName); - var prefs = GetCuePrefs(); - prefs.ReallyDumpBin = true; - var cueBin = boundDisc.DumpCueBin(baseName, prefs); + e.Action = DragAction.Continue; + } + private void handleDragEnter(object sender, DragEventArgs e) + { + List files = validateDrop(e.Data); + if (files.Count > 0) + e.Effect = DragDropEffects.Link; + else e.Effect = DragDropEffects.None; + } + + private void handleDragDrop(object sender, DragEventArgs e) + { + List files = validateDrop(e.Data); + if (files.Count == 0) return; + try + { + foreach (var file in files) + { + Disc disc = Disc.FromCuePath(file); + string baseName = Path.GetFileNameWithoutExtension(file); + baseName += "_hawked"; + var prefs = GetCuePrefs(); + prefs.ReallyDumpBin = true; + var cueBin = disc.DumpCueBin(baseName, GetCuePrefs()); + Dump(cueBin, Path.GetDirectoryName(file), prefs); + } + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString(), "oops! error"); + throw; + } + } + + List validateDrop(IDataObject ido) + { + List ret = new List(); + string[] files = (string[])ido.GetData(System.Windows.Forms.DataFormats.FileDrop); + if (files == null) return new List(); + foreach (string str in files) + { + if (Path.GetExtension(str).ToUpper() != ".CUE") + { + return new List(); + } + ret.Add(str); + } + return ret; + } + + bool Dump(CueBin cueBin, string directoryTo, CueBinPrefs prefs) + { ProgressReport pr = new ProgressReport(); Thread workThread = new Thread(() => { - cueBin.Dump(Path.GetDirectoryName(sfd.FileName), prefs, pr); + cueBin.Dump(directoryTo, prefs, pr); }); ProgressDialog pd = new ProgressDialog(pr); @@ -165,7 +208,23 @@ namespace BizHawk pd.Update(); } this.Enabled = true; - pd.Dispose(); + pd.Dispose(); + return !pr.CancelSignal; + } + + private void btnExportCue_Click(object sender, EventArgs e) + { + SaveFileDialog sfd = new SaveFileDialog(); + sfd.Filter = "CUE files (*.cue)|*.cue"; + sfd.OverwritePrompt = true; + if (sfd.ShowDialog() != DialogResult.OK) + return; + string baseName = Path.GetFileNameWithoutExtension(sfd.FileName); + var prefs = GetCuePrefs(); + prefs.ReallyDumpBin = true; + var cueBin = boundDisc.DumpCueBin(baseName, prefs); + + Dump(cueBin, Path.GetDirectoryName(sfd.FileName), prefs); } }