marioballano / emudore

emudore, a Commodore 64 emulator
Apache License 2.0
303 stars 21 forks source link

Sprites overlapping border #7

Closed xlar54 closed 6 years ago

xlar54 commented 6 years ago

This one will require a basic prog to confirm, but it should be easy enough. The issue is that sprites overlap the screen border. This fix will correct it (and incorporates the 38 col fix earlier as well) I havent tried it yet on multicolor sprites, but I dont think it fixes that one yet.

Basically it still renders the sprite, but uses the border color for the overlapping pixels so it appears to go under the border. Works in all directions.

`void Vic::draw_sprite(int x, int y, int sprite, int row) { uint16_t addr = get_sprite_ptr(sprite); for (int i=0; i < 3 ; i++) { uint8t data = mem->vic_read_byte(addr + row 3 + i); for (int j=0; j < 8; j++) { if(ISSET_BIT(data,j)) { uint16_t newX = x + i8 + 8 - j; uint8_t border38 = 0;

if(!ISSET_BIT(cr2_,3)) // if border mode is 38 columns
  border38 = 8;

if(newX <= kGFirstCol+border38 || y <= kGFirstCol || newX > kGResX+kGFirstCol-border38 || y > kGResY+kGFirstCol)
{
  io_->screen_update_pixel(newX,y,border_color_);
}
else
{
  io_->screen_update_pixel(newX,y,sprite_colors_[sprite]);
}
  }
}

} }`

xlar54 commented 6 years ago

Actually that line should be:

'if(newX <= kGFirstCol+border38 || y < kGFirstCol || newX > kGResX+kGFirstCol-border38 || y >= kGResY+kGFirstCol)'

capture

marioballano commented 6 years ago

thanks!, unfortunately I didn't get to extensively test the all the vic-ii graphic modes, there's likely quite some more issues with the implementation (aside from unimplemented features), your tests are very welcome :)

I just submitted your patch, let me know if it works as expected

xlar54 commented 6 years ago

looks good, thanks!