Deduplicated code from draw_layers to draw_tile