Functions for display text strings in the graphic modes of the TMS9918A (G1 and G2).
Requires the VDP TMS9918A Library to write to the VRAM and so that you can start the graphics modes.
- for MSX-DOS and ROM https://github.com/mvac7/SDCC_TMS9918A_Lib
- only for MSX ROM https://github.com/mvac7/SDCC_TMS9918A_MSXROM_Lib
This library does not use any of the MSX BIOS functions, so it is suitable for creating applications for MSX-DOS and ROM format.
I have adapted a routine for converting a 16 Bits value to ASCII, extracted from the Baze collection (WEB), for printing numbers.
It is adapted to work with the standard MSX screen configurations but it can be changed to the VRAM addresses of other computers or video game consoles.
Use them for developing MSX applications using Small Device C Compiler (SDCC).
This project is an Open Source library. You can add part or all of this code in your application development or include it in other libraries/engines.
This library is part of the MSX fR3eL Project.
Enjoy it!
- Small Device C Compiler (SDCC) v4.1
- Hex2bin v2.5
- VDP TMS9918A SDCC Library (fR3eL) -
MSX-DOS/ROM
-MSX-ROM
VLOCATE | ||
---|---|---|
Moves the cursor to the specified location and optionally provides the VRAM address from the pattern name table, for the indicated screen position. | ||
Function | VLOCATE(column, line) | |
Input | [char] | column (0 - 31) |
[char] | line (0 - 23) | |
Output | [unsigned int] | VRAM address |
Example: | VLOCATE(10,5); |
VPRINT | ||
---|---|---|
Prints a string of characters on the screen. Places it in the position indicated by VLOCATE or in the last printed position. | ||
Function | VPRINT(text) | |
Input | [char*] | string |
Output | --- | |
Example: | VLOCATE(3,4); VPRINT("Alea iacta est"); |
VPRINTN | ||
---|---|---|
Prints a character string with a limited length on the screen. | ||
Function | VPRINTN(text, length) | |
Input | text (char*) | string |
length (unsigned int) | length of the string to print | |
Output | --- | |
Example: | VPRINTN("Alea iacta est",10); |
VPrintNumber | ||
---|---|---|
Prints a number. | ||
Function | VPrintNumber(value, length) | |
Input | [unsigned int] or [char] | value |
[char] | length | |
Output | --- | |
Example: | Save_ISR(); |
num2Dec16 | ||
---|---|---|
16-bit Integer to ASCII (adaptation of Baze code) It is for internal use of the number printing functions. | ||
Function | num2Dec16(value, text) | |
Input | value (unsigned int) | value |
text (unsigned int) | pointer to the string where the number is to be translated | |
Output | --- | |
Example: | unsigned int value=1234; char text[]=" "; num2Dec16(value, text); |
The library works in a similar way to the MSX BASIC LOCATE
and PRINT
instructions.
Before printing a text (VPRINT
or VPRINTN
) or a number (VPrintNumber
), it is necessary to indicate the position on the screen with VLOCATE
.
Several texts can be printed in a row, since their final position is preserved.
This example is illustrative only.
In the examples\
folder of the project sources you will find a complete application where you can check the behavior of the library.
void main()
{
char text01[] = "Number:";
usigned int value = 1234;
VLOCATE(0,19);
VPRINT(text01);
VPrintNumber(value,5);
VPRINT(" Bytes");
}