I don't understand the use of foreground sprite. When we modify a sprite, we have access to background and foreground in editor. But with map() and spr() it is always the background part that is displayed. So what is the use of foreground?
The background sprites are used for the map editor, the map only uses sprites from index 0 to 255. The foreground is an extra sprite layer that can be used with spr() function. With spr() you can show sprites from 0 to 511, which 0 to 255 are from background and 256 to 511 are from foreground.