\documentclass{article}
\usepackage{common}

\begin{document}

\begin{framed}
\pagehead{Sprite palette select}

Each pixel of the sprite image is fetched and looked up in a sprite
palette.  This palette is a list of colors.  Gameduino gives you several
palette options: a 256-color palette, a 16-color palette and a 4-color
palette.  Why not always use the 256-color palette?  Because using
the smaller palette options lets you squeeze more images into memory.
256 bytes of sprite image RAM can hold one 16x16 sprite image
in 256-color mode, two images in 4-bit mode (with a 16 color palette),
or four images in 2-bit mode (4 color palette).

\vspace{10 pt}

\setlength{\bitwidth}{2em}
\setlength{\byteheight}{4em}
\begin{bytefield}{4}
\bitheader[b]{0-3} \\
\wordgroupr{
\begin{minipage}{0.6\textwidth}
\textbf{8-bit mode.} Each byte indexes into 256-color palette, P
\end{minipage}}
\bitbox{1}{0} & \bitbox{1}{0} & \bitbox{2}{P}
\endwordgroupr \\

\wordgroupr{
\begin{minipage}{0.6\textwidth}
\textbf{4-bit mode.}
The high (N=1) or low (N=0) 4 bits from each byte index into 16-color palette A (AB=0) or B (AB=1)
\end{minipage}}
\bitbox{1}{0} & \bitbox{1}{1} & \bitbox{1}{N} & \bitbox{1}{AB}
\endwordgroupr \\

\wordgroupr{
\begin{minipage}{0.6\textwidth}
\textbf{2-bit mode.}
Two bits from each byte (N=3 is highest, N=0 is lowest) index into 4-color palette A (AB=0) or B (AB=1)
\end{minipage}}
\bitbox{1}{1} & \bitbox{2}{N} & \bitbox{1}{AB}
\endwordgroupr \\

\end{bytefield}

\sample{palettes}
\end{framed}
\end{document}
