# Palette map

A palette map is a 2D grid representing pixels (columns x rows, rows being the
"inner" list) where each number, one byte in width, is an entry in a palette.
The palette is a list of encoded colors [gr/color] organized in an array where
each color uses 4 bytes.

The structure of a pmap is a pixbuf [gr/pix] with additional fields.

The palette has no structure, it's only an array. If you go out of bounds,
you'll have weird colors.

Also, you must ensure that the palette you use for drawing your pmap is of the
same color encoding as what you're drawing to.

## Transparency

The value $ff in a pmap holds a special significance: it indicates transparency.

When blending or drawing a pmap, $ff values will be skipped and not written to
the destination pmap or plane.

## API

### Fields

bufsz     Size in bytes of the pixel buffer

### Words

newpmap ( width height -- pmap )
  Allocate a new pmap of the specified size. That new map starts filled with
  transparent ($ff) pixels.

?resize ( width height pmap -- f )
  Change the "width" and "height" fields of "pmap". No buffer reallocation take
  place, which means that the new width and height must fit in the previously
  existing buffer. If it does, proceed and yield f=1. Otherwise, don't resize
  and yield f=0.

  Geometry change invalidates the content. Whatever was in there previously
  becomes garbage after a resize.

resize# ( width height pmap -- )
  Try to resize and abort with error message if we can't.

drawpmap ( palette pmap -- )
  Copy "pmap" into current [gr/pix] dst using specified "palette".

mappalette ( S=pixel -- S=pixel )
  A word that can be plugged into mappixels [gr/pix] which does the general
  palette logic. That's what "drawpmap" uses.

mapblend ( S=pixel -- S=pixel )
  A word that can be plugged into mappixels [gr/pix] which blends a pmap into
  another. It simply copies the pixel *unless* it is $ff, in which case it
  doesn't.
