unsigned char
. A “tile” corresponds to an area of the screen of fixed size, which can be reproduced over and over again. It is like a “box” with which the screen to be drawn is divided. The graphic data in this box is not stored “as is” on the screen bitmap but they are stored in a special memory area. Each box is then identified with a numerical index (offset) in that special area.
When the graphics chipset has to draw the screen, it examines the screen memory and it find a set of indices. The chipset then fetches the first index, it look for the bitmap data in the special area, it fetches the graphic data, and it uses the graphic data to draw that box on the screen. It then proceeds with the second, with the third, and so on. Up to cover the entire surface.
Once finished, the chipset waits for the next “vertical blank” (the moment when the hardware redraws a painting) to repeat the procedure.
Each retrocomputer has terminology for these areas, as well as the dimensions involved in the process.
For example, in the Commodore 64 we have that the surface consists of 320 by 200 pixels. The graphic data of this surface are stored as numerical indexes in the screen memory, which is called “text memory”. This area is made up of 1,000 numeric indexes (40 columns by 25 lines) which are called “screen codes”. Each screen code is nothing more than an index (offset) in the “charset memory”, whose dimensions are 8 by 8 pixels.
So, in other words, a tile in Commoodre 64 represent a letter of a text screen.
Editing a tile means changing its bitmap representation in the character memory. Each retrocomputer has a specific way of representing this information. In general, however, the basic way is to modify those bytes that graphically describe the character and that are identified by the screen code.
For example, in both the Commodore 64 and the VIC = 20 each 8×8 pixel box is represented as a series of 8 consecutive bytes in the character memory. In each byte, the most significant bit is the leftmost pixel on the screen, while the least significant bit is the rightmost pixel.
In C language this means that the square above is represented by the following vector of mr_mixel
1):
mr_mixel square [8] = { 0x00, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0x00 }
It follows that the modification of the tile consists in copying these bytes in the character memory: the modification on the screen will be instantaneous.
The single tile is usually too small to represent, graphically, something complete. Also, the video chipset needs to know, in advance, all the graphics data for ALL the potential possible indices in the video memory.
For this reason, the special memory area with the bitmap data for each tile is usually populated for all possible values of the screen codes, and it is possibly manipulated later by working on a single tile. This implies that, in general, we do not think usually in term of a single tile but for a set of tiles that takes the name of “tile set” (mr_tileset
2))
Again and by convention the tile set is usually implemented as a contiguous series of tiles, with no limit of continuity between one and the other.
For example, in the case of Commodore 64 and VIC=20, knowing the height and width in pixels of each tile, the starting address can be identified with the bitmap data of any screen code s
with the following expression:
START + s * 8
Where START
is the starting address from which the graphics chipset is taking data.
So although it is possible to have multiple tilesets in memory, depending on the characteristics of the retrocomputer and the memory resources available (more info here), only one tileset is visible at any given time. The visible tileset changes the appearance of the entire screen.
In addition to visible tilesets, system tilesets or “rom tilesets” must be mentioned. These are tilesets that are loaded at the start of the system, or made available immediately after boot, being in ROM. These tilesets are indispensable for interacting with the computer, since they also contain the alphabet that is used to render the texts on the screen.
The importance of these tilesets lies in the fact that, usually, they are copied “as is” to a special space by means of special routines and allow to avoid reprogramming, for example, semigraphic characters or alphabetic letters.
unsigned char
. unsigned char
; usually it is used in conjunction with mr_tile
and mr_mixel
by means of the macro TM(…)
, used in order to identify the beginning of the area where the redefined tiles are located