new 32x renderers, auto fskip change, massive refactoring

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@855 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2010-01-10 17:07:28 +00:00
parent 9bb5d91c48
commit 5a68108691
35 changed files with 925 additions and 307 deletions

View file

@ -148,6 +148,26 @@ void PicoReset32x(void)
static void p32x_start_blank(void)
{
if (Pico32xDrawMode != 0) {
if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0 && // 32x not blanking
(Pico.video.reg[12] & 1) && // 40col mode
(PicoDrawMask & PDRAW_32X_ON))
{
int md_bg = Pico.video.reg[7] & 0x3f;
int offs = 8, lines = 224;
if (Pico.video.reg[1] & 8) {
offs = 0;
lines = 240;
}
// we draw full layer (not line-by-line)
PicoDraw32xLayer(offs, lines, md_bg);
}
else {
// TODO: MD layer only?
}
}
// enter vblank
Pico32x.vdp_regs[0x0a/2] |= P32XV_VBLK|P32XV_PEN;

View file

@ -1,5 +1,9 @@
#include "../pico_int.h"
int (*PicoScan32xBegin)(unsigned int num);
int (*PicoScan32xEnd)(unsigned int num);
int Pico32xDrawMode;
static void convert_pal555(int invert_prio)
{
unsigned int *ps = (void *)Pico32xMem->pal;
@ -22,49 +26,87 @@ static void convert_pal555(int invert_prio)
Pico32x.dirty_pal = 0;
}
// direct color mode
#define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code) \
{ \
const unsigned int m1 = 0x001f; \
const unsigned int m2 = 0x03e0; \
const unsigned int m3 = 0x7c00; \
int i; \
\
for (i = 320; i > 0; i--, pd++, p32x++, pmd++) { \
unsigned short t = *p32x; \
if (*pmd != mdbg && !((t ^ inv) & 0x8000)) { \
pmd_draw_code; \
continue; \
} \
\
*pd = ((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10); \
} \
}
// packed pixel mode
#define do_line_pp(pd, p32x, pmd, pmd_draw_code) \
{ \
unsigned short t; \
int i; \
for (i = 320/2; i > 0; i--, p32x++) { \
t = pal[*p32x >> 8]; \
if (*pmd == mdbg || (t & 0x20)) \
*pd = t; \
else \
pmd_draw_code; \
pd++; pmd++; \
t = pal[*p32x & 0xff]; \
if (*pmd == mdbg || (t & 0x20)) \
*pd = t; \
else \
pmd_draw_code; \
pd++; pmd++; \
} \
}
// run length mode
#define do_line_rl(pd, p32x, pmd, pmd_draw_code) \
{ \
unsigned short len, t; \
int i; \
for (i = 320; i > 0; p32x++) { \
t = pal[*p32x & 0xff]; \
for (len = (*p32x >> 8) + 1; len > 0 && i > 0; len--, i--, pd++, pmd++) { \
if (*pmd == mdbg || (t & 0x20)) \
*pd = t; \
else \
pmd_draw_code; \
} \
} \
}
void FinalizeLine32xRGB555(int sh, int line)
{
unsigned short *pd = DrawLineDest;
unsigned short *pal = Pico32xMem->pal_native;
unsigned char *pb = HighCol + 8;
unsigned short *dram, *ps, cram0;
int i;
unsigned char *pmd = HighCol + 8;
unsigned short *dram, *p32x;
unsigned char mdbg;
// this is a bit hackish:
// we swap cram color 0 with color that is used for background,
// as bg is forced to 0 when we do 32X
cram0 = Pico.cram[0];
Pico.cram[0] = Pico.cram[Pico.video.reg[7] & 0x3f];
FinalizeLine555(sh, line);
FinalizeLineRGB555(sh, line);
Pico.cram[0] = cram0;
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0)
return; // blanking
// XXX: how is 32col mode hadled by real hardware?
if (!(Pico.video.reg[12] & 1))
return;
if (!(PicoDrawMask & PDRAW_32X_ON))
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking
// XXX: how is 32col mode hadled by real hardware?
!(Pico.video.reg[12] & 1) || // 32col mode
!(PicoDrawMask & PDRAW_32X_ON))
{
return;
}
dram = (void *)Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS];
ps = dram + dram[line];
p32x = dram + dram[line];
mdbg = Pico.video.reg[7] & 0x3f;
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 2) { // Direct Color Mode
int inv = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0;
unsigned int m1 = 0x001f001f;
unsigned int m2 = 0x03e003e0;
unsigned int m3 = 0xfc00fc00;
for (i = 320; i > 0; i--, ps++, pd++, pb++) {
unsigned short t = *ps;
if (*pb != 0 && !((t ^ inv) & 0x8000))
continue;
*pd = ((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10);
}
int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0;
do_line_dc(pd, p32x, pmd, inv_bit,);
return;
}
@ -72,24 +114,163 @@ void FinalizeLine32xRGB555(int sh, int line)
convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI);
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { // Packed Pixel Mode
unsigned short t;
for (i = 320/2; i > 0; i--, ps++, pd += 2, pb += 2) {
t = pal[*ps >> 8];
if (pb[0] == 0 || (t & 0x20))
pd[0] = t;
t = pal[*ps & 0xff];
if (pb[1] == 0 || (t & 0x20))
pd[1] = t;
}
do_line_pp(pd, p32x, pmd,);
}
else { // Run Length Mode
unsigned short len, t;
for (i = 320; i > 0; ps++) {
t = pal[*ps & 0xff];
for (len = (*ps >> 8) + 1; len > 0 && i > 0; len--, i--, pd++, pb++)
if (*pb == 0 || (t & 0x20))
*pd = t;
}
do_line_rl(pd, p32x, pmd,);
}
}
#define MD_LAYER_CODE \
*dst = palmd[*pmd]
#define PICOSCAN_PRE \
PicoScan32xBegin(l + (lines_offs & 0xff)); \
dst = DrawLineDest; \
#define PICOSCAN_POST \
PicoScan32xEnd(l + (lines_offs & 0xff)); \
#define make_do_loop(name, pre_code, post_code, md_code) \
/* Direct Color Mode */ \
static void do_loop_dc##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg) \
{ \
int inv_bit = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; \
unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \
unsigned short *palmd = HighPal; \
unsigned short *p32x; \
int lines = lines_offs >> 16; \
int l; \
(void)palmd; \
for (l = 0; l < lines; l++, pmd += 8) { \
pre_code; \
p32x = dram + dram[l]; \
do_line_dc(dst, p32x, pmd, inv_bit, md_code); \
post_code; \
} \
} \
\
/* Packed Pixel Mode */ \
static void do_loop_pp##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg) \
{ \
unsigned short *pal = Pico32xMem->pal_native; \
unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \
unsigned short *palmd = HighPal; \
unsigned short *p32x; \
int lines = lines_offs >> 16; \
int l; \
(void)palmd; \
for (l = 0; l < lines; l++, pmd += 8) { \
pre_code; \
p32x = dram + dram[l]; \
do_line_pp(dst, p32x, pmd, md_code); \
post_code; \
} \
} \
\
/* Run Length Mode */ \
static void do_loop_rl##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg) \
{ \
unsigned short *pal = Pico32xMem->pal_native; \
unsigned char *pmd = PicoDraw2FB + 328 * 8 + 8; \
unsigned short *palmd = HighPal; \
unsigned short *p32x; \
int lines = lines_offs >> 16; \
int l; \
(void)palmd; \
for (l = 0; l < lines; l++, pmd += 8) { \
pre_code; \
p32x = dram + dram[l]; \
do_line_rl(dst, p32x, pmd, md_code); \
post_code; \
} \
}
#ifdef _ASM_32X_DRAW
#undef make_do_loop
#define make_do_loop(name, pre_code, post_code, md_code) \
extern void do_loop_dc##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg); \
extern void do_loop_pp##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg); \
extern void do_loop_rl##name(unsigned short *dst, \
unsigned short *dram, int lines_offs, int mdbg);
#endif
make_do_loop(,,,)
make_do_loop(_md, , , MD_LAYER_CODE)
make_do_loop(_scan, PICOSCAN_PRE, PICOSCAN_POST, )
make_do_loop(_scan_md, PICOSCAN_PRE, PICOSCAN_POST, MD_LAYER_CODE)
typedef void (*do_loop_func)(unsigned short *dst, unsigned short *dram, int lines, int mdbg);
enum { DO_LOOP, DO_LOOP_MD, DO_LOOP_SCAN, DO_LOOP_MD_SCAN };
static const do_loop_func do_loop_dc_f[] = { do_loop_dc, do_loop_dc_md, do_loop_dc_scan, do_loop_dc_scan_md };
static const do_loop_func do_loop_pp_f[] = { do_loop_pp, do_loop_pp_md, do_loop_pp_scan, do_loop_pp_scan_md };
static const do_loop_func do_loop_rl_f[] = { do_loop_rl, do_loop_rl_md, do_loop_rl_scan, do_loop_rl_scan_md };
void PicoDraw32xLayer(int offs, int lines, int md_bg)
{
int have_scan = PicoScan32xBegin != NULL && PicoScan32xEnd != NULL;
const do_loop_func *do_loop;
unsigned short *dram;
int which_func;
DrawLineDest = DrawLineDestBase + offs * DrawLineDestIncrement;
dram = Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS];
if (Pico32xDrawMode == 2) {
if (Pico.m.dirtyPal)
PicoDrawUpdateHighPal();
}
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 2)
{
// Direct Color Mode
do_loop = do_loop_dc_f;
goto do_it;
}
if (Pico32x.dirty_pal)
convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI);
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1)
{
// Packed Pixel Mode
do_loop = do_loop_pp_f;
}
else
{
// Run Length Mode
do_loop = do_loop_rl_f;
}
do_it:
if (Pico32xDrawMode == 2)
which_func = have_scan ? DO_LOOP_MD_SCAN : DO_LOOP_MD;
else
which_func = have_scan ? DO_LOOP_SCAN : DO_LOOP;
do_loop[which_func](DrawLineDest, dram, (lines << 16) | offs, md_bg);
}
void PicoDraw32xSetFrameMode(int is_on, int only_32x)
{
#ifdef _ASM_32X_DRAW
extern void *Pico32xNativePal;
Pico32xNativePal = Pico32xMem->pal_native;
#endif
if (is_on) {
// use the same layout as alt renderer
PicoDrawSetInternalBuf(PicoDraw2FB + 328*8, 328);
Pico32xDrawMode = only_32x ? 1 : 2;
} else {
PicoDrawSetInternalBuf(NULL, 0);
Pico32xDrawMode = 0;
}
}

