A conversion of the original Gameduino demo to the Gameduino 2.

The original program kept track of the sprite positions in RAM, so at 4 bytes per sprite it needed 1K of the Arduino's 2K RAM.

This version clearly wasn't going to be able to do the same thing. So here each sprite is rotating around a random point. The 2001 random points are stored in flash - array sprites. This takes 8K of flash. A second array circle holds the 256 XY coordinates to make the sprite move in a circle. The only RAM used is a single byte to keep track of the current rotation position.

Why 2001 sprites? The GPU has a limit of 2048 commands for the screen display. Each sprite is a single command, and there are a few commands overhead for clearing the screen, and drawing the text layer on top.

#include <EEPROM.h>
#include <SPI.h>
#include <GD2.h>

#include "sprites_assets.h"

void setup()

  GD.copy(sprites_assets, sizeof(sprites_assets));

static byte t;

void loop()
  byte j = t;
  uint32_t v, r;

  int nspr = min(2001, max(256, 19 * t));

  PROGMEM prog_uint32_t *pv = sprites;
  for (int i = 0; i < nspr; i++) {
    v = pgm_read_dword(pv++);
    r = pgm_read_dword(circle + j++);
    GD.cmd32(v + r);

  GD.LineWidth(28 * 16);
  GD.Vertex2ii(240 - 110, 136, 0, 0);
  GD.Vertex2ii(240 + 110, 136, 0, 0);


  GD.cmd_number(215, 110, 31, OPT_RIGHTX, nspr);
  GD.cmd_text(  229, 110, 31, 0, "sprites");