Qt: Improve tile view

This commit is contained in:
Jeffrey Pfau 2016-07-22 23:43:00 -07:00
parent ccf66299e6
commit 701869a6ef
6 changed files with 45 additions and 19 deletions

View File

@ -337,8 +337,9 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
}
static void GBAVideoSoftwareRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) {
UNUSED(renderer);
UNUSED(address);
if (renderer->cache) {
GBAVideoTileCacheWriteVRAM(renderer->cache, address);
}
}
static void GBAVideoSoftwareRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam) {
@ -370,6 +371,9 @@ static void GBAVideoSoftwareRendererWritePalette(struct GBAVideoRenderer* render
} else if (softwareRenderer->blendEffect == BLEND_DARKEN) {
softwareRenderer->variantPalette[address >> 1] = _darken(color, softwareRenderer->bldy);
}
if (renderer->cache) {
GBAVideoTileCacheWritePalette(renderer->cache, address);
}
}
static void _breakWindow(struct GBAVideoSoftwareRenderer* softwareRenderer, struct WindowN* win, int y) {

View File

@ -8,6 +8,7 @@
#include "core/sync.h"
#include "gba/gba.h"
#include "gba/io.h"
#include "gba/renderers/tile-cache.h"
#include "gba/rr/rr.h"
#include "gba/serialize.h"
@ -55,7 +56,8 @@ static struct GBAVideoRenderer dummyRenderer = {
.writeOAM = GBAVideoDummyRendererWriteOAM,
.drawScanline = GBAVideoDummyRendererDrawScanline,
.finishFrame = GBAVideoDummyRendererFinishFrame,
.getPixels = GBAVideoDummyRendererGetPixels
.getPixels = GBAVideoDummyRendererGetPixels,
.cache = NULL
};
void GBAVideoInit(struct GBAVideo* video) {
@ -104,6 +106,7 @@ void GBAVideoDeinit(struct GBAVideo* video) {
void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* renderer) {
video->renderer->deinit(video->renderer);
renderer->cache = video->renderer->cache;
video->renderer = renderer;
renderer->palette = video->palette;
renderer->vram = video->vram;
@ -262,16 +265,16 @@ static uint16_t GBAVideoDummyRendererWriteVideoRegister(struct GBAVideoRenderer*
}
static void GBAVideoDummyRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) {
UNUSED(renderer);
UNUSED(address);
// Nothing to do
if (renderer->cache) {
GBAVideoTileCacheWriteVRAM(renderer->cache, address);
}
}
static void GBAVideoDummyRendererWritePalette(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
UNUSED(renderer);
UNUSED(address);
UNUSED(value);
// Nothing to do
if (renderer->cache) {
GBAVideoTileCacheWritePalette(renderer->cache, address);
}
}
static void GBAVideoDummyRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam) {

View File

@ -170,6 +170,7 @@ struct GBAVideoRenderer {
uint16_t* palette;
uint16_t* vram;
union GBAOAM* oam;
struct GBAVideoTileCache* cache;
bool disableBG[4];
bool disableOBJ;

View File

@ -25,14 +25,16 @@ TileView::TileView(GameController* controller, QWidget* parent)
GBAVideoTileCacheInit(&m_tileCache);
m_ui.preview->setDimensions(QSize(8, 8));
updateTiles();
m_updateTimer.setSingleShot(true);
m_updateTimer.setInterval(10);
connect(&m_updateTimer, SIGNAL(timeout()), this, SLOT(updateTiles()));
const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
m_ui.tileId->setFont(font);
m_ui.address->setFont(font);
connect(m_controller, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(updateTiles()));
connect(m_controller, SIGNAL(frameAvailable(const uint32_t*)), &m_updateTimer, SLOT(start()));
connect(m_controller, SIGNAL(gameStopped(mCoreThread*)), this, SLOT(close()));
connect(m_ui.tiles, SIGNAL(indexPressed(int)), this, SLOT(selectIndex(int)));
connect(m_ui.paletteId, SIGNAL(valueChanged(int)), this, SLOT(updatePalette(int)));
@ -40,6 +42,11 @@ TileView::TileView(GameController* controller, QWidget* parent)
}
TileView::~TileView() {
if (m_controller->isLoaded() && m_controller->thread() && m_controller->thread()->core) {
GBA* gba = static_cast<GBA*>(m_controller->thread()->core->board);
gba->video.renderer->cache = nullptr;
}
GBAVideoTileCacheDeinit(&m_tileCache);
}
@ -124,8 +131,5 @@ void TileView::resizeEvent(QResizeEvent*) {
}
void TileView::showEvent(QShowEvent*) {
// XXX: Figure out how to prevent the first resizeEvent
QTimer::singleShot(10, [this]() {
updateTiles(true);
});
m_updateTimer.start();
}

View File

@ -42,6 +42,7 @@ private:
GameController* m_controller;
GBAVideoTileCache m_tileCache;
int m_paletteId;
QTimer m_updateTimer;
};
}

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>509</width>
<height>265</height>
<width>498</width>
<height>335</height>
</rect>
</property>
<property name="windowTitle">
@ -116,7 +116,20 @@
</property>
</widget>
</item>
<item row="0" column="1" rowspan="3">
<item row="3" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" rowspan="4">
<widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
@ -132,7 +145,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>282</width>
<width>271</width>
<height>768</height>
</rect>
</property>