GBA Video: Improve sprite cycle counting (fixes #1126)

This commit is contained in:
Vicki Pfau 2018-07-20 17:16:58 -07:00
parent 57446b087e
commit bb82579d6a
2 changed files with 4 additions and 3 deletions

View File

@ -9,6 +9,7 @@ Bugfixes:
- GBA Serialize: Fix loading channel 3 volume (fixes mgba.io/i/1107) - GBA Serialize: Fix loading channel 3 volume (fixes mgba.io/i/1107)
- GBA BIOS: Fix BitUnPack final byte - GBA BIOS: Fix BitUnPack final byte
- GB I/O: DMA register is R/W - GB I/O: DMA register is R/W
- GBA Video: Improve sprite cycle counting (fixes mgba.io/i/1126)
Misc: Misc:
- FFmpeg: Support libswresample (fixes mgba.io/i/1120, mgba.io/b/123) - FFmpeg: Support libswresample (fixes mgba.io/i/1120, mgba.io/b/123)

View File

@ -192,7 +192,6 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re
if (GBAObjAttributesAIsTransformed(sprite->a)) { if (GBAObjAttributesAIsTransformed(sprite->a)) {
int totalWidth = width << GBAObjAttributesAGetDoubleSize(sprite->a); int totalWidth = width << GBAObjAttributesAGetDoubleSize(sprite->a);
int totalHeight = height << GBAObjAttributesAGetDoubleSize(sprite->a); int totalHeight = height << GBAObjAttributesAGetDoubleSize(sprite->a);
renderer->spriteCyclesRemaining -= 10;
struct GBAOAMMatrix mat; struct GBAOAMMatrix mat;
LOAD_16(mat.a, 0, &renderer->d.oam->mat[GBAObjAttributesBGetMatIndex(sprite->b)].a); LOAD_16(mat.a, 0, &renderer->d.oam->mat[GBAObjAttributesBGetMatIndex(sprite->b)].a);
LOAD_16(mat.b, 0, &renderer->d.oam->mat[GBAObjAttributesBGetMatIndex(sprite->b)].b); LOAD_16(mat.b, 0, &renderer->d.oam->mat[GBAObjAttributesBGetMatIndex(sprite->b)].b);
@ -252,6 +251,7 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re
if (outX < start || outX >= condition) { if (outX < start || outX >= condition) {
return 0; return 0;
} }
renderer->spriteCyclesRemaining -= 10;
if (!GBAObjAttributesAIs256Color(sprite->a)) { if (!GBAObjAttributesAIs256Color(sprite->a)) {
palette = &palette[GBAObjAttributesCGetPalette(sprite->c) << 4]; palette = &palette[GBAObjAttributesCGetPalette(sprite->c) << 4];
@ -272,7 +272,7 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re
SPRITE_TRANSFORMED_LOOP(256, NORMAL); SPRITE_TRANSFORMED_LOOP(256, NORMAL);
} }
} }
if (x + totalWidth > VIDEO_HORIZONTAL_PIXELS) { if (end == VIDEO_HORIZONTAL_PIXELS && x + totalWidth > VIDEO_HORIZONTAL_PIXELS) {
renderer->spriteCyclesRemaining -= (x + totalWidth - VIDEO_HORIZONTAL_PIXELS) * 2; renderer->spriteCyclesRemaining -= (x + totalWidth - VIDEO_HORIZONTAL_PIXELS) * 2;
} }
} else { } else {
@ -332,7 +332,7 @@ int GBAVideoSoftwareRendererPreprocessSprite(struct GBAVideoSoftwareRenderer* re
SPRITE_NORMAL_LOOP(256, NORMAL); SPRITE_NORMAL_LOOP(256, NORMAL);
} }
} }
if (x + width > VIDEO_HORIZONTAL_PIXELS) { if (end == VIDEO_HORIZONTAL_PIXELS && x + width > VIDEO_HORIZONTAL_PIXELS) {
renderer->spriteCyclesRemaining -= x + width - VIDEO_HORIZONTAL_PIXELS; renderer->spriteCyclesRemaining -= x + width - VIDEO_HORIZONTAL_PIXELS;
} }
} }