marioballano / emudore

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

Double width sprites #10

Closed xlar54 closed 6 years ago

xlar54 commented 6 years ago

capture Here's another patch (the previous was for double height):

void Vic::draw_sprite(int x, int y, int sprite, int row) { uint8_t swid = is_double_width_sprite(sprite) == true ? 2 : 1; uint16_t addr = get_sprite_ptr(sprite);

for(int w=0;w<swid;w++) { 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+w + (i*8*swid) + (8*swid) - (j*swid)) ;
  uint8_t side_border_offset = 0;
  uint8_t top_border_offset=0;
  uint8_t btm_border_offset=0;

  // 38 col mode
  if(!ISSET_BIT(cr2_,3)) 
    side_border_offset = 8;

  // 24 line mode
  if(!ISSET_BIT(cr1_,3)) 
  {
    top_border_offset=2;
    btm_border_offset=4;
  }

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

} }

marioballano commented 6 years ago

and I believe commit fe2ea91fe294e1b4f868d468c096033cdff3801c should fix this, but haven't tested, if you have a prg handy that would be great, otherwise I'll try to put something together to test both this and double height sprites.. need to install the C64 dev tools on this box :)

xlar54 commented 6 years ago

yeah, try that program i sent earlier. let it run so that the sprite is displayed, then do the 255 POKE that is in the screenshot. (both screenshots). 53271,255 should double the width of all sprites and the 255 POKE on the other screenshot should double the height for all visible sprites as well. I didnt add those to the program but probably will

marioballano commented 6 years ago

yah, read that on the other thread, will test these two with your PRG and the debugger :)

marioballano commented 6 years ago

just tested with the debugger and it all seems to work fine!