From MSX Game Library

< Modules


Code: scroll.h

Category: Graphic



The scroll module handles multidirectional scrolling. For the moment, it works with tile-based modes. On MSX2, it also supports pixel-per-pixel scrolling via screen adjustment registers, and masks to hide this offset.


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


See module use cases in the sample programs:


Library configuration (msxgl_config.h):

// Allow horizontal and/or vertical scrolling
#define SCROLL_HORIZONTAL			TRUE	// Activate horizontal scrolling
#define SCROLL_VERTICAL				TRUE	// Activate vertical scrolling
// Source data info
#define SCROLL_SRC_X				64		// Start X coordinate of the source data
#define SCROLL_SRC_Y				0		// Start Y coordinate of the source data
#define SCROLL_SRC_W				128		// Width of the source data
#define SCROLL_SRC_H				24		// Height of the source data
// Destination data info
#define SCROLL_DST_X				0		// Destination x coordinate (in layout table)
#define SCROLL_DST_Y				2		// Destination y coordinate (in layout table)
#define SCROLL_DST_W				32		// Destination width
#define SCROLL_DST_H				20		// Destination height
#define SCROLL_SCREEN_W				32		// Screen width in tile number
// Allow scroll data looping (only for horizontal scrolling)
#define SCROLL_WRAP					TRUE
// Use screen position adjust register (allow per-pixel scrolling) [MSX2]
#define SCROLL_ADJUST				TRUE	// Global ajustement
#define SCROLL_ADJUST_SPLIT			TRUE	// Destination windows ajustement using screen split
// Use sprite mask (allow smooth per-pixel scrolling) [MSX2]
#define SCROLL_MASK					TRUE	// Use sprite to mask
#define SCROLL_MASK_ID				0		// First sprite ID to use
#define SCROLL_MASK_COLOR			COLOR_BLACK // Must be the same than border color
#define SCROLL_MASK_PATTERN			0		// Sprite pattern to use


Dependency on other modules: