some support for vdp debug reg

This commit is contained in:
notaz 2017-09-28 03:16:21 +03:00
parent 1a08dec0e0
commit e0bcb7a90d
11 changed files with 160 additions and 69 deletions

View file

@ -230,7 +230,7 @@ static void p32x_start_blank(void)
// XXX: no proper handling of 32col mode.. // XXX: no proper handling of 32col mode..
if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0 && // 32x not blanking if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0 && // 32x not blanking
(Pico.video.reg[12] & 1) && // 40col mode (Pico.video.reg[12] & 1) && // 40col mode
(PicoDrawMask & PDRAW_32X_ON)) (!(Pico.video.debug_p & PVD_KILL_32X)))
{ {
int md_bg = Pico.video.reg[7] & 0x3f; int md_bg = Pico.video.reg[7] & 0x3f;

View file

@ -96,7 +96,7 @@ void FinalizeLine32xRGB555(int sh, int line, struct PicoEState *est)
if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0 || // 32x blanking
// XXX: how is 32col mode hadled by real hardware? // XXX: how is 32col mode hadled by real hardware?
!(Pico.video.reg[12] & 1) || // 32col mode !(Pico.video.reg[12] & 1) || // 32col mode
!(PicoDrawMask & PDRAW_32X_ON)) (Pico.video.debug_p & PVD_KILL_32X))
{ {
return; return;
} }

View file

@ -233,6 +233,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
int table=0,u,link=0,*sprite=0,*fsprite,oldsprite[2]; int table=0,u,link=0,*sprite=0,*fsprite,oldsprite[2];
int x,y,max_sprites = 80, oldcol, oldreg; int x,y,max_sprites = 80, oldcol, oldreg;
unsigned char olddbg;
if (!(pvid->reg[12]&1)) if (!(pvid->reg[12]&1))
max_sprites = 64; max_sprites = 64;
@ -257,9 +258,10 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
fsprite[1] = (sprite[1] & ~0x01ff8000) | 0x800000; fsprite[1] = (sprite[1] & ~0x01ff8000) | 0x800000;
oldreg = pvid->reg[7]; oldreg = pvid->reg[7];
oldcol = Pico.cram[0]; oldcol = Pico.cram[0];
olddbg = pvid->debug_p;
pvid->reg[7] = 0; pvid->reg[7] = 0;
Pico.cram[0] = 0; Pico.cram[0] = 0;
PicoDrawMask = PDRAW_SPRITES_LOW_ON; pvid->debug_p = PVD_KILL_A | PVD_KILL_B;
PicoFrameFull(); PicoFrameFull();
for (y = 0; y < 8*4; y++) for (y = 0; y < 8*4; y++)
@ -274,7 +276,7 @@ void PDebugShowSprite(unsigned short *screen, int stride, int which)
fsprite[1] = oldsprite[1]; fsprite[1] = oldsprite[1];
pvid->reg[7] = oldreg; pvid->reg[7] = oldreg;
Pico.cram[0] = oldcol; Pico.cram[0] = oldcol;
PicoDrawMask = -1; pvid->debug_p = olddbg;
} }
#define dump_ram(ram,fname) \ #define dump_ram(ram,fname) \

View file

