Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 2 additions & 21 deletions src/BitMapViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,7 @@
#include <QMessageBox>


// static to feed to PaletteDialog and be used when VDP colors aren't selected
static uint8_t currentPalette[32] = {
// RB G
0x00, 0,
0x00, 0,
0x11, 6,
0x33, 7,
0x17, 1,
0x27, 3,
0x51, 1,
0x27, 6,
0x71, 1,
0x73, 3,
0x61, 6,
0x64, 6,
0x11, 4,
0x65, 2,
0x55, 5,
0x77, 7,
};
static uint8_t currentPalette[32] = { 0 };

BitMapViewer::BitMapViewer(QWidget* parent)
: QDialog(parent)
Expand Down Expand Up @@ -69,7 +50,7 @@ BitMapViewer::BitMapViewer(QWidget* parent)
imageWidget->setVramAddress(0);
// Palette data not received from VDPDataStore yet causing black image, so
// we start by using fixed palette until VDPDataStoreDataRefreshed kicks in.
imageWidget->setPaletteSource(currentPalette);
imageWidget->setPaletteSource(VDPDataStore::instance().getDefaultPalettePointer());

// now hook up some signals and slots
connect(&VDPDataStore::instance(), &VDPDataStore::dataRefreshed,
Expand Down
25 changes: 17 additions & 8 deletions src/PaletteDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QPainter>
#include "PaletteDialog.h"
#include "Convert.h"
#include "VDPDataStore.h"
#include "ranges.h"


Expand Down Expand Up @@ -40,14 +41,12 @@ void PalettePatch::setHighlightTest(int colorNr)

void PalettePatch::paintEvent(QPaintEvent* /*event*/)
{
QPainter painter(this);
painter.setPen(isSelected ? Qt::white : QColor(myColor));
painter.setBrush(QBrush(myColor));
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
QPainter painter(this);
painter.setPen(isSelected ? Qt::white : QColor(myColor));
painter.setBrush(QBrush(myColor));
painter.drawRect(0, 0, this->width() - 1, this->height() - 1);
}



PaletteDialog::PaletteDialog(QWidget* parent)
: QDialog(parent), ui(std::make_unique<Ui::PaletteDialog>())
{
Expand Down Expand Up @@ -172,6 +171,15 @@ void PaletteDialog::syncToSource()
emit paletteSynced();
}

void PaletteDialog::restoreDefaultPalette()
{
memcpy(myPal, VDPDataStore::instance().getDefaultPalettePointer(), 32);
emit paletteChanged(myPal);
if (autoSync) {
syncToSource();
}
}

void PaletteDialog::setAutoSync(bool value)
{
if (autoSync == value) return;
Expand Down Expand Up @@ -199,8 +207,9 @@ void PaletteDialog::on_horizontalSlider_B_valueChanged(int value)

void PaletteDialog::on_buttonBox_clicked(QAbstractButton* button)
{
if (button== ui->buttonBox->button(QDialogButtonBox::Apply) ||
button== ui->buttonBox->button(QDialogButtonBox::Ok)) {
if (button== ui->buttonBox->button(QDialogButtonBox::RestoreDefaults)) {
restoreDefaultPalette();
} else if (button== ui->buttonBox->button(QDialogButtonBox::Ok)) {
syncToSource();
} else if (button== ui->buttonBox->button(QDialogButtonBox::Reset) ||
button== ui->buttonBox->button(QDialogButtonBox::Cancel)) {
Expand Down
1 change: 1 addition & 0 deletions src/PaletteDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class PaletteDialog : public QDialog
void setPalette(uint8_t* pal);
uint8_t* getPalette();
void syncToSource();
void restoreDefaultPalette();
void setAutoSync(bool value);

signals:
Expand Down
4 changes: 2 additions & 2 deletions src/PaletteDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>513</width>
<height>271</height>
<height>278</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -139,7 +139,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset</set>
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok|QDialogButtonBox::Reset|QDialogButtonBox::RestoreDefaults</set>
</property>
</widget>
</item>
Expand Down
24 changes: 2 additions & 22 deletions src/TileViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,7 @@
#include <QMessageBox>


// static to feed to PaletteDialog and be used when VDP colors aren't selected
static uint8_t currentPalette[32] = {
// RB G
0x00, 0,
0x00, 0,
0x11, 6,
0x33, 7,
0x17, 1,
0x27, 3,
0x51, 1,
0x27, 6,
0x71, 1,
0x73, 3,
0x61, 6,
0x64, 6,
0x11, 4,
0x65, 2,
0x55, 5,
0x77, 7,
};

static uint8_t currentPalette[32] = { 0 };

TileViewer::TileViewer(QWidget* parent)
: QDialog(parent), image4label(32, 32, QImage::Format_RGB32)
Expand Down Expand Up @@ -82,7 +62,7 @@ TileViewer::TileViewer(QWidget* parent)

scrollArea->setWidget(imageWidget);

imageWidget->setPaletteSource(currentPalette);
imageWidget->setPaletteSource(VDPDataStore::instance().getDefaultPalettePointer());
imageWidget->setUseBlink(cb_blinkcolors->isChecked());
imageWidget->setDrawGrid(cb_drawgrid->isChecked());

Expand Down
25 changes: 25 additions & 0 deletions src/VDPDataStore.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
#include "VDPDataStore.h"
#include "CommClient.h"

// static vector to feed PaletteDialog and be used when VDP colors aren't selected
static const uint8_t defaultPalette[32] = {
// RB G
0x00, 0,
0x00, 0,
0x11, 6,
0x33, 7,
0x17, 1,
0x27, 3,
0x51, 1,
0x27, 6,
0x71, 1,
0x73, 3,
0x61, 6,
0x64, 6,
0x11, 4,
0x65, 2,
0x55, 5,
0x77, 7,
};

class VDPDataStoreVersionCheck : public SimpleCommand
{
public:
Expand Down Expand Up @@ -149,6 +170,10 @@ const uint8_t* VDPDataStore::getVramPointer() const
{
return &vram[0];
}
const uint8_t* VDPDataStore::getDefaultPalettePointer() const
{
return defaultPalette;
}
const uint8_t* VDPDataStore::getPalettePointer() const
{
return &vram[vramSize];
Expand Down
1 change: 1 addition & 0 deletions src/VDPDataStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class VDPDataStore : public QObject, public SimpleHexRequestUser
static VDPDataStore& instance();

const uint8_t* getVramPointer() const;
const uint8_t* getDefaultPalettePointer() const;
const uint8_t* getPalettePointer() const;
const uint8_t* getRegsPointer() const;
const uint8_t* getStatusRegsPointer() const;
Expand Down