From 7ab5bd28bfd5f569a67980cf3297c9604b09bf3f Mon Sep 17 00:00:00 2001 From: Guy Perfect Date: Mon, 19 Oct 2026 18:20:00 -0500 Subject: [PATCH] Fix affine world width assignment logic --- core/vip.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/vip.c b/core/vip.c index ce94d22..0dc25ce 100644 --- a/core/vip.c +++ b/core/vip.c @@ -320,6 +320,7 @@ static void vipWriteWorld(VB *sim, uint32_t offset, int type, int32_t value) { uint32_t base; /* Base BG map index */ uint8_t *bg; /* Background template */ uint32_t count; /* Number of BG maps in background */ + int32_t width; /* Computed affine width */ World *world; /* World state */ uint32_t z; /* Iterator */ @@ -381,10 +382,10 @@ static void vipWriteWorld(VB *sim, uint32_t offset, int type, int32_t value) { case 5: world->mp = SignExtend(value, 15); break; case 6: world->my = SignExtend(value, 13); break; case 7: /* W */ - value = SignExtend(value, 13) + 1; - world->wNaffine = value < 0 ? 0 : value; - value = SignExtend(value, 10) + 1; - world->wAffine = value < 0 ? 0 : value; + width = SignExtend(value, 13) + 1; + world->wNaffine = width < 0 ? 0 : width; + width = SignExtend(value, 10) + 1; + world->wAffine = width < 0 ? 0 : width; world->width = world->bgm != 2 ? world->wNaffine : world->wAffine; break; case 8: /* H */