Added a HW registers browser window and set a tab for the Blitter
[clinton/Virtual-Jaguar-Rx.git] / src / gui / debug / hwregsblitterbrowser.cpp
CommitLineData
2d99e2b7
JPM
1//
2// hwregsbrowser.h: Hardware registers blitter browser
3//
4// by Jean-Paul Mari
5//
6// JPM = Jean-Paul Mari <djipi.mari@gmail.com>
7//
8// Who When What
9// --- ---------- -----------------------------------------------------------
10// JPM 08/20/2019 Created this file
11//
12
13// STILL TO DO:
14//
15
16#include "hwregsbrowser.h"
17#include "blitter.h"
18
19
20//
21struct BlitterInfoTable
22{
23 unsigned int Address;
24 unsigned int NbBits;
25 const char *Name;
26 const char *Type;
27}
28S_BlitterInfoTable;
29
30//
31BlitterInfoTable TabBlitterInfoTable[] = {
32 { 0xF02200, sizeof(long), "A1 base address", "32-bit register containing a pointer to the base of the window pointer to by A1.\nThis address must be phrase aligned." },
33 { 0xF02204, sizeof(long), "Flags Register", "A set of flags controlling various aspects of the A1 window and how addresses are updated." },
34 { 0xF02208, sizeof(long), "A1 Clipping Window Size", "This register contains the size in pixels, and may be used for clipping writes, so that if the pointer leaves the window bounds no write is performed." },
35 { 0xF0220C, sizeof(long), "A1 Window Pixel Pointer", "This register contains the X (low word) and Y (high word) pointers onto the window, and are the location where the next pixel will be written.\nThey are sixteen - bit signed values." },
36 { 0xF02210, sizeof(long), "A1 Step Value", "The step register contains two signed sixteen bit values, which are the X step (low word) and Y step (high word)." },
37 { 0xF02214, sizeof(long), "A1 Step Fraction Value", "The step fraction register may be added to the fractional parts of the A1 pointer in the same manner as the step value." },
38 { 0xF02218, sizeof(long), "A1 Window Pixel Pointer Fraction", "" },
39 { 0xF0221C, sizeof(long), "A1 Pixel Pointer Increment", "" },
40 { 0xF02220, sizeof(long), "A1 Pixel Pointer Increment Fraction", "This is the fractional parts of the increment described above." },
41 { 0xF02224, sizeof(long), "A2 Base Register", "32-bit register containing a pointer to the base of the window pointer to by A2.\nThis address must be phrase aligned." },
42 { 0xF02228, sizeof(long), "A2 Flags Register", "A set of flags controlling various aspects of the A2 window and how addresses are updated." },
43 { 0xF0222C, sizeof(long), "A2 Window Mask", "" },
44 { 0xF02230, sizeof(long), "A2 Window Pointer", "" },
45 { 0xF02234, sizeof(long), "A2 Step Value", "" },
46 { 0xF02238, sizeof(long), "Status Register", "" },
47 { 0xF0223C, sizeof(long), "Counters Register", "" },
48 { 0xF02240, sizeof(long long), "Source Data Register", "" },
49 { 0xF02248, sizeof(long long), "Destination Data Register", "" },
50 { 0xF02250, sizeof(long long), "Destination Z Register", "" },
51 { 0xF02258, sizeof(long long), "Source Z Register 1", "The source Z register 1 is also used to hold the four integer parts of computed Z." },
52 { 0xF02260, sizeof(long long), "Source Z Register 2", "The source Z register 2 is also used to hold the four fraction parts of computed Z." },
53 { 0xF02268, sizeof(long long), "Pattern Data Register", "The pattern data register also serves to hold the computed intensity integer parts and their associated colours." },
54 { 0xF02270, sizeof(long), "Intensity Increment", "This thirty-two bit register holds the integer and fractional parts of the intensity increment used for Gouraud shading." },
55 { 0xF02274, sizeof(long), "Z Increment", "This thirty-two bit register holds the integer and fractional parts of the Z increment used for computed Z polygon drawing." },
56 { 0xF02278, sizeof(long), "Collision control", "" },
57 { 0xF0227C, sizeof(long), "Intensity 0", "" },
58 { 0xF02280, sizeof(long), "Intensity 1", "" },
59 { 0xF02284, sizeof(long), "Intensity 2", "" },
60 { 0xF02288, sizeof(long), "Intensity 3", "" },
61 { 0xF0228C, sizeof(long), "Z 0", "These registers are analogous to the intensity registers, and are for Z buffer operation." },
62 { 0xF02290, sizeof(long), "Z 1", "These registers are analogous to the intensity registers, and are for Z buffer operation." },
63 { 0xF02294, sizeof(long), "Z 2", "These registers are analogous to the intensity registers, and are for Z buffer operation." },
64 { 0xF02298, sizeof(long), "Z 3", "These registers are analogous to the intensity registers, and are for Z buffer operation." },
65 };
66
67
68//
69HWRegsBlitterBrowserWindow::HWRegsBlitterBrowserWindow(QWidget * parent/*= 0*/) : QWidget(parent, Qt::Dialog),
70layout(new QVBoxLayout),
71TableView(new QTableView),
72model(new QStandardItemModel)
73{
74 unsigned int i;
75
76 // Set the font
77 QFont fixedFont("Lucida Console", 8, QFont::Normal);
78 fixedFont.setStyleHint(QFont::TypeWriter);
79
80 // Set the new layout with proper identation and readibility
81 model->setColumnCount(4);
82 model->setHeaderData(0, Qt::Horizontal, QObject::tr("Name"));
83 model->setHeaderData(1, Qt::Horizontal, QObject::tr("Address"));
84 model->setHeaderData(2, Qt::Horizontal, QObject::tr("# bits"));
85 model->setHeaderData(3, Qt::Horizontal, QObject::tr("Value"));
86 //model->setHeaderData(4, Qt::Horizontal, QObject::tr("Reference"));
87 // Information table
88 TableView->setModel(model);
89 TableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
90 TableView->setShowGrid(0);
91 TableView->setFont(fixedFont);
92 TableView->verticalHeader()->setDefaultSectionSize(TableView->verticalHeader()->minimumSectionSize());
93 TableView->verticalHeader()->setDefaultAlignment(Qt::AlignRight);
94
95 // Set basic infos in the layout
96 for (i = 0; i < (sizeof(TabBlitterInfoTable) / sizeof(struct BlitterInfoTable)); i++)
97 {
98 model->insertRow(i);
99 model->setItem(i, 0, new QStandardItem(QString("%1").arg(TabBlitterInfoTable[i].Name)));
100 model->setItem(i, 1, new QStandardItem(QString("0x%1").arg(TabBlitterInfoTable[i].Address, 4, 16, QChar('0'))));
101 model->setItem(i, 2, new QStandardItem(QString("%1").arg(TabBlitterInfoTable[i].NbBits * 8)));
102 //model->setItem(i, 4, new QStandardItem(QString("%1").arg(TabBlitterInfoTable[i].Type)));
103 }
104
105 // Set the layout
106 layout->addWidget(TableView);
107 setLayout(layout);
108}
109
110
111//
112HWRegsBlitterBrowserWindow::~HWRegsBlitterBrowserWindow(void)
113{
114 Reset();
115}
116
117
118//
119void HWRegsBlitterBrowserWindow::Reset(void)
120{
121}
122
123
124//
125void HWRegsBlitterBrowserWindow::RefreshContents(void)
126{
127 char string[1024];
128 unsigned int i;
129
130 if (isVisible())
131 {
132 for (i = 0; i < (sizeof(TabBlitterInfoTable) / sizeof(struct BlitterInfoTable)); i++)
133 {
134 // Emulator handles the blitter in a separate array
135 sprintf(string, "0x%08x", BlitterReadLong(TabBlitterInfoTable[i].Address));
136 model->setItem(i, 3, new QStandardItem(QString("%1").arg(string)));
137 }
138 }
139}