From cb0f95b07053e63e817bd05df0a36bf917667d09 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Wed, 12 Apr 2017 13:43:12 -0700 Subject: [PATCH] DS Video: Enable overflow bit on extended affine modes --- CHANGES | 1 + src/ds/renderers/software.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 89577ea0a..c9c3346d3 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,7 @@ Bugfixes: - DS GX: Reset polygon attributes between buffer swaps - DS Video: Fix blend bit on windows for 3D layer (fixes mgba.io/i/611) - DS GX: Hack around writing to a full FIFO that has a swap pending (fixes mgba.io/i/608) + - DS Video: Enable overflow bit on extended affine modes Misc: - DS: Set boot complete bit in RAM on boot (fixes mgba.io/i/576, mgba.io/i/580, mgba.io/i/586) - DS Memory: Ensure DS9 I/O is 8-byte aligned diff --git a/src/ds/renderers/software.c b/src/ds/renderers/software.c index 17fe482db..32becdc27 100644 --- a/src/ds/renderers/software.c +++ b/src/ds/renderers/software.c @@ -743,6 +743,20 @@ void DSVideoSoftwareRendererDrawBackgroundExt0(struct GBAVideoSoftwareRenderer* } } +#define DS_BACKGROUND_BITMAP_ITERATE(W, H) \ + x += background->dx; \ + y += background->dy; \ + \ + if (background->overflow) { \ + localX = x & ((W << 8) - 1); \ + localY = y & ((H << 8) - 1); \ + } else if (x < 0 || y < 0 || (x >> 8) >= W || (y >> 8) >= H) { \ + continue; \ + } else { \ + localX = x; \ + localY = y; \ + } + void DSVideoSoftwareRendererDrawBackgroundExt1(struct GBAVideoSoftwareRenderer* renderer, struct GBAVideoSoftwareBackground* background, int inY) { BACKGROUND_BITMAP_INIT; @@ -770,7 +784,7 @@ void DSVideoSoftwareRendererDrawBackgroundExt1(struct GBAVideoSoftwareRenderer* int outX; for (outX = renderer->start; outX < renderer->end; ++outX) { - BACKGROUND_BITMAP_ITERATE(width, height); + DS_BACKGROUND_BITMAP_ITERATE(width, height); if (!mosaicWait) { uint32_t address = (localX >> 8) + (localY >> 8) * width + screenBase; @@ -827,7 +841,7 @@ void DSVideoSoftwareRendererDrawBackgroundExt2(struct GBAVideoSoftwareRenderer* int outX; for (outX = renderer->start; outX < renderer->end; ++outX) { - BACKGROUND_BITMAP_ITERATE(width, height); + DS_BACKGROUND_BITMAP_ITERATE(width, height); if (!mosaicWait) { uint32_t address = ((localX >> 8) + (localY >> 8) * width + screenBase) << 1;