Added options to disable drawing of BG/Window/Sprites
authorslack <slack@codemaniacs.com>
Tue, 19 May 2009 17:03:13 +0000 (19:03 +0200)
committerslack <slack@codemaniacs.com>
Tue, 19 May 2009 17:03:13 +0000 (19:03 +0200)
core/GBVideo.cc
core/GBVideo.h
qtboi/QtBoiMainWindow.cc
qtboi/QtBoiMainWindow.h

index 2981fe93380d5952d8ea8628c36ea4aecc7c793e..1af8e0cb7943f42dbdbdb6943711455bef3ede21 100644 (file)
@@ -37,6 +37,7 @@ GBVideo::GBVideo(GameBoy *core):
        screen(0),
        oldscreen(0), newscreen(0),
        display_mode(NORMAL),
+    background_enabled(true), window_enabled(true), sprites_enabled(true),
        cycles_until_next_update(0)
 {
        oldscreen = new u8[160*144];
@@ -269,7 +270,7 @@ void GBVideo::draw()
                int line_base = 160*LY;
 
                // Draw the background
-               if (check_bit(LCDC, 0))  // is BG display active?
+               if (background_enabled && check_bit(LCDC, 0))  // is BG display active?
                {
                        u16 tile_map_addr  = check_bit(LCDC,3) ? 0x1C00  : 0x1800;
                        u16 tile_data_addr = check_bit(LCDC,4) ? 0x0000 : 0x0800;
@@ -309,7 +310,7 @@ void GBVideo::draw()
        
                //logger.trace("LCDC=0x", std::hex, LCDC, " LY=", LY, " WY=", WY);
                // Draw the window
-               if (check_bit(LCDC, 5) && LY > WY && LY < 144)  // is BG display active?
+               if (window_enabled && check_bit(LCDC, 5) && LY > WY && LY < 144)  // is BG display active?
                {
                        u16 tile_map_addr  = check_bit(LCDC,6) ? 0x1C00  : 0x1800;
                        u16 tile_data_addr = check_bit(LCDC,4) ? 0x0000 : 0x0800;
@@ -348,7 +349,7 @@ void GBVideo::draw()
                }
 
                // ------- SPRITES
-               if (check_bit(LCDC, 1))
+               if (sprites_enabled && check_bit(LCDC, 1))
                {
                        int sprite_size = (LCDC & 0x4) >> 2;
                        std::vector<Sprite> v;
index aac08309ad12d843493c5fc1120a22d37f33a1a2..8de42558de4cdc036cf19fa7484e14f56072efc6 100644 (file)
@@ -73,6 +73,9 @@ class GBVideo
 
        private:
        DisplayMode display_mode;
+    bool background_enabled;
+    bool window_enabled;
+    bool sprites_enabled;
        
        public:
        int cycles_until_next_update;
@@ -98,6 +101,9 @@ class GBVideo
        void DMA_OAM (const u16 src);
 
        // drawing control
+    void draw_background(bool b) { background_enabled = b; }
+    void draw_window(bool b)     { window_enabled = b; }
+    void draw_sprites(bool b)    { sprites_enabled = b; }
        void draw();
        u32 update();
        void set_display_mode(DisplayMode mode) { display_mode = mode; }
index 685472aff50b436ef2d78ce1a1b3d2dad60db10a..e87b408931263854cde15af405ebd5847d1b0025 100644 (file)
@@ -108,8 +108,8 @@ void QtBoiMainWindow::createActions()
        viewDisassemblyWindow = new QAction(tr("&Disassembly window"), this);
        viewStatusWindow      = new QAction(tr("&Status window"), this);
        viewDisassemblyWindow->setCheckable(true);
-       viewStatusWindow->setCheckable(true);
        viewDisassemblyWindow->setChecked(true);
+       viewStatusWindow->setCheckable(true);
        viewStatusWindow->setChecked(true);
 
        scalingGroup   = new QActionGroup(this);
@@ -118,9 +118,18 @@ void QtBoiMainWindow::createActions()
        scalingScale2X = new QAction(tr("Scale&2X"), scalingGroup);
        scalingNone->setCheckable(true);
        scalingQImage->setCheckable(true);
-       scalingScale2X->setCheckable(true);
        scalingQImage->setChecked(true);
+       scalingScale2X->setCheckable(true);
 
+    debugVideoDrawBackground = new QAction(tr("Draw background"), this);
+    debugVideoDrawWindow     = new QAction(tr("Draw window"), this);
+    debugVideoDrawSprites    = new QAction(tr("Draw sprites"), this);
+    debugVideoDrawBackground->setCheckable(true);
+    debugVideoDrawBackground->setChecked(true);
+    debugVideoDrawWindow->setCheckable(true);
+    debugVideoDrawWindow->setChecked(true);
+    debugVideoDrawSprites->setCheckable(true);
+    debugVideoDrawSprites->setChecked(true);
 
        loadROM->setShortcut(QKeySequence(tr("Ctrl+O", "File|Load ROM...")));
        emulatorCont->setShortcut(QKeySequence(tr("F5", "Emulator|Go")));
@@ -141,6 +150,9 @@ void QtBoiMainWindow::createActions()
        connect(scalingNone, SIGNAL(triggered()), this, SLOT(onScalingNone()));
        connect(scalingQImage, SIGNAL(triggered()), this, SLOT(onScalingQImage()));
        connect(scalingScale2X, SIGNAL(triggered()), this, SLOT(onScalingScale2X()));
+    connect(debugVideoDrawBackground, SIGNAL(triggered()), this, SLOT(onDebugVideoDrawBackground()));
+    connect(debugVideoDrawWindow, SIGNAL(triggered()), this, SLOT(onDebugVideoDrawWindow()));
+    connect(debugVideoDrawSprites, SIGNAL(triggered()), this, SLOT(onDebugVideoDrawSprites()));
 }
 
 
@@ -172,6 +184,10 @@ void QtBoiMainWindow::createMenu()
        QMenu *debug;
        debug = menuBar()->addMenu(tr("&Debug"));
        debug->addAction(emulatorStep);
+    QMenu *debugVideo = debug->addMenu(tr("&Video"));
+    debugVideo->addAction(debugVideoDrawBackground);
+    debugVideo->addAction(debugVideoDrawWindow);
+    debugVideo->addAction(debugVideoDrawSprites);
 
        connect(quit, SIGNAL(triggered()), qApp, SLOT(quit()));
        connect(loadROM, SIGNAL(triggered()), this, SLOT(onLoadROM()));
@@ -521,4 +537,18 @@ void QtBoiMainWindow::saveTags()
        }
 }
 
