roox has uploaded this change for review. (
https://gerrit.osmocom.org/c/osmocom-bb/+/19484 )
Change subject: Initial commit for the game Snake.
..
Initial commit for the game Snake.
It does not much by now but I hope to change that soon.
Change-Id: I6a409074285fda90f966b1727c9c0f068dd050d3
---
M src/target/firmware/Makefile.inc
A src/target/firmware/apps/snake_game/main.c
2 files changed, 179 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/84/19484/1
diff --git a/src/target/firmware/Makefile.inc b/src/target/firmware/Makefile.inc
index a91cf4f..2be240d 100644
--- a/src/target/firmware/Makefile.inc
+++ b/src/target/firmware/Makefile.inc
@@ -39,6 +39,7 @@
GIT VERSION
GIT_COMMIT:=$(shell git describe --always)
+GIT_SHORTHASH:=$(shell git rev-parse --short HEAD)
GIT_MODIFIED:=$(shell (git status | grep "modified:\|added:\|deleted:" -q) &&
echo "-modified")
GIT_REVISION:=$(GIT_COMMIT)$(GIT_MODIFIED)
@@ -46,6 +47,9 @@
ASFLAGS += -DGIT_REVISION=\"$(GIT_REVISION)\"
CFLAGS += -DGIT_REVISION=\"$(GIT_REVISION)\"
+ASFLAGS += -DGIT_SHORTHASH=\"$(GIT_SHORTHASH)\"
+CFLAGS += -DGIT_SHORTHASH=\"$(GIT_SHORTHASH)\"
+
GLOBAL DATA
ALL_OBJS=
diff --git a/src/target/firmware/apps/snake_game/main.c
b/src/target/firmware/apps/snake_game/main.c
new file mode 100644
index 000..63dba3f
--- /dev/null
+++ b/src/target/firmware/apps/snake_game/main.c
@@ -0,0 +1,175 @@
+/* The game Snake as Free Software for Calypso Phone */
+
+/* (C) 2013 by Marcel `sdrfnord` McKinnon
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* Main Program */
+const char *hr =
"==\n";
+
+void key_handler(enum key_codes code, enum key_states state);
+
+static void console_rx_cb(uint8_t dlci, struct msgb *msg)
+{
+ if (dlci != SC_DLCI_CONSOLE) {
+ printf("Message for unknown DLCI %u\n", dlci);
+ return;
+ }
+
+ printf("Message on console DLCI: '%s'\n", msg->data);
+ msgb_free(msg);
+}
+
+static void l1a_l23_rx_cb(uint8_t dlci, struct msgb *msg)
+{
+ int i;
+ puts("l1a_l23_rx_cb: ");
+ for (i = 0; i < msg->len; i++)
+ printf("%02x ", msg->data[i]);
+ puts("\n");
+}
+
+int main(void)
+{
+ board_init(1);
+
+ puts("\n\nOsmocomBB Test sdrfnord (revision " GIT_REVISION ")\n");
+ puts(hr);
+
+ /* Dump device identification */
+ dump_dev_id();
+ puts(hr);
+
+ /* Dump clock config before PLL set */
+ calypso_clk_dump();
+ puts(hr);
+
+ keypad_set_handler(_handler);
+
+ /* Dump clock config after PLL set */
+ calypso_clk_dump();
+ puts(hr);
+
+ fb_clear();
+bl_level(255);
+
+ fb_setfg(FB_COLOR_BLACK);
+ fb_setbg(FB_COLOR_WHITE);
+ fb_setfont(FB_FONT_HELVB14);
+
+ fb_gotoxy(framebuffer->width/2 - 7 * 3, 15);
+ fb_putstr("Snake",framebuffer->width-4);
+
+ fb_gotoxy(14, framebuffer->height-5);
+fb_setfont(FB_FONT_HELVR08);
+ fb_putstr("Version: " GIT_SHORTHASH, framebuffer->width-4);
+ fb_gotoxy(0, 0);
+fb_boxto(framebuffer->width - 1, 1);
+fb_boxto(framebuffer->width - 2, framebuffer->height-1);
+fb_boxto(0, framebuffer->height-2);
+fb_boxto(1, 1);
+/* set_pixel_r(9,9); */
+/* set_pixel_r(10,10); */
+/* set_pixel_r(10,11); */
+/* set_pixel_r(10,12); */
+/* set_pixel_r(12,10); */
+/* set_pixel_r(0,0); */
+printf("(%u, %u)\n", framebuffer->width, framebuffer->height);
+ fb_gotoxy(2, 2);
+fb_lineto(framebuffer->width-3, framebuffer->height-3);
+ fb_gotoxy(2, framebuffer->height-3);
+fb_lineto(framebuffer->width-3, 2);
+
+ fb_setfg(FB_COLOR_WHITE);
+ fb_setbg(FB_COLOR_BLACK);
+fb_lineto(2, 20);
+
+ fb_flush();
+
+
+
+ sercomm_register_rx_cb(SC_DLCI_CONSOLE, console_rx_cb);
+