X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FDraw2.c;h=054cee972ebd2db88e3c99041c3184fbe664a040;hb=f0f0d2df762a7fbbf8d4d9359d541621837ed067;hp=9fc413bc5761af42a0f6608b8468f5966401648e;hpb=e5f426aa2e86d56357b8af2795e73cc0c9b17e8f;p=picodrive.git diff --git a/Pico/Draw2.c b/Pico/Draw2.c index 9fc413b..054cee9 100644 --- a/Pico/Draw2.c +++ b/Pico/Draw2.c @@ -20,8 +20,12 @@ #define USE_CACHE - -int currpri = 0; +// note: this is not implemented in ARM asm +#if defined(DRAW2_OVERRIDE_LINE_WIDTH) +#define LINE_WIDTH DRAW2_OVERRIDE_LINE_WIDTH +#else +#define LINE_WIDTH 328 +#endif static int HighCache2A[41*(TILE_ROWS+1)+1+1]; // caches for high layers static int HighCache2B[41*(TILE_ROWS+1)+1+1]; @@ -45,7 +49,7 @@ static int TileXnormYnorm(unsigned char *pd,int addr,unsigned char pal) unsigned int pack=0; unsigned int t=0, blank = 1; int i; - for(i=8; i; i--, addr+=2, pd += 320+8) { + for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) { pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels if(!pack) continue; @@ -68,7 +72,7 @@ static int TileXflipYnorm(unsigned char *pd,int addr,unsigned char pal) unsigned int pack=0; unsigned int t=0, blank = 1; int i; - for(i=8; i; i--, addr+=2, pd += 320+8) { + for(i=8; i; i--, addr+=2, pd += LINE_WIDTH) { pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels if(!pack) continue; @@ -91,7 +95,7 @@ static int TileXnormYflip(unsigned char *pd,int addr,unsigned char pal) int i; addr+=14; - for(i=8; i; i--, addr-=2, pd += 320+8) { + for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) { pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels if(!pack) continue; @@ -115,7 +119,7 @@ static int TileXflipYflip(unsigned char *pd,int addr,unsigned char pal) int i; addr+=14; - for(i=8; i; i--, addr-=2, pd += 320+8) { + for(i=8; i; i--, addr-=2, pd += LINE_WIDTH) { pack=*(unsigned int *)(Pico.vram+addr); // Get 8 pixels if(!pack) continue; @@ -164,8 +168,8 @@ static void DrawWindowFull(int start, int end, int prio) code=Pico.vram[nametab+tile_start]; if ((code>>15) != prio) return; // hack: just assume that whole window uses same priority - scrpos+=8*328+8; - scrpos+=8*328*(start-START_ROW); + scrpos+=8*LINE_WIDTH+8; + scrpos+=8*LINE_WIDTH*(start-START_ROW); // do a window until we reach planestart row for(trow = start; trow < end; trow++, nametab+=nametab_step) { // current tile row @@ -193,7 +197,7 @@ static void DrawWindowFull(int start, int end, int prio) if(zero) blank=code; // We know this tile is blank now } - scrpos += 328*8; + scrpos += LINE_WIDTH*8; } } @@ -239,11 +243,11 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) else nametab=(pvid->reg[4]&0x07)<<12; // B scrpos = PicoDraw2FB; - scrpos+=8*328*(planestart-START_ROW); + scrpos+=8*LINE_WIDTH*(planestart-START_ROW); // Get vertical scroll value: vscroll=Pico.vsram[plane]&0x1ff; - scrpos+=(8-(vscroll&7))*328; + scrpos+=(8-(vscroll&7))*LINE_WIDTH; if(vscroll&7) planeend++; // we have vertically clipped tiles due to vscroll, so we need 1 more row *hcache++ = 8-(vscroll&7); // push y-offset to tilecache @@ -278,12 +282,8 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) code=Pico.vram[nametab_row+(tilex&xmask)]; if (code==blank) continue; -#ifdef USE_CACHE if (code>>15) { // high priority tile *hcache++ = code|(dx<<16)|(trow<<27); // cache it -#else - if ((code>>15) != currpri) { -#endif continue; } @@ -302,7 +302,7 @@ static void DrawLayerFull(int plane, int *hcache, int planestart, int planeend) if(zero) blank=code; // We know this tile is blank now } - scrpos += 328*8; + scrpos += LINE_WIDTH*8; } *hcache = 0; // terminate cache @@ -319,7 +319,7 @@ static void DrawTilesFromCacheF(int *hc) unsigned char *scrpos = PicoDraw2FB, *pd = 0; // *hcache++ = code|(dx<<16)|(trow<<27); // cache it - scrpos+=(*hc++)*328 - START_ROW*328*8; + scrpos+=(*hc++)*LINE_WIDTH - START_ROW*LINE_WIDTH*8; while((code=*hc++)) { if((short)code == blank) continue; @@ -327,7 +327,7 @@ static void DrawTilesFromCacheF(int *hc) // y pos if(((unsigned)code>>27) != prevy) { prevy = (unsigned)code>>27; - pd = scrpos + prevy*328*8; + pd = scrpos + prevy*LINE_WIDTH*8; } // Get tile address/2: @@ -380,7 +380,7 @@ static void DrawSpriteFull(unsigned int *sprite) while(sy <= START_ROW*8) { sy+=8; tile+=tdeltay; height--; } scrpos = PicoDraw2FB; - scrpos+=(sy-START_ROW*8)*328; + scrpos+=(sy-START_ROW*8)*LINE_WIDTH; for (; height > 0; height--, sy+=8, tile+=tdeltay) { @@ -402,7 +402,7 @@ static void DrawSpriteFull(unsigned int *sprite) } } - scrpos+=8*328; + scrpos+=8*LINE_WIDTH; } } #endif @@ -479,8 +479,7 @@ static void DrawAllSpritesFull(int prio, int maxwidth) #ifndef _ASM_DRAW_C static void BackFillFull(int reg7) { - unsigned int back, i; - unsigned int *p=(unsigned int *)PicoDraw2FB; + unsigned int back; // Start with a background color: // back=PicoCramHigh[reg7&0x3f]; @@ -488,16 +487,11 @@ static void BackFillFull(int reg7) back|=back<<8; back|=back<<16; - for(i = (8+320)*(8+(END_ROW-START_ROW)*8)/16; i; i--) { - *p++ = back; // do 16 pixels per iteration - *p++ = back; - *p++ = back; - *p++ = back; - } + memset32((int *)PicoDraw2FB, back, LINE_WIDTH*(8+(END_ROW-START_ROW)*8)/4); } #endif -static void DrawDisplayFull() +static void DrawDisplayFull(void) { struct PicoVideo *pvid=&Pico.video; int win, edge=0, hvwin=0; // LSb->MSb: hwin&plane, vwin&plane, full @@ -512,7 +506,8 @@ static void DrawDisplayFull() } // horizontal window? - if((win=pvid->reg[0x12])) { + if ((win=pvid->reg[0x12])) + { hvwin=1; // hwindow shares display with plane A edge=win&0x1f; if(win == 0x80) { @@ -531,7 +526,8 @@ static void DrawDisplayFull() } // check for vertical window, but only if win is not fullscreen - if(hvwin != 4) { + if (hvwin != 4) + { win=pvid->reg[0x11]; edge=win&0x1f; if (win&0x80) { @@ -555,15 +551,16 @@ static void DrawDisplayFull() } } - if(hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; } + if (hvwin==1) { winend|=maxcolc<<16; planeend|=maxcolc<<16; } - currpri = 0; - DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW); - switch(hvwin) { + HighCache2A[1] = HighCache2B[1] = 0; + if (PicoDrawMask & PDRAW_LAYERB_ON) + DrawLayerFull(1, HighCache2B, START_ROW, (maxcolc<<16)|END_ROW); + if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) + { case 4: // fullscreen window DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 0); - HighCache2A[1] = 0; break; case 3: @@ -585,12 +582,13 @@ static void DrawDisplayFull() DrawLayerFull(0, HighCache2A, START_ROW, (maxcolc<<16)|END_ROW); break; } - DrawAllSpritesFull(0, maxw); + if (PicoDrawMask & PDRAW_SPRITES_LOW_ON) + DrawAllSpritesFull(0, maxw); -#ifdef USE_CACHE - if(HighCache2B[1]) DrawTilesFromCacheF(HighCache2B); - if(HighCache2A[1]) DrawTilesFromCacheF(HighCache2A); - switch(hvwin) { + if (HighCache2B[1]) DrawTilesFromCacheF(HighCache2B); + if (HighCache2A[1]) DrawTilesFromCacheF(HighCache2A); + if (PicoDrawMask & PDRAW_LAYERA_ON) switch (hvwin) + { case 4: // fullscreen window DrawWindowFull(START_ROW, (maxcolc<<16)|END_ROW, 1); @@ -608,18 +606,15 @@ static void DrawDisplayFull() DrawWindowFull(winstart, winend, 1); break; } -#else - currpri = 1; - // TODO -#endif - DrawAllSpritesFull(1, maxw); + if (PicoDrawMask & PDRAW_SPRITES_HI_ON) + DrawAllSpritesFull(1, maxw); } PICO_INTERNAL void PicoFrameFull() { // prepare cram? - if(PicoPrepareCram) PicoPrepareCram(); + if (PicoPrepareCram) PicoPrepareCram(); // Draw screen: BackFillFull(Pico.video.reg[7]);