@ -46,6 +46,10 @@ static int HighCacheA[41+1]; // caches for high layers
static int HighCacheB[41+1]; static int HighCacheB[41+1];
static int HighPreSpr[80*2+1]; // slightly preprocessed sprites static int HighPreSpr[80*2+1]; // slightly preprocessed sprites
#define LF_PLANE_1 (1 << 0)
#define LF_SH (1 << 1) // must be = 2
#define LF_FORCE (1 << 2)
#define SPRL_HAVE_HI 0x80 // have hi priority sprites #define SPRL_HAVE_HI 0x80 // have hi priority sprites
#define SPRL_HAVE_LO 0x40 // *lo* #define SPRL_HAVE_LO 0x40 // *lo*
#define SPRL_MAY_HAVE_OP 0x20 // may have operator sprites on the line #define SPRL_MAY_HAVE_OP 0x20 // may have operator sprites on the line
@ -54,12 +58,9 @@ unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, til
int rendstatus_old; int rendstatus_old;
int rendlines; int rendlines;
int PicoDrawMask = -1;
static int skip_next_line=0; static int skip_next_line=0;
//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };
struct TileStrip struct TileStrip
{ {
int nametab; // Position in VRAM of name table (for this tile line) int nametab; // Position in VRAM of name table (for this tile line)
@ -192,18 +193,24 @@ TileFlipMaker(TileFlipAS_noop, pix_sh_as_noop)
TileNormMaker(TileNormAS_onlymark, pix_sh_as_onlymark) TileNormMaker(TileNormAS_onlymark, pix_sh_as_onlymark)
TileFlipMaker(TileFlipAS_onlymark, pix_sh_as_onlymark) TileFlipMaker(TileFlipAS_onlymark, pix_sh_as_onlymark)
// mark pixel as sprite pixel (AS)
#define pix_and(x) \
pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t))
TileNormMaker(TileNorm_and, pix_and)
TileFlipMaker(TileFlip_and, pix_and)
// -------------------------------------------- // --------------------------------------------
#ifndef _ASM_DRAW_C #ifndef _ASM_DRAW_C
static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip) static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)
{ {
int tilex,dx,ty,code=0,addr=0,cells; int tilex,dx,ty,code=0,addr=0,cells;
int oldcode=-1,blank=-1; // The tile we know is blank int oldcode=-1,blank=-1; // The tile we know is blank
int pal=0,sh; int pal=0,sh;
// Draw tiles across screen: // Draw tiles across screen:
sh=(plane_sh<<5)&0x40; sh = (lflags & LF_SH) << 5; // 0x40
tilex=((-ts->hscroll)>>3)+cellskip; tilex=((-ts->hscroll)>>3)+cellskip;
ty=(ts->line&7)<<1; // Y-Offset into tile ty=(ts->line&7)<<1; // Y-Offset into tile
dx=((ts->hscroll-1)&7)+1; dx=((ts->hscroll-1)&7)+1;
@ -211,13 +218,14 @@ static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)
if(dx != 8) cells++; // have hscroll, need to draw 1 cell more if(dx != 8) cells++; // have hscroll, need to draw 1 cell more
dx+=cellskip<<3; dx+=cellskip<<3;
for (; cells > 0; dx+=8,tilex++,cells--) for (; cells > 0; dx+=8, tilex++, cells--)
{ {
unsigned int pack; unsigned int pack;
code=Pico.vram[ts->nametab+(tilex&ts->xmask)]; code = Pico.vram[ts->nametab + (tilex & ts->xmask)];
if (code==blank) continue; if (code == blank)
if (code>>15) { // high priority tile continue;
if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile
int cval = code | (dx<<16) | (ty<<25); int cval = code | (dx<<16) | (ty<<25);
if(code&0x1000) cval^=7<<26; if(code&0x1000) cval^=7<<26;
*ts->hc++ = cval; // cache it *ts->hc++ = cval; // cache it
@ -580,10 +588,11 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est
{ {
short blank=-1; // The tile we know is blank short blank=-1; // The tile we know is blank
while ((code=*hc++)) { while ((code=*hc++)) {
if((short)code == blank) continue; if (!(code & 0x8000) || (short)code == blank)
continue;
// Get tile address/2: // Get tile address/2:
addr=(code&0x7ff)<<4; addr = (code & 0x7ff) << 4;
addr+=(unsigned int)code>>25; // y offset into tile addr += code >> 25; // y offset into tile
pack = *(unsigned int *)(Pico.vram + addr); pack = *(unsigned int *)(Pico.vram + addr);
if (!pack) { if (!pack) {
@ -721,6 +730,27 @@ static void DrawSprite(int *sprite, int sh)
} }
#endif #endif
static NOINLINE void DrawTilesFromCacheForced(const int *hc)
{
int code, addr, dx;
unsigned int pack;
int pal;
// *ts->hc++ = code | (dx<<16) | (ty<<25);
while ((code = *hc++)) {
// Get tile address/2:
addr = (code & 0x7ff) << 4;
addr += (code >> 25) & 0x0e; // y offset into tile
dx = (code >> 16) & 0x1ff;
pal = ((code >> 9) & 0x30);
pack = *(unsigned int *)(Pico.vram + addr);
if (code & 0x0800) TileFlip_and(dx, pack, pal);
else TileNorm_and(dx, pack, pal);
}
}
static void DrawSpriteInterlace(unsigned int *sprite) static void DrawSpriteInterlace(unsigned int *sprite)
{ {
int width=0,height=0; int width=0,height=0;
@ -767,7 +797,7 @@ static void DrawSpriteInterlace(unsigned int *sprite)
} }
static void DrawAllSpritesInterlace(int pri, int sh) static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)
{ {
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
int i,u,table,link=0,sline=Pico.est.DrawScanline<<1; int i,u,table,link=0,sline=Pico.est.DrawScanline<<1;
@ -1312,8 +1342,8 @@ static int DrawDisplay(int sh)
struct PicoEState *est=&Pico.est; struct PicoEState *est=&Pico.est;
unsigned char *sprited = &HighLnSpr[est->DrawScanline][0]; unsigned char *sprited = &HighLnSpr[est->DrawScanline][0];
struct PicoVideo *pvid=&Pico.video; struct PicoVideo *pvid=&Pico.video;
int win=0,edge=0,hvwind=0; int win=0, edge=0, hvwind=0, lflags;
int maxw,maxcells; int maxw, maxcells;
if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) { if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {
// elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1); // elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1);
@ -1351,29 +1381,40 @@ static int DrawDisplay(int sh)
} }
/* - layer B low - */ /* - layer B low - */
if (PicoDrawMask & PDRAW_LAYERB_ON) if (!(pvid->debug_p & PVD_KILL_B)) {
DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells, est); lflags = LF_PLANE_1 | (sh << 1);
if (pvid->debug_p & PVD_FORCE_B)
lflags |= LF_FORCE;
DrawLayer(lflags, HighCacheB, 0, maxcells, est);
}
/* - layer A low - */ /* - layer A low - */
if (!(PicoDrawMask & PDRAW_LAYERA_ON)); lflags = 0 | (sh << 1);
if (pvid->debug_p & PVD_FORCE_A)
lflags |= LF_FORCE;
if (pvid->debug_p & PVD_KILL_A)
;
else if (hvwind == 1) else if (hvwind == 1)
DrawWindow(0, maxcells>>1, 0, sh, est); DrawWindow(0, maxcells>>1, 0, sh, est);
else if (hvwind == 2) { else if (hvwind == 2) {
DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est); DrawLayer(lflags, HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est);
DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est); DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);
} else }
DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est); else
DrawLayer(lflags, HighCacheA, 0, maxcells, est);
/* - sprites low - */ /* - sprites low - */
if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON)); if (pvid->debug_p & PVD_KILL_S_LO)
;
else if (est->rendstatus & PDRAW_INTERLACE) else if (est->rendstatus & PDRAW_INTERLACE)
DrawAllSpritesInterlace(0, sh); DrawAllSpritesInterlace(0, sh);
else if (sprited[1] & SPRL_HAVE_LO) else if (sprited[1] & SPRL_HAVE_LO)
DrawAllSprites(sprited, 0, sh, est); DrawAllSprites(sprited, 0, sh, est);
/* - layer B hi - */ /* - layer B hi - */
if ((PicoDrawMask & PDRAW_LAYERB_ON) && HighCacheB[0]) if (!(pvid->debug_p & PVD_KILL_B) && HighCacheB[0])
DrawTilesFromCache(HighCacheB, sh, maxw, est); DrawTilesFromCache(HighCacheB, sh, maxw, est);
/* - layer A hi - */ /* - layer A hi - */
if (!(PicoDrawMask & PDRAW_LAYERA_ON)); if (pvid->debug_p & PVD_KILL_A)
;
else if (hvwind == 1) else if (hvwind == 1)
DrawWindow(0, maxcells>>1, 1, sh, est); DrawWindow(0, maxcells>>1, 1, sh, est);
else if (hvwind == 2) { else if (hvwind == 2) {
@ -1384,7 +1425,8 @@ static int DrawDisplay(int sh)
if (HighCacheA[0]) if (HighCacheA[0])
DrawTilesFromCache(HighCacheA, sh, maxw, est); DrawTilesFromCache(HighCacheA, sh, maxw, est);
/* - sprites hi - */ /* - sprites hi - */
if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON)); if (pvid->debug_p & PVD_KILL_S_HI)
;
else if (est->rendstatus & PDRAW_INTERLACE) else if (est->rendstatus & PDRAW_INTERLACE)
DrawAllSpritesInterlace(1, sh); DrawAllSpritesInterlace(1, sh);
// have sprites without layer pri bit ontop of sprites with that bit // have sprites without layer pri bit ontop of sprites with that bit
@ -1395,6 +1437,11 @@ static int DrawDisplay(int sh)
else if (sprited[1] & SPRL_HAVE_HI) else if (sprited[1] & SPRL_HAVE_HI)
DrawAllSprites(sprited, 1, 0, est); DrawAllSprites(sprited, 1, 0, est);
if (pvid->debug_p & PVD_FORCE_B)
DrawTilesFromCacheForced(HighCacheB);
else if (pvid->debug_p & PVD_FORCE_A)
DrawTilesFromCacheForced(HighCacheA);
#if 0 #if 0
{ {
int *c, a, b; int *c, a, b;
@ -1480,6 +1527,9 @@ static void PicoLine(int line, int offs, int sh, int bgc)
return; return;
} }
if (Pico.video.debug_p & (PVD_FORCE_A | PVD_FORCE_B))
bgc = 0x3f;
// Draw screen: // Draw screen:
BackFill(bgc, sh, &Pico.est); BackFill(bgc, sh, &Pico.est);
if (Pico.video.reg[1]&0x40) if (Pico.video.reg[1]&0x40)

View file

@ -551,9 +551,9 @@ static void DrawDisplayFull(void)
if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; } if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; }
HighCache2A[1] = HighCache2B[1] = 0; HighCache2A[1] = HighCache2B[1] = 0;
if (PicoDrawMask & PDRAW_LAYERB_ON) if (!(pvid->debug_p & PVD_KILL_B))
DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est); DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW, est);
if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)
{ {
case 4: case 4:
// fullscreen window // fullscreen window
@ -579,12 +579,12 @@ static void DrawDisplayFull(void)
DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est); DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW, est);
break; break;
} }
if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) if (!(pvid->debug_p & PVD_KILL_S_LO))
DrawAllSpritesFull(0, maxw); DrawAllSpritesFull(0, maxw);
if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est); if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B, est);
if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est); if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A, est);
if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) if (!(pvid->debug_p & PVD_KILL_A)) switch (hvwin)
{ {
case 4: case 4:
// fullscreen window // fullscreen window
@ -603,7 +603,7 @@ static void DrawDisplayFull(void)
DrawWindowFull(winstart, winend, 1, est); DrawWindowFull(winstart, winend, 1, est);
break; break;
} }
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) if (!(pvid->debug_p & PVD_KILL_S_HI))
DrawAllSpritesFull(1, maxw); DrawAllSpritesFull(1, maxw);
} }

