#else\r
unsigned char HighCol[8+320+8];\r
#endif\r
-unsigned short DefOutBuff[320*2];\r
+static unsigned int DefOutBuff[320*2/2];\r
void *DrawLineDest=DefOutBuff; // pointer to dest buffer where to draw this line to\r
\r
static int HighCacheA[41+1]; // caches for high layers\r
#define SPRL_LO_ABOVE_HI 0x10 // low priority sprites may be on top of hi\r
unsigned char HighLnSpr[240][3 + MAX_LINE_SPRITES]; // sprite_count, ^flags, tile_count, [spritep]...\r
\r
-int rendstatus = 0;\r
-int DrawScanline = 0;\r
+int rendstatus, rendstatus_old;\r
+int DrawScanline;\r
int PicoDrawMask = -1;\r
\r
static int skip_next_line=0;\r
// stuff available in asm:\r
#ifdef _ASM_DRAW_C\r
void DrawWindow(int tstart, int tend, int prio, int sh);\r
-void BackFill(int reg7, int sh);\r
void DrawAllSprites(unsigned char *sprited, int prio, int sh);\r
void DrawTilesFromCache(int *hc, int sh, int rlim);\r
void DrawSpritesSHi(unsigned char *sprited);\r
void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells);\r
void FinalizeLineBGR444(int sh);\r
-void FinalizeLineRGB555(int sh);\r
void *blockcpy(void *dst, const void *src, size_t n);\r
void blockcpy_or(void *dst, void *src, size_t n, int pat);\r
#else\r
\r
// --------------------------------------------\r
\r
-static void BackFill(int reg7, int sh)\r
+void BackFill(int reg7, int sh)\r
{\r
unsigned int back;\r
\r
#ifndef _ASM_DRAW_C\r
void PicoDoHighPal555(int sh)\r
{\r
+ unsigned int *spal, *dpal;\r
unsigned short *pal=HighPal;\r
int i, t;\r
\r
Pico.m.dirtyPal = 0;\r
\r
- {\r
- unsigned int *spal=(void *)Pico.cram;\r
- unsigned int *dpal=(void *)HighPal;\r
- for (i = 0x3f/2; i >= 0; i--)\r
+ spal = (void *)Pico.cram;\r
+ dpal = (void *)HighPal;\r
+\r
+ for (i = 0; i < 0x40; i++) {\r
+ unsigned int t = spal[i];\r
#ifdef USE_BGR555\r
- dpal[i] = ((spal[i]&0x000f000f)<< 1)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)<<4);\r
+ t = ((t & 0x000e000e)<< 1) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)<<4);\r
#else\r
- dpal[i] = ((spal[i]&0x000f000f)<<12)|((spal[i]&0x00f000f0)<<3)|((spal[i]&0x0f000f00)>>7);\r
+ t = ((t & 0x000e000e)<<12) | ((t & 0x00e000e0)<<3) | ((t & 0x0e000e00)>>7);\r
#endif\r
+ t |= (t >> 3) & 0x18e318e3;\r
+ dpal[i] = t;\r
}\r
\r
if (sh)\r
}\r
\r
\r
-static void FinalizeLineRGB555(int sh)\r
+void FinalizeLineRGB555(int sh)\r
{\r
unsigned short *pd=DrawLineDest;\r
unsigned char *ps=HighCol+8;\r
\r
static void FinalizeLine8bit(int sh)\r
{\r
- unsigned char *pd=DrawLineDest;\r
+ unsigned char *pd = DrawLineDest;\r
int len, rs = rendstatus;\r
static int dirty_count;\r
\r
- if (!sh && Pico.m.dirtyPal == 1 && DrawScanline < 222)\r
+ if (!sh && Pico.m.dirtyPal == 1)\r
{\r
// a hack for mid-frame palette changes\r
if (!(rs & PDRAW_SONIC_MODE))\r
if (Pico.video.reg[12]&1) {\r
len = 320;\r
} else {\r
- if (!(PicoOpt&POPT_DIS_32C_BORDER)) pd+=32;\r
+ if (!(PicoOpt & POPT_DIS_32C_BORDER))\r
+ pd += 32;\r
len = 256;\r
}\r
\r
}\r
}\r
\r
-static void (*FinalizeLine)(int sh) = FinalizeLineBGR444;\r
+static void (*FinalizeLine)(int sh);\r
\r
// --------------------------------------------\r
\r
-static void DrawBlankedLine(void)\r
-{\r
- int sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?\r
-\r
- if (PicoScanBegin != NULL)\r
- PicoScanBegin(DrawScanline);\r
-\r
- BackFill(Pico.video.reg[7], sh);\r
-\r
- if (FinalizeLine != NULL)\r
- FinalizeLine(sh);\r
-\r
- if (PicoScanEnd != NULL)\r
- PicoScanEnd(DrawScanline);\r
-}\r
-\r
static int DrawDisplay(int sh)\r
{\r
unsigned char *sprited = &HighLnSpr[DrawScanline][0];\r
rendstatus = 0;\r
if ((Pico.video.reg[12]&6) == 6)\r
rendstatus |= PDRAW_INTERLACE; // interlace mode\r
+ if (Pico.video.reg[1] & 8)\r
+ rendstatus |= PDRAW_240LINES;\r
+\r
+ DrawScanline = 0;\r
+ skip_next_line = 0;\r
+\r
+ if (rendstatus != rendstatus_old) {\r
+ rendstatus_old = rendstatus;\r
+ emu_video_mode_change((rendstatus & PDRAW_240LINES) ? 0 : 8,\r
+ (rendstatus & PDRAW_240LINES) ? 240 : 224,\r
+ (Pico.video.reg[12] & 1) ? 0 : 1);\r
+ }\r
\r
- if (Pico.m.dirtyPal) Pico.m.dirtyPal = 2; // reset dirty if needed\r
+ if (PicoOpt & POPT_ALT_RENDERER)\r
+ return;\r
\r
- DrawScanline=0;\r
+ if (Pico.m.dirtyPal)\r
+ Pico.m.dirtyPal = 2; // reset dirty if needed\r
PrepareSprites(1);\r
- skip_next_line=0;\r
}\r
\r
-static void PicoLine(void)\r
+static void DrawBlankedLine(int line, int offs)\r
+{\r
+ int sh = (Pico.video.reg[0xC]&8)>>3; // shadow/hilight?\r
+\r
+ if (PicoScanBegin != NULL)\r
+ PicoScanBegin(line + offs);\r
+\r
+ BackFill(Pico.video.reg[7], sh);\r
+\r
+ if (FinalizeLine != NULL)\r
+ FinalizeLine(sh);\r
+\r
+ if (PicoScanEnd != NULL)\r
+ PicoScanEnd(line + offs);\r
+}\r
+\r
+static void PicoLine(int line, int offs)\r
{\r
int sh;\r
- if (skip_next_line>0) { skip_next_line--; return; } // skip rendering lines\r
+ if (skip_next_line > 0) {\r
+ skip_next_line--;\r
+ return;\r
+ }\r
\r
sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?\r
\r
+ DrawScanline = line;\r
if (PicoScanBegin != NULL)\r
- skip_next_line = PicoScanBegin(DrawScanline);\r
+ skip_next_line = PicoScanBegin(line + offs);\r
\r
// Draw screen:\r
BackFill(Pico.video.reg[7], sh);\r
FinalizeLine(sh);\r
\r
if (PicoScanEnd != NULL)\r
- skip_next_line = PicoScanEnd(DrawScanline);\r
+ skip_next_line = PicoScanEnd(line + offs);\r
}\r
\r
void PicoDrawSync(int to, int blank_last_line)\r
{\r
- for (; DrawScanline < to; DrawScanline++)\r
+ int line, offs = 0;\r
+\r
+ if (!(rendstatus & PDRAW_240LINES))\r
+ offs = 8;\r
+\r
+ for (line = DrawScanline; line < to; line++)\r
{\r
#if !CAN_HANDLE_240_LINES\r
- if (DrawScanline >= 224) break;\r
+ if (line >= 224) break;\r
#endif\r
- PicoLine();\r
+ PicoLine(line, offs);\r
}\r
\r
#if !CAN_HANDLE_240_LINES\r
- if (DrawScanline >= 224) { DrawScanline = 240; return; }\r
+ if (line >= 224) {\r
+ DrawScanline = 240;\r
+ return;\r
+ }\r
#endif\r
\r
// last line\r
- if (DrawScanline <= to)\r
+ if (line <= to)\r
{\r
if (blank_last_line)\r
- DrawBlankedLine();\r
- else PicoLine();\r
- DrawScanline++;\r
+ DrawBlankedLine(line, offs);\r
+ else PicoLine(line, offs);\r
+ line++;\r
}\r
+ DrawScanline = line;\r
}\r
\r
void PicoDrawSetColorFormat(int which)\r
case 0: FinalizeLine = FinalizeLineBGR444; break;\r
default:FinalizeLine = NULL; break;\r
}\r
+ PicoDrawSetColorFormatMode4(which);\r
#if OVERRIDE_HIGHCOL\r
- if (which) HighCol=DefHighCol;\r
+ if (which)\r
+ HighCol=DefHighCol;\r
#endif\r
}\r
\r