mirror of https://github.com/mgba-emu/mgba.git
Qt: Improve tile view
This commit is contained in:
parent
ccf66299e6
commit
701869a6ef
|
@ -337,8 +337,9 @@ static uint16_t GBAVideoSoftwareRendererWriteVideoRegister(struct GBAVideoRender
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBAVideoSoftwareRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) {
|
static void GBAVideoSoftwareRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) {
|
||||||
UNUSED(renderer);
|
if (renderer->cache) {
|
||||||
UNUSED(address);
|
GBAVideoTileCacheWriteVRAM(renderer->cache, address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBAVideoSoftwareRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam) {
|
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) {
|
} else if (softwareRenderer->blendEffect == BLEND_DARKEN) {
|
||||||
softwareRenderer->variantPalette[address >> 1] = _darken(color, softwareRenderer->bldy);
|
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) {
|
static void _breakWindow(struct GBAVideoSoftwareRenderer* softwareRenderer, struct WindowN* win, int y) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "core/sync.h"
|
#include "core/sync.h"
|
||||||
#include "gba/gba.h"
|
#include "gba/gba.h"
|
||||||
#include "gba/io.h"
|
#include "gba/io.h"
|
||||||
|
#include "gba/renderers/tile-cache.h"
|
||||||
#include "gba/rr/rr.h"
|
#include "gba/rr/rr.h"
|
||||||
#include "gba/serialize.h"
|
#include "gba/serialize.h"
|
||||||
|
|
||||||
|
@ -55,7 +56,8 @@ static struct GBAVideoRenderer dummyRenderer = {
|
||||||
.writeOAM = GBAVideoDummyRendererWriteOAM,
|
.writeOAM = GBAVideoDummyRendererWriteOAM,
|
||||||
.drawScanline = GBAVideoDummyRendererDrawScanline,
|
.drawScanline = GBAVideoDummyRendererDrawScanline,
|
||||||
.finishFrame = GBAVideoDummyRendererFinishFrame,
|
.finishFrame = GBAVideoDummyRendererFinishFrame,
|
||||||
.getPixels = GBAVideoDummyRendererGetPixels
|
.getPixels = GBAVideoDummyRendererGetPixels,
|
||||||
|
.cache = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
void GBAVideoInit(struct GBAVideo* video) {
|
void GBAVideoInit(struct GBAVideo* video) {
|
||||||
|
@ -104,6 +106,7 @@ void GBAVideoDeinit(struct GBAVideo* video) {
|
||||||
|
|
||||||
void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* renderer) {
|
void GBAVideoAssociateRenderer(struct GBAVideo* video, struct GBAVideoRenderer* renderer) {
|
||||||
video->renderer->deinit(video->renderer);
|
video->renderer->deinit(video->renderer);
|
||||||
|
renderer->cache = video->renderer->cache;
|
||||||
video->renderer = renderer;
|
video->renderer = renderer;
|
||||||
renderer->palette = video->palette;
|
renderer->palette = video->palette;
|
||||||
renderer->vram = video->vram;
|
renderer->vram = video->vram;
|
||||||
|
@ -262,16 +265,16 @@ static uint16_t GBAVideoDummyRendererWriteVideoRegister(struct GBAVideoRenderer*
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBAVideoDummyRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) {
|
static void GBAVideoDummyRendererWriteVRAM(struct GBAVideoRenderer* renderer, uint32_t address) {
|
||||||
UNUSED(renderer);
|
if (renderer->cache) {
|
||||||
UNUSED(address);
|
GBAVideoTileCacheWriteVRAM(renderer->cache, address);
|
||||||
// Nothing to do
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBAVideoDummyRendererWritePalette(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
|
static void GBAVideoDummyRendererWritePalette(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
|
||||||
UNUSED(renderer);
|
|
||||||
UNUSED(address);
|
|
||||||
UNUSED(value);
|
UNUSED(value);
|
||||||
// Nothing to do
|
if (renderer->cache) {
|
||||||
|
GBAVideoTileCacheWritePalette(renderer->cache, address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GBAVideoDummyRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam) {
|
static void GBAVideoDummyRendererWriteOAM(struct GBAVideoRenderer* renderer, uint32_t oam) {
|
||||||
|
|
|
@ -170,6 +170,7 @@ struct GBAVideoRenderer {
|
||||||
uint16_t* palette;
|
uint16_t* palette;
|
||||||
uint16_t* vram;
|
uint16_t* vram;
|
||||||
union GBAOAM* oam;
|
union GBAOAM* oam;
|
||||||
|
struct GBAVideoTileCache* cache;
|
||||||
|
|
||||||
bool disableBG[4];
|
bool disableBG[4];
|
||||||
bool disableOBJ;
|
bool disableOBJ;
|
||||||
|
|
|
@ -25,14 +25,16 @@ TileView::TileView(GameController* controller, QWidget* parent)
|
||||||
GBAVideoTileCacheInit(&m_tileCache);
|
GBAVideoTileCacheInit(&m_tileCache);
|
||||||
|
|
||||||
m_ui.preview->setDimensions(QSize(8, 8));
|
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);
|
const QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
|
||||||
|
|
||||||
m_ui.tileId->setFont(font);
|
m_ui.tileId->setFont(font);
|
||||||
m_ui.address->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_controller, SIGNAL(gameStopped(mCoreThread*)), this, SLOT(close()));
|
||||||
connect(m_ui.tiles, SIGNAL(indexPressed(int)), this, SLOT(selectIndex(int)));
|
connect(m_ui.tiles, SIGNAL(indexPressed(int)), this, SLOT(selectIndex(int)));
|
||||||
connect(m_ui.paletteId, SIGNAL(valueChanged(int)), this, SLOT(updatePalette(int)));
|
connect(m_ui.paletteId, SIGNAL(valueChanged(int)), this, SLOT(updatePalette(int)));
|
||||||
|
@ -40,6 +42,11 @@ TileView::TileView(GameController* controller, QWidget* parent)
|
||||||
}
|
}
|
||||||
|
|
||||||
TileView::~TileView() {
|
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);
|
GBAVideoTileCacheDeinit(&m_tileCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +131,5 @@ void TileView::resizeEvent(QResizeEvent*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void TileView::showEvent(QShowEvent*) {
|
void TileView::showEvent(QShowEvent*) {
|
||||||
// XXX: Figure out how to prevent the first resizeEvent
|
m_updateTimer.start();
|
||||||
QTimer::singleShot(10, [this]() {
|
|
||||||
updateTiles(true);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ private:
|
||||||
GameController* m_controller;
|
GameController* m_controller;
|
||||||
GBAVideoTileCache m_tileCache;
|
GBAVideoTileCache m_tileCache;
|
||||||
int m_paletteId;
|
int m_paletteId;
|
||||||
|
QTimer m_updateTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>509</width>
|
<width>498</width>
|
||||||
<height>265</height>
|
<height>335</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -116,7 +116,20 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
<sizepolicy hsizetype="Minimum" vsizetype="Expanding">
|
||||||
|
@ -132,7 +145,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>282</width>
|
<width>271</width>
|
||||||
<height>768</height>
|
<height>768</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue