mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-24 18:21:50 +01:00
improved sprite masking accuracy
This commit is contained in:
parent
36e91c70aa
commit
ae3ac87f7c
@ -1619,6 +1619,8 @@ void parse_satb(uint32 line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int spr_over = 0;
|
||||||
|
|
||||||
static void render_obj(uint32 line, uint8 *buf, uint8 *table)
|
static void render_obj(uint32 line, uint8 *buf, uint8 *table)
|
||||||
{
|
{
|
||||||
uint16 ypos;
|
uint16 ypos;
|
||||||
@ -1642,21 +1644,27 @@ static void render_obj(uint32 line, uint8 *buf, uint8 *table)
|
|||||||
uint8 palette;
|
uint8 palette;
|
||||||
|
|
||||||
int attr_mask, nt_row;
|
int attr_mask, nt_row;
|
||||||
|
int mask = 0;
|
||||||
|
|
||||||
for(count = 0; count < object_index_count; count += 1)
|
for(count = 0; count < object_index_count; count += 1)
|
||||||
{
|
{
|
||||||
xpos = object_info[count].xpos & 0x1ff;
|
xpos = object_info[count].xpos & 0x1ff;
|
||||||
|
|
||||||
/* sprite masking (low priority sprite only) */
|
/* sprite masking (ignore the 1st sprite) */
|
||||||
if(!xpos && count) return;
|
if (xpos) spr_over = 1;
|
||||||
|
else if (spr_over)
|
||||||
|
{
|
||||||
|
spr_over = 0;
|
||||||
|
mask = 1;
|
||||||
|
}
|
||||||
|
|
||||||
size = object_info[count].size & 0x0f;
|
size = object_info[count].size & 0x0f;
|
||||||
width = sizetab[(size >> 2) & 3];
|
width = sizetab[(size >> 2) & 3];
|
||||||
|
|
||||||
/* update pixel count (off-screen sprites included) */
|
/* update pixel count (off-screen sprites included) */
|
||||||
pixelcount += width;
|
pixelcount += xpos ? width : (width * 2);
|
||||||
|
|
||||||
if(((xpos + width) >= left) && (xpos < right))
|
if(((xpos + width) >= left) && (xpos < right) && !mask)
|
||||||
{
|
{
|
||||||
ypos = object_info[count].ypos;
|
ypos = object_info[count].ypos;
|
||||||
attr = object_info[count].attr;
|
attr = object_info[count].attr;
|
||||||
@ -1676,7 +1684,11 @@ static void render_obj(uint32 line, uint8 *buf, uint8 *table)
|
|||||||
|
|
||||||
/* number of tiles to draw */
|
/* number of tiles to draw */
|
||||||
/* adjusted for sprite limit */
|
/* adjusted for sprite limit */
|
||||||
if (pixelcount > bitmap.viewport.w) width -= (pixelcount - bitmap.viewport.w);
|
if (pixelcount > bitmap.viewport.w)
|
||||||
|
{
|
||||||
|
width -= (pixelcount - bitmap.viewport.w);
|
||||||
|
}
|
||||||
|
|
||||||
width >>= 3;
|
width >>= 3;
|
||||||
|
|
||||||
for(column = 0; column < width; column += 1, lb+=8)
|
for(column = 0; column < width; column += 1, lb+=8)
|
||||||
@ -1685,13 +1697,17 @@ static void render_obj(uint32 line, uint8 *buf, uint8 *table)
|
|||||||
src = &bg_pattern_cache[(index << 6) | (v_line)];
|
src = &bg_pattern_cache[(index << 6) | (v_line)];
|
||||||
DRAW_SPRITE_TILE;
|
DRAW_SPRITE_TILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sprite limit (256 or 320 pixels) */
|
/* sprite limit (256 or 320 pixels) */
|
||||||
if (pixelcount >= bitmap.viewport.w) return;
|
if (pixelcount >= bitmap.viewport.w)
|
||||||
|
{
|
||||||
|
spr_over = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spr_over = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table)
|
static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table)
|
||||||
@ -1718,21 +1734,27 @@ static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table)
|
|||||||
uint32 offs;
|
uint32 offs;
|
||||||
|
|
||||||
int attr_mask, nt_row;
|
int attr_mask, nt_row;
|
||||||
|
int mask = 0;
|
||||||
|
|
||||||
for(count = 0; count < object_index_count; count += 1)
|
for(count = 0; count < object_index_count; count += 1)
|
||||||
{
|
{
|
||||||
xpos = object_info[count].xpos & 0x1ff;
|
xpos = object_info[count].xpos & 0x1ff;
|
||||||
|
|
||||||
/* sprite masking (low priority sprite only) */
|
/* sprite masking (ignore the 1st sprite) */
|
||||||
if(!xpos && count) return;
|
if (xpos) spr_over = 1;
|
||||||
|
else if(spr_over)
|
||||||
|
{
|
||||||
|
spr_over = 0;
|
||||||
|
mask = 1;
|
||||||
|
}
|
||||||
|
|
||||||
size = object_info[count].size & 0x0f;
|
size = object_info[count].size & 0x0f;
|
||||||
width = sizetab[(size >> 2) & 3];
|
width = sizetab[(size >> 2) & 3];
|
||||||
|
|
||||||
/* update pixel count (off-screen sprites included) */
|
/* update pixel count (off-screen sprites included) */
|
||||||
pixelcount += width;
|
pixelcount += xpos ? width : (width * 2);
|
||||||
|
|
||||||
if(((xpos + width) >= left) && (xpos < right))
|
if(((xpos + width) >= left) && (xpos < right) && !mask)
|
||||||
{
|
{
|
||||||
ypos = object_info[count].ypos;
|
ypos = object_info[count].ypos;
|
||||||
attr = object_info[count].attr;
|
attr = object_info[count].attr;
|
||||||
@ -1766,7 +1788,13 @@ static void render_obj_im2(uint32 line, uint32 odd, uint8 *buf, uint8 *table)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* sprite limit (256 or 320 pixels) */
|
/* sprite limit (256 or 320 pixels) */
|
||||||
if (pixelcount >= bitmap.viewport.w) return;
|
if (pixelcount >= bitmap.viewport.w)
|
||||||
|
{
|
||||||
|
spr_over = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
spr_over = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -556,8 +556,8 @@ void vdp_ctrl_w(unsigned int data)
|
|||||||
}
|
}
|
||||||
else pending = 1;
|
else pending = 1;
|
||||||
|
|
||||||
addr = ((addr_latch & 0xC000) | (data & 0x3FFF)) & 0xFFFF;
|
addr = ((addr_latch & 0xC000) | (data & 0x3FFF));
|
||||||
code = ((code & 0x3C) | ((data >> 14) & 0x03)) & 0x3F;
|
code = ((code & 0x3C) | ((data >> 14) & 0x03));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -565,8 +565,8 @@ void vdp_ctrl_w(unsigned int data)
|
|||||||
pending = 0;
|
pending = 0;
|
||||||
|
|
||||||
/* Update address and code registers */
|
/* Update address and code registers */
|
||||||
addr = ((addr & 0x3FFF) | ((data & 3) << 14)) & 0xFFFF;
|
addr = ((addr & 0x3FFF) | ((data & 3) << 14));
|
||||||
code = ((code & 0x03) | ((data >> 2) & 0x3C)) & 0x3F;
|
code = ((code & 0x03) | ((data >> 2) & 0x3C));
|
||||||
|
|
||||||
/* Save address bits A15 and A14 */
|
/* Save address bits A15 and A14 */
|
||||||
addr_latch = (addr & 0xC000);
|
addr_latch = (addr & 0xC000);
|
||||||
|
Loading…
Reference in New Issue
Block a user