scroll size improvement
[picodrive.git] / pico / draw.c
index 9ad32da..2aa37f8 100644 (file)
@@ -394,8 +394,11 @@ static void DrawLayer(int plane_sh, int *hcache, int cellskip, int maxcells,
 \r
   ts.xmask=(1<<shift[width])-1; // X Mask in tiles (0x1f-0x7f)\r
   ymask=(height<<8)|0xff;       // Y Mask in pixels\r
-  if(width == 1)   ymask&=0x1ff;\r
-  else if(width>1) ymask =0x0ff;\r
+  switch (width) {\r
+    case 1: ymask &= 0x1ff; break;\r
+    case 2: ymask =  0x007; break;\r
+    case 3: ymask =  0x0ff; break;\r
+  }\r
 \r
   // Find name table:\r
   if (plane_sh&1) ts.nametab=(pvid->reg[4]&0x07)<<12; // B\r
@@ -954,7 +957,7 @@ static void DrawSpritesHiAS(unsigned char *sprited, int sh)
 // Index + 0  :    hhhhvvvv ----hhvv yyyyyyyy yyyyyyyy // v, h: vert./horiz. size\r
 // Index + 4  :    xxxxxxxx xxxxxxxx pccvhnnn nnnnnnnn // x: x coord + 8\r
 \r
-void PrepareSprites(int full)\r
+static NOINLINE void PrepareSprites(int full)\r
 {\r
   const struct PicoVideo *pvid=&Pico.video;\r
   const struct PicoEState *est=&Pico.est;\r
@@ -1117,16 +1120,9 @@ found:;
 static void DrawAllSprites(unsigned char *sprited, int prio, int sh,\r
                            struct PicoEState *est)\r
 {\r
-  int rs = est->rendstatus;\r
   unsigned char *p;\r
   int cnt;\r
 \r
-  if (rs & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
-    //elprintf(EL_STATUS, "PrepareSprites(%i)", (rs>>4)&1);\r
-    PrepareSprites(rs & PDRAW_DIRTY_SPRITES);\r
-    est->rendstatus = rs & ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
-  }\r
-\r
   cnt = sprited[0] & 0x7f;\r
   if (cnt == 0) return;\r
 \r
@@ -1288,6 +1284,12 @@ static int DrawDisplay(int sh)
   int win=0,edge=0,hvwind=0;\r
   int maxw,maxcells;\r
 \r
+  if (est->rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES)) {\r
+    // elprintf(EL_STATUS, "PrepareSprites(%i)", (est->rendstatus>>4)&1);\r
+    PrepareSprites(est->rendstatus & PDRAW_DIRTY_SPRITES);\r
+    est->rendstatus &= ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES);\r
+  }\r
+\r
   est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO);\r
 \r
   if (pvid->reg[12]&1) {\r
@@ -1331,7 +1333,7 @@ static int DrawDisplay(int sh)
     DrawLayer(0|(sh<<1), HighCacheA, 0, maxcells, est);\r
   /* - sprites low - */\r
   if (!(PicoDrawMask & PDRAW_SPRITES_LOW_ON));\r
-  else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
+  else if (est->rendstatus & PDRAW_INTERLACE)\r
     DrawAllSpritesInterlace(0, sh);\r
   else if (sprited[1] & SPRL_HAVE_LO)\r
     DrawAllSprites(sprited, 0, sh, est);\r
@@ -1352,7 +1354,7 @@ static int DrawDisplay(int sh)
       DrawTilesFromCache(HighCacheA, sh, maxw, est);\r
   /* - sprites hi - */\r
   if (!(PicoDrawMask & PDRAW_SPRITES_HI_ON));\r
-  else if (Pico.est.rendstatus & PDRAW_INTERLACE)\r
+  else if (est->rendstatus & PDRAW_INTERLACE)\r
     DrawAllSpritesInterlace(1, sh);\r
   // have sprites without layer pri bit ontop of sprites with that bit\r
   else if ((sprited[1] & 0xd0) == 0xd0 && (PicoOpt & POPT_ACC_SPRITES))\r