LIB: pm_cmap8

CStyle Lib: Map (8x8) 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_map8_set prior of using any other function in exception of c_map8_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 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

map8_camera_x: Horizontal camera position in pixels (Fixed 12.8)

map8_camera_y: Vertical camera position in pixels (Fixed 12.8)

Functions

Set map

c_map8_set width, height, map_addr

[CVar] width: Map width in meta tiles (>= 12 and <= 255)

[CVar] height: Map height in meta tiles (>= 8 and <= 255)

[CPtr] map_addr: Map address

No return

Draw map

c_map8_draw

No return

Warning: Map must be 16x12 on hardware by setting PRC_MAP16x12 in [n+PRC_MODE]

Set camera position

c_map8_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.

For free camera moving use map16_camera_x and map16_camera_y directly.

Move camera relatively along x-axis

c_map8_movex num

[CVar] num: Pixels to move along x-axis (Fixed 12.4)

No return

Camera is clamped to the map dimensions correctly.

Move camera relatively along y-axis

c_map8_movey num

[CVar] num: Pixels to move along y-axis (Fixed 12.4)

No return

Camera is clamped to the map dimensions correctly.

Check if specific coordinate is valid

c_map8_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_map8_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_map8_getcode 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 (8x8 tiles format)

[CVar] map_width: Map width

Returns: 8-Bits code (0 to 255)

Get OAM sprite position from position and camera

c_map8_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.