public static string PointToString(Data.InOutPoint point) { string result; if ((point & Data.InOutPoint.EndPoint) == Data.InOutPoint.EndPoint) { result = "X"; } else if ((point & Data.InOutPoint.OutPoint) == Data.InOutPoint.OutPoint) { result = "<"; } else { result = " "; } result += ((point & Data.InOutPoint.ReadPoint) == Data.InOutPoint.ReadPoint) ? "*" : " "; result += ((point & Data.InOutPoint.InPoint) == Data.InOutPoint.InPoint) ? ">" : " "; return(result); }
public static void PaintCell(int offset, DataGridViewCellStyle style, int column, int selOffset) { // editable cells show up green if (column == 0 || column == 8 || column == 9 || column == 12) { style.SelectionBackColor = Color.Chartreuse; } switch (Data.GetFlag(offset)) { case Data.FlagType.Unreached: style.BackColor = Color.LightGray; style.ForeColor = Color.DarkSlateGray; break; case Data.FlagType.Opcode: int opcode = Data.GetROMByte(offset); switch (column) { case 4: // <*> Data.InOutPoint point = Data.GetInOutPoint(offset); int r = 255, g = 255, b = 255; if ((point & (Data.InOutPoint.EndPoint | Data.InOutPoint.OutPoint)) != 0) { g -= 50; } if ((point & (Data.InOutPoint.InPoint)) != 0) { r -= 50; } if ((point & (Data.InOutPoint.ReadPoint)) != 0) { b -= 50; } style.BackColor = Color.FromArgb(r, g, b); break; case 5: // Instruction if (opcode == 0x40 || opcode == 0xCB || opcode == 0xDB || opcode == 0xF8 || // RTI WAI STP SED opcode == 0xFB || opcode == 0x00 || opcode == 0x02 || opcode == 0x42 // XCE BRK COP WDM ) { style.BackColor = Color.Yellow; } break; case 8: // Data Bank if (opcode == 0xAB || opcode == 0x44 || opcode == 0x54) // PLB MVP MVN { style.BackColor = Color.OrangeRed; } else if (opcode == 0x8B) // PHB { style.BackColor = Color.Yellow; } break; case 9: // Direct Page if (opcode == 0x2B || opcode == 0x5B) // PLD TCD { style.BackColor = Color.OrangeRed; } if (opcode == 0x0B || opcode == 0x7B) // PHD TDC { style.BackColor = Color.Yellow; } break; case 10: // M Flag case 11: // X Flag int mask = column == 10 ? 0x20 : 0x10; if (opcode == 0x28 || ((opcode == 0xC2 || opcode == 0xE2) && // PLP SEP REP (Data.GetROMByte(offset + 1) & mask) != 0)) // relevant bit set { style.BackColor = Color.OrangeRed; } if (opcode == 0x08) // PHP { style.BackColor = Color.Yellow; } break; } break; case Data.FlagType.Operand: style.ForeColor = Color.LightGray; break; case Data.FlagType.Graphics: style.BackColor = Color.LightPink; break; case Data.FlagType.Music: style.BackColor = Color.PowderBlue; break; case Data.FlagType.Data8Bit: case Data.FlagType.Data16Bit: case Data.FlagType.Data24Bit: case Data.FlagType.Data32Bit: style.BackColor = Color.NavajoWhite; break; case Data.FlagType.Pointer16Bit: case Data.FlagType.Pointer24Bit: case Data.FlagType.Pointer32Bit: style.BackColor = Color.Orchid; break; case Data.FlagType.Text: style.BackColor = Color.Aquamarine; break; case Data.FlagType.Empty: style.BackColor = Color.DarkSlateGray; style.ForeColor = Color.LightGray; break; } if (selOffset >= 0 && selOffset < Data.GetROMSize()) { if (column == 1 //&& (Data.GetFlag(selOffset) == Data.FlagType.Opcode || Data.GetFlag(selOffset) == Data.FlagType.Unreached) && ConvertSNEStoPC(GetIntermediateAddressOrPointer(selOffset)) == offset ) { style.BackColor = Color.DeepPink; } if (column == 6 //&& (Data.GetFlag(offset) == Data.FlagType.Opcode || Data.GetFlag(offset) == Data.FlagType.Unreached) && ConvertSNEStoPC(GetIntermediateAddressOrPointer(offset)) == selOffset ) { style.BackColor = Color.DeepPink; } } }
public void PaintCell(int offset, DataGridViewCellStyle style, int column_index, int selOffset, DataGridViewCellPaintingEventArgs cell) { // editable cells show up green string column = ColumnName(column_index); if (column == "label" || column == "base" || column == "db" || column == "dp" || column == "ia" || column == "comment") { style.SelectionBackColor = Color.Chartreuse; } bool diff = Project.Data.GetLabelName(Project.Data.ConvertPCtoSnes(offset)) == "" && (offset > 0 && Project.Data.GetFlag(offset - 1) == Project.Data.GetFlag(offset)); Data.InOutPoint point = Project.Data.GetInOutPoint(offset); Data.FlagType flag = Project.Data.GetFlag(offset); Data.ConstantType constant = Project.Data.GetConstantType(offset); switch (flag) { case Data.FlagType.Unreached: style.BackColor = Color.LightGray; style.ForeColor = Color.DarkSlateGray; break; case Data.FlagType.Opcode: int opcode = Project.Data.GetRomByte(offset); switch (column) { case "points": int r = 255, g = 255, b = 255; if ((point & (Data.InOutPoint.EndPoint | Data.InOutPoint.OutPoint)) != 0) { g -= 50; } if ((point & (Data.InOutPoint.InPoint)) != 0) { r -= 50; } if ((point & (Data.InOutPoint.ReadPoint)) != 0) { b -= 50; } style.BackColor = Color.FromArgb(r, g, b); break; case "instruction": if (opcode == 0x40 || opcode == 0xCB || opcode == 0xDB || opcode == 0xF8 || // RTI WAI STP SED opcode == 0xFB || opcode == 0x00 || opcode == 0x02 || opcode == 0x42 // XCE BRK COP WDM ) { style.BackColor = Color.Yellow; } if (constant != Data.ConstantType.Hexadecimal) { style.BackColor = Color.FromArgb(50 - (int)constant, 100 - (int)constant, 255 - ((int)constant * 20)); style.ForeColor = Color.White; } break; case "db": if (opcode == 0xAB || opcode == 0x44 || opcode == 0x54) // PLB MVP MVN { style.BackColor = Color.OrangeRed; } else if (opcode == 0x8B) // PHB { style.BackColor = Color.Yellow; } break; case "dp": if (opcode == 0x2B || opcode == 0x5B) // PLD TCD { style.BackColor = Color.OrangeRed; } if (opcode == 0x0B || opcode == 0x7B) // PHD TDC { style.BackColor = Color.Yellow; } break; case "m": case "x": int mask = column == "m" ? 0x20 : 0x10; if (opcode == 0x28 || ((opcode == 0xC2 || opcode == 0xE2) && // PLP SEP REP (Project.Data.GetRomByte(offset + 1) & mask) != 0)) // relevant bit set { style.BackColor = Color.OrangeRed; } if (opcode == 0x08) // PHP { style.BackColor = Color.Yellow; } break; } switch (opcode) { case 0x4C: case 0x5C: case 0x6C: case 0x7C: case 0xDC: style.BackColor = Color.WhiteSmoke; break; case 0x60: case 0x6B: style.BackColor = Color.LightGreen; break; } break; case Data.FlagType.Operand: style.ForeColor = Color.LightGray; break; case Data.FlagType.Graphics: style.BackColor = Color.LightPink; break; case Data.FlagType.Music: style.BackColor = Color.PowderBlue; break; case Data.FlagType.Data8Bit: case Data.FlagType.Data16Bit: case Data.FlagType.Data24Bit: case Data.FlagType.Data32Bit: style.BackColor = Color.NavajoWhite; if (column == "ia" && Project.Data.GetConstantType(offset) == Data.ConstantType.Color && (point & Data.InOutPoint.ReadPoint) > 0) { if (flag == Data.FlagType.Data16Bit) { style.BackColor = Util.ColorRGB555(Project.Data.GetRomWord(offset)); } else if (flag == Data.FlagType.Data24Bit) { style.BackColor = Color.FromArgb(Project.Data.GetRomByte(offset + 2), Project.Data.GetRomByte(offset + 1), Project.Data.GetRomByte(offset)); } } if (RomUtil.GetByteLengthForFlag(flag) > 1 && (point & Data.InOutPoint.ReadPoint) == 0) { style.ForeColor = Color.DarkGray; } break; case Data.FlagType.Pointer16Bit: case Data.FlagType.Pointer24Bit: case Data.FlagType.Pointer32Bit: style.BackColor = Color.Orchid; if ((point & (Data.InOutPoint.ReadPoint | Data.InOutPoint.EndPoint)) == 0) { style.ForeColor = Color.DarkMagenta; } break; case Data.FlagType.Text: style.BackColor = Color.Aquamarine; if (diff) { style.ForeColor = Color.DarkGray; } break; case Data.FlagType.Empty: style.BackColor = Color.DarkSlateGray; style.ForeColor = Color.LightGray; break; case Data.FlagType.Binary: style.BackColor = Color.Aqua; break; } int ia = Project.Data.ConvertSnesToPc(Project.Data.GetIntermediateAddressOrPointer(offset)); int sia = Project.Data.ConvertSnesToPc(Project.Data.GetIntermediateAddressOrPointer(selOffset)); if (selOffset >= 0 && selOffset < Project.Data.GetRomSize()) { if ((column == "pc" && sia >= 0 && sia == offset) || (column == "ia" && ia >= 0 && ia == selOffset)) { style.BackColor = Color.DeepPink; } } switch (column) { case "label": style.ForeColor = Project.Data.GetLabelName(Project.Data.ConvertPCtoSnes(offset)) == "" ? Color.LightGray : style.ForeColor; break; case "base": style.ForeColor = Project.Data.GetBaseAddr(offset) > 0 /*&& Project.Data.GetFlag(offset) != Data.FlagType.Operand*/ ? Color.DarkBlue : Color.LightGray; break; case "ia": if (Project.Data.GetIndirectAddr(offset) > 0 /*&& Project.Data.GetFlag(offset) != Data.FlagType.Operand*/) { style.ForeColor = Color.Red; } break; case "constant": if (constant != Data.ConstantType.Hexadecimal) { style.BackColor = Color.FromArgb(50 - (int)constant, 100 - (int)constant, 255 - ((int)constant * 20)); style.ForeColor = Color.White; } break; case "comment": if (Project.Data.GetComment(Project.Data.ConvertPCtoSnes(offset)) == "") { style.ForeColor = Color.LightGray; } break; } cell.PaintBackground(cell.CellBounds, true); if (sia >= 0) { if (column == "pc" && ((sia > selOffset && offset < sia && offset > selOffset) || (sia < selOffset && offset > sia && offset <= selOffset))) { cell.Graphics.DrawLine(new Pen(Color.DeepPink, 2F), cell.CellBounds.Right - 2, cell.CellBounds.Top, cell.CellBounds.Right - 2, cell.CellBounds.Bottom); } if (((sia >= 0 && selOffset == offset - 1) || (ia >= 0 && ia == offset)) && column_index > ColumnIndex("pc") && column_index <= ColumnIndex("ia")) { cell.Graphics.DrawLine(Pens.DeepPink, cell.CellBounds.Left, cell.CellBounds.Top, cell.CellBounds.Right, cell.CellBounds.Top); } } cell.Paint(cell.ClipBounds, DataGridViewPaintParts.ContentForeground); cell.Handled = true; }