mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
more rendering fixes and optimisations
This commit is contained in:
parent
758abbebc2
commit
33cb1ab015
3 changed files with 66 additions and 11 deletions
|
@ -41,6 +41,13 @@ static void convert_pal555(int invert_prio)
|
||||||
Pico32x.dirty_pal = 0;
|
Pico32x.dirty_pal = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 555 conversion for direct color mode
|
||||||
|
#if defined(USE_BGR555)
|
||||||
|
#define DC555(t) t
|
||||||
|
#else
|
||||||
|
#define DC555(t) ((t&m1) << 11) | ((t&m2) << 1) | ((t&m3) >> 10)
|
||||||
|
#endif
|
||||||
|
|
||||||
// direct color mode
|
// direct color mode
|
||||||
#define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code) \
|
#define do_line_dc(pd, p32x, pmd, inv, pmd_draw_code) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -53,12 +60,12 @@ static void convert_pal555(int invert_prio)
|
||||||
while (i > 0) { \
|
while (i > 0) { \
|
||||||
for (; i > 0 && (*pmd & 0x3f) == mdbg; pd++, pmd++, i--) { \
|
for (; i > 0 && (*pmd & 0x3f) == mdbg; pd++, pmd++, i--) { \
|
||||||
t = *p32x++; \
|
t = *p32x++; \
|
||||||
*pd = ((t&m1) << 11) | ((t&m2) << 1) | ((t&m3) >> 10); \
|
*pd = DC555(t); \
|
||||||
} \
|
} \
|
||||||
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
|
for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \
|
||||||
t = *p32x++; \
|
t = *p32x++; \
|
||||||
if ((t ^ inv) & 0x8000) \
|
if ((t ^ inv) & 0x8000) \
|
||||||
*pd = ((t&m1) << 11) | ((t&m2) << 1) | ((t&m3) >> 10); \
|
*pd = DC555(t); \
|
||||||
else \
|
else \
|
||||||
pmd_draw_code; \
|
pmd_draw_code; \
|
||||||
} \
|
} \
|
||||||
|
|
37
pico/draw.c
37
pico/draw.c
|
@ -33,13 +33,14 @@
|
||||||
*
|
*
|
||||||
* low prio s/h rendering:
|
* low prio s/h rendering:
|
||||||
* - plane and non-op sprite pixels have shadow
|
* - plane and non-op sprite pixels have shadow
|
||||||
* - sprite op pixel rendering is marked with hilight (deferred)
|
* - s/h sprite op pixel rendering is marked with hilight (deferred)
|
||||||
* high prio s/h rendering:
|
* high prio s/h rendering:
|
||||||
* - plane and non-op sprite pixels are normal
|
* - plane and non-op sprite pixels are normal
|
||||||
* - all op sprite pixels (either marked or high prio) are rendered
|
* - all s/h sprite op pixels (either marked or high prio) are rendered
|
||||||
*
|
*
|
||||||
* not handled properly:
|
* not handled properly:
|
||||||
* - high prio s/h sprite overlapping low prio sprite shows sprite, not A,B,G
|
* - high prio s/h sprite op overlapping low prio sprite shows sprite, not A,B,G
|
||||||
|
* - in debug sprite-masked, transparent high-prio sprite px don't remove shadow
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "pico_int.h"
|
#include "pico_int.h"
|
||||||
|
@ -252,16 +253,18 @@ TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark)
|
||||||
// NB s/h already resolved by non-forced drawing
|
// NB s/h already resolved by non-forced drawing
|
||||||
// forced both layer draw (through debug reg)
|
// forced both layer draw (through debug reg)
|
||||||
#define pix_and(x) \
|
#define pix_and(x) \
|
||||||
pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t))
|
pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \
|
||||||
|
pd[x] &= pal | t
|
||||||
|
|
||||||
TileNormMaker(TileNorm_and, pix_and)
|
TileNormMaker(TileNorm_and, pix_and)
|
||||||
TileFlipMaker(TileFlip_and, pix_and)
|
TileFlipMaker(TileFlip_and, pix_and)
|
||||||
|
|
||||||
// forced sprite draw (through debug reg)
|
// forced sprite draw (through debug reg)
|
||||||
#define pix_sh_as_and(x) \
|
#define pix_sh_as_and(x) \
|
||||||
|
pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \
|
||||||
if (m & (1<<(x+8))) { \
|
if (m & (1<<(x+8))) { \
|
||||||
m &= ~(1<<(x+8)); \
|
m &= ~(1<<(x+8)); \
|
||||||
if (t<0xe) pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t)); \
|
if (t<0xe) pd[x] &= pal | t; \
|
||||||
}
|
}
|
||||||
|
|
||||||
TileNormMakerAS(TileNormSH_AS_and, pix_sh_as_and)
|
TileNormMakerAS(TileNormSH_AS_and, pix_sh_as_and)
|
||||||
|
@ -356,11 +359,21 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)
|
||||||
dx+=cellskip<<3;
|
dx+=cellskip<<3;
|
||||||
|
|
||||||
// int force = (plane_sh&LF_FORCE) << 13;
|
// int force = (plane_sh&LF_FORCE) << 13;
|
||||||
|
if ((cell&1)==1)
|
||||||
|
{
|
||||||
|
int line,vscroll;
|
||||||
|
vscroll = PicoMem.vsram[plane + (cell&0x3e)];
|
||||||
|
|
||||||
|
// Find the line in the name table
|
||||||
|
line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
|
||||||
|
nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
|
||||||
|
ty=(line&7)<<1; // Y-Offset into tile
|
||||||
|
}
|
||||||
for (; cell < ts->cells; dx+=8,tilex++,cell++)
|
for (; cell < ts->cells; dx+=8,tilex++,cell++)
|
||||||
{
|
{
|
||||||
u32 code, pack;
|
u32 code, pack;
|
||||||
|
|
||||||
if ((cell&1)==0 || cell<0)
|
if ((cell&1)==0)
|
||||||
{
|
{
|
||||||
int line,vscroll;
|
int line,vscroll;
|
||||||
vscroll = PicoMem.vsram[plane + (cell&0x3e)];
|
vscroll = PicoMem.vsram[plane + (cell&0x3e)];
|
||||||
|
@ -1121,11 +1134,21 @@ static void DrawStripVSRamForced(struct TileStrip *ts, int plane_sh, int cellski
|
||||||
tilex+=cellskip;
|
tilex+=cellskip;
|
||||||
dx+=cellskip<<3;
|
dx+=cellskip<<3;
|
||||||
|
|
||||||
|
if ((cell&1)==1)
|
||||||
|
{
|
||||||
|
int line,vscroll;
|
||||||
|
vscroll = PicoMem.vsram[plane + (cell&0x3e)];
|
||||||
|
|
||||||
|
// Find the line in the name table
|
||||||
|
line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..
|
||||||
|
nametabadd=(line>>3)<<(ts->line>>24); // .. and shift[width]
|
||||||
|
ty=(line&7)<<1; // Y-Offset into tile
|
||||||
|
}
|
||||||
for (; cell < ts->cells; dx+=8,tilex++,cell++)
|
for (; cell < ts->cells; dx+=8,tilex++,cell++)
|
||||||
{
|
{
|
||||||
unsigned int pack;
|
unsigned int pack;
|
||||||
|
|
||||||
if ((cell&1)==0 || cell<0)
|
if ((cell&1)==0)
|
||||||
{
|
{
|
||||||
int line,vscroll;
|
int line,vscroll;
|
||||||
vscroll = PicoMem.vsram[plane + (cell&0x3e)];
|
vscroll = PicoMem.vsram[plane + (cell&0x3e)];
|
||||||
|
|
|
@ -570,6 +570,32 @@ DrawLayer:
|
||||||
@ r3=nametabadd[31:16]|must_be_0[15:8]|pal[7:0]
|
@ r3=nametabadd[31:16]|must_be_0[15:8]|pal[7:0]
|
||||||
@ r1=pd+dx r2=pack r6=hc r9=prevcode r11=HighCol r12=nametab lr=vram
|
@ r1=pd+dx r2=pack r6=hc r9=prevcode r11=HighCol r12=nametab lr=vram
|
||||||
@ r4 & r7 are scratch in this loop
|
@ r4 & r7 are scratch in this loop
|
||||||
|
|
||||||
|
@ need to calc new ty?
|
||||||
|
lsls r7, r10, #7 @ (cell&1)?
|
||||||
|
bmi .dsloop_vs_subr1
|
||||||
|
|
||||||
|
@ calc offset and read tileline code to r7, also calc ty
|
||||||
|
add_c24 r7, lr, (OFS_PMEM_vsram-OFS_PMEM_vram)
|
||||||
|
and r4, r10, #0x3e000000
|
||||||
|
add r7, r7, r4, asr #23 @ vsram + ((cell&0x3e)<<1)
|
||||||
|
tst r10,#0x8000 @ plane1?
|
||||||
|
addne r7, r7, #2
|
||||||
|
ldrh r7, [r7] @ r7=vscroll
|
||||||
|
|
||||||
|
bic r10,r10,#0xff @ clear old ty
|
||||||
|
and r4, r5, #0xff0000 @ scanline
|
||||||
|
add r4, r4, r7, lsl #16 @ ... += vscroll
|
||||||
|
and r4, r4, r5, lsl #16 @ ... &= ymask
|
||||||
|
and r7, r4, #0x70000
|
||||||
|
orr r10,r10,r7, lsr #15 @ new ty
|
||||||
|
|
||||||
|
mov r4, r4, lsr #19
|
||||||
|
mov r7, r5, lsr #24
|
||||||
|
mov r4, r4, lsl r7 @ nametabadd
|
||||||
|
and r3, r3, #0xff
|
||||||
|
orr r3, r3, r4, lsl #16 @ r3=(nametabadd[31:16],pal[15:0])
|
||||||
|
|
||||||
.dsloop_vs_subr1:
|
.dsloop_vs_subr1:
|
||||||
sub r1, r1, #8
|
sub r1, r1, #8
|
||||||
.dsloop_vs: @ 40-41 times
|
.dsloop_vs: @ 40-41 times
|
||||||
|
@ -579,8 +605,7 @@ DrawLayer:
|
||||||
ble .dsloop_vs_exit
|
ble .dsloop_vs_exit
|
||||||
|
|
||||||
@ need to calc new ty?
|
@ need to calc new ty?
|
||||||
lsls r7, r10, #7 @ (cell&1) && ...
|
lsls r7, r10, #7 @ (cell&1)?
|
||||||
mvnmis r7, r10 @ ... cell>=0
|
|
||||||
bmi 0f
|
bmi 0f
|
||||||
|
|
||||||
@ calc offset and read tileline code to r7, also calc ty
|
@ calc offset and read tileline code to r7, also calc ty
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue