\documentclass{article}
\usepackage{common}

\begin{document}
\begin{framed}

\pagehead{Sprite control}

Gameduino has 256 hardware sprites: 16$\times$16 pixel images that can appear
anywhere on the screen.  Sprites are drawn from back-to-front, so
higher-numbered sprites cover up lower-numbered ones.
Each sprite's appearance is controlled by a 32-bit word:

\vspace{12 pt}

\setlength{\bitwidth}{1em}
\setlength{\byteheight}{2em}
\begin{bytefield}{32}
\bitheader[b]{0-31} \\
\bitbox{1}{C} & \bitbox{6}{IMAGE} & \bitbox{9}{Y} & \bitbox{4}{PAL} & \bitbox{3}{ROT} & \bitbox{9}{X}
\end{bytefield}

\begin{description}
\item[X] X coordinate, 0-511.  0 is the left edge of the screen, 399 is the right edge.
\item[Y] Y coordinate, 0-511.  0 is the top edge of the screen, 299 is the bottom edge.
\item[IMAGE] Sprite image select, 0-63.  Selects which source image the sprite uses.
\item[PAL] Sprite palette select, 4 bits.  Controls how pixel data is turned into color.
\item[ROT] Sprite rotate, 3 bits.  Rotates a sprite by quarter-turns.
\item[C] Collision class, 0 is J, 1 is K.
\end{description}

\textbf{To hide a sprite} park it off the screen by setting its Y coordinate to 400.

\textbf{To make a large sprite} draw several sprites together in a
grid pattern.  For example four 16x16 sprites can be arranged to make
a single 32x32 sprite.

\textbf{To spin a sprite} use the ROT field to rotate it, and use extra animation frames for finer rotations.

\textbf{To animate a sprite} you can
\begin{itemize}
\item change the IMAGE field
\item change the PAL field to do simple color animation
\item change the ROT field to apply flips and rotates of 90, 180 and 270 degrees
\item load new data to the source image.
\end{itemize}

\end{framed}
\end{document}
