2008-04-03 22:43:39 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Tom Ross
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2008-04-03 22:43:39 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
#include "plugin.h"
|
2009-07-14 17:58:41 +00:00
|
|
|
#include "lib/configfile.h"
|
2009-07-14 13:03:17 +00:00
|
|
|
#include "lib/display_text.h"
|
2009-07-14 17:58:41 +00:00
|
|
|
#include "lib/playback_control.h"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
2008-11-03 14:37:50 +00:00
|
|
|
#include "pluginbitmaps/pegbox_header.h"
|
|
|
|
#include "pluginbitmaps/pegbox_pieces.h"
|
2008-10-13 23:13:12 +00:00
|
|
|
|
2010-08-24 14:30:46 +00:00
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
#define CONFIG_FILE_NAME "pegbox.cfg"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#define ROWS 8 /* Number of rows on each board */
|
|
|
|
#define COLS 12 /* Number of columns on each board */
|
|
|
|
#define NUM_LEVELS 15 /* Number of levels */
|
|
|
|
|
|
|
|
#define SPACE 0
|
|
|
|
#define WALL 1
|
|
|
|
#define TRIANGLE 2
|
|
|
|
#define CROSS 3
|
|
|
|
#define SQUARE 4
|
|
|
|
#define CIRCLE 5
|
|
|
|
#define HOLE 6
|
|
|
|
#define PLAYER 7
|
|
|
|
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_ON
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_OFF
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_RESTART BUTTON_F2
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_LVL_UP BUTTON_F1
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_F3
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "ON"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "OFF"
|
|
|
|
#define RESTART_TEXT "F2"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LVL_UP_TEXT "F1"
|
|
|
|
#define LVL_DOWN_TEXT "F3"
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_OFF
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_QUIT (BUTTON_MENU | BUTTON_LEFT)
|
|
|
|
#define PEGBOX_RESTART (BUTTON_MENU | BUTTON_RIGHT)
|
|
|
|
#define PEGBOX_LVL_UP (BUTTON_MENU | BUTTON_UP)
|
|
|
|
#define PEGBOX_LVL_DOWN (BUTTON_MENU | BUTTON_DOWN)
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "OFF"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "M+LEFT"
|
|
|
|
#define RESTART_TEXT "M+RIGHT"
|
|
|
|
#define LVL_UP_TEXT "M+UP"
|
|
|
|
#define LVL_DOWN_TEXT "M+DOWN"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_OFF
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_RESTART BUTTON_ON
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_MODE
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_REC
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "NAVI"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define QUIT_TEXT "OFF"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define RESTART_TEXT "ON"
|
|
|
|
#define LVL_UP_TEXT "AB"
|
|
|
|
#define LVL_DOWN_TEXT "REC"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT (BUTTON_SELECT|BUTTON_RIGHT)
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_QUIT (BUTTON_SELECT|BUTTON_PLAY)
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_RESTART (BUTTON_SELECT|BUTTON_LEFT)
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_LVL_UP (BUTTON_SELECT|BUTTON_MENU)
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_UP BUTTON_MENU
|
|
|
|
#define PEGBOX_DOWN BUTTON_PLAY
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT+RIGHT"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "SELECT+PLAY"
|
|
|
|
#define RESTART_TEXT "SELECT+LEFT"
|
|
|
|
#define LVL_UP_TEXT "SELECT+MENU"
|
|
|
|
#define LVL_DOWN_TEXT "-"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
2008-04-04 00:33:59 +00:00
|
|
|
#define PEGBOX_RESTART BUTTON_REC
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_LVL_UP BUTTON_PLAY
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "OFF"
|
2008-04-04 00:33:59 +00:00
|
|
|
#define RESTART_TEXT "REC"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define LVL_UP_TEXT "PLAY"
|
2008-04-04 00:33:59 +00:00
|
|
|
#define LVL_DOWN_TEXT "-"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_IFP7XX_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_MODE
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_PLAY
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_RESTART (BUTTON_EQ|BUTTON_MODE)
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_LVL_UP (BUTTON_EQ|BUTTON_UP)
|
|
|
|
#define PEGBOX_LVL_DOWN (BUTTON_EQ|BUTTON_DOWN)
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "MODE"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "PLAY"
|
|
|
|
#define RESTART_TEXT "EQ+MODE"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LVL_UP_TEXT "EQ+UP"
|
|
|
|
#define LVL_DOWN_TEXT "EQ+DOWN"
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_PLAY
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART (BUTTON_FF|BUTTON_REPEAT)
|
|
|
|
#define PEGBOX_LVL_UP (BUTTON_FF|BUTTON_SCROLL_UP)
|
|
|
|
#define PEGBOX_LVL_DOWN (BUTTON_FF|BUTTON_SCROLL_DOWN)
|
|
|
|
#define PEGBOX_UP BUTTON_SCROLL_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_SCROLL_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "PLAY"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "OFF"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define RESTART_TEXT "LONG FF"
|
|
|
|
#define LVL_UP_TEXT "FF+SCROLL_UP"
|
|
|
|
#define LVL_DOWN_TEXT "FF+SCROLL_DOWN"
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_RESTART BUTTON_REC
|
2008-04-04 00:33:59 +00:00
|
|
|
#define PEGBOX_LVL_UP BUTTON_SCROLL_BACK
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_SCROLL_FWD
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define RESTART_TEXT "REC"
|
|
|
|
#define LVL_UP_TEXT "SCROLL BACK"
|
|
|
|
#define LVL_DOWN_TEXT "SCROLL FWD"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
2009-01-04 23:33:15 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT|BUTTON_REL
|
2009-04-10 17:28:26 +00:00
|
|
|
#define PEGBOX_QUIT (BUTTON_HOME|BUTTON_REPEAT)
|
2009-07-14 09:13:30 +00:00
|
|
|
#define PEGBOX_RESTART (BUTTON_SELECT|BUTTON_LEFT)
|
|
|
|
#define PEGBOX_LVL_UP (BUTTON_SELECT|BUTTON_UP)
|
|
|
|
#define PEGBOX_LVL_DOWN (BUTTON_SELECT|BUTTON_DOWN)
|
2009-01-04 23:33:15 +00:00
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2009-04-10 17:28:26 +00:00
|
|
|
#define QUIT_TEXT "HOME"
|
2009-01-04 23:33:15 +00:00
|
|
|
#define RESTART_TEXT "SELECT & LEFT"
|
2009-07-14 09:13:30 +00:00
|
|
|
#define LVL_UP_TEXT "SELECT & UP"
|
|
|
|
#define LVL_DOWN_TEXT "SELECT & DOWN"
|
2009-01-04 23:33:15 +00:00
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART BUTTON_A
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "A"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2008-04-06 23:25:21 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_S_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-06 23:25:21 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_BACK
|
|
|
|
#define PEGBOX_RESTART BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-04-06 23:25:21 +00:00
|
|
|
#define QUIT_TEXT "BACK"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE100_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART BUTTON_PLAY
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_LVL_UP BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_DISPLAY
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define RESTART_TEXT "PLAY"
|
|
|
|
#define LVL_UP_TEXT "MENU"
|
|
|
|
#define LVL_DOWN_TEXT "DISPLAY"
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == SANSA_C200_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_RESTART BUTTON_REC
|
2008-04-03 22:43:39 +00:00
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
2008-04-03 22:43:39 +00:00
|
|
|
#define RESTART_TEXT "REC"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
2008-04-04 00:33:59 +00:00
|
|
|
|
2008-11-28 00:37:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_CLIP_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
2008-11-28 00:37:28 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART BUTTON_HOME
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-11-28 00:37:28 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "HOME"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2008-12-12 19:50:49 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_M200_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT (BUTTON_SELECT | BUTTON_REL)
|
2008-12-12 19:50:49 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART (BUTTON_SELECT | BUTTON_UP)
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "SELECT"
|
2008-12-12 19:50:49 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "SELECT+UP"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
|
|
|
|
2008-04-04 00:33:59 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_RC_PLAY
|
2008-04-04 00:33:59 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_RC_REC
|
|
|
|
#define PEGBOX_RESTART BUTTON_RC_MODE
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_RC_VOL_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_RC_VOL_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RC_FF
|
|
|
|
#define PEGBOX_LEFT BUTTON_RC_REW
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "REM. PLAY"
|
2008-04-04 17:54:29 +00:00
|
|
|
#define QUIT_TEXT "REM. REC"
|
2008-04-04 00:33:59 +00:00
|
|
|
#define RESTART_TEXT "REM. MODE"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif CONFIG_KEYPAD == COWON_D2_PAD
|
2008-04-04 00:33:59 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
|
|
|
|
#define QUIT_TEXT "POWER"
|
2008-12-04 21:28:56 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_CUSTOM
|
2008-12-04 21:28:56 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_BACK
|
2008-12-08 09:51:42 +00:00
|
|
|
#define PEGBOX_RESTART BUTTON_SELECT
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_PLAY
|
2008-12-04 21:28:56 +00:00
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_MENU
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "CUSTOM"
|
2008-12-04 21:28:56 +00:00
|
|
|
#define QUIT_TEXT "BACK"
|
|
|
|
#define RESTART_TEXT "MIDDLE"
|
|
|
|
#define LVL_UP_TEXT "SELECT"
|
|
|
|
#define LVL_DOWN_TEXT "MENU"
|
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
2009-08-01 13:20:20 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_VIEW
|
2009-01-24 22:41:55 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
#define SELECT_TEXT "VIEW"
|
2009-01-24 22:41:55 +00:00
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2010-11-02 20:09:02 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define PEGBOX_SELECT BUTTON_NEXT
|
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
2010-11-03 02:54:05 +00:00
|
|
|
#define SELECT_TEXT "NEXT"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2009-12-03 23:13:45 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
#define PEGBOX_SELECT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_RESTART BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_NEXT
|
|
|
|
#define PEGBOX_LEFT BUTTON_PREV
|
|
|
|
|
|
|
|
#define SELECT_TEXT "RIGHT"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2009-08-31 21:11:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX747_PAD || \
|
|
|
|
CONFIG_KEYPAD == ONDAVX777_PAD || \
|
|
|
|
CONFIG_KEYPAD == MROBE500_PAD
|
2009-04-07 23:41:44 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif CONFIG_KEYPAD == SAMSUNG_YH_PAD
|
|
|
|
#define PEGBOX_SAVE (BUTTON_REC|BUTTON_FFWD)
|
|
|
|
#define PEGBOX_QUIT (BUTTON_REC|BUTTON_PLAY)
|
|
|
|
#define PEGBOX_RESTART (BUTTON_REC|BUTTON_REW)
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_FFWD
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_REW
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
2009-08-04 03:26:03 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_PLAY
|
2009-08-04 03:08:32 +00:00
|
|
|
|
|
|
|
#define SAVE_TEXT "REC + FFWD"
|
|
|
|
#define QUIT_TEXT "REC + PLAY"
|
|
|
|
#define RESTART_TEXT "REC + REW"
|
|
|
|
#define LVL_UP_TEXT "FFWD"
|
|
|
|
#define LVL_DOWN_TEXT "REW"
|
2009-08-04 03:26:03 +00:00
|
|
|
#define SELECT_TEXT "PLAY"
|
2009-08-04 03:08:32 +00:00
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == PBELL_VIBE500_PAD
|
|
|
|
#define PEGBOX_SAVE (BUTTON_REC|BUTTON_OK)
|
|
|
|
#define PEGBOX_QUIT BUTTON_REC
|
|
|
|
#define PEGBOX_RESTART BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_OK
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_CANCEL
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_NEXT
|
|
|
|
#define PEGBOX_LEFT BUTTON_PREV
|
|
|
|
#define PEGBOX_SELECT BUTTON_PLAY
|
|
|
|
|
|
|
|
#define SAVE_TEXT "REC + OK"
|
|
|
|
#define QUIT_TEXT "REC"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "OK"
|
|
|
|
#define LVL_DOWN_TEXT "CANCEL"
|
|
|
|
#define SELECT_TEXT "PLAY"
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD200_PAD
|
2010-11-02 10:44:34 +00:00
|
|
|
#define PEGBOX_SAVE (BUTTON_PLAY|BUTTON_FUNC)
|
2010-04-26 21:40:00 +00:00
|
|
|
#define PEGBOX_QUIT (BUTTON_REC|BUTTON_PLAY)
|
|
|
|
#define PEGBOX_RESTART BUTTON_REC
|
2010-11-02 10:44:34 +00:00
|
|
|
#define PEGBOX_LVL_UP (BUTTON_PLAY|BUTTON_REW)
|
|
|
|
#define PEGBOX_LVL_DOWN (BUTTON_PLAY|BUTTON_FF)
|
|
|
|
#define PEGBOX_UP BUTTON_REW
|
|
|
|
#define PEGBOX_DOWN BUTTON_FF
|
2010-04-26 21:40:00 +00:00
|
|
|
#define PEGBOX_RIGHT BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LEFT BUTTON_VOL_DOWN
|
2010-11-02 10:44:34 +00:00
|
|
|
#define PEGBOX_SELECT BUTTON_FUNC
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2010-11-02 10:44:34 +00:00
|
|
|
#define SAVE_TEXT "PLAY + FUNC"
|
2010-04-26 21:40:00 +00:00
|
|
|
#define QUIT_TEXT "REC + PLAY"
|
|
|
|
#define RESTART_TEXT "REC"
|
2010-11-02 10:44:34 +00:00
|
|
|
#define LVL_UP_TEXT "REW"
|
|
|
|
#define LVL_DOWN_TEXT "FF"
|
|
|
|
#define SELECT_TEXT "FUNC"
|
2010-04-26 21:40:00 +00:00
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif CONFIG_KEYPAD == MPIO_HD300_PAD
|
2012-02-02 13:42:42 +00:00
|
|
|
#define PEGBOX_SAVE (BUTTON_ENTER | BUTTON_REPEAT)
|
|
|
|
#define PEGBOX_QUIT (BUTTON_MENU | BUTTON_REPEAT)
|
|
|
|
#define PEGBOX_RESTART (BUTTON_MENU | BUTTON_REL)
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_PLAY
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_REC
|
2010-11-30 10:52:14 +00:00
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
2012-02-02 13:42:42 +00:00
|
|
|
#define PEGBOX_RIGHT BUTTON_FF
|
|
|
|
#define PEGBOX_LEFT BUTTON_REW
|
|
|
|
#define PEGBOX_SELECT (BUTTON_ENTER | BUTTON_REL)
|
2010-11-30 10:52:14 +00:00
|
|
|
|
2012-02-02 13:42:42 +00:00
|
|
|
#define SAVE_TEXT "Long ENTER"
|
|
|
|
#define QUIT_TEXT "Long MENU"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "PLAY"
|
|
|
|
#define LVL_DOWN_TEXT "REC"
|
|
|
|
#define SELECT_TEXT "ENTER"
|
2010-11-30 10:52:14 +00:00
|
|
|
|
2011-10-02 16:20:50 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD
|
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_SAVE BUTTON_PLAYPAUSE
|
|
|
|
#define PEGBOX_RESTART BUTTON_BACK
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
|
|
|
|
|
|
|
#define SAVE_TEXT "PLAYPAUSE"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "BACK"
|
|
|
|
#define LVL_UP_TEXT "Vol+"
|
|
|
|
#define LVL_DOWN_TEXT "Vol-"
|
|
|
|
#define SELECT_TEXT "SELECT"
|
|
|
|
|
2011-11-16 14:08:01 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_CONNECT_PAD
|
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_SAVE BUTTON_VOL_UP
|
|
|
|
#define PEGBOX_RESTART BUTTON_VOL_DOWN
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_NEXT
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_PREV
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
|
|
|
#define SAVE_TEXT "Vol+"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "Vol-"
|
|
|
|
#define LVL_UP_TEXT "NEXT"
|
|
|
|
#define LVL_DOWN_TEXT "PREV"
|
|
|
|
#define SELECT_TEXT "SELECT"
|
|
|
|
|
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 == SAMSUNG_YPR0_PAD
|
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
|
|
|
#define PEGBOX_QUIT BUTTON_BACK
|
|
|
|
#define PEGBOX_RESTART BUTTON_MENU
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_USER
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_POWER
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
|
|
|
#define SAVE_TEXT "PLAYPAUSE"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "BACK"
|
|
|
|
#define LVL_UP_TEXT "Vol+"
|
|
|
|
#define LVL_DOWN_TEXT "Vol-"
|
|
|
|
#define SELECT_TEXT "SELECT"
|
|
|
|
|
2012-03-23 18:32:50 +00:00
|
|
|
#elif CONFIG_KEYPAD == HM60X_PAD
|
|
|
|
#define PEGBOX_SELECT BUTTON_SELECT
|
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
#define PEGBOX_SAVE (BUTTON_POWER|BUTTON_SELECT)
|
|
|
|
#define PEGBOX_RESTART (BUTTON_POWER|BUTTON_LEFT)
|
|
|
|
#define PEGBOX_LVL_UP (BUTTON_POWER|BUTTON_UP)
|
|
|
|
#define PEGBOX_LVL_DOWN (BUTTON_POWER|BUTTON_DOWN)
|
|
|
|
#define PEGBOX_UP BUTTON_UP
|
|
|
|
#define PEGBOX_DOWN BUTTON_DOWN
|
|
|
|
#define PEGBOX_RIGHT BUTTON_RIGHT
|
|
|
|
#define PEGBOX_LEFT BUTTON_LEFT
|
|
|
|
|
|
|
|
#define SAVE_TEXT "POWER + SELECT"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "POWER + LEFT"
|
|
|
|
#define LVL_UP_TEXT "POWER + UP"
|
|
|
|
#define LVL_DOWN_TEXT "POWER + DOWN"
|
|
|
|
#define SELECT_TEXT "SELECT"
|
|
|
|
|
2008-04-06 23:25:21 +00:00
|
|
|
#else
|
|
|
|
#error Unsupported keymap!
|
2008-04-03 22:43:39 +00:00
|
|
|
#endif
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2008-04-27 15:30:19 +00:00
|
|
|
#ifndef PEGBOX_QUIT
|
|
|
|
#define PEGBOX_QUIT BUTTON_TOPLEFT
|
|
|
|
#endif
|
2009-08-01 13:20:20 +00:00
|
|
|
#ifndef PEGBOX_SELECT
|
|
|
|
#define PEGBOX_SELECT BUTTON_CENTER
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_RESTART
|
|
|
|
#define PEGBOX_RESTART BUTTON_TOPRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_LVL_UP
|
|
|
|
#define PEGBOX_LVL_UP BUTTON_BOTTOMLEFT
|
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_LVL_DOWN
|
|
|
|
#define PEGBOX_LVL_DOWN BUTTON_BOTTOMRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_UP
|
|
|
|
#define PEGBOX_UP BUTTON_TOPMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_DOWN
|
|
|
|
#define PEGBOX_DOWN BUTTON_BOTTOMMIDDLE
|
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_RIGHT
|
|
|
|
#define PEGBOX_RIGHT BUTTON_MIDRIGHT
|
|
|
|
#endif
|
|
|
|
#ifndef PEGBOX_LEFT
|
|
|
|
#define PEGBOX_LEFT BUTTON_MIDLEFT
|
|
|
|
#endif
|
2009-08-01 13:20:20 +00:00
|
|
|
#ifndef SELECT_TEXT
|
|
|
|
#define SELECT_TEXT "CENTER"
|
2008-04-27 15:30:19 +00:00
|
|
|
#endif
|
|
|
|
#ifndef QUIT_TEXT
|
|
|
|
#define QUIT_TEXT "TOPLEFT"
|
|
|
|
#endif
|
|
|
|
#ifndef RESTART_TEXT
|
|
|
|
#define RESTART_TEXT "TOPRIGHT"
|
|
|
|
#endif
|
|
|
|
#ifndef LVL_UP_TEXT
|
|
|
|
#define LVL_UP_TEXT "BOTTOMLEFT"
|
|
|
|
#endif
|
|
|
|
#ifndef LVL_DOWN_TEXT
|
|
|
|
#define LVL_DOWN_TEXT "BOTTOMRIGHT"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2008-10-13 23:13:12 +00:00
|
|
|
|
|
|
|
/* get several sizes from the bitmaps */
|
2008-11-21 15:48:30 +00:00
|
|
|
#ifdef BMPWIDTH_pegbox_pieces
|
2008-10-13 23:13:12 +00:00
|
|
|
#define PIECE_WIDTH BMPWIDTH_pegbox_pieces
|
|
|
|
#define PIECE_HEIGHT (BMPHEIGHT_pegbox_pieces/7)
|
2008-11-21 15:48:30 +00:00
|
|
|
#else
|
|
|
|
/* dummy numbers to avoid #error in dependency generation */
|
|
|
|
#define PIECE_WIDTH 50
|
|
|
|
#define PIECE_HEIGHT 10
|
|
|
|
#endif
|
2008-11-28 00:37:28 +00:00
|
|
|
|
2008-10-13 23:13:12 +00:00
|
|
|
#define BOARD_WIDTH (12*PIECE_WIDTH)
|
|
|
|
#define BOARD_HEIGHT (8*PIECE_HEIGHT)
|
|
|
|
|
|
|
|
|
|
|
|
/* define a wide layout where the statistics are alongside the board, not above
|
|
|
|
* base calculation on the piece bitmaps for the 8x12 board */
|
|
|
|
#if (LCD_WIDTH - BOARD_WIDTH) > (LCD_HEIGHT - BOARD_HEIGHT)
|
|
|
|
#define WIDE_LAYOUT
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#define HEADER_WIDTH BMPWIDTH_pegbox_header
|
|
|
|
#define HEADER_HEIGHT BMPHEIGHT_pegbox_header
|
|
|
|
|
|
|
|
|
|
|
|
#if defined WIDE_LAYOUT
|
|
|
|
|
|
|
|
#if ((BOARD_WIDTH + HEADER_WIDTH + 4) <= LCD_WIDTH)
|
|
|
|
#define BOARD_X 2
|
|
|
|
#else
|
|
|
|
#define BOARD_X 1
|
|
|
|
#endif
|
|
|
|
#define BOARD_Y (LCD_HEIGHT-BOARD_HEIGHT)/2
|
|
|
|
|
|
|
|
#if (LCD_WIDTH >= 132) && (LCD_HEIGHT >= 80)
|
|
|
|
#define TEXT_X 116
|
|
|
|
#define LEVEL_TEXT_Y 14
|
|
|
|
#define PEGS_TEXT_Y 58
|
2008-11-28 00:37:28 +00:00
|
|
|
#elif (LCD_WIDTH >= 128) && (LCD_HEIGHT >= 64)
|
2009-04-17 15:17:08 +00:00
|
|
|
#define TEXT_X 112
|
|
|
|
#define LEVEL_TEXT_Y 27
|
|
|
|
#define PEGS_TEXT_Y 50
|
2008-10-13 23:13:12 +00:00
|
|
|
#else
|
|
|
|
#error "Unsupported screen size"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#else /* "normal" layout */
|
|
|
|
|
|
|
|
#define BOARD_X (LCD_WIDTH-BOARD_WIDTH)/2
|
|
|
|
#if ((BOARD_HEIGHT + HEADER_HEIGHT + 4) <= LCD_HEIGHT)
|
|
|
|
#define BOARD_Y HEADER_HEIGHT+2
|
|
|
|
#else
|
|
|
|
#define BOARD_Y HEADER_HEIGHT
|
|
|
|
#endif
|
|
|
|
|
2009-07-21 02:58:13 +00:00
|
|
|
#if LCD_WIDTH >= 640
|
|
|
|
#define LEVEL_TEXT_X 118
|
|
|
|
#define PEGS_TEXT_X 552
|
|
|
|
#define TEXT_Y 56
|
|
|
|
#elif LCD_WIDTH >= 320
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LEVEL_TEXT_X 59
|
|
|
|
#define PEGS_TEXT_X 276
|
|
|
|
#define TEXT_Y 28
|
2008-10-13 23:13:12 +00:00
|
|
|
#elif LCD_WIDTH >= 240
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LEVEL_TEXT_X 59
|
|
|
|
#define PEGS_TEXT_X 196
|
|
|
|
#define TEXT_Y 28
|
2008-10-13 23:13:12 +00:00
|
|
|
#elif LCD_WIDTH >= 220
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LEVEL_TEXT_X 49
|
|
|
|
#define PEGS_TEXT_X 186
|
|
|
|
#define TEXT_Y 28
|
2008-10-13 23:13:12 +00:00
|
|
|
#elif LCD_WIDTH >= 176
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LEVEL_TEXT_X 38
|
|
|
|
#define PEGS_TEXT_X 155
|
|
|
|
#define TEXT_Y 17
|
2008-10-13 23:13:12 +00:00
|
|
|
#elif LCD_WIDTH >= 160
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LEVEL_TEXT_X 37
|
|
|
|
#define PEGS_TEXT_X 140
|
|
|
|
#define TEXT_Y 13
|
2008-10-13 23:13:12 +00:00
|
|
|
#elif LCD_WIDTH >= 138
|
2008-04-03 22:43:39 +00:00
|
|
|
#define LEVEL_TEXT_X 28
|
|
|
|
#define PEGS_TEXT_X 119
|
|
|
|
#define TEXT_Y 15
|
2008-10-13 23:13:12 +00:00
|
|
|
#elif LCD_WIDTH >= 128
|
|
|
|
#if HEADER_HEIGHT > 16
|
|
|
|
#define LEVEL_TEXT_X 26
|
|
|
|
#define PEGS_TEXT_X 107
|
|
|
|
#define TEXT_Y 31
|
|
|
|
#else
|
|
|
|
#define LEVEL_TEXT_X 15
|
|
|
|
#define PEGS_TEXT_X 100
|
|
|
|
#define TEXT_Y 5
|
|
|
|
#endif /* HEADER_HEIGHT */
|
|
|
|
#elif LCD_WIDTH >= 112
|
|
|
|
#define LEVEL_TEXT_X 25
|
|
|
|
#define PEGS_TEXT_X 90
|
|
|
|
#define TEXT_Y 0
|
2011-11-13 21:25:27 +00:00
|
|
|
#elif LCD_WIDTH >= 96
|
|
|
|
#define LEVEL_TEXT_X 25
|
|
|
|
#define PEGS_TEXT_X 86
|
|
|
|
#define TEXT_Y 22
|
2008-10-13 23:13:12 +00:00
|
|
|
#endif /* LCD_WIDTH */
|
|
|
|
|
|
|
|
#endif /* WIDE_LAYOUT */
|
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
#define BG_COLOR LCD_BLACK
|
|
|
|
#define TEXT_BG LCD_RGBPACK(189,189,189)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2009-08-02 07:05:30 +00:00
|
|
|
#include "lib/pluginlib_touchscreen.h"
|
2008-10-13 23:13:12 +00:00
|
|
|
static struct ts_raster pegbox_raster =
|
|
|
|
{ BOARD_X, BOARD_Y, COLS*PIECE_WIDTH, ROWS*PIECE_HEIGHT,
|
|
|
|
PIECE_WIDTH, PIECE_HEIGHT };
|
|
|
|
static struct ts_raster_button_mapping pegbox_raster_btn =
|
|
|
|
{ &pegbox_raster, false, false, true, false, true, {0, 0}, 0, 0, 0 };
|
2008-06-06 18:29:46 +00:00
|
|
|
#endif
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
struct game_context {
|
|
|
|
unsigned int level;
|
|
|
|
unsigned int highlevel;
|
|
|
|
signed int player_row;
|
|
|
|
signed int player_col;
|
|
|
|
unsigned int num_left;
|
|
|
|
unsigned int playboard[ROWS][COLS];
|
|
|
|
};
|
|
|
|
|
|
|
|
char levels[NUM_LEVELS][ROWS][COLS] = {
|
|
|
|
/* Level 1 */
|
|
|
|
{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},
|
|
|
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,},
|
|
|
|
{1, 0, 0, 0, 7, 0, 0, 5, 0, 0, 0, 1,},
|
|
|
|
{1, 0, 0, 0, 0, 3, 3, 2, 0, 0, 0, 1,},
|
|
|
|
{1, 0, 0, 0, 4, 6, 0, 5, 0, 0, 0, 1,},
|
|
|
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,},
|
|
|
|
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,},
|
|
|
|
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,}},
|
|
|
|
|
|
|
|
/* Level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
|
|
|
|
|
/* Level 15 */
|
|
|
|
{{0, 0, 0, 6, 0, 6, 0, 6, 0, 6, 0, 1,},
|
|
|
|
{0, 0, 0, 6, 0, 6, 0, 6, 0, 6, 0, 1,},
|
|
|
|
{0, 3, 4, 6, 0, 6, 0, 6, 0, 6, 0, 2,},
|
|
|
|
{0, 4, 0, 6, 0, 6, 4, 6, 0, 6, 0, 1,},
|
|
|
|
{0, 3, 0, 6, 0, 6, 0, 6, 0, 6, 0, 1,},
|
|
|
|
{7, 0, 0, 6, 4, 6, 0, 6, 0, 6, 0, 1,},
|
|
|
|
{0, 0, 4, 6, 0, 6, 0, 6, 4, 6, 0, 1,},
|
|
|
|
{0, 0, 4, 6, 0, 6, 0, 6, 0, 6, 0, 1,}}
|
|
|
|
};
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* pegbox_draw_board() draws the game's current level.
|
|
|
|
************************************************************************/
|
|
|
|
static void pegbox_draw_board(struct game_context* pb)
|
|
|
|
{
|
2008-04-03 22:43:39 +00:00
|
|
|
unsigned int r, c, type;
|
|
|
|
pb->num_left = 0;
|
|
|
|
|
|
|
|
rb->lcd_clear_display();
|
2008-10-13 23:13:12 +00:00
|
|
|
#ifdef WIDE_LAYOUT
|
|
|
|
rb->lcd_bitmap(pegbox_header,LCD_WIDTH-HEADER_WIDTH,0,
|
|
|
|
HEADER_WIDTH,LCD_HEIGHT);
|
2008-04-03 22:43:39 +00:00
|
|
|
#else
|
2008-10-13 23:13:12 +00:00
|
|
|
rb->lcd_bitmap(pegbox_header,(LCD_WIDTH-HEADER_WIDTH)/2,0,
|
|
|
|
HEADER_WIDTH, HEADER_HEIGHT);
|
|
|
|
#endif /* WIDE_LAYOUT */
|
|
|
|
|
|
|
|
#if ((BOARD_HEIGHT + HEADER_HEIGHT + 4) <= LCD_HEIGHT)
|
|
|
|
rb->lcd_drawrect(BOARD_X-2,BOARD_Y-2,BOARD_WIDTH+4,BOARD_HEIGHT+4);
|
|
|
|
#endif /* enough space for a frame? */
|
2008-04-04 17:54:29 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
2011-11-13 21:25:27 +00:00
|
|
|
#if ((BOARD_HEIGHT + HEADER_HEIGHT + 2) <= LCD_HEIGHT)
|
2008-10-13 23:13:12 +00:00
|
|
|
rb->lcd_fillrect(BOARD_X-1,BOARD_Y-1,BOARD_WIDTH+2,BOARD_HEIGHT+2);
|
2011-11-13 21:25:27 +00:00
|
|
|
#else
|
|
|
|
rb->lcd_fillrect(BOARD_X,BOARD_Y,BOARD_WIDTH,BOARD_HEIGHT);
|
|
|
|
#endif
|
2008-04-04 17:54:29 +00:00
|
|
|
rb->lcd_set_foreground(LCD_BLACK);
|
|
|
|
rb->lcd_set_background(TEXT_BG);
|
2008-04-03 22:43:39 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
for (r=0 ; r < ROWS ; r++) {
|
|
|
|
for (c = 0 ; c < COLS ; c++) {
|
|
|
|
|
|
|
|
type = pb->playboard[r][c];
|
|
|
|
|
2009-08-01 13:20:20 +00:00
|
|
|
if(type != SPACE) {
|
|
|
|
rb->lcd_bitmap_part(pegbox_pieces, 0, (type-1)*PIECE_HEIGHT,
|
2009-09-04 00:46:24 +00:00
|
|
|
STRIDE( SCREEN_MAIN,
|
|
|
|
BMPWIDTH_pegbox_pieces,BMPHEIGHT_pegbox_pieces),
|
2009-08-31 13:56:48 +00:00
|
|
|
c * PIECE_WIDTH + BOARD_X,
|
|
|
|
r * PIECE_HEIGHT + BOARD_Y, PIECE_WIDTH,
|
|
|
|
PIECE_HEIGHT);
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(pb->playboard[r][c] == PLAYER) {
|
|
|
|
pb->player_row=r;
|
|
|
|
pb->player_col=c;
|
|
|
|
}
|
|
|
|
else if (type != WALL && type != SPACE && type != HOLE)
|
|
|
|
pb->num_left++;
|
|
|
|
}
|
|
|
|
}
|
2008-10-13 23:13:12 +00:00
|
|
|
|
|
|
|
#ifdef WIDE_LAYOUT
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(TEXT_X, LEVEL_TEXT_Y, "%d", pb->level);
|
|
|
|
rb->lcd_putsxyf(TEXT_X, PEGS_TEXT_Y, "%d", pb->num_left);
|
2008-10-13 23:13:12 +00:00
|
|
|
#else
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(LEVEL_TEXT_X, TEXT_Y, "%d", pb->level);
|
|
|
|
rb->lcd_putsxyf(PEGS_TEXT_X, TEXT_Y, "%d", pb->num_left);
|
2008-10-13 23:13:12 +00:00
|
|
|
#endif /*WIDE_LAYOUT*/
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_background(BG_COLOR);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
#endif
|
|
|
|
/* print out the screen */
|
|
|
|
rb->lcd_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2009-07-14 17:58:41 +00:00
|
|
|
* pegbox_load_level() loads the player's current level from the array and sets the
|
2008-04-03 22:43:39 +00:00
|
|
|
* player's position.
|
|
|
|
******************************************************************************/
|
2009-07-14 17:58:41 +00:00
|
|
|
static void pegbox_load_level(struct game_context* pb)
|
|
|
|
{
|
2008-04-03 22:43:39 +00:00
|
|
|
int r, c;
|
|
|
|
|
|
|
|
for(r = 0; r < ROWS; r++)
|
|
|
|
for(c = 0; c < COLS; c++)
|
|
|
|
pb->playboard[r][c] = levels[pb->level-1][r][c];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2009-07-14 17:58:41 +00:00
|
|
|
* pegbox_new_piece() creates a new piece at a specified location. The player
|
2008-04-03 22:43:39 +00:00
|
|
|
* navigates through the pieces and selects one.
|
|
|
|
******************************************************************************/
|
2009-07-14 17:58:41 +00:00
|
|
|
static void pegbox_new_piece(struct game_context* pb, unsigned int x_loc,
|
|
|
|
unsigned int y_loc)
|
|
|
|
{
|
2008-04-03 22:43:39 +00:00
|
|
|
int button;
|
|
|
|
bool exit = false;
|
|
|
|
|
|
|
|
pb->playboard[x_loc][y_loc] = TRIANGLE;
|
|
|
|
|
|
|
|
while (!exit) {
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
button = rb->button_get(true);
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
|
|
|
if(button & BUTTON_TOUCHSCREEN)
|
2008-06-06 18:29:46 +00:00
|
|
|
{
|
|
|
|
pegbox_raster_btn.two_d_from.y = x_loc;
|
|
|
|
pegbox_raster_btn.two_d_from.x = y_loc;
|
2008-10-13 23:13:12 +00:00
|
|
|
|
|
|
|
struct ts_raster_button_result ret =
|
|
|
|
touchscreen_raster_map_button(&pegbox_raster_btn,
|
|
|
|
rb->button_get_data() >> 16,
|
|
|
|
rb->button_get_data() & 0xffff,
|
|
|
|
button);
|
2008-06-06 18:29:46 +00:00
|
|
|
if(ret.action == TS_ACTION_TWO_D_MOVEMENT)
|
|
|
|
{
|
|
|
|
if(ret.to.x > ret.from.x)
|
|
|
|
button = PEGBOX_UP;
|
|
|
|
else if(ret.to.x < ret.from.x)
|
|
|
|
button = PEGBOX_DOWN;
|
|
|
|
else if(ret.to.y > ret.from.y)
|
|
|
|
button = PEGBOX_LEFT;
|
|
|
|
else if(ret.to.y < ret.from.y)
|
|
|
|
button = PEGBOX_RIGHT;
|
|
|
|
}
|
2008-10-13 23:13:12 +00:00
|
|
|
else if(ret.action == TS_ACTION_CLICK
|
|
|
|
&& (unsigned)ret.to.x == y_loc
|
|
|
|
&& (unsigned)ret.to.y == x_loc)
|
2009-08-01 13:20:20 +00:00
|
|
|
button = PEGBOX_SELECT;
|
2008-06-06 18:29:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2008-04-03 22:43:39 +00:00
|
|
|
switch(button){
|
|
|
|
case PEGBOX_LEFT:
|
|
|
|
case (PEGBOX_LEFT|BUTTON_REPEAT):
|
|
|
|
case PEGBOX_DOWN:
|
|
|
|
case (PEGBOX_DOWN|BUTTON_REPEAT):
|
|
|
|
if (pb->playboard[x_loc][y_loc] < 5)
|
|
|
|
pb->playboard[x_loc][y_loc]++;
|
|
|
|
else
|
|
|
|
pb->playboard[x_loc][y_loc] = TRIANGLE;
|
|
|
|
break;
|
|
|
|
case PEGBOX_RIGHT:
|
|
|
|
case (PEGBOX_RIGHT|BUTTON_REPEAT):
|
|
|
|
case PEGBOX_UP:
|
|
|
|
case (PEGBOX_UP|BUTTON_REPEAT):
|
|
|
|
if (pb->playboard[x_loc][y_loc] > 2)
|
|
|
|
pb->playboard[x_loc][y_loc]--;
|
|
|
|
else
|
|
|
|
pb->playboard[x_loc][y_loc] = CIRCLE;
|
|
|
|
break;
|
2009-08-01 13:20:20 +00:00
|
|
|
case PEGBOX_SELECT:
|
2009-07-14 17:58:41 +00:00
|
|
|
exit=true;
|
2009-08-01 13:20:20 +00:00
|
|
|
break;
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
2009-07-14 17:58:41 +00:00
|
|
|
* pegbox_move_player() moves the player and pieces and updates the board accordingly.
|
2008-04-03 22:43:39 +00:00
|
|
|
******************************************************************************/
|
2009-07-14 17:58:41 +00:00
|
|
|
static void pegbox_move_player(struct game_context* pb, signed int x_dir,
|
|
|
|
signed int y_dir)
|
|
|
|
{
|
2008-04-03 22:43:39 +00:00
|
|
|
unsigned int type1, type2;
|
2009-08-01 13:20:20 +00:00
|
|
|
signed int r1,c1,r2,c2;
|
|
|
|
|
|
|
|
r1 = pb->player_row+y_dir;
|
|
|
|
c1 = pb->player_col+x_dir;
|
|
|
|
r2 = pb->player_row+y_dir*2;
|
|
|
|
c2 = pb->player_col+x_dir*2;
|
|
|
|
|
|
|
|
type1 = pb->playboard[r1][c1];
|
|
|
|
type2 = pb->playboard[r2][c2];
|
|
|
|
|
|
|
|
if (r1 == ROWS || c1 == COLS || r1 < 0 || c1 < 0 || type1 == WALL)
|
2008-04-03 22:43:39 +00:00
|
|
|
return;
|
|
|
|
else if(type1 != SPACE) {
|
2009-08-01 13:20:20 +00:00
|
|
|
if (r2 == ROWS || c2 == COLS || r2 < 0 || c2 < 0 || type2 == WALL)
|
2008-04-03 22:43:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pb->playboard[pb->player_row][pb->player_col] = SPACE;
|
|
|
|
pb->player_row += y_dir;
|
|
|
|
pb->player_col += x_dir;
|
|
|
|
|
|
|
|
if (type1 == HOLE) {
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
rb->splash(HZ*2, "You fell down a hole!");
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_load_level(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
else if (type1 == SPACE)
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r1][c1] = PLAYER;
|
2008-04-03 22:43:39 +00:00
|
|
|
else {
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r1][c1] = PLAYER;
|
2008-04-03 22:43:39 +00:00
|
|
|
if(type1 == type2) {
|
|
|
|
if (type1 == TRIANGLE)
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r2][c2] = WALL;
|
2008-04-03 22:43:39 +00:00
|
|
|
else if (type1 == CROSS) {
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r1][c1] = SPACE;
|
|
|
|
pegbox_new_piece(pb, r2, c2);
|
|
|
|
pb->playboard[r1][c1] = PLAYER;
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
else
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r2][c2] = SPACE;
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
else if (type2 == SPACE)
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r2][c2] = type1;
|
2008-04-03 22:43:39 +00:00
|
|
|
else if (type2 == HOLE) {
|
|
|
|
if (type1 == SQUARE)
|
2009-08-01 13:20:20 +00:00
|
|
|
pb->playboard[r2][c2] = SPACE;
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
rb->splash(HZ*2, "Illegal Move!");
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_load_level(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
|
2009-07-14 13:03:17 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* pegbox_help() display help text
|
|
|
|
************************************************************************/
|
|
|
|
static bool pegbox_help(void)
|
|
|
|
{
|
|
|
|
static char* help_text[] = {
|
|
|
|
"Pegbox", "", "Aim", "",
|
|
|
|
"To", "beat", "each", "level,", "you", "must", "destroy", "all", "of",
|
|
|
|
"the", "pegs.", "If", "two", "like", "pegs", "are", "pushed", "into",
|
|
|
|
"each", "other,", "they", "disappear", "except", "for", "triangles",
|
|
|
|
"which", "form", "a", "solid", "block", "and", "crosses", "which",
|
|
|
|
"allow", "you", "to", "choose", "a", "replacement", "block.", "", "",
|
|
|
|
"Controls", "",
|
|
|
|
RESTART_TEXT, "to", "restart", "level", "",
|
|
|
|
LVL_UP_TEXT, "to", "go", "up", "a", "level", "",
|
|
|
|
LVL_DOWN_TEXT, "to", "go", "down", "a", "level", "",
|
2009-08-01 13:20:20 +00:00
|
|
|
SELECT_TEXT, "to", "choose", "peg", "",
|
2009-07-14 13:03:17 +00:00
|
|
|
QUIT_TEXT, "to", "quit"
|
|
|
|
};
|
|
|
|
static struct style_text formation[]={
|
|
|
|
{ 0, TEXT_CENTER|TEXT_UNDERLINE },
|
|
|
|
{ 2, C_RED },
|
|
|
|
{ 46, C_RED },
|
2010-02-22 07:17:15 +00:00
|
|
|
LAST_STYLE_ITEM
|
2009-07-14 13:03:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
rb->lcd_setfont(FONT_UI);
|
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;
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2010-02-22 07:17:15 +00:00
|
|
|
|
2009-07-14 13:03:17 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* pegbox_menu() is the game menu
|
|
|
|
************************************************************************/
|
2009-08-01 13:20:20 +00:00
|
|
|
static bool _ingame;
|
|
|
|
static int pegbox_menu_cb(int action, const struct menu_item_ex *this_item)
|
|
|
|
{
|
|
|
|
int i = (intptr_t)this_item;
|
|
|
|
if( action == ACTION_REQUEST_MENUITEM )
|
|
|
|
{
|
|
|
|
if((!_ingame && (i==0 || i==1)) || ( _ingame && i==2 ))
|
|
|
|
return ACTION_EXIT_MENUITEM;
|
|
|
|
}
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
static unsigned int pegbox_menu(struct game_context* pb, bool ingame)
|
|
|
|
{
|
2009-08-01 13:20:20 +00:00
|
|
|
int selected = 0;
|
|
|
|
int last_level = pb->level;
|
|
|
|
|
|
|
|
MENUITEM_STRINGLIST (main_menu, "Pegbox Menu", pegbox_menu_cb,
|
|
|
|
"Resume Game", "Restart Level", "Start Game",
|
|
|
|
"Select Level", "Help",
|
|
|
|
"Playback Control", "Quit");
|
|
|
|
_ingame = ingame;
|
2009-07-14 17:58:41 +00:00
|
|
|
rb->button_clear_queue();
|
2009-08-01 13:20:20 +00:00
|
|
|
|
|
|
|
while (true) {
|
|
|
|
switch (rb->do_menu(&main_menu, &selected, NULL, false)) {
|
|
|
|
case 0:
|
|
|
|
pb->level = last_level;
|
|
|
|
pegbox_draw_board(pb);
|
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
|
|
|
return 0;
|
|
|
|
case 3:
|
|
|
|
if(rb->set_int("Select Level", "", UNIT_INT, &pb->level,
|
|
|
|
NULL, 1, 1, pb->highlevel, NULL))
|
2009-07-14 17:58:41 +00:00
|
|
|
return 1;
|
2009-08-01 13:20:20 +00:00
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (pegbox_help())
|
2009-07-14 17:58:41 +00:00
|
|
|
return 1;
|
2009-08-01 13:20:20 +00:00
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (playback_control(NULL))
|
2009-07-14 17:58:41 +00:00
|
|
|
return 1;
|
2009-08-01 13:20:20 +00:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
return 1;
|
|
|
|
case MENU_ATTACHED_USB:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
2008-06-06 18:29:46 +00:00
|
|
|
}
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* pegbox_main() is the main game subroutine
|
|
|
|
************************************************************************/
|
|
|
|
static int pegbox_main(struct game_context* pb)
|
|
|
|
{
|
|
|
|
int button;
|
|
|
|
|
|
|
|
if (pegbox_menu(pb, false)==1) {
|
|
|
|
return 1;
|
|
|
|
}
|
2008-04-03 22:43:39 +00:00
|
|
|
|
|
|
|
while (true) {
|
2009-07-14 17:58:41 +00:00
|
|
|
button = rb->button_get(true);
|
2008-08-23 09:46:38 +00:00
|
|
|
#ifdef HAVE_TOUCHSCREEN
|
2009-07-14 17:58:41 +00:00
|
|
|
if(button & BUTTON_TOUCHSCREEN)
|
2008-06-06 18:29:46 +00:00
|
|
|
{
|
|
|
|
pegbox_raster_btn.two_d_from.y = pb->player_row;
|
|
|
|
pegbox_raster_btn.two_d_from.x = pb->player_col;
|
2009-08-01 13:20:20 +00:00
|
|
|
|
2008-10-13 23:13:12 +00:00
|
|
|
struct ts_raster_button_result ret =
|
|
|
|
touchscreen_raster_map_button(&pegbox_raster_btn,
|
|
|
|
rb->button_get_data() >> 16,
|
|
|
|
rb->button_get_data() & 0xffff,
|
2009-07-14 17:58:41 +00:00
|
|
|
button);
|
2008-06-06 18:29:46 +00:00
|
|
|
if(ret.action == TS_ACTION_TWO_D_MOVEMENT)
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_move_player(pb, ret.to.x - ret.from.x, ret.to.y - ret.from.y);
|
2008-06-06 18:29:46 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-07-14 17:58:41 +00:00
|
|
|
switch(button){
|
2008-04-03 22:43:39 +00:00
|
|
|
case PEGBOX_LEFT: /* move cursor left */
|
|
|
|
case (PEGBOX_LEFT|BUTTON_REPEAT):
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_move_player(pb, -1, 0);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEGBOX_RIGHT: /* move cursor right */
|
|
|
|
case (PEGBOX_RIGHT|BUTTON_REPEAT):
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_move_player(pb, 1, 0);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEGBOX_DOWN: /* move cursor down */
|
|
|
|
case (PEGBOX_DOWN|BUTTON_REPEAT):
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_move_player(pb, 0, 1);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEGBOX_UP: /* move cursor up */
|
|
|
|
case (PEGBOX_UP|BUTTON_REPEAT):
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_move_player(pb, 0, -1);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PEGBOX_QUIT:
|
2009-07-14 17:58:41 +00:00
|
|
|
if (pegbox_menu(pb, true)==1) {
|
|
|
|
return 1;
|
|
|
|
}
|
2009-08-01 13:20:20 +00:00
|
|
|
break;
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
#ifdef PEGBOX_RESTART
|
2008-04-03 22:43:39 +00:00
|
|
|
case PEGBOX_RESTART:
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
2009-07-14 17:58:41 +00:00
|
|
|
#endif
|
2008-04-03 22:43:39 +00:00
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
#ifdef PEGBOX_LVL_UP
|
2008-04-04 17:54:29 +00:00
|
|
|
case (PEGBOX_LVL_UP|BUTTON_REPEAT):
|
2008-04-03 22:43:39 +00:00
|
|
|
case PEGBOX_LVL_UP:
|
2009-07-14 17:58:41 +00:00
|
|
|
if (pb->level >= pb->highlevel) {
|
2008-04-04 17:54:29 +00:00
|
|
|
pb->level = 1;
|
|
|
|
} else {
|
2008-04-03 22:43:39 +00:00
|
|
|
pb->level++;
|
|
|
|
}
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
2009-07-14 17:58:41 +00:00
|
|
|
#endif
|
2008-04-03 22:43:39 +00:00
|
|
|
|
2008-04-04 00:33:59 +00:00
|
|
|
#ifdef PEGBOX_LVL_DOWN
|
2008-04-04 17:54:29 +00:00
|
|
|
case (PEGBOX_LVL_DOWN|BUTTON_REPEAT):
|
2008-04-03 22:43:39 +00:00
|
|
|
case PEGBOX_LVL_DOWN:
|
2008-04-04 17:54:29 +00:00
|
|
|
if(pb->level <= 1) {
|
|
|
|
pb->level = pb->highlevel;
|
|
|
|
} else {
|
2008-04-03 22:43:39 +00:00
|
|
|
pb->level--;
|
|
|
|
}
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
2008-04-04 00:33:59 +00:00
|
|
|
#endif
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
if (pb->num_left == 0) {
|
2008-04-03 22:43:39 +00:00
|
|
|
rb->splash(HZ*2, "Nice Pegging!");
|
2009-07-14 17:58:41 +00:00
|
|
|
if (pb->level == NUM_LEVELS) {
|
|
|
|
pegbox_draw_board(pb);
|
|
|
|
rb->splash(HZ*2, "Congratulations!");
|
|
|
|
rb->splash(HZ*2, "You have finished the game!");
|
|
|
|
if (pegbox_menu(pb,false)==1) {
|
|
|
|
return 1;
|
|
|
|
}
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
pb->level++;
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(pb->level > pb->highlevel)
|
|
|
|
pb->highlevel = pb->level;
|
2009-08-01 13:20:20 +00:00
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* plugin entry point.
|
|
|
|
******************************************************************************/
|
2009-07-14 17:58:41 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
|
|
|
{
|
2008-04-03 22:43:39 +00:00
|
|
|
(void)parameter;
|
2009-07-14 17:58:41 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2008-04-03 22:43:39 +00:00
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
2008-04-04 00:33:59 +00:00
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
rb->lcd_set_backdrop(NULL);
|
2009-08-01 13:20:20 +00:00
|
|
|
#endif
|
2008-04-03 22:43:39 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
rb->lcd_set_background(BG_COLOR);
|
|
|
|
#endif
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
struct game_context pb;
|
|
|
|
pb.level=1;
|
|
|
|
pb.highlevel=1;
|
|
|
|
struct configdata config[] = {
|
|
|
|
{TYPE_INT, 1, NUM_LEVELS, { .int_p = &(pb.level) }, "level", NULL},
|
|
|
|
{TYPE_INT, 1, NUM_LEVELS, { .int_p = &(pb.highlevel) }, "highlevel", NULL},
|
2009-08-01 13:20:20 +00:00
|
|
|
};
|
2009-07-14 17:58:41 +00:00
|
|
|
configfile_load(CONFIG_FILE_NAME,config,2,0);
|
|
|
|
pegbox_main(&pb);
|
|
|
|
configfile_save(CONFIG_FILE_NAME,config,2,0);
|
2008-04-03 22:43:39 +00:00
|
|
|
rb->lcd_setfont(FONT_UI);
|
2009-07-14 17:58:41 +00:00
|
|
|
#endif /* HAVE_LCD_BITMAP */
|
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|