From 29d99d6bb852118b2d688705eb427e8e9adb797f Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 16 Feb 2020 13:48:51 +0100 Subject: [PATCH] vdp rendering fixes --- pico/draw.c | 20 ++++++++++++-------- pico/draw2.c | 2 +- pico/draw_arm.S | 15 ++++++++++----- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index 01153f3e..49d41521 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -339,12 +339,13 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) oldcode = code; // Get tile address/2: addr=(code&0x7ff)<<4; - if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip pal=((code>>9)&0x30)|((plane_sh<<5)&0x40); } - pack = *(unsigned int *)(PicoMem.vram + addr); + if (code & 0x1000) ty ^= 0xe; // Y-flip + pack = *(unsigned int *)(PicoMem.vram + addr+ty); + if (!pack) { blank = code; continue; @@ -394,7 +395,7 @@ void DrawStripInterlace(struct TileStrip *ts) if (code!=oldcode) { oldcode = code; // Get tile address/2: - addr=(code&0x7ff)<<5; + addr=(code&0x3ff)<<5; if (code&0x1000) addr+=30-ty; else addr+=ty; // Y-flip // pal=Pico.cram+((code>>9)&0x30); @@ -449,8 +450,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, else ts.nametab=(pvid->reg[2]&0x38)<< 9; // A htab=pvid->reg[13]<<9; // Horizontal scroll table address - if ( pvid->reg[11]&2) htab+=est->DrawScanline<<1; // Offset by line - if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile + switch (pvid->reg[11]&3) { + case 1: htab += (est->DrawScanline<<1) & 0x0f; break; + case 2: htab += (est->DrawScanline<<1) & ~0x0f; break; // Offset by tile + case 3: htab += (est->DrawScanline<<1); break; // Offset by line + } htab+=plane_sh&1; // A or B // Get horizontal scroll value, will be masked later @@ -626,9 +630,9 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est if (!sh) { - short blank=-1; // The tile we know is blank + int blank=-1; // The tile we know is blank while ((code=*hc++)) { - if (!(code & 0x8000) || (short)code == blank) + if (!(code & 0x8000) || (unsigned short)code == blank) continue; // Get tile address/2: addr = (code & 0x7ff) << 4; @@ -636,7 +640,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { - blank = (short)code; + blank = (unsigned short)code; continue; } diff --git a/pico/draw2.c b/pico/draw2.c index 85e2b275..91069770 100644 --- a/pico/draw2.c +++ b/pico/draw2.c @@ -20,7 +20,7 @@ #define LINE_WIDTH 328 #endif -static unsigned char PicoDraw2FB_[(8+320) * (8+240+8)]; +static unsigned char PicoDraw2FB_[(8+320) * (8+240+8) + 8]; static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers static int HighCache2B[41*(TILE_ROWS+1)+1+1]; diff --git a/pico/draw_arm.S b/pico/draw_arm.S index fb6d0950..967bf6aa 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -342,11 +342,15 @@ DrawLayer: mov r4, r8, lsr #8 @ pvid->reg[13] mov r4, r4, lsl #10 @ htab=pvid->reg[13]<<9; (halfwords) - tst r7, #2 - addne r4, r4, r2, lsl #2 @ htab+=DrawScanline<<1; // Offset by line - tst r7, #1 - biceq r4, r4, #0x1f @ htab&=~0xf; // Offset by tile - add r4, r4, r0, lsl #1 @ htab+=plane + + ands r3, r7, #0x03 + beq 0f + cmp r3, #2 + mov r3, r2, lsl #2 @ htab+=DrawScanline<<1; // Offset by line + biceq r3, #0x1f @ htab&=~0xf; // Offset by tile + andlt r3, #0x1f + add r4, r4, r3 +0: add r4, r4, r0, lsl #1 @ htab+=plane bic r4, r4, #0x00ff0000 @ just in case ldrh r3, [lr, r4] @ r3=hscroll @@ -599,6 +603,7 @@ DrawLayer: tst r7, #0x8000 bne .DrawStrip_vs_hiprio + orr r7, r7, r10, lsl #24 @ code | (ty << 24) cmp r7, r9 beq .DrawStrip_vs_samecode @ we know stuff about this tile already -- 2.39.5