summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/Debugger/RegisterColumn.h
blob: 53323ae043f741d325785959321ca7a285bc07ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright 2017 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <QTableWidgetItem>

#include <functional>

#include "Common/CommonTypes.h"

enum class RegisterType
{
  gpr,         // General purpose registers, int (r0-r31)
  fpr,         // Floating point registers, double (f0-f31)
  ibat,        // Instruction BATs (IBAT0-IBAT7)
  dbat,        // Data BATs (DBAT0-DBAT7)
  tb,          // Time base register
  pc,          // Program counter
  lr,          // Link register
  ctr,         // Decremented and incremented by branch and count instructions
  cr,          // Condition register
  xer,         // Integer exception register
  fpscr,       // Floating point status and control register
  msr,         // Machine state register
  srr,         // Machine status save/restore register (SRR0 - SRR1)
  sr,          // Segment register (SR0 - SR15)
  gqr,         // Graphics quantization registers (GQR0 - GQR7)
  hid,         // Hardware Implementation-Dependent registers (HID0-2, HID4)
  exceptions,  // Keeps track of currently triggered exceptions
  int_mask,    // ???
  int_cause,   // ???
  dsisr,       // Defines the cause of data / alignment exceptions
  dar,         // Data address register
  pt_hashmask  // ???
};

enum class RegisterDisplay : int
{
  Hex = 0,
  SInt32,
  UInt32,
  Float,
  Double
};

constexpr int DATA_TYPE = Qt::UserRole;

class RegisterColumn : public QTableWidgetItem
{
public:
  explicit RegisterColumn(RegisterType type, std::function<u64()> get,
                          std::function<void(u64)> set);

  void RefreshValue();

  RegisterDisplay GetDisplay() const;
  void SetDisplay(RegisterDisplay display);
  u64 GetValue() const;
  void SetValue();

private:
  void Update();

  RegisterType m_type;

  std::function<u64()> m_get_register;
  std::function<void(u64)> m_set_register;

  u64 m_value = 0;
  RegisterDisplay m_display = RegisterDisplay::Hex;
};