Skip to content

Commit f7c0640

Browse files
committed
VDPRegViewer autodetects VDP in openMSX
Since openMSX 18.0-106-ge55a4a904 (commit e55a4a9044b...) the TCL command 'machine_info device VDP' now also returns the version string from the machines XML config. This is now used to select the correct view for the VDPRegViewer when decoding the VDP registers.
1 parent 3592c72 commit f7c0640

File tree

5 files changed

+130
-10
lines changed

5 files changed

+130
-10
lines changed

src/VDPDataStore.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,33 @@ class VDPDataStoreVRAMSizeCheck : public SimpleCommand
5454
};
5555

5656

57+
class VDPDataStoreVDPVersionCheck : public SimpleCommand
58+
{
59+
public:
60+
VDPDataStoreVDPVersionCheck(VDPDataStore& dataStore_)
61+
: SimpleCommand("dict get [machine_info device VDP] version")
62+
, dataStore(dataStore_)
63+
{
64+
}
65+
66+
void replyOk(const QString& message) override
67+
{
68+
//printf("dataStore.vramSize %i\n", dataStore.vramSize);
69+
dataStore.machineVDPVersionString = message.toStdString();
70+
emit dataStore.VDPVersionChanged(message);
71+
delete this;
72+
}
73+
void replyNok(const QString& /*message*/) override
74+
{
75+
dataStore.machineVDPVersionString = "unknown";
76+
delete this;
77+
}
78+
79+
private:
80+
VDPDataStore& dataStore;
81+
};
82+
83+
5784
static constexpr unsigned MAX_VRAM_SIZE = 0x30000;
5885
static constexpr unsigned MAX_TOTAL_SIZE = MAX_VRAM_SIZE + 32 + 16 + 64 + 2;
5986

@@ -83,6 +110,7 @@ void VDPDataStore::refresh()
83110

84111
void VDPDataStore::refresh1()
85112
{
113+
CommClient::instance().sendCommand(new VDPDataStoreVDPVersionCheck(*this));
86114
CommClient::instance().sendCommand(new VDPDataStoreVRAMSizeCheck(*this));
87115
}
88116

@@ -133,6 +161,11 @@ MSXPalette* VDPDataStore::getPalette(int index)
133161
return &palettes[index];
134162
}
135163

