blob: 17eadd65bea43331a3d888ea34efe8d1a78f2e54 [file] [log] [blame]
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2005 Eli Sherer
11 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000012 * Heavily modified for embedded use by Björn Stenberg (bjorn@haxx.se)
Björn Stenberg9e7f3612006-09-19 20:48:47 +000013 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000014 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
Björn Stenberg9e7f3612006-09-19 20:48:47 +000018 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23#include "plugin.h"
Johannes Schwarz88261152009-11-17 06:57:36 +000024#include "lib/display_text.h"
Björn Stenbergc6b3d382008-11-20 11:27:31 +000025#include "lib/helper.h"
Johannes Schwarz88261152009-11-17 06:57:36 +000026#include "lib/highscore.h"
27#include "lib/playback_control.h"
28#include "lib/playergfx.h"
Michael Sevakise63e84a2010-06-04 13:22:50 +000029#include "lib/mylcd.h"
Björn Stenberg9e7f3612006-09-19 20:48:47 +000030
Thomas Martitzcae4ae22010-08-24 14:30:46 +000031
Björn Stenberg9e7f3612006-09-19 20:48:47 +000032
Jens Arnoldb7013222007-07-27 09:57:27 +000033#if (CONFIG_KEYPAD == IPOD_4G_PAD) || \
34 (CONFIG_KEYPAD == IPOD_3G_PAD) || \
35 (CONFIG_KEYPAD == IPOD_1G2G_PAD)
Björn Stenberg9e7f3612006-09-19 20:48:47 +000036
37#define ROCKBLOX_OFF (BUTTON_MENU | BUTTON_SELECT)
Tomer Shalev12332de2010-02-24 20:56:52 +000038#define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_BACK
39#define ROCKBLOX_ROTATE_CCW2 (BUTTON_MENU | BUTTON_REL)
40#define ROCKBLOX_ROTATE_CW BUTTON_SCROLL_FWD
Björn Stenberg9e7f3612006-09-19 20:48:47 +000041#define ROCKBLOX_LEFT BUTTON_LEFT
42#define ROCKBLOX_RIGHT BUTTON_RIGHT
43#define ROCKBLOX_DOWN BUTTON_PLAY
44#define ROCKBLOX_RESTART (BUTTON_SELECT | BUTTON_PLAY)
45#define ROCKBLOX_DROP (BUTTON_SELECT | BUTTON_REL)
46
Björn Stenberg9e7f3612006-09-19 20:48:47 +000047#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
48 (CONFIG_KEYPAD == IRIVER_H300_PAD)
49
50#define ROCKBLOX_OFF BUTTON_OFF
Tomer Shalev12332de2010-02-24 20:56:52 +000051#define ROCKBLOX_ROTATE_CCW BUTTON_UP
52#define ROCKBLOX_ROTATE_CW BUTTON_SELECT
Björn Stenberg9e7f3612006-09-19 20:48:47 +000053#define ROCKBLOX_DOWN BUTTON_DOWN
54#define ROCKBLOX_LEFT BUTTON_LEFT
55#define ROCKBLOX_RIGHT BUTTON_RIGHT
56#define ROCKBLOX_DROP BUTTON_MODE
57#define ROCKBLOX_RESTART BUTTON_ON
58
59#define ROCKBLOX_RC_OFF BUTTON_RC_STOP
Jens Arnoldb7013222007-07-27 09:57:27 +000060
Björn Stenberg9e7f3612006-09-19 20:48:47 +000061#elif CONFIG_KEYPAD == RECORDER_PAD
62
63#define ROCKBLOX_OFF BUTTON_OFF
Tomer Shalev12332de2010-02-24 20:56:52 +000064#define ROCKBLOX_ROTATE_CCW BUTTON_UP
65#define ROCKBLOX_ROTATE_CW BUTTON_PLAY
Björn Stenberg9e7f3612006-09-19 20:48:47 +000066#define ROCKBLOX_DOWN BUTTON_DOWN
67#define ROCKBLOX_LEFT BUTTON_LEFT
68#define ROCKBLOX_RIGHT BUTTON_RIGHT
69#define ROCKBLOX_DROP BUTTON_ON
70#define ROCKBLOX_RESTART BUTTON_F1
71
Dave Chapmand64e6262007-01-14 13:48:09 +000072#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
73
74#define ROCKBLOX_OFF BUTTON_OFF
Tomer Shalev12332de2010-02-24 20:56:52 +000075#define ROCKBLOX_ROTATE_CCW BUTTON_UP
76#define ROCKBLOX_ROTATE_CW BUTTON_SELECT
Dave Chapmand64e6262007-01-14 13:48:09 +000077#define ROCKBLOX_DOWN BUTTON_DOWN
78#define ROCKBLOX_LEFT BUTTON_LEFT
79#define ROCKBLOX_RIGHT BUTTON_RIGHT
80#define ROCKBLOX_DROP BUTTON_ON
81#define ROCKBLOX_RESTART BUTTON_F1
82
Jens Arnold89658652006-10-07 20:00:49 +000083#elif CONFIG_KEYPAD == PLAYER_PAD
84
Marianne Arnoldf7726732009-05-18 21:30:06 +000085#define ROCKBLOX_OFF_PRE BUTTON_STOP
86#define ROCKBLOX_OFF (BUTTON_STOP|BUTTON_REL)
Tomer Shalev12332de2010-02-24 20:56:52 +000087#define ROCKBLOX_ROTATE_CCW BUTTON_PLAY
88#define ROCKBLOX_ROTATE_CW (BUTTON_ON|BUTTON_PLAY)
Jens Arnold89658652006-10-07 20:00:49 +000089#define ROCKBLOX_DOWN BUTTON_MENU
90#define ROCKBLOX_LEFT BUTTON_LEFT
91#define ROCKBLOX_RIGHT BUTTON_RIGHT
92#define ROCKBLOX_DROP_PRE BUTTON_ON
93#define ROCKBLOX_DROP (BUTTON_ON|BUTTON_REL)
Thomas Martitzba5618a2009-05-16 16:48:18 +000094#define ROCKBLOX_RESTART (BUTTON_STOP|BUTTON_MENU)
Jens Arnold89658652006-10-07 20:00:49 +000095
Björn Stenberg9e7f3612006-09-19 20:48:47 +000096#elif CONFIG_KEYPAD == ONDIO_PAD
97
Marianne Arnoldf7726732009-05-18 21:30:06 +000098#define ROCKBLOX_OFF_PRE BUTTON_OFF
99#define ROCKBLOX_OFF (BUTTON_OFF|BUTTON_REL)
Tomer Shalev12332de2010-02-24 20:56:52 +0000100#define ROCKBLOX_ROTATE_CCW BUTTON_UP
101#define ROCKBLOX_ROTATE_CW (BUTTON_MENU|BUTTON_UP)
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000102#define ROCKBLOX_DOWN BUTTON_DOWN
103#define ROCKBLOX_LEFT BUTTON_LEFT
104#define ROCKBLOX_RIGHT BUTTON_RIGHT
105#define ROCKBLOX_DROP_PRE BUTTON_MENU
106#define ROCKBLOX_DROP (BUTTON_MENU|BUTTON_REL)
Thomas Martitzba5618a2009-05-16 16:48:18 +0000107#define ROCKBLOX_RESTART (BUTTON_OFF|BUTTON_MENU)
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000108
Jens Arnold85a226d2007-03-16 23:02:39 +0000109#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000110
111#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000112#define ROCKBLOX_ROTATE_CCW BUTTON_UP
113#define ROCKBLOX_ROTATE_CW BUTTON_SELECT
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000114#define ROCKBLOX_DOWN BUTTON_DOWN
115#define ROCKBLOX_LEFT BUTTON_LEFT
116#define ROCKBLOX_RIGHT BUTTON_RIGHT
117#define ROCKBLOX_DROP BUTTON_REC
118#define ROCKBLOX_RESTART BUTTON_PLAY
119
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000120#elif CONFIG_KEYPAD == SANSA_E200_PAD
121
122#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000123#define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_BACK
124#define ROCKBLOX_ROTATE_CCW2 BUTTON_UP
125#define ROCKBLOX_ROTATE_CW BUTTON_SCROLL_FWD
Barry Wardell24f4a2a2006-10-26 13:38:09 +0000126#define ROCKBLOX_DOWN BUTTON_DOWN
127#define ROCKBLOX_LEFT BUTTON_LEFT
128#define ROCKBLOX_RIGHT BUTTON_RIGHT
129#define ROCKBLOX_DROP BUTTON_SELECT
130#define ROCKBLOX_RESTART BUTTON_REC
131
Michael Giacomelli6d5823f2009-01-04 23:33:15 +0000132#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
133
Thomas Martitze6cbad62009-04-10 17:28:26 +0000134#define ROCKBLOX_OFF (BUTTON_HOME|BUTTON_REPEAT)
Tomer Shalev12332de2010-02-24 20:56:52 +0000135#define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_BACK
136#define ROCKBLOX_ROTATE_CCW2 BUTTON_UP
137#define ROCKBLOX_ROTATE_CW BUTTON_SCROLL_FWD
Michael Giacomelli6d5823f2009-01-04 23:33:15 +0000138#define ROCKBLOX_DOWN BUTTON_DOWN
139#define ROCKBLOX_LEFT BUTTON_LEFT
140#define ROCKBLOX_RIGHT BUTTON_RIGHT
Thomas Martitze6cbad62009-04-10 17:28:26 +0000141#define ROCKBLOX_DROP (BUTTON_SELECT | BUTTON_REL)
142#define ROCKBLOX_RESTART (BUTTON_SELECT | BUTTON_UP)
Michael Giacomelli6d5823f2009-01-04 23:33:15 +0000143
144
Marianne Arnold12ddb8e2007-09-20 10:49:48 +0000145#elif CONFIG_KEYPAD == SANSA_C200_PAD
146
147#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000148#define ROCKBLOX_ROTATE_CCW BUTTON_UP
149#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
150#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Marianne Arnold12ddb8e2007-09-20 10:49:48 +0000151#define ROCKBLOX_DOWN BUTTON_DOWN
152#define ROCKBLOX_LEFT BUTTON_LEFT
153#define ROCKBLOX_RIGHT BUTTON_RIGHT
154#define ROCKBLOX_DROP BUTTON_SELECT
155#define ROCKBLOX_RESTART BUTTON_REC
156
Rafaël Carré5656f822008-11-28 00:37:28 +0000157#elif CONFIG_KEYPAD == SANSA_CLIP_PAD
158
159#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000160#define ROCKBLOX_ROTATE_CCW BUTTON_UP
161#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
162#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Rafaël Carré5656f822008-11-28 00:37:28 +0000163#define ROCKBLOX_DOWN BUTTON_DOWN
164#define ROCKBLOX_LEFT BUTTON_LEFT
165#define ROCKBLOX_RIGHT BUTTON_RIGHT
166#define ROCKBLOX_DROP BUTTON_SELECT
167#define ROCKBLOX_RESTART BUTTON_HOME
168
Johannes Schwarz88261152009-11-17 06:57:36 +0000169#elif CONFIG_KEYPAD == SANSA_M200_PAD
Dominik Wenger90bcf9b2008-12-12 19:50:49 +0000170
171#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000172#define ROCKBLOX_ROTATE_CCW BUTTON_UP
173#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_DOWN
174#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Dominik Wenger90bcf9b2008-12-12 19:50:49 +0000175#define ROCKBLOX_DOWN BUTTON_DOWN
176#define ROCKBLOX_LEFT BUTTON_LEFT
177#define ROCKBLOX_RIGHT BUTTON_RIGHT
178#define ROCKBLOX_RESTART (BUTTON_SELECT | BUTTON_UP)
179#define ROCKBLOX_DROP (BUTTON_SELECT | BUTTON_REL)
180
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000181#elif CONFIG_KEYPAD == IRIVER_H10_PAD
182
183#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000184#define ROCKBLOX_ROTATE_CCW BUTTON_SCROLL_UP
185#define ROCKBLOX_ROTATE_CW BUTTON_REW
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000186#define ROCKBLOX_DOWN BUTTON_SCROLL_DOWN
187#define ROCKBLOX_LEFT BUTTON_LEFT
188#define ROCKBLOX_RIGHT BUTTON_RIGHT
189#define ROCKBLOX_DROP BUTTON_FF
190#define ROCKBLOX_RESTART BUTTON_PLAY
191
Steve Gotthardtd850db12007-01-05 16:32:20 +0000192#elif CONFIG_KEYPAD == GIGABEAT_PAD
193
Marcoen Hirschberga7168fe2007-05-19 23:38:09 +0000194#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000195#define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN
196#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Marcoen Hirschberga7168fe2007-05-19 23:38:09 +0000197#define ROCKBLOX_ROTATE BUTTON_UP
Steve Gotthardtd850db12007-01-05 16:32:20 +0000198#define ROCKBLOX_DOWN BUTTON_DOWN
199#define ROCKBLOX_LEFT BUTTON_LEFT
200#define ROCKBLOX_RIGHT BUTTON_RIGHT
201#define ROCKBLOX_DROP BUTTON_SELECT
Marcoen Hirschberga7168fe2007-05-19 23:38:09 +0000202#define ROCKBLOX_RESTART BUTTON_A
Marianne Arnold59c9dcc2007-01-06 12:38:41 +0000203
204#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
205
206#define ROCKBLOX_OFF BUTTON_PLAY
Tomer Shalev12332de2010-02-24 20:56:52 +0000207#define ROCKBLOX_ROTATE_CCW BUTTON_UP
208#define ROCKBLOX_ROTATE_CW BUTTON_SELECT
Marianne Arnold59c9dcc2007-01-06 12:38:41 +0000209#define ROCKBLOX_DOWN BUTTON_DOWN
210#define ROCKBLOX_LEFT BUTTON_LEFT
211#define ROCKBLOX_RIGHT BUTTON_RIGHT
212#define ROCKBLOX_DROP BUTTON_MODE
213#define ROCKBLOX_RESTART BUTTON_EQ
214
Jonathan Gordon56ddddc2007-10-23 15:40:51 +0000215#elif CONFIG_KEYPAD == MROBE500_PAD
216#define ROCKBLOX_OFF BUTTON_POWER
Jonathan Gordon56ddddc2007-10-23 15:40:51 +0000217
Will Robertson8215b342008-02-17 12:23:02 +0000218#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
219#define ROCKBLOX_OFF BUTTON_BACK
Tomer Shalev12332de2010-02-24 20:56:52 +0000220#define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN
221#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Will Robertson8215b342008-02-17 12:23:02 +0000222#define ROCKBLOX_ROTATE BUTTON_UP
223#define ROCKBLOX_DOWN BUTTON_DOWN
224#define ROCKBLOX_LEFT BUTTON_LEFT
225#define ROCKBLOX_RIGHT BUTTON_RIGHT
226#define ROCKBLOX_DROP BUTTON_SELECT
227#define ROCKBLOX_RESTART BUTTON_PLAY
228
Robert Kuklad6c8b572008-03-01 22:55:09 +0000229#elif CONFIG_KEYPAD == MROBE100_PAD
230
231#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000232#define ROCKBLOX_ROTATE_CCW BUTTON_MENU
233#define ROCKBLOX_ROTATE_CW BUTTON_PLAY
Robert Kuklad6c8b572008-03-01 22:55:09 +0000234#define ROCKBLOX_ROTATE BUTTON_UP
235#define ROCKBLOX_DOWN BUTTON_DOWN
236#define ROCKBLOX_LEFT BUTTON_LEFT
237#define ROCKBLOX_RIGHT BUTTON_RIGHT
238#define ROCKBLOX_DROP BUTTON_SELECT
239#define ROCKBLOX_RESTART BUTTON_DISPLAY
240
Jens Arnold29361ab2008-03-22 10:24:28 +0000241#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
242
243#define ROCKBLOX_OFF BUTTON_RC_REC
Tomer Shalev12332de2010-02-24 20:56:52 +0000244#define ROCKBLOX_ROTATE_CCW BUTTON_RC_VOL_DOWN
245#define ROCKBLOX_ROTATE_CW BUTTON_RC_VOL_UP
Jens Arnold29361ab2008-03-22 10:24:28 +0000246#define ROCKBLOX_DOWN BUTTON_RC_MENU
247#define ROCKBLOX_LEFT BUTTON_RC_REW
248#define ROCKBLOX_RIGHT BUTTON_RC_FF
249#define ROCKBLOX_DROP BUTTON_RC_PLAY
250#define ROCKBLOX_RESTART BUTTON_RC_MODE
251
Tomer Shalev47ddbaa2009-12-15 20:51:41 +0000252#elif CONFIG_KEYPAD == COWON_D2_PAD
Tomer Shalev83d589d2010-02-24 21:16:48 +0000253
Rob Purchase554d7ed2008-03-22 22:03:34 +0000254#define ROCKBLOX_OFF BUTTON_POWER
Rob Purchase554d7ed2008-03-22 22:03:34 +0000255#define ROCKBLOX_RESTART BUTTON_MENU
256
Vitja Makarov2f84f692008-10-07 16:38:28 +0000257#elif CONFIG_KEYPAD == IAUDIO67_PAD
258
259#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000260#define ROCKBLOX_ROTATE_CCW BUTTON_VOLDOWN
261#define ROCKBLOX_ROTATE_CW BUTTON_VOLUP
Vitja Makarov2f84f692008-10-07 16:38:28 +0000262#define ROCKBLOX_DOWN BUTTON_STOP
263#define ROCKBLOX_LEFT BUTTON_LEFT
264#define ROCKBLOX_RIGHT BUTTON_RIGHT
265#define ROCKBLOX_DROP BUTTON_PLAY
266#define ROCKBLOX_RESTART BUTTON_MENU
267
Björn Stenbergcea285d2008-12-04 21:28:56 +0000268#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
269#define ROCKBLOX_OFF BUTTON_BACK
Tomer Shalev12332de2010-02-24 20:56:52 +0000270#define ROCKBLOX_ROTATE_CCW BUTTON_UP
271#define ROCKBLOX_ROTATE_CW BUTTON_PLAY
Björn Stenbergcea285d2008-12-04 21:28:56 +0000272#define ROCKBLOX_DOWN BUTTON_DOWN
273#define ROCKBLOX_LEFT BUTTON_LEFT
274#define ROCKBLOX_RIGHT BUTTON_RIGHT
Maurus Cuelenaere6471b3c2008-12-08 09:51:42 +0000275#define ROCKBLOX_DROP BUTTON_SELECT
Björn Stenbergcea285d2008-12-04 21:28:56 +0000276#define ROCKBLOX_RESTART BUTTON_CUSTOM
277
Mark Arigo24902622009-01-24 22:41:55 +0000278#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
279
280#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000281#define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN
282#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Mark Arigo24902622009-01-24 22:41:55 +0000283#define ROCKBLOX_ROTATE BUTTON_UP
284#define ROCKBLOX_DOWN BUTTON_DOWN
285#define ROCKBLOX_LEFT BUTTON_LEFT
286#define ROCKBLOX_RIGHT BUTTON_RIGHT
287#define ROCKBLOX_DROP BUTTON_SELECT
288#define ROCKBLOX_RESTART BUTTON_MENU
289
Robert Menes82d322c2010-11-02 14:36:08 +0000290#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
291
292#define ROCKBLOX_OFF BUTTON_POWER
293#define ROCKBLOX_ROTATE_CCW BUTTON_PREV
294#define ROCKBLOX_ROTATE_CW BUTTON_NEXT
295#define ROCKBLOX_ROTATE BUTTON_UP
296#define ROCKBLOX_DOWN BUTTON_DOWN
297#define ROCKBLOX_LEFT BUTTON_LEFT
298#define ROCKBLOX_RIGHT BUTTON_RIGHT
299#define ROCKBLOX_DROP BUTTON_PLAY
300#define ROCKBLOX_RESTART BUTTON_MENU
301
Robert Menes9dc1c1a2009-12-09 18:20:49 +0000302# elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
303
304#define ROCKBLOX_OFF BUTTON_POWER
Tomer Shalev12332de2010-02-24 20:56:52 +0000305#define ROCKBLOX_ROTATE_CCW BUTTON_VOL_DOWN
306#define ROCKBLOX_ROTATE_CW BUTTON_VOL_UP
Robert Menes9dc1c1a2009-12-09 18:20:49 +0000307#define ROCKBLOX_ROTATE BUTTON_UP
308#define ROCKBLOX_DOWN BUTTON_DOWN
309#define ROCKBLOX_LEFT BUTTON_PREV
310#define ROCKBLOX_RIGHT BUTTON_NEXT
311#define ROCKBLOX_DROP BUTTON_PLAY
312#define ROCKBLOX_RESTART BUTTON_MENU
313
Maurus Cuelenaerefef405c2009-04-07 23:41:44 +0000314#elif CONFIG_KEYPAD == ONDAVX747_PAD
315#define ROCKBLOX_OFF BUTTON_POWER
316#define ROCKBLOX_RESTART BUTTON_MENU
Maurus Cuelenaere96802442009-08-31 21:11:32 +0000317#elif CONFIG_KEYPAD == ONDAVX777_PAD
318#define ROCKBLOX_OFF BUTTON_POWER
Maurus Cuelenaerefef405c2009-04-07 23:41:44 +0000319
Michael Giacomelli594b6e22009-08-04 03:08:32 +0000320#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
321
322#define ROCKBLOX_OFF (BUTTON_REC|BUTTON_PLAY)
Tomer Shalev12332de2010-02-24 20:56:52 +0000323#define ROCKBLOX_ROTATE_CCW BUTTON_UP
324#define ROCKBLOX_ROTATE_CW BUTTON_DOWN
Michael Giacomelli594b6e22009-08-04 03:08:32 +0000325#define ROCKBLOX_DOWN BUTTON_REW
326#define ROCKBLOX_LEFT BUTTON_LEFT
327#define ROCKBLOX_RIGHT BUTTON_RIGHT
328#define ROCKBLOX_DROP BUTTON_FFWD
329#define ROCKBLOX_RESTART (BUTTON_REC|BUTTON_REW)
330
Szymon Dziok05577e42010-02-11 22:40:17 +0000331#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
332
333#define ROCKBLOX_OFF BUTTON_REC
Tomer Shalev12332de2010-02-24 20:56:52 +0000334#define ROCKBLOX_ROTATE_CCW BUTTON_PLAY
335#define ROCKBLOX_ROTATE_CW BUTTON_MENU
Szymon Dziok05577e42010-02-11 22:40:17 +0000336#define ROCKBLOX_DOWN BUTTON_DOWN
337#define ROCKBLOX_LEFT BUTTON_PREV
338#define ROCKBLOX_RIGHT BUTTON_NEXT
339#define ROCKBLOX_DROP BUTTON_OK
340#define ROCKBLOX_RESTART BUTTON_CANCEL
341
Marcin Bukatb09d3ae2010-04-26 21:40:00 +0000342#elif CONFIG_KEYPAD == MPIO_HD200_PAD
343#define ROCKBLOX_OFF (BUTTON_REC|BUTTON_PLAY)
Marcin Bukat59ba8fe2010-11-02 10:44:34 +0000344#define ROCKBLOX_ROTATE_CCW BUTTON_REW
345#define ROCKBLOX_ROTATE_CW BUTTON_FF
346#define ROCKBLOX_DOWN BUTTON_FUNC
Marcin Bukatb09d3ae2010-04-26 21:40:00 +0000347#define ROCKBLOX_LEFT BUTTON_VOL_DOWN
348#define ROCKBLOX_RIGHT BUTTON_VOL_UP
349#define ROCKBLOX_DROP BUTTON_PLAY
350#define ROCKBLOX_RESTART BUTTON_REC
351
Marcin Bukatdd617022010-11-30 10:52:14 +0000352#elif CONFIG_KEYPAD == MPIO_HD300_PAD
Marcin Bukat58633612012-02-02 14:42:42 +0100353#define ROCKBLOX_OFF (BUTTON_MENU|BUTTON_REPEAT)
354#define ROCKBLOX_ROTATE_CCW BUTTON_UP
355#define ROCKBLOX_ROTATE_CW BUTTON_DOWN
356#define ROCKBLOX_DOWN (BUTTON_ENTER | BUTTON_REL)
357#define ROCKBLOX_LEFT BUTTON_REW
358#define ROCKBLOX_RIGHT BUTTON_FF
Marcin Bukatdd617022010-11-30 10:52:14 +0000359#define ROCKBLOX_DROP BUTTON_PLAY
360#define ROCKBLOX_RESTART BUTTON_REC
361
Amaury Pouly24930a32011-10-02 15:39:46 +0000362#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
Jean-Louis Biasini5bfbc642012-03-01 23:23:29 +0100363#define ROCKBLOX_OFF_PRE BUTTON_POWER
364#define ROCKBLOX_OFF BUTTON_POWER|BUTTON_REL
365#define ROCKBLOX_ROTATE_CW BUTTON_BOTTOMRIGHT
366#define ROCKBLOX_ROTATE_CCW BUTTON_BOTTOMLEFT
367#define ROCKBLOX_DOWN BUTTON_SELECT
Amaury Pouly24930a32011-10-02 15:39:46 +0000368#define ROCKBLOX_LEFT BUTTON_LEFT
369#define ROCKBLOX_RIGHT BUTTON_RIGHT
Jean-Louis Biasini5bfbc642012-03-01 23:23:29 +0100370#define ROCKBLOX_DROP_PRE BUTTON_DOWN
371#define ROCKBLOX_DROP BUTTON_DOWN|BUTTON_REL
372#define ROCKBLOX_RESTART BUTTON_BACK|BUTTON_REPEAT
373#define ROCKBLOX_ROTATE_CCW2 BUTTON_VOL_UP
374#define ROCKBLOX_ROTATE_CW2 BUTTON_VOL_DOWN
Amaury Pouly24930a32011-10-02 15:39:46 +0000375
Tomasz Mońe8a8a1b2011-11-16 14:08:01 +0000376#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
377#define ROCKBLOX_OFF BUTTON_POWER
378#define ROCKBLOX_ROTATE_CW BUTTON_NEXT
379#define ROCKBLOX_ROTATE_CCW BUTTON_PREV
380#define ROCKBLOX_DOWN BUTTON_DOWN
381#define ROCKBLOX_LEFT BUTTON_LEFT
382#define ROCKBLOX_RIGHT BUTTON_RIGHT
383#define ROCKBLOX_DROP BUTTON_SELECT
384#define ROCKBLOX_RESTART BUTTON_VOL_DOWN
385
Thomas Martitz249bba02011-12-24 11:56:46 +0000386#elif CONFIG_KEYPAD == SAMSUNG_YPR0_PAD
387
388#define ROCKBLOX_OFF BUTTON_BACK
389#define ROCKBLOX_ROTATE_CCW BUTTON_POWER
390#define ROCKBLOX_ROTATE_CW BUTTON_MENU
391#define ROCKBLOX_ROTATE BUTTON_UP
392#define ROCKBLOX_DOWN BUTTON_DOWN
393#define ROCKBLOX_LEFT BUTTON_LEFT
394#define ROCKBLOX_RIGHT BUTTON_RIGHT
395#define ROCKBLOX_DROP BUTTON_SELECT
396#define ROCKBLOX_RESTART BUTTON_USER
397
Andrew Ryabinin397863a2012-03-23 22:32:50 +0400398#elif CONFIG_KEYPAD == HM60X_PAD
399
400#define ROCKBLOX_OFF BUTTON_POWER
401#define ROCKBLOX_ROTATE_CCW (BUTTON_LEFT|BUTTON_POWER)
402#define ROCKBLOX_ROTATE_CW (BUTTON_RIGHT|BUTTON_POWER)
403#define ROCKBLOX_ROTATE BUTTON_UP
404#define ROCKBLOX_DOWN BUTTON_DOWN
405#define ROCKBLOX_LEFT BUTTON_LEFT
406#define ROCKBLOX_RIGHT BUTTON_RIGHT
407#define ROCKBLOX_DROP BUTTON_SELECT
408#define ROCKBLOX_RESTART (BUTTON_DOWN|BUTTON_POWER)
409
Andrew Ryabinin6ee3fc82012-04-06 20:17:27 +0400410#elif CONFIG_KEYPAD == HM801_PAD
411
412#define ROCKBLOX_OFF BUTTON_POWER
413#define ROCKBLOX_ROTATE_CCW BUTTON_PREV
414#define ROCKBLOX_ROTATE_CW BUTTON_NEXT
415#define ROCKBLOX_ROTATE BUTTON_UP
416#define ROCKBLOX_DOWN BUTTON_DOWN
417#define ROCKBLOX_LEFT BUTTON_LEFT
418#define ROCKBLOX_RIGHT BUTTON_RIGHT
419#define ROCKBLOX_DROP BUTTON_SELECT
420#define ROCKBLOX_RESTART BUTTON_PLAY
421
Robert Kuklad6c8b572008-03-01 22:55:09 +0000422#else
423#error No keymap defined!
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000424#endif
425
Maurus Cuelenaere1392dc22008-08-23 09:46:38 +0000426#ifdef HAVE_TOUCHSCREEN
Rob Purchase297e0502008-04-27 15:30:19 +0000427#ifndef ROCKBLOX_OFF
428#define ROCKBLOX_OFF BUTTON_TOPLEFT
429#endif
Tomer Shalev12332de2010-02-24 20:56:52 +0000430#ifdef ROCKBLOX_ROTATE_CCW
Tomer Shalev32184312010-02-24 20:59:35 +0000431#define ROCKBLOX_ROTATE_CCW2 BUTTON_BOTTOMLEFT
Tomer Shalev12332de2010-02-24 20:56:52 +0000432#else
Tomer Shalev32184312010-02-24 20:59:35 +0000433#define ROCKBLOX_ROTATE_CCW BUTTON_BOTTOMLEFT
Rob Purchase297e0502008-04-27 15:30:19 +0000434#endif
Tomer Shalev12332de2010-02-24 20:56:52 +0000435#ifdef ROCKBLOX_ROTATE_CW
Tomer Shalev32184312010-02-24 20:59:35 +0000436#define ROCKBLOX_ROTATE_CW2 BUTTON_BOTTOMRIGHT
Tomer Shalev12332de2010-02-24 20:56:52 +0000437#else
Tomer Shalev32184312010-02-24 20:59:35 +0000438#define ROCKBLOX_ROTATE_CW BUTTON_BOTTOMRIGHT
Tomer Shalev83d589d2010-02-24 21:16:48 +0000439#define ROCKBLOX_ROTATE_CW2 BUTTON_TOPMIDDLE
Rob Purchase297e0502008-04-27 15:30:19 +0000440#endif
441#ifndef ROCKBLOX_DOWN
442#define ROCKBLOX_DOWN BUTTON_BOTTOMMIDDLE
443#endif
444#ifndef ROCKBLOX_LEFT
445#define ROCKBLOX_LEFT BUTTON_MIDLEFT
446#endif
447#ifndef ROCKBLOX_RIGHT
448#define ROCKBLOX_RIGHT BUTTON_MIDRIGHT
449#endif
450#ifndef ROCKBLOX_DROP
451#define ROCKBLOX_DROP BUTTON_CENTER
452#endif
453#ifndef ROCKBLOX_RESTART
454#define ROCKBLOX_RESTART BUTTON_TOPRIGHT
455#endif
456#endif
457
Jens Arnold89658652006-10-07 20:00:49 +0000458#define BLOCKS_NUM 7
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000459#define EMPTY_BLOCK 7
460
461#define BOARD_WIDTH 10
Jens Arnold89658652006-10-07 20:00:49 +0000462
463#ifdef HAVE_LCD_BITMAP
464
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000465#define BOARD_HEIGHT 20
466
Karl Kurbjund3c0a7f2007-11-10 22:12:54 +0000467#if (LCD_WIDTH == 640) && (LCD_HEIGHT == 480)
468
Karl Kurbjun70deae02009-07-21 03:52:59 +0000469#define BLOCK_WIDTH 24
470#define BLOCK_HEIGHT 24
471#define BOARD_X 172
472#define BOARD_Y 0
473#define PREVIEW_X 24
474#define PREVIEW_Y 22
475#define LABEL_X 482
476#define SCORE_Y 50
477#define LEVEL_Y 140
478#define LINES_Y 210
Karl Kurbjund3c0a7f2007-11-10 22:12:54 +0000479
480#elif (LCD_WIDTH == 480) && (LCD_HEIGHT == 640)
Jonathan Gordon56ddddc2007-10-23 15:40:51 +0000481
482#define BLOCK_WIDTH 30
483#define BLOCK_HEIGHT 30
484#define BOARD_X 14
485#define BOARD_Y 2
486#define PREVIEW_X 342
487#define PREVIEW_Y 482
488#define LABEL_X 344
489#define SCORE_Y 58
490#define LEVEL_Y 142
491#define LINES_Y 218
Jonathan Gordon56ddddc2007-10-23 15:40:51 +0000492
493#elif (LCD_WIDTH == 320) && (LCD_HEIGHT == 240)
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000494
495#define BLOCK_WIDTH 12
496#define BLOCK_HEIGHT 12
497#define BOARD_X 86
498#define BOARD_Y 0
499#define PREVIEW_X 12
500#define PREVIEW_Y 11
501#define LABEL_X 242
502#define SCORE_Y 25
503#define LEVEL_Y 70
504#define LINES_Y 105
505
Maurus Cuelenaerefef405c2009-04-07 23:41:44 +0000506#elif (LCD_WIDTH == 240) && ((LCD_HEIGHT == 320) || (LCD_HEIGHT == 400))
Steve Gotthardtd850db12007-01-05 16:32:20 +0000507
Steve Gotthardt1f38e212007-01-06 03:03:52 +0000508#define BLOCK_WIDTH 15
509#define BLOCK_HEIGHT 15
510#define BOARD_X 7
511#define BOARD_Y 1
512#define PREVIEW_X 171
513#define PREVIEW_Y 241
514#define LABEL_X 172
515#define SCORE_Y 29
516#define LEVEL_Y 71
517#define LINES_Y 109
518#define HIGH_LABEL_X 172
519#define HIGH_SCORE_Y 163
520#define HIGH_LEVEL_Y 172
Steve Gotthardtd850db12007-01-05 16:32:20 +0000521
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000522#elif (LCD_WIDTH == 220) && (LCD_HEIGHT == 176)
523
524#define BLOCK_WIDTH 8
525#define BLOCK_HEIGHT 8
526#define BOARD_X 27
527#define BOARD_Y 5
528#define PREVIEW_X 158
529#define PREVIEW_Y 130
530#define LABEL_X 147
531#define SCORE_Y 20
532#define LEVEL_Y 65
533#define LINES_Y 100
534
535#elif (LCD_WIDTH == 176) && (LCD_HEIGHT == 132)
536
537#define BLOCK_WIDTH 6
538#define BLOCK_HEIGHT 6
539#define BOARD_X 25
540#define BOARD_Y 1
541#define PREVIEW_X 126
542#define PREVIEW_Y 102
543#define LABEL_X 112
544#define SCORE_Y 17
545#define LEVEL_Y 49
546#define LINES_Y 81
547
Marianne Arnold59c9dcc2007-01-06 12:38:41 +0000548#elif (LCD_WIDTH == 176) && (LCD_HEIGHT == 220)
549
Thomas Martitz11231152009-05-13 17:45:07 +0000550/* no room for the space in the highscore list */
551#define _SPACE ""
552
Marianne Arnold59c9dcc2007-01-06 12:38:41 +0000553#define BLOCK_WIDTH 10
554#define BLOCK_HEIGHT 10
555#define BOARD_X 6
556#define BOARD_Y 10
557#define PREVIEW_X 124
Thomas Martitz11231152009-05-13 17:45:07 +0000558#define PREVIEW_Y 174
Marianne Arnold59c9dcc2007-01-06 12:38:41 +0000559#define LABEL_X 117
Thomas Martitz11231152009-05-13 17:45:07 +0000560#define SCORE_Y 18
561#define LEVEL_Y 52
562#define LINES_Y 85
563#define HIGH_SCORE_Y 119
564#define HIGH_LEVEL_Y 126
565#define HIGH_LABEL_X 114
566
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000567#elif (LCD_WIDTH == 160) && (LCD_HEIGHT == 128)
568
Thomas Martitz11231152009-05-13 17:45:07 +0000569
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000570#define BLOCK_WIDTH 6
571#define BLOCK_HEIGHT 6
572#define BOARD_X 22
573#define BOARD_Y 3
574#define PREVIEW_X 114
575#define PREVIEW_Y 100
576#define LABEL_X 101
577#define SCORE_Y 17
578#define LEVEL_Y 49
579#define LINES_Y 82
580
Jens Arnold29361ab2008-03-22 10:24:28 +0000581#elif (LCD_WIDTH == 138) && (LCD_HEIGHT == 110)
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000582
Jens Arnold29361ab2008-03-22 10:24:28 +0000583#define BLOCK_WIDTH 5
584#define BLOCK_HEIGHT 5
585#define BOARD_X 14
586#define BOARD_Y 0
587#define PREVIEW_X 98
588#define PREVIEW_Y 88
589#define LABEL_X 80
590#define SCORE_Y 15
591#define LEVEL_Y 45
592#define LINES_Y 74
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000593
Marianne Arnold12ddb8e2007-09-20 10:49:48 +0000594#elif (LCD_WIDTH == 132) && (LCD_HEIGHT == 80)
595
596#define BLOCK_WIDTH 4
597#define BLOCK_HEIGHT 4
598#define BOARD_X 10
599#define BOARD_Y 0
600#define PREVIEW_X 89
601#define PREVIEW_Y 61
602#define LABEL_X 78
603#define SCORE_Y 10
604#define LEVEL_Y 30
605#define LINES_Y 50
606
Jens Arnold29361ab2008-03-22 10:24:28 +0000607#elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 128)
608
609#define BLOCK_WIDTH 6
610#define BLOCK_HEIGHT 6
611#define BOARD_X 4
612#define BOARD_Y 3
613#define PREVIEW_X 84
614#define PREVIEW_Y 100
615#define LABEL_X 71
616#define SCORE_Y 17
617#define LEVEL_Y 49
618#define LINES_Y 82
619
Robert Menes9dc1c1a2009-12-09 18:20:49 +0000620#elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 160)
621
Michael Sevakis9f4fdbd2011-01-10 07:32:29 +0000622#define BLOCK_WIDTH 7
623#define BLOCK_HEIGHT 7
Robert Menes9dc1c1a2009-12-09 18:20:49 +0000624#define BOARD_X 4
Michael Sevakis9f4fdbd2011-01-10 07:32:29 +0000625#define BOARD_Y 5
626#define PREVIEW_X 88
627#define PREVIEW_Y 111
628#define LABEL_X 82
629#define SCORE_Y (2+16)
630#define LEVEL_Y (36+16)
631#define LINES_Y (70+16)
Robert Menes9dc1c1a2009-12-09 18:20:49 +0000632
Jens Arnold29361ab2008-03-22 10:24:28 +0000633#elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 96)
634
635#define BLOCK_WIDTH 4
636#define BLOCK_HEIGHT 4
637#define BOARD_X 14
638#define BOARD_Y 2
639#define PREVIEW_X 89
640#define PREVIEW_Y 76
641#define LABEL_X 70
642#define SCORE_Y 14
643#define LEVEL_Y 39
644#define LINES_Y 64
645
Marianne Arnold59c9dcc2007-01-06 12:38:41 +0000646#elif (LCD_WIDTH == 128) && (LCD_HEIGHT == 64)
647
648#define BLOCK_WIDTH 3
649#define BLOCK_HEIGHT 3
650#define BOARD_X 9
651#define BOARD_Y 3
652#define PREVIEW_X 53
653#define PREVIEW_Y 5
654#define LABEL_X 70
655#define SCORE_Y 32
656#define LEVEL_Y 13
657#define LINES_Y 51
658
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000659#elif (LCD_WIDTH == 112) && (LCD_HEIGHT == 64)
660
661#define BLOCK_WIDTH 4
662#define BLOCK_HEIGHT 3
663#define BOARD_X 9
664#define BOARD_Y 3
665#define PREVIEW_X 59
666#define PREVIEW_Y 5
667#define LABEL_X 59
668#define SCORE_Y 32
669#define LEVEL_Y 13
670#define LEVEL_X 78
671#define LINES_Y 51
672
Rafaël Carrébd691ef2011-12-02 20:28:20 +0000673#elif LCD_WIDTH == 96 && LCD_HEIGHT == 96
674
675#define BLOCK_WIDTH 3
676#define BLOCK_HEIGHT 3
677#define BOARD_X 9
678#define BOARD_Y 3
679#define PREVIEW_X 59
680#define PREVIEW_Y 5
681#define LABEL_X 59
682#define SCORE_Y 32
683#define LEVEL_Y 13
684#define LEVEL_X 78
685#define LINES_Y 51
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000686#endif
687
Jens Arnold89658652006-10-07 20:00:49 +0000688#ifndef LEVEL_X
689#define LEVEL_X LABEL_X
690#endif
691
Steve Gotthardtd850db12007-01-05 16:32:20 +0000692#ifndef LINES_X
693#define LINES_X LABEL_X
694#endif
695
Jens Arnold89658652006-10-07 20:00:49 +0000696extern const fb_data rockblox_background[];
697
698#else /* HAVE_LCD_CHARCELLS */
699
700#define BOARD_HEIGHT 14
701
702#define BLOCK_WIDTH 1
703#define BLOCK_HEIGHT 1
704#define BOARD_X 5
705#define BOARD_Y 0
706#define PREVIEW_X 15
707#define PREVIEW_Y 1
708
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000709#endif
710
Thomas Martitz11231152009-05-13 17:45:07 +0000711#ifndef _SPACE
712#define _SPACE " "
713#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000714/* <<Explanation on Rockblox shapes>>
715
716 %%
717 %% - O has 1 orientation
718
719 %% %
720 %% %% - Z has 2 orientations
721 %
722
723 %% %
724 %% %% - S has 2 orientations
725 %
726 %
727 %
728 % %%%% - I has 2 orientations
729 %
730
731 % %%
732 % % % %%% - L has 4 orientations
733 %% %%% % %
734
Michael Giacomelli6d5823f2009-01-04 23:33:15 +0000735 % %%
736 % % % %%% - J has 4 orientations
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000737 %% %%% % %
738
739 % % %%%
740 %% % %% % - T has 4 orientations
741 % %%% %
742 */
743
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000744/* c=current f=figure o=orientation n=next */
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000745static struct _rockblox_status
746{
747 int gameover;
748 int lines;
749 int level;
750 int score;
751 int cx;
752 int cy;
753 int cf;
754 int co;
755 int nf;
756 short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */
757} rockblox_status;
758
759/* prototypes */
760static void draw_next_block(void);
761static void new_block(void);
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000762
Thomas Martitz19f3d602009-02-26 20:52:16 +0000763#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000764int wheel_events = 0, last_wheel_event = 0;
765bool wheel_enabled = false;
766#endif
767
Jens Arnold89658652006-10-07 20:00:49 +0000768static const short scoring[4] = { /* scoring for each number of lines */
769#if BOARD_HEIGHT == 20
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000770 40 /* single */ , 100 /* double */ , 300 /* triple */ , 1200 /* rockblox */
Jens Arnold89658652006-10-07 20:00:49 +0000771#elif BOARD_HEIGHT == 14 /* Player special values */
772 60 /* single */ , 150 /* double */ , 500 /* triple */ , 2000 /* rockblox */
773#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000774};
775
776struct figure
777{
778#if LCD_DEPTH >= 2
779 unsigned short color[3]; /* color of figure (light,middle,shadow) */
780#endif
781 unsigned short max_or; /* max orientations */
782 signed short shapeX[4], shapeY[4]; /* implementation of figures */
783}
784
785/* array of figures */
786figures[BLOCKS_NUM] = {
787 /* O */
788 {
789#if LCD_DEPTH >= 16
790 {LCD_RGBPACK (153, 255, 255), LCD_RGBPACK(0, 255, 255),
791 LCD_RGBPACK(0,153,153)},
792#elif LCD_DEPTH == 2
793 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
794#endif
795 1,
796 {-1, 0, -1, 0},
797 {0, 0, 1, 1}
798 },
799 /* I */
800 {
801#if LCD_DEPTH >= 16
802 {LCD_RGBPACK (255, 153, 128), LCD_RGBPACK (255, 0, 0),
803 LCD_RGBPACK (153, 0, 0)},
804#elif LCD_DEPTH == 2
805 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
806#endif
807 2,
808 {-2, -1, 0, 1},
809 {0, 0, 0, 0}
810 },
811 /* 'Z' */
812 {
813#if LCD_DEPTH >= 16
814 {LCD_RGBPACK (153, 255, 153), LCD_RGBPACK (0, 255, 0),
815 LCD_RGBPACK (0, 153, 0)},
816#elif LCD_DEPTH == 2
817 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
818#endif
819 2,
820 {0, 1, -1, 0},
821 {0, 0, 1, 1}
822 },
823 /* 'S' */
824 {
825#if LCD_DEPTH >= 16
826 {LCD_RGBPACK (153, 153, 255), LCD_RGBPACK (0, 0, 255),
827 LCD_RGBPACK (0, 0, 153)},
828#elif LCD_DEPTH == 2
829 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
830#endif
831 2,
832 {-1, 0, 0, 1},
833 {0, 0, 1, 1}
834 },
835 /* 'L' */
836 {
837#if LCD_DEPTH >= 16
838 {LCD_RGBPACK (255, 255, 153), LCD_RGBPACK (255, 255, 0),
839 LCD_RGBPACK (153, 153, 0)},
840#elif LCD_DEPTH == 2
841 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
842#endif
843 4,
844 {-1, 0, 1, 1},
845 {0, 0, 0, 1}
846 },
847 /* 'J' */
848 {
849#if LCD_DEPTH >= 16
850 {LCD_RGBPACK (255, 153, 255), LCD_RGBPACK (255, 0, 255),
851 LCD_RGBPACK (153, 0, 153)},
852#elif LCD_DEPTH == 2
853 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
854#endif
855 4,
856 {-1, 0, 1, -1},
857 {0, 0, 0, 1}
858 },
859 /* 'T' */
860 {
861#if LCD_DEPTH >= 16
862 {LCD_RGBPACK (204, 204, 204), LCD_RGBPACK (153, 153, 153),
863 LCD_RGBPACK (85, 85, 85)},
864#elif LCD_DEPTH == 2
865 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
866#endif
867 4,
868 {-1, 0, 1, 0},
869 {0, 0, 0, 1}
870 }
871};
Johannes Schwarz88261152009-11-17 06:57:36 +0000872bool resume = false;
873bool resume_file = false;
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000874
Steve Gotthardtd850db12007-01-05 16:32:20 +0000875/* Rockbox File System only supports full filenames inc dir */
Thomas Jaroschf9f89cf2011-03-02 23:43:54 +0000876#define SCORE_FILE PLUGIN_GAMES_DATA_DIR "/rockblox.score"
877#define RESUME_FILE PLUGIN_GAMES_DATA_DIR "/rockblox.resume"
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +0000878#define NUM_SCORES 5
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000879
Steve Gotthardtd850db12007-01-05 16:32:20 +0000880/* Default High Scores... */
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +0000881struct highscore highscores[NUM_SCORES];
Steve Gotthardtd850db12007-01-05 16:32:20 +0000882
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000883/* get random number from (0) to (range-1) */
884static int t_rand (int range)
885{
886 return rb->rand () % range;
887}
888
Thomas Martitz399a0942009-05-16 18:52:00 +0000889static inline void show_game_over (void)
890{
891 rb->splash(HZ,"Game over!");
892}
893
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000894/* init the board array to have no blocks */
895static void init_board (void)
896{
897 int i, j;
898 for (i = 0; i < BOARD_WIDTH; i++)
899 for (j = 0; j < BOARD_HEIGHT; j++)
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000900 rockblox_status.board[j][i] = EMPTY_BLOCK;
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000901}
902
903/* show the score, level and lines */
904static void show_details (void)
905{
Jens Arnold89658652006-10-07 20:00:49 +0000906#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000907#if LCD_DEPTH >= 2
908 rb->lcd_set_foreground (LCD_BLACK);
909 rb->lcd_set_background (LCD_WHITE);
910#endif
Rafaël Carréab9fd182010-08-28 21:46:45 +0000911 rb->lcd_putsxyf (LABEL_X, SCORE_Y, "%d", rockblox_status.score);
912 rb->lcd_putsxyf (LEVEL_X, LEVEL_Y, "%d", rockblox_status.level);
913 rb->lcd_putsxyf (LINES_X, LINES_Y, "%d", rockblox_status.lines);
Jens Arnold89658652006-10-07 20:00:49 +0000914#else /* HAVE_LCD_CHARCELLS */
Rafaël Carréab9fd182010-08-28 21:46:45 +0000915 rb->lcd_putsf (5, 0, "L%d/%d", rockblox_status.level,
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000916 rockblox_status.lines);
Rafaël Carréab9fd182010-08-28 21:46:45 +0000917 rb->lcd_putsf (5, 1, "S%d", rockblox_status.score);
Jens Arnold89658652006-10-07 20:00:49 +0000918#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000919}
920
Greg Whitef7afb1b2007-01-05 18:44:32 +0000921#ifdef HIGH_SCORE_Y
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000922static void show_highscores (void)
923{
Greg Whitef7afb1b2007-01-05 18:44:32 +0000924 int i;
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000925
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +0000926 for (i = 0; i<NUM_SCORES; i++)
Rafaël Carréab9fd182010-08-28 21:46:45 +0000927 rb->lcd_putsxyf (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * i),
928 "%06d" _SPACE "L%1d", highscores[i].score, highscores[i].level);
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000929}
Greg Whitef7afb1b2007-01-05 18:44:32 +0000930#endif
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000931
Johannes Schwarz88261152009-11-17 06:57:36 +0000932static void load_game(void)
Thomas Martitz399a0942009-05-16 18:52:00 +0000933{
934 int fd;
Johannes Schwarz88261152009-11-17 06:57:36 +0000935
936 resume = false;
937
Thomas Martitz399a0942009-05-16 18:52:00 +0000938 fd = rb->open(RESUME_FILE, O_RDONLY);
Johannes Schwarz88261152009-11-17 06:57:36 +0000939 if (fd < 0) return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000940
941 if (rb->read(fd, &rockblox_status, sizeof(struct _rockblox_status))
942 < (ssize_t)sizeof(struct _rockblox_status))
943 {
944 rb->splash(HZ/2, "Loading Rockblox resume info failed");
Johannes Schwarz88261152009-11-17 06:57:36 +0000945 } else {
946 resume = true;
Thomas Martitz399a0942009-05-16 18:52:00 +0000947 }
948
949 rb->close(fd);
950
Johannes Schwarz88261152009-11-17 06:57:36 +0000951 return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000952}
953
Johannes Schwarz88261152009-11-17 06:57:36 +0000954static void dump_resume(void)
Thomas Martitz399a0942009-05-16 18:52:00 +0000955{
956 int fd;
957
Thomas Martitz0a1d7c22010-05-06 17:35:13 +0000958 fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT, 0666);
Thomas Martitz9a2e8c22009-05-16 20:45:00 +0000959 if (fd < 0)
Thomas Martitz399a0942009-05-16 18:52:00 +0000960 goto fail;
961
962 if (rb->write(fd, &rockblox_status, sizeof(struct _rockblox_status))
963 <= 0)
964 {
965 rb->close(fd);
966 goto fail;
967 }
968 rb->close(fd);
Johannes Schwarz88261152009-11-17 06:57:36 +0000969 return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000970
971fail:
972 rb->splash(HZ/2, "Writing Rockblox resume info failed");
Johannes Schwarz88261152009-11-17 06:57:36 +0000973 return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000974}
Johannes Schwarz88261152009-11-17 06:57:36 +0000975
Thomas Martitz399a0942009-05-16 18:52:00 +0000976static void init_rockblox (bool resume)
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000977{
Alexander Levin6a5245a2009-06-30 20:00:46 +0000978 char score_name[50];
979 struct tm* tm;
Johannes Schwarz88261152009-11-17 06:57:36 +0000980
Alexander Levin6a5245a2009-06-30 20:00:46 +0000981 tm = rb->get_time();
982 rb->snprintf(score_name, sizeof(score_name), "%04d%02d%02d %02d%02d%02d",
983 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
984 tm->tm_hour, tm->tm_min, tm->tm_sec);
985
Jens Arnold89658652006-10-07 20:00:49 +0000986#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000987 rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT);
Jens Arnold89658652006-10-07 20:00:49 +0000988#else /* HAVE_LCD_CHARCELLS */
989 pgfx_display (0, 0);
990 pgfx_display_block (3, 0, 3, 1);
991 pgfx_display_block (4, 0, 3, 0);
Jens Arnold8edca8e2010-04-25 06:30:19 +0000992 rb->lcd_puts(4, 1, " ");
Jens Arnold89658652006-10-07 20:00:49 +0000993 pgfx_clear_display();
994 pgfx_fillrect (3, 0, 2, 14);
995 pgfx_fillrect (15, 7, 2, 7);
996 pgfx_update();
997#endif
Johannes Schwarz88261152009-11-17 06:57:36 +0000998 if (!resume)
Thomas Martitz399a0942009-05-16 18:52:00 +0000999 {
1000 rockblox_status.level = 1;
1001 rockblox_status.lines = 0;
1002 rockblox_status.score = 0;
1003 rockblox_status.nf = t_rand(BLOCKS_NUM);
1004 init_board ();
1005 new_block ();
1006 }
1007 draw_next_block();
1008
Greg Whitef7afb1b2007-01-05 18:44:32 +00001009 show_details ();
Jens Arnold17645832007-03-26 08:52:36 +00001010#ifdef HIGH_SCORE_Y
Adam Gashlin8e5a39c2007-11-16 09:29:34 +00001011 show_highscores ();
Steve Gotthardtd850db12007-01-05 16:32:20 +00001012#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001013}
1014
1015static inline int level_speed(int level)
1016{
Jens Arnolddfcbcd12006-10-08 17:27:33 +00001017#if BOARD_HEIGHT == 20
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001018 return (5*HZ) / (level + 9);
Jens Arnolddfcbcd12006-10-08 17:27:33 +00001019#elif BOARD_HEIGHT == 14
1020 return (7*HZ) / (level + 9);
1021#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001022}
1023
1024static int getRelativeX (int figure, int square, int orientation)
1025{
1026 switch (orientation) {
1027 case 0:
1028 return figures[figure].shapeX[square];
1029 case 1:
1030 return figures[figure].shapeY[square];
1031 case 2:
1032 return -figures[figure].shapeX[square];
1033 case 3:
1034 return -figures[figure].shapeY[square];
1035 default:
1036 return 0;
1037 }
1038}
1039
1040static int getRelativeY (int figure, int square, int orientation)
1041{
1042 switch (orientation) {
1043 case 0:
1044 return figures[figure].shapeY[square];
1045 case 1:
1046 return -figures[figure].shapeX[square];
1047 case 2:
1048 return -figures[figure].shapeY[square];
1049 case 3:
1050 return figures[figure].shapeX[square];
1051 default:
1052 return 0;
1053 }
1054}
1055
1056/* redraw the while board on the screen */
1057static void refresh_board (void)
1058{
1059 int i, j, x, y, block;
1060
1061#if LCD_DEPTH >= 2
1062 rb->lcd_set_foreground (LCD_BLACK);
1063#elif LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001064 mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001065#endif
1066
Michael Sevakise63e84a2010-06-04 13:22:50 +00001067 mylcd_fillrect (BOARD_X, BOARD_Y, BOARD_WIDTH * BLOCK_WIDTH,
1068 BOARD_HEIGHT * BLOCK_HEIGHT);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001069
1070#if LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001071 mylcd_set_drawmode (DRMODE_SOLID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001072#endif
1073
1074 for (i = 0; i < BOARD_WIDTH; i++)
1075 for (j = 0; j < BOARD_HEIGHT; j++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001076 block = rockblox_status.board[j][i];
Jens Arnold89658652006-10-07 20:00:49 +00001077 if (block != EMPTY_BLOCK) {
1078#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001079#if LCD_DEPTH >= 2
1080 /* middle drawing */
1081 rb->lcd_set_foreground (figures[block].color[1]);
1082#endif
1083 rb->lcd_fillrect (BOARD_X + i * BLOCK_WIDTH,
1084 BOARD_Y + j * BLOCK_HEIGHT,
1085 BLOCK_WIDTH, BLOCK_HEIGHT);
1086#if LCD_DEPTH >= 2
1087 /* light drawing */
1088 rb->lcd_set_foreground (figures[block].color[0]);
1089#endif
1090 rb->lcd_vline (BOARD_X + i * BLOCK_WIDTH,
1091 BOARD_Y + j * BLOCK_HEIGHT,
1092 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 2);
1093 rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH,
1094 BOARD_X + (i + 1) * BLOCK_WIDTH - 2,
1095 BOARD_Y + j * BLOCK_HEIGHT);
1096#if LCD_DEPTH >= 2
1097 /* shadow drawing */
1098 rb->lcd_set_foreground (figures[block].color[2]);
1099#endif
1100 rb->lcd_vline (BOARD_X + (i + 1) * BLOCK_WIDTH - 1,
1101 BOARD_Y + j * BLOCK_HEIGHT + 1,
1102 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1);
1103 rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH + 1,
1104 BOARD_X + (i + 1) * BLOCK_WIDTH - 1,
1105 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1);
Jens Arnold89658652006-10-07 20:00:49 +00001106#else /* HAVE_LCD_CHARCELLS */
1107 pgfx_drawpixel (BOARD_X + i, BOARD_Y + j);
1108#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001109 }
1110 }
1111
1112 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001113 x = getRelativeX (rockblox_status.cf, i, rockblox_status.co)
1114 + rockblox_status.cx;
1115 y = getRelativeY (rockblox_status.cf, i, rockblox_status.co)
1116 + rockblox_status.cy;
Jens Arnold89658652006-10-07 20:00:49 +00001117#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001118#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001119 /* middle drawing */
1120 rb->lcd_set_foreground (figures[rockblox_status.cf].color[1]);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001121#endif
1122 rb->lcd_fillrect (BOARD_X + x * BLOCK_WIDTH,
1123 BOARD_Y + y * BLOCK_HEIGHT,
1124 BLOCK_WIDTH, BLOCK_HEIGHT);
1125#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001126 /* light drawing */
1127 rb->lcd_set_foreground (figures[rockblox_status.cf].color[0]);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001128#endif
1129 rb->lcd_vline (BOARD_X + x * BLOCK_WIDTH, BOARD_Y + y * BLOCK_HEIGHT,
1130 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 2);
1131 rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH,
1132 BOARD_X + (x + 1) * BLOCK_WIDTH - 2,
1133 BOARD_Y + y * BLOCK_HEIGHT);
1134#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001135 /* shadow drawing */
1136 rb->lcd_set_foreground (figures[rockblox_status.cf].color[2]);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001137#endif
1138 rb->lcd_vline (BOARD_X + (x + 1) * BLOCK_WIDTH - 1,
1139 BOARD_Y + y * BLOCK_HEIGHT + 1,
1140 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1);
1141 rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH + 1,
1142 BOARD_X + (x + 1) * BLOCK_WIDTH - 1,
1143 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1);
Jens Arnold89658652006-10-07 20:00:49 +00001144#else /* HAVE_LCD_CHARCELLS */
1145 pgfx_drawpixel (BOARD_X + x, BOARD_Y + y);
1146#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001147 }
Michael Sevakise63e84a2010-06-04 13:22:50 +00001148 mylcd_update ();
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001149}
1150
1151static bool canMoveTo (int x, int y, int newOrientation)
1152{
1153 int i, rx, ry;
1154 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001155 ry = getRelativeY (rockblox_status.cf, i, newOrientation) + y;
1156 rx = getRelativeX (rockblox_status.cf, i, newOrientation) + x;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001157 if ((rx < 0 || rx >= BOARD_WIDTH) ||
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001158 (ry < 0 || ry >= BOARD_HEIGHT) ||
1159 (rockblox_status.board[ry][rx] != EMPTY_BLOCK))
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001160 return false;
1161 }
1162 return true;
1163}
1164
1165/* draws the preview of next block in the preview window */
1166static void draw_next_block (void)
1167{
1168 int i, rx, ry;
1169 /* clear preview window first */
1170#if LCD_DEPTH >= 2
1171 rb->lcd_set_foreground (LCD_BLACK);
1172#elif LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001173 mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001174#endif
1175
1176 /* 4x4 */
Michael Sevakise63e84a2010-06-04 13:22:50 +00001177 mylcd_fillrect (PREVIEW_X, PREVIEW_Y, BLOCK_WIDTH * 4, BLOCK_HEIGHT * 4);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001178
1179#if LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001180 mylcd_set_drawmode (DRMODE_SOLID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001181#endif
1182
1183 /* draw the lightgray rectangles */
1184#if LCD_DEPTH >= 16
1185 rb->lcd_set_foreground (LCD_RGBPACK (40, 40, 40));
1186#elif LCD_DEPTH == 2
1187 rb->lcd_set_foreground (LCD_DARKGRAY);
1188#endif
1189
1190#if LCD_DEPTH >= 2
1191 for (rx = 0; rx < 4; rx++)
1192 for (ry = 0; ry < 4; ry++)
1193 rb->lcd_drawrect (PREVIEW_X + rx * BLOCK_WIDTH,
1194 PREVIEW_Y + ry * BLOCK_HEIGHT, BLOCK_WIDTH,
1195 BLOCK_HEIGHT);
1196#endif
1197
1198 /* draw the figure */
1199 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001200 rx = getRelativeX (rockblox_status.nf, i, 0) + 2;
1201 ry = getRelativeY (rockblox_status.nf, i, 0) + 2;
Jens Arnold89658652006-10-07 20:00:49 +00001202#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001203#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001204 rb->lcd_set_foreground (figures[rockblox_status.nf].color[1]); /* middle drawing */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001205#endif
1206 rb->lcd_fillrect (PREVIEW_X + rx * BLOCK_WIDTH,
1207 PREVIEW_Y + ry * BLOCK_HEIGHT,
1208 BLOCK_WIDTH, BLOCK_HEIGHT);
1209#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001210 rb->lcd_set_foreground (figures[rockblox_status.nf].color[0]); /* light drawing */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001211#endif
1212 rb->lcd_vline (PREVIEW_X + rx * BLOCK_WIDTH,
1213 PREVIEW_Y + ry * BLOCK_HEIGHT,
1214 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 2);
1215 rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH,
1216 PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 2,
1217 PREVIEW_Y + ry * BLOCK_HEIGHT);
1218#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001219 rb->lcd_set_foreground (figures[rockblox_status.nf].color[2]); /* shadow drawing */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001220#endif
1221 rb->lcd_vline (PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
1222 PREVIEW_Y + ry * BLOCK_HEIGHT + 1,
1223 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
1224 rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH + 1,
1225 PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
1226 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
Jens Arnold89658652006-10-07 20:00:49 +00001227#else /* HAVE_LCD_CHARCELLS */
1228 pgfx_drawpixel (PREVIEW_X + rx, PREVIEW_Y + ry);
1229#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001230 }
1231
1232}
1233
1234/* move the block to a relative location */
1235static void move_block (int x, int y, int o)
1236{
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001237 if (canMoveTo (rockblox_status.cx + x, rockblox_status.cy + y, o)) {
1238 rockblox_status.cy += y;
1239 rockblox_status.cx += x;
1240 rockblox_status.co = o;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001241 }
1242}
1243
1244/* try to add a new block to play with (return true if gameover) */
1245static void new_block (void)
1246{
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001247 rockblox_status.cy = 1;
1248 rockblox_status.cx = 5;
1249 rockblox_status.cf = rockblox_status.nf;
1250 rockblox_status.co = 0; /* start at the same orientation all time */
1251 rockblox_status.nf = t_rand (BLOCKS_NUM);
1252 rockblox_status.gameover = !canMoveTo (rockblox_status.cx,
1253 rockblox_status.cy, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001254
1255 draw_next_block ();
1256}
1257
1258
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001259/* check for filled rockblox_status.lines and do what necessary */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001260static int check_lines (void)
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001261
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001262{
1263 int i, j, y;
1264 int rockblox = 0;
1265
1266 for (j = 0; j < BOARD_HEIGHT; j++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001267 for (i = 0; ((i < BOARD_WIDTH) &&
1268 (rockblox_status.board[j][i] != EMPTY_BLOCK)); i++);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001269 if (i == BOARD_WIDTH) { /* woo hoo, we have a line */
1270 rockblox++;
1271 for (y = j; y > 0; y--)
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001272 {
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001273 for (i = 0; i < BOARD_WIDTH; i++)
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001274 { /* fall line */
1275 rockblox_status.board[y][i] = rockblox_status.board[y - 1][i];
1276 }
1277 }
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001278 }
1279 }
1280
1281 return rockblox;
1282}
1283
1284/* moves down the figure and returns true if gameover */
1285static void move_down (void)
1286{
1287 int l, i, rx, ry;
1288
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001289 if (!canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co)) {
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001290 /* save figure to board */
1291 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001292 rx = getRelativeX (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cx;
1293 ry = getRelativeY (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cy;
1294 rockblox_status.board[ry][rx] = rockblox_status.cf;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001295 }
1296 /* check if formed some lines */
1297 l = check_lines ();
1298 if (l) {
1299 /* the original scoring from "http://en.wikipedia.org/wiki/Rockblox" */
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001300 rockblox_status.score += scoring[l - 1] * rockblox_status.level;
1301 rockblox_status.lines += l;
1302 rockblox_status.level = (int) rockblox_status.lines / 10 + 1;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001303 }
1304
1305 /* show details */
1306 show_details ();
1307
1308 /* generate a new figure */
1309 new_block ();
1310 } else
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001311 move_block (0, 1, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001312}
1313
Johannes Schwarz88261152009-11-17 06:57:36 +00001314static bool rockblox_help(void)
1315{
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001316 static char *help_text[] = {
1317 "Rockblox", "", "Aim", "",
1318 "Make", "the", "falling", "blocks", "of",
1319 "different", "shapes", "form", "full", "rows.",
1320 "Whenever", "a", "row", "is", "completed,",
1321 "it", "will", "be", "cleared", "away",
1322 "and", "you", "gain", "points."
Johannes Schwarz88261152009-11-17 06:57:36 +00001323 };
Johannes Schwarz88261152009-11-17 06:57:36 +00001324 static struct style_text formation[]={
1325 { 0, TEXT_CENTER|TEXT_UNDERLINE },
1326 { 2, C_RED },
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001327 LAST_STYLE_ITEM
Johannes Schwarz88261152009-11-17 06:57:36 +00001328 };
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001329
Johannes Schwarz88261152009-11-17 06:57:36 +00001330#ifdef HAVE_LCD_BITMAP
1331 rb->lcd_setfont(FONT_UI);
1332#endif
1333#ifdef HAVE_LCD_COLOR
1334 rb->lcd_set_background(LCD_BLACK);
1335 rb->lcd_set_foreground(LCD_WHITE);
1336#endif
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001337 if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true))
Johannes Schwarz88261152009-11-17 06:57:36 +00001338 return true;
Johannes Schwarz88261152009-11-17 06:57:36 +00001339#ifdef HAVE_LCD_BITMAP
1340 rb->lcd_setfont(FONT_SYSFIXED);
1341#endif
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001342
Johannes Schwarz88261152009-11-17 06:57:36 +00001343 return false;
1344}
1345
1346static int rockblox_menu_cb(int action, const struct menu_item_ex *this_item)
1347{
1348 int i = ((intptr_t)this_item);
1349 if(action == ACTION_REQUEST_MENUITEM
1350 && !resume && (i==0 || i==5))
1351 return ACTION_EXIT_MENUITEM;
1352 return action;
1353}
1354
1355static int rockblox_menu(void)
1356{
1357 int selected = 0;
1358
1359 MENUITEM_STRINGLIST(main_menu, "Rockblox Menu", rockblox_menu_cb,
1360 "Resume Game", "Start New Game",
1361 "Help", "High Scores", "Playback Control",
1362 "Quit without Saving", "Quit");
1363
1364 rb->button_clear_queue();
1365 while (true) {
1366 switch (rb->do_menu(&main_menu, &selected, NULL, false)) {
1367 case 0:
1368 if(resume_file)
1369 rb->remove(RESUME_FILE);
1370 init_rockblox(true);
1371 return 0;
1372 case 1:
1373 init_rockblox(false);
1374 return 0;
1375 case 2:
1376 if (rockblox_help())
1377 return 1;
1378 break;
1379 case 3:
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001380 highscore_show(-1, highscores, NUM_SCORES, true);
Johannes Schwarz88261152009-11-17 06:57:36 +00001381 break;
1382 case 4:
1383 if (playback_control(NULL))
1384 return 1;
1385 break;
1386 case 5:
1387 return 1;
1388 case 6:
1389 if (resume) {
1390 rb->splash(HZ*1, "Saving game ...");
1391 dump_resume();
1392 }
1393 return 1;
1394 case MENU_ATTACHED_USB:
1395 return 1;
1396 default:
1397 return 1;
1398 break;
1399 }
1400 }
1401}
1402
1403
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001404static int rockblox_loop (void)
1405{
1406 int button;
Andree Buschmann27d153d2011-05-01 14:44:20 +00001407#if defined(ROCKBLOX_OFF_PRE) || defined(ROCKBLOX_DROP_PRE)
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001408 int lastbutton = BUTTON_NONE;
Andree Buschmann27d153d2011-05-01 14:44:20 +00001409#endif
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001410 long next_down_tick = *rb->current_tick + level_speed(rockblox_status.level);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001411
Johannes Schwarz88261152009-11-17 06:57:36 +00001412 if (rockblox_menu()) {
1413 return 1;
1414 }
1415 resume = false;
1416 resume_file = false;
1417
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001418 while (1) {
1419#ifdef HAS_BUTTON_HOLD
1420 if (rb->button_hold ()) {
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +00001421 /* Turn on backlight timeout (revert to settings) */
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001422 backlight_use_settings();
Jens Arnold4d6374c2007-03-16 21:56:08 +00001423 rb->splash(0, "Paused");
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001424 while (rb->button_hold ())
1425 rb->sleep(HZ/10);
1426
Peter D'Hoye767c0ec2007-08-16 23:01:18 +00001427 /* Turn off backlight timeout */
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001428 backlight_ignore_timeout();
Greg Whitec76d3ae2007-01-05 18:00:56 +00001429
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001430 /* get rid of the splash text */
1431 rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT);
1432 show_details ();
Adam Gashlin8e5a39c2007-11-16 09:29:34 +00001433#ifdef HIGH_SCORE_Y
1434 show_highscores ();
1435#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001436 draw_next_block ();
1437 refresh_board ();
1438 }
1439#endif
1440
1441 button = rb->button_get_w_tmo (MAX(next_down_tick - *rb->current_tick, 1));
1442 switch (button) {
1443#ifdef ROCKBLOX_RC_OFF
1444 case ROCKBLOX_RC_OFF:
1445#endif
1446 case ROCKBLOX_OFF:
Marianne Arnoldf7726732009-05-18 21:30:06 +00001447#ifdef ROCKBLOX_OFF_PRE
1448 if (lastbutton != ROCKBLOX_OFF_PRE)
1449 break;
1450#endif
Johannes Schwarz88261152009-11-17 06:57:36 +00001451 resume = true;
1452 return 0;
1453 break;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001454
Steve Gotthardtd850db12007-01-05 16:32:20 +00001455#if defined(ROCKBLOX_ROTATE)
Greg Whitef7afb1b2007-01-05 18:44:32 +00001456 case ROCKBLOX_ROTATE:
Greg Whitec76d3ae2007-01-05 18:00:56 +00001457#endif
Tomer Shalev12332de2010-02-24 20:56:52 +00001458 case ROCKBLOX_ROTATE_CCW:
1459 case ROCKBLOX_ROTATE_CCW | BUTTON_REPEAT:
Thomas Martitz19f3d602009-02-26 20:52:16 +00001460#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001461 /* if the wheel is disabled, add an event to the stack. */
1462 if(wheel_enabled == false)
1463 wheel_events++;
1464
1465 /* if it's enabled, go ahead and rotate.. */
1466 if(wheel_enabled)
1467#endif
Tomer Shalev83d589d2010-02-24 21:16:48 +00001468#ifdef ROCKBLOX_ROTATE_CCW2
1469 /* fallback */
1470 case ROCKBLOX_ROTATE_CCW2:
1471#endif
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001472 move_block (0, 0, (rockblox_status.co + 1) % figures[rockblox_status.cf].max_or);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001473 break;
1474
Tomer Shalev12332de2010-02-24 20:56:52 +00001475 case ROCKBLOX_ROTATE_CW:
1476 case ROCKBLOX_ROTATE_CW | BUTTON_REPEAT:
Thomas Martitz19f3d602009-02-26 20:52:16 +00001477#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001478 if(wheel_enabled == false)
1479 wheel_events++;
1480
1481 if(wheel_enabled)
1482#endif
Tomer Shalev83d589d2010-02-24 21:16:48 +00001483#ifdef ROCKBLOX_ROTATE_CW2
1484 /* fallback */
1485 case ROCKBLOX_ROTATE_CW2:
1486#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001487 move_block (0, 0,
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001488 (rockblox_status.co + figures[rockblox_status.cf].max_or -
1489 1) % figures[rockblox_status.cf].max_or);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001490 break;
1491
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001492 case ROCKBLOX_DOWN:
1493 case ROCKBLOX_DOWN | BUTTON_REPEAT:
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001494 move_block (0, 1, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001495 break;
1496
1497 case ROCKBLOX_RIGHT:
1498 case ROCKBLOX_RIGHT | BUTTON_REPEAT:
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001499 move_block (1, 0, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001500 break;
1501
1502 case ROCKBLOX_LEFT:
1503 case ROCKBLOX_LEFT | BUTTON_REPEAT:
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001504 move_block (-1, 0, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001505 break;
1506
1507 case ROCKBLOX_DROP:
1508#ifdef ROCKBLOX_DROP_PRE
1509 if (lastbutton != ROCKBLOX_DROP_PRE)
1510 break;
1511#endif
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001512 while (canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co))
1513 move_block (0, 1, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001514 break;
1515#ifdef ROCKBLOX_RESTART
1516 case ROCKBLOX_RESTART:
Jens Arnold4d6374c2007-03-16 21:56:08 +00001517 rb->splash (HZ * 1, "Restarting...");
Thomas Martitz399a0942009-05-16 18:52:00 +00001518 init_rockblox (false);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001519 break;
1520#endif
1521
1522 default:
1523 if (rb->default_event_handler (button) == SYS_USB_CONNECTED)
1524 return PLUGIN_USB_CONNECTED;
1525 break;
1526 }
Andree Buschmann27d153d2011-05-01 14:44:20 +00001527#if defined(ROCKBLOX_OFF_PRE) || defined(ROCKBLOX_DROP_PRE)
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001528 if (button != BUTTON_NONE)
1529 lastbutton = button;
Andree Buschmann27d153d2011-05-01 14:44:20 +00001530#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001531
Thomas Martitz19f3d602009-02-26 20:52:16 +00001532#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001533 /* check if we should enable the scroll wheel, if events
1534 * begin to stack up... */
1535 if(wheel_enabled == false)
1536 {
1537 /* stopped rotating the wheel, reset the count */
1538 if(wheel_events == last_wheel_event)
1539 {
1540 last_wheel_event = 0;
1541 wheel_events = 0;
1542 }
1543 /* rotated the wheel a while constantly, enable it. */
1544 else if(wheel_events > 3)
1545 {
1546 wheel_enabled = true;
1547 }
1548
1549 /* this evens out the last event and the "current" event.
1550 * if we get an event next time through button reading, it will
1551 * remain ahead of last_event. if we don't, they'll end up equaling
1552 * each other.. thus, the scroll count will be reset. */
1553 if(wheel_enabled == false && wheel_events > last_wheel_event)
1554 last_wheel_event++;
1555 }
1556#endif
1557
1558 if (TIME_AFTER(*rb->current_tick, next_down_tick)) {
1559 move_down ();
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001560 next_down_tick += level_speed(rockblox_status.level);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001561 if (TIME_AFTER(*rb->current_tick, next_down_tick))
1562 /* restart time "raster" when we had to wait longer than usual
1563 * (pause, game restart etc) */
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001564 next_down_tick = *rb->current_tick + level_speed(rockblox_status.level);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001565 }
1566
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001567 if (rockblox_status.gameover) {
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001568#if LCD_DEPTH >= 2
1569 rb->lcd_set_foreground (LCD_BLACK);
1570#endif
Thomas Martitz399a0942009-05-16 18:52:00 +00001571 show_game_over();
Johannes Schwarz88261152009-11-17 06:57:36 +00001572 resume = false;
1573 return 0;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001574 }
1575
1576 refresh_board ();
1577 }
1578
Johannes Schwarz88261152009-11-17 06:57:36 +00001579 return 0;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001580}
1581
Andrew Mahone23d98122009-01-16 10:34:40 +00001582enum plugin_status plugin_start (const void *parameter)
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001583{
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001584
1585 (void) parameter;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001586
1587 rb->srand (*rb->current_tick);
Greg Whitec76d3ae2007-01-05 18:00:56 +00001588
Steve Gotthardtd850db12007-01-05 16:32:20 +00001589 /* Load HighScore if any */
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001590 highscore_load(SCORE_FILE, highscores, NUM_SCORES);
Steve Gotthardtd850db12007-01-05 16:32:20 +00001591
Karl Kurbjun1a9442c2006-11-15 06:46:35 +00001592#if LCD_DEPTH > 1
Karl Kurbjund6b0c972006-11-15 06:14:27 +00001593 rb->lcd_set_backdrop(NULL);
Karl Kurbjun1a9442c2006-11-15 06:46:35 +00001594#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001595
Jens Arnold89658652006-10-07 20:00:49 +00001596#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001597 rb->lcd_setfont (FONT_SYSFIXED);
Jens Arnold89658652006-10-07 20:00:49 +00001598#else
Andrew Mahone23d98122009-01-16 10:34:40 +00001599 if (!pgfx_init(4, 2))
Jens Arnold89658652006-10-07 20:00:49 +00001600 {
Jens Arnold4d6374c2007-03-16 21:56:08 +00001601 rb->splash(HZ*2, "Old LCD :(");
Jens Arnold89658652006-10-07 20:00:49 +00001602 return PLUGIN_OK;
1603 }
1604#endif
Peter D'Hoye767c0ec2007-08-16 23:01:18 +00001605 /* Turn off backlight timeout */
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001606 backlight_ignore_timeout();
Johannes Schwarz88261152009-11-17 06:57:36 +00001607 load_game();
1608 resume_file = resume;
1609 while(!rockblox_loop()) {
1610 if(!resume) {
Teruaki Kawashimac1bb06c2010-02-22 13:45:24 +00001611 int position = highscore_update(rockblox_status.score,
1612 rockblox_status.level, "",
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001613 highscores, NUM_SCORES);
Johannes Schwarz88261152009-11-17 06:57:36 +00001614 if (position != -1) {
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001615 if (position == 0)
1616 rb->splash(HZ*2, "New High Score");
1617 highscore_show(position, highscores, NUM_SCORES, true);
Johannes Schwarz88261152009-11-17 06:57:36 +00001618 }
1619 }
1620 }
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001621
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001622#ifndef HAVE_LCD_BITMAP
Jens Arnold89658652006-10-07 20:00:49 +00001623 pgfx_release();
1624#endif
Steve Gotthardtd850db12007-01-05 16:32:20 +00001625 /* Save user's HighScore */
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001626 highscore_save(SCORE_FILE, highscores, NUM_SCORES);
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001627 backlight_use_settings();
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001628
Johannes Schwarz88261152009-11-17 06:57:36 +00001629 return PLUGIN_OK;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001630}