I am pretty sure that you need to call bmap_zbuffer _after_ setting the video resolution. That means you call it always after F5, not before, otherwise the zbuffer size is reset to the selected resolution. But I'll look into this to make 100% sure.