added pal behavior with secondary palette and reset, fixed map layering mask, fixed tile map address computation