+void QtBoiMainWindow::onDebugVideoDrawBackground()
+{
+    emuThread->gb.video.draw_background(debugVideoDrawBackground->isChecked());
+}
+
+void QtBoiMainWindow::onDebugVideoDrawWindow()
+{
+    emuThread->gb.video.draw_window(debugVideoDrawWindow->isChecked());
+}
+
+void QtBoiMainWindow::onDebugVideoDrawSprites()
+{
+    emuThread->gb.video.draw_sprites(debugVideoDrawSprites->isChecked());
+}
 
index 8e241136c366b0c6c5a636a03b7e6157e0a3a962..4aef6322db9039e9e7c3ca1375fa7c7cbe409163 100644 (file)
@@ -37,6 +37,9 @@ class QtBoiMainWindow: public QMainWindow
                void onScalingScale2X();
                void onViewDisassemblyWindow();
                void onViewStatusWindow();
+        void onDebugVideoDrawBackground();
+        void onDebugVideoDrawWindow();
+        void onDebugVideoDrawSprites();
 
        private:
                enum ScalingMethod {SCALING_NONE, SCALING_QIMAGE, SCALING_SCALE2X};
@@ -85,6 +88,10 @@ class QtBoiMainWindow: public QMainWindow
                QAction *scalingNone;
                QAction *scalingQImage;
                QAction *scalingScale2X;
+
+        QAction *debugVideoDrawBackground;
+        QAction *debugVideoDrawWindow;
+        QAction *debugVideoDrawSprites;
 };