BBC Maps

The BBC Micro builds game worlds from tiles. Because it has no map hardware, a map is an array of tile codes the program copies to the screen, each code standing for a small block of pixels. The blocks are usually redefined characters or byte tables plotted into the bitmap, and the whole screen is assembled from them.

BBC Maps

Overview

A map is a grid of small cells, each named by a code. The codes are far smaller than the pixels they stand for, so a large level fits in little memory: one byte per cell instead of a full bitmap. To show part of the map, the program reads the codes for the visible area and draws each cell's block at the matching screen position. This tile approach keeps levels compact and lets the same few blocks build endless layouts.

Tiles and characters

A tile is a small fixed block of pixels. The simplest tiles are redefined characters: in MODE 1, 2 or 5 a set of VDU 23 shapes gives a library of 8×8 blocks, each printed by writing its character code. For larger or multi-colour tiles the program stores its own byte tables and plots them straight into the bitmap. Either way, every distinct tile has a code, and the map refers to tiles only by that code.

Tile sourceSizeDrawn by
Redefined character8 × 8Printing its code
Byte tableAny multiple of a cellCopying into screen RAM

The map array

The map itself is a two-dimensional array of tile codes, one code per cell, stored row by row. A cell at map column mx, map row my is found at base + my * width + mx, and the byte there is the tile code to draw. The array can be far wider and taller than the screen, holding a whole level, while the screen shows a window into it.

ElementMeaning
CellOne tile code, usually a byte
Rowwidth codes, left to right
Arrayheight rows, top to bottom

Drawing the map

To paint the screen the program walks the visible window of the array. For each cell it reads the tile code, looks up the tile's pixels, and writes them to the screen at the cell's position. With character tiles this is a move of the text cursor and a print; with byte tables it is a copy into screen RAM using the cell-based address layout. A full redraw touches every visible cell, so games redraw only the cells that changed when they can.

Scrolling

There are two ways to move the view across a large map. The first is to redraw: shift the window over the array by one column or row and repaint the tiles, cheap when tiles are small and only the new edge changes. The second is hardware scroll: the 6845 holds the address where the screen starts, so writing a new start value shifts the whole display without copying pixels. Coarse hardware scroll moves in whole character rows very cheaply, and new tiles are drawn only into the row or column that scrolls into view.

MethodCostGranularity
RedrawRepaint changed cellsAny step
Hardware scrollChange 6845 start addressWhole character rows