View file

@ -278,7 +278,7 @@
@ int cells; // 0x14 @ int cells; // 0x14
@ }; @ };
@ void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, @ void DrawLayer(int lflags, int *hcache, int cellskip, int maxcells,
@ struct PicoEState *est) @ struct PicoEState *est)
.global DrawLayer .global DrawLayer
@ -293,8 +293,8 @@ DrawLayer:
ldrb r7, [r11, #16] @ ??vv??hh ldrb r7, [r11, #16] @ ??vv??hh
mov r6, r1 @ hcache mov r6, r1 @ hcache
orr r9, r3, r0, lsl #30 orr r9, r3, r0, lsl #29 @ r9=force[31]|sh[30]|plane[29]
orr r9, r9, r2, lsl #8 @ r9=sh[31]|cellskip[15:8]|maxcells[7:0] (tmp) orr r9, r9, r2, lsl #8 @ |cellskip[15:8]|maxcells[7:0] (tmp)
mov r1, r7, lsl #4 mov r1, r7, lsl #4
orr r1, r1, #0x00ff orr r1, r1, #0x00ff
@ -375,10 +375,11 @@ DrawLayer:
and r1, r1, #7 and r1, r1, #7
add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1 add r7, r1, #1 @ r7=dx=((ts->hscroll-1)&7)+1
tst r9, #1<<31 movs r3, r9, lsl #1 @ (force[31]|sh[30]) << 1
mov r3, #0 mov r3, #0
orrne r10,r10, #1<<23 @ r10=(cells<<24|sh<<23|hi_not_empty<<22|had_output<<21|ty) orrmi r10,r10, #1<<23 @ r10=cells[31:24]|sh[23]|hi_not_empty[22]
movne r3, #0x40 @ default to shadowed pal on sh mode orrcs r10,r10, #1<<20 @ |had_output[21]|force[20]|ty[15:0]
movmi r3, #0x40 @ default to shadowed pal on sh mode
cmp r7, #8 cmp r7, #8
addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll addne r10,r10, #0x01000000 @ we will loop cells+1 times if there is scroll
@ -413,6 +414,7 @@ DrawLayer:
add r8, r8, #1 add r8, r8, #1
tst r7, #0x8000 tst r7, #0x8000
tsteq r10, #1<<20 @ force?
bne .DrawStrip_hiprio bne .DrawStrip_hiprio
cmp r7, r9 cmp r7, r9
@ -480,7 +482,7 @@ DrawLayer:
orr r10, r10, #1<<22 orr r10, r10, #1<<22
.DrawStrip_hiprio: .DrawStrip_hiprio:
tst r10, #0x00c00000 tst r10, #0x00d00000 @ sh[23]|hi_not_empty[22]|force[20]
beq .DrawStrip_hiprio_maybempt beq .DrawStrip_hiprio_maybempt
sub r0, r1, r11 sub r0, r1, r11
orr r7, r7, r0, lsl #16 orr r7, r7, r0, lsl #16
@ -774,7 +776,8 @@ DrawTilesFromCache:
bic r4, r1, #0xfe00 bic r4, r1, #0xfe00
add r1, r11, r4 @ r1=pdest add r1, r11, r4 @ r1=pdest
mov r7, r6, lsl #16 movs r7, r6, lsl #16
bpl .dtfc_loop @ !(code & 0x8000)
cmp r5, r7, lsr #16 cmp r5, r7, lsr #16
beq .dtfc_samecode @ if (code==prevcode) beq .dtfc_samecode @ if (code==prevcode)

View file

@ -179,15 +179,15 @@ static void DrawDisplayM4(int scanline)
dx += cellskip << 3; dx += cellskip << 3;
// low priority tiles // low priority tiles
if (PicoDrawMask & PDRAW_LAYERB_ON) if (!(pv->debug_p & PVD_KILL_B))
draw_strip(nametab, dx, cells, tilex | 0x0000 | (ty << 16)); draw_strip(nametab, dx, cells, tilex | 0x0000 | (ty << 16));
// sprites // sprites
if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) if (!(pv->debug_p & PVD_KILL_S_LO))
draw_sprites(scanline); draw_sprites(scanline);
// high priority tiles (use virtual layer switch just for fun) // high priority tiles (use virtual layer switch just for fun)
if (PicoDrawMask & PDRAW_LAYERA_ON) if (!(pv->debug_p & PVD_KILL_A))
draw_strip(nametab, dx, cells, tilex | 0x1000 | (ty << 16)); draw_strip(nametab, dx, cells, tilex | 0x1000 | (ty << 16));
if (pv->reg[0] & 0x20) if (pv->reg[0] & 0x20)

