Name | VDP_TMS9918A_MSXBIOS |
Architecture | MSX |
Environment | ROM, MSX BASIC |
Format | SDCC Relocatable object file (.rel) |
Programming language | C and Z80 assembler |
Compiler | SDCC v4.4 or newer |
C function library for working with the TMS9918A/28A/29A video processor.
This library contains a collection of functions for basic access to VDP capabilities, such as: initializing display modes, accessing registers, accessing video memory, and displaying sprites.
It uses MSX BIOS functions, so it is designed to develop applications in ROM or MSXBASIC environments, using the Small Device C Compiler (SDCC) cross compiler.
The advantage of using the BIOS is that the library is more compact and guarantees compatibility with all MSX models, but it has the disadvantage of being slow.
It also has an alternative library, VDP_TMS9918A, where all functions are programmed without using the MSX BIOS. It is optimized to offer good performance with the VDP TMS9918A, especially for functions that work with VRAM. It is designed for environments such as DOS or 48K ROMs, where direct access to the BIOS is not available (it is slower), although it is advisable for any environment that requires optimal access to VRAM.
You can complement it with any of these libraries:
- VDP_PRINT Library with functions for display text strings in the graphic modes of the TMS9918A (Graphic1 and Graphic2).
- VDP_SPRITES Library with functions for directly accessing sprite attributes from the TMS9918A video processor.
You can access the documentation here with How to use the library
.
These libraries are part of the MSX fR3eL Project.
This project is open source under the MIT license. You can add part or all of this code in your application development or include it in other libraries/engines.
Enjoy it!
(dd/mm/yyyy)
- v1.5 (22/07/2025) Changes for the new version of the VDP_SPRITES library.
- Added GetSPRattrVRAM function.
- Added GetSpritePattern routine for Assembler Inline.
- Added ReadByteFromVRAM and WriteByteToVRAM labels for Assembler Inline.
- v1.4 (12/06/2025)
- Added PUTSPRITE function.
- v1.3 ( 1/12/2023) Update to SDCC (4.1.12) Z80 calling conventions.
- v1.2 (22/12/2020) Conversion to source in C and added Sprite initialization functions.
- v1.1 (14/02/2014)
- v1.0 (11/02/2014)
Name | Declaration | Output | Description |
---|---|---|---|
SCREEN | SCREEN(mode) |
--- | Initializes the display |
COLOR | COLOR(ink, background, border) |
--- | Set the foreground, background, and border screen colors |
CLS | CLS() |
--- | Clear Screen. Fill VRAM Name Table with the value 0 |
Name | Declaration | Output | Description |
---|---|---|---|
GetVDP | GetVDP(reg) |
char |
Gets the value in a VDP register. Provides the mirror value stored in system variables |
SetVDP | SetVDP(reg, value) |
--- | Writes a value to a VDP register |
Name | Declaration | Output | Description |
---|---|---|---|
VPOKE | VPOKE(vaddr, value) |
--- | Writes a value to VRAM |
VPEEK | VPEEK(vaddr) |
char |
Reads a value from VRAM |
FillVRAM | FillVRAM(vaddr, size, value) |
--- | Fills an area of VRAM with the same value |
CopyToVRAM | CopyToVRAM(addr, vaddr, size) |
--- | Block transfer from memory to VRAM |
CopyFromVRAM | CopyFromVRAM(vaddr, addr, size) |
--- | Block transfer from VRAM to memory |
Name | Declaration | Output | Description |
---|---|---|---|
SetSpritesSize | SetSpritesSize(size) |
--- | Set size type for the sprites |
SetSpritesZoom | SetSpritesZoom(zoom) |
--- | Set zoom type for the sprites |
ClearSprites | ClearSprites() |
--- | Initialises the Sprite Attribute Table (OAM) |
PUTSPRITE | PUTSPRITE(plane, x, y, color, pattern) |
--- | Displays a sprite |
GetSPRattrVRAM | GetSPRattrVRAM(plane) |
unsigned int |
Gets the address in video memory of the Sprite attributes of specified plane |
The project includes several examples that I have used to test the library and that can help you learn how to use this library.
You can find them in the examples/
folder.
Example included in the HOWTO document.
This example tests all of the library's functions in the four screen modes of the TMS9918A. Test the functionality of the library in a system environment for ROM (BIOS+ROM+RAM+RAM).
- Texas Instruments TMS9918A application manual
PDF
- Texas Instruments VDP Programmer’s Guide
PDF
- Texas Instruments TMS9918A VDP by Sean Young
TXT
- The MSX Red Book · 2 Video Display Processor
HTML
- YAMAHA 9938 Technical Data Book
HTML