From: slack Date: Fri, 13 Mar 2009 03:34:05 +0000 (+0100) Subject: Changed palette. Added QLabel with status string. X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=95132a63d9fd4f7e79ef8a331c97f481b1d9d216;p=wenboi.git Changed palette. Added QLabel with status string. --- diff --git a/qtboi/QtBoiEmuThread.cc b/qtboi/QtBoiEmuThread.cc index f4b1a28..37c4c67 100644 --- a/qtboi/QtBoiEmuThread.cc +++ b/qtboi/QtBoiEmuThread.cc @@ -155,7 +155,6 @@ void QtBoiEmuThread::run() break; } - print_run_result(gb, status); if (isPaused) { emit emulationPaused(); diff --git a/qtboi/QtBoiMainWindow.cc b/qtboi/QtBoiMainWindow.cc index 4f2549f..1e4c70f 100644 --- a/qtboi/QtBoiMainWindow.cc +++ b/qtboi/QtBoiMainWindow.cc @@ -7,21 +7,31 @@ #include #include #include -#include +#include #include QtBoiMainWindow::QtBoiMainWindow(QWidget *parent) :QMainWindow(parent), emuThread(0) { - screen = new QImage(160, 144, QImage::Format_Indexed8); - screen->setNumColors(7); - screen->setColor(6, qRgb(0,0,0)); - screen->setColor(5, qRgb(42,42,42)); - screen->setColor(4, qRgb(85,85,85)); - screen->setColor(3, qRgb(127,127,127)); - screen->setColor(2, qRgb(170,170,170)); - screen->setColor(1, qRgb(212,212,212)); - screen->setColor(0, qRgb(255,255,255)); + screen_image = new QImage(160, 144, QImage::Format_Indexed8); + screen_image->setNumColors(7); + // gray palette + //screen_image->setColor(6, qRgb(0,0,0)); + //screen_image->setColor(5, qRgb(42,42,42)); + //screen_image->setColor(4, qRgb(85,85,85)); + //screen_image->setColor(3, qRgb(127,127,127)); + //screen_image->setColor(2, qRgb(170,170,170)); + //screen_image->setColor(1, qRgb(212,212,212)); + //screen_image->setColor(0, qRgb(255,255,255)); + + // greenish palette + screen_image->setColor(6, qRgb(64,64,64)); + screen_image->setColor(5, qRgb(82,82,53)); + screen_image->setColor(4, qRgb(101,101,42)); + screen_image->setColor(3, qRgb(120,120,31)); + screen_image->setColor(2, qRgb(139,139,21)); + screen_image->setColor(1, qRgb(166,166,10)); + screen_image->setColor(0, qRgb(192,192,0)); emuThread = new QtBoiEmuThread(this); emuThread->start(); @@ -51,11 +61,25 @@ QtBoiMainWindow::QtBoiMainWindow(QWidget *parent) connect(emulatorStep, SIGNAL(triggered()), emuThread, SLOT(step())); connect(emulatorReset, SIGNAL(triggered()), emuThread, SLOT(reset())); connect(emuThread, SIGNAL(redraw(const uchar*)), this, SLOT(onRedraw(const uchar*))); + connect(emuThread, SIGNAL(emulationPaused()), this, SLOT(onPause())); resize(640,480); - centralWindow = new QLabel(this); + centralWindow = new QWidget(this); setCentralWidget(centralWindow); - centralWindow->move(0,0); + + QVBoxLayout *vbox = new QVBoxLayout(centralWindow); + + screen = new QLabel(centralWindow); + screen->resize(320,288); + + status = new QLabel; + status->setFont(QFont("courier")); + + vbox->addWidget(screen); + vbox->addWidget(status); + + centralWindow->setLayout(vbox); + } QtBoiMainWindow::~QtBoiMainWindow() @@ -110,11 +134,17 @@ void QtBoiMainWindow::onLoadROM() void QtBoiMainWindow::onRedraw(const uchar *buffer) { - uchar *pixels = screen->bits(); + uchar *pixels = screen_image->bits(); memcpy(pixels, buffer, 160*144); - centralWindow->setPixmap(QPixmap::fromImage(screen->scaled(320,288))); + screen->setPixmap(QPixmap::fromImage(screen_image->scaled(320,288))); } +void QtBoiMainWindow::onPause() +{ + status->setText(QString(emuThread->gb.status_string().c_str())); +} + + void QtBoiMainWindow::keyPressEvent(QKeyEvent *event) { if (emuThread->isPaused) { diff --git a/qtboi/QtBoiMainWindow.h b/qtboi/QtBoiMainWindow.h index 17edd0f..29f3e16 100644 --- a/qtboi/QtBoiMainWindow.h +++ b/qtboi/QtBoiMainWindow.h @@ -17,9 +17,10 @@ class QtBoiMainWindow: public QMainWindow QtBoiMainWindow(QWidget *parent=0); ~QtBoiMainWindow(); - public slots: - void onLoadROM(); + public slots: + void onLoadROM(); void onRedraw(const uchar *buffer); + void onPause(); private: // private functions @@ -32,8 +33,10 @@ class QtBoiMainWindow: public QMainWindow QtBoiEmuThread *emuThread; - QLabel *centralWindow; - QImage *screen; + QWidget *centralWindow; + QLabel *screen; + QImage *screen_image; + QLabel *status; QAction *loadROM; QAction *quit;