-
- int n,sprindex;
- SPRB *spr;
- uint8 *P=target;
-
- //if (printed) { printf("SPRB: %d SPR: %d\n", sizeof(SPRB), sizeof(SPR)); printed=0; }
- if(!numsprites) return;
-
- FCEU_dwmemset(sprlinebuf,0x80808080,256);
-
- numsprites--;
- sprindex=numsprites;
- spr = (SPRB*)SPRBUF;
-
- // for(n=nosprites;n>=0;n--,spr--)
- for(n=numsprites;n>=0;n--,sprindex--)
- {
- uint8 J,atr,c1,c2;
- int x=spr[sprindex].x;
- uint8 *C;
- uint8 *VB;
-
- P+=x;
-
- c1=((spr[sprindex].ca[0]>>1)&0x55)|(spr[sprindex].ca[1]&0xAA);
- c2=(spr[sprindex].ca[0]&0x55)|((spr[sprindex].ca[1]<<1)&0xAA);
-
- J=spr[sprindex].ca[0]|spr[sprindex].ca[1];
- atr=spr[sprindex].atr;
-
- if(J)
- {
- if(n==0 && SpriteBlurp && !(PPU_status&0x40))
- {
- int z,ze=x+8;
- if(ze>256) {ze=256;}
- if(ScreenON && (scanline<FSettings.FirstSLine || scanline>FSettings.LastSLine
- #ifdef FRAMESKIP
- || FSkip
- #endif
- ))
- // nothing wrong with this
- BGRender(target);
-
- if(!(atr&H_FLIP))
- {
- for(z=x;z<ze;z++)
- {
- if(J&(0x80>>(z-x)))
- {
- if(!(target[z]&64))
- tosprite=z;
- }
- }
- }
- else
- {
- for(z=x;z<ze;z++)
- {
- if(J&(1<<(z-x)))
- {
- if(!(target[z]&64))
- tosprite=z;
- }
- }
- }
- //FCEU_DispMessage("%d, %d:%d",scanline,x,tosprite);
- }
-
- //C = sprlinebuf+(uint8)x;
- C = &(sprlinebuf[(uint8)x]);
- VB = (PALRAM+0x10)+((atr&3)<<2);
-
- if(atr&SP_BACK)
- {
- if (atr&H_FLIP)
- {
- if (J&0x02) C[1]=VB[c1&3]|0x40;
- if (J&0x01) *C=VB[c2&3]|0x40;
- c1>>=2;c2>>=2;
- if (J&0x08) C[3]=VB[c1&3]|0x40;
- if (J&0x04) C[2]=VB[c2&3]|0x40;
- c1>>=2;c2>>=2;
- if (J&0x20) C[5]=VB[c1&3]|0x40;
- if (J&0x10) C[4]=VB[c2&3]|0x40;
- c1>>=2;c2>>=2;
- if (J&0x80) C[7]=VB[c1]|0x40;
- if (J&0x40) C[6]=VB[c2]|0x40;
- } else {
- if (J&0x02) C[6]=VB[c1&3]|0x40;
- if (J&0x01) C[7]=VB[c2&3]|0x40;
- c1>>=2;c2>>=2;
- if (J&0x08) C[4]=VB[c1&3]|0x40;
- if (J&0x04) C[5]=VB[c2&3]|0x40;
- c1>>=2;c2>>=2;
- if (J&0x20) C[2]=VB[c1&3]|0x40;
- if (J&0x10) C[3]=VB[c2&3]|0x40;
- c1>>=2;c2>>=2;
- if (J&0x80) *C=VB[c1]|0x40;
- if (J&0x40) C[1]=VB[c2]|0x40;
- }
- } else {
- if (atr&H_FLIP)
- {
- if (J&0x02) C[1]=VB[(c1&3)];
- if (J&0x01) *C=VB[(c2&3)];
- c1>>=2;c2>>=2;
- if (J&0x08) C[3]=VB[(c1&3)];
- if (J&0x04) C[2]=VB[(c2&3)];
- c1>>=2;c2>>=2;
- if (J&0x20) C[5]=VB[(c1&3)];
- if (J&0x10) C[4]=VB[(c2&3)];
- c1>>=2;c2>>=2;
- if (J&0x80) C[7]=VB[c1];
- if (J&0x40) C[6]=VB[c2];
- }else{
- if (J&0x02) C[6]=VB[(c1&3)];
- if (J&0x01) C[7]=VB[(c2&3)];
- c1>>=2;c2>>=2;
- if (J&0x08) C[4]=VB[(c1&3)];
- if (J&0x04) C[5]=VB[(c2&3)];
- c1>>=2;c2>>=2;
- if (J&0x20) C[2]=VB[(c1&3)];
- if (J&0x10) C[3]=VB[(c2&3)];
- c1>>=2;c2>>=2;
- if (J&0x80) *C=VB[c1];
- if (J&0x40) C[1]=VB[c2];
- }
- }
- }
- P-=x;
- }
-
- numsprites=0;
- #ifdef FRAMESKIP
- if(FSkip) return;
- #endif
-
- {