2009-07-08 17:42:37 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008-2009 Rene Peinthor
|
|
|
|
* Contribution from Johannes Schwarz (new menu system, use of highscore lib)
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "lib/highscore.h"
|
|
|
|
#include "lib/playback_control.h"
|
|
|
|
#include "lib/display_text.h"
|
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
|
2011-11-16 14:08:01 +00:00
|
|
|
#if (CONFIG_KEYPAD == SANSA_E200_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SANSA_CONNECT_PAD)
|
2009-07-08 17:42:37 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_SCROLL_FWD
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_SCROLL_BACK
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == SANSA_CLIP_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZE_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_HOME
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_SCROLL_FWD
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_SCROLL_BACK
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == SANSA_C200_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_VOL_UP
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_VOL_DOWN
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
plugins: Improve usability of iPod keymaps
- Reduce need to press multiple buttons at
the same time to quit a plugin
- Have "Menu" be default way to quit plugins or
to access plugin menu
- Fall back to (Long) "Select" or Long "Menu"
in cases where Menu button isn't available
(e.g. in ImageViewer and many games)
out of scope:
boomshine, lua_scripts, Rockpaint,
Doom, Duke3D, Pacbox, Quake,
Sgt-Puzzles, Wolf3D, XWorld,
Minesweeper, Pixel Painter, Spacerocks
Change-Id: I6d4dc7174695fe4b8ee9cbaccb21bdbfe6af5c48
2022-12-18 20:13:15 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_MENU
|
2009-07-18 12:33:13 +00:00
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_SCROLL_FWD
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_SCROLL_BACK
|
2009-07-18 21:08:38 +00:00
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
2009-07-18 12:33:13 +00:00
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
|
2009-07-08 17:42:37 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_BACK
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_SCROLL_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_SCROLL_DOWN
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2009-07-08 18:10:14 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H300_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_OFF
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_BACK
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2014-03-21 21:16:02 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI3_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_BACK
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_MENU
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PHILIPS_HDD1630_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2010-11-02 03:29:16 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PHILIPS_HDD6330_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2009-12-02 01:56:39 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PHILIPS_SA9200_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2009-07-08 17:42:37 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
|
2009-07-13 12:16:06 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_MENU
|
2012-01-29 23:51:43 +00:00
|
|
|
|
2009-08-31 21:11:32 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX777_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
2009-07-13 12:16:06 +00:00
|
|
|
|
2012-01-29 23:51:43 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ANDROID_PAD) \
|
|
|
|
|| (CONFIG_KEYPAD == SDL_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_BACK
|
|
|
|
|
2009-07-13 12:16:06 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MROBE500_PAD)
|
2009-07-08 17:42:37 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
|
2014-05-22 21:34:52 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SAMSUNG_YH820_PAD) || \
|
2016-01-23 14:54:08 +00:00
|
|
|
(CONFIG_KEYPAD == SAMSUNG_YH92X_PAD)
|
2015-07-19 23:50:26 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_REW
|
2009-08-04 03:08:32 +00:00
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_REC
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_PLAY
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_MENU
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_OK
|
|
|
|
|
2011-10-02 17:34:07 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
2012-03-01 22:23:29 +00:00
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_BOTTOMRIGHT
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_BOTTOMLEFT
|
2011-10-02 17:34:07 +00:00
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
2012-03-23 18:32:50 +00:00
|
|
|
#elif (CONFIG_KEYPAD == HM60X_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD (BUTTON_POWER | BUTTON_UP)
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK (BUTTON_POWER | BUTTON_DOWN)
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
2012-04-06 16:17:27 +00:00
|
|
|
#elif (CONFIG_KEYPAD == HM801_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_NEXT
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
2014-06-30 18:24:15 +00:00
|
|
|
#elif CONFIG_KEYPAD == SONY_NWZ_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_BACK
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD (BUTTON_POWER|BUTTON_RIGHT)
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK (BUTTON_POWER|BUTTON_LEFT)
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
|
2014-07-17 08:40:17 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZEN_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_BACK
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_PLAYPAUSE
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_MENU
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
2013-09-10 20:48:34 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SAMSUNG_YPR1_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
|
2014-08-30 11:15:53 +00:00
|
|
|
#elif (CONFIG_KEYPAD == DX50_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
|
2018-02-22 22:42:29 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVE_ZENXFI2_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_TOPMIDDLE
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_BOTTOMMIDDLE
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD BUTTON_TOPRIGHT
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK BUTTON_TOPLEFT
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_MIDLEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_MIDRIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_CENTER
|
|
|
|
|
2018-03-02 20:53:55 +00:00
|
|
|
#elif (CONFIG_KEYPAD == AGPTEK_ROCKER_PAD)
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_SCROLL_FWD (BUTTON_VOLUP)
|
|
|
|
#define CLIX_BUTTON_SCROLL_BACK (BUTTON_VOLDOWN)
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
2018-06-28 10:24:26 +00:00
|
|
|
#elif CONFIG_KEYPAD == XDUOO_X3_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_HOME
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_OPTION
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
|
2018-11-05 12:01:55 +00:00
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == XDUOO_X3II_PAD || CONFIG_KEYPAD == XDUOO_X20_PAD
|
2018-11-05 12:01:55 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_HOME
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_OPTION
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
|
2018-06-28 10:24:26 +00:00
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
|
2021-02-27 22:07:37 +00:00
|
|
|
#elif CONFIG_KEYPAD == FIIO_M3K_LINUX_PAD
|
2020-10-03 22:17:11 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_HOME
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_OPTION
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_NEXT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == IHIFI_770_PAD || CONFIG_KEYPAD == IHIFI_800_PAD
|
2018-06-29 20:09:28 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_NEXT
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_HOME
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_VOL_DOWN
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_VOL_UP
|
|
|
|
|
2020-10-08 13:47:40 +00:00
|
|
|
#elif CONFIG_KEYPAD == EROSQ_PAD
|
2018-06-29 20:09:28 +00:00
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_PREV
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_NEXT
|
2020-10-08 13:47:40 +00:00
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_SCROLL_BACK
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_SCROLL_FWD
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_PLAY
|
2018-06-29 20:09:28 +00:00
|
|
|
|
2021-02-27 22:08:58 +00:00
|
|
|
#elif CONFIG_KEYPAD == FIIO_M3K_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
#define CLIX_BUTTON_UP BUTTON_UP
|
|
|
|
#define CLIX_BUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define CLIX_BUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define CLIX_BUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_SELECT
|
|
|
|
|
2021-05-23 16:30:58 +00:00
|
|
|
#elif CONFIG_KEYPAD == SHANLING_Q1_PAD
|
|
|
|
#define CLIX_BUTTON_QUIT BUTTON_POWER
|
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
#else
|
|
|
|
#error "no keymap"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CLIX_BUTTON_CLICK
|
2009-07-11 14:06:00 +00:00
|
|
|
#define CLIX_BUTTON_CLICK BUTTON_CENTER
|
2009-07-08 17:42:37 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-02 23:43:54 +00:00
|
|
|
#define SCORE_FILE PLUGIN_GAMES_DATA_DIR "/clix.score"
|
2009-07-08 17:42:37 +00:00
|
|
|
#define NUM_SCORES 5
|
2010-02-27 14:01:28 +00:00
|
|
|
struct highscore highscores[NUM_SCORES];
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
#define NUM_LEVELS 9
|
|
|
|
#define BLINK_TICKCOUNT 25
|
|
|
|
#define MARGIN 5
|
|
|
|
|
|
|
|
#if (LCD_WIDTH >= LCD_HEIGHT)
|
|
|
|
#define BOARD_WIDTH 18
|
|
|
|
#define BOARD_HEIGHT 12
|
|
|
|
#else
|
|
|
|
#define BOARD_WIDTH 12
|
|
|
|
#define BOARD_HEIGHT 18
|
|
|
|
#endif
|
|
|
|
|
2009-07-18 04:38:33 +00:00
|
|
|
#if (LCD_WIDTH>=480)
|
|
|
|
#if (LCD_WIDTH/BOARD_WIDTH) > (LCD_HEIGHT/BOARD_HEIGHT)
|
|
|
|
#define CELL_SIZE (LCD_HEIGHT/BOARD_HEIGHT)
|
2010-02-27 14:01:28 +00:00
|
|
|
#else
|
2009-07-18 04:38:33 +00:00
|
|
|
#define CELL_SIZE (LCD_WIDTH/BOARD_WIDTH)
|
|
|
|
#endif
|
|
|
|
|
2012-01-29 23:51:43 +00:00
|
|
|
#elif (LCD_WIDTH >= 312 && LCD_HEIGHT >= 468)
|
|
|
|
#define CELL_SIZE 24
|
|
|
|
|
2009-07-18 04:38:33 +00:00
|
|
|
#elif (LCD_WIDTH >= 306 && LCD_HEIGHT>= 204)
|
2009-07-08 17:42:37 +00:00
|
|
|
#define CELL_SIZE 16
|
|
|
|
|
|
|
|
#elif (LCD_WIDTH >= 270 && LCD_HEIGHT>= 180)
|
|
|
|
#define CELL_SIZE 14
|
|
|
|
|
|
|
|
#elif (LCD_WIDTH >= 234 && LCD_HEIGHT>= 156)
|
|
|
|
#define CELL_SIZE 12
|
|
|
|
|
|
|
|
#elif (LCD_WIDTH >= 198 && LCD_HEIGHT>= 132)
|
|
|
|
#define CELL_SIZE 10
|
|
|
|
|
|
|
|
#elif (LCD_WIDTH >= 162 && LCD_HEIGHT>= 108)
|
|
|
|
#define CELL_SIZE 8
|
|
|
|
|
|
|
|
#elif (LCD_WIDTH >= 126 && LCD_HEIGHT>= 84)
|
|
|
|
#define CELL_SIZE 6
|
|
|
|
|
|
|
|
#elif (LCD_WIDTH >= 60)
|
|
|
|
#define CELL_SIZE 4
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define XYPOS(x,y) ((y) * BOARD_WIDTH + x)
|
|
|
|
#define XOFS LCD_WIDTH/2-(BOARD_WIDTH * (CELL_SIZE + 1)/2)
|
|
|
|
#define YOFS (LCD_HEIGHT+10)/2-(BOARD_HEIGHT * (CELL_SIZE + 1)/2)
|
|
|
|
|
|
|
|
|
|
|
|
struct clix_game_state_t {
|
2009-07-11 14:06:00 +00:00
|
|
|
int level; /* current level */
|
|
|
|
int score; /* current game score */
|
|
|
|
int x,y; /* current positions of the cursor */
|
2009-07-08 18:10:14 +00:00
|
|
|
int board[BOARD_WIDTH * BOARD_HEIGHT]; /* play board*/
|
2009-07-08 17:42:37 +00:00
|
|
|
/* state of selected fields,maybe we can store this in the play board too */
|
|
|
|
bool board_selected[ BOARD_WIDTH * BOARD_HEIGHT];
|
2009-07-11 14:06:00 +00:00
|
|
|
int selected_count;
|
|
|
|
int status;
|
2009-07-08 17:42:37 +00:00
|
|
|
bool blink; /* true if selected CELLS are currently white */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* game state enum */
|
|
|
|
enum {
|
|
|
|
CLIX_GAMEOVER = -1,
|
|
|
|
CLIX_CONTINUE,
|
|
|
|
CLIX_CLEARED
|
|
|
|
};
|
|
|
|
|
|
|
|
/* cell color enum */
|
|
|
|
enum {
|
|
|
|
CC_BLACK = -1,
|
|
|
|
CC_BLUE,
|
|
|
|
CC_GREEN,
|
|
|
|
CC_RED,
|
|
|
|
CC_YELLOW,
|
|
|
|
CC_ORANGE,
|
|
|
|
CC_CYAN,
|
|
|
|
CC_BROWN,
|
|
|
|
CC_PINK,
|
|
|
|
CC_DARK_BLUE,
|
|
|
|
CC_DARK_GREEN
|
|
|
|
};
|
|
|
|
|
2009-07-11 14:06:00 +00:00
|
|
|
/* recursive function to check if a neighbour cell is of the same color
|
2009-07-08 17:42:37 +00:00
|
|
|
if so call the function with the neighbours position
|
|
|
|
*/
|
|
|
|
static void clix_set_selected(struct clix_game_state_t* state,
|
|
|
|
const int x, const int y)
|
|
|
|
{
|
|
|
|
state->selected_count++;
|
|
|
|
state->board_selected[ XYPOS( x, y)] = true;
|
|
|
|
int current_color = state->board[ XYPOS( x, y)];
|
|
|
|
|
|
|
|
if( (x - 1) >= 0 &&
|
|
|
|
state->board[ XYPOS( x - 1, y)] == current_color &&
|
|
|
|
state->board_selected[ XYPOS(x - 1, y)] == false)
|
|
|
|
clix_set_selected( state, x - 1, y);
|
|
|
|
|
|
|
|
if( (y + 1) < BOARD_HEIGHT &&
|
|
|
|
state->board[ XYPOS( x, y + 1)] == current_color &&
|
|
|
|
state->board_selected[ XYPOS(x, y + 1)] == false)
|
|
|
|
clix_set_selected( state, x, y + 1);
|
|
|
|
|
|
|
|
if( (x + 1) < BOARD_WIDTH &&
|
|
|
|
state->board[ XYPOS( x + 1, y)] == current_color &&
|
|
|
|
state->board_selected[ XYPOS(x + 1, y)] == false)
|
|
|
|
clix_set_selected( state, x + 1, y);
|
|
|
|
|
|
|
|
if( (y - 1) >= 0 &&
|
|
|
|
state->board[ XYPOS( x, y - 1)] == current_color &&
|
|
|
|
state->board_selected[ XYPOS(x, y - 1)] == false)
|
|
|
|
clix_set_selected( state, x, y - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* updates "blinking" cells by finding out which one is a valid neighbours */
|
|
|
|
static void clix_update_selected(struct clix_game_state_t* state)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for( i = 0; i < BOARD_WIDTH * BOARD_HEIGHT; ++i)
|
|
|
|
{
|
|
|
|
state->board_selected[i] = false;
|
|
|
|
}
|
|
|
|
state->selected_count = 0;
|
|
|
|
|
|
|
|
/* recursion starts here */
|
|
|
|
clix_set_selected( state, state->x, state->y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* inits the board with new random colors according to the level */
|
|
|
|
static void clix_init_new_level(struct clix_game_state_t* state)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int r;
|
|
|
|
|
|
|
|
state->y = BOARD_HEIGHT / 2;
|
|
|
|
state->x = BOARD_WIDTH / 2;
|
2010-02-27 14:01:28 +00:00
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
rb->srand( *rb->current_tick);
|
|
|
|
/* create a random colored board, according to the current level */
|
|
|
|
for(i = 0; i < BOARD_HEIGHT * BOARD_WIDTH; ++i)
|
|
|
|
{
|
|
|
|
r = rb->rand() % (state->level + 1);
|
|
|
|
state->board[i] = r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this inits the game state structure */
|
|
|
|
static void clix_init(struct clix_game_state_t* state)
|
|
|
|
{
|
|
|
|
state->level = 1;
|
|
|
|
state->score = 0;
|
|
|
|
state->blink = false;
|
|
|
|
state->status = CLIX_CONTINUE;
|
|
|
|
|
|
|
|
clix_init_new_level(state);
|
|
|
|
|
|
|
|
clix_update_selected(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Function for drawing a cell */
|
|
|
|
static void clix_draw_cell(struct clix_game_state_t* state, const int x, const int y)
|
|
|
|
{
|
|
|
|
int realx = XOFS;
|
|
|
|
int realy = YOFS;
|
|
|
|
|
|
|
|
realx += x * (CELL_SIZE + 1);
|
|
|
|
realy += y * (CELL_SIZE + 1);
|
|
|
|
|
|
|
|
if (state->blink && state->board_selected[ XYPOS( x, y)]) {
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
} else {
|
|
|
|
switch (state->board[ XYPOS( x, y)])
|
|
|
|
{
|
|
|
|
case CC_BLUE:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 25, 25, 255));
|
|
|
|
break;
|
|
|
|
case CC_GREEN:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 25, 255, 25));
|
|
|
|
break;
|
|
|
|
case CC_RED:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 255, 25, 25));
|
|
|
|
break;
|
|
|
|
case CC_YELLOW:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 225, 225, 25));
|
|
|
|
break;
|
|
|
|
case CC_ORANGE:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 230, 140, 15));
|
|
|
|
break;
|
|
|
|
case CC_CYAN:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 25, 245, 230));
|
|
|
|
break;
|
|
|
|
case CC_BROWN:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK(139, 69, 19));
|
|
|
|
break;
|
|
|
|
case CC_PINK:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK(255, 105, 180));
|
|
|
|
break;
|
|
|
|
case CC_DARK_GREEN:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 0, 100, 0));
|
|
|
|
break;
|
|
|
|
case CC_DARK_BLUE:
|
|
|
|
rb->lcd_set_foreground( LCD_RGBPACK( 280, 32, 144));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb->lcd_set_foreground( LCD_BLACK);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rb->lcd_fillrect( realx, realy, CELL_SIZE, CELL_SIZE);
|
|
|
|
|
|
|
|
/* draw cursor */
|
|
|
|
if ( x == state->x && y == state->y) {
|
|
|
|
rb->lcd_set_foreground( LCD_WHITE);
|
|
|
|
rb->lcd_drawrect( realx - 1, realy - 1, CELL_SIZE + 2, CELL_SIZE + 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* main function of drawing the whole board and score... */
|
|
|
|
static void clix_draw(struct clix_game_state_t* state)
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
/* Clear screen */
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
rb->lcd_set_foreground( LCD_WHITE);
|
2010-02-27 14:01:28 +00:00
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
rb->lcd_putsxy( MARGIN, MARGIN, "Score:");
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf( 43, MARGIN, "%d", state->score);
|
2009-07-08 17:42:37 +00:00
|
|
|
#if LCD_WIDTH <= 100
|
|
|
|
rb->lcd_putsxy( 75, MARGIN, "L:");
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf( 90, MARGIN, "%d", state->level);
|
2009-07-08 17:42:37 +00:00
|
|
|
#else
|
|
|
|
rb->lcd_putsxy( 75, MARGIN, "Level:");
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf( 113, MARGIN, "%d", state->level);
|
2009-07-08 17:42:37 +00:00
|
|
|
#endif
|
|
|
|
for( i = 0; i < BOARD_WIDTH; ++i)
|
|
|
|
{
|
|
|
|
for( j = 0; j < BOARD_HEIGHT; ++j)
|
|
|
|
{
|
|
|
|
clix_draw_cell( state, i, j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rb->lcd_update();
|
2010-02-22 07:17:15 +00:00
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
2009-07-08 17:42:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void clix_move_cursor(struct clix_game_state_t* state, const bool left)
|
|
|
|
{
|
2009-07-11 14:06:00 +00:00
|
|
|
int x, y;
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
x = state->x;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
y = state->y;
|
|
|
|
while(state->board[ XYPOS( x, y)] == CC_BLACK && y < BOARD_HEIGHT) y++;
|
|
|
|
if (y < BOARD_HEIGHT) {
|
|
|
|
state->y = y;
|
|
|
|
state->x = x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (left) {
|
|
|
|
if( x >= 0)
|
|
|
|
x--;
|
|
|
|
else
|
|
|
|
y = state->y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if( x < BOARD_WIDTH - 1)
|
|
|
|
x++;
|
|
|
|
else
|
|
|
|
x = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while ( y != state->y);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* returns the color of the given position, if out of bounds return CC_BLACK */
|
|
|
|
static int clix_get_color(struct clix_game_state_t* state, const int x, const int y)
|
|
|
|
{
|
|
|
|
if( x >= 0 && x < BOARD_WIDTH && y >= 0 && y < BOARD_HEIGHT)
|
|
|
|
return state->board[XYPOS( x, y)];
|
|
|
|
else
|
|
|
|
return CC_BLACK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clix_clear_selected(struct clix_game_state_t* state)
|
|
|
|
{
|
|
|
|
int i, j, x, y;
|
2010-02-27 14:01:28 +00:00
|
|
|
bool found_move;
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
state->status = CLIX_CLEARED;
|
|
|
|
|
|
|
|
/* clear the selected blocks */
|
|
|
|
for( i = 0; i < BOARD_WIDTH; ++i)
|
|
|
|
{
|
|
|
|
for( j = 0; j < BOARD_HEIGHT; ++j)
|
|
|
|
{
|
|
|
|
if( state->board_selected[ XYPOS( i, j)] )
|
|
|
|
{
|
|
|
|
state->board_selected[ XYPOS( i, j)] = false;
|
|
|
|
state->board[ XYPOS( i, j)] = CC_BLACK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-11 14:06:00 +00:00
|
|
|
/* count score */
|
|
|
|
state->score += state->selected_count * state->level;
|
|
|
|
state->selected_count = 0;
|
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
/* let blocks falling down */
|
|
|
|
for( i = BOARD_WIDTH - 1; i >= 0; --i)
|
|
|
|
{
|
|
|
|
for( j = BOARD_HEIGHT - 1; j >= 0; --j)
|
|
|
|
{
|
|
|
|
y = j;
|
2009-07-11 14:06:00 +00:00
|
|
|
while( (y + 1) < BOARD_HEIGHT &&
|
|
|
|
state->board[ XYPOS( i, y + 1)] == CC_BLACK
|
2009-07-08 17:42:37 +00:00
|
|
|
)
|
|
|
|
y++;
|
|
|
|
|
|
|
|
if (y != j) {
|
2009-07-11 14:06:00 +00:00
|
|
|
state->board[ XYPOS( i, y)] = state->board[ XYPOS( i, j)];
|
2009-07-08 17:42:37 +00:00
|
|
|
state->board[ XYPOS( i, j)] = CC_BLACK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-11 14:06:00 +00:00
|
|
|
/* move columns to left side */
|
|
|
|
for( i = 0; i < BOARD_WIDTH; ++i)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2009-07-11 14:06:00 +00:00
|
|
|
x = i;
|
|
|
|
while( (x - 1) >= 0 &&
|
|
|
|
state->board[ XYPOS( x - 1, BOARD_HEIGHT - 1)] == CC_BLACK
|
|
|
|
)
|
|
|
|
x--;
|
|
|
|
if (x != i)
|
|
|
|
{
|
|
|
|
for( j = 0; j < BOARD_HEIGHT; ++j)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2009-07-11 14:06:00 +00:00
|
|
|
state->board[ XYPOS( x, j)] = state->board[ XYPOS( i, j)];
|
|
|
|
state->board[ XYPOS( i, j)] = CC_BLACK;
|
2009-07-08 17:42:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-11 14:06:00 +00:00
|
|
|
if(state->board[ XYPOS( 0, BOARD_HEIGHT - 1)] != CC_BLACK)
|
|
|
|
state->status = CLIX_CONTINUE;
|
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
if (state->status != CLIX_CLEARED) {
|
|
|
|
/* check if a move is still possible, otherwise the game is over.
|
|
|
|
tart from the left bottom, because there are the last fields
|
|
|
|
at the end of the game.
|
|
|
|
*/
|
2010-02-27 14:01:28 +00:00
|
|
|
found_move = false;
|
|
|
|
for( i = 0; !found_move && i < BOARD_WIDTH; ++i)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2010-02-27 14:01:28 +00:00
|
|
|
for( j = BOARD_HEIGHT - 1; !found_move && j >= 0; --j)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2009-07-11 14:06:00 +00:00
|
|
|
int color = state->board[ XYPOS( i, j)];
|
|
|
|
if (color != CC_BLACK) {
|
|
|
|
if (color == clix_get_color( state, i - 1, j) ||
|
|
|
|
color == clix_get_color( state, i + 1, j) ||
|
|
|
|
color == clix_get_color( state, i, j - 1) ||
|
|
|
|
color == clix_get_color( state, i, j + 1)
|
2009-07-08 17:42:37 +00:00
|
|
|
)
|
|
|
|
{
|
2010-02-27 14:01:28 +00:00
|
|
|
found_move = true;
|
2009-07-08 17:42:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* if the loops ended without a possible move, the game is over */
|
2010-02-27 14:01:28 +00:00
|
|
|
if( !found_move)
|
2009-07-08 17:42:37 +00:00
|
|
|
state->status = CLIX_GAMEOVER;
|
|
|
|
|
|
|
|
/* set cursor to the right position */
|
|
|
|
if (state->status == CLIX_CONTINUE) {
|
|
|
|
clix_move_cursor( state, true);
|
|
|
|
clix_update_selected( state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state->status;
|
|
|
|
}
|
|
|
|
|
2009-07-14 13:03:17 +00:00
|
|
|
static bool clix_help(void)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2009-07-11 14:06:00 +00:00
|
|
|
static char *help_text[] = {
|
2009-07-14 13:03:17 +00:00
|
|
|
"Clix", "", "Aim", "",
|
|
|
|
"Remove", "all", "blocks", "from", "the", "board", "to", "achieve",
|
|
|
|
"the", "next", "level.", "You", "can", "only", "remove", "blocks,",
|
|
|
|
"if", "at", "least", "two", "blocks", "with", "the", "same", "color",
|
|
|
|
"have", "a", "direct", "connection.", "The", "more", "blocks", "you",
|
|
|
|
"remove", "per", "turn,", "the", "more", "points", "you", "get."
|
2009-07-08 17:42:37 +00:00
|
|
|
};
|
|
|
|
static struct style_text formation[]={
|
|
|
|
{ 0, TEXT_CENTER|TEXT_UNDERLINE },
|
2009-07-14 13:03:17 +00:00
|
|
|
{ 2, C_RED },
|
2010-02-22 07:17:15 +00:00
|
|
|
LAST_STYLE_ITEM
|
2009-07-08 17:42:37 +00:00
|
|
|
};
|
2010-02-22 07:17:15 +00:00
|
|
|
|
2009-07-14 13:03:17 +00:00
|
|
|
rb->lcd_setfont(FONT_UI);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
2010-02-22 07:17:15 +00:00
|
|
|
if (display_text(ARRAYLEN(help_text), help_text, formation, NULL, true))
|
2009-07-14 13:03:17 +00:00
|
|
|
return true;
|
2009-07-08 17:42:37 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2010-02-22 07:17:15 +00:00
|
|
|
|
|
|
|
return false;
|
2009-07-08 17:42:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static bool _ingame;
|
2020-07-19 17:42:04 +00:00
|
|
|
static int clix_menu_cb(int action,
|
|
|
|
const struct menu_item_ex *this_item,
|
|
|
|
struct gui_synclist *this_list)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2020-07-19 17:42:04 +00:00
|
|
|
(void)this_list;
|
2009-07-08 17:42:37 +00:00
|
|
|
if(action == ACTION_REQUEST_MENUITEM
|
|
|
|
&& !_ingame && ((intptr_t)this_item)==0)
|
|
|
|
return ACTION_EXIT_MENUITEM;
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int clix_menu(struct clix_game_state_t* state, bool ingame)
|
|
|
|
{
|
|
|
|
rb->button_clear_queue();
|
|
|
|
int choice = 0;
|
2009-08-03 02:56:55 +00:00
|
|
|
bool leave_menu=false;
|
|
|
|
int ret=0;
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
_ingame = ingame;
|
2010-02-27 14:01:28 +00:00
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
MENUITEM_STRINGLIST (main_menu, "Clix Menu", clix_menu_cb,
|
|
|
|
"Resume Game",
|
|
|
|
"Start New Game",
|
|
|
|
"Help",
|
2009-08-03 16:30:08 +00:00
|
|
|
"High Scores",
|
2009-07-08 17:42:37 +00:00
|
|
|
"Playback Control",
|
|
|
|
"Quit");
|
|
|
|
|
2009-08-03 02:56:55 +00:00
|
|
|
while (!leave_menu) {
|
2010-02-27 14:01:28 +00:00
|
|
|
|
2009-07-11 14:06:00 +00:00
|
|
|
switch (rb->do_menu(&main_menu, &choice, NULL, false)) {
|
2009-07-08 17:42:37 +00:00
|
|
|
case 0:
|
2009-08-03 02:56:55 +00:00
|
|
|
leave_menu=true;
|
|
|
|
ret = 0;
|
|
|
|
break;
|
2009-07-08 17:42:37 +00:00
|
|
|
case 1:
|
|
|
|
clix_init(state);
|
2009-08-03 02:56:55 +00:00
|
|
|
leave_menu=true;
|
|
|
|
ret = 0;
|
|
|
|
break;
|
2009-07-08 17:42:37 +00:00
|
|
|
case 2:
|
2009-08-03 02:56:55 +00:00
|
|
|
if (clix_help()) {
|
|
|
|
leave_menu=true;
|
|
|
|
ret = 1;
|
|
|
|
}
|
2009-07-08 17:42:37 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2010-02-27 14:01:28 +00:00
|
|
|
highscore_show(-1, highscores, NUM_SCORES, true);
|
2009-07-08 17:42:37 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
playback_control(NULL);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
case MENU_ATTACHED_USB:
|
2009-08-03 02:56:55 +00:00
|
|
|
leave_menu=true;
|
|
|
|
ret = 1;
|
|
|
|
break;
|
2009-07-08 17:42:37 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-02-27 14:01:28 +00:00
|
|
|
|
2009-08-03 02:56:55 +00:00
|
|
|
return ret;
|
2009-07-08 17:42:37 +00:00
|
|
|
}
|
|
|
|
|
2010-02-27 14:01:28 +00:00
|
|
|
static int clix_click(struct clix_game_state_t* state)
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
2010-02-27 14:01:28 +00:00
|
|
|
int position;
|
|
|
|
if (state->selected_count <= 1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
switch( clix_clear_selected( state))
|
|
|
|
{
|
|
|
|
case CLIX_CLEARED:
|
|
|
|
state->score += state->level * 100;
|
|
|
|
clix_draw( state);
|
|
|
|
if (state->level < NUM_LEVELS) {
|
|
|
|
rb->splash(HZ*2, "Great! Next Level!");
|
|
|
|
state->level++;
|
|
|
|
clix_init_new_level( state);
|
|
|
|
clix_update_selected( state);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb->splash(HZ*2, "Congratulation!!!");
|
|
|
|
rb->splash(HZ*2, "You have finished the game.");
|
|
|
|
if(clix_menu(state, 0))
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CLIX_GAMEOVER:
|
|
|
|
clix_draw( state);
|
|
|
|
rb->splash(HZ*2, "Game Over!");
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
position = highscore_update(state->score, state->level, "",
|
|
|
|
highscores, NUM_SCORES);
|
|
|
|
if (position != -1)
|
|
|
|
{
|
|
|
|
if (position == 0)
|
|
|
|
rb->splash(HZ*2, "New High Score");
|
|
|
|
highscore_show(position, highscores, NUM_SCORES, true);
|
|
|
|
}
|
|
|
|
if(clix_menu(state, 0))
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
rb->sleep(10); /* prevent repeating clicks */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-08 17:42:37 +00:00
|
|
|
|
2010-02-27 14:01:28 +00:00
|
|
|
static int clix_handle_game(struct clix_game_state_t* state)
|
|
|
|
{
|
2009-07-08 17:42:37 +00:00
|
|
|
int button;
|
|
|
|
int blink_tick = *rb->current_tick + BLINK_TICKCOUNT;
|
|
|
|
|
|
|
|
int time;
|
|
|
|
int start;
|
|
|
|
int end;
|
|
|
|
int oldx, oldy;
|
2010-02-27 14:01:28 +00:00
|
|
|
|
|
|
|
if (clix_menu(state, 0))
|
|
|
|
return 1;
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
2009-10-18 15:50:30 +00:00
|
|
|
if (TIME_AFTER(*rb->current_tick, blink_tick)) {
|
2010-01-01 22:47:25 +00:00
|
|
|
state->blink = !state->blink;
|
2009-07-08 17:42:37 +00:00
|
|
|
blink_tick = *rb->current_tick + BLINK_TICKCOUNT;
|
|
|
|
}
|
|
|
|
|
|
|
|
time = 6; /* number of ticks this function will loop reading keys */
|
|
|
|
start = *rb->current_tick;
|
|
|
|
end = start + time;
|
2009-10-18 15:50:30 +00:00
|
|
|
while(TIME_BEFORE(*rb->current_tick, end))
|
2009-07-08 17:42:37 +00:00
|
|
|
{
|
|
|
|
oldx = state->x;
|
|
|
|
oldy = state->y;
|
|
|
|
|
2009-07-18 12:33:13 +00:00
|
|
|
button = rb->button_get_w_tmo(end - *rb->current_tick);
|
2009-07-13 12:16:06 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
if(button & BUTTON_TOUCHSCREEN)
|
|
|
|
{
|
|
|
|
int x = rb->button_get_data() >> 16;
|
|
|
|
int y = rb->button_get_data() & 0xffff;
|
|
|
|
|
|
|
|
x -= XOFS;
|
|
|
|
y -= YOFS;
|
|
|
|
if(x >= 0 && y >= 0)
|
|
|
|
{
|
|
|
|
x /= CELL_SIZE + 1;
|
|
|
|
y /= CELL_SIZE + 1;
|
|
|
|
|
|
|
|
if(x < BOARD_WIDTH && y < BOARD_HEIGHT
|
|
|
|
&& state->board[XYPOS(x, y)] != CC_BLACK)
|
|
|
|
{
|
2012-01-30 00:03:22 +00:00
|
|
|
if(state->x == x && state->y == y && button & BUTTON_REL)
|
2009-07-13 12:16:06 +00:00
|
|
|
button = CLIX_BUTTON_CLICK;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
state->x = x;
|
|
|
|
state->y = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2009-07-08 17:42:37 +00:00
|
|
|
switch( button)
|
|
|
|
{
|
2009-07-13 12:16:06 +00:00
|
|
|
#ifndef HAVE_TOUCHSCREEN
|
2009-07-08 17:42:37 +00:00
|
|
|
#ifdef CLIX_BUTTON_SCROLL_BACK
|
|
|
|
case CLIX_BUTTON_SCROLL_BACK:
|
2009-07-18 12:33:13 +00:00
|
|
|
case CLIX_BUTTON_SCROLL_BACK|BUTTON_REPEAT:
|
2009-07-08 17:42:37 +00:00
|
|
|
#endif
|
plugins: Improve usability of iPod keymaps
- Reduce need to press multiple buttons at
the same time to quit a plugin
- Have "Menu" be default way to quit plugins or
to access plugin menu
- Fall back to (Long) "Select" or Long "Menu"
in cases where Menu button isn't available
(e.g. in ImageViewer and many games)
out of scope:
boomshine, lua_scripts, Rockpaint,
Doom, Duke3D, Pacbox, Quake,
Sgt-Puzzles, Wolf3D, XWorld,
Minesweeper, Pixel Painter, Spacerocks
Change-Id: I6d4dc7174695fe4b8ee9cbaccb21bdbfe6af5c48
2022-12-18 20:13:15 +00:00
|
|
|
#ifdef CLIX_BUTTON_UP
|
2009-07-08 17:42:37 +00:00
|
|
|
case CLIX_BUTTON_UP:
|
2010-02-27 14:01:28 +00:00
|
|
|
case CLIX_BUTTON_UP|BUTTON_REPEAT:
|
plugins: Improve usability of iPod keymaps
- Reduce need to press multiple buttons at
the same time to quit a plugin
- Have "Menu" be default way to quit plugins or
to access plugin menu
- Fall back to (Long) "Select" or Long "Menu"
in cases where Menu button isn't available
(e.g. in ImageViewer and many games)
out of scope:
boomshine, lua_scripts, Rockpaint,
Doom, Duke3D, Pacbox, Quake,
Sgt-Puzzles, Wolf3D, XWorld,
Minesweeper, Pixel Painter, Spacerocks
Change-Id: I6d4dc7174695fe4b8ee9cbaccb21bdbfe6af5c48
2022-12-18 20:13:15 +00:00
|
|
|
#endif
|
2009-07-08 17:42:37 +00:00
|
|
|
if( state->y == 0 ||
|
|
|
|
state->board[ XYPOS( state->x, state->y - 1)] ==
|
|
|
|
CC_BLACK
|
|
|
|
)
|
|
|
|
state->y = BOARD_HEIGHT - 1;
|
|
|
|
else
|
|
|
|
state->y--;
|
|
|
|
|
|
|
|
clix_move_cursor(state, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
#ifdef CLIX_BUTTON_SCROLL_FWD
|
|
|
|
case CLIX_BUTTON_SCROLL_FWD:
|
2009-07-18 12:33:13 +00:00
|
|
|
case CLIX_BUTTON_SCROLL_FWD|BUTTON_REPEAT:
|
2009-07-08 17:42:37 +00:00
|
|
|
#endif
|
plugins: Improve usability of iPod keymaps
- Reduce need to press multiple buttons at
the same time to quit a plugin
- Have "Menu" be default way to quit plugins or
to access plugin menu
- Fall back to (Long) "Select" or Long "Menu"
in cases where Menu button isn't available
(e.g. in ImageViewer and many games)
out of scope:
boomshine, lua_scripts, Rockpaint,
Doom, Duke3D, Pacbox, Quake,
Sgt-Puzzles, Wolf3D, XWorld,
Minesweeper, Pixel Painter, Spacerocks
Change-Id: I6d4dc7174695fe4b8ee9cbaccb21bdbfe6af5c48
2022-12-18 20:13:15 +00:00
|
|
|
#ifdef CLIX_BUTTON_DOWN
|
2009-07-08 17:42:37 +00:00
|
|
|
case CLIX_BUTTON_DOWN:
|
2010-02-27 14:01:28 +00:00
|
|
|
case CLIX_BUTTON_DOWN|BUTTON_REPEAT:
|
plugins: Improve usability of iPod keymaps
- Reduce need to press multiple buttons at
the same time to quit a plugin
- Have "Menu" be default way to quit plugins or
to access plugin menu
- Fall back to (Long) "Select" or Long "Menu"
in cases where Menu button isn't available
(e.g. in ImageViewer and many games)
out of scope:
boomshine, lua_scripts, Rockpaint,
Doom, Duke3D, Pacbox, Quake,
Sgt-Puzzles, Wolf3D, XWorld,
Minesweeper, Pixel Painter, Spacerocks
Change-Id: I6d4dc7174695fe4b8ee9cbaccb21bdbfe6af5c48
2022-12-18 20:13:15 +00:00
|
|
|
#endif
|
2009-07-08 17:42:37 +00:00
|
|
|
if( state->y == (BOARD_HEIGHT - 1))
|
|
|
|
state->y = 0;
|
|
|
|
else
|
|
|
|
state->y++;
|
|
|
|
|
|
|
|
clix_move_cursor( state, true);
|
|
|
|
break;
|
2010-02-27 14:01:28 +00:00
|
|
|
|
|
|
|
case CLIX_BUTTON_RIGHT:
|
|
|
|
case CLIX_BUTTON_RIGHT|BUTTON_REPEAT:
|
|
|
|
if( state->x == (BOARD_WIDTH - 1))
|
|
|
|
state->x = 0;
|
|
|
|
else
|
|
|
|
state->x++;
|
|
|
|
|
|
|
|
clix_move_cursor(state, false);
|
|
|
|
break;
|
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
case CLIX_BUTTON_LEFT:
|
2010-02-27 14:01:28 +00:00
|
|
|
case CLIX_BUTTON_LEFT|BUTTON_REPEAT:
|
2009-07-08 17:42:37 +00:00
|
|
|
if( state->x == 0)
|
|
|
|
state->x = BOARD_WIDTH - 1;
|
|
|
|
else
|
|
|
|
state->x--;
|
|
|
|
|
|
|
|
clix_move_cursor(state, true);
|
|
|
|
break;
|
2009-07-13 12:16:06 +00:00
|
|
|
#endif
|
2009-07-08 17:42:37 +00:00
|
|
|
case CLIX_BUTTON_CLICK:
|
2010-02-27 14:01:28 +00:00
|
|
|
if (clix_click(state) == 1)
|
|
|
|
return 1;
|
2009-07-08 17:42:37 +00:00
|
|
|
break;
|
2010-02-27 14:01:28 +00:00
|
|
|
|
2009-07-08 17:42:37 +00:00
|
|
|
case CLIX_BUTTON_QUIT:
|
|
|
|
if (clix_menu(state, 1) != 0) {
|
|
|
|
rb->button_clear_queue();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( (oldx != state->x || oldy != state->y) &&
|
|
|
|
state->board_selected[ XYPOS( oldx, oldy)] !=
|
|
|
|
state->board_selected[ XYPOS( state->x, state->y)]
|
|
|
|
)
|
|
|
|
{
|
|
|
|
clix_update_selected(state);
|
|
|
|
}
|
|
|
|
clix_draw(state);
|
|
|
|
rb->sleep(time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is the plugin entry point */
|
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
|
|
|
{
|
|
|
|
(void)parameter;
|
|
|
|
|
|
|
|
rb->lcd_set_backdrop(NULL);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2009-07-13 12:16:06 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
rb->touchscreen_set_mode(TOUCHSCREEN_POINT);
|
|
|
|
#endif
|
2009-07-08 17:42:37 +00:00
|
|
|
|
2010-02-27 14:45:37 +00:00
|
|
|
highscore_load(SCORE_FILE, highscores, NUM_SCORES);
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
struct clix_game_state_t state;
|
|
|
|
clix_handle_game( &state);
|
|
|
|
|
2010-02-27 14:45:37 +00:00
|
|
|
highscore_save(SCORE_FILE, highscores, NUM_SCORES);
|
2009-07-08 17:42:37 +00:00
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|