X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fdraw.c;h=0480242f7879cbd7ffaf4521397c9c919db38956;hb=d3bbc8d2cbb5fcc61e9f4e282effd0f2777a5cc3;hp=1781b9eaa211700b233d375748ee8e8e56e244cf;hpb=e51e5983fe5cac8486df76bf349bde8aa23d1e5d;p=picodrive.git diff --git a/pico/draw.c b/pico/draw.c index 1781b9e..0480242 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1,11 +1,11 @@ -// This is part of Pico Library - -// (c) Copyright 2004 Dave, All rights reserved. -// (c) Copyright 2006-2008 notaz, All rights reserved. -// Free for non-commercial use. - -// For commercial use, separate licencing terms must be obtained. - +/* + * line renderer + * (c) Copyright Dave, 2004 + * (C) notaz, 2006-2010 + * + * This work is licensed under the terms of MAME license. + * See COPYING file in the top-level directory. + */ /* * The renderer has 4 modes now: * - normal @@ -19,7 +19,7 @@ * * since renderer always draws line in 8bit mode, there are 2 spare bits: * b \ mode: s/h as sonic - * 00 normal - - + * 00 normal - pal index * 01 shadow - pal index * 10 hilight+op spr spr pal index * 11 shadow +op spr - pal index @@ -1162,77 +1162,40 @@ unsigned short HighPal[0x100]; void PicoDoHighPal555(int sh) { unsigned int *spal, *dpal; - unsigned short *pal=HighPal; - int i, t; + unsigned int t, i; Pico.m.dirtyPal = 0; spal = (void *)Pico.cram; dpal = (void *)HighPal; - for (i = 0; i < 0x40; i++) { - unsigned int t = spal[i]; + for (i = 0; i < 0x40 / 2; i++) { + t = spal[i]; #ifdef USE_BGR555 t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4); #else t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7); #endif - t |= (t >> 3) & 0x18e318e3; + // treat it like it was 4-bit per channel, since in s/h mode it somewhat is that. + // otherwise intensity difference between this and s/h will be wrong + t |= (t >> 4) & 0x08610861; // 0x18e318e3 dpal[i] = t; } + // norm: xxx0, sh: 0xxx, hi: 0xxx + 7 if (sh) { // shadowed pixels - for (i = 0x3f; i >= 0; i--) - pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x738e); + for (i = 0; i < 0x40 / 2; i++) + dpal[0x40/2 | i] = dpal[0xc0/2 | i] = (dpal[i] >> 1) & 0x738e738e; // hilighted pixels - for (i = 0x3f; i >= 0; i--) { - t=pal[i]&0xe71c;t+=0x4208;if(t&0x20)t|=0x1c;if(t&0x800)t|=0x700;if(t&0x10000)t|=0xe000;t&=0xe71c; - pal[0x80|i]=(unsigned short)t; - } - } -} - -#if 0 -static void FinalizeLineBGR444(int sh, int line) -{ - unsigned short *pd=DrawLineDest; - unsigned char *ps=HighCol+8; - unsigned short *pal=Pico.cram; - int len, i, t, mask=0xff; - - if (Pico.video.reg[12]&1) { - len = 320; - } else { - if(!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32; - len = 256; - } - - if(sh) { - pal=HighPal; - if(Pico.m.dirtyPal) { - blockcpy(pal, Pico.cram, 0x40*2); - // shadowed pixels - for(i = 0x3f; i >= 0; i--) - pal[0x40|i] = pal[0xc0|i] = (unsigned short)((pal[i]>>1)&0x0777); - // hilighted pixels - for(i = 0x3f; i >= 0; i--) { - t=pal[i]&0xeee;t+=0x444;if(t&0x10)t|=0xe;if(t&0x100)t|=0xe0;if(t&0x1000)t|=0xe00;t&=0xeee; - pal[0x80|i]=(unsigned short)t; - } - Pico.m.dirtyPal = 0; + for (i = 0; i < 0x40 / 2; i++) { + t = ((dpal[i] >> 1) & 0x738e738e) + 0x738e738e; // 0x7bef7bef; + t |= (t >> 4) & 0x08610861; + dpal[0x80/2 | i] = t; } } - - if (!sh && (rendstatus & PDRAW_SPR_LO_ON_HI)) - mask=0x3f; // accurate sprites - - for(i = 0; i < len; i++) - pd[i] = pal[ps[i] & mask]; } -#endif - void FinalizeLine555(int sh, int line) { @@ -1421,11 +1384,6 @@ PICO_INTERNAL void PicoFrameStart(void) lines = 240; } - HighCol = HighColBase; - DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; - DrawScanline = 0; - skip_next_line = 0; - if (rendstatus != rendstatus_old || lines != rendlines) { rendlines = lines; // mode_change() might reset rendstatus_old by calling SetColorFormat @@ -1434,6 +1392,11 @@ PICO_INTERNAL void PicoFrameStart(void) rendstatus_old = rendstatus; } + HighCol = HighColBase + offs * HighColIncrement; + DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; + DrawScanline = 0; + skip_next_line = 0; + if (PicoOpt & POPT_ALT_RENDERER) return; @@ -1454,6 +1417,9 @@ static void DrawBlankedLine(int line, int offs, int sh, int bgc) if (PicoScanEnd != NULL) PicoScanEnd(line + offs); + + HighCol += HighColIncrement; + DrawLineDest = (char *)DrawLineDest + DrawLineDestIncrement; } static void PicoLine(int line, int offs, int sh, int bgc) @@ -1502,19 +1468,9 @@ void PicoDrawSync(int to, int blank_last_line) for (line = DrawScanline; line < to; line++) { -#if !CAN_HANDLE_240_LINES - if (line >= 224) break; -#endif PicoLine(line, offs, sh, bgc); } -#if !CAN_HANDLE_240_LINES - if (line >= 224) { - DrawScanline = 240; - return; - } -#endif - // last line if (line <= to) { @@ -1543,7 +1499,7 @@ void PicoDrawUpdateHighPal(void) } } -void PicoDrawSetOutFormat(pdso_t which, int allow_32x) +void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode) { switch (which) { @@ -1552,7 +1508,7 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x) break; case PDF_RGB555: - if ((PicoAHW & PAHW_32X) && allow_32x) + if ((PicoAHW & PAHW_32X) && use_32x_line_mode) FinalizeLine = FinalizeLine32xRGB555; else FinalizeLine = FinalizeLine555; @@ -1562,6 +1518,7 @@ void PicoDrawSetOutFormat(pdso_t which, int allow_32x) FinalizeLine = NULL; break; } + PicoDrawSetOutFormat32x(which, use_32x_line_mode); PicoDrawSetOutputMode4(which); rendstatus_old = -1; } @@ -1571,7 +1528,7 @@ void PicoDrawSetOutBuf(void *dest, int increment) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; - DrawLineDest = DrawLineDestBase + DrawScanline * increment; + DrawLineDest = (unsigned char*)DrawLineDestBase + DrawScanline * increment; } void PicoDrawSetInternalBuf(void *dest, int increment) @@ -1587,3 +1544,19 @@ void PicoDrawSetInternalBuf(void *dest, int increment) } } +void PicoDrawSetCallbacks(int (*begin)(unsigned int num), int (*end)(unsigned int num)) +{ + PicoScanBegin = NULL; + PicoScanEnd = NULL; + PicoScan32xBegin = NULL; + PicoScan32xEnd = NULL; + + if ((PicoAHW & PAHW_32X) && FinalizeLine != FinalizeLine32xRGB555) { + PicoScan32xBegin = begin; + PicoScan32xEnd = end; + } + else { + PicoScanBegin = begin; + PicoScanEnd = end; + } +}