Modules/print
From MSX Game Library
< Modules
The print module used to display text in any screen mode. It offers functions for displaying different types of data in different formats, including advanced effects such as shading or outlining (for bitmap modes).
Usage
To use this module, include "print.h" in your source code, and add "print" to the modules list (LibModules) in your project's configuration file (project_config.js).
Use of this module begins with the initialization of a font. Then you can use all the functions to display text.
You have several render mode:
- Text (using tiles/characters set for tiled-based screen modes),
- Bitmap (draw text from RAM to VRAM for bitmap screen modes),
- Bitmap with transparency.
- VRAM (put font on VRAM and draw from there; slower to initialize, quicker to draw),
- Sprite (draw text using sprites).
Example using tile-based render mode:
#include "font/font_mgl_sample8.h" VDP_SetMode(VDP_MODE_SCREEN1); // Initialize screen mode 1 (tiled-base mode) Print_SetTextFont(g_Font_MGL_Sample8, 1); // Upload font tile-set from index 1 Print_SetPosition(10, 10); // Position in tile grid unit Print_DrawText("Text mode");
Example using bitmap render mode for MSX2:
#include "font/font_mgl_sample6.h" VDP_SetMode(VDP_MODE_SCREEN5); // Initialize screen mode 5 (bitmap mode) Print_SetBitmapFont(g_Font_MGL_Sample6); // Initialize bitmap font Print_SetOutline(TRUE, COLOR_GRAY); // Set outline effect Print_SetPosition(100, 100); // Position in pixel unit Print_DrawText("Bitmap mode"); Print_SetVRAMFont(g_Font_MGL_Sample6, 212, COLOR_WHITE); Print_SetPosition(100, 150); // Position in pixel unit Print_DrawText("VRAM mode");
Example using sprite render mode:
#include "font/font_mgl_sample8.h" VDP_SetMode(VDP_MODE_SCREEN1); // Initialize screen mode 1 (tiled-base mode) Print_SetSpriteFont(g_Font_MGL_Sample8, 0, 0); Print_SetPosition(100, 50); // Position in pixel unit Print_DrawText("SPRT");
Samples
See module use cases in the sample programs:
Settings
Library configuration (msxgl_config.h):
// Print module setting #define PRINT_USE_TEXT TRUE // Allow use of Text font (T1-T2, G1-G3) #define PRINT_USE_BITMAP FALSE // Allow use of Bitmap font (G4-G7) #define PRINT_USE_VRAM FALSE // Allow use of VRAM stored font (G4-G7) #define PRINT_USE_SPRITE FALSE // Allow use of Sprite font (G3-G7) #define PRINT_USE_FX_SHADOW FALSE // [Bitmap] Allow use of text shadow #define PRINT_USE_FX_OUTLINE FALSE // [Bitmap] Allow use of text outline #define PRINT_USE_2_PASS_FX FALSE // [Bitmap] Allow use 2-pass FX render to prevent character overlap #define PRINT_USE_GRAPH TRUE // Allow use of character lines and boxes #define PRINT_USE_VALIDATOR TRUE // Add validator character code #define PRINT_USE_UNIT FALSE // Display integer type (h: hexadecimal, b: binary) #define PRINT_USE_FORMAT TRUE // Add printf type function #define PRINT_USE_32B TRUE // Allow to print 32-bits integers #define PRINT_SKIP_SPACE FALSE // Skill space character #define PRINT_COLOR_NUM 12 // 1 color per line // Character width // - PRINT_WIDTH_1 (text mode) // - PRINT_WIDTH_6 // - PRINT_WIDTH_8 // - PRINT_WIDTH_X (variable) #define PRINT_WIDTH PRINT_WIDTH_1 // Character height // - PRINT_HEIGHT_1 (text mode) // - PRINT_HEIGHT_8 // - PRINT_HEIGHT_X (variable) #define PRINT_HEIGHT PRINT_HEIGHT_1
Dependencies
Dependency on other modules:
Documentation