static int HighCacheB[41+1];\r
static int HighPreSpr[80*2+1]; // slightly preprocessed sprites\r
\r
+#define LF_PLANE_1 (1 << 0)\r
+#define LF_SH (1 << 1) // must be = 2\r
+#define LF_FORCE (1 << 2)\r
+\r
#define SPRL_HAVE_HI 0x80 // have hi priority sprites\r
#define SPRL_HAVE_LO 0x40 // *lo*\r
#define SPRL_MAY_HAVE_OP 0x20 // may have operator sprites on the line\r
\r
int rendstatus_old;\r
int rendlines;\r
-int PicoDrawMask = -1;\r
\r
static int skip_next_line=0;\r
\r
-//unsigned short ppt[] = { 0x0f11, 0x0ff1, 0x01f1, 0x011f, 0x01ff, 0x0f1f, 0x0f0e, 0x0e7c };\r
-\r
struct TileStrip\r
{\r
int nametab; // Position in VRAM of name table (for this tile line)\r
\r
\r
#define TileNormMaker(funcname,pix_func) \\r
-static int funcname(int sx,int addr,int pal) \\r
+static void funcname(int sx, unsigned int pack, int pal) \\r
{ \\r
- unsigned char *pd = Pico.est.HighCol+sx; \\r
- unsigned int pack=0; unsigned int t=0; \\r
- \\r
- pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \\r
- if (pack) \\r
- { \\r
- t=(pack&0x0000f000)>>12; pix_func(0); \\r
- t=(pack&0x00000f00)>> 8; pix_func(1); \\r
- t=(pack&0x000000f0)>> 4; pix_func(2); \\r
- t=(pack&0x0000000f) ; pix_func(3); \\r
- t=(pack&0xf0000000)>>28; pix_func(4); \\r
- t=(pack&0x0f000000)>>24; pix_func(5); \\r
- t=(pack&0x00f00000)>>20; pix_func(6); \\r
- t=(pack&0x000f0000)>>16; pix_func(7); \\r
- return 0; \\r
- } \\r
+ unsigned char *pd = Pico.est.HighCol + sx; \\r
+ unsigned int t; \\r
\\r
- return 1; /* Tile blank */ \\r
+ t = (pack&0x0000f000)>>12; pix_func(0); \\r
+ t = (pack&0x00000f00)>> 8; pix_func(1); \\r
+ t = (pack&0x000000f0)>> 4; pix_func(2); \\r
+ t = (pack&0x0000000f) ; pix_func(3); \\r
+ t = (pack&0xf0000000)>>28; pix_func(4); \\r
+ t = (pack&0x0f000000)>>24; pix_func(5); \\r
+ t = (pack&0x00f00000)>>20; pix_func(6); \\r
+ t = (pack&0x000f0000)>>16; pix_func(7); \\r
}\r
\r
-\r
#define TileFlipMaker(funcname,pix_func) \\r
-static int funcname(int sx,int addr,int pal) \\r
+static void funcname(int sx, unsigned int pack, int pal) \\r
{ \\r
- unsigned char *pd = Pico.est.HighCol+sx; \\r
- unsigned int pack=0; unsigned int t=0; \\r
- \\r
- pack=*(unsigned int *)(Pico.vram+addr); /* Get 8 pixels */ \\r
- if (pack) \\r
- { \\r
- t=(pack&0x000f0000)>>16; pix_func(0); \\r
- t=(pack&0x00f00000)>>20; pix_func(1); \\r
- t=(pack&0x0f000000)>>24; pix_func(2); \\r
- t=(pack&0xf0000000)>>28; pix_func(3); \\r
- t=(pack&0x0000000f) ; pix_func(4); \\r
- t=(pack&0x000000f0)>> 4; pix_func(5); \\r
- t=(pack&0x00000f00)>> 8; pix_func(6); \\r
- t=(pack&0x0000f000)>>12; pix_func(7); \\r
- return 0; \\r
- } \\r
+ unsigned char *pd = Pico.est.HighCol + sx; \\r
+ unsigned int t; \\r
\\r
- return 1; /* Tile blank */ \\r
+ t = (pack&0x000f0000)>>16; pix_func(0); \\r
+ t = (pack&0x00f00000)>>20; pix_func(1); \\r
+ t = (pack&0x0f000000)>>24; pix_func(2); \\r
+ t = (pack&0xf0000000)>>28; pix_func(3); \\r
+ t = (pack&0x0000000f) ; pix_func(4); \\r
+ t = (pack&0x000000f0)>> 4; pix_func(5); \\r
+ t = (pack&0x00000f00)>> 8; pix_func(6); \\r
+ t = (pack&0x0000f000)>>12; pix_func(7); \\r
}\r
\r
\r
-#ifdef _ASM_DRAW_C_AMIPS\r
-int TileNorm(int sx,int addr,int pal);\r
-int TileFlip(int sx,int addr,int pal);\r
-#else\r
-\r
#define pix_just_write(x) \\r
if (t) pd[x]=pal|t\r
\r
TileNormMaker(TileNorm,pix_just_write)\r
TileFlipMaker(TileFlip,pix_just_write)\r
\r
-#endif\r
-\r
#ifndef _ASM_DRAW_C\r
\r
// draw a sprite pixel, process operator colors\r
TileNormMaker(TileNormAS_onlymark, pix_sh_as_onlymark)\r
TileFlipMaker(TileFlipAS_onlymark, pix_sh_as_onlymark)\r
\r
+// mark pixel as sprite pixel (AS)\r
+#define pix_and(x) \\r
+ pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t))\r
+\r
+TileNormMaker(TileNorm_and, pix_and)\r
+TileFlipMaker(TileFlip_and, pix_and)\r
\r
// --------------------------------------------\r
\r
#ifndef _ASM_DRAW_C\r
-static void DrawStrip(struct TileStrip *ts, int plane_sh, int cellskip)\r
+static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip)\r
{\r
int tilex,dx,ty,code=0,addr=0,cells;\r
int oldcode=-1,blank=-1; // The tile we know is blank\r
int pal=0,sh;\r
\r
// Draw tiles across screen:\r
- sh=(plane_sh<<5)&0x40;\r
+ sh = (lflags & LF_SH) << 5; // 0x40\r
tilex=((-ts->hscroll)>>3)+cellskip;\r
ty=(ts->line&7)<<1; // Y-Offset into tile\r
dx=((ts->hscroll-1)&7)+1;\r
if(dx != 8) cells++; // have hscroll, need to draw 1 cell more\r
dx+=cellskip<<3;\r
\r
- for (; cells > 0; dx+=8,tilex++,cells--)\r
+ for (; cells > 0; dx+=8, tilex++, cells--)\r
{\r
- int zero=0;\r
+ unsigned int pack;\r
\r
- code=Pico.vram[ts->nametab+(tilex&ts->xmask)];\r
- if (code==blank) continue;\r
- if (code>>15) { // high priority tile\r
+ code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];\r
+ if (code == blank)\r
+ continue;\r
+ if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile\r
int cval = code | (dx<<16) | (ty<<25);\r
if(code&0x1000) cval^=7<<26;\r
*ts->hc++ = cval; // cache it\r
pal=((code>>9)&0x30)|sh;\r
}\r
\r
- if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
- else zero=TileNorm(dx,addr,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack) {\r
+ blank = code;\r
+ continue;\r
+ }\r
\r
- if (zero) blank=code; // We know this tile is blank now\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
\r
// terminate the cache list\r
}\r
\r
// this is messy\r
-void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)\r
+static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip)\r
{\r
int tilex,dx,code=0,addr=0,cell=0;\r
int oldcode=-1,blank=-1; // The tile we know is blank\r
// Draw tiles across screen:\r
tilex=(-ts->hscroll)>>3;\r
dx=((ts->hscroll-1)&7)+1;\r
- if(dx != 8) cell--; // have hscroll, start with negative cell\r
+ if (ts->hscroll & 0x0f) {\r
+ int adj = ((ts->hscroll ^ dx) >> 3) & 1;\r
+ cell -= adj + 1;\r
+ ts->cells -= adj;\r
+ }\r
cell+=cellskip;\r
tilex+=cellskip;\r
dx+=cellskip<<3;\r
\r
for (; cell < ts->cells; dx+=8,tilex++,cell++)\r
{\r
- int zero=0,nametabadd,ty;\r
+ int nametabadd, ty;\r
+ unsigned int pack;\r
\r
//if((cell&1)==0)\r
{\r
int line,vscroll;\r
- vscroll=Pico.vsram[(plane_sh&1)+(cell&~1)];\r
+ vscroll=PicoMem.vsram[(plane_sh&1)+(cell&~1)];\r
\r
// Find the line in the name table\r
line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask ..\r
ty=(line&7)<<1; // Y-Offset into tile\r
}\r
\r
- code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];\r
+ code=PicoMem.vram[ts->nametab+nametabadd+(tilex&ts->xmask)];\r
if (code==blank) continue;\r
if (code>>15) { // high priority tile\r
int cval = code | (dx<<16) | (ty<<25);\r
pal=((code>>9)&0x30)|((plane_sh<<5)&0x40);\r
}\r
\r
- if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
- else zero=TileNorm(dx,addr,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack) {\r
+ blank = code;\r
+ continue;\r
+ }\r
\r
- if (zero) blank=code; // We know this tile is blank now\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
\r
// terminate the cache list\r
\r
for (; cells; dx+=8,tilex++,cells--)\r
{\r
- int zero=0;\r
+ unsigned int pack;\r
\r
- code=Pico.vram[ts->nametab+(tilex&ts->xmask)];\r
+ code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)];\r
if (code==blank) continue;\r
if (code>>15) { // high priority tile\r
int cval = (code&0xfc00) | (dx<<16) | (ty<<25);\r
pal=((code>>9)&0x30);\r
}\r
\r
- if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
- else zero=TileNorm(dx,addr,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack) {\r
+ blank = code;\r
+ continue;\r
+ }\r
\r
- if (zero) blank=code; // We know this tile is blank now\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
\r
// terminate the cache list\r
\r
ts.xmask=(1<<shift[width])-1; // X Mask in tiles (0x1f-0x7f)\r
ymask=(height<<8)|0xff; // Y Mask in pixels\r
- if(width == 1) ymask&=0x1ff;\r
- else if(width>1) ymask =0x0ff;\r
+ switch (width) {\r
+ case 1: ymask &= 0x1ff; break;\r
+ case 2: ymask = 0x007; break;\r
+ case 3: ymask = 0x0ff; break;\r
+ }\r
\r
// Find name table:\r
if (plane_sh&1) ts.nametab=(pvid->reg[4]&0x07)<<12; // B\r
htab+=plane_sh&1; // A or B\r
\r
// Get horizontal scroll value, will be masked later\r
- ts.hscroll=Pico.vram[htab&0x7fff];\r
+ ts.hscroll = PicoMem.vram[htab & 0x7fff];\r
\r
if((pvid->reg[12]&6) == 6) {\r
// interlace mode 2\r
- vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
+ vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value\r
\r
// Find the line in the name table\r
ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1);\r
ts.line=ymask|(shift[width]<<24); // save some stuff instead of line\r
DrawStripVSRam(&ts, plane_sh, cellskip);\r
} else {\r
- vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
+ vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value\r
\r
// Find the line in the name table\r
ts.line=(vscroll+est->DrawScanline)&ymask;\r
\r
if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) {\r
// check the first tile code\r
- code=Pico.vram[nametab+tilex];\r
+ code = PicoMem.vram[nametab + tilex];\r
// if the whole window uses same priority (what is often the case), we may be able to skip this field\r
if ((code>>15) != prio) return;\r
}\r
{\r
for (; tilex < tend; tilex++)\r
{\r
- int addr=0,zero=0;\r
+ unsigned int pack;\r
+ int dx, addr;\r
int pal;\r
\r
- code=Pico.vram[nametab+tilex];\r
+ code = PicoMem.vram[nametab + tilex];\r
if (code==blank) continue;\r
if ((code>>15) != prio) {\r
est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
continue;\r
}\r
\r
- pal=((code>>9)&0x30);\r
-\r
// Get tile address/2:\r
addr=(code&0x7ff)<<4;\r
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip\r
\r
- if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal);\r
- else zero=TileNorm(8+(tilex<<3),addr,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack) {\r
+ blank = code;\r
+ continue;\r
+ }\r
\r
- if (zero) blank=code; // We know this tile is blank now\r
+ pal = ((code >> 9) & 0x30);\r
+ dx = 8 + (tilex << 3);\r
+\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
}\r
else\r
{\r
for (; tilex < tend; tilex++)\r
{\r
- int addr=0,zero=0;\r
+ unsigned int pack;\r
+ int dx, addr;\r
int pal;\r
\r
- code=Pico.vram[nametab+tilex];\r
+ code = PicoMem.vram[nametab + tilex];\r
if(code==blank) continue;\r
if((code>>15) != prio) {\r
est->rendstatus |= PDRAW_WND_DIFF_PRIO;\r
addr=(code&0x7ff)<<4;\r
if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip\r
\r
- if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal);\r
- else zero=TileNorm(8+(tilex<<3),addr,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack) {\r
+ blank = code;\r
+ continue;\r
+ }\r
+\r
+ dx = 8 + (tilex << 3);\r
\r
- if (zero) blank=code; // We know this tile is blank now\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
}\r
}\r
static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est)\r
{\r
int code, addr, dx;\r
+ unsigned int pack;\r
int pal;\r
\r
// *ts->hc++ = code | (dx<<16) | (ty<<25); // cache it\r
{\r
short blank=-1; // The tile we know is blank\r
while ((code=*hc++)) {\r
- int zero;\r
- if((short)code == blank) continue;\r
+ if (!(code & 0x8000) || (short)code == blank)\r
+ continue;\r
// Get tile address/2:\r
- addr=(code&0x7ff)<<4;\r
- addr+=(unsigned int)code>>25; // y offset into tile\r
- dx=(code>>16)&0x1ff;\r
+ addr = (code & 0x7ff) << 4;\r
+ addr += code >> 25; // y offset into tile\r
\r
- pal=((code>>9)&0x30);\r
- if (rlim-dx < 0) goto last_cut_tile;\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack) {\r
+ blank = (short)code;\r
+ continue;\r
+ }\r
\r
- if (code&0x0800) zero=TileFlip(dx,addr,pal);\r
- else zero=TileNorm(dx,addr,pal);\r
+ dx = (code >> 16) & 0x1ff;\r
+ pal = ((code >> 9) & 0x30);\r
+ if (rlim-dx < 0)\r
+ goto last_cut_tile;\r
\r
- if (zero) blank=(short)code;\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
}\r
else\r
{\r
while ((code=*hc++)) {\r
unsigned char *zb;\r
+\r
// Get tile address/2:\r
addr=(code&0x7ff)<<4;\r
addr+=(unsigned int)code>>25; // y offset into tile\r
*zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;\r
*zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf;\r
\r
- pal=((code>>9)&0x30);\r
- if (rlim-dx < 0) goto last_cut_tile;\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+ if (!pack)\r
+ continue;\r
+\r
+ pal = ((code >> 9) & 0x30);\r
+ if (rlim - dx < 0)\r
+ goto last_cut_tile;\r
\r
- if (code&0x0800) TileFlip(dx,addr,pal);\r
- else TileNorm(dx,addr,pal);\r
+ if (code & 0x0800) TileFlip(dx, pack, pal);\r
+ else TileNorm(dx, pack, pal);\r
}\r
}\r
return;\r
\r
last_cut_tile:\r
+ // for vertical window cutoff\r
{\r
- unsigned int t, pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels\r
- unsigned char *pd = est->HighCol+dx;\r
- if (!pack) return;\r
+ unsigned char *pd = est->HighCol + dx;\r
+ unsigned int t;\r
+\r
if (code&0x0800)\r
{\r
switch (rlim-dx+8)\r
int pal;\r
int tile=0,delta=0;\r
int sx, sy;\r
- int (*fTileFunc)(int sx,int addr,int pal);\r
+ void (*fTileFunc)(int sx, unsigned int pack, int pal);\r
\r
// parse the sprite data\r
sy=sprite[0];\r
\r
for (; width; width--,sx+=8,tile+=delta)\r
{\r
+ unsigned int pack;\r
+\r
if(sx<=0) continue;\r
if(sx>=328) break; // Offscreen\r
\r
- tile&=0x7fff; // Clip tile address\r
- fTileFunc(sx,tile,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+ fTileFunc(sx, pack, pal);\r
}\r
}\r
#endif\r
\r
+static NOINLINE void DrawTilesFromCacheForced(const int *hc)\r
+{\r
+ int code, addr, dx;\r
+ unsigned int pack;\r
+ int pal;\r
+\r
+ // *ts->hc++ = code | (dx<<16) | (ty<<25);\r
+ while ((code = *hc++)) {\r
+ // Get tile address/2:\r
+ addr = (code & 0x7ff) << 4;\r
+ addr += (code >> 25) & 0x0e; // y offset into tile\r
+\r
+ dx = (code >> 16) & 0x1ff;\r
+ pal = ((code >> 9) & 0x30);\r
+ pack = *(unsigned int *)(PicoMem.vram + addr);\r
+\r
+ if (code & 0x0800) TileFlip_and(dx, pack, pal);\r
+ else TileNorm_and(dx, pack, pal);\r
+ }\r
+}\r
+\r
static void DrawSpriteInterlace(unsigned int *sprite)\r
{\r
int width=0,height=0;\r
\r
for (; width; width--,sx+=8,tile+=delta)\r
{\r
+ unsigned int pack;\r
+\r
if(sx<=0) continue;\r
if(sx>=328) break; // Offscreen\r
\r
- tile&=0x7fff; // Clip tile address\r
- if (code&0x0800) TileFlip(sx,tile,pal);\r
- else TileNorm(sx,tile,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+ if (code & 0x0800) TileFlip(sx, pack, pal);\r
+ else TileNorm(sx, pack, pal);\r
}\r
}\r
\r
\r
-static void DrawAllSpritesInterlace(int pri, int sh)\r
+static NOINLINE void DrawAllSpritesInterlace(int pri, int sh)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
int i,u,table,link=0,sline=Pico.est.DrawScanline<<1;\r
unsigned int *sprite;\r
int code, sx, sy, height;\r
\r
- sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+ sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
\r
// get sprite info\r
code = sprite[0];\r
*/\r
static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est)\r
{\r
- int (*fTileFunc)(int sx,int addr,int pal);\r
+ void (*fTileFunc)(int sx, unsigned int pack, int pal);\r
unsigned char *p;\r
int cnt;\r
\r
\r
for (; width; width--,sx+=8,tile+=delta)\r
{\r
+ unsigned int pack;\r
+\r
if(sx<=0) continue;\r
if(sx>=328) break; // Offscreen\r
\r
- tile&=0x7fff; // Clip tile address\r
- fTileFunc(sx,tile,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+ fTileFunc(sx, pack, pal);\r
}\r
}\r
}\r
\r
static void DrawSpritesHiAS(unsigned char *sprited, int sh)\r
{\r
- int (*fTileFunc)(int sx,int addr,int pal);\r
+ void (*fTileFunc)(int sx, unsigned int pack, int pal);\r
unsigned char *p;\r
int entry, cnt, sh_cnt = 0;\r
\r
pal |= 0x80;\r
for (; width; width--,sx+=8,tile+=delta)\r
{\r
+ unsigned int pack;\r
+\r
if(sx<=0) continue;\r
if(sx>=328) break; // Offscreen\r
\r
- tile&=0x7fff; // Clip tile address\r
- fTileFunc(sx,tile,pal);\r
+ pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff));\r
+ fTileFunc(sx, pack, pal);\r
}\r
}\r
\r
// Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size\r
// Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
\r
-void PrepareSprites(int full)\r
+static NOINLINE void PrepareSprites(int full)\r
{\r
const struct PicoVideo *pvid=&Pico.video;\r
const struct PicoEState *est=&Pico.est;\r
unsigned int *sprite;\r
int code2, sx, sy, height;\r
\r
- sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+ sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
\r
// parse sprite info\r
code2 = sprite[1];\r
unsigned int *sprite;\r
int code, code2, sx, sy, hv, height, width;\r
\r
- sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
+ sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite\r
\r
// parse sprite info\r
code = sprite[0];\r
static void DrawAllSprites(unsigned char *sprited, int prio, int sh,\r
struct PicoEState *est)\r
{\r
- int rs = est->rendstatus;\r
unsigned char *p;\r
int cnt;\r
\r
- if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
- //elprintf(EL_STATUS, "PrepareSprites(%i)", (rs>>4)&1);\r
- PrepareSprites(rs & PDRAW_DIRTY_SPRITES);\r
- est->rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
- }\r
-\r
cnt = sprited[0] & 0x7f;\r
if (cnt == 0) return;\r
\r
\r
Pico.m.dirtyPal = 0;\r
\r
- spal = (void *)Pico.cram;\r
+ spal = (void *)PicoMem.cram;\r
dpal = (void *)est->HighPal;\r
\r
for (i = 0; i < 0x40 / 2; i++) {\r
rs |= PDRAW_SONIC_MODE;\r
est->rendstatus = rs;\r
if (dirty_count == 3) {\r
- blockcpy(est->HighPal, Pico.cram, 0x40*2);\r
+ blockcpy(est->HighPal, PicoMem.cram, 0x40*2);\r
} else if (dirty_count == 11) {\r
- blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2);\r
+ blockcpy(est->HighPal+0x40, PicoMem.cram, 0x40*2);\r
}\r
}\r
\r
struct PicoEState *est=&Pico.est;\r
unsigned char *sprited = &HighLnSpr[est->DrawScanline][0];\r
struct PicoVideo *pvid=&Pico.video;\r
- int win=0,edge=0,hvwind=0;\r
- int maxw,maxcells;\r
+ int win=0, edge=0, hvwind=0, lflags;\r
+ int maxw, maxcells;\r
+\r
+ if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
+ // elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1);\r
+ PrepareSprites(est->rendstatus & PDRAW_DIRTY_SPRITES);\r
+ est->rendstatus &= ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
+ }\r
\r
est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);\r
\r
}\r
\r
/* - layer B low - */\r
- if (PicoDrawMask & PDRAW_LAYERB_ON)\r
- DrawLayer(1|(sh<<1), HighCacheB, 0, maxcells, est);\r
+ if (!(pvid->debug_p & PVD_KILL_B)) {\r
+ lflags = LF_PLANE_1 | (sh << 1);\r
+ if (pvid->debug_p & PVD_FORCE_B)\r
+ lflags |= LF_FORCE;\r
+ DrawLayer(lflags, HighCacheB, 0, maxcells, est);\r
+ }\r
/* - layer A low - */\r
- if (!(PicoDrawMask & PDRAW_LAYERA_ON));\r
+ lflags = 0 | (sh << 1);\r
+ if (pvid->debug_p & PVD_FORCE_A)\r
+ lflags |= LF_FORCE;\r
+ if (pvid->debug_p & PVD_KILL_A)\r
+ ;\r
else if (hvwind == 1)\r
DrawWindow(0, maxcells>>1, 0, sh, est);\r
else if (hvwind == 2) {\r
- DrawLayer(0|(sh<<1), HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est);\r
- DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);\r
- } else\r
- DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est);\r
+ DrawLayer(lflags, HighCacheA, (win&0x80) ? 0 : edge<<1, (win&0x80) ? edge<<1 : maxcells, est);\r
+ DrawWindow( (win&0x80) ? edge : 0, (win&0x80) ? maxcells>>1 : edge, 0, sh, est);\r
+ }\r
+ else\r
+ DrawLayer(lflags, HighCacheA, 0, maxcells, est);\r
/* - sprites low - */\r
- if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON));\r
- else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
+ if (pvid->debug_p & PVD_KILL_S_LO)\r
+ ;\r
+ else if (est->rendstatus & PDRAW_INTERLACE)\r
DrawAllSpritesInterlace(0, sh);\r
else if (sprited[1] & SPRL_HAVE_LO)\r
DrawAllSprites(sprited, 0, sh, est);\r
\r
/* - layer B hi - */\r
- if ((PicoDrawMask & PDRAW_LAYERB_ON) && HighCacheB[0])\r
+ if (!(pvid->debug_p & PVD_KILL_B) && HighCacheB[0])\r
DrawTilesFromCache(HighCacheB, sh, maxw, est);\r
/* - layer A hi - */\r
- if (!(PicoDrawMask & PDRAW_LAYERA_ON));\r
+ if (pvid->debug_p & PVD_KILL_A)\r
+ ;\r
else if (hvwind == 1)\r
DrawWindow(0, maxcells>>1, 1, sh, est);\r
else if (hvwind == 2) {\r
if (HighCacheA[0])\r
DrawTilesFromCache(HighCacheA, sh, maxw, est);\r
/* - sprites hi - */\r
- if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON));\r
- else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
+ if (pvid->debug_p & PVD_KILL_S_HI)\r
+ ;\r
+ else if (est->rendstatus & PDRAW_INTERLACE)\r
DrawAllSpritesInterlace(1, sh);\r
// have sprites without layer pri bit ontop of sprites with that bit\r
else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES))\r
else if (sprited[1] & SPRL_HAVE_HI)\r
DrawAllSprites(sprited, 1, 0, est);\r
\r
+ if (pvid->debug_p & PVD_FORCE_B)\r
+ DrawTilesFromCacheForced(HighCacheB);\r
+ else if (pvid->debug_p & PVD_FORCE_A)\r
+ DrawTilesFromCacheForced(HighCacheA);\r
+\r
#if 0\r
{\r
int *c, a, b;\r
return;\r
}\r
\r
+ if (Pico.video.debug_p & (PVD_FORCE_A | PVD_FORCE_B))\r
+ bgc = 0x3f;\r
+\r
// Draw screen:\r
BackFill(bgc, sh, &Pico.est);\r
if (Pico.video.reg[1]&0x40)\r
\r
pprof_start(draw);\r
\r
- if (rendlines != 240)\r
+ if (rendlines != 240) {\r
offs = 8;\r
+ if (to > 223)\r
+ to = 223;\r
+ }\r
\r
for (line = Pico.est.DrawScanline; line < to; line++)\r
- {\r
PicoLine(line, offs, sh, bgc);\r
- }\r
\r
// last line\r
if (line <= to)\r
{\r
DrawLineDestBase = dest;\r
DrawLineDestIncrement = increment;\r
- Pico.est.DrawLineDest = DrawLineDestBase + Pico.est.DrawScanline * increment;\r
+ Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment;\r
}\r
\r
void PicoDrawSetInternalBuf(void *dest, int increment)\r