Skip to content

Latest commit

 

History

History
166 lines (113 loc) · 5.19 KB

HOWTO.md

File metadata and controls

166 lines (113 loc) · 5.19 KB

How to use the VDP PRINT MSX SDCC Library


Index



1 Description

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.

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!



2 Requirements



3 Functions

3.1 VLOCATE

VLOCATE
Moves the cursor to the specified location and optionally provides the
VRAM address from the pattern name table,
for the indicated screen position.
FunctionVLOCATE(column, line)
Input[char]column (0 - 31)
[char]line (0 - 23)
Output[unsigned int]VRAM address
Example:
VLOCATE(10,5);
VPRINT("Hello World!");

3.2 VPRINT

VPRINT
Prints a string of characters on the screen.
Places it in the position indicated by VLOCATE or in the last printed position.
FunctionVPRINT(text)
Input[char*]string
Output ---
Example:
VLOCATE(3,4);
VPRINT("Alea iacta est");

3.3 VPRINTN

VPRINTN
Prints a character string with a limited length on the screen.
FunctionVPRINTN(text, length)
Inputtext (char*)string
length (unsigned int)length of the string to print
Output ---
Example:VPRINTN("Alea iacta est",10);

3.4 VPrintNumber

VPrintNumber
Prints a number.
FunctionVPrintNumber(value, length)
Input[unsigned int] or [char]value
[char]length
Output ---
Example:Save_ISR();

3.5 num2Dec16

num2Dec16
16-bit Integer to ASCII (adaptation of Baze code)
It is for internal use of the number printing functions.
Functionnum2Dec16(value, text)
Inputvalue (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);

4 How to use

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.

Example:

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");
}