X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fdraw.c;h=180045d26f736a53fafefd38542b324d8e8e8413;hb=3cf9570bacd8952713106a2a2e3176852d811d18;hp=747f428158dcef62c68fd4c9709592069bfa40e9;hpb=87b0845f3733166b491ae236feb8bc2eb0fca2ec;p=picodrive.git diff --git a/pico/draw.c b/pico/draw.c index 747f428..180045d 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -53,8 +53,8 @@ int HighPreSpr[80*2+1]; // slightly preprocessed sprites #define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]... -int rendstatus = 0; -int DrawScanline = 0; +int rendstatus, rendstatus_old; +int DrawScanline; int PicoDrawMask = -1; static int skip_next_line=0; @@ -78,8 +78,7 @@ void DrawAllSprites(unsigned char *sprited, int prio, int sh); void DrawTilesFromCache(int *hc, int sh, int rlim); void DrawSpritesSHi(unsigned char *sprited); void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells); -void FinalizeLineBGR444(int sh); -void FinalizeLineRGB555(int sh); +void FinalizeLineBGR444(int sh, int line); void *blockcpy(void *dst, const void *src, size_t n); void blockcpy_or(void *dst, void *src, size_t n, int pat); #else @@ -1160,20 +1159,24 @@ unsigned short HighPal[0x100]; #ifndef _ASM_DRAW_C void PicoDoHighPal555(int sh) { + unsigned int *spal, *dpal; unsigned short *pal=HighPal; int i, t; Pico.m.dirtyPal = 0; - { - unsigned int *spal=(void *)Pico.cram; - unsigned int *dpal=(void *)HighPal; - for (i = 0x3f/2; i >= 0; i--) + spal = (void *)Pico.cram; + dpal = (void *)HighPal; + + for (i = 0; i < 0x40; i++) { + unsigned int t = spal[i]; #ifdef USE_BGR555 - dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4); + t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4); #else - dpal[i] = ((spal[i]&0x000f000f)<<12)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)>>7); + t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7); #endif + t |= (t >> 3) & 0x18e318e3; + dpal[i] = t; } if (sh) @@ -1189,7 +1192,7 @@ void PicoDoHighPal555(int sh) } } -static void FinalizeLineBGR444(int sh) +static void FinalizeLineBGR444(int sh, int line) { unsigned short *pd=DrawLineDest; unsigned char *ps=HighCol+8; @@ -1227,7 +1230,7 @@ static void FinalizeLineBGR444(int sh) } -static void FinalizeLineRGB555(int sh) +void FinalizeLineRGB555(int sh, int line) { unsigned short *pd=DrawLineDest; unsigned char *ps=HighCol+8; @@ -1263,9 +1266,9 @@ static void FinalizeLineRGB555(int sh) } #endif -static void FinalizeLine8bit(int sh) +static void FinalizeLine8bit(int sh, int line) { - unsigned char *pd=DrawLineDest; + unsigned char *pd = DrawLineDest; int len, rs = rendstatus; static int dirty_count; @@ -1287,7 +1290,8 @@ static void FinalizeLine8bit(int sh) if (Pico.video.reg[12]&1) { len = 320; } else { - if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32; + if (!(PicoOpt & POPT_DIS_32C_BORDER)) + pd += 32; len = 256; } @@ -1302,7 +1306,7 @@ static void FinalizeLine8bit(int sh) } } -static void (*FinalizeLine)(int sh); +static void (*FinalizeLine)(int sh, int line); // -------------------------------------------- @@ -1407,51 +1411,56 @@ PICO_INTERNAL void PicoFrameStart(void) if (Pico.video.reg[1] & 8) rendstatus |= PDRAW_240LINES; + DrawScanline = 0; + skip_next_line = 0; + + if (rendstatus != rendstatus_old) { + rendstatus_old = rendstatus; + emu_video_mode_change((rendstatus & PDRAW_240LINES) ? 0 : 8, + (rendstatus & PDRAW_240LINES) ? 240 : 224, + (Pico.video.reg[12] & 1) ? 0 : 1); + } + + if (PicoOpt & POPT_ALT_RENDERER) + return; + if (Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed - - DrawScanline=0; PrepareSprites(1); - skip_next_line=0; } -static void DrawBlankedLine(int line, int offs) +static void DrawBlankedLine(int line, int offs, int sh, int bgc) { - int sh = (Pico.video.reg[0xC]&8)>>3; // shadow/hilight? - if (PicoScanBegin != NULL) PicoScanBegin(line + offs); - BackFill(Pico.video.reg[7], sh); + BackFill(bgc, sh); if (FinalizeLine != NULL) - FinalizeLine(sh); + FinalizeLine(sh, line); if (PicoScanEnd != NULL) PicoScanEnd(line + offs); } -static void PicoLine(int line, int offs) +static void PicoLine(int line, int offs, int sh, int bgc) { - int sh; if (skip_next_line > 0) { skip_next_line--; return; } - sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight? - DrawScanline = line; if (PicoScanBegin != NULL) skip_next_line = PicoScanBegin(line + offs); // Draw screen: - BackFill(Pico.video.reg[7], sh); + BackFill(bgc, sh); if (Pico.video.reg[1]&0x40) DrawDisplay(sh); if (FinalizeLine != NULL) - FinalizeLine(sh); + FinalizeLine(sh, line); if (PicoScanEnd != NULL) skip_next_line = PicoScanEnd(line + offs); @@ -1460,16 +1469,22 @@ static void PicoLine(int line, int offs) void PicoDrawSync(int to, int blank_last_line) { int line, offs = 0; + int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? + int bgc = Pico.video.reg[7]; if (!(rendstatus & PDRAW_240LINES)) offs = 8; + // need to know which pixels are bg for 32x + if (PicoAHW & PAHW_32X) + bgc = 0; + for (line = DrawScanline; line < to; line++) { #if !CAN_HANDLE_240_LINES if (line >= 224) break; #endif - PicoLine(line, offs); + PicoLine(line, offs, sh, bgc); } #if !CAN_HANDLE_240_LINES @@ -1483,8 +1498,8 @@ void PicoDrawSync(int to, int blank_last_line) if (line <= to) { if (blank_last_line) - DrawBlankedLine(line, offs); - else PicoLine(line, offs); + DrawBlankedLine(line, offs, sh, bgc); + else PicoLine(line, offs, sh, bgc); line++; } DrawScanline = line; @@ -1495,7 +1510,7 @@ void PicoDrawSetColorFormat(int which) switch (which) { case 2: FinalizeLine = FinalizeLine8bit; break; - case 1: FinalizeLine = FinalizeLineRGB555; break; + case 1: FinalizeLine = (PicoAHW & PAHW_32X) ? FinalizeLine32xRGB555 : FinalizeLineRGB555; break; case 0: FinalizeLine = FinalizeLineBGR444; break; default:FinalizeLine = NULL; break; }