From: kub Date: Sat, 10 Oct 2020 07:38:59 +0000 (+0200) Subject: more rendering fixes and optimisations X-Git-Tag: v2.00~676 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33cb1ab0152d352c21a2ab66ccf7307281e20736;p=picodrive.git more rendering fixes and optimisations --- diff --git a/pico/32x/draw.c b/pico/32x/draw.c index bef8dd3d..8f933a08 100644 --- a/pico/32x/draw.c +++ b/pico/32x/draw.c @@ -41,6 +41,13 @@ static void convert_pal555(int invert_prio) 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 #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) { \ for (; i > 0 && (*pmd & 0x3f) == mdbg; pd++, pmd++, i--) { \ t = *p32x++; \ - *pd = ((t&m1) << 11) | ((t&m2) << 1) | ((t&m3) >> 10); \ + *pd = DC555(t); \ } \ for (; i > 0 && (*pmd & 0x3f) != mdbg; pd++, pmd++, i--) { \ t = *p32x++; \ if ((t ^ inv) & 0x8000) \ - *pd = ((t&m1) << 11) | ((t&m2) << 1) | ((t&m3) >> 10); \ + *pd = DC555(t); \ else \ pmd_draw_code; \ } \ diff --git a/pico/draw.c b/pico/draw.c index abffdfd7..66fa1a2e 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -33,13 +33,14 @@ * * low prio s/h rendering: * - 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: * - 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: - * - 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" @@ -252,16 +253,18 @@ TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark) // NB s/h already resolved by non-forced drawing // forced both layer draw (through debug reg) #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) TileFlipMaker(TileFlip_and, pix_and) // forced sprite draw (through debug reg) #define pix_sh_as_and(x) \ + pal |= 0xc0; /* leave s/h bits untouched in pixel "and" */ \ if (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) @@ -356,11 +359,21 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) dx+=cellskip<<3; // 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++) { u32 code, pack; - if ((cell&1)==0 || cell<0) + if ((cell&1)==0) { int line,vscroll; vscroll = PicoMem.vsram[plane + (cell&0x3e)]; @@ -1121,11 +1134,21 @@ static void DrawStripVSRamForced(struct TileStrip *ts, int plane_sh, int cellski tilex+=cellskip; 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++) { unsigned int pack; - if ((cell&1)==0 || cell<0) + if ((cell&1)==0) { int line,vscroll; vscroll = PicoMem.vsram[plane + (cell&0x3e)]; diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 0211dfac..d455197d 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -570,6 +570,32 @@ DrawLayer: @ 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 @ 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: sub r1, r1, #8 .dsloop_vs: @ 40-41 times @@ -579,8 +605,7 @@ DrawLayer: ble .dsloop_vs_exit @ need to calc new ty? - lsls r7, r10, #7 @ (cell&1) && ... - mvnmis r7, r10 @ ... cell>=0 + lsls r7, r10, #7 @ (cell&1)? bmi 0f @ calc offset and read tileline code to r7, also calc ty