LIB: pm_cmap16
CStyle Lib: Map (16x16) Manipulations
pmrom_cmap16.s
Type: Source File
Dependency: pm_init.s and pm_cstyle.s
Including Rules: Must be after ROM (PM_HEADER) declaration
Overview
Map must be always set with c_map16_set prior of using any other function in exception of c_map16_getcode which work individualy.
The following .pmimage can be used to generate a map from existing tileset:
format=raw ; set to 'asm' if you perfer to use .include instead of .incbin gfx=exmap dither=yes ; set to 'no' if using 2 colors or if there's too much motion metaw=2 metah=2 metashl=yes img=(exported image of the map) tileset=(image of the tileset) outmap=(generated file of the map) outheader=(generated header with map information) outtileset=(converted file of the tileset, PM format) outtilesetgray=(converted file of the tileset, PM format for the 3rd gray)
For more information about .pmimage format check here.
Variables
map16_camera_x: Horizontal camera position in pixels (Fixed 12.8)
map16_camera_y: Vertical camera position in pixels (Fixed 12.8)
Functions
Set map
c_map16_set width, height, map_addr
[CVar] width: Map width in meta tiles (>= 6 and <= 255)
[CVar] height: Map height in meta tiles (>= 4 and <= 255)
[CPtr] map_addr: Map address
No return
Draw map
c_map16_draw
No return
Warning: Map must be 16x12 on hardware by setting PRC_MAP16x12 in [n+PRC_MODE]
Set camera position
c_map16_campos x, y
[CVar] x: Pixel x-coordinate of camera at left (Fixed 12.4)
[CVar] y: Pixel y-coordinate of camera at top (Fixed 12.4)
No return
Camera is clamped to the map dimensions correctly unless map is >= 128 metatiles in any dimension.
For free camera moving use map16_camera_x and map16_camera_y directly.
Move camera relatively along x-axis
c_map16_movex num
[CVar] num: Pixels to move along x-axis (Fixed 12.4)
No return
Camera is clamped to the map dimensions correctly, even if the map width is >= 128 metatiles.
Move camera relatively along y-axis
c_map16_movey num
[CVar] num: Pixels to move along y-axis (Fixed 12.4)
No return
Camera is clamped to the map dimensions correctly, even if the map height is >= 128 metatiles.
Check if specific coordinate is valid
c_map16_validcoord x, y
[CVar] x: Pixel x-coordinate (Fixed 12.4)
[CVar] y: Pixel y-coordinate (Fixed 12.4)
Returns: zero if invalid, non-zero otherwise
Get tile from map at specific coordinate
c_map16_gettile x, y
[CVar] x: Pixel x-coordinate (Fixed 12.4)
[CVar] y: Pixel y-coordinate (Fixed 12.4)
Returns: Tile ID (0 to 255)
Get code from external map at specific coordinate
c_map16_gecode x, y, map_addr, map_width
[CVar] x: Pixel x-coordinate (Fixed 12.4)
[CVar] y: Pixel y-coordinate (Fixed 12.4)
[CPtr] map_addr: Map address (16x16 tiles format)
[CVar] map_width: Map width
Returns: 8-Bits code (0 to 255)
Get OAM sprite position from position and camera
c_map16_sprpos x, y, width, height
[CVar] x: Sprite pixel x-coordinate (Fixed 12.4)
[CVar] y: Sprite pixel y-coordinate (Fixed 12.4)
Returns: zero if outside or reg B = OAM Y and reg A = OAM X
Register BA can be used directly on the first 2 bytes of the sprite entry or in c_spr_add (CSpr lib) 1st argument.