From 50d38dff620680b428392ac4d08cf5e582f09a53 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sat, 22 Aug 2020 21:56:57 -0700 Subject: [PATCH] GBA Video: Don't draw sprites using unmapped VRAM in GL renderer (fixes #1865) --- CHANGES | 1 + src/gba/renderers/gl.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 0cef2f9c5..e00e67ae6 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,7 @@ Emulation fixes: - GBA Audio: Fix volume/mute in XQ audio (fixes mgba.io/i/1864) - GBA Hardware: Fix GB Player detection on big endian platforms - GBA Video: Invalidate map cache when modifying BGCNT (fixes mgba.io/i/1846) + - GBA Video: Don't draw sprites using unmapped VRAM in GL renderer (fixes mgba.io/i/1865) Other fixes: - 3DS: Redo video sync to be more precise - 3DS: Fix crash with libctru 2.0 when exiting diff --git a/src/gba/renderers/gl.c b/src/gba/renderers/gl.c index 7376b6dc2..9787b77ef 100644 --- a/src/gba/renderers/gl.c +++ b/src/gba/renderers/gl.c @@ -1647,6 +1647,10 @@ void GBAVideoGLRendererDrawSprite(struct GBAVideoGLRenderer* renderer, struct GB int32_t x = (uint32_t) GBAObjAttributesBGetX(sprite->b) << 23; x >>= 23; + if (GBARegisterDISPCNTGetMode(renderer->dispcnt) >= 3 && GBAObjAttributesCGetTile(sprite->c) < 512) { + return; + } + int align = GBAObjAttributesAIs256Color(sprite->a) && !GBARegisterDISPCNTIsObjCharacterMapping(renderer->dispcnt); unsigned charBase = (BASE_TILE >> 1) + (GBAObjAttributesCGetTile(sprite->c) & ~align) * 0x10; int stride = GBARegisterDISPCNTIsObjCharacterMapping(renderer->dispcnt) ? (width >> 3) : (0x20 >> GBAObjAttributesAGet256Color(sprite->a));