Fix affine world width assignment logic

This commit is contained in:
2026-10-19 18:20:00 -05:00
parent 41cd7bc089
commit 7ab5bd28bf
+5 -4
View File
@@ -320,6 +320,7 @@ static void vipWriteWorld(VB *sim, uint32_t offset, int type, int32_t value) {
uint32_t base; /* Base BG map index */ uint32_t base; /* Base BG map index */
uint8_t *bg; /* Background template */ uint8_t *bg; /* Background template */
uint32_t count; /* Number of BG maps in background */ uint32_t count; /* Number of BG maps in background */
int32_t width; /* Computed affine width */
World *world; /* World state */ World *world; /* World state */
uint32_t z; /* Iterator */ 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 5: world->mp = SignExtend(value, 15); break;
case 6: world->my = SignExtend(value, 13); break; case 6: world->my = SignExtend(value, 13); break;
case 7: /* W */ case 7: /* W */
value = SignExtend(value, 13) + 1; width = SignExtend(value, 13) + 1;
world->wNaffine = value < 0 ? 0 : value; world->wNaffine = width < 0 ? 0 : width;
value = SignExtend(value, 10) + 1; width = SignExtend(value, 10) + 1;
world->wAffine = value < 0 ? 0 : value; world->wAffine = width < 0 ? 0 : width;
world->width = world->bgm != 2 ? world->wNaffine : world->wAffine; world->width = world->bgm != 2 ? world->wNaffine : world->wAffine;
break; break;
case 8: /* H */ case 8: /* H */