The GD library (download) is a set of routines that make it easier to control the Gameduino.
The GD library is a very thin layer between your code and the hardware.
While it is possible to control the Gameduino using the Arduino SPI library, the samples use the GD library to do some common operations. For example, “hello world” using GD:
#include <SPI.h>
#include <GD.h>
void setup()
{
GD.begin();
// Load the standard ascii font
GD.ascii();
GD.putstr(0, 0, "Hello world");
}
void loop()
{
}
Initialize the connection to the adapter, and reset the adapter.
Read a byte from memory location addr
Write byte v to memory location addr.
Read a 16-bit word from memory locations addr and addr+1
Write 16-bit word v to memory locations addr and addr+1
Fill count memory locations starting at addr with value v
Copy count bytes from AVR flash memory location src to addr. See also Use PROGMEM for graphics data.
Set character palette entry pal to color rgb. See also RGB() for rgb encoding.
Set attributes of sprite spr
| Param spr: | sprite number, 0-255 |
|---|---|
| Param x: | x coordinate, 0-511. 0 is left edge of screen. |
| Param y: | y coordinate, 0-511. 0 is top edge of screen. |
| Param image: | image number, 0-63 |
| Param palette: | palette control 0-15 |
| Param rot: | rotate/flip control 0-7 |
| Param jk: | J/K collision select, 0-1 |
For details on these attributes, see the reference poster or Sprite graphics.
Set attributes of four sprites in a 2x2 configuration. (x,y) specifies the center of the group. Other arguments are as for GD::sprite().
Waits for the start of the vertical blanking period. By waiting for vertical blanking:
- any animation is guaranteed to be smooth
- the sprite collision RAM is valid
Copy count bytes from AVR flash memory location src into the coprocessor’s instruction RAM, and restart the coprocessor. The use of the coprocessor is described in Coprocessor.
Load a standard 8x8 ASCII font into character RAM. This is useful for debugging and status display.
Draw string s at character screen position (x,y). Assumes that a standard character set has been loaded, e.g. by GD::ascii().
Set audio voice waveform, frequency and amplitude
| Param voice: | hardware voice number, 0-63 |
|---|---|
| Param wave: | waveform, 0 is sine wave, 1 is noise |
| Param freq: | frequency in quarter-Hz, e.g. 100 Hz is 400 |
| Param lamp: | left amplitude, 0-255 |
| Param ramp: | right amplitude, 0-255 |
The 64 audio voices are summed for final output. So to guarantee no audio clipping, the sum of all voices’ amplitudes should be 255 or less.
Return the 15-bit encoding of an RGB color. r, g and b are 0-255.
Last modified $Date: 2011-07-31 15:23:57 -0700 (Sun, 31 Jul 2011) $