32x: various gfx related bugfixes

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@856 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2010-01-10 22:58:13 +00:00
parent 5a68108691
commit e51e5983fe
6 changed files with 45 additions and 27 deletions

View file

@ -50,19 +50,12 @@ static void convert_pal555(int invert_prio)
{ \ { \
unsigned short t; \ unsigned short t; \
int i; \ int i; \
for (i = 320/2; i > 0; i--, p32x++) { \ for (i = 320; i > 0; i--, pd++, p32x++, pmd++) { \
t = pal[*p32x >> 8]; \ t = pal[*(unsigned char *)((long)p32x ^ 1)]; \
if (*pmd == mdbg || (t & 0x20)) \ if (*pmd == mdbg || (t & 0x20)) \
*pd = t; \ *pd = t; \
else \ else \
pmd_draw_code; \ pmd_draw_code; \
pd++; pmd++; \
t = pal[*p32x & 0xff]; \
if (*pmd == mdbg || (t & 0x20)) \
*pd = t; \
else \
pmd_draw_code; \
pd++; pmd++; \
} \ } \
} }
@ -114,7 +107,10 @@ void FinalizeLine32xRGB555(int sh, int line)
convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI); convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI);
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { // Packed Pixel Mode if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { // Packed Pixel Mode
do_line_pp(pd, p32x, pmd,); unsigned char *p32xb = (void *)p32x;
if (Pico32x.vdp_regs[2 / 2] & P32XV_SFT)
p32xb++;
do_line_pp(pd, p32xb, pmd,);
} }
else { // Run Length Mode else { // Run Length Mode
do_line_rl(pd, p32x, pmd,); do_line_rl(pd, p32x, pmd,);
@ -125,22 +121,22 @@ void FinalizeLine32xRGB555(int sh, int line)
*dst = palmd[*pmd] *dst = palmd[*pmd]
#define PICOSCAN_PRE \ #define PICOSCAN_PRE \
PicoScan32xBegin(l + (lines_offs & 0xff)); \ PicoScan32xBegin(l + (lines_sft_offs & 0xff)); \
dst = DrawLineDest; \ dst = DrawLineDest; \
#define PICOSCAN_POST \ #define PICOSCAN_POST \
PicoScan32xEnd(l + (lines_offs & 0xff)); \ PicoScan32xEnd(l + (lines_sft_offs & 0xff)); \
#define make_do_loop(name, pre_code, post_code, md_code) \ #define make_do_loop(name, pre_code, post_code, md_code) \
/* Direct Color Mode */ \ /* Direct Color Mode */ \
static void do_loop_dc##name(unsigned short *dst, \ static void do_loop_dc##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg) \ unsigned short *dram, int lines_sft_offs, int mdbg) \
{ \ { \
int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; \ int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; \
unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \ unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \
unsigned short *palmd = HighPal; \ unsigned short *palmd = HighPal; \
unsigned short *p32x; \ unsigned short *p32x; \
int lines = lines_offs >> 16; \ int lines = lines_sft_offs >> 16; \
int l; \ int l; \
(void)palmd; \ (void)palmd; \
for (l = 0; l < lines; l++, pmd += 8) { \ for (l = 0; l < lines; l++, pmd += 8) { \
@ -153,18 +149,19 @@ static void do_loop_dc##name(unsigned short *dst, \
\ \
/* Packed Pixel Mode */ \ /* Packed Pixel Mode */ \
static void do_loop_pp##name(unsigned short *dst, \ static void do_loop_pp##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg) \ unsigned short *dram, int lines_sft_offs, int mdbg) \
{ \ { \
unsigned short *pal = Pico32xMem->pal_native; \ unsigned short *pal = Pico32xMem->pal_native; \
unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \ unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \
unsigned short *palmd = HighPal; \ unsigned short *palmd = HighPal; \
unsigned short *p32x; \ unsigned char *p32x; \
int lines = lines_offs >> 16; \ int lines = lines_sft_offs >> 16; \
int l; \ int l; \
(void)palmd; \ (void)palmd; \
for (l = 0; l < lines; l++, pmd += 8) { \ for (l = 0; l < lines; l++, pmd += 8) { \
pre_code; \ pre_code; \
p32x = dram + dram[l]; \ p32x = (void *)(dram + dram[l]); \
p32x += (lines_sft_offs >> 8) & 1; \
do_line_pp(dst, p32x, pmd, md_code); \ do_line_pp(dst, p32x, pmd, md_code); \
post_code; \ post_code; \
} \ } \
@ -172,13 +169,13 @@ static void do_loop_pp##name(unsigned short *dst, \
\ \
/* Run Length Mode */ \ /* Run Length Mode */ \
static void do_loop_rl##name(unsigned short *dst, \ static void do_loop_rl##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg) \ unsigned short *dram, int lines_sft_offs, int mdbg) \
{ \ { \
unsigned short *pal = Pico32xMem->pal_native; \ unsigned short *pal = Pico32xMem->pal_native; \
unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \ unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \
unsigned short *palmd = HighPal; \ unsigned short *palmd = HighPal; \
unsigned short *p32x; \ unsigned short *p32x; \
int lines = lines_offs >> 16; \ int lines = lines_sft_offs >> 16; \
int l; \ int l; \
(void)palmd; \ (void)palmd; \
for (l = 0; l < lines; l++, pmd += 8) { \ for (l = 0; l < lines; l++, pmd += 8) { \
@ -217,6 +214,7 @@ void PicoDraw32xLayer(int offs, int lines, int md_bg)
int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL; int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL;
const do_loop_func *do_loop; const do_loop_func *do_loop;
unsigned short *dram; unsigned short *dram;
int lines_sft_offs;
int which_func; int which_func;
DrawLineDest = DrawLineDestBase + offs * DrawLineDestIncrement; DrawLineDest = DrawLineDestBase + offs * DrawLineDestIncrement;
@ -253,8 +251,11 @@ do_it:
which_func = have_scan ? DO_LOOP_MD_SCAN : DO_LOOP_MD; which_func = have_scan ? DO_LOOP_MD_SCAN : DO_LOOP_MD;
else else
which_func = have_scan ? DO_LOOP_SCAN : DO_LOOP; which_func = have_scan ? DO_LOOP_SCAN : DO_LOOP;
lines_sft_offs = (lines << 16) | offs;
if (Pico32x.vdp_regs[2 / 2] & P32XV_SFT)
lines_sft_offs |= 1 << 8;
do_loop[which_func](DrawLineDest, dram, (lines << 16) | offs, md_bg); do_loop[which_func](DrawLineDest, dram, lines_sft_offs, md_bg);
} }
void PicoDraw32xSetFrameMode(int is_on, int only_32x) void PicoDraw32xSetFrameMode(int is_on, int only_32x)

View file

@ -58,7 +58,7 @@ Pico32xNativePal:
.endm .endm
@ direct color @ direct color
@ unsigned short *dst, unsigned short *dram, int lines_offs, int mdbg @ unsigned short *dst, unsigned short *dram, int lines_sft_offs, int mdbg
.macro make_do_loop_dc name call_scan do_md .macro make_do_loop_dc name call_scan do_md
.global \name .global \name
\name: \name:
@ -144,7 +144,7 @@ Pico32xNativePal:
.endif .endif
.endm .endm
@ unsigned short *dst, unsigned short *dram, int lines_offs, int mdbg @ unsigned short *dst, unsigned short *dram, int lines_sft_offs, int mdbg
.macro make_do_loop_pp name call_scan do_md .macro make_do_loop_pp name call_scan do_md
.global \name .global \name
\name: \name:
@ -175,6 +175,8 @@ Pico32xNativePal:
add r11,r11,#8 add r11,r11,#8
mov r6, #320 mov r6, #320
add r5, r1, r12, lsl #1 @ p32x = dram + dram[l] add r5, r1, r12, lsl #1 @ p32x = dram + dram[l]
and r12,r2, #0x100 @ shift
add r5, r5, r12,lsr #8
2: @ loop_inner: 2: @ loop_inner:
do_pixel_pp \do_md do_pixel_pp \do_md
@ -185,7 +187,7 @@ Pico32xNativePal:
@ run length @ run length
@ unsigned short *dst, unsigned short *dram, int lines_offs, int mdbg @ unsigned short *dst, unsigned short *dram, int lines_sft_offs, int mdbg
.macro make_do_loop_rl name call_scan do_md .macro make_do_loop_rl name call_scan do_md
.global \name .global \name
\name: \name:

View file

@ -341,6 +341,9 @@ static void p32x_vdp_write8(u32 a, u32 d)
Pico32x.dirty_pal = 1; Pico32x.dirty_pal = 1;
r[0] = (r[0] & P32XV_nPAL) | (d & 0xff); r[0] = (r[0] & P32XV_nPAL) | (d & 0xff);
break; break;
case 0x03: // shift (for pp mode)
r[2 / 2] = d & 1;
break;
case 0x05: // fill len case 0x05: // fill len
r[4 / 2] = d & 0xff; r[4 / 2] = d & 0xff;
break; break;
@ -1050,8 +1053,9 @@ static int REGPARM(3) sh2_write8_cs0(u32 a, u32 d, int id)
return sh2_write8_unmapped(a, d, id); return sh2_write8_unmapped(a, d, id);
} }
/* quirk: in both normal and overwrite areas only nonzero values go through */
#define sh2_write8_dramN(n) \ #define sh2_write8_dramN(n) \
if (!(a & 0x20000) || d) { \ if ((d & 0xff) != 0) { \
u8 *dram = (u8 *)Pico32xMem->dram[n]; \ u8 *dram = (u8 *)Pico32xMem->dram[n]; \
dram[(a & 0x1ffff) ^ 1] = d; \ dram[(a & 0x1ffff) ^ 1] = d; \
} \ } \

View file

@ -1566,10 +1566,12 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x)
rendstatus_old = -1; rendstatus_old = -1;
} }
// note: may be called on the middle of frame
void PicoDrawSetOutBuf(void *dest, int increment) void PicoDrawSetOutBuf(void *dest, int increment)
{ {
DrawLineDestBase = dest; DrawLineDestBase = dest;
DrawLineDestIncrement = increment; DrawLineDestIncrement = increment;
DrawLineDest = DrawLineDestBase + DrawScanline * increment;
} }
void PicoDrawSetInternalBuf(void *dest, int increment) void PicoDrawSetInternalBuf(void *dest, int increment)
@ -1577,6 +1579,7 @@ void PicoDrawSetInternalBuf(void *dest, int increment)
if (dest != NULL) { if (dest != NULL) {
HighColBase = dest; HighColBase = dest;
HighColIncrement = increment; HighColIncrement = increment;
HighCol = HighColBase + DrawScanline * increment;
} }
else { else {
HighColBase = DefHighCol; HighColBase = DefHighCol;

View file

@ -437,6 +437,8 @@ typedef struct
#define P32XV_PRI (1<< 7) #define P32XV_PRI (1<< 7)
#define P32XV_Mx (3<< 0) // display mode mask #define P32XV_Mx (3<< 0) // display mode mask
#define P32XV_SFT (1<< 0)
#define P32XV_VBLK (1<<15) #define P32XV_VBLK (1<<15)
#define P32XV_HBLK (1<<14) #define P32XV_HBLK (1<<14)
#define P32XV_PEN (1<<13) #define P32XV_PEN (1<<13)

View file

@ -156,6 +156,8 @@ static void apply_renderer(void)
PicoDraw32xSetFrameMode(1, only_32x); PicoDraw32xSetFrameMode(1, only_32x);
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2); PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
} }
//PicoDraw32xSetFrameMode(0, 0);
//PicoDrawSetOutFormat(PDF_RGB555, 1);
} }
void plat_video_toggle_renderer(int change, int is_menu) void plat_video_toggle_renderer(int change, int is_menu)
@ -220,7 +222,9 @@ void pemu_forced_frame(int opts)
PicoOpt &= ~POPT_ALT_RENDERER; PicoOpt &= ~POPT_ALT_RENDERER;
PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites PicoOpt |= opts|POPT_ACC_SPRITES; // acc_sprites
PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetOutFormat(PDF_RGB555, 1);
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
PicoDraw32xSetFrameMode(0, 0);
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
PicoFrameDrawOnly(); PicoFrameDrawOnly();
@ -311,7 +315,9 @@ void pemu_loop_end(void)
PicoOpt &= ~POPT_ALT_RENDERER; PicoOpt &= ~POPT_ALT_RENDERER;
PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES; PicoOpt |= POPT_EN_SOFTSCALE|POPT_ACC_SPRITES;
PicoDrawSetOutFormat(PDF_RGB555, 0); PicoDrawSetOutFormat(PDF_RGB555, 1);
PicoDrawSetOutBuf(g_screen_ptr, g_screen_width * 2);
PicoDraw32xSetFrameMode(0, 0);
Pico.m.dirtyPal = 1; Pico.m.dirtyPal = 1;
PicoFrame(); PicoFrame();