Skip to content

Commit

Permalink
Have the BitMapViewer use MSXPalette
Browse files Browse the repository at this point in the history
  • Loading branch information
turbor committed May 23, 2022
1 parent 39a9d42 commit 157b303
Show file tree
Hide file tree
Showing 5 changed files with 187 additions and 247 deletions.
38 changes: 3 additions & 35 deletions src/BitMapViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,6 @@
#include "Convert.h"
#include <QMessageBox>

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,
};

BitMapViewer::BitMapViewer(QWidget* parent)
: QDialog(parent)
, screenMod(0) // avoid UMR
Expand All @@ -38,7 +18,6 @@ BitMapViewer::BitMapViewer(QWidget* parent)
connect(useVDPRegisters, &QCheckBox::stateChanged,this, &BitMapViewer::on_useVDPRegisters_stateChanged);

connect(saveImageButton, &QPushButton::clicked, this, &BitMapViewer::on_saveImageButton_clicked);
connect(editPaletteButton, &QPushButton::clicked, this, &BitMapViewer::on_editPaletteButton_clicked);
connect(useVDPPalette, &QCheckBox::stateChanged, this, &BitMapViewer::on_useVDPPalette_stateChanged);
connect(zoomLevel, qOverload<double>(&QDoubleSpinBox::valueChanged), this, &BitMapViewer::on_zoomLevel_valueChanged);

Expand All @@ -61,10 +40,9 @@ BitMapViewer::BitMapViewer(QWidget* parent)
useVDP = useVDPRegisters->isChecked();

const uint8_t* vram = VDPDataStore::instance().getVramPointer();
const uint8_t* palette = VDPDataStore::instance().getPalettePointer();
imageWidget->setVramSource(vram);
imageWidget->setVramAddress(0);
imageWidget->setPaletteSource(palette);
imageWidget->setPaletteSource(VDPDataStore::instance().getPalette(paletteVDP));

//now hook up some signals and slots
connect(&VDPDataStore::instance(), &VDPDataStore::dataRefreshed,
Expand Down Expand Up @@ -246,23 +224,13 @@ void BitMapViewer::on_saveImageButton_clicked(bool /*checked*/)
"Sorry, the save image dialog is not yet implemented");
}

void BitMapViewer::on_editPaletteButton_clicked(bool /*checked*/)
{
useVDPPalette->setChecked(false);
QMessageBox::information(
this,
"Not yet implemented",
"Sorry, the palette editor is not yet implemented, "
"only disabling 'Use VDP palette registers' for now");
}

void BitMapViewer::on_useVDPPalette_stateChanged(int state)
{
if (state) {
const uint8_t* palette = VDPDataStore::instance().getPalettePointer();
imageWidget->setPaletteSource(palette);
imageWidget->setPaletteSource(VDPDataStore::instance().getPalette(paletteVDP));
} else {
imageWidget->setPaletteSource(defaultPalette);
imageWidget->setPaletteSource(VDPDataStore::instance().getPalette(paletteBitmap));
}
imageWidget->refresh();
}
Expand Down
2 changes: 1 addition & 1 deletion src/BitMapViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QDialog>

class VramBitMappedView;
class MSXPalette;

class BitMapViewer : public QDialog, private Ui::BitMapViewer
{
Expand All @@ -25,7 +26,6 @@ class BitMapViewer : public QDialog, private Ui::BitMapViewer
void on_useVDPRegisters_stateChanged(int state);

void on_saveImageButton_clicked(bool checked);
void on_editPaletteButton_clicked(bool checked);
void on_useVDPPalette_stateChanged(int state);
void on_zoomLevel_valueChanged(double d);

Expand Down
Loading

0 comments on commit 157b303

Please sign in to comment.