The spec doesn't require that FRAME_BEGIN, REGION, TILESET, and FRAME_END come all in one chunk. This patch adds the necessary state saving. A unitary test is also added.