From 0403e99362b2a88adec5e3454b831e9f1e57bdac Mon Sep 17 00:00:00 2001 From: Thammi Date: Thu, 11 Aug 2011 17:35:17 +0200 Subject: [PATCH 1/7] Adding a very small tron/snake like game --- firmware/l0dable/tron.c | 98 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 firmware/l0dable/tron.c diff --git a/firmware/l0dable/tron.c b/firmware/l0dable/tron.c new file mode 100644 index 0000000..4fb8428 --- /dev/null +++ b/firmware/l0dable/tron.c @@ -0,0 +1,98 @@ +#include +#include + +#include "basic/basic.h" +#include "basic/random.h" +#include "lcd/display.h" +#include "usetable.h" + +void randomizeCoin(int* x, int* y); + +void ram() { + int key; + + int d = 0; + int x = RESX / 2; + int y = RESY / 2; + + int p = 0; + int q, r; + + randomizeCoin(&q, &r); + + lcdClear(); + + while (1) { + // display + lcdSetPixel(q, r, p % 3); + lcdSetPixel(x, y, 1); + lcdDisplay(); + + // wait + + delayms(20); + + // input + + key=getInputRaw(); + + switch(key) { + case BTN_RIGHT: + d = 3; + break; + case BTN_LEFT: + d = 2; + break; + case BTN_UP: + d = 0; + break; + case BTN_DOWN: + d = 1; + break; + case BTN_ENTER: + return; + } + + // step + + if(d > 1) { + x = (RESX + x + (d & 1) * 2 - 1) % RESX; + } else { + y = (RESY + y + d * 2 - 1) % RESY; + } + + p += 1; + + // collision + + if(x == q && y == r) { + p += 99; + randomizeCoin(&q, &r); + } else if(lcdGetPixel(x, y)) { + lcdClear(); + lcdPrintln("You lost!"); + lcdNl(); + lcdPrintInt(p); + lcdPrintln(" points"); + lcdDisplay(); + + while(getInputRaw() != BTN_ENTER); + + return; + } + } + return; +} + +void randomizeCoin(int* x, int* y) { + // WARNING: if you are really got at this the game freezes :D + for(;;) { + *x = getRandom() % RESX; + *y = getRandom() % RESY; + + if(!lcdGetPixel(*x, *y)) { + return; + } + } +} + From efbb72a31de80080a4e61805ff218279c8f387c0 Mon Sep 17 00:00:00 2001 From: Thammi Date: Thu, 11 Aug 2011 17:42:30 +0200 Subject: [PATCH 2/7] Adding author and license information to tron --- firmware/l0dable/tron.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firmware/l0dable/tron.c b/firmware/l0dable/tron.c index 4fb8428..52a6978 100644 --- a/firmware/l0dable/tron.c +++ b/firmware/l0dable/tron.c @@ -1,3 +1,7 @@ +/* + * Pizzaware by Thammi from Pentaville + */ + #include #include From e3b1ff3a22ea0608f5ecc56dcde47149cf92a381 Mon Sep 17 00:00:00 2001 From: Thammi Date: Fri, 12 Aug 2011 21:41:06 +0200 Subject: [PATCH 3/7] Getting personal when losing tron --- firmware/l0dable/tron.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/firmware/l0dable/tron.c b/firmware/l0dable/tron.c index 52a6978..419a1a9 100644 --- a/firmware/l0dable/tron.c +++ b/firmware/l0dable/tron.c @@ -74,7 +74,11 @@ void ram() { randomizeCoin(&q, &r); } else if(lcdGetPixel(x, y)) { lcdClear(); - lcdPrintln("You lost!"); + lcdPrint("You failed,"); + lcdNl(); + lcdPrint(nickname); + lcdPrint("!"); + lcdNl(); lcdNl(); lcdPrintInt(p); lcdPrintln(" points"); From e0ad56aebc3608f10392e469d4a99c98a3862e82 Mon Sep 17 00:00:00 2001 From: Thammi Date: Fri, 12 Aug 2011 21:42:13 +0200 Subject: [PATCH 4/7] Removing pizzaware licence to use bsd --- firmware/l0dable/tron.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/l0dable/tron.c b/firmware/l0dable/tron.c index 419a1a9..78d6364 100644 --- a/firmware/l0dable/tron.c +++ b/firmware/l0dable/tron.c @@ -1,5 +1,5 @@ /* - * Pizzaware by Thammi from Pentaville + * coded by Thammi from Pentaville */ #include From 7f15ac9a4cc4ad747e8eb29e6b823d3927fe4c9b Mon Sep 17 00:00:00 2001 From: Thammi Date: Fri, 12 Aug 2011 23:08:45 +0200 Subject: [PATCH 5/7] Fixing village name --- firmware/l0dable/tron.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/l0dable/tron.c b/firmware/l0dable/tron.c index 78d6364..c238fd5 100644 --- a/firmware/l0dable/tron.c +++ b/firmware/l0dable/tron.c @@ -1,5 +1,5 @@ /* - * coded by Thammi from Pentaville + * coded by Thammi from Pentagon Village */ #include From 33fe346942176a0e988818980d04d1a8f746f894 Mon Sep 17 00:00:00 2001 From: Stefan Tomanek Date: Sat, 13 Aug 2011 14:14:12 +0200 Subject: [PATCH 6/7] add w0rpcore nickname l0dable This l0dable by Benedikt Roth and Stefan Tomanek serves as your main viewscreen, displaying your nickname the way you want it, and lets the stars zoom by. You can accelerate your vessel by pushing the joystick upwards or bring it to a halt by pressing it down - leaving your ship drifting in the endless space. Attach two LEDs to the modulbus connectors (SS2->GND, SS5->GND), so your r0ket can light up its nacelles when breaking the warp barrier. --- firmware/l0dable/nick_w0rpcore.c | 157 +++++++++++++++++++++++++++++++ 1 file changed, 157 insertions(+) create mode 100644 firmware/l0dable/nick_w0rpcore.c diff --git a/firmware/l0dable/nick_w0rpcore.c b/firmware/l0dable/nick_w0rpcore.c new file mode 100644 index 0000000..ca4df31 --- /dev/null +++ b/firmware/l0dable/nick_w0rpcore.c @@ -0,0 +1,157 @@ +#include + +#include "basic/basic.h" +#include "basic/config.h" + +#include "lcd/lcd.h" +#include "lcd/print.h" + +#include "usetable.h" + +#define NUM_STARS 100 +#define SPEED_MAX 10 +#define SPEED_DEFAULT 4 +#define SPEED_STOP 0 +#define SPEED_WARP 6 + +// Two RGB LEDs on the Modulbus +#define LEDA_R RB_SPI_SS0 +#define LEDA_G RB_SPI_SS1 +#define LEDA_B RB_SPI_SS2 + +#define LEDB_R RB_SPI_SS3 +#define LEDB_G RB_SPI_SS4 +#define LEDB_B RB_SPI_SS5 + +typedef struct { + short x, y, z; +} s_star; + +typedef struct { + short speed; +} s_ship; + +static s_ship ship = {SPEED_DEFAULT}; + +static s_star stars[NUM_STARS]; + +void init_star(s_star *star, int z); +void set_warp_lights(uint8_t enabled); +void drift_ship(void); + +void ram(void) +{ + short centerx = RESX >> 1; + short centery = RESY >> 1; + short i; + uint8_t key = 0; + + for (i = 0; i < NUM_STARS; i++) { + init_star(stars + i, i + 1); + } + + static uint8_t count = 0; + while(1) { + count++; + count%=256; + key = getInputRaw(); + if (key == BTN_ENTER) { + break; + } else if ( count%4 == 0 ) { + if (key == BTN_UP && ship.speed < SPEED_MAX) { + ship.speed++; + } else if (key == BTN_DOWN && ship.speed > SPEED_STOP) { + ship.speed--; + } else if (key ==BTN_NONE) { + /* converge towards default speed */ + if (ship.speed < SPEED_DEFAULT) { + ship.speed++; + } else if (ship.speed > SPEED_DEFAULT) { + ship.speed--; + } + } + } + + if (ship.speed > SPEED_WARP) { + set_warp_lights(1); + } else { + set_warp_lights(0); + } + + if (ship.speed == 0 && count%6==0) drift_ship(); + + int dx=0; + int dy=0; + setExtFont(GLOBAL(nickfont)); + dx=DoString(0,0,GLOBAL(nickname)); + dx=(RESX-dx)/2; + if(dx<0) dx=0; + dy=(RESY-getFontHeight())/2; + + lcdClear(); + DoString(dx,dy,GLOBAL(nickname)); + + for (i = 0; i < NUM_STARS; i++) { + stars[i].z -= ship.speed; + + if (ship.speed > 0 && stars[i].z <= 0) + init_star(stars + i, i + 1); + + short tempx = ((stars[i].x * 30) / stars[i].z) + centerx; + short tempy = ((stars[i].y * 30) / stars[i].z) + centery; + + if (tempx < 0 || tempx > RESX - 1 || tempy < 0 || tempy > RESY - 1) { + if (ship.speed > 0) { /* if we are flying, generate new stars in front */ + init_star(stars + i, i + 1); + } else { /* if we are drifting, simply move those stars to the other end */ + stars[i].x = (((tempx%RESX)-centerx)*stars[i].z)/30; + stars[i].y = (((tempy%RESY)-centery)*stars[i].z)/30; + } + continue; + } + + lcdSetPixel(tempx, tempy, 1); + if (stars[i].z < 50) { + lcdSetPixel(tempx + 1, tempy, 1); + } + if (stars[i].z < 20) { + lcdSetPixel(tempx, tempy + 1, 1); + lcdSetPixel(tempx + 1, tempy + 1, 1); + } + } + + lcdRefresh(); + + delayms_queue_plus(50,0); + } + set_warp_lights(0); +} + +void set_warp_lights(uint8_t enabled) { + gpioSetValue(LEDA_R, 0); + gpioSetValue(LEDA_G, 0); + gpioSetValue(LEDA_B, enabled); + + gpioSetValue(LEDB_R, 0); + gpioSetValue(LEDB_G, 0); + gpioSetValue(LEDB_B, enabled); +} + +void drift_ship(void) { + uint8_t d_x = 1; + uint8_t d_y = 1; + for (uint8_t i = 0; i < NUM_STARS; i++) { + stars[i].x += d_x; + stars[i].y += d_y; + } +} + +void init_star(s_star *star, int z) +{ + star->x = (getRandom() % RESX) - (RESX >> 1); + star->y = (getRandom() % RESY) - (RESY >> 1); + star->z = z; + + return; +} + From d82dde9ecf0d9b088c366fc52c0e6d12ac58afe5 Mon Sep 17 00:00:00 2001 From: schneider Date: Thu, 19 Jan 2012 01:32:05 +0100 Subject: [PATCH 7/7] added authors to w0rpcore --- firmware/l0dable/nick_w0rpcore.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/firmware/l0dable/nick_w0rpcore.c b/firmware/l0dable/nick_w0rpcore.c index ca4df31..57a5526 100644 --- a/firmware/l0dable/nick_w0rpcore.c +++ b/firmware/l0dable/nick_w0rpcore.c @@ -1,3 +1,15 @@ +/* + * This l0dable by Benedikt Roth and Stefan Tomanek serves as your main + * viewscreen, displaying your nickname the way you want it, and lets the + * stars zoom by. You can accelerate your vessel by pushing the joystick + * upwards or bring it to a halt by pressing it down - leaving your ship + * drifting in the endless space. Attach two LEDs to the modulbus + * connectors (SS2->GND, SS5->GND), so your r0ket can light up its nacelles + * when breaking the warp barrier. + * + * commit 33fe346942176a0e988818980d04d1a8f746f894 1 parent 0eaf74fa87 + * wertarbyte authored August 13, 2011 + */ #include #include "basic/basic.h"