mirror of
https://github.com/ekeeke/Genesis-Plus-GX.git
synced 2024-12-30 21:21:49 +01:00
.fixed a bug with sprite rendering
.additional "optimization"
This commit is contained in:
parent
d2b4f21de8
commit
48b77511bf
@ -1456,19 +1456,18 @@ static void render_bg_im2_vs(int line, int width, int odd)
|
|||||||
|
|
||||||
static int spr_over = 0;
|
static int spr_over = 0;
|
||||||
|
|
||||||
static void render_obj(int line, uint8 *buf, uint8 *table)
|
static void render_obj(uint8 *buf, uint8 *table)
|
||||||
{
|
{
|
||||||
uint8 sizetab[] = {8, 16, 24, 32};
|
uint8 sizetab[] = {8, 16, 24, 32};
|
||||||
|
|
||||||
int i, count, column;
|
int i, count, column;
|
||||||
int xpos;
|
int xpos, width;
|
||||||
int v_line;
|
|
||||||
int pixelmax = bitmap.viewport.w;
|
int pixelmax = bitmap.viewport.w;
|
||||||
int pixelcount = 0;
|
int pixelcount = 0;
|
||||||
int masked = 0;
|
int masked = 0;
|
||||||
|
|
||||||
uint8 *src, *s, *lb;
|
uint8 *src, *s, *lb;
|
||||||
uint32 size, width;
|
uint32 size, v_line;
|
||||||
uint32 attr, attr_mask, name, palette, index;
|
uint32 attr, attr_mask, name, palette, index;
|
||||||
|
|
||||||
object *obj_info = object_info[object_which];
|
object *obj_info = object_info[object_which];
|
||||||
@ -1500,7 +1499,7 @@ static void render_obj(int line, uint8 *buf, uint8 *table)
|
|||||||
pixelcount += width;
|
pixelcount += width;
|
||||||
|
|
||||||
/* draw visible sprites */
|
/* draw visible sprites */
|
||||||
if (((xpos + width) >= 0) && (xpos < pixelmax) && !masked)
|
if (((xpos + width) > 0) && (xpos < pixelmax) && !masked)
|
||||||
{
|
{
|
||||||
/* sprite attributes + pattern index */
|
/* sprite attributes + pattern index */
|
||||||
attr = obj_info[count].attr;
|
attr = obj_info[count].attr;
|
||||||
@ -1509,7 +1508,7 @@ static void render_obj(int line, uint8 *buf, uint8 *table)
|
|||||||
name = attr & 0x07FF;
|
name = attr & 0x07FF;
|
||||||
|
|
||||||
/* sprite vertical offset */
|
/* sprite vertical offset */
|
||||||
v_line = line - obj_info[count].ypos;
|
v_line = obj_info[count].ypos;
|
||||||
s = &name_lut[((attr >> 3) & 0x300) | (size << 4) | ((v_line & 0x18) >> 1)];
|
s = &name_lut[((attr >> 3) & 0x300) | (size << 4) | ((v_line & 0x18) >> 1)];
|
||||||
v_line = (v_line & 7) << 3;
|
v_line = (v_line & 7) << 3;
|
||||||
|
|
||||||
@ -1545,19 +1544,18 @@ static void render_obj(int line, uint8 *buf, uint8 *table)
|
|||||||
spr_over = 0;
|
spr_over = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void render_obj_im2(int line, int odd, uint8 *buf, uint8 *table)
|
static void render_obj_im2(int odd, uint8 *buf, uint8 *table)
|
||||||
{
|
{
|
||||||
uint8 sizetab[] = {8, 16, 24, 32};
|
uint8 sizetab[] = {8, 16, 24, 32};
|
||||||
|
|
||||||
int i, count, column;
|
int i, count, column;
|
||||||
int xpos;
|
int xpos, width;
|
||||||
int v_line;
|
|
||||||
int pixelmax = bitmap.viewport.w;
|
int pixelmax = bitmap.viewport.w;
|
||||||
int pixelcount = 0;
|
int pixelcount = 0;
|
||||||
int masked = 0;
|
int masked = 0;
|
||||||
|
|
||||||
uint8 *src, *s, *lb;
|
uint8 *src, *s, *lb;
|
||||||
uint32 size, width;
|
uint32 size, v_line;
|
||||||
uint32 attr, attr_mask, name, palette, index;
|
uint32 attr, attr_mask, name, palette, index;
|
||||||
uint32 offs;
|
uint32 offs;
|
||||||
|
|
||||||
@ -1590,7 +1588,7 @@ static void render_obj_im2(int line, int odd, uint8 *buf, uint8 *table)
|
|||||||
pixelcount += width;
|
pixelcount += width;
|
||||||
|
|
||||||
/* draw visible sprites */
|
/* draw visible sprites */
|
||||||
if (((xpos + width) >= 0) && (xpos < pixelmax) && !masked)
|
if (((xpos + width) > 0) && (xpos < pixelmax) && !masked)
|
||||||
{
|
{
|
||||||
/* sprite attributes + pattern index */
|
/* sprite attributes + pattern index */
|
||||||
attr = obj_info[count].attr;
|
attr = obj_info[count].attr;
|
||||||
@ -1599,7 +1597,7 @@ static void render_obj_im2(int line, int odd, uint8 *buf, uint8 *table)
|
|||||||
name = (attr & 0x03FF);
|
name = (attr & 0x03FF);
|
||||||
|
|
||||||
/* sprite vertical offset */
|
/* sprite vertical offset */
|
||||||
v_line = line - obj_info[count].ypos;
|
v_line = obj_info[count].ypos;
|
||||||
s = &name_lut[((attr >> 3) & 0x300) | (size << 4) | ((v_line & 0x18) >> 1)];
|
s = &name_lut[((attr >> 3) & 0x300) | (size << 4) | ((v_line & 0x18) >> 1)];
|
||||||
v_line = (((v_line & 7) << 1) | odd) << 3;
|
v_line = (((v_line & 7) << 1) | odd) << 3;
|
||||||
|
|
||||||
@ -1758,13 +1756,13 @@ void render_line(int line)
|
|||||||
/* Shadow & Highlight */
|
/* Shadow & Highlight */
|
||||||
merge(&nta_buf[0x20], &ntb_buf[0x20], &bg_buf[0x20], lut[2], width);
|
merge(&nta_buf[0x20], &ntb_buf[0x20], &bg_buf[0x20], lut[2], width);
|
||||||
memset(&obj_buf[0x20], 0, width);
|
memset(&obj_buf[0x20], 0, width);
|
||||||
render_obj_im2(line, odd, obj_buf, lut[3]);
|
render_obj_im2(odd, obj_buf, lut[3]);
|
||||||
merge(&obj_buf[0x20], &bg_buf[0x20], &lb[0x20], lut[4], width);
|
merge(&obj_buf[0x20], &bg_buf[0x20], &lb[0x20], lut[4], width);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], width);
|
merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], width);
|
||||||
render_obj_im2(line, odd, lb, lut[1]);
|
render_obj_im2(odd, lb, lut[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1780,13 +1778,13 @@ void render_line(int line)
|
|||||||
/* Shadow & Highlight */
|
/* Shadow & Highlight */
|
||||||
merge(&nta_buf[0x20], &ntb_buf[0x20], &bg_buf[0x20], lut[2], width);
|
merge(&nta_buf[0x20], &ntb_buf[0x20], &bg_buf[0x20], lut[2], width);
|
||||||
memset(&obj_buf[0x20], 0, width);
|
memset(&obj_buf[0x20], 0, width);
|
||||||
render_obj(line, obj_buf, lut[3]);
|
render_obj(obj_buf, lut[3]);
|
||||||
merge(&obj_buf[0x20], &bg_buf[0x20], &lb[0x20], lut[4], width);
|
merge(&obj_buf[0x20], &bg_buf[0x20], &lb[0x20], lut[4], width);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], width);
|
merge(&nta_buf[0x20], &ntb_buf[0x20], &lb[0x20], lut[0], width);
|
||||||
render_obj(line, lb, lut[1]);
|
render_obj(lb, lut[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1907,7 +1905,8 @@ void parse_satb(int line)
|
|||||||
{
|
{
|
||||||
uint8 sizetab[] = {8, 16, 24, 32};
|
uint8 sizetab[] = {8, 16, 24, 32};
|
||||||
uint32 link = 0;
|
uint32 link = 0;
|
||||||
uint32 ypos, size, height;
|
uint32 size, height;
|
||||||
|
int ypos;
|
||||||
|
|
||||||
uint32 limit = (reg[12] & 1) ? 20 : 16;
|
uint32 limit = (reg[12] & 1) ? 20 : 16;
|
||||||
uint32 total = limit << 2;
|
uint32 total = limit << 2;
|
||||||
@ -1921,11 +1920,11 @@ void parse_satb(int line)
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
/* Read ypos & size from internal SAT */
|
/* Read ypos & size from internal SAT */
|
||||||
ypos = (q[link] >> im2_flag) & 0x1FF;
|
ypos = line - ((q[link] >> im2_flag) & 0x1FF);
|
||||||
size = q[link + 1] >> 8;
|
size = q[link + 1] >> 8;
|
||||||
height = sizetab[size & 3];
|
height = sizetab[size & 3];
|
||||||
|
|
||||||
if((line >= ypos) && (line < (ypos + height)))
|
if ((ypos >= 0) && (ypos < height))
|
||||||
{
|
{
|
||||||
/* Sprite limit (max. 16 or 20 sprites displayed per line) */
|
/* Sprite limit (max. 16 or 20 sprites displayed per line) */
|
||||||
if(count == limit)
|
if(count == limit)
|
||||||
|
@ -681,7 +681,7 @@ static void data_w(unsigned int data)
|
|||||||
error("[%d(%d)][%d(%d)] CRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC));
|
error("[%d(%d)][%d(%d)] CRAM 0x%x write -> 0x%x (%x)\n", v_counter, mcycles_68k/MCYCLES_PER_LINE, mcycles_68k, mcycles_68k%MCYCLES_PER_LINE, addr, data, m68k_get_reg (NULL, M68K_REG_PC));
|
||||||
#endif
|
#endif
|
||||||
uint16 *p = (uint16 *) &cram[(addr & 0x7E)];
|
uint16 *p = (uint16 *) &cram[(addr & 0x7E)];
|
||||||
data = PACK_CRAM (data & 0x0EEE);
|
data = PACK_CRAM (data);
|
||||||
if (data != *p)
|
if (data != *p)
|
||||||
{
|
{
|
||||||
int index = (addr >> 1) & 0x3F;
|
int index = (addr >> 1) & 0x3F;
|
||||||
@ -690,11 +690,11 @@ static void data_w(unsigned int data)
|
|||||||
/* update color palette */
|
/* update color palette */
|
||||||
/* color entry 0 of each palette is never displayed (transparent pixel) */
|
/* color entry 0 of each palette is never displayed (transparent pixel) */
|
||||||
if (index & 0x0F)
|
if (index & 0x0F)
|
||||||
color_update(index, *p);
|
color_update(index, data);
|
||||||
|
|
||||||
/* update background color */
|
/* update background color */
|
||||||
if (border == index)
|
if (border == index)
|
||||||
color_update (0x00, *p);
|
color_update (0x00, data);
|
||||||
|
|
||||||
/* CRAM modified during HBLANK (Striker, Zero the Kamikaze, etc) */
|
/* CRAM modified during HBLANK (Striker, Zero the Kamikaze, etc) */
|
||||||
if (!(status & 8) && (reg[1]& 0x40) && (mcycles_68k <= (mcycles_vdp + 860)))
|
if (!(status & 8) && (reg[1]& 0x40) && (mcycles_68k <= (mcycles_vdp + 860)))
|
||||||
|
Loading…
Reference in New Issue
Block a user