private void tbSequenceFile_DragDrop(object sender, DragEventArgs e) { this.tbSequenceFile.Text = this.getDroppedFile(e); // get track count SegaSaturnSequence s = new SegaSaturnSequence(this.tbSequenceFile.Text); this.tbSequenceCount.Text = String.Format("0x{0}", s.SequenceCount.ToString("X2")); // (de)activate ssflib checkbox if (s.SequenceCount <= 1) { this.cbMakeSsflib.Checked = false; this.cbMakeSsflib.Enabled = false; } else { this.cbMakeSsflib.Checked = true; this.cbMakeSsflib.Enabled = true; } }
protected void RenderMemoryGrid() { long?driverFileSize; long?seqFileSize; long?dspFileSize; uint?dspRamNeeded; long?tonFileSize; long currentOffset = DATA_START_OFFSET; float currentHeight = DATA_START_HEIGHT; float seqHeight; float dspHeight; float dspRamHeight; float tonHeight; Brush rectangleColor; // draw white background this.graphicsRenderer.FillRectangle(Brushes.White, 0, 0, RECT_WIDTH, RECT_HEIGHT); #region Render Driver if (!String.IsNullOrEmpty(this.tbDriverFile.Text)) { driverFileSize = FileUtil.GetFileSize(this.tbDriverFile.Text); if (driverFileSize != null) { if (driverFileSize > TOTAL_68000_MEMORY) { rectangleColor = Brushes.Red; } else { rectangleColor = Brushes.Aqua; } this.graphicsRenderer.FillRectangle(rectangleColor, 0, 0, RECT_WIDTH, this.GetRectangleHeight((float)driverFileSize)); } } #endregion #region Render SEQ if (!String.IsNullOrEmpty(this.tbSequenceFile.Text)) { seqFileSize = FileUtil.GetFileSize(this.tbSequenceFile.Text); if (seqFileSize != null) { if ((currentOffset + seqFileSize) > TOTAL_68000_MEMORY) { rectangleColor = Brushes.Red; } else { rectangleColor = Brushes.BlueViolet; } seqHeight = this.GetRectangleHeight((float)seqFileSize); this.graphicsRenderer.FillRectangle(rectangleColor, 0, currentHeight, RECT_WIDTH, seqHeight); // update current offset/hieght currentOffset += (long)seqFileSize; currentHeight += seqHeight; } } #endregion #region Render DSP if (!String.IsNullOrEmpty(this.tbDspProgram.Text)) { dspFileSize = FileUtil.GetFileSize(this.tbDspProgram.Text); // shoudl do some error handling around this dspRamNeeded = SegaSaturnSequence.GetDspRamNeeded(this.tbDspProgram.Text); if (dspFileSize != null) { currentOffset = MathUtil.RoundUpToByteAlignment((long)currentOffset, 0x2000); currentHeight = GetRectangleHeight(currentOffset); if ((currentOffset + dspFileSize) > TOTAL_68000_MEMORY) { rectangleColor = Brushes.Red; } else { rectangleColor = Brushes.DarkKhaki; } dspHeight = this.GetRectangleHeight((float)dspFileSize); this.graphicsRenderer.FillRectangle(rectangleColor, 0, currentHeight, RECT_WIDTH, dspHeight); // update current offset/height currentOffset += (long)dspFileSize; currentHeight += dspHeight; // handle DSP RAM dspRamHeight = this.GetRectangleHeight((float)dspRamNeeded); if ((currentOffset + dspRamHeight) > TOTAL_68000_MEMORY) { rectangleColor = Brushes.Red; } else { rectangleColor = Brushes.Lime; } this.graphicsRenderer.FillRectangle(rectangleColor, 0, currentHeight, RECT_WIDTH, dspRamHeight); this.graphicsRenderer.DrawString("DSP RAM", new Font(FontFamily.GenericSansSerif, 7), Brushes.Black, 5, currentHeight + 1); currentOffset += (long)dspRamNeeded; currentHeight += dspRamHeight; } } #endregion #region Render TON if (this.lbToneData.Items.Count > 0) { foreach (ListBoxFileInfoObject listFileObject in this.lbToneData.Items) { tonFileSize = FileUtil.GetFileSize(listFileObject.FilePath); if (tonFileSize != null) { if ((currentOffset + tonFileSize) > TOTAL_68000_MEMORY) { rectangleColor = Brushes.Red; } else { rectangleColor = Brushes.Plum; } tonHeight = this.GetRectangleHeight((float)tonFileSize); this.graphicsRenderer.FillRectangle(rectangleColor, 0, currentHeight, RECT_WIDTH, tonHeight); // update current offset/hieght currentOffset += (long)tonFileSize; currentHeight += tonHeight; } } } #endregion //render outline this.graphicsRenderer.DrawRectangle(this.blackPen, 0, 0, RECT_WIDTH - this.blackPen.Width, RECT_HEIGHT - this.blackPen.Width); // repaint this.pb68000Memory.Refresh(); }