263
pico/32x/draw_arm.s Normal file
View file

@ -0,0 +1,263 @@
@ vim:filetype=armasm
.extern Pico32x
.extern PicoDraw2FB
.extern HighPal
.equiv P32XV_PRI, (1<< 7)
.bss
.align 2
.global Pico32xNativePal
Pico32xNativePal:
.word 0
.text
.align 2
.macro call_scan_prep cond
.if \cond
ldr r4, =PicoScan32xBegin
ldr r5, =PicoScan32xEnd
ldr r6, =DrawLineDest
ldr r4, [r4]
ldr r5, [r5]
stmfd sp!, {r4,r5,r6}
.endif
.endm
.macro call_scan_fin_ge cond
.if \cond
addge sp, sp, #4*3
.endif
.endm
.macro call_scan_begin cond
.if \cond
stmfd sp!, {r1-r3}
and r0, r2, #0xff
add r0, r0, r4
mov lr, pc
ldr pc, [sp, #(3+0)*4]
ldr r0, [sp, #(3+2)*4] @ &DrawLineDest
ldmfd sp!, {r1-r3}
ldr r0, [r0]
.endif
.endm
.macro call_scan_end cond
.if \cond
stmfd sp!, {r0-r3}
and r0, r2, #0xff
add r0, r0, r4
mov lr, pc
ldr pc, [sp, #(4+1)*4]
ldmfd sp!, {r0-r3}
.endif
.endm
@ direct color
@ unsigned short *dst, unsigned short *dram, int lines_offs, int mdbg
.macro make_do_loop_dc name call_scan do_md
.global \name
\name:
stmfd sp!, {r4-r11,lr}
ldr r10,=Pico32x
ldr r11,=PicoDraw2FB
ldr r10,[r10, #0x40] @ Pico32x.vdp_regs[0]
ldr r11,[r11]
ldr r9, =HighPal @ palmd
add r11,r11,#(328*8) @ r11 = pmd: md data
tst r10,#P32XV_PRI
moveq r10,#0
movne r10,#0x8000 @ r10 = inv_bit
call_scan_prep \call_scan
mov r4, #0 @ line
b 1f @ loop_outer_entry
0: @ loop_outer:
call_scan_end \call_scan
add r4, r4, #1
sub r11,r11,#1 @ adjust for prev read
cmp r4, r2, lsr #16
call_scan_fin_ge \call_scan
ldmgefd sp!, {r4-r11,pc}
1: @ loop_outer_entry:
call_scan_begin \call_scan
mov r12,r4, lsl #1
ldrh r12,[r1, r12]
add r11,r11,#8
mov r6, #320
add r5, r1, r12, lsl #1 @ p32x = dram + dram[l]
2: @ loop_inner:
ldrb r7, [r11], #1 @ MD pixel
subs r6, r6, #1
blt 0b @ loop_outer
ldrh r8, [r5], #2 @ 32x pixel
cmp r7, r3 @ MD has bg pixel?
beq 3f @ draw32x
eor r12,r8, r10
ands r12,r12,#0x8000 @ !((t ^ inv) & 0x8000)
.if \do_md
mov r7, r7, lsl #1
ldreqh r12,[r9, r7]
streqh r12,[r0], #2 @ *dst++ = palmd[*pmd]
.endif
beq 2b @ loop_inner
3: @ draw32x:
and r12,r8, #0x03e0
mov r8, r8, lsl #11
orr r8, r8, r8, lsr #(10+11)
orr r8, r8, r12,lsl #1
bic r8, r8, #0x0020 @ kill prio bit
strh r8, [r0], #2 @ *dst++ = bgr2rgb(*p32x++)
b 2b @ loop_inner
.endm
@ packed pixel
.macro do_pixel_pp do_md
ldrb r7, [r11], #1 @ MD pixel
eor r12,r5, #1
ldrb r8, [r12] @ palette index
cmp r7, r3 @ MD has bg pixel?
mov r12,r8,lsl #1
ldrh r8, [r10,r12] @ t = 32x pixel
mov r7, r7, lsl #1
add r5, r5, #1
eorne r12,r8, #0x20
tstne r12, #0x20
.if \do_md
ldrneh r8, [r9, r7] @ t = palmd[*pmd]
subs r6, r6, #1
strh r8, [r0], #2 @ *dst++ = t
.else
streqh r8, [r0], #2
addne r0, r0, #2
subs r6, r6, #1
.endif
.endm
@ unsigned short *dst, unsigned short *dram, int lines_offs, int mdbg
.macro make_do_loop_pp name call_scan do_md
.global \name
\name:
stmfd sp!, {r4-r11,lr}
ldr r11,=PicoDraw2FB
ldr r10,=Pico32xNativePal
ldr r11,[r11]
ldr r10,[r10]
ldr r9, =HighPal @ palmd
add r11,r11,#(328*8) @ r11 = pmd: md data
call_scan_prep \call_scan
mov r4, #0 @ line
b 1f @ loop_outer_entry
0: @ loop_outer:
call_scan_end \call_scan
add r4, r4, #1
cmp r4, r2, lsr #16
call_scan_fin_ge \call_scan
ldmgefd sp!, {r4-r11,pc}
1: @ loop_outer_entry:
call_scan_begin \call_scan
mov r12,r4, lsl #1
ldrh r12,[r1, r12]
add r11,r11,#8
mov r6, #320
add r5, r1, r12, lsl #1 @ p32x = dram + dram[l]
2: @ loop_inner:
do_pixel_pp \do_md
do_pixel_pp \do_md
bgt 2b @ loop_inner
b 0b @ loop_outer
.endm
@ run length
@ unsigned short *dst, unsigned short *dram, int lines_offs, int mdbg
.macro make_do_loop_rl name call_scan do_md
.global \name
\name:
stmfd sp!, {r4-r11,lr}
ldr r11,=PicoDraw2FB
ldr r10,=Pico32xNativePal
ldr r11,[r11]
ldr r10,[r10]
ldr r9, =HighPal @ palmd
add r11,r11,#(328*8) @ r11 = pmd: md data
call_scan_prep \call_scan
mov r4, #0 @ line
b 1f @ loop_outer_entry
0: @ loop_outer:
call_scan_end \call_scan
add r4, r4, #1
sub r11,r11,#1 @ adjust for prev read
cmp r4, r2, lsr #16
call_scan_fin_ge \call_scan
ldmgefd sp!, {r4-r11,pc}
1: @ loop_outer_entry:
call_scan_begin \call_scan
mov r12,r4, lsl #1
ldrh r12,[r1, r12]
add r11,r11,#8
mov r6, #320
add r5, r1, r12, lsl #1 @ p32x = dram + dram[l]
2: @ loop_inner:
ldrh r8, [r5], #2 @ control word
and r12,r8, #0xff
mov r12,r12,lsl #1
ldrh lr, [r10,r12] @ t = 32x pixel
eor lr, lr, #0x20
3: @ loop_innermost:
ldrb r7, [r11], #1 @ MD pixel
subs r6, r6, #1
blt 0b @ loop_outer
cmp r7, r3 @ MD has bg pixel?
mov r7, r7, lsl #1
tstne lr, #0x20
.if \do_md
ldrneh r12,[r9, r7] @ t = palmd[*pmd]
streqh lr, [r0], #2
strneh r12,[r0], #2 @ *dst++ = t
.else
streqh lr, [r0]
add r0, r0, #2
.endif
subs r8, r8, #0x100
bge 3b @ loop_innermost
b 2b @ loop_inner
.endm
make_do_loop_dc do_loop_dc, 0, 0
make_do_loop_dc do_loop_dc_md, 0, 1
make_do_loop_dc do_loop_dc_scan, 1, 0
make_do_loop_dc do_loop_dc_scan_md, 1, 1
make_do_loop_pp do_loop_pp, 0, 0
make_do_loop_pp do_loop_pp_md, 0, 1
make_do_loop_pp do_loop_pp_scan, 1, 0
make_do_loop_pp do_loop_pp_scan_md, 1, 1
make_do_loop_rl do_loop_rl, 0, 0
make_do_loop_rl do_loop_rl_md, 0, 1
make_do_loop_rl do_loop_rl_scan, 1, 0
make_do_loop_rl do_loop_rl_scan_md, 1, 1

View file

@ -34,14 +34,15 @@
int (*PicoScanBegin)(unsigned int num) = NULL;
int (*PicoScanEnd) (unsigned int num) = NULL;
#if OVERRIDE_HIGHCOL
static unsigned char DefHighCol[8+320+8];
unsigned char *HighCol=DefHighCol;
#else
unsigned char HighCol[8+320+8];
#endif
unsigned char *HighCol = DefHighCol;
static unsigned char *HighColBase = DefHighCol;
static int HighColIncrement;
static unsigned int DefOutBuff[320*2/2];
void *DrawLineDest=DefOutBuff; // pointer to dest buffer where to draw this line to
void *DrawLineDest = DefOutBuff; // pointer to dest buffer where to draw this line to
void *DrawLineDestBase = DefOutBuff;
int DrawLineDestIncrement;
static int HighCacheA[41+1]; // caches for high layers
static int HighCacheB[41+1];
@ -1193,6 +1194,7 @@ void PicoDoHighPal555(int sh)
}
}
#if 0
static void FinalizeLineBGR444(int sh, int line)
{
unsigned short *pd=DrawLineDest;
@ -1229,9 +1231,10 @@ static void FinalizeLineBGR444(int sh, int line)
for(i = 0; i < len; i++)
pd[i] = pal[ps[i] & mask];
}
#endif
void FinalizeLineRGB555(int sh, int line)
void FinalizeLine555(int sh, int line)
{
unsigned short *pd=DrawLineDest;
unsigned char *ps=HighCol+8;
@ -1405,7 +1408,7 @@ static int DrawDisplay(int sh)
// MUST be called every frame
PICO_INTERNAL void PicoFrameStart(void)
{
int lines = 224;
int offs = 8, lines = 224;
// prepare to do this frame
rendstatus = 0;
@ -1413,9 +1416,13 @@ PICO_INTERNAL void PicoFrameStart(void)
rendstatus |= PDRAW_INTERLACE; // interlace mode
if (!(Pico.video.reg[12] & 1))
rendstatus |= PDRAW_32_COLS;
if (Pico.video.reg[1] & 8)
if (Pico.video.reg[1] & 8) {
offs = 0;
lines = 240;
}
HighCol = HighColBase;
DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement;
DrawScanline = 0;
skip_next_line = 0;
@ -1477,6 +1484,9 @@ static void PicoLine(int line, int offs, int sh, int bgc)
if (PicoScanEnd != NULL)
skip_next_line = PicoScanEnd(line + offs);
HighCol += HighColIncrement;
DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement;
}
void PicoDrawSync(int to, int blank_last_line)
@ -1490,10 +1500,6 @@ void PicoDrawSync(int to, int blank_last_line)
if (rendlines != 240)
offs = 8;
// need to know which pixels are bg for 32x
if (PicoAHW & PAHW_32X)
bgc = 0;
for (line = DrawScanline; line < to; line++)
{
#if !CAN_HANDLE_240_LINES
@ -1522,20 +1528,59 @@ void PicoDrawSync(int to, int blank_last_line)
pprof_end(draw);
}
void PicoDrawSetColorFormat(int which)
// also works for fast renderer
void PicoDrawUpdateHighPal(void)
{
int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight?
if (PicoOpt & POPT_ALT_RENDERER)
sh = 0; // no s/h support
PicoDoHighPal555(sh);
if (rendstatus & PDRAW_SONIC_MODE) {
// FIXME?
memcpy(HighPal + 0x40, HighPal, 0x40*2);
memcpy(HighPal + 0x80, HighPal, 0x40*2);
}
}
void PicoDrawSetOutFormat(pdso_t which, int allow_32x)
{
switch (which)
{
case 2: FinalizeLine = FinalizeLine8bit; break;
case 1: FinalizeLine = (PicoAHW & PAHW_32X) ? FinalizeLine32xRGB555 : FinalizeLineRGB555; break;
case 0: FinalizeLine = FinalizeLineBGR444; break;
default:FinalizeLine = NULL; break;
case PDF_8BIT:
FinalizeLine = FinalizeLine8bit;
break;
case PDF_RGB555:
if ((PicoAHW & PAHW_32X) && allow_32x)
FinalizeLine = FinalizeLine32xRGB555;
else
FinalizeLine = FinalizeLine555;
break;
default:
FinalizeLine = NULL;
break;
}
PicoDrawSetColorFormatMode4(which);
PicoDrawSetOutputMode4(which);
rendstatus_old = -1;
#if OVERRIDE_HIGHCOL
if (which)
HighCol=DefHighCol;
#endif
}
void PicoDrawSetOutBuf(void *dest, int increment)
{
DrawLineDestBase = dest;
DrawLineDestIncrement = increment;
}
void PicoDrawSetInternalBuf(void *dest, int increment)
{
if (dest != NULL) {
HighColBase = dest;
HighColIncrement = increment;
}
else {
HighColBase = DefHighCol;
HighColIncrement = 0;
}
}

View file

@ -19,6 +19,8 @@
.extern DrawStripInterlace
.extern HighCacheS_ptr
.equiv OVERRIDE_HIGHCOL, 1
.equ PDRAW_SPRITES_MOVED, (1<<0)
.equ PDRAW_WND_DIFF_PRIO, (1<<1)
.equ PDRAW_ACC_SPRITES, (1<<2)
@ -1674,7 +1676,7 @@ PicoDoHighPal555:
ldr r8, =(Pico+0x22228) @ Pico.video
PicoDoHighPal555_nopush:
str r1, [sp, #-8] @ is called from FinalizeLineRGB555?
str r1, [sp, #-8] @ is called from FinalizeLine555?
str r0, [sp, #-4]
ldr r0, =HighPal
@ -1728,9 +1730,9 @@ PicoDoHighPal555_end:
b FinalizeLineRGB555_pal_done
.global FinalizeLineRGB555 @ int sh
.global FinalizeLine555 @ int sh
FinalizeLineRGB555:
FinalizeLine555:
stmfd sp!, {r4-r9,lr}
ldr r8, =(Pico+0x22228) @ Pico.video

View file

@ -211,6 +211,8 @@ void PicoFrameStartMode4(void)
rendlines = lines;
emu_video_mode_change(screen_offset, lines, 1);
}
DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement;
}
void PicoLineMode4(int line)
@ -233,6 +235,8 @@ void PicoLineMode4(int line)
if (PicoScanEnd != NULL)
skip_next_line = PicoScanEnd(line + screen_offset);
DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement;
}
void PicoDoHighPal555M4(void)
@ -265,7 +269,7 @@ static void FinalizeLineRGB555M4(int line)
// standard FinalizeLine can finish it for us,
// with features like scaling and such
FinalizeLineRGB555(0, line);
FinalizeLine555(0, line);
}
static void FinalizeLine8bitM4(int line)
@ -278,13 +282,13 @@ static void FinalizeLine8bitM4(int line)
memcpy32((int *)pd, (int *)(HighCol+8), 256/4);
}
void PicoDrawSetColorFormatMode4(int which)
void PicoDrawSetOutputMode4(pdso_t which)
{
switch (which)
{
case 2: FinalizeLineM4 = FinalizeLine8bitM4; break;
case 1: FinalizeLineM4 = FinalizeLineRGB555M4; break;
default:FinalizeLineM4 = NULL; break;
case PDF_8BIT: FinalizeLineM4 = FinalizeLine8bitM4; break;
case PDF_RGB555: FinalizeLineM4 = FinalizeLineRGB555M4; break;
default: FinalizeLineM4 = NULL; break;
}
}

View file

@ -160,13 +160,18 @@ extern void (*PicoCartLoadProgressCB)(int percent);
extern void (*PicoCDLoadProgressCB)(const char *fname, int percent);
// Draw.c
void PicoDrawSetColorFormat(int which); // 0=BGR444, 1=RGB555, 2=8bit(HighPal pal)
// for line-based renderer, set conversion
// from internal 8 bit representation in 'HighCol' to:
typedef enum
{
PDF_NONE = 0, // no conversion
PDF_RGB555, // RGB/BGR output, depends on compile options
PDF_8BIT, // 8-bit out (handles shadow/hilight mode, sonic water)
} pdso_t;
void PicoDrawSetOutFormat(pdso_t which, int allow_32x);
void PicoDrawSetOutBuf(void *dest, int increment);
extern void *DrawLineDest;
#if OVERRIDE_HIGHCOL
extern unsigned char *HighCol;
#else
extern unsigned char HighCol[8+320+8];
#endif
extern int (*PicoScanBegin)(unsigned int num);
extern int (*PicoScanEnd)(unsigned int num);
// utility
@ -194,12 +199,21 @@ extern int rendstatus, rendstatus_old;
extern int rendlines;
extern unsigned short HighPal[0x100];
// Draw2.c
// draw.c
void PicoDrawUpdateHighPal(void);
void PicoDrawSetInternalBuf(void *dest, int line_increment);
// draw2.c
// stuff below is optional
extern unsigned char *PicoDraw2FB; // buffer for fast renderer in format (8+320)x(8+224+8) (eights for borders)
extern unsigned short *PicoCramHigh; // pointer to CRAM buff (0x40 shorts), converted to native device color (works only with 16bit for now)
extern void (*PicoPrepareCram)(); // prepares PicoCramHigh for renderer to use
// 32x/draw.c
void PicoDraw32xSetFrameMode(int is_on, int only_32x);
extern int (*PicoScan32xBegin)(unsigned int num);
extern int (*PicoScan32xEnd)(unsigned int num);
// sound.c
extern int PsndRate,PsndLen;
extern short *PsndOut;

View file

@ -474,8 +474,8 @@ typedef struct
struct Pico32x
{
unsigned short regs[0x20];
unsigned short vdp_regs[0x10];
unsigned short sh2_regs[3];
unsigned short vdp_regs[0x10]; // 0x40
unsigned short sh2_regs[3]; // 0x60
unsigned char pending_fb;
unsigned char dirty_pal;
unsigned int emu_flags;
@ -547,10 +547,12 @@ int CM_compareRun(int cyc, int is_sub);
PICO_INTERNAL void PicoFrameStart(void);
void PicoDrawSync(int to, int blank_last_line);
void BackFill(int reg7, int sh);
void FinalizeLineRGB555(int sh, int line);
void FinalizeLine555(int sh, int line);
extern int DrawScanline;
#define MAX_LINE_SPRITES 29
extern unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES];
extern void *DrawLineDestBase;
extern int DrawLineDestIncrement;
// draw2.c
PICO_INTERNAL void PicoFrameFull();
@ -559,7 +561,7 @@ PICO_INTERNAL void PicoFrameFull();
void PicoFrameStartMode4(void);
void PicoLineMode4(int line);
void PicoDoHighPal555M4(void);
void PicoDrawSetColorFormatMode4(int which);
void PicoDrawSetOutputMode4(pdso_t which);
// memory.c
PICO_INTERNAL void PicoMemSetup(void);
@ -717,6 +719,8 @@ void p32x_poll_event(int cpu_mask, int is_vdp);
// 32x/draw.c
void FinalizeLine32xRGB555(int sh, int line);
void PicoDraw32xLayer(int offs, int lines, int mdbg);
extern int Pico32xDrawMode;
// 32x/pwm.c
unsigned int p32x_pwm_read16(unsigned int a);