Modules/vdp

From MSX Game Library

Revision as of 18:26, 11 January 2024 by Aoineko (talk | contribs) (Created page with "{{MODULE |name=vdp |category=Core |dependency1= |dependency2= |dependency3= |sample1=s_sm1 |sample1_desc=sprite mode 1 |sample2=s_sprite |sample2_desc=sprite mode 2 and screen...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

< Modules

vdp

Code: vdp.h

Category: Core

Dependencies: None

Samples:

The vdp module is a major module that handles all display-related tasks: choice of screen modes, VRAM writing and reading, sprite management, management of advanced MSX2 commands, etc. This module manages all the graphics processors (VDPs) of the MSX1 (TI TMS9918), MSX2 (Yamaha V9938) and MSX2+ (Yamaha V9958). This module manages all the graphics processors (VDPs) of the MSX1 (TI TMS9918), MSX2 (Yamaha V9938) and MSX2+ (Yamaha V9958).

Note: For the Yamaha V9990 extension, see module v9990.

Usage

To use this module, include "vdp.h" in your source code, and add "vdp" to the modules list (LibModules) in your project's configuration file (project_config.js).

Links

For more information about the 3 generations of MSX's VDP, please check:

Samples

See module use cases in the sample programs:

  • s_sm1 (sprite mode 1)
  • s_sprite (sprite mode 2 and screen split)
  • s_vdpcmd (VDP commands)
  • s_gm3 (Undocumented mode and screen split)

Settings

Library configuration (msxgl_config.h):

// VRAM addressing unit
// - VDP_VRAM_ADDR_14 ............. Use 14-bits 16K VRAM addressing for MSX1 (u16)
// - VDP_VRAM_ADDR_17 ............. Use 17-bits 128K VRAM addressing for MSX2/2+/turbo R (u32)
#define VDP_VRAM_ADDR				VDP_VRAM_ADDR_17

// VDP X/Y units
// - VDP_UNIT_U8 .................. X and Y use 8-bits values
// - VDP_UNIT_X16 ................. X use 16-bits and Y use 8-bits values
// - VDP_UNIT_Y16 ................. X use 8-bits and Y use 16-bits values
// - VDP_UNIT_U16 ................. X and Y use 16-bits values
#define VDP_UNIT					VDP_UNIT_X16

// VDP screen modes (additionnal limitations come from the selected MSX_VERSION)
#define VDP_USE_MODE_T1				TRUE	// MSX1		Screen 0 Width 40
#define VDP_USE_MODE_MC				TRUE	// MSX1		Screen 3
#define VDP_USE_MODE_G1				TRUE	// MSX1		Screen 1
#define VDP_USE_MODE_G2				TRUE	// MSX1		Screen 2
#define VDP_USE_MODE_T2				TRUE	// MSX2		Screen 0 Width 80
#define VDP_USE_MODE_G3				TRUE	// MSX2		Screen 4
#define VDP_USE_MODE_G4				TRUE	// MSX2		Screen 5
#define VDP_USE_MODE_G5				TRUE	// MSX2		Screen 6
#define VDP_USE_MODE_G6				TRUE	// MSX2		Screen 7
#define VDP_USE_MODE_G7				TRUE	// MSX2/2+	Screen 8, 10, 11 & 12

#define VDP_USE_VRAM16K				TRUE	// Use 16K VRAM access functions on MSX2
#define VDP_USE_SPRITE				TRUE	// Use sprite handling functions
#define VDP_USE_COMMAND				TRUE	// Use VDP commands wrapper functions
#define VDP_USE_CUSTOM_CMD			FALSE	// Use custom VDP commands through data buffer
#define VDP_AUTO_INIT				TRUE	// Call VDP_Initialize() at the first call to VDP_SetMode()
#define VDP_USE_UNDOCUMENTED		TRUE	// Allow the use of undocumented screen mode (WIP)
#define VDP_USE_VALIDATOR			TRUE	// Handle some option specific for each VDP mode (highly recommended)
#define VDP_USE_DEFAULT_PALETTE		FALSE	// Add data for default MSX2 palette
#define VDP_USE_MSX1_PALETTE		FALSE	// Add data for default MSX1 palette
#define VDP_USE_DEFAULT_SETTINGS	TRUE	// Auto-initialization of common VDP feature
#define VDP_USE_16X16_SPRITE		TRUE	// Use 16x16 sprites mode
#define VDP_USE_RESTORE_S0			TRUE	// Do restore of status register pointer to S#0 (needed onlt for default BIOS ISR)
#define VDP_USE_PALETTE16			TRUE	// Use 16 entries palette (use only 15 entries otherwise)

// ISR protection while modifiying VDP registers
// - VDP_ISR_SAFE_NONE ............ No ISR protection (for program not using VDP interruption)
// - VDP_ISR_SAFE_DEFAULT ......... Protect only VDP register pair writing (default behavior; ISR can read/write registers but VRAM ones)
// - VDP_ISR_SAFE_ALL ............. Protect all VDP writing process
#define VDP_ISR_SAFE_MODE			VDP_ISR_SAFE_DEFAULT

// Initial screen mode setting
// - VDP_INIT_OFF ................. Force option to be disable
// - VDP_INIT_ON .................. Force option to be enable
// - VDP_INIT_AUTO ................ Determining the best value for the context
// - VDP_INIT_DEFAULT ............. Keep default value
#define VDP_INIT_50HZ				VDP_INIT_ON

Dependencies

Dependency on other modules: None

Documentation