From 6ff42f4252d17fb603ac6755f3cd6e9364dd4404 Mon Sep 17 00:00:00 2001 From: ekeeke31 Date: Mon, 9 Nov 2009 12:05:19 +0000 Subject: [PATCH] minor optimizations to VDP rendering code --- source/render.c | 28 ++++++++++++---------------- source/vdp.c | 9 +++------ source/vdp.h | 1 - 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/source/render.c b/source/render.c index ad248bd..04fd5af 100644 --- a/source/render.c +++ b/source/render.c @@ -974,7 +974,6 @@ static void render_bg(uint32 line, uint32 width) uint32 pf_col_mask = playfield_col_mask; uint32 pf_row_mask = playfield_row_mask; uint32 pf_shift = playfield_shift; - uint32 pf_y_mask = y_mask; /* Plane B */ uint8 *buf = ntb_buf; @@ -991,7 +990,7 @@ static void render_bg(uint32 line, uint32 width) uint32 v_line = (line + (yscroll & 0x3FF)) & pf_row_mask; #endif - uint32 *nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + uint32 *nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (v_line & 7) << 3; if(shift) @@ -1044,7 +1043,7 @@ static void render_bg(uint32 line, uint32 width) v_line = (line + ((yscroll >> 16) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (v_line & 7) << 3; if(shift) @@ -1094,7 +1093,6 @@ static void render_bg_vs(uint32 line, uint32 width) uint32 pf_col_mask = playfield_col_mask; uint32 pf_row_mask = playfield_row_mask; uint32 pf_shift = playfield_shift; - uint32 pf_y_mask = y_mask; uint32 *vs = (uint32 *)&vsram[0]; /* Plane B */ @@ -1121,7 +1119,7 @@ static void render_bg_vs(uint32 line, uint32 width) #else v_line = (line + (vs[0] & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (v_line & 7) << 3; atbuf = nt[(index-1) & pf_col_mask]; @@ -1136,7 +1134,7 @@ static void render_bg_vs(uint32 line, uint32 width) #else v_line = (line + (vs[column] & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (v_line & 7) << 3; atbuf = nt[index & pf_col_mask]; @@ -1186,7 +1184,7 @@ static void render_bg_vs(uint32 line, uint32 width) #else v_line = (line + ((vs[start] >> 16) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (v_line & 7) << 3; /* Window bug */ @@ -1204,7 +1202,7 @@ static void render_bg_vs(uint32 line, uint32 width) #else v_line = (line + ((vs[column] >> 16) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (v_line & 7) << 3; atbuf = nt[index & pf_col_mask]; @@ -1240,7 +1238,6 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) uint32 pf_col_mask = playfield_col_mask; uint32 pf_row_mask = playfield_row_mask; uint32 pf_shift = playfield_shift; - uint32 pf_y_mask = y_mask; /* Plane B */ uint8 *buf = ntb_buf; @@ -1257,7 +1254,7 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) uint32 v_line = (line + ((yscroll >> 1) & 0x3FF)) & pf_row_mask; #endif - uint32 *nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + uint32 *nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (((v_line & 7) << 1) | odd) << 3; if(shift) @@ -1308,7 +1305,7 @@ static void render_bg_im2(uint32 line, uint32 width, uint32 odd) v_line = (line + ((yscroll >> 17) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (((v_line & 7) << 1) | odd) << 3; if(shift) @@ -1357,7 +1354,6 @@ static void render_bg_im2_vs(uint32 line, uint32 width, uint32 odd) uint32 pf_col_mask = playfield_col_mask; uint32 pf_row_mask = playfield_row_mask; uint32 pf_shift = playfield_shift; - uint32 pf_y_mask = y_mask; uint32 *vs = (uint32 *)&vsram[0]; /* Plane B */ @@ -1384,7 +1380,7 @@ static void render_bg_im2_vs(uint32 line, uint32 width, uint32 odd) #else v_line = (line + ((vs[0] >> 1) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (((v_line & 7) << 1) | odd) << 3; atbuf = nt[(index-1) & pf_col_mask]; @@ -1399,7 +1395,7 @@ static void render_bg_im2_vs(uint32 line, uint32 width, uint32 odd) #else v_line = (line + ((vs[column] >> 1) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntbb + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (((v_line & 7) << 1) | odd) << 3; atbuf = nt[index & pf_col_mask]; @@ -1447,7 +1443,7 @@ static void render_bg_im2_vs(uint32 line, uint32 width, uint32 odd) #else v_line = (line + ((vs[start] >> 17) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (((v_line & 7) << 1) | odd) << 3; /* Window bug */ @@ -1465,7 +1461,7 @@ static void render_bg_im2_vs(uint32 line, uint32 width, uint32 odd) #else v_line = (line + ((vs[column] >> 17) & 0x3FF)) & pf_row_mask; #endif - nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & pf_y_mask)]; + nt = (uint32 *)&vram[ntab + (((v_line >> 3) << pf_shift) & 0x1FC0)]; v_line = (((v_line & 7) << 1) | odd) << 3; atbuf = nt[index & pf_col_mask]; diff --git a/source/vdp.c b/source/vdp.c index 2a24bd6..4cf7202 100644 --- a/source/vdp.c +++ b/source/vdp.c @@ -82,10 +82,9 @@ uint16 lines_per_frame; /* PAL: 313 lines, NTSC: 262 lines */ /* Tables that define the playfield layout */ -static const uint8 shift_table[] = { 6, 7, 0, 8 }; +static const uint8 shift_table[] = { 6, 7, 0, 8 }; /* fixes Window Bug test program */ static const uint8 col_mask_table[] = { 0x0F, 0x1F, 0x0F, 0x3F }; static const uint16 row_mask_table[] = { 0x0FF, 0x1FF, 0x2FF, 0x3FF }; -static const uint32 y_mask_table[] = { 0x1FC0, 0x1F80, 0x1FC0, 0x1F00 }; static uint16 sat_base_mask; /* Base bits of SAT */ static uint16 sat_addr_mask; /* Index bits of SAT */ @@ -194,7 +193,6 @@ void vdp_reset(void) playfield_shift = 6; playfield_col_mask = 0x0F; playfield_row_mask = 0x0FF; - y_mask = 0x1FC0; hint_pending = 0; vint_pending = 0; @@ -906,7 +904,7 @@ static inline void reg_w(unsigned int r, unsigned int d) } break; - case 13: /* HSCB */ + case 13: /* HScroll Base Address */ hscb = (d << 10) & 0xFC00; break; @@ -914,10 +912,9 @@ static inline void reg_w(unsigned int r, unsigned int d) playfield_shift = shift_table[(d & 3)]; playfield_col_mask = col_mask_table[(d & 3)]; playfield_row_mask = row_mask_table[(d >> 4) & 3]; - y_mask = y_mask_table[(d & 3)]; break; - case 17: /* Update clipping */ + case 17: /* Window/Plane A clipping */ reg[17] = d; window_clip(); break; diff --git a/source/vdp.h b/source/vdp.h index f1b4f7c..e08c4db 100644 --- a/source/vdp.h +++ b/source/vdp.h @@ -54,7 +54,6 @@ extern uint8 bg_pattern_cache[0x80000]; extern uint8 playfield_shift; extern uint8 playfield_col_mask; extern uint16 playfield_row_mask; -extern uint32 y_mask; extern uint16 hc_latch; extern uint16 v_counter; extern uint32 dma_length;