X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=pico%2Fdraw.c;h=2aa37f8d748b6dbe51c2bc483b4a63ce2f1d49da;hb=eced0190981a424f9910a7052765023474483b33;hp=7dbdc34e62638fd6988a38a3c67941d8d88c3c32;hpb=99bdfd31b8708f8059fbc16ec8be90cb8d7c8bc3;p=picodrive.git diff --git a/pico/draw.c b/pico/draw.c index 7dbdc34..2aa37f8 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -394,8 +394,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells, ts.xmask=(1<1) ymask =0x0ff; + switch (width) { + case 1: ymask &= 0x1ff; break; + case 2: ymask = 0x007; break; + case 3: ymask = 0x0ff; break; + } // Find name table: if (plane_sh&1) ts.nametab=(pvid->reg[4]&0x07)<<12; // B @@ -954,7 +957,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh) // Index + 0 : hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size // Index + 4 : xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8 -void PrepareSprites(int full) +static NOINLINE void PrepareSprites(int full) { const struct PicoVideo *pvid=&Pico.video; const struct PicoEState *est=&Pico.est; @@ -1117,16 +1120,9 @@ found:; static void DrawAllSprites(unsigned char *sprited, int prio, int sh, struct PicoEState *est) { - int rs = est->rendstatus; unsigned char *p; int cnt; - if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) { - //elprintf(EL_STATUS, "PrepareSprites(%i)", (rs>>4)&1); - PrepareSprites(rs & PDRAW_DIRTY_SPRITES); - est->rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES); - } - cnt = sprited[0] & 0x7f; if (cnt == 0) return; @@ -1161,8 +1157,6 @@ void BackFill(int reg7, int sh, struct PicoEState *est) // -------------------------------------------- -unsigned short HighPal[0x100]; - #ifndef _ASM_DRAW_C void PicoDoHighPal555(int sh, int line, struct PicoEState *est) { @@ -1172,7 +1166,7 @@ void PicoDoHighPal555(int sh, int line, struct PicoEState *est) Pico.m.dirtyPal = 0; spal = (void *)Pico.cram; - dpal = (void *)HighPal; + dpal = (void *)est->HighPal; for (i = 0; i < 0x40 / 2; i++) { t = spal[i]; @@ -1206,7 +1200,7 @@ void FinalizeLine555(int sh, int line, struct PicoEState *est) { unsigned short *pd=est->DrawLineDest; unsigned char *ps=est->HighCol+8; - unsigned short *pal=HighPal; + unsigned short *pal=est->HighPal; int len; if (Pico.m.dirtyPal) @@ -1253,9 +1247,9 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) rs |= PDRAW_SONIC_MODE; est->rendstatus = rs; if (dirty_count == 3) { - blockcpy(HighPal, Pico.cram, 0x40*2); + blockcpy(est->HighPal, Pico.cram, 0x40*2); } else if (dirty_count == 11) { - blockcpy(HighPal+0x40, Pico.cram, 0x40*2); + blockcpy(est->HighPal+0x40, Pico.cram, 0x40*2); } } @@ -1290,6 +1284,12 @@ static int DrawDisplay(int sh) int win=0,edge=0,hvwind=0; int maxw,maxcells; + if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) { + // elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1); + PrepareSprites(est->rendstatus & PDRAW_DIRTY_SPRITES); + est->rendstatus &= ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES); + } + est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO); if (pvid->reg[12]&1) { @@ -1333,7 +1333,7 @@ static int DrawDisplay(int sh) DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est); /* - sprites low - */ if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON)); - else if (Pico.est.rendstatus & PDRAW_INTERLACE) + else if (est->rendstatus & PDRAW_INTERLACE) DrawAllSpritesInterlace(0, sh); else if (sprited[1] & SPRL_HAVE_LO) DrawAllSprites(sprited, 0, sh, est); @@ -1354,7 +1354,7 @@ static int DrawDisplay(int sh) DrawTilesFromCache(HighCacheA, sh, maxw, est); /* - sprites hi - */ if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON)); - else if (Pico.est.rendstatus & PDRAW_INTERLACE) + 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)) @@ -1496,15 +1496,16 @@ void PicoDrawSync(int to, int blank_last_line) // also works for fast renderer void PicoDrawUpdateHighPal(void) { + struct PicoEState *est = &Pico.est; int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? if (PicoOpt & POPT_ALT_RENDERER) sh = 0; // no s/h support PicoDoHighPal555(sh, 0, &Pico.est); - if (Pico.est.rendstatus & PDRAW_SONIC_MODE) { + if (est->rendstatus & PDRAW_SONIC_MODE) { // FIXME? - memcpy(HighPal + 0x40, HighPal, 0x40*2); - memcpy(HighPal + 0x80, HighPal, 0x40*2); + memcpy(est->HighPal + 0x40, est->HighPal, 0x40*2); + memcpy(est->HighPal + 0x80, est->HighPal, 0x40*2); } }