Skip to content

Commit

Permalink
MEGA65 VIC-IV fix for horizontally tiled sprites (#276)
Browse files Browse the repository at this point in the history
* Added check for alternate palette in NCM RRB GOTOX

* Added check for alternate palette on GOTOX when using RRB in NCM mode

* removed my local build.sh script .. doh

* Fix for horizontally tiled sprites

Co-authored-by: smnjameson <smnjameson@googlemai.com>
  • Loading branch information
smnjameson and smnjameson authored Jun 7, 2021
1 parent d81a010 commit 3b2a62e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
32 changes: 17 additions & 15 deletions targets/mega65/vic4.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,22 +853,24 @@ static XEMU_INLINE void vic4_draw_sprite_row_16color( int sprnum, int x_display_
// in 16 colour sprite mode, sprite colour register gives the transparent colour index
// We always use the lower 4 bit only at this very specific case, that's the reason for SPRITE_COLOR_4BIT() macro and not SPRITE_COLOR() [which can be 4/8 bit depending on curretn VIC mode)
const Uint8 transparency_palette_index = SPRITE_COLOR_4BIT(sprnum);
for (int byte = 0; byte < totalBytes; byte++) {
const Uint8 c0 = (*(row_data_ptr + byte)) >> 4;
const Uint8 c1 = (*(row_data_ptr + byte)) & 0xF;
for (int p = 0; p < xscale && x_display_pos < border_x_right; p++, x_display_pos++) {
if (c0 != transparency_palette_index && x_display_pos >= border_x_left && (
!SPRITE_IS_BACK(sprnum) || (SPRITE_IS_BACK(sprnum) && !is_fg[x_display_pos])
))
*(pixel_raster_start + x_display_pos) = pal16[c0];
}
for (int p = 0; p < xscale && x_display_pos < border_x_right; p++, x_display_pos++) {
if (c1 != transparency_palette_index && x_display_pos >= border_x_left && (
!SPRITE_IS_BACK(sprnum) || (SPRITE_IS_BACK(sprnum) && !is_fg[x_display_pos])
))
*(pixel_raster_start + x_display_pos) = pal16[c1];
do {
for (int byte = 0; byte < totalBytes; byte++) {
const Uint8 c0 = (*(row_data_ptr + byte)) >> 4;
const Uint8 c1 = (*(row_data_ptr + byte)) & 0xF;
for (int p = 0; p < xscale && x_display_pos < border_x_right; p++, x_display_pos++) {
if (c0 != transparency_palette_index && x_display_pos >= border_x_left && (
!SPRITE_IS_BACK(sprnum) || (SPRITE_IS_BACK(sprnum) && !is_fg[x_display_pos])
))
*(pixel_raster_start + x_display_pos) = pal16[c0];
}
for (int p = 0; p < xscale && x_display_pos < border_x_right; p++, x_display_pos++) {
if (c1 != transparency_palette_index && x_display_pos >= border_x_left && (
!SPRITE_IS_BACK(sprnum) || (SPRITE_IS_BACK(sprnum) && !is_fg[x_display_pos])
))
*(pixel_raster_start + x_display_pos) = pal16[c1];
}
}
}
} while ((REG_SPRTILEN & (1 << sprnum)) && x_display_pos < border_x_right);
}


Expand Down
1 change: 1 addition & 0 deletions targets/mega65/vic4.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#define REG_BBRDPOS_U4 (vic_registers[0x4B] & 0xF)
#define REG_TEXTXPOS (vic_registers[0x4C])
#define REG_TEXTXPOS_U4 (vic_registers[0x4D] & 0xF)
#define REG_SPRTILEN ((vic_registers[0x4D] & 0xF0) >> 4 | (vic_registers[0x4F] & 0xF0))
#define REG_TEXTYPOS (vic_registers[0x4E])
#define REG_TEXTYPOS_U4 (vic_registers[0x4F] & 0xF)
#define REG_XPOS (vic_registers[0x51])
Expand Down

1 comment on commit 3b2a62e

@lgblgblgb
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log to #29 too

Please sign in to comment.