summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2005-12-20 22:57:04 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2005-12-20 22:57:04 +0000
commitca1a1ab141f745660ebceae9d70b827314ea29b8 (patch)
tree1cb9a03b7678c573d9faaf8a540204390b2c6d8b
parent735f8273f067869596ccef2e537c941c270ca950 (diff)
downloadrockbox-ca1a1ab141f745660ebceae9d70b827314ea29b8.tar.gz
rockbox-ca1a1ab141f745660ebceae9d70b827314ea29b8.zip
H300: Colors for solitaire by Ben Basha
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8267 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/solitaire.c727
-rw-r--r--docs/CREDITS1
2 files changed, 482 insertions, 246 deletions
diff --git a/apps/plugins/solitaire.c b/apps/plugins/solitaire.c
index ea56e2a693..306c0dcc8d 100644
--- a/apps/plugins/solitaire.c
+++ b/apps/plugins/solitaire.c
@@ -16,9 +16,10 @@
16 * KIND, either express or implied. 16 * KIND, either express or implied.
17 * 17 *
18 ****************************************************************************/ 18 ****************************************************************************/
19 19
20/***************************************************************************** 20/*****************************************************************************
21Solitaire by dionoea 21Solitaire by dionoea
22Graphics & Fix Bugs by Ben Basha
22 23
23use arrows to move the cursor 24use arrows to move the cursor
24use ON to select cards, move cards, reveal hidden cards, ... 25use ON to select cards, move cards, reveal hidden cards, ...
@@ -31,9 +32,11 @@ use F3 to put card on top of the remains' stack on one of the 4 final stacks
31*****************************************************************************/ 32*****************************************************************************/
32 33
33#include "plugin.h" 34#include "plugin.h"
35#include "configfile.h"
34#include "button.h" 36#include "button.h"
35#include "lcd.h" 37#include "lcd.h"
36 38
39
37#ifdef HAVE_LCD_BITMAP 40#ifdef HAVE_LCD_BITMAP
38 41
39/* here is a global api struct pointer. while not strictly necessary, 42/* here is a global api struct pointer. while not strictly necessary,
@@ -43,6 +46,7 @@ static struct plugin_api* rb;
43 46
44#define min(a,b) (a<b?a:b) 47#define min(a,b) (a<b?a:b)
45 48
49
46/* variable button definitions */ 50/* variable button definitions */
47#if CONFIG_KEYPAD == RECORDER_PAD 51#if CONFIG_KEYPAD == RECORDER_PAD
48#define SOL_QUIT BUTTON_OFF 52#define SOL_QUIT BUTTON_OFF
@@ -100,23 +104,8 @@ static struct plugin_api* rb;
100#define SOL_MENU_RUN BUTTON_SELECT 104#define SOL_MENU_RUN BUTTON_SELECT
101#define SOL_MENU_RUN2 BUTTON_RIGHT 105#define SOL_MENU_RUN2 BUTTON_RIGHT
102#define SOL_MENU_INFO BUTTON_MODE 106#define SOL_MENU_INFO BUTTON_MODE
103#define SOL_MENU_INFO2 BUTTON_REC 107#define SOL_OPT BUTTON_ON
104 108#define SOL_REM BUTTON_REC
105#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
106
107#define SOL_QUIT (BUTTON_SELECT | BUTTON_MENU)
108#define SOL_UP BUTTON_MENU
109#define SOL_DOWN BUTTON_PLAY
110#define SOL_LEFT BUTTON_LEFT
111#define SOL_RIGHT BUTTON_RIGHT
112#define SOL_MOVE BUTTON_SELECT
113#define SOL_DRAW (BUTTON_SELECT | BUTTON_PLAY)
114#define SOL_REM2CUR (BUTTON_SELECT | BUTTON_LEFT)
115#define SOL_CUR2STACK (BUTTON_SELECT | BUTTON_RIGHT)
116#define SOL_REM2STACK (BUTTON_LEFT | BUTTON_RIGHT)
117#define SOL_MENU_RUN BUTTON_SELECT
118#define SOL_MENU_INFO (BUTTON_PLAY | BUTTON_MENU)
119
120#endif 109#endif
121 110
122/* common help definitions */ 111/* common help definitions */
@@ -148,13 +137,6 @@ static struct plugin_api* rb;
148#define HELP_SOL_CUR2STACK "SELECT..: Put the card under the cursor on one of the 4 final stacks." 137#define HELP_SOL_CUR2STACK "SELECT..: Put the card under the cursor on one of the 4 final stacks."
149#define HELP_SOL_REM2STACK "PLAY+RIGHT: Put the card on top of the remains' stack on one of the 4 final stacks." 138#define HELP_SOL_REM2STACK "PLAY+RIGHT: Put the card on top of the remains' stack on one of the 4 final stacks."
150 139
151#elif (CONFIG_KEYPAD == IPOD_4G_PAD)
152#define HELP_SOL_MOVE "SELECT: Select cards, Move cards, reveal hidden cards ..."
153#define HELP_SOL_DRAW "SELECT+PLAY: Un-select a card if it was selected. Else, draw 3 new cards out of the remains' stack."
154#define HELP_SOL_REM2CUR "SELECT+LEFT: Put the card on top of the remains' stack on top of the cursor."
155#define HELP_SOL_CUR2STACK "SELECT+RIGHT..: Put the card under the cursor on one of the 4 final stacks."
156#define HELP_SOL_REM2STACK "LEFT+RIGHT: Put the card on top of the remains' stack on one of the 4 final stacks."
157
158#endif 140#endif
159 141
160#if LCD_DEPTH>1 142#if LCD_DEPTH>1
@@ -167,165 +149,162 @@ static const unsigned colors[4] = {
167}; 149};
168#endif 150#endif
169 151
170static const unsigned char suits[4][8] = { 152#define BMPHEIGHT_c 10
153#define BMPWIDTH_c 8
154#define BMPHEIGHT_BACKSIDE 33
155#define BMPWIDTH_BACKSIDE 26
156
157static const unsigned short backside[33*26] = {
1580x9572, 0xdf3a, 0xdf3a, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39,
1590xdf3a, 0xdf3a, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39, 0xdf39,
1600xdf39, 0xdf39, 0xdf39, 0xdf3a, 0xdf3a, 0x9572,
1610xe77b, 0xfffc, 0xffbc, 0xfffd, 0xfffd, 0xfffc, 0xfffc, 0xfffd, 0xfffd, 0xfffc,
1620xfffc, 0xfffc, 0xfffd, 0xfffc, 0xfffc, 0xfffd, 0xfffc, 0xfffc, 0xfffc, 0xfffd,
1630xfffd, 0xfffd, 0xfffd, 0xffbc, 0xfffc, 0xe73a,
1640xdf3a, 0xfffb, 0xf7bc, 0xc639, 0xbdf9, 0xc63a, 0xc67a, 0xc67b, 0xc63a, 0xbe3a,
1650xc639, 0xbe39, 0xbe3a, 0xbe3a, 0xbe3a, 0xc63b, 0xbe3a, 0xc63a, 0xc63a, 0xb5fa,
1660xb5f9, 0xb5f9, 0xc63b, 0xf77c, 0xf7fc, 0xe6fa,
1670xdefa, 0xfffc, 0xc679, 0x6bd4, 0x5b54, 0x6394, 0x5b54, 0x6c34, 0x7433, 0x7435,
1680x7c34, 0x9536, 0x7c35, 0x7c35, 0x8cb5, 0x7434, 0x8474, 0x7c74, 0x8cf5, 0x7434,
1690x8475, 0x7c75, 0x6b93, 0xc63a, 0xfffc, 0xe6f9,
1700xdefa, 0xfffd, 0xc6ba, 0x6395, 0x42d3, 0x7c77, 0x7436, 0x73d5, 0x5b11, 0x8cb6,
1710xa578, 0x7c35, 0xadb9, 0xadb8, 0x6bd4, 0x9537, 0x84b6, 0x5312, 0x5b53, 0x7436,
1720x9538, 0x7436, 0x5b94, 0xc67b, 0xfffd, 0xdefa,
1730xdefa, 0xfffc, 0xce7a, 0x6bd5, 0x5311, 0x73d4, 0x94f7, 0xa5b8, 0x7435, 0x9538,
1740x84b6, 0x190d, 0x7c35, 0x94f7, 0x088d, 0x7c76, 0x84b7, 0x7c75, 0x8cb6, 0xadb9,
1750x7c35, 0x7436, 0x6bd3, 0xce7b, 0xfffd, 0xdefa,
1760xdf39, 0xfffd, 0xceba, 0x63d5, 0x6bd5, 0x31cf, 0x8476, 0xa577, 0x84b7, 0x5b54,
1770x7436, 0x6b94, 0x84b5, 0x9d38, 0x7394, 0x7c37, 0x84b7, 0x84b7, 0xa578, 0x9d77,
1780x31cf, 0x6bd5, 0x6bd4, 0xcebb, 0xfffc, 0xdefa,
1790xdf3a, 0xfffc, 0xce7a, 0x6c35, 0x7c76, 0x9537, 0xa5b9, 0x6b94, 0x5291, 0x4ad2,
1800x7c35, 0x9537, 0x6394, 0x5353, 0x9578, 0x8cb6, 0x5b13, 0x3a11, 0x5b13, 0x9538,
1810x9539, 0x7434, 0x7434, 0xce7a, 0xfffc, 0xe6fa,
1820xdf3a, 0xfffd, 0xc67a, 0x6394, 0x84b7, 0x7c75, 0xa578, 0x94f7, 0x8cb6, 0x94f6,
1830xa5b8, 0x5b12, 0x4b13, 0x4b13, 0x4291, 0xa5b9, 0x6bd4, 0x73d5, 0x7c34, 0xa578,
1840x6bd5, 0x7c75, 0x6b94, 0xc67a, 0xfffd, 0xdefa,
1850xdf3a, 0xfffd, 0xc67a, 0x63d4, 0x7c76, 0x320f, 0xc67b, 0xadf9, 0x5b52, 0xadba,
1860x5b53, 0x6bd4, 0x4b13, 0x6bd5, 0x6bd5, 0x52d2, 0xbe7b, 0x4a91, 0x94f7, 0xbe7b,
1870x320f, 0x7c35, 0x6b94, 0xc67a, 0xfffd, 0xdefa,
1880xdf3a, 0xfffd, 0xbe39, 0x6bd5, 0x84b7, 0x9537, 0xb5f9, 0x6352, 0xbe3b, 0x6393,
1890x4ad4, 0x73d5, 0x6395, 0x6bd5, 0x84b6, 0x52d3, 0x7c76, 0xbe3a, 0x5ad2, 0x8477,
1900x6bd5, 0x84b6, 0x73d5, 0xbe39, 0xfffd, 0xdefa,
1910xdf3a, 0xfffc, 0xc639, 0x7cb6, 0x8cf6, 0xa578, 0x4ad0, 0xc63a, 0x7c74, 0x7475,
1920x84b8, 0x3a51, 0x3210, 0x4292, 0x4250, 0x9d79, 0x7c77, 0x7435, 0xbe3a, 0x424f,
1930x84b8, 0x84b6, 0x84b6, 0xc63a, 0xfffd, 0xdefb,
1940xdf3a, 0xfffd, 0xc63a, 0x6bd5, 0x7c75, 0x4ad0, 0xb5fa, 0x9d38, 0x8cf6, 0x6353,
1950x5313, 0x6395, 0x7c77, 0x7c76, 0x7436, 0x6bd4, 0x5b52, 0xa5b9, 0xb5fa, 0xbdf9,
1960x4a91, 0x7435, 0x6c34, 0xc63a, 0xfffe, 0xdefb,
1970xdf3a, 0xfffd, 0xbe39, 0x7c76, 0x8cb6, 0xb639, 0x9d78, 0x7c35, 0x52d2, 0x2990,
1980x9538, 0xbe3b, 0x9d78, 0xadfa, 0xb63c, 0xadb9, 0x73d5, 0x5b13, 0x6353, 0x9d38,
1990xadf9, 0x8cb5, 0x7c75, 0xbe39, 0xfffd, 0xdefb,
2000xdf3b, 0xfffe, 0xbdf9, 0x5312, 0xadfa, 0x9d78, 0x3a51, 0x9d78, 0x4251, 0x84b8,
2010x7c75, 0x8d37, 0x7cb7, 0x7476, 0x84f7, 0x9d37, 0xcebc, 0x6bd4, 0x94f7, 0x5b53,
2020x94f6, 0xadf8, 0x5b13, 0xb5f9, 0xfffd, 0xdefa,
2030xdf3b, 0xffff, 0xb5f9, 0x63d5, 0x8cf8, 0x4ad2, 0x4ad4, 0x6c35, 0x4293, 0x9d78,
2040x7cb7, 0x6435, 0x5b55, 0x4b13, 0x63d4, 0x9537, 0x9d37, 0x84b7, 0x63d4, 0x84b7,
2050x4292, 0x8cb6, 0x6bd4, 0xb5f9, 0xfffd, 0xdefa,
2060xdf3b, 0xffff, 0xadf9, 0x5b54, 0x7c77, 0x6c35, 0x42d4, 0x218f, 0x4292, 0x9537,
2070x8d38, 0x5354, 0x7475, 0x9538, 0x5b94, 0x7c76, 0x9537, 0x84b8, 0x114e, 0x4b13,
2080x5315, 0x7c76, 0x6353, 0xb5b9, 0xfffd, 0xdefa,
2090xdf3b, 0xffff, 0xb5f9, 0x6395, 0x8cf8, 0x6bd4, 0x5313, 0x7cb6, 0x4ad3, 0xb63b,
2100x8cf7, 0x7436, 0x6c35, 0x6bd6, 0x7cb7, 0xadba, 0xadb8, 0x8477, 0x7435, 0x7435,
2110x4ad2, 0x7cb6, 0x6b95, 0xb5fa, 0xfffc, 0xdefa,
2120xdf3b, 0xffff, 0xadb8, 0x5b53, 0xadfa, 0xb63a, 0x42d2, 0x8cf7, 0x29cf, 0x7c77,
2130x8cb6, 0x7cb6, 0x7436, 0x7435, 0x9538, 0x84b6, 0xa5ba, 0x4a91, 0x84b7, 0x4b12,
2140x8cf7, 0xb63a, 0x5b53, 0xadb8, 0xfffd, 0xdefa,
2150xdf3b, 0xffff, 0xadf9, 0x5353, 0x7cb6, 0x9d36, 0xadfa, 0x6393, 0x5b53, 0x194f,
2160x6395, 0x8d38, 0x9538, 0x9537, 0xa5b9, 0x9539, 0x4a92, 0x4291, 0x6352, 0x8476,
2170xa578, 0x7435, 0x5b53, 0xadb9, 0xfffd, 0xdefa,
2180xdf3b, 0xffff, 0xb5f9, 0x6394, 0x8cf7, 0x4ad1, 0xadb9, 0xa5f9, 0x84b6, 0x6b94,
2190x4a92, 0x31d0, 0x5b55, 0x5314, 0x4252, 0x4a92, 0x52d2, 0x94f8, 0x9d78, 0xb5f9,
2200x5ad2, 0x8477, 0x6b95, 0xb5b9, 0xfffc, 0xdefa,
2210xdf3b, 0xffff, 0xadb9, 0x5354, 0x84f8, 0x7435, 0x4292, 0xadb8, 0x8475, 0x5b53,
2220x7c77, 0x3a93, 0x29d1, 0x4b13, 0x3a51, 0x6bd5, 0x6355, 0x5312, 0xa5b8, 0x4a91,
2230x84b7, 0x7cb6, 0x5b54, 0xadb9, 0xfffc, 0xdefa,
2240xdf3b, 0xffff, 0xadb8, 0x6394, 0x8cf8, 0x6393, 0xa57a, 0x6352, 0xbe7b, 0x7c75,
2250x2a10, 0x5b54, 0x4ad4, 0x5353, 0x5b54, 0x4292, 0x6354, 0xadb9, 0x5b12, 0xa5b9,
2260x6394, 0x7c76, 0x6394, 0xadb8, 0xfffd, 0xdefa,
2270xdf3b, 0xffff, 0xb5f9, 0x6c35, 0x8cf7, 0x31cf, 0x9578, 0x84b7, 0x4a91, 0xadf9,
2280x5b53, 0x5b94, 0x4293, 0x4b53, 0x5b55, 0x4291, 0xa5b8, 0x6352, 0x7c36, 0xc6bb,
2290x4a91, 0x6b95, 0x7436, 0xb5b9, 0xfffd, 0xdefa,
2300xdf3b, 0xffff, 0xb5f8, 0x5b53, 0x9539, 0x7435, 0x6bd5, 0x6bd5, 0x7c75, 0x6b94,
2310xadb9, 0x6bd4, 0x2a11, 0x2a11, 0x3a51, 0x84b6, 0x7434, 0x8476, 0x73d4, 0xa5b9,
2320x7435, 0x7476, 0x6394, 0xadb9, 0xfffd, 0xdefa,
2330xdf3b, 0xffff, 0xb5f9, 0x6bd4, 0x9539, 0x9d38, 0x6bd6, 0x5313, 0x4291, 0x4ad2,
2340x94f6, 0xd6fd, 0x5b52, 0x5353, 0x8cb7, 0x9538, 0x5b53, 0x4292, 0x5b52, 0x9537,
2350xb5fa, 0x7c36, 0x6c35, 0xb5f9, 0xfffd, 0xdefa,
2360xdf3b, 0xffff, 0xb5f8, 0x7434, 0x84b7, 0x298e, 0x8cf6, 0xadf9, 0x9538, 0xadf9,
2370x9d78, 0x5312, 0xadb9, 0xadf9, 0x6bd4, 0x6395, 0x8cf7, 0x7435, 0x9d77, 0xa578,
2380x3a10, 0x6394, 0x7c75, 0xb5f9, 0xfffd, 0xdefa,
2390xdf3b, 0xffff, 0xbe39, 0x63d5, 0x6394, 0x84b6, 0xa5b8, 0x84b7, 0x6353, 0xa5b8,
2400x8cf7, 0x008c, 0x6b93, 0xadb9, 0x190d, 0x7476, 0xadfa, 0x6c35, 0x8cf7, 0xbe3a,
2410x6393, 0x7c75, 0x63d5, 0xb63a, 0xfffd, 0xdefa,
2420xdf3b, 0xffff, 0xb5f9, 0x5354, 0x6354, 0x94f8, 0x5b54, 0x63d4, 0x5b93, 0x84b7,
2430xa578, 0x7434, 0xadb9, 0xb5f9, 0x8cb6, 0x9d78, 0x9537, 0x5b93, 0x6bd5, 0x84b6,
2440x8cf7, 0x84b6, 0x5353, 0xb639, 0xfffd, 0xdefa,
2450xdf3a, 0xfffe, 0xbdf8, 0x63d4, 0x5b53, 0x6394, 0x6354, 0x7434, 0x7433, 0x7435,
2460x7433, 0x9537, 0x7c35, 0x7c34, 0x84b4, 0x7433, 0x7c74, 0x7474, 0x84b5, 0x73d4,
2470x8476, 0x7c35, 0x6393, 0xbe38, 0xfffd, 0xdefa,
2480xdf3a, 0xffbc, 0xf7bc, 0xc67a, 0xbe3a, 0xc67a, 0xc67b, 0xce7a, 0xc67a, 0xc63a,
2490xc67a, 0xc67a, 0xc63a, 0xc63b, 0xc67a, 0xc67a, 0xc63a, 0xc67a, 0xc63a, 0xbdf9,
2500xbdf9, 0xb5f9, 0xc67a, 0xf7bc, 0xfffc, 0xdefa,
2510xdf7b, 0xfffc, 0xffbc, 0xfffc, 0xfffd, 0xfffc, 0xfffc, 0xfffc, 0xfffd, 0xfffd,
2520xfffd, 0xfffc, 0xfffc, 0xfffc, 0xfffc, 0xfffd, 0xfffc, 0xfffb, 0xfffd, 0xfffd,
2530xfffc, 0xfffc, 0xfffd, 0xfffc, 0xfffc, 0xdefa,
2540x9572, 0xe73b, 0xdefa, 0xdefa, 0xdefa, 0xdefa, 0xdefa, 0xdefa, 0xdefa, 0xdefa,
2550xdefa, 0xdefa, 0xe6fa, 0xe6fa, 0xdefa, 0xdefa, 0xdefa, 0xdefa, 0xdefa, 0xdefa,
2560xdefa, 0xdefa, 0xdefa, 0xdefa, 0xe73a, 0xd6b9};
257
258static const unsigned char suitsi[4][30] = {
259 {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00, 0x07, 0x0f, 0x1f, 0x1f, 0x0f, 0x7f, 0x7f, 0x7f, 0x0f, 0x1f, 0x1f, 0x0f, 0x07, 0x00},
260 {0x00, 0xf0, 0xf8, 0xfc, 0xfe, 0xfc, 0xf8, 0xf0, 0xf8, 0xfc, 0xfe, 0xfc, 0xf8, 0xf0, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01, 0x00, 0x00},
261 {0x00, 0xc0, 0xe0, 0xe0, 0xfc, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfc, 0xe0, 0xe0, 0xc0, 0x00, 0x00, 0x03, 0x07, 0x07, 0x0f, 0x0f, 0x7f, 0x7f, 0x7f, 0x0f, 0x0f, 0x07, 0x07, 0x03, 0x00},
262 {0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf8, 0xfe, 0xfe, 0xf8, 0xe0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x07, 0x1f, 0x7f, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00},
263};
264static const unsigned char suits[4][16] = {
171/* Spades */ 265/* Spades */
172 {0x00, /* ........ */ 266 {0x00, 0x78, 0x3c, 0xfe, 0xfe, 0x3c, 0x78, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00},/* ........ */
173 0x18, /* ...O.... */
174 0x1c, /* ..OOO... */
175 0x3e, /* .OOOOO.. */
176 0x1c, /* .OOOOO.. */
177 0x18, /* ...O.... */
178 0x00, /* ........ */
179 0x00},/* ........ */
180/* Hearts */ 267/* Hearts */
181 {0x00, /* ........ */ 268 {0x00, 0x3c, 0x7e, 0xfc, 0xf8, 0xfc, 0x7e, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00},/* ........ */
182 0x0c, /* ..O.O... */
183 0x1e, /* .OOOOO.. */
184 0x3c, /* .OOOOO.. */
185 0x1e, /* ..OOO... */
186 0x0c, /* ...O.... */
187 0x00, /* ........ */
188 0x00},/* ........ */
189/* Clubs */ 269/* Clubs */
190 {0x00, /* ........ */ 270 {0x00, 0x70, 0x34, 0xfe, 0xfe, 0x34, 0x70, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00},/* ........ */
191 0x18, /* ..OOO... */
192 0x0a, /* ...O.... */
193 0x3e, /* .OOOOO.. */
194 0x0a, /* .O.O.O.. */
195 0x18, /* ...O.... */
196 0x00, /* ........ */
197 0x00},/* ........ */
198/* Diamonds */ 271/* Diamonds */
199 {0x00, /* ........ */ 272 {0x00, 0x70, 0xfc, 0xfe, 0xfe, 0xfc, 0x70, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00} /* ........ */
200 0x08, /* ...O.... */
201 0x1c, /* ..OOO... */
202 0x3e, /* .OOOOO.. */
203 0x1c, /* ..OOO... */
204 0x08, /* ...O.... */
205 0x00, /* ........ */
206 0x00} /* ........ */
207}; 273};
208 274
209static unsigned char numbers[13][8] = { 275static unsigned char numbers[13][16] = {
210/* Ace */ 276/* Ace */
211 {0x00, /* ........ */ 277 {0x00, 0xf0, 0xfc, 0x7e, 0x36, 0x7e, 0xfc, 0xf0, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01},
212 0x38, /* ...O.... */
213 0x14, /* ..O.O... */
214 0x12, /* .O...O.. */
215 0x14, /* .OOOOO.. */
216 0x38, /* .O...O.. */
217 0x00, /* ........ */
218 0x00},/* ........ */
219/* 2 */ 278/* 2 */
220 {0x00, /* ........ */ 279 {0x00, 0x8c, 0xce, 0xe6, 0xf6, 0xbe, 0x9c, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00}, /* ........ */
221 0x24, /* ..OOO... */
222 0x32, /* .O...O.. */
223 0x32, /* ....O... */
224 0x2a, /* ..OO.... */
225 0x24, /* .OOOOO.. */
226 0x00, /* ........ */
227 0x00},/* ........ */
228/* 3 */ 280/* 3 */
229 {0x00, /* ........ */ 281 {0x00, 0xcc, 0x86, 0xb6, 0xb6, 0xfe, 0xdc, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}, /* ........ */
230 0x22, /* .OOOO... */
231 0x2a, /* .....O.. */
232 0x2a, /* ..OOO... */
233 0x2a, /* .....O.. */
234 0x14, /* .OOOO... */
235 0x00, /* ........ */
236 0x00},/* ........ */
237/* 4 */ 282/* 4 */
238 {0x00, /* ........ */ 283 {0x00, 0x3e, 0x3e, 0x30, 0xfe, 0xfe, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00}, /* ........ */
239 0x10, /* ....O... */
240 0x18, /* ...O.... */
241 0x34, /* ..O..... */
242 0x12, /* .OOOOO.. */
243 0x10, /* ...O.... */
244 0x00, /* ........ */
245 0x00},/* ........ */
246/* 5 */ 284/* 5 */
247 {0x00, /* ........ */ 285 {0x00, 0xbe, 0xbe, 0xb6, 0xb6, 0xf6, 0xe6, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}, /* ........ */
248 0x2e, /* .OOOOO.. */
249 0x2a, /* .O...... */
250 0x2a, /* .OOOO... */
251 0x2a, /* .....O.. */
252 0x12, /* .OOOO... */
253 0x00, /* ........ */
254 0x00},/* ........ */
255/* 6 */ 286/* 6 */
256 {0x00, /* ........ */ 287 {0x00, 0xfc, 0xfe, 0xb6, 0xb6, 0xf6, 0xe4, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}, /* ........ */
257 0x1c, /* ..OOO... */
258 0x2a, /* .O...... */
259 0x2a, /* .OOOO... */
260 0x2a, /* .O...O.. */
261 0x10, /* ..OOO... */
262 0x00, /* ........ */
263 0x00},/* ........ */
264/* 7 */ 288/* 7 */
265 {0x00, /* ........ */ 289 {0x00, 0x86, 0xc6, 0x66, 0x36, 0x1e, 0x0e, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00}, /* ........ */
266 0x22, /* .OOOOO.. */
267 0x12, /* ....O... */
268 0x0a, /* ...O.... */
269 0x06, /* ..O..... */
270 0x02, /* .O...... */
271 0x00, /* ........ */
272 0x00},/* ........ */
273/* 8 */ 290/* 8 */
274 {0x00, /* ........ */ 291 {0x00, 0xdc, 0xfe, 0xb6, 0xb6, 0xfe, 0xdc, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}, /* ........ */
275 0x14, /* ..OOO... */
276 0x2a, /* .O...O.. */
277 0x2a, /* ..OOO... */
278 0x2a, /* .O...O.. */
279 0x14, /* ..OOO... */
280 0x00, /* ........ */
281 0x00},/* ........ */
282/* 9 */ 292/* 9 */
283 {0x00, /* ........ */ 293 {0x00, 0x9c, 0xbe, 0xb6, 0xb6, 0xfe, 0xfc, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00}, /* ........ */
284 0x04, /* ..OOO... */
285 0x2a, /* .O...O.. */
286 0x2a, /* ..OOOO.. */
287 0x2a, /* .....O.. */
288 0x1c, /* ..OOO... */
289 0x00, /* ........ */
290 0x00},/* ........ */
291/* 10 */ 294/* 10 */
292 {0x00, /* ........ */ 295 {0x00, 0x18, 0x0c, 0xfe, 0x00, 0xfc, 0x86, 0xfc, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00}, /* ........ */
293 0x3e, /* .O..O... */
294 0x00, /* .O.O.O.. */
295 0x1c, /* .O.O.O.. */
296 0x22, /* .O.O.O.. */
297 0x1c, /* .O..O... */
298 0x00, /* ........ */
299 0x00},/* ........ */
300/* Jack */ 296/* Jack */
301 {0x00, /* ........ */ 297 {0x00, 0xe6, 0xc6, 0x86, 0xfe, 0xfe, 0x06, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00}, /* ........ */
302 0x12, /* .OOOOO.. */
303 0x22, /* ...O.... */
304 0x1e, /* ...O.... */
305 0x02, /* .O.O.... */
306 0x02, /* ..O..... */
307 0x00, /* ........ */
308 0x00},/* ........ */
309/* Queen */ 298/* Queen */
310 {0x00, /* ........ */ 299 {0x00, 0x7c, 0xfe, 0xc6, 0xe6, 0xfe, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00}, /* ........ */
311 0x1c, /* ..OOO... */
312 0x22, /* .O...O.. */
313 0x32, /* .O...O.. */
314 0x22, /* .O.O.O.. */
315 0x1c, /* ..OOO... */
316 0x00, /* ........ */
317 0x00},/* ........ */
318/* King */ 300/* King */
319 {0x00, /* ........ */ 301 {0x00, 0xfe, 0xfe, 0x38, 0x7c, 0xee, 0xc6, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00} /* ........ */
320 0x3e, /* .O...O.. */
321 0x08, /* .O..O... */
322 0x08, /* .OOO.... */
323 0x14, /* .O..O... */
324 0x22, /* .O...O.. */
325 0x00, /* ........ */
326 0x00} /* ........ */
327}; 302};
328 303
304
305#define FILENAME "sol.cfg"
306
307
329#define NOT_A_CARD 255 308#define NOT_A_CARD 255
330 309
331/* number of cards per suit */ 310/* number of cards per suit */
@@ -345,12 +324,29 @@ static unsigned char numbers[13][8] = {
345 324
346#define NOT_A_COL 255 325#define NOT_A_COL 255
347 326
348/* number of cards that are drawn on the remains' stack (by pressing F2) */
349#define CARDS_PER_DRAW 3
350 327
351/* size of a card on the screen */ 328/* size of a card on the screen */
352#define CARD_WIDTH 14 329#if (CONFIG_KEYPAD == IRIVER_H300_PAD)
353#define CARD_HEIGHT 10 330#define CARD_WIDTH 26
331#define CARD_HEIGHT 34
332#else
333#define CARD_WIDTH 18
334#define CARD_HEIGHT 24
335#endif
336
337/* where the cards start */
338#define CARD_START CARD_HEIGHT +4
339
340#if (CONFIG_KEYPAD == IRIVER_H300_PAD)
341#define KNOWN_CARD 23
342#define NOT_KNOWN_CARD 30
343#else
344#define KNOWN_CARD 13
345#define NOT_KNOWN_CARD 20
346#endif
347
348/* background color */
349#define background_color LCD_RGBPACK(0,157,0)
354 350
355typedef struct card { 351typedef struct card {
356 unsigned char suit : 2; 352 unsigned char suit : 2;
@@ -503,51 +499,74 @@ int solitaire_help(void){
503 lastbutton = button; 499 lastbutton = button;
504 } 500 }
505} 501}
502#define CFGFILE_VERSION 0
503int draw_type;
504
505
506unsigned char change_draw(unsigned char draw){
507 if (draw == 0)
508 return 1;
509 else
510 return 0;
511}
512static struct configdata config[] = {
513 { TYPE_INT, 0, 1, &draw_type, "draw_type", NULL, NULL }
514};
506 515
507/* menu return codes */ 516/* menu return codes */
508#define MENU_RESUME 0 517#define MENU_RESUME 0
509#define MENU_RESTART 1 518#define MENU_RESTART 1
510#define MENU_HELP 2 519#define MENU_HELP 3
511#define MENU_QUIT 3 520#define MENU_QUIT 4
512#define MENU_USB 4 521#define MENU_USB 5
522#define MENU_OPT 2
513 523
514/* menu item number */ 524/* menu item number */
515#define MENU_LENGTH 4 525#define MENU_LENGTH 5
516 526
517/* different menu behaviors */ 527/* different menu behaviors */
518#define MENU_BEFOREGAME 0
519#define MENU_DURINGGAME 1
520 528
529#define MENU_BEFOREGAME 0
530#define MENU_BEFOREGAMEOP 1
531#define MENU_DURINGGAME 2
532unsigned char when;
521/* the menu */ 533/* the menu */
522/* text displayed changes depending on the 'when' parameter */ 534/* text displayed changes depending on the 'when' parameter */
523int solitaire_menu(unsigned char when) 535int solitaire_menu(unsigned char when_n)
524{ 536{
525 static char menu[2][MENU_LENGTH][13] = 537 static char menu[3][MENU_LENGTH][17] =
526 { { "Start Game", 538 { { "Start Game",
527 "", 539 "",
540 "Draw Three Cards",
541 "Help",
542 "Quit" },
543 { "Start Game",
544 "",
545 "Draw One Card",
528 "Help", 546 "Help",
529 "Quit" }, 547 "Quit" },
530 { "Resume Game", 548 { "Resume Game",
531 "Restart Game", 549 "Restart Game",
550 "",
532 "Help", 551 "Help",
533 "Quit"} 552 "Quit"},
534 }; 553 };
535 554
555
536 int i; 556 int i;
537 int cursor=0; 557 int cursor=0;
538 int button; 558 int button;
539 int fh; 559 int fh;
540 560 when=when_n;
541 rb->lcd_getstringsize("A", NULL, &fh); 561 rb->lcd_getstringsize("A", NULL, &fh);
542 fh++; 562 fh++;
543 563
544 if(when!=MENU_BEFOREGAME && when!=MENU_DURINGGAME) 564 if(when != MENU_BEFOREGAMEOP && when!=MENU_BEFOREGAME && when!=MENU_DURINGGAME)
545 when = MENU_DURINGGAME; 565 when = MENU_DURINGGAME;
546 566
547 while(1){ 567 while(1){
548 568
549 rb->lcd_clear_display(); 569 rb->lcd_clear_display();
550
551 rb->lcd_putsxy(20, 1, "Solitaire"); 570 rb->lcd_putsxy(20, 1, "Solitaire");
552 571
553 for(i = 0; i<MENU_LENGTH; i++){ 572 for(i = 0; i<MENU_LENGTH; i++){
@@ -563,11 +582,11 @@ int solitaire_menu(unsigned char when)
563 582
564 button = rb->button_get(true); 583 button = rb->button_get(true);
565 switch(button){ 584 switch(button){
566 case SOL_UP: 585 case BUTTON_UP:
567 cursor = (cursor + MENU_LENGTH - 1)%MENU_LENGTH; 586 cursor = (cursor + MENU_LENGTH - 1)%MENU_LENGTH;
568 break; 587 break;
569 588
570 case SOL_DOWN: 589 case BUTTON_DOWN:
571 cursor = (cursor + 1)%MENU_LENGTH; 590 cursor = (cursor + 1)%MENU_LENGTH;
572 break; 591 break;
573 592
@@ -581,6 +600,7 @@ int solitaire_menu(unsigned char when)
581 switch(cursor){ 600 switch(cursor){
582 case MENU_RESUME: 601 case MENU_RESUME:
583 case MENU_RESTART: 602 case MENU_RESTART:
603 case MENU_OPT:
584 case MENU_QUIT: 604 case MENU_QUIT:
585 return cursor; 605 return cursor;
586 606
@@ -598,10 +618,11 @@ int solitaire_menu(unsigned char when)
598#endif 618#endif
599 rb->splash(HZ, true, "Solitaire for Rockbox by dionoea"); 619 rb->splash(HZ, true, "Solitaire for Rockbox by dionoea");
600 break; 620 break;
601 621 case BUTTON_ON:
602 case SOL_QUIT: 622 return MENU_OPT;
623 case BUTTON_OFF:
603 return MENU_QUIT; 624 return MENU_QUIT;
604 625
605 default: 626 default:
606 if(rb->default_event_handler(button) == SYS_USB_CONNECTED) 627 if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
607 return MENU_USB; 628 return MENU_USB;
@@ -624,18 +645,32 @@ card deck[SUITS * CARDS_PER_SUIT];
624/* the remaining cards */ 645/* the remaining cards */
625unsigned char rem; 646unsigned char rem;
626unsigned char cur_rem; 647unsigned char cur_rem;
648unsigned char coun_rem;
627 649
628/* the 7 game columns */ 650/* the 7 game columns */
629unsigned char cols[COL_NUM]; 651unsigned char cols[COL_NUM];
630 652
653int CARDS_PER_DRAW;
631/* the 4 final stacks */ 654/* the 4 final stacks */
632unsigned char stacks[SUITS]; 655unsigned char stacks[SUITS];
633 656
634/* initialize the game */ 657/* initialize the game */
635void solitaire_init(void){ 658void solitaire_init(void){
659
636 unsigned char c; 660 unsigned char c;
637 int i,j; 661 int i,j;
638 662#if LCD_DEPTH>1
663 rb->lcd_set_foreground(LCD_BLACK);
664#ifdef HAVE_LCD_COLOR
665 rb->lcd_set_background(background_color);
666#endif
667#endif
668/* number of cards that are drawn on the remains' stack (by pressing F2) */
669 if(draw_type == 0) {
670 CARDS_PER_DRAW =3;
671 } else {
672 CARDS_PER_DRAW=1;
673 }
639 /* init deck */ 674 /* init deck */
640 for(i=0;i<SUITS;i++){ 675 for(i=0;i<SUITS;i++){
641 for(j=0;j<CARDS_PER_SUIT;j++){ 676 for(j=0;j<CARDS_PER_SUIT;j++){
@@ -688,6 +723,8 @@ void solitaire_init(void){
688 723
689 /* init the remainder */ 724 /* init the remainder */
690 cur_rem = NOT_A_CARD; 725 cur_rem = NOT_A_CARD;
726
727 coun_rem=0;
691} 728}
692 729
693/* find the column number in which 'card' can be found */ 730/* find the column number in which 'card' can be found */
@@ -835,6 +872,7 @@ unsigned char move_card(unsigned char dest_col, unsigned char src_card){
835 /* if src card is the first card from the stack */ 872 /* if src card is the first card from the stack */
836 if(src_card_prev == NOT_A_CARD){ 873 if(src_card_prev == NOT_A_CARD){
837 rem = deck[src_card].next; 874 rem = deck[src_card].next;
875 coun_rem = coun_rem-1;
838 } 876 }
839 /* if src card is not the first card from the stack */ 877 /* if src card is not the first card from the stack */
840 else { 878 else {
@@ -842,6 +880,7 @@ unsigned char move_card(unsigned char dest_col, unsigned char src_card){
842 } 880 }
843 cur_rem = src_card_prev; 881 cur_rem = src_card_prev;
844 deck[src_card].next = NOT_A_CARD; 882 deck[src_card].next = NOT_A_CARD;
883 coun_rem = coun_rem-1;
845 } 884 }
846 /* if the src card is from somewhere else, just take everything */ 885 /* if the src card is from somewhere else, just take everything */
847 else { 886 else {
@@ -855,11 +894,13 @@ unsigned char move_card(unsigned char dest_col, unsigned char src_card){
855 deck[src_card_prev].next = NOT_A_CARD; 894 deck[src_card_prev].next = NOT_A_CARD;
856 } 895 }
857 } 896 }
858 897 sel_card = NOT_A_CARD;
859 /* tada ! */ 898 /* tada ! */
860 return MOVE_OK; 899 return MOVE_OK;
861} 900}
862 901
902
903
863#define SOLITAIRE_WIN 0 904#define SOLITAIRE_WIN 0
864#define SOLITAIRE_QUIT 1 905#define SOLITAIRE_QUIT 1
865#define SOLITAIRE_USB 2 906#define SOLITAIRE_USB 2
@@ -874,21 +915,35 @@ unsigned char move_card(unsigned char dest_col, unsigned char src_card){
874/* the game */ 915/* the game */
875int solitaire(void){ 916int solitaire(void){
876 917
877 int i,j; 918 int i,j,x;
878 int button, lastbutton = 0; 919 int button, lastbutton = 0;
879 unsigned char c; 920 unsigned char c,h,prevcard;
880 int biggest_col_length; 921 int biggest_col_length;
881 922
923 configfile_init(rb);
924 configfile_load(FILENAME, config, 1, 0);
925
882 rb->srand( *rb->current_tick ); 926 rb->srand( *rb->current_tick );
883 927 switch(solitaire_menu(draw_type==0?MENU_BEFOREGAME:MENU_BEFOREGAMEOP)) {
884 switch(solitaire_menu(MENU_BEFOREGAME)) { 928 case MENU_QUIT:
885 case MENU_QUIT:
886 return SOLITAIRE_QUIT; 929 return SOLITAIRE_QUIT;
887 930
888 case MENU_USB: 931 case MENU_USB:
889 return SOLITAIRE_USB; 932 return SOLITAIRE_USB;
933 case MENU_OPT:
934 draw_type=change_draw(draw_type);
935 configfile_save(FILENAME, config, 1, 0);
936 when=draw_type==0?MENU_BEFOREGAME:MENU_BEFOREGAMEOP;
937 return NULL;
890 } 938 }
891 939#if LCD_DEPTH>1
940 rb->lcd_set_foreground(LCD_BLACK);
941#ifdef HAVE_LCD_COLOR
942 rb->lcd_set_background(background_color);
943#else
944 rb->lcd_set_background(LCD_DEFAULT_BG);
945#endif
946#endif
892 solitaire_init(); 947 solitaire_init();
893 948
894 while(true){ 949 while(true){
@@ -918,63 +973,100 @@ int solitaire(void){
918 /* draw the columns */ 973 /* draw the columns */
919 for(i=0;i<COL_NUM;i++){ 974 for(i=0;i<COL_NUM;i++){
920 c = cols[i]; 975 c = cols[i];
921 j = 0; 976 j = CARD_START;
922 while(true){ 977 while(true){
923 if(c==NOT_A_CARD) { 978 if(c==NOT_A_CARD) {
924 /* draw the cursor on empty columns */ 979 /* draw the cursor on empty columns */
925 if(cur_col == i){ 980 if(cur_col == i){
926 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 981 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
927 rb->lcd_fillrect(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+2, 2, CARD_WIDTH-3, CARD_HEIGHT-1); 982 rb->lcd_fillrect(1+i*(LCD_WIDTH-2)/COL_NUM+1, j+1, CARD_WIDTH-1, CARD_HEIGHT-1);
928 } 983 }
929 break; 984 break;
930 } 985 }
931 /* clear the card's spot */ 986 /* clear the card's spot */
987
932 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); 988 rb->lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
933 rb->lcd_fillrect(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM, j+1, CARD_WIDTH, CARD_HEIGHT-1); 989 rb->lcd_fillrect(1+i*(LCD_WIDTH - 2)/COL_NUM, j+1, CARD_WIDTH, CARD_HEIGHT-1);
934 rb->lcd_set_drawmode(DRMODE_SOLID); 990 rb->lcd_set_drawmode(DRMODE_SOLID);
935 /* known card */ 991 /* known card */
936 if(deck[c].known){ 992 if(deck[c].known == 1){
993#if LCD_DEPTH>1
994 #ifdef HAVE_LCD_COLOR
995 rb->lcd_set_foreground(LCD_WHITE);
996 rb->lcd_set_background(LCD_WHITE);
997 #else
998 rb->lcd_set_foreground(LCD_DEFAULT_BG);
999 rb->lcd_set_background(LCD_DEFAULT_BG);
1000 #endif
1001#endif
1002 rb->lcd_fillrect(1+i*(LCD_WIDTH - 2)/COL_NUM+1, j+1, CARD_WIDTH-1, CARD_HEIGHT-1);
937#if LCD_DEPTH>1 1003#if LCD_DEPTH>1
938 rb->lcd_set_foreground(colors[deck[c].suit]); 1004 rb->lcd_set_foreground(colors[deck[c].suit]);
939#endif 1005#endif
940 rb->lcd_mono_bitmap(numbers[deck[c].num], i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+1, j, 8, 8); 1006 rb->lcd_mono_bitmap(numbers[deck[c].num], 1+i*(LCD_WIDTH - 2)/COL_NUM+1, j+1, BMPWIDTH_c, BMPHEIGHT_c);
941 rb->lcd_mono_bitmap(suits[deck[c].suit], i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+7, j, 8, 8); 1007 rb->lcd_mono_bitmap(suits[deck[c].suit], 1+i*(LCD_WIDTH - 2)/COL_NUM+ BMPWIDTH_c +2, j+1, BMPWIDTH_c, BMPHEIGHT_c);
942#if LCD_DEPTH>1 1008#if LCD_DEPTH>1
943 rb->lcd_set_foreground(LCD_BLACK); 1009 rb->lcd_set_foreground(LCD_BLACK);
1010#ifdef HAVE_LCD_COLOR
1011 rb->lcd_set_background(background_color);
1012#endif
1013#endif
1014 } else {
1015#ifdef HAVE_LCD_COLOR
1016 rb->lcd_bitmap(backside, 1+i*(LCD_WIDTH - 2)/COL_NUM+1, j+1, BMPWIDTH_BACKSIDE, BMPHEIGHT_BACKSIDE);
944#endif 1017#endif
945 } 1018 }
946 /* draw top line of the card */ 1019 /* draw top line of the card */
947 rb->lcd_drawline(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+1,j,i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+CARD_WIDTH-1,j); 1020 rb->lcd_drawline(1+i*(LCD_WIDTH - 2)/COL_NUM+1,j,1+i*(LCD_WIDTH - 2)/COL_NUM+CARD_WIDTH-1,j);
948 /* selected card */ 1021 /* selected card */
949 if(c == sel_card && sel_card != NOT_A_CARD){ 1022 if(c == sel_card && sel_card != NOT_A_CARD){
950 rb->lcd_drawrect(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+1, j+1, CARD_WIDTH-1, CARD_HEIGHT-1); 1023 rb->lcd_drawrect(1+i*(LCD_WIDTH - 2)/COL_NUM+1, j+1, CARD_WIDTH-1, CARD_HEIGHT-1);
951 } 1024 }
952 /* cursor (or not) */ 1025 /* cursor (or not) */
953 if(c == cur_card){ 1026 if(c == cur_card){
954 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 1027 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
955 rb->lcd_fillrect(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+1, j+1, CARD_WIDTH-1, CARD_HEIGHT-1); 1028 rb->lcd_fillrect(1+i*(LCD_WIDTH - 2)/COL_NUM+1, j+1, CARD_WIDTH-1, CARD_HEIGHT-1);
956 rb->lcd_set_drawmode(DRMODE_SOLID); 1029 rb->lcd_set_drawmode(DRMODE_SOLID);
957 /* go to the next card */ 1030 /* go to the next card */
958 c = deck[c].next; 1031 c = deck[c].next;
959 if(c == NOT_A_CARD) break; 1032 if(c == NOT_A_CARD) break;
960 j += CARD_HEIGHT - 2; 1033 else {
1034 if(deck[c].known == 0) {
1035 j += CARD_HEIGHT - NOT_KNOWN_CARD;
1036 } else {
1037 j += CARD_HEIGHT - KNOWN_CARD;
1038 }
1039 }
961 } else { 1040 } else {
962 /* go to the next card */ 1041 /* go to the next card */
963 c = deck[c].next; 1042 h = c;
1043 c = deck[c].next;
964 if(c == NOT_A_CARD) break; 1044 if(c == NOT_A_CARD) break;
965 j += min(CARD_HEIGHT - 2, (LCD_HEIGHT - CARD_HEIGHT)/biggest_col_length); 1045 if(c!=NOT_A_CARD) {
1046 if(deck[h].known == 0) {
1047 /*changeeee*/ j += CARD_HEIGHT - NOT_KNOWN_CARD;
1048 } else {
1049 j += min(CARD_HEIGHT - KNOWN_CARD, (LCD_HEIGHT - CARD_START - CARD_HEIGHT)/biggest_col_length);
1050 }
1051 }
966 } 1052 }
967 } 1053 }
968 if(cols[i]!=NOT_A_CARD){ 1054 if(cols[i]!=NOT_A_CARD){
969 /* draw line to the left of the column */ 1055 /* draw line to the left of the column */
970 rb->lcd_drawline(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM,1,i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM,j+CARD_HEIGHT-1); 1056 rb->lcd_drawline(1+i*(LCD_WIDTH - 2)/COL_NUM,CARD_START,1+i*(LCD_WIDTH - 2)/COL_NUM,j+CARD_HEIGHT-1);
971 /* draw line to the right of the column */ 1057 /* draw line to the right of the column */
972 rb->lcd_drawline(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+CARD_WIDTH,1,i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+CARD_WIDTH,j+CARD_HEIGHT-1); 1058 rb->lcd_drawline(1+i*(LCD_WIDTH - 2)/COL_NUM+CARD_WIDTH,CARD_START,1+i*(LCD_WIDTH - 2)/COL_NUM+CARD_WIDTH,j+CARD_HEIGHT-1);
973 /* draw bottom of the last card */ 1059 /* draw bottom of the last card */
974 rb->lcd_drawline(i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+1,j+CARD_HEIGHT,i*(LCD_WIDTH - CARD_WIDTH)/COL_NUM+CARD_WIDTH-1,j+CARD_HEIGHT); 1060 rb->lcd_drawline(1+i*(LCD_WIDTH - 2)/COL_NUM+1,j+CARD_HEIGHT,1+i*(LCD_WIDTH - 2)/COL_NUM+CARD_WIDTH-1,j+CARD_HEIGHT);
975 } 1061 }
976 } 1062 }
977 1063#if LCD_DEPTH>1
1064 rb->lcd_set_foreground(LCD_BLACK);
1065#ifdef HAVE_LCD_COLOR
1066 rb->lcd_set_background(background_color);
1067#endif
1068#endif
1069 rb->lcd_set_drawmode(DRMODE_SOLID);
978 /* draw the stacks */ 1070 /* draw the stacks */
979 for(i=0; i<SUITS; i++){ 1071 for(i=0; i<SUITS; i++){
980 c = stacks[i]; 1072 c = stacks[i];
@@ -983,67 +1075,177 @@ int solitaire(void){
983 c = deck[c].next; 1075 c = deck[c].next;
984 } 1076 }
985 } 1077 }
1078
1079 if(c != NOT_A_CARD) {
1080#if LCD_DEPTH>1
1081 #ifdef HAVE_LCD_COLOR
1082 rb->lcd_set_foreground(LCD_WHITE);
1083 rb->lcd_set_background(LCD_WHITE);
1084 #else
1085 rb->lcd_set_foreground(LCD_DEFAULT_BG);
1086 rb->lcd_set_background(LCD_DEFAULT_BG);
1087 #endif
1088#endif
1089 rb->lcd_fillrect(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1, 2, CARD_WIDTH-1, CARD_HEIGHT-1);
1090#if LCD_DEPTH>1
1091 rb->lcd_set_foreground(colors[i]);
1092#endif
1093 rb->lcd_mono_bitmap(numbers[deck[c].num], LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1, 2, BMPWIDTH_c, BMPHEIGHT_c);
1094 rb->lcd_mono_bitmap(suits[deck[c].suit], LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+10, 2, BMPWIDTH_c, BMPHEIGHT_c);
1095 } else {
1096#if LCD_DEPTH>1
1097 #ifdef HAVE_LCD_COLOR
1098 rb->lcd_set_foreground(LCD_WHITE);
1099 rb->lcd_set_background(LCD_WHITE);
1100 #else
1101 rb->lcd_set_foreground(LCD_DEFAULT_BG);
1102 rb->lcd_set_background(LCD_DEFAULT_BG);
1103 #endif
1104#endif
1105 rb->lcd_fillrect(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1, 2, CARD_WIDTH-1, CARD_HEIGHT-1);
986#if LCD_DEPTH>1 1106#if LCD_DEPTH>1
987 rb->lcd_set_foreground(colors[i]); 1107 rb->lcd_set_foreground(colors[i]);
1108#endif
1109#ifdef HAVE_LCD_COLOR
1110 rb->lcd_mono_bitmap(suitsi[i], LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+(CARD_WIDTH/2-7), CARD_HEIGHT/2-7, 15, 16);
988#endif 1111#endif
989 if(c != NOT_A_CARD) {
990 rb->lcd_mono_bitmap(numbers[deck[c].num], LCD_WIDTH2 - CARD_WIDTH+1, i*CARD_HEIGHT, 8, 8);
991 } 1112 }
992 rb->lcd_mono_bitmap(suits[i], LCD_WIDTH2 - CARD_WIDTH+7, i*CARD_HEIGHT, 8, 8);
993#if LCD_DEPTH>1 1113#if LCD_DEPTH>1
994 rb->lcd_set_foreground(colors[deck[c].suit]); 1114 rb->lcd_set_foreground(LCD_BLACK);
1115#ifdef HAVE_LCD_COLOR
1116 rb->lcd_set_background(background_color);
1117#endif
995#endif 1118#endif
996 /* draw a selected card */ 1119 /* draw a selected card */
997 if(c != NOT_A_CARD) { 1120 if(c != NOT_A_CARD) {
998 if(sel_card == c){ 1121 if(sel_card == c){
999 rb->lcd_drawrect(LCD_WIDTH2 - CARD_WIDTH+1, i*CARD_HEIGHT + 1, CARD_WIDTH-1, CARD_HEIGHT-1); 1122 rb->lcd_drawrect(LCD_WIDTH2 -(CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1, 2, CARD_WIDTH-1, CARD_HEIGHT-1);
1000 } 1123 }
1001 } 1124 }
1002 rb->lcd_drawline(LCD_WIDTH2 - CARD_WIDTH+1, i*CARD_HEIGHT,LCD_WIDTH2 - 1,i*CARD_HEIGHT); 1125 rb->lcd_drawline(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1, 1,LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+CARD_WIDTH,1);
1003 rb->lcd_drawline(LCD_WIDTH2 - CARD_WIDTH,i*CARD_HEIGHT+1,LCD_WIDTH2 - CARD_WIDTH,(i+1)*CARD_HEIGHT-1); 1126 rb->lcd_drawline(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2 ,2,LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2,CARD_HEIGHT);
1004 rb->lcd_drawline(LCD_WIDTH2 - CARD_WIDTH+1,(i+1)*CARD_HEIGHT,LCD_WIDTH2 - 1,(i+1)*CARD_HEIGHT); 1127 rb->lcd_drawline(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1,CARD_HEIGHT+1,LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+CARD_WIDTH - 1,CARD_HEIGHT+1);
1005#if BIG_SCREEN 1128#if BIG_SCREEN
1006 rb->lcd_drawline(LCD_WIDTH2,i*CARD_HEIGHT+1,LCD_WIDTH2,(i+1)*CARD_HEIGHT-1); 1129 rb->lcd_drawline(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+CARD_WIDTH,2,LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+CARD_WIDTH,CARD_HEIGHT);
1007#endif 1130#endif
1008 /* draw the cursor on one of the stacks */ 1131 /* draw the cursor on one of the stacks */
1009 if(cur_col == STACKS_COL + i){ 1132 if(cur_col == STACKS_COL + i){
1010 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 1133 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
1011 rb->lcd_fillrect(LCD_WIDTH2 - CARD_WIDTH+1, i*CARD_HEIGHT + 1, CARD_WIDTH-1, CARD_HEIGHT-1); 1134 rb->lcd_fillrect(LCD_WIDTH2 - (CARD_WIDTH*4+8)+CARD_WIDTH*i+i*2+1, 2, CARD_WIDTH-1, CARD_HEIGHT-1);
1012 rb->lcd_set_drawmode(DRMODE_SOLID); 1135 rb->lcd_set_drawmode(DRMODE_SOLID);
1013 } 1136 }
1014 } 1137 }
1015 1138
1016 /* draw the remains */ 1139 /* draw the remains */
1017 if(rem != NOT_A_CARD) { 1140
1018 rb->lcd_drawline(LCD_WIDTH2 - CARD_WIDTH+1,LCD_HEIGHT-CARD_HEIGHT-1,LCD_WIDTH2 - 1,LCD_HEIGHT-CARD_HEIGHT-1); 1141
1019 rb->lcd_drawline(LCD_WIDTH2 - CARD_WIDTH,LCD_HEIGHT-CARD_HEIGHT,LCD_WIDTH2 - CARD_WIDTH,LCD_HEIGHT-2); 1142 if(rem != NOT_A_CARD) {
1020 rb->lcd_drawline(LCD_WIDTH2 - CARD_WIDTH+1,LCD_HEIGHT-1,LCD_WIDTH2 - 1,LCD_HEIGHT-1); 1143 coun_rem = coun_rem>2?coun_rem=2:coun_rem;
1021#if BIG_SCREEN 1144 if(cur_rem != NOT_A_CARD && find_prev_card(cur_rem) != NOT_A_CARD && CARDS_PER_DRAW != 1) {
1022 rb->lcd_drawline(LCD_WIDTH2,LCD_HEIGHT-CARD_HEIGHT,LCD_WIDTH2,LCD_HEIGHT-2); 1145 j = (coun_rem)*(BMPWIDTH_c+2);
1146 for(i=0;i<=coun_rem;i++) {
1147 if (i>0 && i<3){
1148#if LCD_DEPTH>1
1149 #ifdef HAVE_LCD_COLOR
1150 rb->lcd_set_foreground(LCD_WHITE);
1151 rb->lcd_set_background(LCD_WHITE);
1152 #else
1153 rb->lcd_set_foreground(LCD_DEFAULT_BG);
1154 rb->lcd_set_background(LCD_DEFAULT_BG);
1155 #endif
1023#endif 1156#endif
1024 if(cur_rem != NOT_A_CARD){ 1157 rb->lcd_fillrect(CARD_WIDTH+4+j+1, 2, BMPWIDTH_c+1, CARD_HEIGHT-1);
1158 #if LCD_DEPTH>1
1159 rb->lcd_set_foreground(LCD_BLACK);
1160 #endif
1161 rb->lcd_drawline(CARD_WIDTH+4+j+1,1,CARD_WIDTH+4+j+BMPWIDTH_c+2,1); /* top line */
1162 rb->lcd_drawline(CARD_WIDTH+4+j+1,CARD_HEIGHT+1,CARD_WIDTH+4+j+BMPWIDTH_c+2,CARD_HEIGHT+1); /* bottom line */
1163 rb->lcd_drawline(CARD_WIDTH+4+j,2,CARD_WIDTH+4+j,CARD_HEIGHT); /* right line */
1164
1165
1166 prevcard = cur_rem;
1167 for(x=0;i>x;x++)
1168 prevcard = find_prev_card(prevcard);
1169 #if LCD_DEPTH>1
1170 rb->lcd_set_foreground(colors[deck[prevcard].suit]);
1171 #ifdef HAVE_LCD_COLOR
1172 rb->lcd_set_background(LCD_WHITE);
1173 #endif
1174 #endif
1175 rb->lcd_mono_bitmap(numbers[deck[prevcard].num], CARD_WIDTH+4+j+1, 3, BMPWIDTH_c, BMPHEIGHT_c);
1176 rb->lcd_mono_bitmap(suits[deck[prevcard].suit], CARD_WIDTH+4+j+1, 4+BMPHEIGHT_c, BMPWIDTH_c, BMPHEIGHT_c);
1177
1178
1179 }
1180 j -= BMPWIDTH_c+2;
1181 }
1182 }
1025#if LCD_DEPTH>1 1183#if LCD_DEPTH>1
1026 rb->lcd_set_foreground(colors[deck[cur_rem].suit]); 1184 rb->lcd_set_foreground(LCD_BLACK);
1027#endif 1185#endif
1028 rb->lcd_mono_bitmap(numbers[deck[cur_rem].num], LCD_WIDTH2 - CARD_WIDTH+1, LCD_HEIGHT-CARD_HEIGHT, 8, 8); 1186 if(CARDS_PER_DRAW==1 || cur_rem==NOT_A_CARD)
1029 rb->lcd_mono_bitmap(suits[deck[cur_rem].suit], LCD_WIDTH2 - CARD_WIDTH+7, LCD_HEIGHT-CARD_HEIGHT, 8, 8); 1187 j=0;
1030 /* draw a selected card */ 1188 else
1189 j=(coun_rem)*(BMPWIDTH_c+2);
1190 if(cur_rem != NOT_A_CARD){
1191 rb->lcd_drawline(CARD_WIDTH+4+j+1,1,CARD_WIDTH+4+j+CARD_WIDTH-1,1); /* top line */
1192 rb->lcd_drawline(CARD_WIDTH+4+j,2,CARD_WIDTH+4+j,CARD_HEIGHT); /* left line */
1193 rb->lcd_drawline(CARD_WIDTH+4+j+1,CARD_HEIGHT+1,CARD_WIDTH+4+j+CARD_WIDTH - 1,CARD_HEIGHT+1); /* bottom line */
1194 rb->lcd_drawline(CARD_WIDTH+4+j+CARD_WIDTH,2,CARD_WIDTH+4+j+CARD_WIDTH,CARD_HEIGHT); /* right line */
1195 }
1196
1197 rb->lcd_drawline(2,1,CARD_WIDTH+1,1); /* top line */
1198 rb->lcd_drawline(1,2,1,CARD_HEIGHT); /* left line */
1199 rb->lcd_drawline(2,CARD_HEIGHT+1,CARD_WIDTH + 1,CARD_HEIGHT+1); /* bottom line */
1200 rb->lcd_drawline(CARD_WIDTH+2,2,CARD_WIDTH+2,CARD_HEIGHT); /* right line */
1201
1202 if(cur_rem != NOT_A_CARD){
1031#if LCD_DEPTH>1 1203#if LCD_DEPTH>1
1032 rb->lcd_set_foreground(LCD_BLACK); 1204 #ifdef HAVE_LCD_COLOR
1205 rb->lcd_set_foreground(LCD_WHITE);
1206 rb->lcd_set_background(LCD_WHITE);
1207 #else
1208 rb->lcd_set_foreground(LCD_DEFAULT_BG);
1209 rb->lcd_set_background(LCD_DEFAULT_BG);
1210 #endif
1033#endif 1211#endif
1034 if(sel_card == cur_rem){ 1212 rb->lcd_fillrect(CARD_WIDTH+4+j+1, 2, CARD_WIDTH-1, CARD_HEIGHT-1);
1035 rb->lcd_drawrect(LCD_WIDTH2 - CARD_WIDTH+1, LCD_HEIGHT-CARD_HEIGHT,CARD_WIDTH-1, CARD_HEIGHT-1); 1213 #if LCD_DEPTH>1
1214 rb->lcd_set_foreground(colors[deck[cur_rem].suit]);
1215 #endif
1216 rb->lcd_mono_bitmap(numbers[deck[cur_rem].num], CARD_WIDTH+4+j+1, 3, BMPWIDTH_c, BMPHEIGHT_c);
1217 rb->lcd_mono_bitmap(suits[deck[cur_rem].suit], CARD_WIDTH+4+j+10, 3, BMPWIDTH_c, BMPHEIGHT_c);
1218 /* draw a selected card */
1219 #if LCD_DEPTH>1
1220 rb->lcd_set_foreground(LCD_BLACK);
1221 #ifdef HAVE_LCD_COLOR
1222 rb->lcd_set_background(background_color);
1223 #endif
1224 #endif
1225 if(sel_card == cur_rem){
1226 rb->lcd_drawrect(CARD_WIDTH+4+j+1, 2,CARD_WIDTH-1, CARD_HEIGHT-1);
1227 }
1036 } 1228 }
1229 if(rem != NOT_A_CARD){
1230#ifdef HAVE_LCD_COLOR
1231 rb->lcd_bitmap(backside, 2, 2, BMPWIDTH_BACKSIDE, BMPHEIGHT_BACKSIDE);
1232#endif
1233 }
1037 } 1234 }
1038 } 1235
1236
1039 /* draw the cursor */ 1237 /* draw the cursor */
1040 if(cur_col == REM_COL){ 1238 if(cur_col == REM_COL && rem != NOT_A_CARD){
1239 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
1240 rb->lcd_fillrect(CARD_WIDTH+4+j+1, 2,CARD_WIDTH-1, CARD_HEIGHT-1);
1241 rb->lcd_set_drawmode(DRMODE_SOLID);
1242 } else if(cur_col == REM_COL && rem == NOT_A_CARD) {
1041 rb->lcd_set_drawmode(DRMODE_COMPLEMENT); 1243 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
1042 rb->lcd_fillrect(LCD_WIDTH2 - CARD_WIDTH+1, LCD_HEIGHT-CARD_HEIGHT,CARD_WIDTH-1, CARD_HEIGHT-1); 1244 rb->lcd_fillrect(CARD_WIDTH+4+1, 2,CARD_WIDTH-1, CARD_HEIGHT-1);
1043 rb->lcd_set_drawmode(DRMODE_SOLID); 1245 rb->lcd_set_drawmode(DRMODE_SOLID);
1044 } 1246 }
1045 1247
1046 1248
1047 rb->lcd_update(); 1249 rb->lcd_update();
1048 1250
1049 /* what to do when a key is pressed ... */ 1251 /* what to do when a key is pressed ... */
@@ -1104,7 +1306,8 @@ int solitaire(void){
1104 cur_col = (cur_col - COL_NUM + 1)%(SUITS + 1) + COL_NUM; 1306 cur_col = (cur_col - COL_NUM + 1)%(SUITS + 1) + COL_NUM;
1105 if(cur_col == REM_COL){ 1307 if(cur_col == REM_COL){
1106 cur_card = cur_rem; 1308 cur_card = cur_rem;
1107 } else { 1309 }
1310 else {
1108 cur_card = find_last_card(cur_col); 1311 cur_card = find_last_card(cur_col);
1109 } 1312 }
1110 break; 1313 break;
@@ -1154,6 +1357,7 @@ int solitaire(void){
1154#endif 1357#endif
1155 if(cur_card != NOT_A_CARD){ 1358 if(cur_card != NOT_A_CARD){
1156 move_card(deck[cur_card].suit + STACKS_COL, cur_card); 1359 move_card(deck[cur_card].suit + STACKS_COL, cur_card);
1360 sel_card = NOT_A_CARD;
1157 } 1361 }
1158 break; 1362 break;
1159 1363
@@ -1163,11 +1367,14 @@ int solitaire(void){
1163 if(lastbutton != SOL_MOVE_PRE) 1367 if(lastbutton != SOL_MOVE_PRE)
1164 break; 1368 break;
1165#endif 1369#endif
1370
1166 if(sel_card == NOT_A_CARD) { 1371 if(sel_card == NOT_A_CARD) {
1167 if(cur_card != NOT_A_CARD){ 1372 if(cur_card != NOT_A_CARD) {
1168 /* reveal a hidden card */ 1373 /* reveal a hidden card */
1169 if(deck[cur_card].next == NOT_A_CARD && deck[cur_card].known==0){ 1374 if(deck[cur_card].next == NOT_A_CARD && deck[cur_card].known==0){
1170 deck[cur_card].known = 1; 1375 deck[cur_card].known = 1;
1376 } else if(cur_col == REM_COL && cur_rem == NOT_A_CARD) {
1377 break;
1171 /* select a card */ 1378 /* select a card */
1172 } else { 1379 } else {
1173 sel_card = cur_card; 1380 sel_card = cur_card;
@@ -1192,7 +1399,9 @@ int solitaire(void){
1192 if(lastbutton != SOL_REM2CUR_PRE) 1399 if(lastbutton != SOL_REM2CUR_PRE)
1193 break; 1400 break;
1194#endif 1401#endif
1402 coun_rem = coun_rem-1;
1195 move_card(cur_col, cur_rem); 1403 move_card(cur_col, cur_rem);
1404 sel_card = NOT_A_CARD;
1196 break; 1405 break;
1197 1406
1198 /* If the card on top of the remains can be put on one */ 1407 /* If the card on top of the remains can be put on one */
@@ -1204,9 +1413,26 @@ int solitaire(void){
1204#endif 1413#endif
1205 if(cur_rem != NOT_A_CARD){ 1414 if(cur_rem != NOT_A_CARD){
1206 move_card(deck[cur_rem].suit + COL_NUM, cur_rem); 1415 move_card(deck[cur_rem].suit + COL_NUM, cur_rem);
1416 sel_card = NOT_A_CARD;
1417 coun_rem = coun_rem-1;
1207 } 1418 }
1208 break; 1419 break;
1209 1420
1421
1422#ifdef SOL_REM
1423 case SOL_REM:
1424 if(sel_card != NOT_A_CARD){
1425 /* unselect selected card */
1426 sel_card = NOT_A_CARD;
1427 break;
1428 }
1429 if(rem != NOT_A_CARD && cur_rem != NOT_A_CARD) {
1430 sel_card=cur_rem;
1431 break;
1432 }
1433 break;
1434#endif
1435
1210 /* unselect selected card or ... */ 1436 /* unselect selected card or ... */
1211 /* draw new cards from the remains of the deck */ 1437 /* draw new cards from the remains of the deck */
1212 case SOL_DRAW: 1438 case SOL_DRAW:
@@ -1221,38 +1447,47 @@ int solitaire(void){
1221 } 1447 }
1222 if(rem != NOT_A_CARD) { 1448 if(rem != NOT_A_CARD) {
1223 int cur_rem_old = cur_rem; 1449 int cur_rem_old = cur_rem;
1450 coun_rem = 0;
1224 /* draw new cards form the remains of the deck */ 1451 /* draw new cards form the remains of the deck */
1225 if(cur_rem == NOT_A_CARD){ 1452 if(cur_rem == NOT_A_CARD){ /*if the cursor card is null*/
1226 cur_rem = rem; 1453 cur_rem = rem;
1227 i = CARDS_PER_DRAW - 1; 1454 i = CARDS_PER_DRAW - 1;
1228 } else { 1455 } else {
1229 i = CARDS_PER_DRAW; 1456 i = CARDS_PER_DRAW;
1230 } 1457 }
1458
1231 while(i>0 && deck[cur_rem].next != NOT_A_CARD){ 1459 while(i>0 && deck[cur_rem].next != NOT_A_CARD){
1232 cur_rem = deck[cur_rem].next; 1460 cur_rem = deck[cur_rem].next;
1233 i--; 1461 i--;
1462 coun_rem = coun_rem +1;
1234 } 1463 }
1235 /* test if any cards are really left on */ 1464 /* test if any cards are really left on */
1236 /* the remains' stack */ 1465 /* the remains' stack */
1237 if(i == CARDS_PER_DRAW){ 1466 if(i == CARDS_PER_DRAW){
1238 cur_rem = NOT_A_CARD; 1467 cur_rem = NOT_A_CARD;
1468 coun_rem = 0;
1239 } 1469 }
1240 /* if cursor was on remains' stack when new cards were 1470 /* if cursor was on remains' stack when new cards were
1241 * drawn, put cursor on top of remains' stack */ 1471 * drawn, put cursor on top of remains' stack */
1242 if(cur_col == REM_COL && cur_card == cur_rem_old) 1472 if(cur_col == REM_COL && cur_card == cur_rem_old) {
1243 cur_card = cur_rem; 1473 cur_card = cur_rem;
1474 sel_card = NOT_A_CARD;
1475 }
1244 } 1476 }
1245 break; 1477 break;
1246 1478
1247 /* Show the menu */ 1479 /* Show the menu */
1248 case SOL_QUIT: 1480 case SOL_QUIT:
1481#if LCD_DEPTH>1
1482 rb->lcd_set_background(LCD_DEFAULT_BG);
1483#endif
1249 switch(solitaire_menu(MENU_DURINGGAME)){ 1484 switch(solitaire_menu(MENU_DURINGGAME)){
1250 case MENU_QUIT: 1485 case MENU_QUIT:
1251 return SOLITAIRE_QUIT; 1486 return SOLITAIRE_QUIT;
1252 1487
1253 case MENU_USB: 1488 case MENU_USB:
1254 return SOLITAIRE_USB; 1489 return SOLITAIRE_USB;
1255 1490
1256 case MENU_RESTART: 1491 case MENU_RESTART:
1257 solitaire_init(); 1492 solitaire_init();
1258 break; 1493 break;
@@ -1285,9 +1520,9 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
1285 (void)parameter; 1520 (void)parameter;
1286 rb = api; 1521 rb = api;
1287 /* end of plugin init */ 1522 /* end of plugin init */
1288
1289 /* Welcome to Solitaire ! */ 1523 /* Welcome to Solitaire ! */
1290 rb->splash(HZ*2, true, "Welcome to Solitaire !"); 1524
1525 rb->splash(HZ, true, "Welcome to Solitaire !");
1291 1526
1292 /* play the game :) */ 1527 /* play the game :) */
1293 /* Keep playing if a game was won (that means display the menu after */ 1528 /* Keep playing if a game was won (that means display the menu after */
diff --git a/docs/CREDITS b/docs/CREDITS
index 52fead8dff..2bd8b2616b 100644
--- a/docs/CREDITS
+++ b/docs/CREDITS
@@ -150,3 +150,4 @@ David J. Song
150Jeong Taek In 150Jeong Taek In
151Anders Kagerin 151Anders Kagerin
152Peter D'Hoye 152Peter D'Hoye
153Ben Basha