X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FDraw.c;h=989d9bdb27b8d5f27715fd9d021c727a324b6e17;hb=d4ca252d929395352f581b532e9d3726da31d718;hp=1c562f6b45307e51d9e0948251da2d73bb2d3e25;hpb=70357ce52578dee0dd3b3663902cf872c3d34258;p=picodrive.git diff --git a/Pico/Draw.c b/Pico/Draw.c index 1c562f6..989d9bd 100644 --- a/Pico/Draw.c +++ b/Pico/Draw.c @@ -66,6 +66,10 @@ void blockcpy_or(void *dst, void *src, size_t n, int pat) #endif +#ifdef _ASM_DRAW_C_AMIPS +int TileNorm(int sx,int addr,int pal); +int TileFlip(int sx,int addr,int pal); +#else static int TileNorm(int sx,int addr,int pal) { unsigned char *pd = HighCol+sx; @@ -108,7 +112,7 @@ static int TileFlip(int sx,int addr,int pal) } return 1; // Tile blank } - +#endif // tile renderers for hacky operator sprite support #define sh_pix(x) \ @@ -531,22 +535,49 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache } // Draw tiles across screen: - for (; tilex < tend; tilex++) + if (!sh) { - int addr=0,zero=0; - int pal; + for (; tilex < tend; tilex++) + { + int addr=0,zero=0; + int pal; + + code=Pico.vram[nametab+tilex]; + if(code==blank) continue; + if((code>>15) != prio) { + rendstatus|=2; + continue; + } - code=Pico.vram[nametab+tilex]; - if(code==blank) continue; - if((code>>15) != prio) { - rendstatus|=2; - continue; + pal=((code>>9)&0x30); + + // Get tile address/2: + addr=(code&0x7ff)<<4; + if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip + + if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal); + else zero=TileNorm(8+(tilex<<3),addr,pal); + + if (zero) blank=code; // We know this tile is blank now } + } + else + { + for (; tilex < tend; tilex++) + { + int addr=0,zero=0; + int pal, tmp, *zb; + + code=Pico.vram[nametab+tilex]; + if(code==blank) continue; + if((code>>15) != prio) { + rendstatus|=2; + continue; + } - pal=((code>>9)&0x30); + pal=((code>>9)&0x30); - if(sh) { - int tmp, *zb = (int *)(HighCol+8+(tilex<<3)); + zb = (int *)(HighCol+8+(tilex<<3)); if(prio) { tmp = *zb; if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000; @@ -558,24 +589,43 @@ static void DrawWindow(int tstart, int tend, int prio, int sh) // int *hcache } else { pal |= 0x40; } - } - // Get tile address/2: - addr=(code&0x7ff)<<4; - if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip + // Get tile address/2: + addr=(code&0x7ff)<<4; + if (code&0x1000) addr+=14-ty; else addr+=ty; // Y-flip - if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal); - else zero=TileNorm(8+(tilex<<3),addr,pal); + if (code&0x0800) zero=TileFlip(8+(tilex<<3),addr,pal); + else zero=TileNorm(8+(tilex<<3),addr,pal); - if (zero) blank=code; // We know this tile is blank now + if (zero) blank=code; // We know this tile is blank now + } } - - // terminate the cache list - //*hcache = 0; } // -------------------------------------------- +static void DrawTilesFromCacheShPrep(void) +{ + if (!(rendstatus&0x80)) + { + // as some layer has covered whole line with hi priority tiles, + // we can process whole line and then act as if sh/hi mode was off. + rendstatus|=0x80; + int c = 320/4, *zb = (int *)(HighCol+8); + while (c--) + { + int tmp = *zb; + if (!(tmp & 0x80808080)) *zb=tmp&0x3f3f3f3f; + else { + if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000; + if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000; + *zb=tmp; + } + zb++; + } + } +} + static void DrawTilesFromCache(int *hc, int sh, int rlim) { int code, addr, dx; @@ -585,66 +635,49 @@ static void DrawTilesFromCache(int *hc, int sh, int rlim) if (sh && (rendstatus&0xc0)) { - if (!(rendstatus&0x80)) - { - // as some layer has covered whole line with hi priority tiles, - // we can process whole line and then act as if sh/hi mode was off. - rendstatus|=0x80; - int c = 320/4, *zb = (int *)(HighCol+8); - while (c--) - { - int tmp = *zb; - if (!(tmp & 0x80808080)) *zb=tmp&0x3f3f3f3f; - else { - if(!(tmp&0x00000080)) tmp&=~0x000000c0; if(!(tmp&0x00008000)) tmp&=~0x0000c000; - if(!(tmp&0x00800000)) tmp&=~0x00c00000; if(!(tmp&0x80000000)) tmp&=~0xc0000000; - *zb=tmp; - } - zb++; - } - } + DrawTilesFromCacheShPrep(); sh = 0; } - if (sh) + if (!sh) { + short blank=-1; // The tile we know is blank while ((code=*hc++)) { - unsigned char *zb; + int zero; + if((short)code == blank) continue; // Get tile address/2: addr=(code&0x7ff)<<4; addr+=(unsigned int)code>>25; // y offset into tile dx=(code>>16)&0x1ff; - zb = HighCol+dx; - if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; - if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; - if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; - if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; pal=((code>>9)&0x30); if (rlim-dx < 0) goto last_cut_tile; - if (code&0x0800) TileFlip(dx,addr,pal); - else TileNorm(dx,addr,pal); + if (code&0x0800) zero=TileFlip(dx,addr,pal); + else zero=TileNorm(dx,addr,pal); + + if (zero) blank=(short)code; } } else { - short blank=-1; // The tile we know is blank while ((code=*hc++)) { - int zero; - if((short)code == blank) continue; + unsigned char *zb; // Get tile address/2: addr=(code&0x7ff)<<4; addr+=(unsigned int)code>>25; // y offset into tile dx=(code>>16)&0x1ff; + zb = HighCol+dx; + if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; + if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; + if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; + if(!(*zb&0x80)) *zb&=0x3f; zb++; if(!(*zb&0x80)) *zb&=0x3f; zb++; pal=((code>>9)&0x30); if (rlim-dx < 0) goto last_cut_tile; - if (code&0x0800) zero=TileFlip(dx,addr,pal); - else zero=TileNorm(dx,addr,pal); - - if (zero) blank=(short)code; + if (code&0x0800) TileFlip(dx,addr,pal); + else TileNorm(dx,addr,pal); } } return; @@ -1123,8 +1156,7 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh) #ifndef _ASM_DRAW_C static void BackFill(int reg7, int sh) { - unsigned int back=0; - unsigned int *pd=NULL,*end=NULL; + unsigned int back; // Start with a blank scanline (background colour): back=reg7&0x3f; @@ -1132,10 +1164,7 @@ static void BackFill(int reg7, int sh) back|=back<<8; back|=back<<16; - pd= (unsigned int *)(HighCol+8); - end=(unsigned int *)(HighCol+8+320); - - do { pd[0]=pd[1]=pd[2]=pd[3]=back; pd+=4; } while (pd