View file

@ -176,12 +176,6 @@ void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned in
void vidConvCpyRGB565(void *to, void *from, int pixels); void vidConvCpyRGB565(void *to, void *from, int pixels);
#endif #endif
void PicoDoHighPal555(int sh, int line, struct PicoEState *est); void PicoDoHighPal555(int sh, int line, struct PicoEState *est);
extern int PicoDrawMask;
#define PDRAW_LAYERB_ON (1<<2)
#define PDRAW_LAYERA_ON (1<<3)
#define PDRAW_SPRITES_LOW_ON (1<<4)
#define PDRAW_SPRITES_HI_ON (1<<7)
#define PDRAW_32X_ON (1<<8)
// internals // internals
#define PDRAW_SPRITES_MOVED (1<<0) // (asm) #define PDRAW_SPRITES_MOVED (1<<0) // (asm)
#define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority

View file

@ -281,6 +281,15 @@ extern SH2 sh2s[2];
#define OSC_NTSC 53693100 #define OSC_NTSC 53693100
#define OSC_PAL 53203424 #define OSC_PAL 53203424
#define PVD_KILL_A (1 << 0)
#define PVD_KILL_B (1 << 1)
#define PVD_KILL_S_LO (1 << 2)
#define PVD_KILL_S_HI (1 << 3)
#define PVD_KILL_32X (1 << 4)
#define PVD_FORCE_A (1 << 5)
#define PVD_FORCE_B (1 << 6)
#define PVD_FORCE_S (1 << 7)
struct PicoVideo struct PicoVideo
{ {
unsigned char reg[0x20]; unsigned char reg[0x20];
@ -292,8 +301,10 @@ struct PicoVideo
unsigned char pending_ints; // pending interrupts: ??VH???? unsigned char pending_ints; // pending interrupts: ??VH????
signed char lwrite_cnt; // VDP write count during active display line signed char lwrite_cnt; // VDP write count during active display line
unsigned short v_counter; // V-counter unsigned short v_counter; // V-counter
unsigned short debug; // raw debug register
unsigned char debug_p; // ... parsed: PVD_*
unsigned char addr_u; unsigned char addr_u;
unsigned char pad[0x0f]; unsigned char pad[0x0c];
}; };
struct PicoMisc struct PicoMisc

