The difficulty is that there is no BGCOL or similar command. However, you can detect if a sprite's home is in a BG tile with BGGET(LAYER,SPX/16,SPY/16)==0, though this changes if you use BGOFS.