int *HighCacheS_ptr;\r
\r
int rendstatus = 0;\r
-int Scanline = 0; // Scanline\r
+int DrawScanline = 0;\r
\r
static int SpriteBlocks;\r
static int skip_next_line=0;\r
{\r
int tilex,dx,code=0,addr=0,cell=0;\r
int oldcode=-1,blank=-1; // The tile we know is blank\r
- int pal=0,scan=Scanline;\r
+ int pal=0,scan=DrawScanline;\r
\r
// Draw tiles across screen:\r
tilex=(-ts->hscroll)>>3;\r
else ts.nametab=(pvid->reg[2]&0x38)<< 9; // A\r
\r
htab=pvid->reg[13]<<9; // Horizontal scroll table address\r
- if ( pvid->reg[11]&2) htab+=Scanline<<1; // Offset by line\r
+ if ( pvid->reg[11]&2) htab+=DrawScanline<<1; // Offset by line\r
if ((pvid->reg[11]&1)==0) htab&=~0xf; // Offset by tile\r
htab+=plane_sh&1; // A or B\r
\r
vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
\r
// Find the line in the name table\r
- ts.line=(vscroll+(Scanline<<1))&((ymask<<1)|1);\r
+ ts.line=(vscroll+(DrawScanline<<1))&((ymask<<1)|1);\r
ts.nametab+=(ts.line>>4)<<shift[width];\r
\r
DrawStripInterlace(&ts);\r
vscroll=Pico.vsram[plane_sh&1]; // Get vertical scroll value\r
\r
// Find the line in the name table\r
- ts.line=(vscroll+Scanline)&ymask;\r
+ ts.line=(vscroll+DrawScanline)&ymask;\r
ts.nametab+=(ts.line>>3)<<shift[width];\r
\r
DrawStrip(&ts, plane_sh, cellskip);\r
if (pvid->reg[12]&1)\r
{\r
nametab=(pvid->reg[3]&0x3c)<<9; // 40-cell mode\r
- nametab+=(Scanline>>3)<<6;\r
+ nametab+=(DrawScanline>>3)<<6;\r
}\r
else\r
{\r
nametab=(pvid->reg[3]&0x3e)<<9; // 32-cell mode\r
- nametab+=(Scanline>>3)<<5;\r
+ nametab+=(DrawScanline>>3)<<5;\r
}\r
\r
tilex=tstart<<1;\r
}\r
\r
tend<<=1;\r
- ty=(Scanline&7)<<1; // Y-Offset into tile\r
+ ty=(DrawScanline&7)<<1; // Y-Offset into tile\r
\r
// Draw tiles across screen:\r
if (!sh)\r
height=(sy>>24)&7; // Width and height in tiles\r
sy=(sy<<16)>>16; // Y\r
\r
- row=Scanline-sy; // Row of the sprite we are on\r
+ row=DrawScanline-sy; // Row of the sprite we are on\r
\r
if (code&0x1000) row=(height<<3)-1-row; // Flip Y\r
\r
width=(height>>2)&3; height&=3;\r
width++; height++; // Width and height in tiles\r
\r
- row=(Scanline<<1)-sy; // Row of the sprite we are on\r
+ row=(DrawScanline<<1)-sy; // Row of the sprite we are on\r
\r
code=sprite[1];\r
sx=((code>>16)&0x1ff)-0x78; // X\r
static void DrawAllSpritesInterlace(int *hcache, int maxwidth, int pri, int sh)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
- int i,u,table,link=0,sline=Scanline<<1;\r
+ int i,u,table,link=0,sline=DrawScanline<<1;\r
unsigned int *sprites[80]; // Sprite index\r
\r
table=pvid->reg[5]&0x7f;\r
// Go through sprites backwards:\r
for (i-- ;i>=0; i--)\r
DrawSpriteInterlace(sprites[i]);\r
+\r
+ HighCacheS[0] = 1; // just to fool main code\r
}\r
\r
\r
int ntiles = 0; // tile counter for sprite limit emulation\r
int *sprites[40]; // Sprites to draw in fast mode\r
int max_line_sprites = 20; // 20 sprites, 40 tiles\r
- int *ps, pack, rs = rendstatus, scan = Scanline;\r
+ int *ps, pack, rs = rendstatus, scan = DrawScanline;\r
\r
if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
//dprintf("PrepareSprites(%i) [%i]", (rs>>4)&1, scan);\r
int len, rs = rendstatus;\r
static int dirty_count;\r
\r
- if (!sh && !(rs & PDRAW_ACC_SPRITES) && Pico.m.dirtyPal == 1 && Scanline < 222)\r
+ if (!sh && !(rs & PDRAW_ACC_SPRITES) && Pico.m.dirtyPal == 1 && DrawScanline < 222)\r
{\r
// a hack for mid-frame palette changes\r
if (!(rs & PDRAW_SONIC_MODE))\r
\r
static void (*FinalizeLine)(int sh) = FinalizeLineBGR444;\r
\r
-// hblank was enabled early during prev line processng -\r
-// it should have been blanked\r
-static void handle_early_blank(int scanline, int sh)\r
+// --------------------------------------------\r
+\r
+static void DrawBlankedLine(void)\r
{\r
- scanline--;\r
+ int sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?\r
\r
if (PicoScanBegin != NULL)\r
- PicoScanBegin(scanline);\r
+ PicoScanBegin(DrawScanline);\r
\r
BackFill(Pico.video.reg[7], sh);\r
\r
FinalizeLine(sh);\r
\r
if (PicoScanEnd != NULL)\r
- PicoScanEnd(scanline);\r
+ PicoScanEnd(DrawScanline);\r
}\r
\r
-// --------------------------------------------\r
-\r
static int DrawDisplay(int sh, int as)\r
{\r
struct PicoVideo *pvid=&Pico.video;\r
win=pvid->reg[0x12];\r
edge=(win&0x1f)<<3;\r
\r
- if (win&0x80) { if (Scanline>=edge) hvwind=1; }\r
- else { if (Scanline< edge) hvwind=1; }\r
+ if (win&0x80) { if (DrawScanline>=edge) hvwind=1; }\r
+ else { if (DrawScanline< edge) hvwind=1; }\r
\r
if (!hvwind) { // we might have a vertical window here\r
win=pvid->reg[0x11];\r
int *c, a, b;\r
for (a = 0, c = HighCacheA; *c; c++, a++);\r
for (b = 0, c = HighCacheB; *c; c++, b++);\r
- printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count, Scanline, a, b);\r
+ printf("%i:%03i: a=%i, b=%i\n", Pico.m.frame_count, DrawScanline, a, b);\r
}\r
#endif\r
\r
\r
PrepareSprites(1);\r
skip_next_line=0;\r
+ DrawScanline=0;\r
}\r
\r
-PICO_INTERNAL int PicoLine(int scan)\r
+static void PicoLine(void)\r
{\r
int sh, as = 0;\r
- if (skip_next_line>0) { skip_next_line--; return 0; } // skip_next_line rendering lines\r
+ if (skip_next_line>0) { skip_next_line--; return; } // skip rendering lines\r
\r
- Scanline=scan;\r
sh=(Pico.video.reg[0xC]&8)>>3; // shadow/hilight?\r
if (rendstatus & PDRAW_ACC_SPRITES) as|=1; // accurate sprites\r
\r
- if (rendstatus & PDRAW_EARLY_BLANK) {\r
- if (scan > 0) handle_early_blank(scan, sh);\r
- rendstatus &= ~PDRAW_EARLY_BLANK;\r
- }\r
-\r
if (PicoScanBegin != NULL)\r
- skip_next_line = PicoScanBegin(scan);\r
+ skip_next_line = PicoScanBegin(DrawScanline);\r
\r
// Draw screen:\r
BackFill(Pico.video.reg[7], sh|as);\r
FinalizeLine(sh);\r
\r
if (PicoScanEnd != NULL)\r
- PicoScanEnd(scan);\r
-\r
- return 0;\r
+ PicoScanEnd(DrawScanline);\r
}\r
\r
+void PicoDrawSync(int to, int blank_last_line)\r
+{\r
+ for (; DrawScanline < to; DrawScanline++)\r
+ {\r
+#if !CAN_HANDLE_240_LINES\r
+ if (DrawScanline >= 224) break;\r
+#endif\r
+ PicoLine();\r
+ }\r
+\r
+#if !CAN_HANDLE_240_LINES\r
+ if (DrawScanline >= 224) DrawScanline = 240, return;\r
+#endif\r
+\r
+ // last line\r
+ if (DrawScanline <= to)\r
+ {\r
+ if (blank_last_line)\r
+ DrawBlankedLine();\r
+ else PicoLine();\r
+ DrawScanline++;\r
+ }\r
+}\r
\r
void PicoDrawSetColorFormat(int which)\r
{\r