View file

@ -361,8 +361,9 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
// elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x", a, d); // elprintf(EL_STATUS, "PicoVideoWrite [%06x] %04x", a, d);
a&=0x1c; a&=0x1c;
if (a==0x00) // Data port 0 or 2 switch (a)
{ {
case 0x00: // Data port 0 or 2
// try avoiding the sync.. // try avoiding the sync..
if (Pico.m.scanline < 224 && (pvid->reg[1]&0x40) && if (Pico.m.scanline < 224 && (pvid->reg[1]&0x40) &&
!(!pvid->pending && !(!pvid->pending &&
@ -392,11 +393,9 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
if ((pvid->command&0x80) && (pvid->reg[1]&0x10) && (pvid->reg[0x17]>>6)==2) if ((pvid->command&0x80) && (pvid->reg[1]&0x10) && (pvid->reg[0x17]>>6)==2)
DmaFill(d); DmaFill(d);
return; break;
}
if (a==0x04) // Control (command) port 4 or 6 case 0x04: // Control (command) port 4 or 6
{
if (pvid->pending) if (pvid->pending)
{ {
// Low word of command: // Low word of command:
@ -473,6 +472,35 @@ update_irq:
pvid->pending=1; pvid->pending=1;
} }
} }
break;
// case 0x08: // 08 0a - HV counter - lock up
// case 0x0c: // 0c 0e - HV counter - lock up
// case 0x10: // 10 12 - PSG - handled by caller
// case 0x14: // 14 16 - PSG - handled by caller
// case 0x18: // 18 1a - no effect?
case 0x1c: // 1c 1e - debug
pvid->debug = d;
pvid->debug_p = 0;
if (d & (1 << 6)) {
pvid->debug_p |= PVD_KILL_A | PVD_KILL_B;
pvid->debug_p |= PVD_KILL_S_LO | PVD_KILL_S_HI;
}
switch ((d >> 7) & 3) {
case 1:
pvid->debug_p &= ~(PVD_KILL_S_LO | PVD_KILL_S_HI);
pvid->debug_p |= PVD_FORCE_S;
break;
case 2:
pvid->debug_p &= ~PVD_KILL_A;
pvid->debug_p |= PVD_FORCE_A;
break;
case 3:
pvid->debug_p &= ~PVD_KILL_B;
pvid->debug_p |= PVD_FORCE_B;
break;
}
break;
} }
} }

