diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 6257a22..7854ef3 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -107,6 +107,11 @@ rockboy.c zxbox.c #endif +/* overlay loader for Goban */ +#if (PLUGIN_BUFFER_SIZE < 0x10000) && !defined(SIMULATOR) +goban.c +#endif + /* not support recorder models for now */ #if (LCD_WIDTH > 112) && (LCD_HEIGHT > 64) fireworks.c diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS index f07bf86..af5e1d0 100644 --- a/apps/plugins/SUBDIRS +++ b/apps/plugins/SUBDIRS @@ -20,10 +20,7 @@ chessbox jpeg sudoku reversi -/* Plugin is about 40k, rounding up to 65k to be safe. */ -#if (defined(PLUGIN_BUFFER_SIZE) && PLUGIN_BUFFER_SIZE >= 0x10000) goban -#endif #ifndef OLYMPUS_MROBE_500 zxbox #endif diff --git a/apps/plugins/goban.c b/apps/plugins/goban.c new file mode 100644 index 0000000..8c8aa7a --- /dev/null +++ b/apps/plugins/goban.c @@ -0,0 +1,33 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id$ + * + * Copyright (C) 2007-2009 Joshua Simmons + * + * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include "plugin.h" + +#if PLUGIN_BUFFER_SIZE < 0x10000 && !defined(SIMULATOR) + +#include "lib/overlay.h" + +PLUGIN_HEADER + +enum plugin_status plugin_start(const void* parameter) +{ + return run_overlay(parameter, PLUGIN_GAMES_DIR "/goban.ovl", "Goban"); +} +#endif diff --git a/apps/plugins/goban/archos.lds b/apps/plugins/goban/archos.lds new file mode 100644 index 0000000..c17346f --- /dev/null +++ b/apps/plugins/goban/archos.lds @@ -0,0 +1,43 @@ +#include "config.h" + +/* linker script for goban as an overlay */ + +OUTPUT_FORMAT(elf32-sh) + +#define DRAMORIG 0x09000000 +#define PLUGIN_LENGTH PLUGIN_BUFFER_SIZE + +#define OVERLAY_LENGTH 0x10000 +#define OVERLAY_ORIGIN (DRAMORIG + (MEMORYSIZE * 0x100000) - PLUGIN_LENGTH - OVERLAY_LENGTH) + +MEMORY +{ + OVERLAY_RAM : ORIGIN = OVERLAY_ORIGIN, LENGTH = OVERLAY_LENGTH +} + +SECTIONS +{ + .header : { + _plugin_start_addr = .; + KEEP(*(.header)) + } > OVERLAY_RAM + + .text : { + *(.text*) + } > OVERLAY_RAM + + .rodata : { + *(.rodata*) + } > OVERLAY_RAM + + .data : { + *(.data*) + } > OVERLAY_RAM + + .bss : { + *(.bss*) + *(COMMON) + . = ALIGN(0x4); + _plugin_end_addr = .; + } > OVERLAY_RAM +} diff --git a/apps/plugins/goban/goban.h b/apps/plugins/goban/goban.h index 8c7ca9a..12c5890 100644 --- a/apps/plugins/goban/goban.h +++ b/apps/plugins/goban/goban.h @@ -23,9 +23,7 @@ #define GOBAN_MAIN_H /* Enable this to run test mode. (see the end of util.c) */ -#if 0 #define GBN_TEST -#endif #include "types.h" #include "util.h" diff --git a/apps/plugins/goban/goban.make b/apps/plugins/goban/goban.make index f3f96ff..b8866fb 100644 --- a/apps/plugins/goban/goban.make +++ b/apps/plugins/goban/goban.make @@ -8,15 +8,41 @@ # -GOBANSRCDIR := $(APPSDIR)/plugins/goban -GOBANBUILDDIR := $(BUILDDIR)/apps/plugins/goban +GOBAN_SRCDIR := $(APPSDIR)/plugins/goban +GOBAN_BUILDDIR := $(BUILDDIR)/apps/plugins/goban -ROCKS += $(GOBANBUILDDIR)/goban.rock - - -GOBAN_SRC := $(call preprocess, $(GOBANSRCDIR)/SOURCES) +GOBAN_SRC := $(call preprocess, $(GOBAN_SRCDIR)/SOURCES) GOBAN_OBJ := $(call c2obj, $(GOBAN_SRC)) OTHER_SRC += $(GOBAN_SRC) -$(GOBANBUILDDIR)/goban.rock: $(GOBAN_OBJ) +ifndef SIMVER +ifneq (,$(strip $(foreach tgt,RECORDER ONDIO,$(findstring $(tgt),$(TARGET))))) + ### archos recorder targets + GOBAN_INLDS := $(GOBAN_SRCDIR)/archos.lds + ROCKS += $(GOBAN_BUILDDIR)/goban.ovl +else + ### all other targets + GOBAN_INLDS := $(APPSDIR)/plugins/plugin.lds + ROCKS += $(GOBAN_BUILDDIR)/goban.rock +endif + GOBAN_OVLFLAGS = -T$(GOBAN_OUTLDS) -Wl,--gc-sections -Wl,-Map,$(basename $@).map + GOBAN_OUTLDS = $(GOBAN_BUILDDIR)/goban.lds +else + ### simulator + ROCKS += $(GOBAN_BUILDDIR)/goban.rock + GOBAN_OVLFLAGS = $(SHARED_FLAG) # <-- from Makefile +endif + +$(GOBAN_OUTLDS): $(GOBAN_INLDS) $(GOBAN_OBJ) + $(call PRINTS,PP $(splash (2 * HZ, "Stopping music playback to get more space"); + rb->splash (1 * HZ, "Stopping music playback to get more space"); DEBUGF ("storage_buffer_size < MIN!!: %d\n", (int) total_storage_size); temp_buffer = rb->plugin_get_audio_buffer (&size); @@ -335,7 +335,7 @@ setup_sgf (void) if (total_storage_size < MIN_STORAGE_BUFFER_SIZE) { - rb->splash (5 * HZ, "Low memory. Large files may not load."); + rb->splash (1 * HZ, "Low memory. Large files may not load."); DEBUGF ("storage_buffer_size < MIN!!!!: %d\n", (int) total_storage_size); @@ -387,6 +387,15 @@ setup_storage_buffer (char *temp_buffer, size_t size) unsigned int index = 0; int temp; +#if PLUGIN_BUFFER_SIZE < 0x10000 && !defined(SIMULATOR) + /* loaded as an overlay plugin, protect from overwriting ourselves */ + if (plugin_start_addr >= (unsigned char *) temp_buffer && + plugin_start_addr < (unsigned char *) temp_buffer + size) + { + size = plugin_start_addr - (unsigned char *) temp_buffer; + } +#endif + while (1) { if (index >= sizeof (storage_initialized) / diff --git a/apps/plugins/goban/util.c b/apps/plugins/goban/util.c index e996631..f3c1f12 100644 --- a/apps/plugins/goban/util.c +++ b/apps/plugins/goban/util.c @@ -520,19 +520,20 @@ get_header_string_and_size (struct header_t *header, #include "game.h" #include "sgf.h" #include "sgf_storage.h" +#include "lib/helper.h" /* If this isn't on a single line, the line numbers it reports will be wrong. * * I'm sure there's a way to make it better, but it's not really worth it. */ -#define gbn_assert(test) if (test) {DEBUGF("%d passed\n", __LINE__);} else {DEBUGF("%d FAILED!\n", __LINE__); rb->splashf(10 * HZ, "Test on line %d of util.c failed!", __LINE__); return;} +#define gbn_assert(test) if (test) {DEBUGF("%d passed\n", __LINE__);} else {DEBUGF("%d FAILED!\n", __LINE__); rb->splashf(10 * HZ, "Test on line %d of util.c failed!", __LINE__); backlight_use_settings(); return;} void run_tests (void) { rb->splash (3 * HZ, "Running tests. Failures will stop testing."); - + backlight_force_on(); /* allocating and freeing storage units */ @@ -816,7 +817,30 @@ run_tests (void) gbn_assert (rb->strcmp (header.white, "Jill White") == 0); gbn_assert (redo_node_sgf ()); gbn_assert (read_comment_sgf (read_buffer, sizeof (read_buffer))); - gbn_assert (rb->strcmp (read_buffer, some_comment) == 0); + + int result = rb->strcmp (read_buffer, some_comment); + if (result != 0) + { + rb->splashf (7 * HZ, "Comment lengths: %d %d", + (int)rb->strlen(read_buffer), + (int)rb->strlen(some_comment)); + + int diff_char = 0; + while (read_buffer[diff_char] && some_comment[diff_char] && + (read_buffer[diff_char] == some_comment[diff_char])) + { + ++diff_char; + } + + if (!read_buffer[diff_char] || !some_comment[diff_char]) + { + rb->splashf (7 * HZ, "Comments differ on: %d %d %d", + diff_char, read_buffer[diff_char], + some_comment[diff_char]); + } + + gbn_assert (false); + } gbn_assert (redo_node_sgf ()); gbn_assert (get_point_board (POS (0, 0)) == WHITE); gbn_assert (get_point_board (POS (0, 1)) == BLACK); @@ -881,5 +905,6 @@ run_tests (void) gbn_assert (get_point_board (POS (1, 3)) == EMPTY); rb->splash (10 * HZ, "All tests passed. Exiting"); + backlight_use_settings(); } #endif /* GBN_TEST */