Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:e047847f1cda, committed 2012-12-21
- Comitter:
- TheChrisyd
- Date:
- Fri Dec 21 14:00:03 2012 +0000
- Parent:
- 0:a2d36977aec3
- Commit message:
- sound on title screen not working, otherwise ok
Changed in this revision
--- a/GD.cpp Sun Aug 05 12:47:00 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,357 +0,0 @@
-/*
- * Copyright (c) 2011 by James Bowman <jamesb@excamera.com>
- * Gameduino library for mbed. Ported from Arduino by Chris Dick
- *
- */
-
-#include "GD.h"
-GDClass GD;
-extern DigitalOut cs;
-extern SPI spi; // mosi, miso, sclk
-extern Serial pc;
-
-
-void GDClass::begin()
-{
- delay(250); // give Gameduino time to boot
-
- spi.format(8,0);
- spi.frequency(8000000);
-
- cs = 1;
-
- GD.wr(J1_RESET, 1); // HALT coprocessor
- __wstart(RAM_SPR); // Hide all sprites
- for (int i = 0; i < 512; i++)
- GD.xhide();
- __end();
- fill(RAM_PIC, 0, 1024 * 10); // Zero all character RAM
- fill(RAM_SPRPAL, 0, 2048); // Sprite palletes black
- fill(RAM_SPRIMG, 0, 64 * 256); // Clear all sprite data
- fill(VOICES, 0, 256); // Silence
- fill(PALETTE16A, 0, 128); // Black 16-, 4-palletes and COMM
-
- GD.wr16(SCROLL_X, 0);
- GD.wr16(SCROLL_Y, 0);
- GD.wr(JK_MODE, 0);
- GD.wr(SPR_DISABLE, 0);
- GD.wr(SPR_PAGE, 0);
- GD.wr(IOMODE, 0);
- GD.wr16(BG_COLOR, 0);
- GD.wr16(SAMPLE_L, 0);
- GD.wr16(SAMPLE_R, 0);
- GD.wr16(SCREENSHOT_Y, 0);
- GD.wr(MODULATOR, 64);
-}
-
-void GDClass::end() {
-}
-
-void GDClass::__start(unsigned int addr) // start an spi transaction to addr
-{
- cs = 0;
- spi.write(highByte(addr));
- spi.write(lowByte(addr));
-}
-
-void GDClass::__wstart(unsigned int addr) // start an spi write transaction to addr
-{
- __start(0x8000|addr);
-}
-
-void GDClass::__wstartspr(unsigned int sprnum)
-{
- __start((0x8000 | RAM_SPR) + (sprnum << 2));
- spr = 0;
-}
-
-void GDClass::__end() // end the spi transaction
-{
- cs = 1;
-}
-
-byte GDClass::rd(unsigned int addr)
-{
- __start(addr);
- byte r = spi.write(0);
- __end();
- return r;
-}
-
-void GDClass::wr(unsigned int addr, byte v)
-{
- __wstart(addr);
- spi.write(v);
- __end();
-}
-
-unsigned int GDClass::rd16(unsigned int addr)
-{
- unsigned int r;
-
- __start(addr);
- r = spi.write(0);
- r |= (spi.write(0) << 8);
- __end();
- return r;
-}
-
-void GDClass::wr16(unsigned int addr, unsigned int v)
-{
- __wstart(addr);
- spi.write(lowByte(v));
- spi.write(highByte(v));
- __end();
-}
-
-void GDClass::fill(int addr, byte v, unsigned int count)
-{
- __wstart(addr);
- while (count--)
- spi.write(v);
- __end();
-}
-
-void GDClass::copy(unsigned int addr, PROGMEM prog_uchar *src, int count)
-{
- __wstart(addr);
- while (count--) {
- spi.write(pgm_read_byte_near(src));
- src++;
- }
- __end();
-}
-
-
-
-void GDClass::microcode(PROGMEM prog_uchar *src, int count)
-{
- wr(J1_RESET, 1);
- copy(J1_CODE, src, count);
- wr(J1_RESET, 0);
-}
-
-
-
-void GDClass::setpal(int pal, unsigned int rgb)
-{
- wr16(RAM_PAL + (pal << 1), rgb);
-}
-
-void GDClass::sprite(int spr, int x, int y, byte image, byte palette, byte rot, byte jk)
-{
- __wstart(RAM_SPR + (spr << 2));
- spi.write(lowByte(x));
- spi.write((palette << 4) | (rot << 1) | (highByte(x) & 1));
- spi.write(lowByte(y));
- spi.write((jk << 7) | (image << 1) | (highByte(y) & 1));
- __end();
-}
-
-void GDClass::xsprite(int ox, int oy, signed char x, signed char y, byte image, byte palette, byte rot, byte jk)
-{
- if (rot & 2)
- x = -16-x;
- if (rot & 4)
- y = -16-y;
- if (rot & 1) {
- int s;
- s = x; x = y; y = s;
- }
- ox += x;
- oy += y;
- spi.write(lowByte(ox));
- spi.write((palette << 4) | (rot << 1) | (highByte(ox) & 1));
- spi.write(lowByte(oy));
- spi.write((jk << 7) | (image << 1) | (highByte(oy) & 1));
- spr++;
-}
-
-void GDClass::xhide()
-{
- spi.write(lowByte(400));
- spi.write(highByte(400));
- spi.write(lowByte(400));
- spi.write(highByte(400));
- spr++;
-}
-
-void GDClass::plots(int ox, int oy, PROGMEM sprplot *psp, byte count, byte rot, byte jk)
-{
- while (count--) {
- struct sprplot sp;
- sp = *psp++;
- GD.xsprite(ox, oy, sp.x, sp.y, sp.image, sp.palette, rot, jk);
- }
-}
-
-void GDClass::sprite2x2(int spr, int x, int y, byte image, byte palette, byte rot, byte jk)
-{
- __wstart(0x3000 + (spr << 2));
- GD.xsprite(x, y, -16, -16, image + 0, palette, rot, jk);
- GD.xsprite(x, y, 0, -16, image + 1, palette, rot, jk);
- GD.xsprite(x, y, -16, 0, image + 2, palette, rot, jk);
- GD.xsprite(x, y, 0, 0, image + 3, palette, rot, jk);
- __end();
-}
-
-void GDClass::waitvblank()
-{
- // Wait for the VLANK to go from 0 to 1: this is the start
- // of the vertical blanking interval.
-
- while (rd(VBLANK) == 1)
- ;
- while (rd(VBLANK) == 0)
- ;
-}
-
-/* Fixed ascii font, useful for debug */
-
-#include "font8x8.h"
-static byte stretch[16] = {
- 0x00, 0x03, 0x0c, 0x0f,
- 0x30, 0x33, 0x3c, 0x3f,
- 0xc0, 0xc3, 0xcc, 0xcf,
- 0xf0, 0xf3, 0xfc, 0xff
-};
-
-
-void GDClass::ascii()
-{
- long i;
- for (i = 0; i < 768; i++) {
- byte b = font8x8[i];
- byte h = stretch[b >> 4];
- byte l = stretch[b & 0xf];
- GD.wr(0x1000 + (16 * ' ') + (2 * i), h);
- GD.wr(0x1000 + (16 * ' ') + (2 * i) + 1, l);
- }
- for (i = 0x20; i < 0x80; i++) {
- GD.setpal(4 * i + 0, TRANSPARENT);
- GD.setpal(4 * i + 3, RGB(255,255,255));
- }
- GD.fill(RAM_PIC, ' ', 4096);
-}
-
-void GDClass::putstr(int x, int y, const char *s)
-{
- GD.__wstart((y << 6) + x);
- while (*s)
- spi.write(*s++);
- GD.__end();
-}
-
-void GDClass::voice(int v, byte wave, unsigned int freq, byte lamp, byte ramp)
-{
- __wstart(VOICES + (v << 2));
- spi.write(lowByte(freq));
- spi.write(highByte(freq) | (wave << 7));
- spi.write(lamp);
- spi.write(ramp);
- __end();
-}
-
-void GDClass::screenshot(unsigned int frame)
-{
- int yy, xx;
- byte undone[38]; // 300-long bitmap of lines pending
-
- // initialize to 300 ones
- memset(undone, 0xff, 37);
- undone[37] = 0xf;
- int nundone = 300;
-
- pc.putc(0xa5); // sync byte
- pc.putc(lowByte(frame));
- pc.putc(highByte(frame));
-
- while (nundone) {
- // find a pending line a short distance ahead of the raster
- int hwline = GD.rd16(SCREENSHOT_Y) & 0x1ff;
- for (yy = (hwline + 7) % 300; ((undone[yy>>3] >> (yy&7)) & 1) == 0; yy = (yy + 1) % 300)
- ;
- GD.wr16(SCREENSHOT_Y, 0x8000 | yy); // ask for it
-
- // housekeeping while waiting: mark line done and send yy
- undone[yy>>3] ^= (1 << (yy&7));
- nundone--;
- pc.putc(lowByte(yy));
- pc.putc(highByte(yy));
- while ((GD.rd(SCREENSHOT_Y + 1) & 0x80) == 0)
- ;
-
- // Now send the line, compressing zero pixels
- uint16_t zeroes = 0;
- for (xx = 0; xx < 800; xx += 2) {
- uint16_t v = GD.rd16(SCREENSHOT + xx);
- if (v == 0) {
- zeroes++;
- } else {
- if (zeroes) {
- pc.putc(lowByte(zeroes));
- pc.putc(0x80 | highByte(zeroes));
- zeroes = 0;
- }
- pc.putc(lowByte(v));
- pc.putc(highByte(v));
- }
- }
- if (zeroes) {
- pc.putc(lowByte(zeroes));
- pc.putc(0x80 | highByte(zeroes));
- }
- }
- GD.wr16(SCREENSHOT_Y, 0); // restore screen to normal
-}
-
-class GDflashbits {
-public:
- void begin(PROGMEM prog_uchar *s) {
- src = s;
- mask = 0x01;
- }
- byte get1(void) {
- byte r = (pgm_read_byte_near(src) & mask) != 0;
- mask <<= 1;
- if (!mask) {
- mask = 1;
- src++;
- }
- return r;
- }
- unsigned short getn(byte n) {
- unsigned short r = 0;
- while (n--) {
- r <<= 1;
- r |= get1();
- }
- return r;
- }
-private:
- PROGMEM prog_uchar *src;
- byte mask;
-};
-
-static GDflashbits GDFB;
-
-void GDClass::uncompress(unsigned int addr, PROGMEM prog_uchar *src)
-{
- GDFB.begin(src);
- byte b_off = GDFB.getn(4);
- byte b_len = GDFB.getn(4);
- byte minlen = GDFB.getn(2);
- unsigned short items = GDFB.getn(16);
- while (items--) {
- if (GDFB.get1() == 0) {
- GD.wr(addr++, GDFB.getn(8));
- } else {
- int offset = -GDFB.getn(b_off) - 1;
- int l = GDFB.getn(b_len) + minlen;
- while (l--) {
- GD.wr(addr, GD.rd(addr + offset));
- addr++;
- }
- }
- }
-}
--- a/GD.h Sun Aug 05 12:47:00 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2011 by James Bowman <jamesb@excamera.com>
- * Gameduino library for arduino.
- *
- */
-
-
-#ifndef _GD_H_INCLUDED
-#define _GD_H_INCLUDED
-#include "shield.h"
-#include "mbed.h"
-#include "arduino.h"
-
-// define SS_PIN before including "GD.h" to override this
-
-struct sprplot
-{
- signed char x, y;
- byte image, palette;
-};
-
-class GDClass {
-public:
- static void begin();
- static void end();
- static void __start(unsigned int addr);
- static void __wstart(unsigned int addr);
- static void __end(void);
- static byte rd(unsigned int addr);
- static void wr(unsigned int addr, byte v);
- static unsigned int rd16(unsigned int addr);
- static void wr16(unsigned int addr, unsigned int v);
- static void fill(int addr, byte v, unsigned int count);
- static void copy(unsigned int addr, PROGMEM prog_uchar *src, int count);
-
- static void setpal(int pal, unsigned int rgb);
- static void sprite(int spr, int x, int y, byte image, byte palette, byte rot = 0, byte jk = 0);
- static void sprite2x2(int spr, int x, int y, byte image, byte palette, byte rot = 0, byte jk = 0);
- static void waitvblank();
- static void microcode(PROGMEM prog_uchar *src, int count);
- static void uncompress(unsigned int addr, PROGMEM prog_uchar *src);
-
- static void voice(int v, byte wave, unsigned int freq, byte lamp, byte ramp);
- static void ascii();
- static void putstr(int x, int y, const char *s);
-
- static void screenshot(unsigned int frame);
-
- void __wstartspr(unsigned int spr = 0);
- void xsprite(int ox, int oy, signed char x, signed char y, byte image, byte palette, byte rot = 0, byte jk = 0);
- void xhide();
- void plots(int ox, int oy, PROGMEM sprplot *psp, byte count, byte rot, byte jk);
-
- byte spr; // Current sprite, incremented by xsprite/xhide above
-};
-
-#define GD_HAS_PLOTS 1 // have the 'GD.plots' method
-
-extern GDClass GD;
-
-#define RGB(r,g,b) ((((r) >> 3) << 10) | (((g) >> 3) << 5) | ((b) >> 3))
-#define TRANSPARENT (1 << 15) // transparent for chars and sprites
-
-#define RAM_PIC 0x0000 // Screen Picture, 64 x 64 = 4096 bytes
-#define RAM_CHR 0x1000 // Screen Characters, 256 x 16 = 4096 bytes
-#define RAM_PAL 0x2000 // Screen Character Palette, 256 x 8 = 2048 bytes
-
-#define IDENT 0x2800
-#define REV 0x2801
-#define FRAME 0x2802
-#define VBLANK 0x2803
-#define SCROLL_X 0x2804
-#define SCROLL_Y 0x2806
-#define JK_MODE 0x2808
-#define J1_RESET 0x2809
-#define SPR_DISABLE 0x280a
-#define SPR_PAGE 0x280b
-#define IOMODE 0x280c
-
-#define BG_COLOR 0x280e
-#define SAMPLE_L 0x2810
-#define SAMPLE_R 0x2812
-
-#define MODULATOR 0x2814
-
-#define SCREENSHOT_Y 0x281e
-
-#define PALETTE16A 0x2840 // 16-color palette RAM A, 32 bytes
-#define PALETTE16B 0x2860 // 16-color palette RAM B, 32 bytes
-#define PALETTE4A 0x2880 // 4-color palette RAM A, 8 bytes
-#define PALETTE4B 0x2888 // 4-color palette RAM A, 8 bytes
-#define COMM 0x2890 // Communication buffer
-#define COLLISION 0x2900 // Collision detection RAM, 256 bytes
-#define VOICES 0x2a00 // Voice controls
-#define J1_CODE 0x2b00 // J1 coprocessor microcode RAM
-#define SCREENSHOT 0x2c00 // screenshot line RAM
-
-#define RAM_SPR 0x3000 // Sprite Control, 512 x 4 = 2048 bytes
-#define RAM_SPRPAL 0x3800 // Sprite Palettes, 4 x 256 = 2048 bytes
-#define RAM_SPRIMG 0x4000 // Sprite Image, 64 x 256 = 16384 bytes
-
-#ifndef GET_FAR_ADDRESS // at some point this will become official... https://savannah.nongnu.org/patch/?6352
-#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
-#define GET_FAR_ADDRESS(var) \
-({ \
- uint_farptr_t tmp; \
- \
- __asm__ __volatile__( \
- \
- "ldi %A0, lo8(%1)" "\n\t" \
- "ldi %B0, hi8(%1)" "\n\t" \
- "ldi %C0, hh8(%1)" "\n\t" \
- "clr %D0" "\n\t" \
- : \
- "=d" (tmp) \
- : \
- "p" (&(var)) \
- ); \
- tmp; \
-})
-#else
-#define GET_FAR_ADDRESS(var) (var)
-#endif
-#endif
-/*
-// simple utilities for accessing the asset library in a filesystem-like
-// way
-// Details of the flash chip:
-// http://www.atmel.com/dyn/resources/prod_documents/doc3638.pdf
-
-const int FLASHSEL = 2; // flash SPI select pin
-class Asset {
-
- private:
-
- uint32_t addr; // pointer into flash memory
- uint16_t remain; // number of remaing unread bytes
-
- byte find_name(const char *name) {
- // addr points at a directory, scan for name, if found set addr
- // to the entry and return 1, otherwise return 0.
- while (true) {
- static struct {
- char name[12];
- uint16_t length;
- uint32_t addr;
- } de;
- read(&de, sizeof(de));
- if (de.name[0] == 0)
- return 0; // end of dir, no match found
- if (strcmp(de.name, name) == 0) {
- remain = de.length;
- addr = de.addr;
- return 1;
- }
- }
- }
-
- public:
-
- int open(const char *d, ...) {
- va_list ap;
- va_start(ap, d);
- addr = 512L * 640;
- remain = 1024;
- pinMode(FLASHSEL, OUTPUT);
- digitalWrite(FLASHSEL, HIGH);
- do {
- if (!find_name(d))
- return 0;
- d = va_arg(ap, const char *);
- } while (d != NULL);
- return 1;
- }
- int read(void *dst, uint16_t n) {
- GD.wr(IOMODE, 'F');
- digitalWrite(FLASHSEL, LOW);
- SPI.transfer(0x03);
- SPI.transfer((byte)(addr >> 16));
- SPI.transfer((byte)(addr >> 8));
- SPI.transfer((byte)(addr >> 0));
- uint16_t actual = min(n, remain); // actual bytes read
- byte *bdst = (byte*)dst;
- for (uint16_t a = actual; a; a--) {
- byte b = SPI.transfer(0);
- *bdst++ = b;
- addr++;
- if ((511 & (uint16_t)addr) == 264)
- addr = addr - 264 + 512;
- }
- remain -= actual;
- digitalWrite(FLASHSEL, HIGH);
- GD.wr(IOMODE, 0);
- return actual;
- }
- int load(uint16_t dst) {
- while (remain) {
- byte buf[16];
- uint16_t n = min(remain, sizeof(buf));
- read(buf, n);
- GD.__wstart(dst);
- for (byte i = 0; i < n; i++)
- SPI.transfer(buf[i]);
- GD.__end();
- dst += n;
- }
- }
- uint16_t available() {
- return remain;
- }
-};
-*/
-#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Gameduino.lib Fri Dec 21 14:00:03 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/TheChrisyd/code/Gameduino/#84c1ca3e1be0
--- a/arduino.c Sun Aug 05 12:47:00 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-#include "arduino.h"
-
-long time_counter;
-Ticker ticker;
-
-long millis(void) {
- return time_counter/1000;
-}
-long micros(void) {
- return time_counter;
-}
-
-void one_micro(void) {
- time_counter += 10;
-}
-
-void arduino_setup(void) {
- ticker.attach_us( &one_micro, 10 );
-}
-
-byte lowByte(short int low) {
- byte bytelow = 0;
- bytelow = (low & 0xFF);
- return bytelow;
-}
-
-byte highByte(short int high) {
- byte bytehigh = 0;
- bytehigh = ((high >> 8) & 0xFF);
- return bytehigh;
-}
-
-long random(int number) {
- return (rand()%number);
-}
-
-int random(int numberone, int numbertwo) {
- int random = 0;
- if ((numberone < 0) && (numbertwo < 0)) {
- numberone = numberone * -1;
- numbertwo = numbertwo * -1;
- random = -1 * (rand()%(numberone + numbertwo));
- }
- if ((numbertwo < 0) && (numberone >= 0)) {
- numbertwo = numbertwo * -1;
- random = (rand()%(numberone + numbertwo)) - numbertwo;
- }
- if ((numberone < 0) && (numbertwo >= 0)) {
- numberone = numberone * -1;
- random = (rand()%(numberone + numbertwo)) - numberone;
- } else {
- random = (rand()%(numberone + numbertwo)) - min(numberone, numbertwo);
- }
- return random;
-}
--- a/arduino.h Sun Aug 05 12:47:00 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -#ifndef ARDUINO_H -#define ARDUINO_H - -#include "mbed.h" -#include "shield.h" - - -typedef unsigned char prog_uint8_t; -typedef unsigned int prog_uint16_t; -typedef unsigned int prog_uint32_t; -typedef unsigned char byte; -typedef bool boolean; -typedef unsigned char prog_uchar; -typedef signed char prog_char; - -#define pgm_read_word_near(x) (*(const unsigned int*)x) -#define pgm_read_int_near(x) (*(const int*)x) -#define pgm_read_int(x) (*(const int*)x) -#define pgm_read_byte(x) (*(const char*)x) -#define pgm_read_byte_near(x) (*(const char*)x) -#define pgm_read_dword_near(x) (*(const int*)x) -#define pgm_read_word(x) (*(const short int*)x) - -#define PROGMEM const - -#define randomSeed(x) srand(x) -#define min(a,b) ((a)<(b)?(a):(b)) -#define max(a,b) ((a)>(b)?(a):(b)) -#define delay(x) (wait_ms(x)) -long millis(void); -long micros(void); -void arduino_setup(void); -void one_mirco(void); -byte lowByte(short int low); -byte highByte(short int high); -long random(int number); -int random(int numberone, int numbertwo); -#endif
--- a/font8x8.h Sun Aug 05 12:47:00 2012 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,53 +0,0 @@
-static PROGMEM prog_uchar font8x8[] = {
-
-0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00,
-0x6c, 0x6c, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7f, 0x36, 0x7f, 0x36, 0x36, 0x00,
-0x0c, 0x3f, 0x68, 0x3e, 0x0b, 0x7e, 0x18, 0x00, 0x60, 0x66, 0x0c, 0x18, 0x30, 0x66, 0x06, 0x00,
-0x38, 0x6c, 0x6c, 0x38, 0x6d, 0x66, 0x3b, 0x00, 0x0c, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
-0x0c, 0x18, 0x30, 0x30, 0x30, 0x18, 0x0c, 0x00, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x18, 0x30, 0x00,
-0x00, 0x18, 0x7e, 0x3c, 0x7e, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7e, 0x18, 0x18, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x00,
-0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x00, 0x00,
-0x3c, 0x66, 0x6e, 0x7e, 0x76, 0x66, 0x3c, 0x00, 0x18, 0x38, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00,
-0x3c, 0x66, 0x06, 0x0c, 0x18, 0x30, 0x7e, 0x00, 0x3c, 0x66, 0x06, 0x1c, 0x06, 0x66, 0x3c, 0x00,
-0x0c, 0x1c, 0x3c, 0x6c, 0x7e, 0x0c, 0x0c, 0x00, 0x7e, 0x60, 0x7c, 0x06, 0x06, 0x66, 0x3c, 0x00,
-0x1c, 0x30, 0x60, 0x7c, 0x66, 0x66, 0x3c, 0x00, 0x7e, 0x06, 0x0c, 0x18, 0x30, 0x30, 0x30, 0x00,
-0x3c, 0x66, 0x66, 0x3c, 0x66, 0x66, 0x3c, 0x00, 0x3c, 0x66, 0x66, 0x3e, 0x06, 0x0c, 0x38, 0x00,
-0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x30,
-0x0c, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0c, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00,
-0x30, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x30, 0x00, 0x3c, 0x66, 0x0c, 0x18, 0x18, 0x00, 0x18, 0x00,
-
-0x3c, 0x66, 0x6e, 0x6a, 0x6e, 0x60, 0x3c, 0x00, 0x3c, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x66, 0x00,
-0x7c, 0x66, 0x66, 0x7c, 0x66, 0x66, 0x7c, 0x00, 0x3c, 0x66, 0x60, 0x60, 0x60, 0x66, 0x3c, 0x00,
-0x78, 0x6c, 0x66, 0x66, 0x66, 0x6c, 0x78, 0x00, 0x7e, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x7e, 0x00,
-0x7e, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x00, 0x3c, 0x66, 0x60, 0x6e, 0x66, 0x66, 0x3c, 0x00,
-0x66, 0x66, 0x66, 0x7e, 0x66, 0x66, 0x66, 0x00, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x00,
-0x3e, 0x0c, 0x0c, 0x0c, 0x0c, 0x6c, 0x38, 0x00, 0x66, 0x6c, 0x78, 0x70, 0x78, 0x6c, 0x66, 0x00,
-0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7e, 0x00, 0x63, 0x77, 0x7f, 0x6b, 0x6b, 0x63, 0x63, 0x00,
-0x66, 0x66, 0x76, 0x7e, 0x6e, 0x66, 0x66, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
-0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x60, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x6a, 0x6c, 0x36, 0x00,
-0x7c, 0x66, 0x66, 0x7c, 0x6c, 0x66, 0x66, 0x00, 0x3c, 0x66, 0x60, 0x3c, 0x06, 0x66, 0x3c, 0x00,
-0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00,
-0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x63, 0x63, 0x6b, 0x6b, 0x7f, 0x77, 0x63, 0x00,
-0x66, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0x66, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x00,
-0x7e, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x7e, 0x00, 0x7c, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7c, 0x00,
-0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x3e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x3e, 0x00,
-0x18, 0x3c, 0x66, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
-
-0x1c, 0x36, 0x30, 0x7c, 0x30, 0x30, 0x7e, 0x00, 0x00, 0x00, 0x3c, 0x06, 0x3e, 0x66, 0x3e, 0x00,
-0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x7c, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x60, 0x66, 0x3c, 0x00,
-0x06, 0x06, 0x3e, 0x66, 0x66, 0x66, 0x3e, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00,
-0x1c, 0x30, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x3e, 0x66, 0x66, 0x3e, 0x06, 0x3c,
-0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x3c, 0x00,
-0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x70, 0x60, 0x60, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0x00,
-0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, 0x00, 0x00, 0x36, 0x7f, 0x6b, 0x6b, 0x63, 0x00,
-0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00,
-0x00, 0x00, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60, 0x00, 0x00, 0x3e, 0x66, 0x66, 0x3e, 0x06, 0x07,
-0x00, 0x00, 0x6c, 0x76, 0x60, 0x60, 0x60, 0x00, 0x00, 0x00, 0x3e, 0x60, 0x3c, 0x06, 0x7c, 0x00,
-0x30, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x00,
-0x00, 0x00, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x00, 0x00, 0x00, 0x63, 0x6b, 0x6b, 0x7f, 0x36, 0x00,
-0x00, 0x00, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x3c,
-0x00, 0x00, 0x7e, 0x0c, 0x18, 0x30, 0x7e, 0x00, 0x0c, 0x18, 0x18, 0x70, 0x18, 0x18, 0x0c, 0x00,
-0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, 0x30, 0x18, 0x18, 0x0e, 0x18, 0x18, 0x30, 0x00,
-0x31, 0x6b, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
-};
--- a/main.cpp Sun Aug 05 12:47:00 2012 +0000
+++ b/main.cpp Fri Dec 21 14:00:03 2012 +0000
@@ -1,7 +1,9 @@
#include "mbed.h"
#include "GD.h"
#include "arduino.h"
+#include "shield.h"
+GDClass GD(ARD_MOSI, ARD_MISO, ARD_SCK, ARD_D9, USBTX, USBRX) ;
SPI spi(ARD_MOSI, ARD_MISO, ARD_SCK);// mosi, miso, sclk
DigitalOut cs(ARD_D9);
Serial pc(USBTX, USBRX);
@@ -15,9 +17,9 @@
// below.
#if 1 // SPARKFUN_JOYSTICK
-#define PIN_L ARD_D6
-#define PIN_R ARD_D3
-#define PIN_J ARD_D4
+#define PIN_L ARD_A0
+#define PIN_R ARD_A1
+#define PIN_J ARD_D6
#else
#define PIN_L ARD_A2
#define PIN_R ARD_A3
@@ -28,27 +30,42 @@
#define CONTROL_RIGHT 2
#define CONTROL_JUMP 4
-DigitalIn jump(p10);
-DigitalIn left(p11);
-DigitalIn right(p12);
+DigitalIn jump(ARD_D4);
+DigitalIn jumpa(ARD_D5);
+DigitalIn jumpb(ARD_D6);
+DigitalIn jumpc(ARD_D7);
+DigitalIn jumpd(ARD_A4);
+DigitalIn left(ARD_A1);
+DigitalIn right(ARD_A0);
static byte setup_control()
{
- jump.mode(PullDown);
- left.mode(PullDown);
- right.mode(PullDown);
+ jump.mode(PullUp);
+ jumpa.mode(PullUp);
+ jumpb.mode(PullUp);
+ jumpc.mode(PullUp);
+ jumpd.mode(PullUp);
+ left.mode(PullUp);
+ right.mode(PullUp);
}
static byte control()
{
byte r = 0;
- if (jump)
+ //if (jump)
+ // r |= CONTROL_JUMP;
+ if (!jumpa)
+ r |= CONTROL_JUMP;
+ if (!jumpb)
r |= CONTROL_JUMP;
- if (left)
+ if (!jumpc)
+ r |= CONTROL_JUMP;
+ if (!jumpd)
+ r |= CONTROL_JUMP;
+ if (!left)
r |= CONTROL_LEFT;
- if (right)
+ if (!right)
r |= CONTROL_RIGHT;
- r = 0;
return r;
}
@@ -996,7 +1013,6 @@
int main(){
- arduino_setup();
setup();
while(1){
loop();
Gameduino Shield