Qt: Fix a handful of edge cases with graphics viewers (fixes #2827)

This commit is contained in:
Vicki Pfau 2023-02-14 23:13:04 -08:00
parent 033efff86e
commit 0b17a40d6b
3 changed files with 14 additions and 3 deletions

View File

@ -20,6 +20,7 @@ Other fixes:
- Qt: Properly cap number of attached players by platform (fixes mgba.io/i/2807) - Qt: Properly cap number of attached players by platform (fixes mgba.io/i/2807)
- Qt: Disable attempted linking betwen incompatible platforms (fixes mgba.io/i/2702) - Qt: Disable attempted linking betwen incompatible platforms (fixes mgba.io/i/2702)
- Qt: Fix modifier key names in shortcut editor (fixes mgba.io/i/2817) - Qt: Fix modifier key names in shortcut editor (fixes mgba.io/i/2817)
- Qt: Fix a handful of edge cases with graphics viewers (fixes mgba.io/i/2827)
Misc: Misc:
- GB Serialize: Add missing savestate support for MBC6 and NT (newer) - GB Serialize: Add missing savestate support for MBC6 and NT (newer)
- GBA: Improve detection of valid ELF ROMs - GBA: Improve detection of valid ELF ROMs

View File

@ -42,7 +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_ui.tile->setMaxTile(3072);
m_addressBase = GBA_BASE_VRAM; m_addressBase = GBA_BASE_VRAM;
m_addressWidth = 8; m_addressWidth = 8;
m_ui.bgInfo->addCustomProperty("priority", tr("Priority")); m_ui.bgInfo->addCustomProperty("priority", tr("Priority"));
@ -119,6 +119,9 @@ void MapView::selectMap(int map) {
} }
m_map = map; m_map = map;
m_mapStatus.fill({}); m_mapStatus.fill({});
// Different maps can have different max palette counts; set it to
// 0 immediately to avoid tile lookups with state palette IDs break
m_ui.tile->setPalette(0);
updateTiles(true); updateTiles(true);
} }
@ -184,11 +187,18 @@ void MapView::updateTilesGBA(bool) {
frame = GBARegisterDISPCNTGetFrameSelect(io[REG_DISPCNT >> 1]); frame = GBARegisterDISPCNTGetFrameSelect(io[REG_DISPCNT >> 1]);
} }
} }
m_boundary = 1024;
m_ui.tile->setMaxTile(1536);
priority = GBARegisterBGCNTGetPriority(io[(REG_BG0CNT >> 1) + m_map]); priority = GBARegisterBGCNTGetPriority(io[(REG_BG0CNT >> 1) + m_map]);
if (mode == 0 || (mode == 1 && m_map != 2)) { if (mode == 0 || (mode == 1 && m_map != 2)) {
offset = QString("%1, %2") offset = QString("%1, %2")
.arg(io[(REG_BG0HOFS >> 1) + (m_map << 1)]) .arg(io[(REG_BG0HOFS >> 1) + (m_map << 1)])
.arg(io[(REG_BG0VOFS >> 1) + (m_map << 1)]); .arg(io[(REG_BG0VOFS >> 1) + (m_map << 1)]);
if (!GBARegisterBGCNTIs256Color(io[(REG_BG0CNT >> 1) + m_map])) {
m_boundary = 2048;
m_ui.tile->setMaxTile(3072);
}
} else if ((mode > 0 && m_map == 2) || (mode == 2 && m_map == 3)) { } else if ((mode > 0 && m_map == 2) || (mode == 2 && m_map == 3)) {
int32_t refX = io[(REG_BG2X_LO >> 1) + ((m_map - 2) << 2)]; int32_t refX = io[(REG_BG2X_LO >> 1) + ((m_map - 2) << 2)];
refX |= io[(REG_BG2X_HI >> 1) + ((m_map - 2) << 2)] << 16; refX |= io[(REG_BG2X_HI >> 1) + ((m_map - 2) << 2)] << 16;

View File

@ -51,7 +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); m_ui.tile->setMaxTile(3072);
break; break;
#endif #endif
#ifdef M_CORE_GB #ifdef M_CORE_GB
@ -76,7 +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); m_ui.tile->setMaxTile(3072 >> selected);
break; break;
#endif #endif
#ifdef M_CORE_GB #ifdef M_CORE_GB