mirror of https://github.com/mgba-emu/mgba.git
Qt: Add GB to sprite viewer, fix tile addresses
This commit is contained in:
parent
2176202bcd
commit
7f443f2fae
|
@ -53,17 +53,20 @@ void AssetTile::setController(GameController* controller) {
|
|||
case PLATFORM_GBA:
|
||||
m_addressWidth = 8;
|
||||
m_addressBase = BASE_VRAM;
|
||||
m_boundaryBase = BASE_VRAM | 0x10000;
|
||||
break;
|
||||
#endif
|
||||
#ifdef M_CORE_GB
|
||||
case PLATFORM_GB:
|
||||
m_addressWidth = 4;
|
||||
m_addressBase = GB_BASE_VRAM;
|
||||
m_boundaryBase = GB_BASE_VRAM;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
m_addressWidth = 0;
|
||||
m_addressBase = 0;
|
||||
m_boundaryBase = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -86,16 +89,28 @@ void AssetTile::setPaletteSet(int palette, int boundary, int max) {
|
|||
void AssetTile::selectIndex(int index) {
|
||||
m_index = index;
|
||||
const uint16_t* data;
|
||||
m_ui.tileId->setText(QString::number(index * (1 + m_paletteSet)));
|
||||
|
||||
mTileCacheSetPalette(m_tileCache.get(), m_paletteSet);
|
||||
unsigned bpp = 8 << m_tileCache->bpp;
|
||||
m_ui.address->setText(tr("0x%0").arg(index * bpp | m_addressBase, m_addressWidth, 16, QChar('0')));
|
||||
if (index < m_boundary) {
|
||||
data = mTileCacheGetTile(m_tileCache.get(), index, m_paletteId);
|
||||
} else {
|
||||
data = mTileCacheGetTile(m_tileCache.get(), index, m_paletteId + m_tileCache->count / 2);
|
||||
int dispIndex = index;
|
||||
int paletteId = m_paletteId;
|
||||
int base = m_addressBase;
|
||||
if (index >= m_boundary) {
|
||||
base = m_boundaryBase;
|
||||
// XXX: Do this better
|
||||
#ifdef M_CORE_GBA
|
||||
if (m_boundaryBase == (BASE_VRAM | 0x10000)) {
|
||||
paletteId += m_tileCache->count / 2;
|
||||
}
|
||||
#endif
|
||||
dispIndex -= m_boundary;
|
||||
}
|
||||
data = mTileCacheGetTile(m_tileCache.get(), index, paletteId);
|
||||
m_ui.tileId->setText(QString::number(dispIndex * (1 + m_paletteSet)));
|
||||
m_ui.address->setText(tr("%0%1%2")
|
||||
.arg(m_addressWidth == 4 ? index >= m_boundary : 0)
|
||||
.arg(m_addressWidth == 4 ? ":" : "x")
|
||||
.arg(dispIndex * bpp | base, m_addressWidth, 16, QChar('0')));
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
m_ui.preview->setColor(i, data[i]);
|
||||
}
|
||||
|
@ -106,11 +121,14 @@ void AssetTile::selectColor(int index) {
|
|||
const uint16_t* data;
|
||||
mTileCacheSetPalette(m_tileCache.get(), m_paletteSet);
|
||||
unsigned bpp = 8 << m_tileCache->bpp;
|
||||
if (m_index < m_boundary) {
|
||||
data = mTileCacheGetTile(m_tileCache.get(), m_index, m_paletteId);
|
||||
} else {
|
||||
data = mTileCacheGetTile(m_tileCache.get(), m_index, m_paletteId + m_tileCache->count / 2);
|
||||
int paletteId = m_paletteId;
|
||||
// XXX: Do this better
|
||||
#ifdef M_CORE_GBA
|
||||
if (m_index >= m_boundary && m_boundaryBase == (BASE_VRAM | 0x10000)) {
|
||||
paletteId += m_tileCache->count / 2;
|
||||
}
|
||||
#endif
|
||||
data = mTileCacheGetTile(m_tileCache.get(), m_index, m_paletteId);
|
||||
uint16_t color = data[index];
|
||||
m_ui.color->setColor(0, color);
|
||||
m_ui.color->update();
|
||||
|
|
|
@ -40,6 +40,7 @@ private:
|
|||
int m_addressWidth;
|
||||
int m_addressBase;
|
||||
int m_boundary;
|
||||
int m_boundaryBase;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
|
||||
extern "C" {
|
||||
#include "gba/gba.h"
|
||||
#ifdef M_CORE_GB
|
||||
#include "gb/gb.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace QGBA;
|
||||
|
@ -145,5 +148,53 @@ void ObjView::updateTilesGBA(bool force) {
|
|||
|
||||
#ifdef M_CORE_GB
|
||||
void ObjView::updateTilesGB(bool force) {
|
||||
const GB* gb = static_cast<const GB*>(m_controller->thread()->core->board);
|
||||
const GBObj* obj = &gb->video.oam.obj[m_objId];
|
||||
|
||||
unsigned width = 8;
|
||||
unsigned height = 8; // TODO
|
||||
m_ui.tiles->setTileCount(width * height / 64);
|
||||
m_ui.tiles->setMinimumSize(QSize(width, height) * m_ui.magnification->value());
|
||||
int palette = 0;
|
||||
unsigned tile = obj->tile;
|
||||
if (gb->model >= GB_MODEL_CGB) {
|
||||
if (GBObjAttributesIsBank(obj->attr)) {
|
||||
tile += 512;
|
||||
}
|
||||
palette = GBObjAttributesGetCGBPalette(obj->attr);
|
||||
} else {
|
||||
palette = GBObjAttributesGetPalette(obj->attr);
|
||||
}
|
||||
int i = 0;
|
||||
// TODO: Check to see if parameters are changed (so as to enable force if needed)
|
||||
m_ui.palette->setText(QString::number(palette));
|
||||
mTileCacheSetPalette(m_tileCache.get(), 0);
|
||||
m_ui.tile->setPalette(palette + 8);
|
||||
m_ui.tile->setPaletteSet(0, 512, 1024);
|
||||
for (int y = 0; y < height / 8; ++y, ++i) {
|
||||
unsigned t = tile + i;
|
||||
const uint16_t* data = mTileCacheGetTileIfDirty(m_tileCache.get(), &m_tileStatus[16 * t], t, palette + 8);
|
||||
if (data) {
|
||||
m_ui.tiles->setTile(i, data);
|
||||
} else if (force) {
|
||||
m_ui.tiles->setTile(i, mTileCacheGetTile(m_tileCache.get(), t, palette + 8));
|
||||
}
|
||||
}
|
||||
m_tileOffset = tile;
|
||||
|
||||
m_ui.x->setText(QString::number(obj->x));
|
||||
m_ui.y->setText(QString::number(obj->y));
|
||||
m_ui.w->setText(QString::number(width));
|
||||
m_ui.h->setText(QString::number(height));
|
||||
|
||||
m_ui.address->setText(tr("0x%0").arg(GB_BASE_OAM + m_objId * sizeof(*obj), 4, 16, QChar('0')));
|
||||
m_ui.priority->setText(QString::number(GBObjAttributesGetPriority(obj->attr)));
|
||||
m_ui.flippedH->setChecked(GBObjAttributesIsXFlip(obj->attr));
|
||||
m_ui.flippedV->setChecked(GBObjAttributesIsYFlip(obj->attr));
|
||||
m_ui.enabled->setChecked(obj->y == 0 || obj->y >= 160);
|
||||
m_ui.doubleSize->setChecked(false);
|
||||
m_ui.mosaic->setChecked(false);
|
||||
m_ui.transform->setText(tr("N/A"));
|
||||
m_ui.mode->setText(tr("N/A"));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -10,6 +10,12 @@
|
|||
#include <QFontDatabase>
|
||||
#include <QTimer>
|
||||
|
||||
extern "C" {
|
||||
#ifdef M_CORE_GB
|
||||
#include "gb/gb.h"
|
||||
#endif
|
||||
}
|
||||
|
||||
using namespace QGBA;
|
||||
|
||||
TileView::TileView(GameController* controller, QWidget* parent)
|
||||
|
@ -36,7 +42,7 @@ TileView::TileView(GameController* controller, QWidget* parent)
|
|||
#ifdef M_CORE_GB
|
||||
case PLATFORM_GB:
|
||||
max = 1024;
|
||||
boundary = 1024;
|
||||
boundary = 512;
|
||||
m_ui.palette256->setEnabled(false);
|
||||
break;
|
||||
#endif
|
||||
|
@ -119,9 +125,11 @@ void TileView::updateTilesGBA(bool force) {
|
|||
|
||||
#ifdef M_CORE_GB
|
||||
void TileView::updateTilesGB(bool force) {
|
||||
m_ui.tiles->setTileCount(1024);
|
||||
const GB* gb = static_cast<const GB*>(m_controller->thread()->core->board);
|
||||
int count = gb->model >= GB_MODEL_CGB ? 1024 : 512;
|
||||
m_ui.tiles->setTileCount(count);
|
||||
mTileCacheSetPalette(m_tileCache.get(), 0);
|
||||
for (int i = 0; i < 1024; ++i) {
|
||||
for (int i = 0; i < count; ++i) {
|
||||
const uint16_t* data = mTileCacheGetTileIfDirty(m_tileCache.get(), &m_tileStatus[16 * i], i, m_paletteId);
|
||||
if (data) {
|
||||
m_ui.tiles->setTile(i, data);
|
||||
|
|
Loading…
Reference in New Issue