comparison vdp.c @ 2503:fa49e06d8c92

Fix silly bug in Mode 4 sprite rendering (Thanks Sik!)
author Michael Pavone <pavone@retrodev.com>
date Wed, 31 Jul 2024 22:30:14 -0700
parents b62580dc6f30
children 593a4f308335
comparison
equal deleted inserted replaced
2502:ad50530a7c27 2503:fa49e06d8c92
484 pixels |= planar_to_chunky[context->vdpmem[address]] << 3; 484 pixels |= planar_to_chunky[context->vdpmem[address]] << 3;
485 pixels |= planar_to_chunky[context->vdpmem[address + 1]] << 2; 485 pixels |= planar_to_chunky[context->vdpmem[address + 1]] << 2;
486 int x = d->x_pos & 0xFF; 486 int x = d->x_pos & 0xFF;
487 for (int i = 28; i >= 0; i -= 4, x++) 487 for (int i = 28; i >= 0; i -= 4, x++)
488 { 488 {
489 if (context->linebuf[x] && (pixels >> i & 0xF)) { 489 uint8_t pixel = pixels >> i & 0xF;
490 if ( 490 if (pixel) {
491 if (!context->linebuf[x]) {
492 context->linebuf[x] = pixel;
493 } else if(
491 ((context->regs[REG_MODE_1] & BIT_SPRITE_8PX) && x > 8) 494 ((context->regs[REG_MODE_1] & BIT_SPRITE_8PX) && x > 8)
492 || ((!(context->regs[REG_MODE_1] & BIT_SPRITE_8PX)) && x < 256) 495 || ((!(context->regs[REG_MODE_1] & BIT_SPRITE_8PX)) && x < 256)
493 ) { 496 ) {
494 context->flags2 |= FLAG2_SPRITE_COLLIDE; 497 context->flags2 |= FLAG2_SPRITE_COLLIDE;
495 } 498 }
496 } else {
497 context->linebuf[x] = pixels >> i & 0xF;
498 } 499 }
499 if (zoom) { 500 if (zoom) {
500 x++; 501 x++;
501 if (context->linebuf[x] && (pixels >> i & 0xF)) { 502 if (pixel) {
502 if ( 503 if (!context->linebuf[x]) {
504 context->linebuf[x] = pixel;
505 } else if(
503 ((context->regs[REG_MODE_1] & BIT_SPRITE_8PX) && x > 8) 506 ((context->regs[REG_MODE_1] & BIT_SPRITE_8PX) && x > 8)
504 || ((!(context->regs[REG_MODE_1] & BIT_SPRITE_8PX)) && x < 256) 507 || ((!(context->regs[REG_MODE_1] & BIT_SPRITE_8PX)) && x < 256)
505 ) { 508 ) {
506 context->flags2 |= FLAG2_SPRITE_COLLIDE; 509 context->flags2 |= FLAG2_SPRITE_COLLIDE;
507 } 510 }
508 } else {
509 context->linebuf[x] = pixels >> i & 0xF;
510 } 511 }
511 } 512 }
512 } 513 }
513 context->sprite_index--; 514 context->sprite_index--;
514 } 515 }