Skip to content

Commit

Permalink
core, fix H32 mode in fast renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
irixxxx committed Nov 23, 2023
1 parent 9215679 commit 96a972d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pico/draw2.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static void DrawWindowFull(int start, int end, int prio, struct PicoEState *est)
end = end<<16>>16;

// Find name table line:
if (pvid->reg[12]&1)
if (!(est->rendstatus & PDRAW_32_COLS))
{
nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode
nametab_step = 1<<6;
Expand Down Expand Up @@ -268,7 +268,7 @@ static void DrawLayerFull(int plane, u32 *hcache, int planestart, int planeend,
else nametab=(pvid->reg[4]&0x07)<<12; // B

scrpos = est->Draw2FB;
if (est->rendstatus & PDRAW_BORDER_32)
if ((~est->rendstatus & (PDRAW_BORDER_32|PDRAW_32_COLS)) == 0)
scrpos += 32;
scrpos+=8*est->Draw2Width*(planestart-scrstart);

Expand All @@ -280,7 +280,7 @@ static void DrawLayerFull(int plane, u32 *hcache, int planestart, int planeend,
// Get vertical scroll value:
vscroll=PicoMem.vsram[plane];//&0x1ff;
#if VSRAM
if (!(pvid->reg[12]&1) && (pvid->reg[11]&4)) // H32 + 2-cell mode
if ((est->rendstatus & PDRAW_32_COLS) && (pvid->reg[11]&4)) // H32 + 2-cell mode
vscroll=PicoMem.vsram[plane+0x20];//&0x1ff;
#endif
#if INTERLACE
Expand Down Expand Up @@ -371,7 +371,7 @@ static void DrawTilesFromCacheF(u32 *hc, struct PicoEState *est)
unsigned char *scrpos = est->Draw2FB, *pd = 0;
int scrstart = est->Draw2Start;

if (est->rendstatus & PDRAW_BORDER_32)
if ((~est->rendstatus & (PDRAW_BORDER_32|PDRAW_32_COLS)) == 0)
scrpos += 32;

while((code=*hc++)) {
Expand Down Expand Up @@ -446,7 +446,7 @@ static void DrawSpriteFull(u32 *sprite, struct PicoEState *est)
while(sy <= 0) { sy+=8; tile+=tdeltay; height--; }

scrpos = est->Draw2FB;
if (est->rendstatus&PDRAW_BORDER_32)
if ((~est->rendstatus & (PDRAW_BORDER_32|PDRAW_32_COLS)) == 0)
scrpos += 32;
scrpos+=sy*est->Draw2Width;

Expand Down Expand Up @@ -489,13 +489,13 @@ static void DrawAllSpritesFull(int prio, int maxwidth, struct PicoEState *est)
int i,u,link=0;
u32 *sprites[80]; // Sprites
int y_min=START_ROW*8, y_max=END_ROW*8; // for a simple sprite masking
int max_sprites = pvid->reg[12]&1 ? 80 : 64;
int max_sprites = !(est->rendstatus & PDRAW_32_COLS) ? 80 : 64;

if (est->rendstatus & PDRAW_30_ROWS)
y_min += 8, y_max += 8;

table=pvid->reg[5]&0x7f;
if (pvid->reg[12]&1) table&=0x7e; // Lowest bit 0 in 40-cell mode
if (!(est->rendstatus & PDRAW_32_COLS)) table&=0x7e; // Lowest bit 0 in 40-cell mode
table<<=8; // Get sprite table address/2

for (i = u = 0; u < max_sprites && link < max_sprites; u++)
Expand Down
4 changes: 4 additions & 0 deletions pico/draw2_arm.S
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ DrawLayerFull:
ldr r11, [r11, #OFS_EST_Draw2FB]
sub r4, r9, r4, lsl #24
tst r7, #PDRAW_BORDER_32 @ H32 border mode?
tstne r7, #PDRAW_32_COLS
addne r11, r11, #32
mov r4, r4, asr #24
mov r7, #328*8
Expand Down Expand Up @@ -609,6 +610,7 @@ DrawTilesFromCacheF:
ldr r11,[r1, #OFS_EST_Draw2Start]
ldr r2, [r0], #4 @ read y offset
tst r7, #PDRAW_BORDER_32 @ H32 border mode?
tstne r7, #PDRAW_32_COLS
addne r4, r4, #32
mov r7, #328
mla r2, r7, r2, r4
Expand Down Expand Up @@ -717,6 +719,7 @@ DrawWindowFull:
and r12, r12, #0xf800
mov r5, r5, lsl #6 @ nametab_step
tst r7, #PDRAW_BORDER_32
tstne r7, #PDRAW_32_COLS
addne r11, r11, #32 @ center screen in H32 mode

0: and r4, r0, #0xff
Expand Down Expand Up @@ -945,6 +948,7 @@ DrawSpriteFull:
ldr r2, [r1, #OFS_EST_Draw2Start]
ldr r10, [r1, #OFS_EST_PicoMem_vram]
tst r0, #PDRAW_BORDER_32 @ H32 border mode?
tstne r0, #PDRAW_32_COLS
addne r11, r11, #32
sub r12, r12, r2, lsl #3
mov r0, #328
Expand Down

0 comments on commit 96a972d

Please sign in to comment.