mirror of https://github.com/mgba-emu/mgba.git
Qt: Add more bounds checks to tile selection
This commit is contained in:
parent
76d6055bb0
commit
0cfaf0a240
1
CHANGES
1
CHANGES
|
@ -64,6 +64,7 @@ Other fixes:
|
||||||
- Qt: Fix crash when clicking past last tile in viewer
|
- Qt: Fix crash when clicking past last tile in viewer
|
||||||
- Qt: Fix preloading for ROM replacing
|
- Qt: Fix preloading for ROM replacing
|
||||||
- Qt: Fix screen not displaying on Wayland (fixes mgba.io/i/2190)
|
- Qt: Fix screen not displaying on Wayland (fixes mgba.io/i/2190)
|
||||||
|
- Qt: Fix crash when selecting 256-color sprite in sprite view
|
||||||
- VFS: Failed file mapping should return NULL on POSIX
|
- VFS: Failed file mapping should return NULL on POSIX
|
||||||
Misc:
|
Misc:
|
||||||
- Core: Suspend runloop when a core crashes
|
- Core: Suspend runloop when a core crashes
|
||||||
|
|
|
@ -82,6 +82,9 @@ void AssetTile::setBoundary(int boundary, int set0, int set1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssetTile::selectIndex(int index) {
|
void AssetTile::selectIndex(int index) {
|
||||||
|
if (index > m_maxTile) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_index = index;
|
m_index = index;
|
||||||
const color_t* data;
|
const color_t* data;
|
||||||
mTileCache* tileCache = m_tileCaches[index >= m_boundary];
|
mTileCache* tileCache = m_tileCaches[index >= m_boundary];
|
||||||
|
@ -141,3 +144,7 @@ void AssetTile::selectColor(int index) {
|
||||||
m_ui.g->setText(tr("0x%0 (%1)").arg(g, 2, 16, QChar('0')).arg(g, 2, 10, QChar('0')));
|
m_ui.g->setText(tr("0x%0 (%1)").arg(g, 2, 16, QChar('0')).arg(g, 2, 10, QChar('0')));
|
||||||
m_ui.b->setText(tr("0x%0 (%1)").arg(b, 2, 16, QChar('0')).arg(b, 2, 10, QChar('0')));
|
m_ui.b->setText(tr("0x%0 (%1)").arg(b, 2, 16, QChar('0')).arg(b, 2, 10, QChar('0')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AssetTile::setMaxTile(int tile) {
|
||||||
|
m_maxTile = tile;
|
||||||
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ public slots:
|
||||||
void selectIndex(int);
|
void selectIndex(int);
|
||||||
void setFlip(bool h, bool v);
|
void setFlip(bool h, bool v);
|
||||||
void selectColor(int);
|
void selectColor(int);
|
||||||
|
void setMaxTile(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int customLocation(const QString& id = {}) override;
|
int customLocation(const QString& id = {}) override;
|
||||||
|
@ -45,6 +46,7 @@ private:
|
||||||
int m_addressBase;
|
int m_addressBase;
|
||||||
int m_boundary;
|
int m_boundary;
|
||||||
int m_boundaryBase;
|
int m_boundaryBase;
|
||||||
|
int m_maxTile;
|
||||||
bool m_flipH = false;
|
bool m_flipH = false;
|
||||||
bool m_flipV = false;
|
bool m_flipV = false;
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ MapView::MapView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
case mPLATFORM_GBA:
|
case mPLATFORM_GBA:
|
||||||
m_boundary = 2048;
|
m_boundary = 2048;
|
||||||
|
m_ui.tile->setMaxTile(3096);
|
||||||
m_addressBase = BASE_VRAM;
|
m_addressBase = BASE_VRAM;
|
||||||
m_addressWidth = 8;
|
m_addressWidth = 8;
|
||||||
m_ui.bgInfo->addCustomProperty("priority", tr("Priority"));
|
m_ui.bgInfo->addCustomProperty("priority", tr("Priority"));
|
||||||
|
@ -55,6 +56,7 @@ MapView::MapView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
#ifdef M_CORE_GB
|
#ifdef M_CORE_GB
|
||||||
case mPLATFORM_GB:
|
case mPLATFORM_GB:
|
||||||
m_boundary = 1024;
|
m_boundary = 1024;
|
||||||
|
m_ui.tile->setMaxTile(512);
|
||||||
m_addressBase = GB_BASE_VRAM;
|
m_addressBase = GB_BASE_VRAM;
|
||||||
m_addressWidth = 4;
|
m_addressWidth = 4;
|
||||||
m_ui.bgInfo->addCustomProperty("screenBase", tr("Map base"));
|
m_ui.bgInfo->addCustomProperty("screenBase", tr("Map base"));
|
||||||
|
|
|
@ -116,14 +116,16 @@ void ObjView::updateTilesGBA(bool force) {
|
||||||
if (GBAObjAttributesAIs256Color(obj->a)) {
|
if (GBAObjAttributesAIs256Color(obj->a)) {
|
||||||
m_ui.palette->setText("256-color");
|
m_ui.palette->setText("256-color");
|
||||||
m_ui.tile->setBoundary(1024, 1, 3);
|
m_ui.tile->setBoundary(1024, 1, 3);
|
||||||
m_ui.tile->setPalette(0);
|
|
||||||
m_boundary = 1024;
|
m_boundary = 1024;
|
||||||
tileBase *= 2;
|
tileBase *= 2;
|
||||||
|
m_ui.tile->setMaxTile(1536);
|
||||||
|
m_ui.tile->setPalette(0);
|
||||||
} else {
|
} else {
|
||||||
m_ui.palette->setText(QString::number(newInfo.paletteId));
|
m_ui.palette->setText(QString::number(newInfo.paletteId));
|
||||||
m_ui.tile->setBoundary(2048, 0, 2);
|
m_ui.tile->setBoundary(2048, 0, 2);
|
||||||
m_ui.tile->setPalette(newInfo.paletteId);
|
|
||||||
m_boundary = 2048;
|
m_boundary = 2048;
|
||||||
|
m_ui.tile->setMaxTile(3072);
|
||||||
|
m_ui.tile->setPalette(newInfo.paletteId);
|
||||||
}
|
}
|
||||||
if (newInfo != m_objInfo) {
|
if (newInfo != m_objInfo) {
|
||||||
force = true;
|
force = true;
|
||||||
|
@ -225,6 +227,7 @@ void ObjView::updateTilesGB(bool force) {
|
||||||
m_objInfo = newInfo;
|
m_objInfo = newInfo;
|
||||||
m_tileOffset = tile;
|
m_tileOffset = tile;
|
||||||
m_boundary = 1024;
|
m_boundary = 1024;
|
||||||
|
m_ui.tile->setMaxTile(512);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
m_ui.tile->setPalette(newInfo.paletteId);
|
m_ui.tile->setPalette(newInfo.paletteId);
|
||||||
|
|
|
@ -51,6 +51,7 @@ TileView::TileView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
case mPLATFORM_GBA:
|
case mPLATFORM_GBA:
|
||||||
m_ui.tile->setBoundary(2048, 0, 2);
|
m_ui.tile->setBoundary(2048, 0, 2);
|
||||||
|
m_ui.tile->setMaxTile(3096);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef M_CORE_GB
|
#ifdef M_CORE_GB
|
||||||
|
@ -60,6 +61,7 @@ TileView::TileView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
m_ui.tilesBoth->setEnabled(false);
|
m_ui.tilesBoth->setEnabled(false);
|
||||||
m_ui.palette256->setEnabled(false);
|
m_ui.palette256->setEnabled(false);
|
||||||
m_ui.tile->setBoundary(1024, 0, 0);
|
m_ui.tile->setBoundary(1024, 0, 0);
|
||||||
|
m_ui.tile->setMaxTile(512);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
|
@ -74,6 +76,7 @@ TileView::TileView(std::shared_ptr<CoreController> controller, QWidget* parent)
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
case mPLATFORM_GBA:
|
case mPLATFORM_GBA:
|
||||||
m_ui.tile->setBoundary(2048 >> selected, selected, selected + 2);
|
m_ui.tile->setBoundary(2048 >> selected, selected, selected + 2);
|
||||||
|
m_ui.tile->setMaxTile(3096 >> selected);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef M_CORE_GB
|
#ifdef M_CORE_GB
|
||||||
|
|
Loading…
Reference in New Issue