-
Notifications
You must be signed in to change notification settings - Fork 34
Home
Welcome to the devkitSMS wiki! How devkitSMS/SMSlib works. A small journey into functions and functionalities.
The SEGA Master System and its portable brother, the SEGA Game Gear, are 8-bit machines powered by two hearts. One heart is the Zilog Z80 processor, while the other is a custom graphic chip (derived from the Texas Instruments TMS9918) that handles everything that's on-screen: it's called the 'Video Display Processor', or VDP for short. (Different Master System models can have different VDP revisions with different features, and the Game Gear one also has few differences. But as long as we're concerned we can consider them all equal, there will be a special note when necessary.)
The VDP works by redrawing the screen top to bottom 50 or 60 times a second, according to television type. 192 lines of pixels (scanline) will be on screen in any case, and each line will be 256 pixel wide, making the image resolution 256x192 pixel. The pixels will use colors in two 16-color palettes, one reserved for background tiles and one that can be used both for sprites and background tiles. This also means that all the sprites will share the same 16-color palette.
The background is made up of 16-color 8x8 pixel tiles. Both tiles and tilemap (the map which describes how tiles should be placed on-screen) need to be loaded into Video RAM (VRAM). Tilemap is a single 32x28 table where each entry contains information about which tile should be used, which palette, and if sprites are supposed to appear behind that tile or in front of it. VRAM size is 16KB and it also contains the Sprite Attribute Table (SAT).
Sprites are made of 16-color 8x8 pixel tiles too, but they can be placed anywhere on screen. The VDP supports up to 64 of them at the same time, even if won't draw more than 8 of them on any given scanline. Their positions and images (the tiles used) are stored into SAT, which is again allocated into VRAM. VRAM is big enough to theoretically contain up to 512 tiles, but only tiles defined into either the 1st or the 2nd half of VRAM can be used.