[Core/VDP]

.Minor optimizations to rendering code
.Fixed DMA Copy with undocumented code value (Fatal Labyrinth end sequence)
This commit is contained in:
EkeEke 2013-04-19 16:55:15 +02:00
parent f78f3e605a
commit e78d5a7834
2 changed files with 41 additions and 41 deletions

View File

@ -2976,7 +2976,7 @@ static void vdp_dma_68k_io(unsigned int length)
static void vdp_dma_copy(unsigned int length) static void vdp_dma_copy(unsigned int length)
{ {
/* VRAM read/write operation only */ /* VRAM read/write operation only */
if ((code & 0x1F) == 0x10) if ((code & 0x1E) == 0x10)
{ {
int name; int name;
uint8 data; uint8 data;

View File

@ -1521,11 +1521,11 @@ void render_bg_m5(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
uint32 shift = (xscroll >> 16) & 0x0F; uint32 shift = (xscroll >> 16) & 0x0F;
uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
uint32 v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; uint32 v_line = (line + (yscroll >> 16)) & pf_row_mask;
#else #else
uint32 shift = (xscroll & 0x0F); uint32 shift = (xscroll & 0x0F);
uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
uint32 v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; uint32 v_line = (line + yscroll) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -1578,11 +1578,11 @@ void render_bg_m5(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; v_line = (line + yscroll) & pf_row_mask;
#else #else
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 16)) & pf_row_mask;
#endif #endif
/* Plane A name table */ /* Plane A name table */
@ -1683,7 +1683,6 @@ void render_bg_m5_vs(int line, int width)
if (reg[12] & 1) if (reg[12] & 1)
{ {
yscroll = vs[19] & (vs[19] >> 16); yscroll = vs[19] & (vs[19] >> 16);
yscroll &= 0x3FF;
} }
if(shift) if(shift)
@ -1713,9 +1712,9 @@ void render_bg_m5_vs(int line, int width)
{ {
/* Plane B vertical scroll */ /* Plane B vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 16)) & pf_row_mask;
#else #else
v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; v_line = (line + vs[column]) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -1793,9 +1792,9 @@ void render_bg_m5_vs(int line, int width)
{ {
/* Plane A vertical scroll */ /* Plane A vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; v_line = (line + vs[column]) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 16)) & pf_row_mask;
#endif #endif
/* Plane A name table */ /* Plane A name table */
@ -1858,11 +1857,11 @@ void render_bg_m5_im2(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
uint32 shift = (xscroll >> 16) & 0x0F; uint32 shift = (xscroll >> 16) & 0x0F;
uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
uint32 v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; uint32 v_line = (line + (yscroll >> 17)) & pf_row_mask;
#else #else
uint32 shift = (xscroll & 0x0F); uint32 shift = (xscroll & 0x0F);
uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); uint32 index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
uint32 v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; uint32 v_line = (line + (yscroll >> 1)) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -1915,11 +1914,11 @@ void render_bg_m5_im2(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 1)) & pf_row_mask;
#else #else
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 17)) & pf_row_mask;
#endif #endif
/* Plane A name table */ /* Plane A name table */
@ -2021,7 +2020,6 @@ void render_bg_m5_im2_vs(int line, int width)
if (reg[12] & 1) if (reg[12] & 1)
{ {
yscroll = (vs[19] >> 1) & (vs[19] >> 17); yscroll = (vs[19] >> 1) & (vs[19] >> 17);
yscroll &= 0x3FF;
} }
if(shift) if(shift)
@ -2051,9 +2049,9 @@ void render_bg_m5_im2_vs(int line, int width)
{ {
/* Plane B vertical scroll */ /* Plane B vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 17)) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 1)) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -2131,9 +2129,9 @@ void render_bg_m5_im2_vs(int line, int width)
{ {
/* Plane A vertical scroll */ /* Plane A vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 1)) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 17)) & pf_row_mask;
#endif #endif
/* Plane A name table */ /* Plane A name table */
@ -2178,6 +2176,7 @@ void render_bg_m5(int line, int width)
int column, start, end; int column, start, end;
uint32 atex, atbuf, *src, *dst; uint32 atex, atbuf, *src, *dst;
uint32 shift, index, v_line, *nt; uint32 shift, index, v_line, *nt;
uint8 *lb;
/* Scroll Planes common data */ /* Scroll Planes common data */
uint32 xscroll = *(uint32 *)&vram[hscb + ((line & hscroll_mask) << 2)]; uint32 xscroll = *(uint32 *)&vram[hscb + ((line & hscroll_mask) << 2)];
@ -2223,11 +2222,11 @@ void render_bg_m5(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; v_line = (line + yscroll) & pf_row_mask;
#else #else
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 16)) & pf_row_mask;
#endif #endif
/* Background line buffer */ /* Background line buffer */
@ -2297,11 +2296,11 @@ void render_bg_m5(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 16)) & pf_row_mask;
#else #else
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; v_line = (line + yscroll) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -2311,7 +2310,7 @@ void render_bg_m5(int line, int width)
v_line = (v_line & 7) << 3; v_line = (v_line & 7) << 3;
/* Background line buffer */ /* Background line buffer */
uint8 *lb = &linebuf[0][0x20]; lb = &linebuf[0][0x20];
if(shift) if(shift)
{ {
@ -2334,6 +2333,7 @@ void render_bg_m5_vs(int line, int width)
int column, start, end; int column, start, end;
uint32 atex, atbuf, *src, *dst; uint32 atex, atbuf, *src, *dst;
uint32 shift, index, v_line, *nt; uint32 shift, index, v_line, *nt;
uint8 *lb;
/* Scroll Planes common data */ /* Scroll Planes common data */
uint32 xscroll = *(uint32 *)&vram[hscb + ((line & hscroll_mask) << 2)]; uint32 xscroll = *(uint32 *)&vram[hscb + ((line & hscroll_mask) << 2)];
@ -2372,7 +2372,6 @@ void render_bg_m5_vs(int line, int width)
if (reg[12] & 1) if (reg[12] & 1)
{ {
yscroll = vs[19] & (vs[19] >> 16); yscroll = vs[19] & (vs[19] >> 16);
yscroll &= 0x3FF;
} }
/* Number of columns to draw */ /* Number of columns to draw */
@ -2428,9 +2427,9 @@ void render_bg_m5_vs(int line, int width)
{ {
/* Plane A vertical scroll */ /* Plane A vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; v_line = (line + vs[column]) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 16)) & pf_row_mask;
#endif #endif
/* Plane A name table */ /* Plane A name table */
@ -2483,7 +2482,7 @@ void render_bg_m5_vs(int line, int width)
#endif #endif
/* Background line buffer */ /* Background line buffer */
uint8 *lb = &linebuf[0][0x20]; lb = &linebuf[0][0x20];
if(shift) if(shift)
{ {
@ -2507,9 +2506,9 @@ void render_bg_m5_vs(int line, int width)
{ {
/* Plane B vertical scroll */ /* Plane B vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 16)) & pf_row_mask;
#else #else
v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; v_line = (line + vs[column]) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -2528,6 +2527,7 @@ void render_bg_m5_im2(int line, int width)
int column, start, end; int column, start, end;
uint32 atex, atbuf, *src, *dst; uint32 atex, atbuf, *src, *dst;
uint32 shift, index, v_line, *nt; uint32 shift, index, v_line, *nt;
uint8 *lb;
/* Scroll Planes common data */ /* Scroll Planes common data */
int odd = odd_frame; int odd = odd_frame;
@ -2574,11 +2574,11 @@ void render_bg_m5_im2(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 1)) & pf_row_mask;
#else #else
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + start + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 17)) & pf_row_mask;
#endif #endif
/* Background line buffer */ /* Background line buffer */
@ -2648,11 +2648,11 @@ void render_bg_m5_im2(int line, int width)
#ifdef LSB_FIRST #ifdef LSB_FIRST
shift = (xscroll >> 16) & 0x0F; shift = (xscroll >> 16) & 0x0F;
index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask); index = pf_col_mask + 1 - ((xscroll >> 20) & pf_col_mask);
v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 17)) & pf_row_mask;
#else #else
shift = (xscroll & 0x0F); shift = (xscroll & 0x0F);
index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask); index = pf_col_mask + 1 - ((xscroll >> 4) & pf_col_mask);
v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (yscroll >> 1)) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */
@ -2662,7 +2662,7 @@ void render_bg_m5_im2(int line, int width)
v_line = (((v_line & 7) << 1) | odd) << 3; v_line = (((v_line & 7) << 1) | odd) << 3;
/* Background line buffer */ /* Background line buffer */
uint8 *lb = &linebuf[0][0x20]; lb = &linebuf[0][0x20];
if(shift) if(shift)
{ {
@ -2685,6 +2685,7 @@ void render_bg_m5_im2_vs(int line, int width)
int column, start, end; int column, start, end;
uint32 atex, atbuf, *src, *dst; uint32 atex, atbuf, *src, *dst;
uint32 shift, index, v_line, *nt; uint32 shift, index, v_line, *nt;
uint8 *lb;
/* common data */ /* common data */
int odd = odd_frame; int odd = odd_frame;
@ -2725,7 +2726,6 @@ void render_bg_m5_im2_vs(int line, int width)
{ {
/* only in 40-cell mode, verified on MD2 */ /* only in 40-cell mode, verified on MD2 */
yscroll = (vs[19] >> 1) & (vs[19] >> 17); yscroll = (vs[19] >> 1) & (vs[19] >> 17);
yscroll &= 0x3FF;
} }
/* Number of columns to draw */ /* Number of columns to draw */
@ -2781,9 +2781,9 @@ void render_bg_m5_im2_vs(int line, int width)
{ {
/* Plane A vertical scroll */ /* Plane A vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 1)) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 17)) & pf_row_mask;
#endif #endif
/* Plane A name table */ /* Plane A name table */
@ -2836,7 +2836,7 @@ void render_bg_m5_im2_vs(int line, int width)
#endif #endif
/* Background line buffer */ /* Background line buffer */
uint8 *lb = &linebuf[0][0x20]; lb = &linebuf[0][0x20];
if(shift) if(shift)
{ {
@ -2860,9 +2860,9 @@ void render_bg_m5_im2_vs(int line, int width)
{ {
/* Plane B vertical scroll */ /* Plane B vertical scroll */
#ifdef LSB_FIRST #ifdef LSB_FIRST
v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 17)) & pf_row_mask;
#else #else
v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; v_line = (line + (vs[column] >> 1)) & pf_row_mask;
#endif #endif
/* Plane B name table */ /* Plane B name table */