all repos — mgba @ a87cde8e93f7ccf5bcd671f1c94accaa328407e1

mGBA Game Boy Advance Emulator

GBA Video: Add sprite cycle counting to GL (fixes #1635)
Vicki Pfau vi@endrift.com
Wed, 10 Jun 2020 02:19:41 -0700
commit

a87cde8e93f7ccf5bcd671f1c94accaa328407e1

parent

0216557477ad2606a4e094ad53cefaae3185dd96

2 files changed, 12 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -14,6 +14,7 @@ - GBA Video: Fix disabling OBJWIN in GL renderer (fixes mgba.io/i/1759)

- GBA Video: Add missing parts of 256-color mode 0 mosaic (fixes mgba.io/i/1701) - GBA Video: Fix double-size OBJ wrapping in GL renderer (fixes mgba.io/i/1712) - GBA Video: Simplify sprite cycle counting (fixes mgba.io/i/1279) + - GBA Video: Add sprite cycle counting to GL (fixes mgba.io/i/1635) Other fixes: - ARM: Fix disassembling of several S-type instructions (fixes mgba.io/i/1778) - ARM Debugger: Clear low bit on breakpoint addresses (fixes mgba.io/i/1764)
M src/gba/renderers/gl.csrc/gba/renderers/gl.c

@@ -1427,6 +1427,7 @@

GBAVideoGLRendererDrawWindow(glRenderer, y); if (GBARegisterDISPCNTIsObjEnable(glRenderer->dispcnt) && !glRenderer->d.disableOBJ) { int i; + int spriteCyclesRemaining = GBARegisterDISPCNTIsHblankIntervalFree(glRenderer->dispcnt) ? OBJ_HBLANK_FREE_LENGTH : OBJ_LENGTH; glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glEnable(GL_STENCIL_TEST); glDepthFunc(GL_LESS);

@@ -1437,6 +1438,16 @@ continue;

} GBAVideoGLRendererDrawSprite(glRenderer, &sprite->obj, y, sprite->y); + + int cycles = GBAVideoObjSizes[GBAObjAttributesAGetShape(sprite->obj.a) * 4 + GBAObjAttributesBGetSize(sprite->obj.b)][0]; + if (GBAObjAttributesAIsTransformed(sprite->obj.a)) { + cycles <<= GBAObjAttributesAGetDoubleSize(sprite->obj.a) + 1; + cycles += 10; + } + spriteCyclesRemaining -= cycles; + if (spriteCyclesRemaining <= 0) { + break; + } } glDisable(GL_DEPTH_TEST); glDisable(GL_STENCIL_TEST);