164+
std::optional<std::string> VDPDataStore::getVDPVersion() const
165+
{
166+
return machineVDPVersionString;
167+
}
168+
136169
size_t VDPDataStore::getVRAMSize() const
137170
{
138171
return vramSize;

src/VDPDataStore.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,14 @@ class VDPDataStore : public QObject, public SimpleHexRequestUser
2929
const uint8_t* getVdpVramPointer() const;
3030

3131
MSXPalette* getPalette(int index);
32+
std::optional<std::string> getVDPVersion() const;
3233
size_t getVRAMSize() const;
3334

3435
void refresh();
3536

3637
signals:
37-
void dataRefreshed(); // The refresh got the new data
38+
void dataRefreshed(); // The refresh got the new data
39+
void VDPVersionChanged(QString VDPversion); // New VDP version received during refresh
3840

3941
/** This might become handy later on, for now we only need the dataRefreshed
4042
*
@@ -59,9 +61,11 @@ class VDPDataStore : public QObject, public SimpleHexRequestUser
5961
size_t vramSize;
6062

6163
std::optional<std::string> debuggableNameVRAM; // VRAM debuggable name
64+
std::optional<std::string> machineVDPVersionString; // VRAM debuggable name
6265

6366
friend class VDPDataStoreVersionCheck;
6467
friend class VDPDataStoreVRAMSizeCheck;
68+
friend class VDPDataStoreVDPVersionCheck;
6569
};
6670

6771
#endif // VDPDATASTORE_H

src/VDPRegViewer.cpp

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ VDPRegViewer::VDPRegViewer(QWidget *parent)
3838
{
3939
setupUi(this);
4040
connect(VDPcomboBox, qOverload<int>(&QComboBox::currentIndexChanged), this, &VDPRegViewer::on_VDPcomboBox_currentIndexChanged);
41-
41+
connect(cb_useOpenMSXVDP, &QCheckBox::stateChanged, this, &VDPRegViewer::on_cb_useOpenMSXVDP_stateChanged);
42+
connect(&VDPDataStore::instance(),&VDPDataStore::VDPVersionChanged, this, &VDPRegViewer::on_VDPVersionChanged);
4243
vdpId = 99; // make sure that we parse the first time the status registers are read
4344
vdpId = VDP_V9958; //quick hack for now
4445

@@ -954,17 +955,67 @@ void VDPRegViewer::registerBitChanged(int reg, int bit, bool state)
954955

955956
void VDPRegViewer::on_VDPcomboBox_currentIndexChanged(int index)
956957
{
958+
int newVdpId = VDP_TMS99X8;
957959
switch (index) {
958960
case 0:
959-
vdpId = VDP_V9958;
961+
newVdpId = VDP_V9958;
960962
break;
961963
case 1:
962-
vdpId = VDP_V9938;
964+
newVdpId = VDP_V9938;
963965
break;
964966
case 2:
965-
vdpId = VDP_TMS99X8;
967+
newVdpId = VDP_TMS99X8;
966968
break;
967-
}
969+
};
970+
971+
// on_VDPVersionChanged might have changed vdpId already so avoid calling decode twice
972+
if (newVdpId != vdpId){
973+
vdpId = newVdpId;
974+
decodeStatusVDPRegs();
975+
decodeVDPRegs();
976+
};
977+
978+
}
979+
980+
void VDPRegViewer::on_VDPVersionChanged(QString VDPversion)
981+
{
982+
if (!cb_useOpenMSXVDP->isChecked()){
983+
label_VDPreported->setText(VDPversion);
984+
return;
985+
};
986+
987+
if (VDPversion == label_VDPreported->text()){
988+
return;
989+
} else {
990+
label_VDPreported->setText(VDPversion);
991+
};
992+
VDPVersion_to_combobox(VDPversion);
993+
}
994+
995+
void VDPRegViewer::on_cb_useOpenMSXVDP_stateChanged(int arg1)
996+
{
997+
if (arg1 == Qt::Checked){
998+
QString VDPversion = label_VDPreported->text();
999+
VDPVersion_to_combobox(VDPversion);
1000+
};
1001+
}
1002+
1003+
void VDPRegViewer::VDPVersion_to_combobox(QString VDPversion)
1004+
{
1005+
if (VDPversion == "unknown"){
1006+
return;
1007+
} else if (VDPversion == "V9958"){
1008+
vdpId = VDP_V9958;
1009+
VDPcomboBox->setCurrentIndex(0);
1010+
} else if (VDPversion == "V9938"){
1011+
vdpId = VDP_V9938;
1012+
VDPcomboBox->setCurrentIndex(1);
1013+
} else {
1014+
vdpId = VDP_TMS99X8;
1015+
VDPcomboBox->setCurrentIndex(2);
1016+
};
9681017
decodeStatusVDPRegs();
9691018
decodeVDPRegs();
9701019
}
1020+
1021+

src/VDPRegViewer.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class buttonHighlightDispatcher : public QObject
2828

2929

3030
class VDPRegViewer : public QDialog, public SimpleHexRequestUser,
31-
private Ui::VDPRegisters
31+
private Ui::VDPRegisters
3232
{
3333
Q_OBJECT
3434
public:
@@ -37,8 +37,12 @@ class VDPRegViewer : public QDialog, public SimpleHexRequestUser,
3737
void refresh();
3838
void registerBitChanged(int reg, int bit, bool state);
3939

40-
//quick hack while no auto-detection...
40+
//override auto-detection or in case of older openMSX...
4141
void on_VDPcomboBox_currentIndexChanged(int index);
42+
void on_VDPVersionChanged(QString VDPversion);
43+
44+
private slots:
45+
void on_cb_useOpenMSXVDP_stateChanged(int arg1);
4246

4347
private:
4448
void decodeVDPRegs();
@@ -59,6 +63,8 @@ class VDPRegViewer : public QDialog, public SimpleHexRequestUser,
5963
uint8_t regs[64 + 16 + 2];
6064
buttonHighlightDispatcher* modeBitsDispat;
6165
int vdpId;
66+
void VDPVersion_to_combobox(QString VDPversion);
67+
6268
};
6369

6470
#endif /* VDPSTATUSREGVIEWER_H */

src/VDPRegistersExplained.ui

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10951,6 +10951,31 @@ p, li { white-space: pre-wrap; }
1095110951
</item>
1095210952
<item>
1095310953
<layout class="QHBoxLayout" name="horizontalLayout_6">
10954+
<item>
10955+
<widget class="QCheckBox" name="cb_useOpenMSXVDP">
10956+
<property name="text">
10957+
<string>use VDP reported by openMSX: </string>
10958+
</property>
10959+
<property name="checked">
10960+
<bool>true</bool>
10961+
</property>
10962+
</widget>
10963+
</item>
10964+
<item>
10965+
<widget class="QLabel" name="label_VDPreported">
10966+
<property name="font">
10967+
<font>
10968+
<bold>true</bold>
10969+
</font>
10970+
</property>
10971+
<property name="toolTip">
10972+
<string>older versions of openMSX do not expose this info</string>
10973+
</property>
10974+
<property name="text">
10975+
<string>unknown</string>
10976+
</property>
10977+
</widget>
10978+
</item>
1095410979
<item>
1095510980
<spacer name="horizontalSpacer">
1095610981
<property name="orientation">
@@ -10968,10 +10993,11 @@ p, li { white-space: pre-wrap; }
1096810993
<widget class="QLabel" name="label">
1096910994
<property name="text">
1097010995
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
10971-
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
10996+
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;meta charset=&quot;utf-8&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
1097210997
p, li { white-space: pre-wrap; }
10998+
hr { height: 1px; border-width: 0; }
1097310999
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;&quot;&gt;
10974-
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-weight:600; font-style:italic;&quot;&gt;Quick hack&lt;/span&gt;&lt;span style=&quot; font-size:10pt; font-style:italic;&quot;&gt; use this to switch between VDP chip, since no autodetection yet in the code&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
11000+
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:10pt; font-style:italic;&quot;&gt;Decode VDP register for video chip&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
1097511001
</property>
1097611002
<property name="textFormat">
1097711003
<enum>Qt::RichText</enum>

0 commit comments

Comments
 (0)