2008-06-28 15:16:43 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// __ \_/ ___\| |/ /| __ \ / __ \ \/ /
|
|
|
|
* Jukebox | | ( (__) ) \___| ( | \_\ ( (__) ) (
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 - 2008 Alexander Papst
|
|
|
|
* Idea from http://www.tetris1d.org
|
|
|
|
*
|
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-06-28 15:16:43 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
|
|
|
|
#if CONFIG_KEYPAD == RECORDER_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_PLAY
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_OFF
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == ARCHOS_AV300_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_OFF
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == ONDIO_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_RIGHT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_OFF
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IAUDIO_X5M5_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IPOD_4G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT (BUTTON_SELECT | BUTTON_MENU)
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H100_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IRIVER_H300_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_OFF
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2009-01-04 23:33:15 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_C200_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_CLIP_PAD || \
|
2011-11-16 14:08:01 +00:00
|
|
|
CONFIG_KEYPAD == SANSA_M200_PAD || \
|
|
|
|
CONFIG_KEYPAD == SANSA_CONNECT_PAD
|
2008-06-28 15:16:43 +00:00
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2009-04-10 17:28:26 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_FUZE_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
2009-05-13 08:27:36 +00:00
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_HOME
|
2009-04-10 17:28:26 +00:00
|
|
|
|
2008-06-28 15:16:43 +00:00
|
|
|
#elif (CONFIG_KEYPAD == IRIVER_H10_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_PLAY
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
Initial commit of the Samsung YP-R0 port.
This port is a hybrid native/RaaA port. It runs on a embedded linux system,
but is the only application. It therefore can implement lots of stuff that
native targets also implement, while leveraging the underlying linux kernel.
The port is quite advanced. User interface, audio playback, plugins work
mostly fine. Missing is e.g. power mangement and USB (see SamsungYPR0 wiki page).
Included in utils/ypr0tools are scripts and programs required to generate
a patched firmware. The patched firmware has the rootfs modified to load
Rockbox. It includes a early/safe USB mode.
This port needs a new toolchain, one that includes glibc headers and libraries.
rockboxdev.sh can generate it, but e.g. codesourcey and distro packages may
also work.
Most of the initial effort is done by Lorenzo Miori and others (on ABI),
including reverse engineering and patching of the original firmware,
initial drivers, and more. Big thanks to you.
Flyspray: FS#12348
Author: Lorenzo Miori, myself
Merry christmas to ypr0 owners! :)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31415 a1c6a512-1295-4272-9138-f99709370657
2011-12-24 11:56:46 +00:00
|
|
|
#elif (CONFIG_KEYPAD == GIGABEAT_S_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == SAMSUNG_YPR0_PAD)
|
2008-06-28 15:16:43 +00:00
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_BACK
|
|
|
|
|
|
|
|
#elif (CONFIG_KEYPAD == MROBE100_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_M3_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_RC_PLAY
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_RC_REC
|
|
|
|
|
2009-12-15 20:51:41 +00:00
|
|
|
#elif (CONFIG_KEYPAD == COWON_D2_PAD)
|
2008-06-28 15:39:52 +00:00
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_MENU
|
2008-06-28 15:16:43 +00:00
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2008-10-07 16:38:28 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO67_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_MENU
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2008-12-04 21:28:56 +00:00
|
|
|
#elif CONFIG_KEYPAD == CREATIVEZVM_PAD
|
2008-12-08 09:51:42 +00:00
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
2008-12-04 21:28:56 +00:00
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_BACK
|
|
|
|
|
2009-01-24 22:41:55 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD1630_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_SELECT
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2010-11-02 14:36:08 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_HDD6330_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_PLAY
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2009-12-02 01:56:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == PHILIPS_SA9200_PAD
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_PLAY
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2009-04-07 23:41:44 +00:00
|
|
|
#elif (CONFIG_KEYPAD == ONDAVX747_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_MENU
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2009-08-04 03:08:32 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SAMSUNG_YH_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_DOWN
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_PLAY
|
|
|
|
|
2010-02-13 15:46:34 +00:00
|
|
|
#elif (CONFIG_KEYPAD == PBELL_VIBE500_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_DOWN
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_REC
|
|
|
|
|
2010-04-26 21:40:00 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MPIO_HD200_PAD)
|
2010-11-02 10:44:34 +00:00
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_FUNC
|
2010-04-26 21:40:00 +00:00
|
|
|
#define ONEDROCKBLOX_QUIT (BUTTON_REC | BUTTON_PLAY)
|
|
|
|
|
2010-11-30 10:52:14 +00:00
|
|
|
#elif (CONFIG_KEYPAD == MPIO_HD300_PAD)
|
2012-02-02 13:42:42 +00:00
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_ENTER
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_MENU
|
2010-11-30 10:52:14 +00:00
|
|
|
|
2011-10-02 15:51:13 +00:00
|
|
|
#elif (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD)
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_DOWN
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2009-04-21 04:24:16 +00:00
|
|
|
#elif defined(HAVE_TOUCHSCREEN)
|
|
|
|
|
|
|
|
#define ONEDROCKBLOX_DOWN BUTTON_BOTTOMMIDDLE
|
|
|
|
#define ONEDROCKBLOX_QUIT BUTTON_POWER
|
|
|
|
|
2008-06-28 15:16:43 +00:00
|
|
|
#else
|
|
|
|
#error No keymap defined!
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define mrand(max) (short)(rb->rand()%max)
|
|
|
|
|
|
|
|
#define TILES 11
|
|
|
|
|
|
|
|
/**********
|
|
|
|
** Lots of defines for the drawing stuff :-)
|
|
|
|
** The most ugly way i could think of...
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if (LCD_WIDTH > LCD_HEIGHT)
|
|
|
|
/* Any screens larger than the minis LCD */
|
|
|
|
#if (LCD_WIDTH > 132)
|
|
|
|
/* Max size of one block */
|
|
|
|
# define WIDTH (int)((LCD_HEIGHT * 0.85) / TILES)
|
|
|
|
/* Align the playing filed centered */
|
|
|
|
# define CENTER_X (int)(LCD_WIDTH/2-(WIDTH/2))
|
|
|
|
# define CENTER_Y (int)(LCD_HEIGHT/2-((WIDTH*TILES+TILES)/2))
|
|
|
|
/* Score box */
|
|
|
|
# define SCORE_X (int)(((CENTER_X+WIDTH+4) + (LCD_WIDTH-(CENTER_X+WIDTH+4))/2)-(f_width/2))
|
|
|
|
# define SCORE_Y (int)((LCD_HEIGHT/2)-(f_height/2))
|
|
|
|
/* Max. size of bricks is 4 blocks */
|
|
|
|
# define NEXT_H (WIDTH*4+3)
|
|
|
|
# define NEXT_X (int)(CENTER_X/2-WIDTH/2)
|
|
|
|
# define NEXT_Y (int)(LCD_HEIGHT/2-NEXT_H/2)
|
|
|
|
#else
|
|
|
|
/* Max size of one block */
|
|
|
|
# define WIDTH (int)((LCD_HEIGHT * 0.85) / TILES)
|
|
|
|
/* Align the playing left centered */
|
|
|
|
# define CENTER_X (int)(LCD_WIDTH*0.2)
|
|
|
|
# define CENTER_Y (int)(LCD_HEIGHT/2-((WIDTH*TILES+TILES)/2))
|
|
|
|
/* Score box */
|
|
|
|
# define SCORE_X (int)(((CENTER_X+WIDTH+4) + (LCD_WIDTH-(CENTER_X+WIDTH+4))/2)-(f_width/2))
|
|
|
|
# define SCORE_Y 16
|
|
|
|
/* Max. size of bricks is 4 blocks */
|
|
|
|
# define NEXT_H (WIDTH*4+3)
|
|
|
|
# define NEXT_X (score_x+f_width+7)
|
|
|
|
# define NEXT_Y (int)(LCD_HEIGHT-((4*WIDTH)+13))
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
/* Max size of one block */
|
|
|
|
# define WIDTH (int)((LCD_HEIGHT * 0.8) / TILES)
|
|
|
|
/* Align the playing filed centered */
|
|
|
|
# define CENTER_X (int)(LCD_WIDTH/2-(WIDTH/2))
|
|
|
|
# define CENTER_Y 2
|
|
|
|
/* Score box */
|
|
|
|
# define SCORE_X (int)((LCD_WIDTH/2)-(f_width/2))
|
|
|
|
# define SCORE_Y (LCD_HEIGHT-(f_height+2))
|
|
|
|
/* Max. size of bricks is 4 blocks */
|
|
|
|
# define NEXT_H (WIDTH*4+3)
|
|
|
|
# define NEXT_X (int)(CENTER_X/2-WIDTH/2)
|
|
|
|
# define NEXT_Y (int)((LCD_HEIGHT * 0.8)/2-NEXT_H/2)
|
|
|
|
#endif
|
|
|
|
|
2011-10-04 19:33:52 +00:00
|
|
|
static void draw_brick(int pos, int length) {
|
2008-06-28 15:16:43 +00:00
|
|
|
int i = pos;
|
|
|
|
rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID);
|
|
|
|
rb->lcd_fillrect(CENTER_X, CENTER_Y, WIDTH, WIDTH * TILES + TILES);
|
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
|
|
|
|
for (i = pos; i < length + pos; ++i) {
|
|
|
|
if (i >= 0) rb->lcd_fillrect(CENTER_X, CENTER_Y+i+(WIDTH*i), WIDTH, WIDTH);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
enum plugin_status plugin_start(const void* parameter)
|
2008-06-28 15:16:43 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int f_width, f_height;
|
|
|
|
int score_x;
|
|
|
|
|
|
|
|
bool quit = false;
|
|
|
|
int button;
|
|
|
|
|
|
|
|
int cycletime = 300;
|
|
|
|
int end;
|
|
|
|
|
|
|
|
int pos_cur_brick = 0;
|
|
|
|
int type_cur_brick = 0;
|
|
|
|
int type_next_brick = 0;
|
|
|
|
|
|
|
|
unsigned long int score = 34126;
|
|
|
|
|
|
|
|
(void)parameter;
|
|
|
|
|
|
|
|
#if LCD_DEPTH > 1
|
|
|
|
rb->lcd_set_backdrop(NULL);
|
|
|
|
rb->lcd_set_background(LCD_BLACK);
|
|
|
|
rb->lcd_set_foreground(LCD_WHITE);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
rb->lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
|
|
|
rb->lcd_getstringsize("100000000", &f_width, &f_height);
|
|
|
|
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
|
|
|
/***********
|
|
|
|
** Draw EVERYTHING
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Playing filed box */
|
|
|
|
rb->lcd_vline(CENTER_X-2, CENTER_Y, CENTER_Y + (WIDTH*TILES+TILES));
|
|
|
|
rb->lcd_vline(CENTER_X + WIDTH + 1, CENTER_Y,
|
|
|
|
CENTER_Y + (WIDTH*TILES+TILES));
|
|
|
|
rb->lcd_hline(CENTER_X-2, CENTER_X + WIDTH + 1,
|
|
|
|
CENTER_Y + (WIDTH*TILES+TILES));
|
|
|
|
|
|
|
|
/* Score box */
|
|
|
|
#if (LCD_WIDTH > LCD_HEIGHT)
|
|
|
|
rb->lcd_drawrect(SCORE_X-4, SCORE_Y-5, f_width+8, f_height+9);
|
|
|
|
rb->lcd_putsxy(SCORE_X-4, SCORE_Y-6-f_height, "score");
|
|
|
|
#else
|
|
|
|
rb->lcd_hline(0, LCD_WIDTH, SCORE_Y-5);
|
|
|
|
rb->lcd_putsxy(2, SCORE_Y-6-f_height, "score");
|
|
|
|
#endif
|
|
|
|
score_x = SCORE_X;
|
|
|
|
|
|
|
|
/* Next box */
|
|
|
|
rb->lcd_getstringsize("next", &f_width, NULL);
|
|
|
|
#if (LCD_WIDTH > LCD_HEIGHT) && !(LCD_WIDTH > 132)
|
|
|
|
rb->lcd_drawrect(NEXT_X-5, NEXT_Y-5, WIDTH+10, NEXT_H+10);
|
|
|
|
rb->lcd_putsxy(score_x-4, NEXT_Y-5, "next");
|
|
|
|
#else
|
|
|
|
rb->lcd_drawrect(NEXT_X-5, NEXT_Y-5, WIDTH+10, NEXT_H+10);
|
|
|
|
rb->lcd_putsxy(NEXT_X-5, NEXT_Y-5-f_height-1, "next");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/***********
|
|
|
|
** GAMELOOP
|
|
|
|
*/
|
|
|
|
rb->srand( *rb->current_tick );
|
|
|
|
|
|
|
|
type_cur_brick = 2 + mrand(3);
|
|
|
|
type_next_brick = 2 + mrand(3);
|
|
|
|
|
|
|
|
do {
|
|
|
|
end = *rb->current_tick + (cycletime * HZ) / 1000;
|
|
|
|
|
|
|
|
draw_brick(pos_cur_brick, type_cur_brick);
|
|
|
|
|
|
|
|
/* Draw next brick */
|
|
|
|
rb->lcd_set_drawmode(DRMODE_BG|DRMODE_INVERSEVID);
|
|
|
|
rb->lcd_fillrect(NEXT_X, NEXT_Y, WIDTH, WIDTH * 4 + 4);
|
|
|
|
rb->lcd_set_drawmode(DRMODE_SOLID);
|
|
|
|
|
|
|
|
for (i = 0; i < type_next_brick; ++i) {
|
|
|
|
rb->lcd_fillrect(NEXT_X,
|
|
|
|
NEXT_Y + ((type_next_brick % 2) ? (int)(WIDTH/2) : ((type_next_brick == 2) ? (WIDTH+1) : 0)) + (WIDTH*i) + i,
|
|
|
|
WIDTH, WIDTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Score box */
|
2010-08-28 21:46:45 +00:00
|
|
|
rb->lcd_putsxyf(score_x, SCORE_Y, "%8ld0", score);
|
2008-06-28 15:16:43 +00:00
|
|
|
|
|
|
|
rb->lcd_update();
|
|
|
|
|
|
|
|
button = rb->button_status();
|
|
|
|
|
|
|
|
switch(button) {
|
|
|
|
case ONEDROCKBLOX_DOWN:
|
|
|
|
case (ONEDROCKBLOX_DOWN|BUTTON_REPEAT):
|
|
|
|
cycletime = 100;
|
|
|
|
break;
|
|
|
|
case ONEDROCKBLOX_QUIT:
|
|
|
|
quit = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
cycletime = 300;
|
|
|
|
if(rb->default_event_handler(button) == SYS_USB_CONNECTED) {
|
|
|
|
quit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pos_cur_brick + type_cur_brick) > 10) {
|
|
|
|
type_cur_brick = type_next_brick;
|
|
|
|
type_next_brick = 2 + mrand(3);
|
|
|
|
score += (type_cur_brick - 1) * 2;
|
|
|
|
pos_cur_brick = 1 - type_cur_brick;
|
|
|
|
} else {
|
|
|
|
++pos_cur_brick;
|
|
|
|
}
|
|
|
|
|
2009-10-18 15:50:30 +00:00
|
|
|
if (TIME_BEFORE(*rb->current_tick, end))
|
2008-06-28 15:16:43 +00:00
|
|
|
rb->sleep(end-*rb->current_tick);
|
|
|
|
else
|
|
|
|
rb->yield();
|
|
|
|
|
|
|
|
} while (!quit);
|
|
|
|
|
|
|
|
return PLUGIN_OK;
|
|
|
|
}
|