blob: 8db4a3497fdbdd09dfa06326fcb497a0538c5b9b [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
Marty Miller84f7f602012-04-21 21:36:42 -0500673#elif (LCD_WIDTH == 96) && (LCD_HEIGHT == 96)
Rafaël Carrébd691ef2011-12-02 20:28:20 +0000674
Marty Miller84f7f602012-04-21 21:36:42 -0500675#define BLOCK_WIDTH 4
676#define BLOCK_HEIGHT 4
677#define BOARD_X 5
678#define BOARD_Y 4
679#define PREVIEW_X 64
680#define PREVIEW_Y 76
Rafaël Carrébd691ef2011-12-02 20:28:20 +0000681#define LABEL_X 59
Marty Miller84f7f602012-04-21 21:36:42 -0500682#define SCORE_Y 15
683#define SCORE_X 58
684#define LEVEL_Y 39
685#define LEVEL_X 58
686#define LINES_Y 62
687#define LINES_X 58
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000688#endif
689
Jens Arnold89658652006-10-07 20:00:49 +0000690#ifndef LEVEL_X
691#define LEVEL_X LABEL_X
692#endif
693
Steve Gotthardtd850db12007-01-05 16:32:20 +0000694#ifndef LINES_X
695#define LINES_X LABEL_X
696#endif
697
Jens Arnold89658652006-10-07 20:00:49 +0000698extern const fb_data rockblox_background[];
699
700#else /* HAVE_LCD_CHARCELLS */
701
702#define BOARD_HEIGHT 14
703
704#define BLOCK_WIDTH 1
705#define BLOCK_HEIGHT 1
706#define BOARD_X 5
707#define BOARD_Y 0
708#define PREVIEW_X 15
709#define PREVIEW_Y 1
710
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000711#endif
712
Thomas Martitz11231152009-05-13 17:45:07 +0000713#ifndef _SPACE
714#define _SPACE " "
715#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000716/* <<Explanation on Rockblox shapes>>
717
718 %%
719 %% - O has 1 orientation
720
721 %% %
722 %% %% - Z has 2 orientations
723 %
724
725 %% %
726 %% %% - S has 2 orientations
727 %
728 %
729 %
730 % %%%% - I has 2 orientations
731 %
732
733 % %%
734 % % % %%% - L has 4 orientations
735 %% %%% % %
736
Michael Giacomelli6d5823f2009-01-04 23:33:15 +0000737 % %%
738 % % % %%% - J has 4 orientations
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000739 %% %%% % %
740
741 % % %%%
742 %% % %% % - T has 4 orientations
743 % %%% %
744 */
745
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000746/* c=current f=figure o=orientation n=next */
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000747static struct _rockblox_status
748{
749 int gameover;
750 int lines;
751 int level;
752 int score;
753 int cx;
754 int cy;
755 int cf;
756 int co;
757 int nf;
758 short board[BOARD_HEIGHT][BOARD_WIDTH]; /* 20 rows of 10 blocks */
759} rockblox_status;
760
761/* prototypes */
762static void draw_next_block(void);
763static void new_block(void);
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000764
Thomas Martitz19f3d602009-02-26 20:52:16 +0000765#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000766int wheel_events = 0, last_wheel_event = 0;
767bool wheel_enabled = false;
768#endif
769
Jens Arnold89658652006-10-07 20:00:49 +0000770static const short scoring[4] = { /* scoring for each number of lines */
771#if BOARD_HEIGHT == 20
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000772 40 /* single */ , 100 /* double */ , 300 /* triple */ , 1200 /* rockblox */
Jens Arnold89658652006-10-07 20:00:49 +0000773#elif BOARD_HEIGHT == 14 /* Player special values */
774 60 /* single */ , 150 /* double */ , 500 /* triple */ , 2000 /* rockblox */
775#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000776};
777
778struct figure
779{
780#if LCD_DEPTH >= 2
781 unsigned short color[3]; /* color of figure (light,middle,shadow) */
782#endif
783 unsigned short max_or; /* max orientations */
784 signed short shapeX[4], shapeY[4]; /* implementation of figures */
785}
786
787/* array of figures */
788figures[BLOCKS_NUM] = {
789 /* O */
790 {
791#if LCD_DEPTH >= 16
792 {LCD_RGBPACK (153, 255, 255), LCD_RGBPACK(0, 255, 255),
793 LCD_RGBPACK(0,153,153)},
794#elif LCD_DEPTH == 2
795 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
796#endif
797 1,
798 {-1, 0, -1, 0},
799 {0, 0, 1, 1}
800 },
801 /* I */
802 {
803#if LCD_DEPTH >= 16
804 {LCD_RGBPACK (255, 153, 128), LCD_RGBPACK (255, 0, 0),
805 LCD_RGBPACK (153, 0, 0)},
806#elif LCD_DEPTH == 2
807 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
808#endif
809 2,
810 {-2, -1, 0, 1},
811 {0, 0, 0, 0}
812 },
813 /* 'Z' */
814 {
815#if LCD_DEPTH >= 16
816 {LCD_RGBPACK (153, 255, 153), LCD_RGBPACK (0, 255, 0),
817 LCD_RGBPACK (0, 153, 0)},
818#elif LCD_DEPTH == 2
819 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
820#endif
821 2,
822 {0, 1, -1, 0},
823 {0, 0, 1, 1}
824 },
825 /* 'S' */
826 {
827#if LCD_DEPTH >= 16
828 {LCD_RGBPACK (153, 153, 255), LCD_RGBPACK (0, 0, 255),
829 LCD_RGBPACK (0, 0, 153)},
830#elif LCD_DEPTH == 2
831 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
832#endif
833 2,
834 {-1, 0, 0, 1},
835 {0, 0, 1, 1}
836 },
837 /* 'L' */
838 {
839#if LCD_DEPTH >= 16
840 {LCD_RGBPACK (255, 255, 153), LCD_RGBPACK (255, 255, 0),
841 LCD_RGBPACK (153, 153, 0)},
842#elif LCD_DEPTH == 2
843 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
844#endif
845 4,
846 {-1, 0, 1, 1},
847 {0, 0, 0, 1}
848 },
849 /* 'J' */
850 {
851#if LCD_DEPTH >= 16
852 {LCD_RGBPACK (255, 153, 255), LCD_RGBPACK (255, 0, 255),
853 LCD_RGBPACK (153, 0, 153)},
854#elif LCD_DEPTH == 2
855 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
856#endif
857 4,
858 {-1, 0, 1, -1},
859 {0, 0, 0, 1}
860 },
861 /* 'T' */
862 {
863#if LCD_DEPTH >= 16
864 {LCD_RGBPACK (204, 204, 204), LCD_RGBPACK (153, 153, 153),
865 LCD_RGBPACK (85, 85, 85)},
866#elif LCD_DEPTH == 2
867 {LCD_WHITE, LCD_LIGHTGRAY, LCD_DARKGRAY},
868#endif
869 4,
870 {-1, 0, 1, 0},
871 {0, 0, 0, 1}
872 }
873};
Johannes Schwarz88261152009-11-17 06:57:36 +0000874bool resume = false;
875bool resume_file = false;
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000876
Steve Gotthardtd850db12007-01-05 16:32:20 +0000877/* Rockbox File System only supports full filenames inc dir */
Thomas Jaroschf9f89cf2011-03-02 23:43:54 +0000878#define SCORE_FILE PLUGIN_GAMES_DATA_DIR "/rockblox.score"
879#define RESUME_FILE PLUGIN_GAMES_DATA_DIR "/rockblox.resume"
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +0000880#define NUM_SCORES 5
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000881
Steve Gotthardtd850db12007-01-05 16:32:20 +0000882/* Default High Scores... */
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +0000883struct highscore highscores[NUM_SCORES];
Steve Gotthardtd850db12007-01-05 16:32:20 +0000884
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000885/* get random number from (0) to (range-1) */
886static int t_rand (int range)
887{
888 return rb->rand () % range;
889}
890
Thomas Martitz399a0942009-05-16 18:52:00 +0000891static inline void show_game_over (void)
892{
893 rb->splash(HZ,"Game over!");
894}
895
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000896/* init the board array to have no blocks */
897static void init_board (void)
898{
899 int i, j;
900 for (i = 0; i < BOARD_WIDTH; i++)
901 for (j = 0; j < BOARD_HEIGHT; j++)
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000902 rockblox_status.board[j][i] = EMPTY_BLOCK;
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000903}
904
905/* show the score, level and lines */
906static void show_details (void)
907{
Jens Arnold89658652006-10-07 20:00:49 +0000908#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000909#if LCD_DEPTH >= 2
910 rb->lcd_set_foreground (LCD_BLACK);
911 rb->lcd_set_background (LCD_WHITE);
912#endif
Rafaël Carréab9fd182010-08-28 21:46:45 +0000913 rb->lcd_putsxyf (LABEL_X, SCORE_Y, "%d", rockblox_status.score);
914 rb->lcd_putsxyf (LEVEL_X, LEVEL_Y, "%d", rockblox_status.level);
915 rb->lcd_putsxyf (LINES_X, LINES_Y, "%d", rockblox_status.lines);
Jens Arnold89658652006-10-07 20:00:49 +0000916#else /* HAVE_LCD_CHARCELLS */
Rafaël Carréab9fd182010-08-28 21:46:45 +0000917 rb->lcd_putsf (5, 0, "L%d/%d", rockblox_status.level,
Thomas Martitz732ef1e2009-05-16 17:12:07 +0000918 rockblox_status.lines);
Rafaël Carréab9fd182010-08-28 21:46:45 +0000919 rb->lcd_putsf (5, 1, "S%d", rockblox_status.score);
Jens Arnold89658652006-10-07 20:00:49 +0000920#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000921}
922
Greg Whitef7afb1b2007-01-05 18:44:32 +0000923#ifdef HIGH_SCORE_Y
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000924static void show_highscores (void)
925{
Greg Whitef7afb1b2007-01-05 18:44:32 +0000926 int i;
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000927
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +0000928 for (i = 0; i<NUM_SCORES; i++)
Rafaël Carréab9fd182010-08-28 21:46:45 +0000929 rb->lcd_putsxyf (HIGH_LABEL_X, HIGH_SCORE_Y + (10 * i),
930 "%06d" _SPACE "L%1d", highscores[i].score, highscores[i].level);
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000931}
Greg Whitef7afb1b2007-01-05 18:44:32 +0000932#endif
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000933
Johannes Schwarz88261152009-11-17 06:57:36 +0000934static void load_game(void)
Thomas Martitz399a0942009-05-16 18:52:00 +0000935{
936 int fd;
Johannes Schwarz88261152009-11-17 06:57:36 +0000937
938 resume = false;
939
Thomas Martitz399a0942009-05-16 18:52:00 +0000940 fd = rb->open(RESUME_FILE, O_RDONLY);
Johannes Schwarz88261152009-11-17 06:57:36 +0000941 if (fd < 0) return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000942
943 if (rb->read(fd, &rockblox_status, sizeof(struct _rockblox_status))
944 < (ssize_t)sizeof(struct _rockblox_status))
945 {
946 rb->splash(HZ/2, "Loading Rockblox resume info failed");
Johannes Schwarz88261152009-11-17 06:57:36 +0000947 } else {
948 resume = true;
Thomas Martitz399a0942009-05-16 18:52:00 +0000949 }
950
951 rb->close(fd);
952
Johannes Schwarz88261152009-11-17 06:57:36 +0000953 return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000954}
955
Johannes Schwarz88261152009-11-17 06:57:36 +0000956static void dump_resume(void)
Thomas Martitz399a0942009-05-16 18:52:00 +0000957{
958 int fd;
959
Thomas Martitz0a1d7c22010-05-06 17:35:13 +0000960 fd = rb->open(RESUME_FILE, O_WRONLY|O_CREAT, 0666);
Thomas Martitz9a2e8c22009-05-16 20:45:00 +0000961 if (fd < 0)
Thomas Martitz399a0942009-05-16 18:52:00 +0000962 goto fail;
963
964 if (rb->write(fd, &rockblox_status, sizeof(struct _rockblox_status))
965 <= 0)
966 {
967 rb->close(fd);
968 goto fail;
969 }
970 rb->close(fd);
Johannes Schwarz88261152009-11-17 06:57:36 +0000971 return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000972
973fail:
974 rb->splash(HZ/2, "Writing Rockblox resume info failed");
Johannes Schwarz88261152009-11-17 06:57:36 +0000975 return;
Thomas Martitz399a0942009-05-16 18:52:00 +0000976}
Johannes Schwarz88261152009-11-17 06:57:36 +0000977
Thomas Martitz399a0942009-05-16 18:52:00 +0000978static void init_rockblox (bool resume)
Adam Gashlin8e5a39c2007-11-16 09:29:34 +0000979{
Alexander Levin6a5245a2009-06-30 20:00:46 +0000980 char score_name[50];
981 struct tm* tm;
Johannes Schwarz88261152009-11-17 06:57:36 +0000982
Alexander Levin6a5245a2009-06-30 20:00:46 +0000983 tm = rb->get_time();
984 rb->snprintf(score_name, sizeof(score_name), "%04d%02d%02d %02d%02d%02d",
985 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
986 tm->tm_hour, tm->tm_min, tm->tm_sec);
987
Jens Arnold89658652006-10-07 20:00:49 +0000988#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +0000989 rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT);
Jens Arnold89658652006-10-07 20:00:49 +0000990#else /* HAVE_LCD_CHARCELLS */
991 pgfx_display (0, 0);
992 pgfx_display_block (3, 0, 3, 1);
993 pgfx_display_block (4, 0, 3, 0);
Jens Arnold8edca8e2010-04-25 06:30:19 +0000994 rb->lcd_puts(4, 1, " ");
Jens Arnold89658652006-10-07 20:00:49 +0000995 pgfx_clear_display();
996 pgfx_fillrect (3, 0, 2, 14);
997 pgfx_fillrect (15, 7, 2, 7);
998 pgfx_update();
999#endif
Johannes Schwarz88261152009-11-17 06:57:36 +00001000 if (!resume)
Thomas Martitz399a0942009-05-16 18:52:00 +00001001 {
1002 rockblox_status.level = 1;
1003 rockblox_status.lines = 0;
1004 rockblox_status.score = 0;
1005 rockblox_status.nf = t_rand(BLOCKS_NUM);
1006 init_board ();
1007 new_block ();
1008 }
1009 draw_next_block();
1010
Greg Whitef7afb1b2007-01-05 18:44:32 +00001011 show_details ();
Jens Arnold17645832007-03-26 08:52:36 +00001012#ifdef HIGH_SCORE_Y
Adam Gashlin8e5a39c2007-11-16 09:29:34 +00001013 show_highscores ();
Steve Gotthardtd850db12007-01-05 16:32:20 +00001014#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001015}
1016
1017static inline int level_speed(int level)
1018{
Jens Arnolddfcbcd12006-10-08 17:27:33 +00001019#if BOARD_HEIGHT == 20
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001020 return (5*HZ) / (level + 9);
Jens Arnolddfcbcd12006-10-08 17:27:33 +00001021#elif BOARD_HEIGHT == 14
1022 return (7*HZ) / (level + 9);
1023#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001024}
1025
1026static int getRelativeX (int figure, int square, int orientation)
1027{
1028 switch (orientation) {
1029 case 0:
1030 return figures[figure].shapeX[square];
1031 case 1:
1032 return figures[figure].shapeY[square];
1033 case 2:
1034 return -figures[figure].shapeX[square];
1035 case 3:
1036 return -figures[figure].shapeY[square];
1037 default:
1038 return 0;
1039 }
1040}
1041
1042static int getRelativeY (int figure, int square, int orientation)
1043{
1044 switch (orientation) {
1045 case 0:
1046 return figures[figure].shapeY[square];
1047 case 1:
1048 return -figures[figure].shapeX[square];
1049 case 2:
1050 return -figures[figure].shapeY[square];
1051 case 3:
1052 return figures[figure].shapeX[square];
1053 default:
1054 return 0;
1055 }
1056}
1057
1058/* redraw the while board on the screen */
1059static void refresh_board (void)
1060{
1061 int i, j, x, y, block;
1062
1063#if LCD_DEPTH >= 2
1064 rb->lcd_set_foreground (LCD_BLACK);
1065#elif LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001066 mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001067#endif
1068
Michael Sevakise63e84a2010-06-04 13:22:50 +00001069 mylcd_fillrect (BOARD_X, BOARD_Y, BOARD_WIDTH * BLOCK_WIDTH,
1070 BOARD_HEIGHT * BLOCK_HEIGHT);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001071
1072#if LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001073 mylcd_set_drawmode (DRMODE_SOLID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001074#endif
1075
1076 for (i = 0; i < BOARD_WIDTH; i++)
1077 for (j = 0; j < BOARD_HEIGHT; j++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001078 block = rockblox_status.board[j][i];
Jens Arnold89658652006-10-07 20:00:49 +00001079 if (block != EMPTY_BLOCK) {
1080#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001081#if LCD_DEPTH >= 2
1082 /* middle drawing */
1083 rb->lcd_set_foreground (figures[block].color[1]);
1084#endif
1085 rb->lcd_fillrect (BOARD_X + i * BLOCK_WIDTH,
1086 BOARD_Y + j * BLOCK_HEIGHT,
1087 BLOCK_WIDTH, BLOCK_HEIGHT);
1088#if LCD_DEPTH >= 2
1089 /* light drawing */
1090 rb->lcd_set_foreground (figures[block].color[0]);
1091#endif
1092 rb->lcd_vline (BOARD_X + i * BLOCK_WIDTH,
1093 BOARD_Y + j * BLOCK_HEIGHT,
1094 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 2);
1095 rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH,
1096 BOARD_X + (i + 1) * BLOCK_WIDTH - 2,
1097 BOARD_Y + j * BLOCK_HEIGHT);
1098#if LCD_DEPTH >= 2
1099 /* shadow drawing */
1100 rb->lcd_set_foreground (figures[block].color[2]);
1101#endif
1102 rb->lcd_vline (BOARD_X + (i + 1) * BLOCK_WIDTH - 1,
1103 BOARD_Y + j * BLOCK_HEIGHT + 1,
1104 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1);
1105 rb->lcd_hline (BOARD_X + i * BLOCK_WIDTH + 1,
1106 BOARD_X + (i + 1) * BLOCK_WIDTH - 1,
1107 BOARD_Y + (j + 1) * BLOCK_HEIGHT - 1);
Jens Arnold89658652006-10-07 20:00:49 +00001108#else /* HAVE_LCD_CHARCELLS */
1109 pgfx_drawpixel (BOARD_X + i, BOARD_Y + j);
1110#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001111 }
1112 }
1113
1114 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001115 x = getRelativeX (rockblox_status.cf, i, rockblox_status.co)
1116 + rockblox_status.cx;
1117 y = getRelativeY (rockblox_status.cf, i, rockblox_status.co)
1118 + rockblox_status.cy;
Jens Arnold89658652006-10-07 20:00:49 +00001119#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001120#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001121 /* middle drawing */
1122 rb->lcd_set_foreground (figures[rockblox_status.cf].color[1]);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001123#endif
1124 rb->lcd_fillrect (BOARD_X + x * BLOCK_WIDTH,
1125 BOARD_Y + y * BLOCK_HEIGHT,
1126 BLOCK_WIDTH, BLOCK_HEIGHT);
1127#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001128 /* light drawing */
1129 rb->lcd_set_foreground (figures[rockblox_status.cf].color[0]);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001130#endif
1131 rb->lcd_vline (BOARD_X + x * BLOCK_WIDTH, BOARD_Y + y * BLOCK_HEIGHT,
1132 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 2);
1133 rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH,
1134 BOARD_X + (x + 1) * BLOCK_WIDTH - 2,
1135 BOARD_Y + y * BLOCK_HEIGHT);
1136#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001137 /* shadow drawing */
1138 rb->lcd_set_foreground (figures[rockblox_status.cf].color[2]);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001139#endif
1140 rb->lcd_vline (BOARD_X + (x + 1) * BLOCK_WIDTH - 1,
1141 BOARD_Y + y * BLOCK_HEIGHT + 1,
1142 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1);
1143 rb->lcd_hline (BOARD_X + x * BLOCK_WIDTH + 1,
1144 BOARD_X + (x + 1) * BLOCK_WIDTH - 1,
1145 BOARD_Y + (y + 1) * BLOCK_HEIGHT - 1);
Jens Arnold89658652006-10-07 20:00:49 +00001146#else /* HAVE_LCD_CHARCELLS */
1147 pgfx_drawpixel (BOARD_X + x, BOARD_Y + y);
1148#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001149 }
Michael Sevakise63e84a2010-06-04 13:22:50 +00001150 mylcd_update ();
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001151}
1152
1153static bool canMoveTo (int x, int y, int newOrientation)
1154{
1155 int i, rx, ry;
1156 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001157 ry = getRelativeY (rockblox_status.cf, i, newOrientation) + y;
1158 rx = getRelativeX (rockblox_status.cf, i, newOrientation) + x;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001159 if ((rx < 0 || rx >= BOARD_WIDTH) ||
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001160 (ry < 0 || ry >= BOARD_HEIGHT) ||
1161 (rockblox_status.board[ry][rx] != EMPTY_BLOCK))
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001162 return false;
1163 }
1164 return true;
1165}
1166
1167/* draws the preview of next block in the preview window */
1168static void draw_next_block (void)
1169{
1170 int i, rx, ry;
1171 /* clear preview window first */
1172#if LCD_DEPTH >= 2
1173 rb->lcd_set_foreground (LCD_BLACK);
1174#elif LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001175 mylcd_set_drawmode (DRMODE_SOLID | DRMODE_INVERSEVID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001176#endif
1177
1178 /* 4x4 */
Michael Sevakise63e84a2010-06-04 13:22:50 +00001179 mylcd_fillrect (PREVIEW_X, PREVIEW_Y, BLOCK_WIDTH * 4, BLOCK_HEIGHT * 4);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001180
1181#if LCD_DEPTH == 1
Michael Sevakise63e84a2010-06-04 13:22:50 +00001182 mylcd_set_drawmode (DRMODE_SOLID);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001183#endif
1184
1185 /* draw the lightgray rectangles */
1186#if LCD_DEPTH >= 16
1187 rb->lcd_set_foreground (LCD_RGBPACK (40, 40, 40));
1188#elif LCD_DEPTH == 2
1189 rb->lcd_set_foreground (LCD_DARKGRAY);
1190#endif
1191
1192#if LCD_DEPTH >= 2
1193 for (rx = 0; rx < 4; rx++)
1194 for (ry = 0; ry < 4; ry++)
1195 rb->lcd_drawrect (PREVIEW_X + rx * BLOCK_WIDTH,
1196 PREVIEW_Y + ry * BLOCK_HEIGHT, BLOCK_WIDTH,
1197 BLOCK_HEIGHT);
1198#endif
1199
1200 /* draw the figure */
1201 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001202 rx = getRelativeX (rockblox_status.nf, i, 0) + 2;
1203 ry = getRelativeY (rockblox_status.nf, i, 0) + 2;
Jens Arnold89658652006-10-07 20:00:49 +00001204#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001205#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001206 rb->lcd_set_foreground (figures[rockblox_status.nf].color[1]); /* middle drawing */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001207#endif
1208 rb->lcd_fillrect (PREVIEW_X + rx * BLOCK_WIDTH,
1209 PREVIEW_Y + ry * BLOCK_HEIGHT,
1210 BLOCK_WIDTH, BLOCK_HEIGHT);
1211#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001212 rb->lcd_set_foreground (figures[rockblox_status.nf].color[0]); /* light drawing */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001213#endif
1214 rb->lcd_vline (PREVIEW_X + rx * BLOCK_WIDTH,
1215 PREVIEW_Y + ry * BLOCK_HEIGHT,
1216 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 2);
1217 rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH,
1218 PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 2,
1219 PREVIEW_Y + ry * BLOCK_HEIGHT);
1220#if LCD_DEPTH >= 2
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001221 rb->lcd_set_foreground (figures[rockblox_status.nf].color[2]); /* shadow drawing */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001222#endif
1223 rb->lcd_vline (PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
1224 PREVIEW_Y + ry * BLOCK_HEIGHT + 1,
1225 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
1226 rb->lcd_hline (PREVIEW_X + rx * BLOCK_WIDTH + 1,
1227 PREVIEW_X + (rx + 1) * BLOCK_WIDTH - 1,
1228 PREVIEW_Y + (ry + 1) * BLOCK_HEIGHT - 1);
Jens Arnold89658652006-10-07 20:00:49 +00001229#else /* HAVE_LCD_CHARCELLS */
1230 pgfx_drawpixel (PREVIEW_X + rx, PREVIEW_Y + ry);
1231#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001232 }
1233
1234}
1235
1236/* move the block to a relative location */
1237static void move_block (int x, int y, int o)
1238{
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001239 if (canMoveTo (rockblox_status.cx + x, rockblox_status.cy + y, o)) {
1240 rockblox_status.cy += y;
1241 rockblox_status.cx += x;
1242 rockblox_status.co = o;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001243 }
1244}
1245
1246/* try to add a new block to play with (return true if gameover) */
1247static void new_block (void)
1248{
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001249 rockblox_status.cy = 1;
1250 rockblox_status.cx = 5;
1251 rockblox_status.cf = rockblox_status.nf;
1252 rockblox_status.co = 0; /* start at the same orientation all time */
1253 rockblox_status.nf = t_rand (BLOCKS_NUM);
1254 rockblox_status.gameover = !canMoveTo (rockblox_status.cx,
1255 rockblox_status.cy, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001256
1257 draw_next_block ();
1258}
1259
1260
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001261/* check for filled rockblox_status.lines and do what necessary */
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001262static int check_lines (void)
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001263
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001264{
1265 int i, j, y;
1266 int rockblox = 0;
1267
1268 for (j = 0; j < BOARD_HEIGHT; j++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001269 for (i = 0; ((i < BOARD_WIDTH) &&
1270 (rockblox_status.board[j][i] != EMPTY_BLOCK)); i++);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001271 if (i == BOARD_WIDTH) { /* woo hoo, we have a line */
1272 rockblox++;
1273 for (y = j; y > 0; y--)
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001274 {
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001275 for (i = 0; i < BOARD_WIDTH; i++)
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001276 { /* fall line */
1277 rockblox_status.board[y][i] = rockblox_status.board[y - 1][i];
1278 }
1279 }
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001280 }
1281 }
1282
1283 return rockblox;
1284}
1285
1286/* moves down the figure and returns true if gameover */
1287static void move_down (void)
1288{
1289 int l, i, rx, ry;
1290
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001291 if (!canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co)) {
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001292 /* save figure to board */
1293 for (i = 0; i < 4; i++) {
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001294 rx = getRelativeX (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cx;
1295 ry = getRelativeY (rockblox_status.cf, i, rockblox_status.co) + rockblox_status.cy;
1296 rockblox_status.board[ry][rx] = rockblox_status.cf;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001297 }
1298 /* check if formed some lines */
1299 l = check_lines ();
1300 if (l) {
1301 /* the original scoring from "http://en.wikipedia.org/wiki/Rockblox" */
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001302 rockblox_status.score += scoring[l - 1] * rockblox_status.level;
1303 rockblox_status.lines += l;
1304 rockblox_status.level = (int) rockblox_status.lines / 10 + 1;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001305 }
1306
1307 /* show details */
1308 show_details ();
1309
1310 /* generate a new figure */
1311 new_block ();
1312 } else
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001313 move_block (0, 1, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001314}
1315
Johannes Schwarz88261152009-11-17 06:57:36 +00001316static bool rockblox_help(void)
1317{
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001318 static char *help_text[] = {
1319 "Rockblox", "", "Aim", "",
1320 "Make", "the", "falling", "blocks", "of",
1321 "different", "shapes", "form", "full", "rows.",
1322 "Whenever", "a", "row", "is", "completed,",
1323 "it", "will", "be", "cleared", "away",
1324 "and", "you", "gain", "points."
Johannes Schwarz88261152009-11-17 06:57:36 +00001325 };
Johannes Schwarz88261152009-11-17 06:57:36 +00001326 static struct style_text formation[]={
1327 { 0, TEXT_CENTER|TEXT_UNDERLINE },
1328 { 2, C_RED },
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001329 LAST_STYLE_ITEM
Johannes Schwarz88261152009-11-17 06:57:36 +00001330 };
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001331
Johannes Schwarz88261152009-11-17 06:57:36 +00001332#ifdef HAVE_LCD_BITMAP
1333 rb->lcd_setfont(FONT_UI);
1334#endif
1335#ifdef HAVE_LCD_COLOR
1336 rb->lcd_set_background(LCD_BLACK);
1337 rb->lcd_set_foreground(LCD_WHITE);
1338#endif
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001339 if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true))
Johannes Schwarz88261152009-11-17 06:57:36 +00001340 return true;
Johannes Schwarz88261152009-11-17 06:57:36 +00001341#ifdef HAVE_LCD_BITMAP
1342 rb->lcd_setfont(FONT_SYSFIXED);
1343#endif
Teruaki Kawashima56d29e82010-02-22 07:17:15 +00001344
Johannes Schwarz88261152009-11-17 06:57:36 +00001345 return false;
1346}
1347
1348static int rockblox_menu_cb(int action, const struct menu_item_ex *this_item)
1349{
1350 int i = ((intptr_t)this_item);
1351 if(action == ACTION_REQUEST_MENUITEM
1352 && !resume && (i==0 || i==5))
1353 return ACTION_EXIT_MENUITEM;
1354 return action;
1355}
1356
1357static int rockblox_menu(void)
1358{
1359 int selected = 0;
1360
1361 MENUITEM_STRINGLIST(main_menu, "Rockblox Menu", rockblox_menu_cb,
1362 "Resume Game", "Start New Game",
1363 "Help", "High Scores", "Playback Control",
1364 "Quit without Saving", "Quit");
1365
1366 rb->button_clear_queue();
1367 while (true) {
1368 switch (rb->do_menu(&main_menu, &selected, NULL, false)) {
1369 case 0:
1370 if(resume_file)
1371 rb->remove(RESUME_FILE);
1372 init_rockblox(true);
1373 return 0;
1374 case 1:
1375 init_rockblox(false);
1376 return 0;
1377 case 2:
1378 if (rockblox_help())
1379 return 1;
1380 break;
1381 case 3:
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001382 highscore_show(-1, highscores, NUM_SCORES, true);
Johannes Schwarz88261152009-11-17 06:57:36 +00001383 break;
1384 case 4:
1385 if (playback_control(NULL))
1386 return 1;
1387 break;
1388 case 5:
1389 return 1;
1390 case 6:
1391 if (resume) {
1392 rb->splash(HZ*1, "Saving game ...");
1393 dump_resume();
1394 }
1395 return 1;
1396 case MENU_ATTACHED_USB:
1397 return 1;
1398 default:
1399 return 1;
1400 break;
1401 }
1402 }
1403}
1404
1405
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001406static int rockblox_loop (void)
1407{
1408 int button;
Andree Buschmann27d153d2011-05-01 14:44:20 +00001409#if defined(ROCKBLOX_OFF_PRE) || defined(ROCKBLOX_DROP_PRE)
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001410 int lastbutton = BUTTON_NONE;
Andree Buschmann27d153d2011-05-01 14:44:20 +00001411#endif
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001412 long next_down_tick = *rb->current_tick + level_speed(rockblox_status.level);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001413
Johannes Schwarz88261152009-11-17 06:57:36 +00001414 if (rockblox_menu()) {
1415 return 1;
1416 }
1417 resume = false;
1418 resume_file = false;
1419
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001420 while (1) {
1421#ifdef HAS_BUTTON_HOLD
1422 if (rb->button_hold ()) {
Peter D'Hoyecb53e3c2007-08-15 12:42:09 +00001423 /* Turn on backlight timeout (revert to settings) */
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001424 backlight_use_settings();
Jens Arnold4d6374c2007-03-16 21:56:08 +00001425 rb->splash(0, "Paused");
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001426 while (rb->button_hold ())
1427 rb->sleep(HZ/10);
1428
Peter D'Hoye767c0ec2007-08-16 23:01:18 +00001429 /* Turn off backlight timeout */
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001430 backlight_ignore_timeout();
Greg Whitec76d3ae2007-01-05 18:00:56 +00001431
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001432 /* get rid of the splash text */
1433 rb->lcd_bitmap (rockblox_background, 0, 0, LCD_WIDTH, LCD_HEIGHT);
1434 show_details ();
Adam Gashlin8e5a39c2007-11-16 09:29:34 +00001435#ifdef HIGH_SCORE_Y
1436 show_highscores ();
1437#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001438 draw_next_block ();
1439 refresh_board ();
1440 }
1441#endif
1442
1443 button = rb->button_get_w_tmo (MAX(next_down_tick - *rb->current_tick, 1));
1444 switch (button) {
1445#ifdef ROCKBLOX_RC_OFF
1446 case ROCKBLOX_RC_OFF:
1447#endif
1448 case ROCKBLOX_OFF:
Marianne Arnoldf7726732009-05-18 21:30:06 +00001449#ifdef ROCKBLOX_OFF_PRE
1450 if (lastbutton != ROCKBLOX_OFF_PRE)
1451 break;
1452#endif
Johannes Schwarz88261152009-11-17 06:57:36 +00001453 resume = true;
1454 return 0;
1455 break;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001456
Steve Gotthardtd850db12007-01-05 16:32:20 +00001457#if defined(ROCKBLOX_ROTATE)
Greg Whitef7afb1b2007-01-05 18:44:32 +00001458 case ROCKBLOX_ROTATE:
Greg Whitec76d3ae2007-01-05 18:00:56 +00001459#endif
Tomer Shalev12332de2010-02-24 20:56:52 +00001460 case ROCKBLOX_ROTATE_CCW:
1461 case ROCKBLOX_ROTATE_CCW | BUTTON_REPEAT:
Thomas Martitz19f3d602009-02-26 20:52:16 +00001462#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001463 /* if the wheel is disabled, add an event to the stack. */
1464 if(wheel_enabled == false)
1465 wheel_events++;
1466
1467 /* if it's enabled, go ahead and rotate.. */
1468 if(wheel_enabled)
1469#endif
Tomer Shalev83d589d2010-02-24 21:16:48 +00001470#ifdef ROCKBLOX_ROTATE_CCW2
1471 /* fallback */
1472 case ROCKBLOX_ROTATE_CCW2:
1473#endif
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001474 move_block (0, 0, (rockblox_status.co + 1) % figures[rockblox_status.cf].max_or);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001475 break;
1476
Tomer Shalev12332de2010-02-24 20:56:52 +00001477 case ROCKBLOX_ROTATE_CW:
1478 case ROCKBLOX_ROTATE_CW | BUTTON_REPEAT:
Thomas Martitz19f3d602009-02-26 20:52:16 +00001479#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001480 if(wheel_enabled == false)
1481 wheel_events++;
1482
1483 if(wheel_enabled)
1484#endif
Tomer Shalev83d589d2010-02-24 21:16:48 +00001485#ifdef ROCKBLOX_ROTATE_CW2
1486 /* fallback */
1487 case ROCKBLOX_ROTATE_CW2:
1488#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001489 move_block (0, 0,
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001490 (rockblox_status.co + figures[rockblox_status.cf].max_or -
1491 1) % figures[rockblox_status.cf].max_or);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001492 break;
1493
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001494 case ROCKBLOX_DOWN:
1495 case ROCKBLOX_DOWN | BUTTON_REPEAT:
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001496 move_block (0, 1, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001497 break;
1498
1499 case ROCKBLOX_RIGHT:
1500 case ROCKBLOX_RIGHT | BUTTON_REPEAT:
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001501 move_block (1, 0, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001502 break;
1503
1504 case ROCKBLOX_LEFT:
1505 case ROCKBLOX_LEFT | BUTTON_REPEAT:
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001506 move_block (-1, 0, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001507 break;
1508
1509 case ROCKBLOX_DROP:
1510#ifdef ROCKBLOX_DROP_PRE
1511 if (lastbutton != ROCKBLOX_DROP_PRE)
1512 break;
1513#endif
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001514 while (canMoveTo (rockblox_status.cx, rockblox_status.cy + 1, rockblox_status.co))
1515 move_block (0, 1, rockblox_status.co);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001516 break;
1517#ifdef ROCKBLOX_RESTART
1518 case ROCKBLOX_RESTART:
Jens Arnold4d6374c2007-03-16 21:56:08 +00001519 rb->splash (HZ * 1, "Restarting...");
Thomas Martitz399a0942009-05-16 18:52:00 +00001520 init_rockblox (false);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001521 break;
1522#endif
1523
1524 default:
1525 if (rb->default_event_handler (button) == SYS_USB_CONNECTED)
1526 return PLUGIN_USB_CONNECTED;
1527 break;
1528 }
Andree Buschmann27d153d2011-05-01 14:44:20 +00001529#if defined(ROCKBLOX_OFF_PRE) || defined(ROCKBLOX_DROP_PRE)
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001530 if (button != BUTTON_NONE)
1531 lastbutton = button;
Andree Buschmann27d153d2011-05-01 14:44:20 +00001532#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001533
Thomas Martitz19f3d602009-02-26 20:52:16 +00001534#ifdef HAVE_SCROLLWHEEL
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001535 /* check if we should enable the scroll wheel, if events
1536 * begin to stack up... */
1537 if(wheel_enabled == false)
1538 {
1539 /* stopped rotating the wheel, reset the count */
1540 if(wheel_events == last_wheel_event)
1541 {
1542 last_wheel_event = 0;
1543 wheel_events = 0;
1544 }
1545 /* rotated the wheel a while constantly, enable it. */
1546 else if(wheel_events > 3)
1547 {
1548 wheel_enabled = true;
1549 }
1550
1551 /* this evens out the last event and the "current" event.
1552 * if we get an event next time through button reading, it will
1553 * remain ahead of last_event. if we don't, they'll end up equaling
1554 * each other.. thus, the scroll count will be reset. */
1555 if(wheel_enabled == false && wheel_events > last_wheel_event)
1556 last_wheel_event++;
1557 }
1558#endif
1559
1560 if (TIME_AFTER(*rb->current_tick, next_down_tick)) {
1561 move_down ();
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001562 next_down_tick += level_speed(rockblox_status.level);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001563 if (TIME_AFTER(*rb->current_tick, next_down_tick))
1564 /* restart time "raster" when we had to wait longer than usual
1565 * (pause, game restart etc) */
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001566 next_down_tick = *rb->current_tick + level_speed(rockblox_status.level);
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001567 }
1568
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001569 if (rockblox_status.gameover) {
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001570#if LCD_DEPTH >= 2
1571 rb->lcd_set_foreground (LCD_BLACK);
1572#endif
Thomas Martitz399a0942009-05-16 18:52:00 +00001573 show_game_over();
Johannes Schwarz88261152009-11-17 06:57:36 +00001574 resume = false;
1575 return 0;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001576 }
1577
1578 refresh_board ();
1579 }
1580
Johannes Schwarz88261152009-11-17 06:57:36 +00001581 return 0;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001582}
1583
Andrew Mahone23d98122009-01-16 10:34:40 +00001584enum plugin_status plugin_start (const void *parameter)
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001585{
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001586
1587 (void) parameter;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001588
1589 rb->srand (*rb->current_tick);
Greg Whitec76d3ae2007-01-05 18:00:56 +00001590
Steve Gotthardtd850db12007-01-05 16:32:20 +00001591 /* Load HighScore if any */
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001592 highscore_load(SCORE_FILE, highscores, NUM_SCORES);
Steve Gotthardtd850db12007-01-05 16:32:20 +00001593
Karl Kurbjun1a9442c2006-11-15 06:46:35 +00001594#if LCD_DEPTH > 1
Karl Kurbjund6b0c972006-11-15 06:14:27 +00001595 rb->lcd_set_backdrop(NULL);
Karl Kurbjun1a9442c2006-11-15 06:46:35 +00001596#endif
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001597
Jens Arnold89658652006-10-07 20:00:49 +00001598#ifdef HAVE_LCD_BITMAP
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001599 rb->lcd_setfont (FONT_SYSFIXED);
Jens Arnold89658652006-10-07 20:00:49 +00001600#else
Andrew Mahone23d98122009-01-16 10:34:40 +00001601 if (!pgfx_init(4, 2))
Jens Arnold89658652006-10-07 20:00:49 +00001602 {
Jens Arnold4d6374c2007-03-16 21:56:08 +00001603 rb->splash(HZ*2, "Old LCD :(");
Jens Arnold89658652006-10-07 20:00:49 +00001604 return PLUGIN_OK;
1605 }
1606#endif
Peter D'Hoye767c0ec2007-08-16 23:01:18 +00001607 /* Turn off backlight timeout */
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001608 backlight_ignore_timeout();
Johannes Schwarz88261152009-11-17 06:57:36 +00001609 load_game();
1610 resume_file = resume;
1611 while(!rockblox_loop()) {
1612 if(!resume) {
Teruaki Kawashimac1bb06c2010-02-22 13:45:24 +00001613 int position = highscore_update(rockblox_status.score,
1614 rockblox_status.level, "",
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001615 highscores, NUM_SCORES);
Johannes Schwarz88261152009-11-17 06:57:36 +00001616 if (position != -1) {
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001617 if (position == 0)
1618 rb->splash(HZ*2, "New High Score");
1619 highscore_show(position, highscores, NUM_SCORES, true);
Johannes Schwarz88261152009-11-17 06:57:36 +00001620 }
1621 }
1622 }
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001623
Thomas Martitz732ef1e2009-05-16 17:12:07 +00001624#ifndef HAVE_LCD_BITMAP
Jens Arnold89658652006-10-07 20:00:49 +00001625 pgfx_release();
1626#endif
Steve Gotthardtd850db12007-01-05 16:32:20 +00001627 /* Save user's HighScore */
Teruaki Kawashima3f8d4a52010-02-27 14:45:37 +00001628 highscore_save(SCORE_FILE, highscores, NUM_SCORES);
Teruaki Kawashima01313d52011-01-24 12:29:16 +00001629 backlight_use_settings();
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001630
Johannes Schwarz88261152009-11-17 06:57:36 +00001631 return PLUGIN_OK;
Björn Stenberg9e7f3612006-09-19 20:48:47 +00001632}