sprite masking fixed according to Lordus expl.
[picodrive.git] / Pico / Draw.c
index 4572710..0d7f89b 100644 (file)
@@ -194,7 +194,7 @@ static int TileNormZ(int sx,int addr,int pal,int zval)
 \r
   return 1; // Tile blank\r
 }\r
-                                              \r
+\r
 static int TileFlipZ(int sx,int addr,int pal,int zval)\r
 {\r
   unsigned int pack=0; unsigned int t=0;\r
@@ -1096,8 +1096,6 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
   {\r
     int sx, sy, row, pack2;\r
 \r
-    elprintf(EL_ANOMALY, "x: %i y: %i %ix%i", pack2>>16, (pack<<16)>>16, (pack>>28)<<3, (pack>>21)&0x38);\r
-\r
     if (pack & 0x00400000) continue;\r
 \r
     // get sprite info\r
@@ -1106,11 +1104,20 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
     sy = (pack <<16)>>16;\r
     row = scan-sy;\r
 \r
+    // elprintf(EL_ANOMALY, "x: %4i y: %4i p %i %ix%i", sx, sy, (pack2>>15)&1, (pack>>28)<<3, (pack>>21)&0x38);\r
+\r
     if (sx == -0x77) sx1seen|=1; // for masking mode 2\r
 \r
     // check if it is on this line\r
     if (row < 0 || row >= ((pack>>21)&0x38)) continue; // no\r
-    n++; // number of sprites on this line (both visible and hidden, max is 20)\r
+\r
+    // masking sprite?\r
+    if (sx == -0x78) {\r
+      if (n > 0) break; // masked\r
+      continue;\r
+    }\r
+\r
+    n++; // number of sprites on this line (both visible and hidden, except of x=0)\r
 \r
     // sprite limit\r
     ntiles += pack>>28;\r
@@ -1118,21 +1125,6 @@ static void DrawAllSprites(int *hcache, int maxwidth, int prio, int sh)
 \r
     if (pack & 0x00800000) continue;\r
 \r
-    // masking sprite?\r
-    if (sx == -0x78) {\r
-      if(!(sx1seen&1) || sx1seen==3) {\r
-        break; // this sprite is not drawn and remaining sprites are masked\r
-      }\r
-      if((sx1seen>>8) == 0) sx1seen=(i+1)<<8;\r
-      continue;\r
-    }\r
-    else if (sx == -0x77) {\r
-      // masking mode2 (Outrun, Galaxy Force II, Shadow of the beast)\r
-      if(sx1seen>>8) { i=(sx1seen>>8)-1; break; } // seen both 0 and 1\r
-      sx1seen |= 2;\r
-      continue;\r
-    }\r
-\r
     // accurate sprites\r
     //dprintf("P:%i",((sx>>15)&1));\r
     if (rs & PDRAW_ACC_SPRITES) {\r