X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fdraw.c;h=680de3da03795081094a9142e7a47c5c169cc8ba;hb=ee3c39efd2cf51cd654b6240f6fb595673f10f45;hp=e2e4fb498b27b5570f66e2bee04b5547ba4a66c1;hpb=e42a47e2086e6512519dd86af420363498302f49;p=picodrive.git diff --git a/pico/draw.c b/pico/draw.c index e2e4fb4..680de3d 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -13,20 +13,19 @@ * - "sonic mode" for midline palette changes (8bit mode only) * - accurate sprites (AS) [+ s/h] * - * AS and s/h both use upper bits for both priority and shadow/hilight flags. + * s/h uses upper bits for both priority and shadow/hilight flags. * "sonic mode" is autodetected, shadow/hilight is enabled by emulated game. * AS is enabled by user and takes priority over "sonic mode". * * since renderer always draws line in 8bit mode, there are 2 spare bits: - * b \ mode: s/h as sonic - * 00 normal - pal index - * 01 shadow - pal index - * 10 hilight+op spr spr pal index - * 11 shadow +op spr - pal index + * b \ mode: s/h sonic + * 00 normal pal index + * 01 shadow pal index + * 10 hilight+op spr pal index + * 11 shadow +op spr pal index * * not handled properly: * - hilight op on shadow tile - * - AS + s/h (s/h sprite flag interferes with and cleared by AS code) */ #include "pico_int.h" @@ -95,11 +94,8 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat) #define blockcpy memcpy #endif - -#define TileNormMaker(funcname,pix_func) \ -static void funcname(int sx, unsigned int pack, int pal) \ +#define TileNormMaker_(pix_func) \ { \ - unsigned char *pd = Pico.est.HighCol + sx; \ unsigned int t; \ \ t = (pack&0x0000f000)>>12; pix_func(0); \ @@ -112,10 +108,8 @@ static void funcname(int sx, unsigned int pack, int pal) \ t = (pack&0x000f0000)>>16; pix_func(7); \ } -#define TileFlipMaker(funcname,pix_func) \ -static void funcname(int sx, unsigned int pack, int pal) \ +#define TileFlipMaker_(pix_func) \ { \ - unsigned char *pd = Pico.est.HighCol + sx; \ unsigned int t; \ \ t = (pack&0x000f0000)>>16; pix_func(0); \ @@ -128,11 +122,21 @@ static void funcname(int sx, unsigned int pack, int pal) \ t = (pack&0x0000f000)>>12; pix_func(7); \ } +#define TileNormMaker(funcname, pix_func) \ +static void funcname(unsigned char *pd, unsigned int pack, int pal) \ +TileNormMaker_(pix_func) -#ifdef _ASM_DRAW_C_AMIPS -int TileNorm(int sx, unsigned int pack, int pal); -int TileFlip(int sx, unsigned int pack, int pal); -#else +#define TileFlipMaker(funcname, pix_func) \ +static void funcname(unsigned char *pd, unsigned int pack, int pal) \ +TileFlipMaker_(pix_func) + +#define TileNormMakerAS(funcname, pix_func) \ +static void funcname(unsigned char *pd, unsigned char *mb, unsigned int pack, int pal) \ +TileNormMaker_(pix_func) + +#define TileFlipMakerAS(funcname, pix_func) \ +static void funcname(unsigned char *pd, unsigned char *mb, unsigned int pack, int pal) \ +TileFlipMaker_(pix_func) #define pix_just_write(x) \ if (t) pd[x]=pal|t @@ -140,8 +144,6 @@ int TileFlip(int sx, unsigned int pack, int pal); TileNormMaker(TileNorm,pix_just_write) TileFlipMaker(TileFlip,pix_just_write) -#endif - #ifndef _ASM_DRAW_C // draw a sprite pixel, process operator colors @@ -162,11 +164,15 @@ TileFlipMaker(TileFlipSH, pix_sh) TileNormMaker(TileNormSH_markop, pix_sh_markop) TileFlipMaker(TileFlipSH_markop, pix_sh_markop) +#endif + // process operator pixels only, apply only on low pri tiles and other op pixels #define pix_sh_onlyop(x) \ if (t>=0xe && (pd[x]&0xc0)) \ pd[x]=(pd[x]&0x3f)|(t<<6); /* c0 shadow, 80 hilight */ \ +#ifndef _ASM_DRAW_C + TileNormMaker(TileNormSH_onlyop_lp, pix_sh_onlyop) TileFlipMaker(TileFlipSH_onlyop_lp, pix_sh_onlyop) @@ -174,26 +180,39 @@ TileFlipMaker(TileFlipSH_onlyop_lp, pix_sh_onlyop) // draw a sprite pixel (AS) #define pix_as(x) \ - if (t && !(pd[x]&0x80)) pd[x]=pal|t + if (t & mb[x]) mb[x] = 0, pd[x] = pal | t + +TileNormMakerAS(TileNormAS, pix_as) +TileFlipMakerAS(TileFlipAS, pix_as) + +// draw a sprite pixel, process operator colors (AS) +#define pix_sh_as(x) \ + if (t & mb[x]) { \ + mb[x] = 0; \ + if (t>=0xe) pd[x]=(pd[x]&0x3f)|(t<<6); /* c0 shadow, 80 hilight */ \ + else pd[x] = pal | t; \ + } -TileNormMaker(TileNormAS, pix_as) -TileFlipMaker(TileFlipAS, pix_as) +TileNormMakerAS(TileNormSH_AS, pix_sh_as) +TileFlipMakerAS(TileFlipSH_AS, pix_sh_as) -// draw a sprite pixel, skip operator colors (AS) -#define pix_sh_as_noop(x) \ - if (t && t < 0xe && !(pd[x]&0x80)) pd[x]=pal|t +#define pix_sh_as_onlyop(x) \ + if (t & mb[x]) { \ + mb[x] = 0; \ + pix_sh_onlyop(x); \ + } -TileNormMaker(TileNormAS_noop, pix_sh_as_noop) -TileFlipMaker(TileFlipAS_noop, pix_sh_as_noop) +TileNormMakerAS(TileNormSH_AS_onlyop_lp, pix_sh_as_onlyop) +TileFlipMakerAS(TileFlipSH_AS_onlyop_lp, pix_sh_as_onlyop) // mark pixel as sprite pixel (AS) #define pix_sh_as_onlymark(x) \ - if (t) pd[x]|=0x80 + if (t) mb[x] = 0 -TileNormMaker(TileNormAS_onlymark, pix_sh_as_onlymark) -TileFlipMaker(TileFlipAS_onlymark, pix_sh_as_onlymark) +TileNormMakerAS(TileNormAS_onlymark, pix_sh_as_onlymark) +TileFlipMakerAS(TileFlipAS_onlymark, pix_sh_as_onlymark) -// mark pixel as sprite pixel (AS) +// forced both layer draw (through debug reg) #define pix_and(x) \ pd[x] = (pd[x] & 0xc0) | (pd[x] & (pal | t)) @@ -205,6 +224,7 @@ TileFlipMaker(TileFlip_and, pix_and) #ifndef _ASM_DRAW_C static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip) { + unsigned char *pd = Pico.est.HighCol; int tilex,dx,ty,code=0,addr=0,cells; int oldcode=-1,blank=-1; // The tile we know is blank int pal=0,sh; @@ -222,7 +242,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip) { unsigned int pack; - code = Pico.vram[ts->nametab + (tilex & ts->xmask)]; + code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)]; if (code == blank) continue; if ((code >> 15) | (lflags & LF_FORCE)) { // high priority tile @@ -242,14 +262,14 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip) pal=((code>>9)&0x30)|sh; } - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { blank = code; continue; } - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } // terminate the cache list @@ -261,6 +281,7 @@ static void DrawStrip(struct TileStrip *ts, int lflags, int cellskip) // this is messy static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) { + unsigned char *pd = Pico.est.HighCol; int tilex,dx,code=0,addr=0,cell=0; int oldcode=-1,blank=-1; // The tile we know is blank int pal=0,scan=Pico.est.DrawScanline; @@ -268,7 +289,11 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) // Draw tiles across screen: tilex=(-ts->hscroll)>>3; dx=((ts->hscroll-1)&7)+1; - if(dx != 8) cell--; // have hscroll, start with negative cell + if (ts->hscroll & 0x0f) { + int adj = ((ts->hscroll ^ dx) >> 3) & 1; + cell -= adj + 1; + ts->cells -= adj; + } cell+=cellskip; tilex+=cellskip; dx+=cellskip<<3; @@ -281,7 +306,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) //if((cell&1)==0) { int line,vscroll; - vscroll=Pico.vsram[(plane_sh&1)+(cell&~1)]; + vscroll=PicoMem.vsram[(plane_sh&1)+(cell&~1)]; // Find the line in the name table line=(vscroll+scan)&ts->line&0xffff; // ts->line is really ymask .. @@ -289,7 +314,7 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) ty=(line&7)<<1; // Y-Offset into tile } - code=Pico.vram[ts->nametab+nametabadd+(tilex&ts->xmask)]; + code=PicoMem.vram[ts->nametab+nametabadd+(tilex&ts->xmask)]; if (code==blank) continue; if (code>>15) { // high priority tile int cval = code | (dx<<16) | (ty<<25); @@ -307,14 +332,14 @@ static void DrawStripVSRam(struct TileStrip *ts, int plane_sh, int cellskip) pal=((code>>9)&0x30)|((plane_sh<<5)&0x40); } - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { blank = code; continue; } - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } // terminate the cache list @@ -328,6 +353,7 @@ static #endif void DrawStripInterlace(struct TileStrip *ts) { + unsigned char *pd = Pico.est.HighCol; int tilex=0,dx=0,ty=0,code=0,addr=0,cells; int oldcode=-1,blank=-1; // The tile we know is blank int pal=0; @@ -343,7 +369,7 @@ void DrawStripInterlace(struct TileStrip *ts) { unsigned int pack; - code=Pico.vram[ts->nametab+(tilex&ts->xmask)]; + code = PicoMem.vram[ts->nametab + (tilex & ts->xmask)]; if (code==blank) continue; if (code>>15) { // high priority tile int cval = (code&0xfc00) | (dx<<16) | (ty<<25); @@ -363,14 +389,14 @@ void DrawStripInterlace(struct TileStrip *ts) pal=((code>>9)&0x30); } - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { blank = code; continue; } - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } // terminate the cache list @@ -416,11 +442,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, htab+=plane_sh&1; // A or B // Get horizontal scroll value, will be masked later - ts.hscroll=Pico.vram[htab&0x7fff]; + ts.hscroll = PicoMem.vram[htab & 0x7fff]; if((pvid->reg[12]&6) == 6) { // interlace mode 2 - vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value + vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value // Find the line in the name table ts.line=(vscroll+(est->DrawScanline<<1))&((ymask<<1)|1); @@ -433,7 +459,7 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, ts.line=ymask|(shift[width]<<24); // save some stuff instead of line DrawStripVSRam(&ts, plane_sh, cellskip); } else { - vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value + vscroll = PicoMem.vsram[plane_sh & 1]; // Get vertical scroll value // Find the line in the name table ts.line=(vscroll+est->DrawScanline)&ymask; @@ -450,7 +476,8 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, static void DrawWindow(int tstart, int tend, int prio, int sh, struct PicoEState *est) { - struct PicoVideo *pvid=&Pico.video; + unsigned char *pd = Pico.est.HighCol; + struct PicoVideo *pvid = &Pico.video; int tilex,ty,nametab,code=0; int blank=-1; // The tile we know is blank @@ -470,7 +497,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, if (!(est->rendstatus & PDRAW_WND_DIFF_PRIO)) { // check the first tile code - code=Pico.vram[nametab+tilex]; + code = PicoMem.vram[nametab + tilex]; // if the whole window uses same priority (what is often the case), we may be able to skip this field if ((code>>15) != prio) return; } @@ -487,7 +514,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, int dx, addr; int pal; - code=Pico.vram[nametab+tilex]; + code = PicoMem.vram[nametab + tilex]; if (code==blank) continue; if ((code>>15) != prio) { est->rendstatus |= PDRAW_WND_DIFF_PRIO; @@ -498,7 +525,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, addr=(code&0x7ff)<<4; if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { blank = code; continue; @@ -507,8 +534,8 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, pal = ((code >> 9) & 0x30); dx = 8 + (tilex << 3); - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } } else @@ -519,7 +546,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, int dx, addr; int pal; - code=Pico.vram[nametab+tilex]; + code = PicoMem.vram[nametab + tilex]; if(code==blank) continue; if((code>>15) != prio) { est->rendstatus |= PDRAW_WND_DIFF_PRIO; @@ -540,7 +567,7 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, addr=(code&0x7ff)<<4; if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { blank = code; continue; @@ -548,8 +575,8 @@ static void DrawWindow(int tstart, int tend, int prio, int sh, dx = 8 + (tilex << 3); - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } } } @@ -571,6 +598,7 @@ static void DrawTilesFromCacheShPrep(void) static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est) { + unsigned char *pd = Pico.est.HighCol; int code, addr, dx; unsigned int pack; int pal; @@ -594,7 +622,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est addr = (code & 0x7ff) << 4; addr += code >> 25; // y offset into tile - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) { blank = (short)code; continue; @@ -605,8 +633,8 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est if (rlim-dx < 0) goto last_cut_tile; - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } } else @@ -622,7 +650,7 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; *zb++ &= 0xbf; - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); if (!pack) continue; @@ -630,8 +658,8 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est if (rlim - dx < 0) goto last_cut_tile; - if (code & 0x0800) TileFlip(dx, pack, pal); - else TileNorm(dx, pack, pal); + if (code & 0x0800) TileFlip(pd + dx, pack, pal); + else TileNorm(pd + dx, pack, pal); } } return; @@ -639,9 +667,9 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim, struct PicoEState *est last_cut_tile: // for vertical window cutoff { - unsigned char *pd = est->HighCol + dx; unsigned int t; + pd += dx; if (code&0x0800) { switch (rlim-dx+8) @@ -680,12 +708,13 @@ last_cut_tile: static void DrawSprite(int *sprite, int sh) { + void (*fTileFunc)(unsigned char *pd, unsigned int pack, int pal); + unsigned char *pd = Pico.est.HighCol; int width=0,height=0; int row=0,code=0; int pal; int tile=0,delta=0; int sx, sy; - void (*fTileFunc)(int sx, unsigned int pack, int pal); // parse the sprite data sy=sprite[0]; @@ -724,14 +753,15 @@ static void DrawSprite(int *sprite, int sh) if(sx<=0) continue; if(sx>=328) break; // Offscreen - pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff)); - fTileFunc(sx, pack, pal); + pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); + fTileFunc(pd + sx, pack, pal); } } #endif static NOINLINE void DrawTilesFromCacheForced(const int *hc) { + unsigned char *pd = Pico.est.HighCol; int code, addr, dx; unsigned int pack; int pal; @@ -744,15 +774,16 @@ static NOINLINE void DrawTilesFromCacheForced(const int *hc) dx = (code >> 16) & 0x1ff; pal = ((code >> 9) & 0x30); - pack = *(unsigned int *)(Pico.vram + addr); + pack = *(unsigned int *)(PicoMem.vram + addr); - if (code & 0x0800) TileFlip_and(dx, pack, pal); - else TileNorm_and(dx, pack, pal); + if (code & 0x0800) TileFlip_and(pd + dx, pack, pal); + else TileNorm_and(pd + dx, pack, pal); } } static void DrawSpriteInterlace(unsigned int *sprite) { + unsigned char *pd = Pico.est.HighCol; int width=0,height=0; int row=0,code=0; int pal; @@ -790,9 +821,9 @@ static void DrawSpriteInterlace(unsigned int *sprite) if(sx<=0) continue; if(sx>=328) break; // Offscreen - pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff)); - if (code & 0x0800) TileFlip(sx, pack, pal); - else TileNorm(sx, pack, pal); + pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); + if (code & 0x0800) TileFlip(pd + sx, pack, pal); + else TileNorm(pd + sx, pack, pal); } } @@ -812,7 +843,7 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh) unsigned int *sprite; int code, sx, sy, height; - sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite + sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite // get sprite info code = sprite[0]; @@ -854,7 +885,8 @@ static NOINLINE void DrawAllSpritesInterlace(int pri, int sh) */ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) { - void (*fTileFunc)(int sx, unsigned int pack, int pal); + void (*fTileFunc)(unsigned char *pd, unsigned int pack, int pal); + unsigned char *pd = Pico.est.HighCol; unsigned char *p; int cnt; @@ -915,8 +947,8 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) if(sx<=0) continue; if(sx>=328) break; // Offscreen - pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff)); - fTileFunc(sx, pack, pal); + pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); + fTileFunc(pd + sx, pack, pal); } } } @@ -924,15 +956,17 @@ static void DrawSpritesSHi(unsigned char *sprited, const struct PicoEState *est) static void DrawSpritesHiAS(unsigned char *sprited, int sh) { - void (*fTileFunc)(int sx, unsigned int pack, int pal); + void (*fTileFunc)(unsigned char *pd, unsigned char *mb, + unsigned int pack, int pal); + unsigned char *pd = Pico.est.HighCol; + unsigned char mb[8+320+8]; unsigned char *p; - int entry, cnt, sh_cnt = 0; + int entry, cnt; cnt = sprited[0] & 0x7f; if (cnt == 0) return; - Pico.est.rendstatus |= PDRAW_SPR_LO_ON_HI; - + memset(mb, 0xff, sizeof(mb)); p = &sprited[3]; // Go through sprites: @@ -946,22 +980,26 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) code = sprite[1]; pal = (code>>9)&0x30; - if (code & 0x8000) // hi priority + if (sh && pal == 0x30) { - if (sh && pal == 0x30) + if (code & 0x8000) // hi priority { - if (code&0x800) fTileFunc=TileFlipAS_noop; - else fTileFunc=TileNormAS_noop; + if (code&0x800) fTileFunc = TileFlipSH_AS; + else fTileFunc = TileNormSH_AS; } else { - if (code&0x800) fTileFunc=TileFlipAS; - else fTileFunc=TileNormAS; + if (code&0x800) fTileFunc = TileFlipSH_AS_onlyop_lp; + else fTileFunc = TileNormSH_AS_onlyop_lp; } } else { - if (code&0x800) fTileFunc=TileFlipAS_onlymark; - else fTileFunc=TileNormAS_onlymark; + if (code & 0x8000) // hi priority + { + if (code&0x800) fTileFunc = TileFlipAS; + else fTileFunc = TileNormAS; + } else { + if (code&0x800) fTileFunc = TileFlipAS_onlymark; + else fTileFunc = TileNormAS_onlymark; + } } - if (sh && pal == 0x30) - p[sh_cnt++] = offs / 2; // re-save for sh/hi pass // parse remaining sprite data sy=sprite[0]; @@ -981,7 +1019,6 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) tile &= 0x7ff; tile<<=4; tile+=(row&7)<<1; // Tile address delta<<=4; // Delta of address - pal |= 0x80; for (; width; width--,sx+=8,tile+=delta) { unsigned int pack; @@ -989,26 +1026,10 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) if(sx<=0) continue; if(sx>=328) break; // Offscreen - pack = *(unsigned int *)(Pico.vram + (tile & 0x7fff)); - fTileFunc(sx, pack, pal); - } - } - - if (!sh || !(sprited[1]&SPRL_MAY_HAVE_OP)) return; - - /* nasty 1: remove 'sprite' flags */ - { - int c = 320/4/4, *zb = (int *)(Pico.est.HighCol+8); - while (c--) - { - *zb++ &= 0x7f7f7f7f; *zb++ &= 0x7f7f7f7f; - *zb++ &= 0x7f7f7f7f; *zb++ &= 0x7f7f7f7f; + pack = *(unsigned int *)(PicoMem.vram + (tile & 0x7fff)); + fTileFunc(pd + sx, mb + sx, pack, pal); } } - - /* nasty 2: sh operator pass */ - sprited[0] = sh_cnt; - DrawSpritesSHi(sprited, &Pico.est); } @@ -1030,7 +1051,7 @@ static NOINLINE void PrepareSprites(int full) if (!(Pico.video.reg[12]&1)) max_sprites = 64, max_line_sprites = 16, max_width = 264; - if (PicoOpt & POPT_DIS_SPRITE_LIM) + if (PicoIn.opt & POPT_DIS_SPRITE_LIM) max_line_sprites = MAX_LINE_SPRITES; if (pvid->reg[1]&8) max_lines = 240; @@ -1049,7 +1070,7 @@ static NOINLINE void PrepareSprites(int full) unsigned int *sprite; int code2, sx, sy, height; - sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite + sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite // parse sprite info code2 = sprite[1]; @@ -1102,7 +1123,7 @@ found:; unsigned int *sprite; int code, code2, sx, sy, hv, height, width; - sprite=(unsigned int *)(Pico.vram+((table+(link<<2))&0x7ffc)); // Find sprite + sprite=(unsigned int *)(PicoMem.vram+((table+(link<<2))&0x7ffc)); // Find sprite // parse sprite info code = sprite[0]; @@ -1226,7 +1247,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est) Pico.m.dirtyPal = 0; - spal = (void *)Pico.cram; + spal = (void *)PicoMem.cram; dpal = (void *)est->HighPal; for (i = 0; i < 0x40 / 2; i++) { @@ -1270,22 +1291,20 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est) if (Pico.video.reg[12]&1) { len = 320; } else { - if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32; + if (!(PicoIn.opt&POPT_DIS_32C_BORDER)) pd+=32; len = 256; } { -#ifndef PSP - int i, mask=0xff; - if (!sh && (est->rendstatus & PDRAW_SPR_LO_ON_HI)) - mask=0x3f; // accurate sprites, upper bits are priority stuff +#if 1 + int i; for (i = 0; i < len; i++) - pd[i] = pal[ps[i] & mask]; + pd[i] = pal[ps[i]]; #else extern void amips_clut(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); extern void amips_clut_6bit(unsigned short *dst, unsigned char *src, unsigned short *pal, int count); - if (!sh && (est->rendstatus & PDRAW_SPR_LO_ON_HI)) + if (!sh) amips_clut_6bit(pd, ps, pal, len); else amips_clut(pd, ps, pal, len); #endif @@ -1308,16 +1327,16 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) rs |= PDRAW_SONIC_MODE; est->rendstatus = rs; if (dirty_count == 3) { - blockcpy(est->HighPal, Pico.cram, 0x40*2); + blockcpy(est->HighPal, PicoMem.cram, 0x40*2); } else if (dirty_count == 11) { - blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2); + blockcpy(est->HighPal+0x40, PicoMem.cram, 0x40*2); } } if (Pico.video.reg[12]&1) { len = 320; } else { - if (!(PicoOpt & POPT_DIS_32C_BORDER)) + if (!(PicoIn.opt & POPT_DIS_32C_BORDER)) pd += 32; len = 256; } @@ -1430,7 +1449,7 @@ static int DrawDisplay(int sh) else if (est->rendstatus & PDRAW_INTERLACE) DrawAllSpritesInterlace(1, sh); // have sprites without layer pri bit ontop of sprites with that bit - else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES)) + else if ((sprited[1] & 0xd0) == 0xd0 && (PicoIn.opt & POPT_ACC_SPRITES)) DrawSpritesHiAS(sprited, sh); else if (sh && (sprited[1] & SPRL_MAY_HAVE_OP)) DrawSpritesSHi(sprited, est); @@ -1484,7 +1503,7 @@ PICO_INTERNAL void PicoFrameStart(void) Pico.est.DrawScanline = 0; skip_next_line = 0; - if (PicoOpt & POPT_ALT_RENDERER) + if (PicoIn.opt & POPT_ALT_RENDERER) return; if (Pico.m.dirtyPal) @@ -1580,7 +1599,7 @@ void PicoDrawUpdateHighPal(void) { struct PicoEState *est = &Pico.est; int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? - if (PicoOpt & POPT_ALT_RENDERER) + if (PicoIn.opt & POPT_ALT_RENDERER) sh = 0; // no s/h support PicoDoHighPal555(sh, 0, &Pico.est); @@ -1600,7 +1619,7 @@ void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode) break; case PDF_RGB555: - if ((PicoAHW & PAHW_32X) && use_32x_line_mode) + if ((PicoIn.AHW & PAHW_32X) && use_32x_line_mode) FinalizeLine = FinalizeLine32xRGB555; else FinalizeLine = FinalizeLine555; @@ -1620,7 +1639,7 @@ void PicoDrawSetOutBuf(void *dest, int increment) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; - Pico.est.DrawLineDest = DrawLineDestBase + Pico.est.DrawScanline * increment; + Pico.est.DrawLineDest = (char *)DrawLineDestBase + Pico.est.DrawScanline * increment; } void PicoDrawSetInternalBuf(void *dest, int increment) @@ -1643,7 +1662,7 @@ void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned in PicoScan32xBegin = NULL; PicoScan32xEnd = NULL; - if ((PicoAHW & PAHW_32X) && FinalizeLine != FinalizeLine32xRGB555) { + if ((PicoIn.AHW & PAHW_32X) && FinalizeLine != FinalizeLine32xRGB555) { PicoScan32xBegin = begin; PicoScan32xEnd = end; }