View file

@ -14,7 +14,7 @@
#include "input_pico.h" #include "input_pico.h"
#include "version.h" #include "version.h"
#include <pico/pico.h> #include <pico/pico_int.h>
#include <pico/patch.h> #include <pico/patch.h>
#ifdef PANDORA #ifdef PANDORA
@ -803,11 +803,13 @@ static void draw_text_debug(const char *str, int skip, int from)
static void draw_frame_debug(void) static void draw_frame_debug(void)
{ {
char layer_str[48] = "layers: "; char layer_str[48] = "layers: ";
if (PicoDrawMask & PDRAW_LAYERB_ON) memcpy(layer_str + 8, "B", 1); struct PicoVideo *pv = &Pico.video;
if (PicoDrawMask & PDRAW_LAYERA_ON) memcpy(layer_str + 10, "A", 1);
if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) memcpy(layer_str + 12, "spr_lo", 6); if (!(pv->debug_p & PVD_KILL_B)) memcpy(layer_str + 8, "B", 1);
if (PicoDrawMask & PDRAW_SPRITES_HI_ON) memcpy(layer_str + 19, "spr_hi", 6); if (!(pv->debug_p & PVD_KILL_A)) memcpy(layer_str + 10, "A", 1);
if (PicoDrawMask & PDRAW_32X_ON) memcpy(layer_str + 26, "32x", 4); if (!(pv->debug_p & PVD_KILL_S_LO)) memcpy(layer_str + 12, "spr_lo", 6);
if (!(pv->debug_p & PVD_KILL_S_HI)) memcpy(layer_str + 19, "spr_hi", 6);
if (!(pv->debug_p & PVD_KILL_32X)) memcpy(layer_str + 26, "32x", 4);
pemu_forced_frame(1, 0); pemu_forced_frame(1, 0);
make_bg(1); make_bg(1);
@ -818,6 +820,7 @@ static void draw_frame_debug(void)
static void debug_menu_loop(void) static void debug_menu_loop(void)
{ {
struct PicoVideo *pv = &Pico.video;
int inp, mode = 0; int inp, mode = 0;
int spr_offs = 0, dumped = 0; int spr_offs = 0, dumped = 0;
char *tmp; char *tmp;
@ -878,11 +881,11 @@ static void debug_menu_loop(void)
} }
break; break;
case 1: case 1:
if (inp & PBTN_LEFT) PicoDrawMask ^= PDRAW_LAYERB_ON; if (inp & PBTN_LEFT) pv->debug_p ^= PVD_KILL_B;
if (inp & PBTN_RIGHT) PicoDrawMask ^= PDRAW_LAYERA_ON; if (inp & PBTN_RIGHT) pv->debug_p ^= PVD_KILL_A;
if (inp & PBTN_DOWN) PicoDrawMask ^= PDRAW_SPRITES_LOW_ON; if (inp & PBTN_DOWN) pv->debug_p ^= PVD_KILL_S_LO;
if (inp & PBTN_UP) PicoDrawMask ^= PDRAW_SPRITES_HI_ON; if (inp & PBTN_UP) pv->debug_p ^= PVD_KILL_S_HI;
if (inp & PBTN_MA2) PicoDrawMask ^= PDRAW_32X_ON; if (inp & PBTN_MA2) pv->debug_p ^= PVD_KILL_32X;
if (inp & PBTN_MOK) { if (inp & PBTN_MOK) {
PsndOut = NULL; // just in case PsndOut = NULL; // just in case
PicoSkipFrame = 1; PicoSkipFrame = 1;