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
|
|
|
|
2008-04-03 22:43:39 +00:00
|
|
|
PLUGIN_HEADER
|
|
|
|
|
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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "ON"
|
|
|
|
#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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE BUTTON_OFF
|
|
|
|
#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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "OFF"
|
|
|
|
#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)
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_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)
|
|
|
|
#define PEGBOX_SAVE (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
|
|
|
|
|
|
|
|
#define SAVE_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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "SELECT"
|
|
|
|
#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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "MODE"
|
|
|
|
#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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "PLAY"
|
|
|
|
#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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_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
|
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
|
|
|
#define SAVE_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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "SELECT"
|
|
|
|
#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
|
|
|
|
#define PEGBOX_SAVE BUTTON_SELECT
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define SAVE_TEXT "SELECT"
|
|
|
|
#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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "SELECT"
|
|
|
|
#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
|
|
|
|
#define PEGBOX_SAVE BUTTON_SELECT
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define SAVE_TEXT "SELECT"
|
|
|
|
#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
|
|
|
|
#define PEGBOX_SAVE (BUTTON_SELECT | BUTTON_REL)
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define SAVE_TEXT "SELECT"
|
|
|
|
#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
|
2008-04-04 17:54:29 +00:00
|
|
|
#define PEGBOX_SAVE 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
|
|
|
|
|
2008-04-04 17:54:29 +00:00
|
|
|
#define SAVE_TEXT "REM. PLAY"
|
|
|
|
#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-"
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == COWOND2_PAD
|
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
|
|
|
|
#define QUIT_TEXT "POWER"
|
2008-12-04 21:28:56 +00:00
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
|
|
|
#define PEGBOX_SAVE BUTTON_CUSTOM
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define SAVE_TEXT "CUSTOM"
|
|
|
|
#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
|
|
|
|
#define PEGBOX_SAVE BUTTON_VIEW
|
|
|
|
#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
|
|
|
|
|
|
|
|
#define SAVE_TEXT "VIEW"
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
#define RESTART_TEXT "MENU"
|
|
|
|
#define LVL_UP_TEXT "VOL+"
|
|
|
|
#define LVL_DOWN_TEXT "VOL-"
|
|
|
|
|
2009-04-21 04:24:16 +00:00
|
|
|
#elif CONFIG_KEYPAD == ONDAVX747_PAD || CONFIG_KEYPAD == MROBE500_PAD
|
2009-04-07 23:41:44 +00:00
|
|
|
#define PEGBOX_QUIT BUTTON_POWER
|
|
|
|
|
|
|
|
#define QUIT_TEXT "POWER"
|
|
|
|
|
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
|
|
|
|
#ifndef PEGBOX_SAVE
|
|
|
|
#define PEGBOX_SAVE BUTTON_CENTER
|
|
|
|
#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
|
|
|
|
#ifndef SAVE_TEXT
|
|
|
|
#define SAVE_TEXT "CENTER"
|
|
|
|
#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
|
|
|
|
#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
|
2008-06-06 18:29:46 +00:00
|
|
|
#include "lib/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 2 */
|
|
|
|
{{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,},
|
|
|
|
{1, 1, 1, 0, 0, 0, 2, 2, 0, 0, 0, 1,},
|
|
|
|
{1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1,},
|
|
|
|
{1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 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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;
|
|
|
|
char str[5];
|
|
|
|
|
|
|
|
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);
|
2008-10-13 23:13:12 +00:00
|
|
|
rb->lcd_fillrect(BOARD_X-1,BOARD_Y-1,BOARD_WIDTH+2,BOARD_HEIGHT+2);
|
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];
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case SPACE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2008-10-13 23:13:12 +00:00
|
|
|
rb->lcd_bitmap_part(pegbox_pieces, 0, (type-1)*PIECE_HEIGHT,
|
|
|
|
PIECE_WIDTH, c * PIECE_WIDTH + BOARD_X,
|
|
|
|
r * PIECE_HEIGHT + BOARD_Y, PIECE_WIDTH,
|
|
|
|
PIECE_HEIGHT);
|
2008-04-03 22:43:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
rb->snprintf(str, 3, "%d", pb->level);
|
|
|
|
rb->lcd_putsxy(TEXT_X, LEVEL_TEXT_Y, str);
|
|
|
|
rb->snprintf(str, 3, "%d", pb->num_left);
|
|
|
|
rb->lcd_putsxy(TEXT_X, PEGS_TEXT_Y, str);
|
|
|
|
#else
|
2008-04-03 22:43:39 +00:00
|
|
|
rb->snprintf(str, 3, "%d", pb->level);
|
|
|
|
rb->lcd_putsxy(LEVEL_TEXT_X, TEXT_Y, str);
|
|
|
|
rb->snprintf(str, 3, "%d", pb->num_left);
|
|
|
|
rb->lcd_putsxy(PEGS_TEXT_X, TEXT_Y, str);
|
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)
|
2008-06-06 18:29:46 +00:00
|
|
|
button = PEGBOX_SAVE;
|
|
|
|
}
|
|
|
|
#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;
|
2008-04-04 17:54:29 +00:00
|
|
|
case PEGBOX_SAVE:
|
2009-07-14 17:58:41 +00:00
|
|
|
exit=true;
|
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;
|
|
|
|
signed int r,c;
|
|
|
|
|
|
|
|
r = pb->player_row+y_dir;
|
|
|
|
c = pb->player_col+x_dir;
|
|
|
|
|
|
|
|
type1 = pb->playboard[r][c];
|
|
|
|
type2 = pb->playboard[r+y_dir][c+x_dir];
|
|
|
|
|
|
|
|
if (r == ROWS || c == COLS || r < 0 || c < 0 || type1 == WALL)
|
|
|
|
return;
|
|
|
|
else if(type1 != SPACE) {
|
|
|
|
if (type2 == WALL || r+y_dir == ROWS || c+x_dir == COLS ||
|
|
|
|
r+y_dir < 0 || c+x_dir < 0)
|
|
|
|
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)
|
|
|
|
pb->playboard[r][c] = PLAYER;
|
|
|
|
else {
|
|
|
|
pb->playboard[r][c] = PLAYER;
|
|
|
|
if(type1 == type2) {
|
|
|
|
if (type1 == TRIANGLE)
|
|
|
|
pb->playboard[r+y_dir][c+x_dir] = WALL;
|
|
|
|
else if (type1 == CROSS) {
|
|
|
|
pb->playboard[r][c] = SPACE;
|
2009-07-14 17:58:41 +00:00
|
|
|
pegbox_new_piece(pb, r+y_dir, c+x_dir);
|
2008-04-03 22:43:39 +00:00
|
|
|
pb->playboard[r][c] = PLAYER;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pb->playboard[r+y_dir][c+x_dir] = SPACE;
|
|
|
|
}
|
|
|
|
else if (type2 == SPACE)
|
|
|
|
pb->playboard[r+y_dir][c+x_dir] = type1;
|
|
|
|
else if (type2 == HOLE) {
|
|
|
|
if (type1 == SQUARE)
|
|
|
|
pb->playboard[r+y_dir][c+x_dir] = SPACE;
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
int button;
|
|
|
|
#define WORDS (sizeof help_text / sizeof (char*))
|
|
|
|
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-07-15 15:15:48 +00:00
|
|
|
SAVE_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 },
|
|
|
|
{ -1, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
rb->lcd_setfont(FONT_UI);
|
|
|
|
|
|
|
|
if (display_text(WORDS, help_text, formation, NULL))
|
|
|
|
return true;
|
|
|
|
do {
|
|
|
|
button = rb->button_get(true);
|
|
|
|
if ( rb->default_event_handler( button ) == SYS_USB_CONNECTED )
|
|
|
|
return true;
|
|
|
|
} while( ( button == BUTTON_NONE )
|
|
|
|
|| ( button & (BUTTON_REL|BUTTON_REPEAT) ) );
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
/***********************************************************************
|
|
|
|
* pegbox_menu() is the game menu
|
|
|
|
************************************************************************/
|
|
|
|
static unsigned int pegbox_menu(struct game_context* pb, bool ingame)
|
|
|
|
{
|
|
|
|
rb->button_clear_queue();
|
|
|
|
int choice = 0;
|
2008-04-03 22:43:39 +00:00
|
|
|
|
2009-07-14 17:58:41 +00:00
|
|
|
if (ingame) {
|
|
|
|
MENUITEM_STRINGLIST (main_menu, "Pegbox Menu", NULL,
|
|
|
|
"Resume Game",
|
|
|
|
"Restart Level",
|
|
|
|
"Select Level",
|
|
|
|
"Help",
|
|
|
|
"Playback Control",
|
|
|
|
"Quit");
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
switch (rb->do_menu(&main_menu, &choice, NULL, false)) {
|
|
|
|
case 0:
|
|
|
|
pegbox_draw_board(pb);
|
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
|
|
|
return 0;
|
|
|
|
case 2:
|
|
|
|
rb->set_int("Select Level", "", UNIT_INT,
|
|
|
|
&pb->level, NULL, 1, 1,
|
|
|
|
pb->highlevel, NULL);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (pegbox_help()==PLUGIN_USB_CONNECTED)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
playback_control(NULL);
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
return 1;
|
|
|
|
case MENU_ATTACHED_USB:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
break;
|
2008-04-03 22:43:39 +00:00
|
|
|
}
|
2008-10-13 23:13:12 +00:00
|
|
|
}
|
2009-07-14 17:58:41 +00:00
|
|
|
} else {
|
|
|
|
MENUITEM_STRINGLIST (main_menu, "Pegbox Menu", NULL,
|
|
|
|
"Start Game",
|
|
|
|
"Select Level",
|
|
|
|
"Help",
|
|
|
|
"Playback Control",
|
|
|
|
"Quit");
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
switch (rb->do_menu(&main_menu, &choice, NULL, false)) {
|
|
|
|
case 0:
|
|
|
|
pegbox_load_level(pb);
|
|
|
|
pegbox_draw_board(pb);
|
|
|
|
return 0;
|
|
|
|
case 1:
|
|
|
|
rb->set_int("Select Level", "", UNIT_INT,
|
|
|
|
&pb->level, NULL, 1, 1,
|
|
|
|
pb->highlevel, NULL);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (pegbox_help()==PLUGIN_USB_CONNECTED)
|
|
|
|
return 1;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
playback_control(NULL);
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
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;
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
#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-07-14 17:58:41 +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-07-14 17:58:41 +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},
|
|
|
|
};
|
|
|
|
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;
|
|
|
|
}
|