From a3cfe0a434fd1ef5e4a59e34499d10cd0211f76b Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Thu, 23 Feb 2006 21:16:51 +0000 Subject: Fixes to Chessclock from Miguel (to make it work again after we broke his patch), plus iPod button mapping changes from me git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8816 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/chessbox/Makefile | 3 +-- apps/plugins/chessbox/chessbox.c | 13 +++++-------- apps/plugins/chessbox/gnuchess.c | 10 ++++++---- apps/plugins/chessbox/gnuchess.h | 5 ++++- 4 files changed, 16 insertions(+), 15 deletions(-) (limited to 'apps/plugins') diff --git a/apps/plugins/chessbox/Makefile b/apps/plugins/chessbox/Makefile index be75b2c5e1..05b6d8f6a7 100644 --- a/apps/plugins/chessbox/Makefile +++ b/apps/plugins/chessbox/Makefile @@ -9,7 +9,7 @@ INCLUDES = -I$(APPSDIR) -I.. -I. -I$(FIRMDIR)/include -I$(FIRMDIR)/export \ -I$(FIRMDIR)/common -I$(FIRMDIR)/drivers -I$(OUTDIR) -I$(BUILDDIR) -CFLAGS = $(GCCOPTS) -O3 $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \ +CFLAGS = $(GCCOPTS) $(INCLUDES) $(TARGET) $(EXTRA_DEFINES) \ -DTARGET_ID=$(TARGET_ID) -DMEM=${MEMORYSIZE} -DPLUGIN ifdef APPEXTRA @@ -109,4 +109,3 @@ clean: @rm -f $(OBJDIR)/chessbox.* $(DEPFILE) -include $(DEPFILE) - diff --git a/apps/plugins/chessbox/chessbox.c b/apps/plugins/chessbox/chessbox.c index d16497dc6a..0d145ec00a 100644 --- a/apps/plugins/chessbox/chessbox.c +++ b/apps/plugins/chessbox/chessbox.c @@ -31,9 +31,6 @@ struct cb_command { unsigned short mv; }; -/* global rockbox api */ -static struct plugin_api* rb; - /* External bitmaps */ extern const fb_data chessbox_pieces[]; @@ -43,13 +40,13 @@ PLUGIN_HEADER /* button definitions */ #if (CONFIG_KEYPAD == IPOD_3G_PAD) || (CONFIG_KEYPAD == IPOD_4G_PAD) #define CB_SELECT BUTTON_SELECT -#define CB_UP BUTTON_SCROLL_BACK -#define CB_DOWN BUTTON_SCROLL_FWD +#define CB_UP BUTTON_MENU +#define CB_DOWN BUTTON_PLAY #define CB_LEFT BUTTON_LEFT #define CB_RIGHT BUTTON_RIGHT -#define CB_PLAY BUTTON_PLAY -#define CB_LEVEL BUTTON_MENU -#define CB_QUIT BUTTON_REL +#define CB_PLAY (BUTTON_SELECT | BUTTON_PLAY) +#define CB_LEVEL (BUTTON_SELECT | BUTTON_RIGHT) +#define CB_QUIT (BUTTON_SELECT | BUTTON_MENU) #elif CONFIG_KEYPAD == IAUDIO_X5_PAD #define CB_SELECT BUTTON_MENU diff --git a/apps/plugins/chessbox/gnuchess.c b/apps/plugins/chessbox/gnuchess.c index ed4a7f2a0f..45ca66e778 100644 --- a/apps/plugins/chessbox/gnuchess.c +++ b/apps/plugins/chessbox/gnuchess.c @@ -66,7 +66,7 @@ #define taxicab(a,b) (abs(column[a]-column[b]) + abs(row[a]-row[b])) /* ---- RockBox datatypes and variables */ -static struct plugin_api* rb; +struct plugin_api* rb; /* ---- Chess datatypes and variables ---- */ struct leaf @@ -332,8 +332,7 @@ short pscore[3]; xside = otherside[side]; pscore[white] = pscore[black] = 0; - /* ok, I will yield here although this function will be called much more - many times than needed I think */ + /* ok, I will yield here for lower levels */ rb->yield(); for (c1 = white; c1 <= black; c1++) @@ -1238,6 +1237,9 @@ short xside,pbst,d,e,cf,score,rcnt; unsigned short mv,nxtline[maxdepth]; struct leaf *node,tmp; + /* ok, I will yield here for higher levels */ + rb->yield(); + NodeCnt++; xside = otherside[side]; @@ -2353,7 +2355,7 @@ void GNUChess_Initialize ( void ) { /*ttable = (struct hashentry *)malloc(ttblsz * (unsigned long)sizeof(struct hashentry));*/ buffer_size = ttblsz * sizeof(struct hashentry); - ttable = rb->plugin_get_buffer( &buffer_size ); + ttable = (struct hashentry *)rb->plugin_get_buffer( &buffer_size ); Level = 1; OperatorTime = 0; TCmoves = 60; diff --git a/apps/plugins/chessbox/gnuchess.h b/apps/plugins/chessbox/gnuchess.h index 6ea77dc00b..68ef9f9a81 100644 --- a/apps/plugins/chessbox/gnuchess.h +++ b/apps/plugins/chessbox/gnuchess.h @@ -19,7 +19,7 @@ #define valueQ 1100 #define valueK 1200 - +/* ---- chess system global variables ---- */ extern short mate,opponent,computer; extern short locn[8][8]; extern short board[64]; @@ -27,7 +27,10 @@ extern short color[64]; extern long Level; extern short TCflag,TCmoves,TCminutes; +/* ---- RockBox integration ---- */ +extern struct plugin_api* rb; +/* ---- The beginning of a GNUChess v2 APIfication ---- */ void SetTimeControl(void); void GNUChess_Initialize(void); int VerifyMove(char s[],short iop,unsigned short *mv); -- cgit v1.2.3