Nate Nystrom's ff/rw acceleration patch

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2044 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Eric Linenberg 2002-08-28 19:34:07 +00:00
parent 7d808a83e4
commit 65240761fb
4 changed files with 63 additions and 6 deletions

View file

@ -65,10 +65,12 @@ offset abs
0x0d 0x21 <resume settings byte>
0x0e 0x22 <shuffle,mp3filter,sort_case,discharge,statusbar,show_hidden>
0x0f 0x23 <scroll speed & WPS display byte>
0x10 0x24 <playlist options byte>
0x10 0x24 <ff/rewind step size>
0x11 0x25 <AVC byte>
0x12 0x26 <(int) Resume playlist index, or -1 if no playlist resume>
0x16 0x2a <(int) Byte offset into resume file>
0x1a 0x2e <time until disk spindown>
0x1b 0x2f <ff/rewind acceleration rate>
<all unused space filled with 0xff>
@ -269,6 +271,7 @@ int settings_save( void )
config_block[0x10] = (unsigned char)global_settings.ff_rewind;
config_block[0x11] = (unsigned char)global_settings.avc;
config_block[0x1a] = (unsigned char)global_settings.disk_spindown;
config_block[0x1b] = (unsigned char)global_settings.ff_rewind_accel;
memcpy(&config_block[0x12], &global_settings.resume_index, 4);
memcpy(&config_block[0x16], &global_settings.resume_offset, 4);
@ -373,6 +376,9 @@ void settings_load(void)
if (config_block[0x1a] != 0xFF)
global_settings.disk_spindown = config_block[0x1a];
if (config_block[0x1b] != 0xFF)
global_settings.ff_rewind_accel = config_block[0x1b];
memcpy(&global_settings.resume_seed, &config_block[0xF8], 4);
if (config_block[0x24] != 0xFF)
@ -419,6 +425,7 @@ void settings_reset(void) {
global_settings.scroll_speed = 8;
global_settings.show_hidden_files = false;
global_settings.ff_rewind = DEFAULT_FF_REWIND_SETTING;
global_settings.ff_rewind_accel = DEFAULT_FF_REWIND_ACCEL_SETTING;
global_settings.resume_index = -1;
global_settings.resume_offset = -1;
global_settings.disk_spindown = 5;

View file

@ -64,6 +64,7 @@ struct user_settings
int scroll_speed; /* long texts scrolling speed: 1-20 */
bool playlist_shuffle;
int ff_rewind; /* FF/Rewind step size (in seconds) */
int ff_rewind_accel; /* FF/Rewind acceleration (in seconds per doubling) */
int disk_spindown; /* time until disk spindown, in seconds (0=off) */
/* while playing screen settings */
@ -78,7 +79,6 @@ struct user_settings
/* geeky persistent statistics */
unsigned int total_uptime; /* total uptime since rockbox was first booted */
};
/* prototypes */
@ -116,5 +116,6 @@ extern struct user_settings global_settings;
#define DEFAULT_BACKLIGHT_SETTING 5
#define DEFAULT_WPS_DISPLAY 0
#define DEFAULT_FF_REWIND_SETTING 2
#define DEFAULT_FF_REWIND_ACCEL_SETTING 3
#endif /* __SETTINGS_H__ */

View file

@ -179,6 +179,16 @@ static Menu spindown(void)
return MENU_OK;
}
static Menu ff_rewind_accel(void)
{
char* names[] = { "off ", "2x/1s ", "2x/2s ", "2x/3s ",
"2x/4s ", "2x/5s ", "2x/6s ", "2x/7s ",
"2x/8s ", "2x/9s ", "2x/10s" };
set_option("[FF/Rewind Accel]", &global_settings.ff_rewind_accel,
names, 11 );
return MENU_OK;
}
Menu settings_menu(void)
{
int m;
@ -200,6 +210,7 @@ Menu settings_menu(void)
#endif
{ "Show hidden files", show_hidden_files },
{ "FF/Rewind", ff_rewind },
{ "FF/Rewind Accel", ff_rewind_accel },
{ "Resume", resume },
{ "Disk spindown", spindown },
};

View file

@ -44,6 +44,9 @@
#include "ajf.h"
#endif
#define FF_REWIND_MAX_PERCENT 3 /* cap ff/rewind step size at max % of file */
/* 3% of 30min file == 54s step size */
#ifdef HAVE_LCD_BITMAP
#define PLAY_DISPLAY_2LINEID3 0
#define PLAY_DISPLAY_FILENAME_SCROLL 1
@ -714,6 +717,9 @@ int wps_show(void)
int old_release_mask;
int button;
int ff_rewind_count = 0;
unsigned int ff_rewind_step = 0; /* current rewind step size */
unsigned int ff_rewind_max_step = 0; /* max rewind step size */
long ff_rewind_accel_tick = 0; /* next time to bump ff/rewind step size */
bool ignore_keyup = true;
bool restore = false;
@ -853,7 +859,16 @@ int wps_show(void)
{
if (ff_rewind)
{
ff_rewind_count -= global_settings.ff_rewind*1000;
ff_rewind_count -= ff_rewind_step;
if (global_settings.ff_rewind_accel != 0 &&
current_tick >= ff_rewind_accel_tick)
{
ff_rewind_step *= 2;
if (ff_rewind_step > ff_rewind_max_step)
ff_rewind_step = ff_rewind_max_step;
ff_rewind_accel_tick = current_tick +
global_settings.ff_rewind_accel*HZ;
}
}
else
{
@ -867,7 +882,14 @@ int wps_show(void)
status_set_playmode(STATUS_FASTBACKWARD);
status_draw();
ff_rewind = true;
ff_rewind_count = -global_settings.ff_rewind*1000;
ff_rewind_max_step =
id3->length * FF_REWIND_MAX_PERCENT / 100;
ff_rewind_step = global_settings.ff_rewind*1000;
if (ff_rewind_step > ff_rewind_max_step)
ff_rewind_step = ff_rewind_max_step;
ff_rewind_count = -ff_rewind_step;
ff_rewind_accel_tick = current_tick +
global_settings.ff_rewind_accel*HZ;
}
else
break;
@ -886,7 +908,16 @@ int wps_show(void)
{
if (ff_rewind)
{
ff_rewind_count += global_settings.ff_rewind*1000;
ff_rewind_count += ff_rewind_step;
if (global_settings.ff_rewind_accel != 0 &&
current_tick >= ff_rewind_accel_tick)
{
ff_rewind_step *= 2;
if (ff_rewind_step > ff_rewind_max_step)
ff_rewind_step = ff_rewind_max_step;
ff_rewind_accel_tick = current_tick +
global_settings.ff_rewind_accel*HZ;
}
}
else
{
@ -900,7 +931,14 @@ int wps_show(void)
status_set_playmode(STATUS_FASTFORWARD);
status_draw();
ff_rewind = true;
ff_rewind_count = global_settings.ff_rewind*1000;
ff_rewind_max_step =
id3->length * FF_REWIND_MAX_PERCENT / 100;
ff_rewind_step = global_settings.ff_rewind*1000;
if (ff_rewind_step > ff_rewind_max_step)
ff_rewind_step = ff_rewind_max_step;
ff_rewind_count = ff_rewind_step;
ff_rewind_accel_tick = current_tick +
global_settings.ff_rewind_accel*HZ;
}
else
break;