Week 4 — Show me the World

Overview

  • Map rendering
  • Improving dialog handling

Unfortunately the map rendering kept breaking so there’s no video of it right now. While there are improvements in other areas like the dialog handling, the map renderer blocked me for most of the week.
Below I describe the structure of the MAZE.CMP file that stores static background tiles and how it is used.

Details

struct Map { // MAZE.CMP
    byte tileIndex[128][20]
    byte subTileIndex[146][64]
    byte bitmap[1832][32]
}

Compared to sprites from animation files (discussed in Week 2) the static background is composed of tiles from MAZE.CMP. Those tiles in turn are made of subtiles of 8×8 to save space by assembling the bigger tiles of the smaller ones. So the tileIndex are offsets into subTileIndex that again are offsets to the 8×8 pixel data in bitmap.

On every frame an indexMap is generated of the currently visible subtiles. The reason is not only for caching but for clipping tiles (that’s what kAnimationShadow* are for) and general tile manipulation depending on game state.

34×18 tiles are shown at a time on screen. There will be overdraw as the viewport is only 256×128 but it doesn’t matter as the video buffer is 320×200 and it is clipped off by the frame border in the end. Currently my implementation draws the frame border first for “clearing” the screen as it was convenient to just blit the fullscreen image without the need for transparency.

Next Week

The most urgent feature right now is renderering the map. Not only does it help to visually convey the progress better but other features like player movement, rendering of NPCs, Objects, animation of static objects like torches, collision, … depend on it. Besides that, the definitions for the all objects, … will need to be ported over as well.