Depending on the position, the background-sprite overlap algorithm might fail (left) or do just fine (right). Mind you, when it fails it’s just one pixel off along the horizontal direction. This is what I would like to fix next in LN.
The way this overlapping stuff works is rather simple from a high level viewpoint. Some locations have graphic elements (wall, pillar, etc) for which sprites have to create the illusion they are behind those elements. The way this is achieved is by blanking out portions of the sprite based on its position within the location, using the element’s bitmap data as a delete-mask. A sprite->graphic coordinate transformation has to take place before a comparison can occur between homogeneous coordinates. Being this an isometric system, there is a depth factor, but that is worked out of the X-Y coordinates of the sprite.
I think the bug is in the bit masking: the delete-mask offsets are valid for a multicolour environment where the “granularity” of pixels is 2 in width. Hence the overlapping will work for a certain position of the sprite, but not if you move it 1 pixel left or right from there.