- int mzx=ZD[w].mzx;
-
- if(line==0) ZD[w].colok=1<<16; /* Disable it. */
-
- ZD[w].coloklast=ZD[w].colok;
-
- if(ZD[w].mzb&2) return;
- if((line>=ZD[w].mzy-3 && line<=ZD[w].mzy+3) && mzx<256)
- {
- int a,sum,x;
-
- for(x=-4;x<4;x++)
- {
- if((mzx+x)<0 || (mzx+x)>255) continue;
- a=buf[mzx+x]&63;
- sum=palo[a].r+palo[a].g+palo[a].b;
-
- if(sum>=100*3)
- {
- ZD[w].colok=timestamp+mzx/3;
- break;
- }
- }
- }
-
+ int xs,xe;
+ int zx,zy;
+
+ if(!bg) // New line, so reset stuff.
+ {
+ ZD[w].zappo=0;
+ return;
+ }
+ xs=ZD[w].zappo;
+ xe=final;
+
+ zx=ZD[w].mzx;
+ zy=ZD[w].mzy;
+
+ if(xe>256) xe=256;
+
+ if(scanline>=(zy-4) && scanline<=(zy+4))
+ {
+ while(xs<xe)
+ {
+ uint8 a1,a2;
+ uint32 sum;
+ if(xs<=(zx+4) && xs>=(zx-4))
+ {
+ a1=bg[xs];
+ if(spr)
+ {
+ a2=spr[xs];
+
+ if(!(a2&0x80))
+ if(!(a2&0x40) || (a1&64))
+ a1=a2;
+ }
+ a1&=63;
+
+ sum=palo[a1].r+palo[a1].g+palo[a1].b;
+ if(sum>=100*3)
+ {
+ ZD[w].zaphit=((uint64)linets+(xs+16)*(PAL?15:16))/48+timestampbase;
+ goto endo;
+ }
+ }
+ xs++;
+ }
+ }
+ endo:
+ ZD[w].zappo=final;