#include <SPI.h>
#include <GD.h>
#include "debug.h"

#include "reload.h"
#include "random.h"

void setup()
{
  Serial.begin(1000000);

  GD.begin();
  GD.ascii();
  if (0) {
    Serial.println("Starting reload");
    GD.fill(0, 0x01, 4096);
    dump(0xf00, 16);
    GD.microcode(reload_code, sizeof(reload_code));

    delay(400);
    dump(0xf00, 16);
    Serial.println("");
    delay(1000);
  }
  GD.fill(0, 0, 4096);
  int i;
  for (i = 0; i < 256; i++) {
    GD.wr16(RAM_PAL + (4 * i + 0) * 2, RGB(0,0,0));
    GD.wr16(RAM_PAL + (4 * i + 1) * 2, RGB(0x20,0x20,0x20));
    GD.wr16(RAM_PAL + (4 * i + 2) * 2, RGB(0x40,0x40,0x40));
    GD.wr16(RAM_PAL + (4 * i + 3) * 2, RGB(0xff,0xff,0xff));
  }
  GD.microcode(random_code, sizeof(random_code));
  delay(2);
  dump(0, 0x2800);
}

void loop()
{
}
