diff -u -r -N --strip-trailing-cr -X '~builddir.tmp' -x '*.pat' -x '*.rej' -x '*.orig' -x '*.bak' -x '*.exe' -x '*.prj' win32sim_8-rockbox-daily-20040101/apps/plugin.c bcbox-20040101/apps/plugin.c --- win32sim_8-rockbox-daily-20040101/apps/plugin.c 2004-01-03 00:17:26.000000000 +0000 +++ bcbox-20040101/apps/plugin.c 2004-01-03 01:58:36.000000000 +0000 @@ -163,6 +163,16 @@ lcd_blit, #endif yield, + + /* sound */ +#ifndef SIMULATOR +#ifdef HAVE_MAS3587F + mas_codec_writereg, + mas_readmem, + mas_writemem, +#endif +#endif + }; int plugin_load(char* plugin, void* parameter) diff -u -r -N --strip-trailing-cr -X '~builddir.tmp' -x '*.pat' -x '*.rej' -x '*.orig' -x '*.bak' -x '*.exe' -x '*.prj' win32sim_8-rockbox-daily-20040101/apps/plugin.h bcbox-20040101/apps/plugin.h --- win32sim_8-rockbox-daily-20040101/apps/plugin.h 2003-12-16 05:00:34.000000000 +0000 +++ bcbox-20040101/apps/plugin.h 2004-01-03 01:58:36.000000000 +0000 @@ -43,7 +43,7 @@ #include "mpeg.h" /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 8 +#define PLUGIN_API_VERSION 9 /* update this to latest version if a change to the api struct breaks backwards compatibility */ @@ -188,6 +188,19 @@ void (*lcd_blit) (unsigned char* p_data, int x, int y, int width, int height, int stride); #endif void (*yield)(void); + +/*************** PLUGIN_API_VERSION 9 ******************/ + /* sound */ +#ifndef SIMULATOR +#ifdef HAVE_MAS3587F + int (*mas_codec_writereg)(int reg, unsigned int val); + + /* note: 'len' is number of 32-bit words, not number of bytes! */ + int (*mas_readmem)(int bank, int addr, unsigned long* dest, int len); + int (*mas_writemem)(int bank, int addr, unsigned long* src, int len); +#endif +#endif + }; /* defined by the plugin loader (plugin.c) */ diff -u -r -N --strip-trailing-cr -X '~builddir.tmp' -x '*.pat' -x '*.rej' -x '*.orig' -x '*.bak' -x '*.exe' -x '*.prj' win32sim_8-rockbox-daily-20040101/apps/plugins/audio_3587.c bcbox-20040101/apps/plugins/audio_3587.c --- win32sim_8-rockbox-daily-20040101/apps/plugins/audio_3587.c 1970-01-01 00:00:00.000000000 +0000 +++ bcbox-20040101/apps/plugins/audio_3587.c 2004-01-06 15:48:48.000000000 +0000 @@ -0,0 +1,3044 @@ +/* AUDIO_3587.c - Audio configuration for the MAS 3587F */ + + +/* Code required if app is a plugin */ +#define IS_PLUGIN + +/* enable Advanced/Custom seperation feature */ +#define CUSTOM_SEP + +/* enable Advanced/Custom MDB feature */ +#undef CUSTOM_MDB + +/* at the moment there is no option scrolling code + this will remain so, unless I can turn the internal font + into an real RockBox font */ +#undef CAN_SCROLL + + +/* to save a shit load of typing and produce more readable code */ +typedef unsigned long int UI32; +typedef signed long int I32; + +typedef unsigned short int UI16; +typedef signed short int I16; + +typedef unsigned char UI8; +typedef signed char I8; + + +/* Comprehensive list of all translatable strings used by Audio_3587 */ +#define str_STEREO "STEREO" +#define str_NARROW "NARROW" +#define str_WIDE "WIDE" +#define str_MONO "MONO" +#define str_LEFT "LEFT" +#define str_RIGHT "RIGHT" +#define str_LOUD "LOUD" +#define str_CUSTOM "CUSTOM" +#define str_CUSTOM2 "(C)" +#define str_KARAOKE "KARAOKE" +#define str_AUDIO_RESET "AUDIO RESET?" +#define str_PLAY "PLAY" +#define str_YES "YES" +#define str_OTHER "OTHER" +#define str_NO "NO" +#define str_OFF "OFF" +#define str_NORM "NORM" +#define str_CENTRE "-CENTRE-" +#define str_MUTE "MUTE" +#define str_LINE_OUT "-LINE OUT-" +#define str_MODE "MODE" +#define str_DEC "DEC" +#define str_HEX "HEX" + + +/* plugin header */ +#ifdef IS_PLUGIN +#include "plugin.h" +#include "settings.h" +static struct plugin_api* rb; +#endif + + +#ifdef CUSTOM_SEP +/*--------------------------------------------------------------------------*/ + static UI8 gfx_spkrR[]={10,8, +/* |####| #|# | | */ 0xF1, 0x80, +/* |####| ## |# | | */ 0xF6, 0x80, +/* |####|# |# | | */ 0xF8, 0x80, +/* |####| |# | | */ 0xF0, 0x80, +/* |####| |# | | */ 0xF0, 0x80, +/* |####|# |# | | */ 0xF8, 0x80, +/* |####| ## |# | | */ 0xF6, 0x80, +/* |####| #|# | | */ 0xF1, 0x80 }; + + static UI8 gfx_spkrL[]={9,8, +/* |## | ###|# | | */ 0xC7, 0x80, +/* |# ##| ###|# | | */ 0xB7, 0x80, +/* |# |####|# | | */ 0x8F, 0x80, +/* |# | ###|# | | */ 0x87, 0x80, +/* |# | ###|# | | */ 0x87, 0x80, +/* |# |####|# | | */ 0x8F, 0x80, +/* |# ##| ###|# | | */ 0xB7, 0x80, +/* |## | ###|# | | */ 0xC7, 0x80 }; + + static UI8 gfx_waveOUT[]={8,8, +/* | | | */ 0x00, +/* | ## | | */ 0x60, +/* |# #| # | */ 0x92, +/* | |## | */ 0x0C, +/* | ## | | */ 0x60, +/* |# #| # | */ 0x92, +/* | |## | */ 0x0C, +/* | | | */ 0x00 }; + +/*--------------------------------------------------------------------------*/ + static UI8 gfx_waveIN[]={8,8, +/* | | | */ 0x00, +/* | ## | | */ 0x60, +/* |# #| | */ 0x90, +/* |# #| | */ 0x90, +/* | |# #| */ 0x09, +/* | |# #| */ 0x09, +/* | | ## | */ 0x06, +/* | | | */ 0x00 }; + + static UI8 gfx_bigL[]={7,8, +/* |## | | */ 0xC0, +/* |## | | */ 0xC0, +/* |## | | */ 0xC0, +/* |## | | */ 0xC0, +/* |## | | */ 0xC0, +/* |## | | */ 0xC0, +/* |####|### | */ 0xFE, +/* |####|### | */ 0xFE }; + + static UI8 gfx_bigR[]={8,8, +/* |####|## | */ 0xFC, +/* |####|### | */ 0xFE, +/* |## | ## | */ 0xC6, +/* |## | ## | */ 0xC6, +/* |####|## | */ 0xFC, +/* |## |## | */ 0xCC, +/* |## | ## | */ 0xC6, +/* |## | ## | */ 0xC6 }; + +/*--------------------------------------------------------------------------*/ + static UI8 gfx_arrowR[]={8,7, +/* | |# | */ 0x08, +/* | |## | */ 0x0C, +/* |####|### | */ 0xFE, +/* |####|####| */ 0xFF, +/* |####|### | */ 0xFE, +/* | |## | */ 0x0C, +/* | |# | */ 0x08 }; + static UI8 gfx_arrowL[]={8,7, +/* | #| | */ 0x10, +/* | ##| | */ 0x30, +/* | ###|####| */ 0x7F, +/* |####|####| */ 0xFF, +/* | ###|####| */ 0x7F, +/* | ##| | */ 0x30, +/* | #| | */ 0x10 }; + static UI8 gfx_arrowU[]={7,8, +/* | #| | */ 0x10, +/* | ##|# | */ 0x38, +/* | ###|## | */ 0x7C, +/* |####|### | */ 0xFE, +/* | ##|# | */ 0x38, +/* | ##|# | */ 0x38, +/* | ##|# | */ 0x38, +/* | ##|# | */ 0x38 }; + + static UI8 gfx_arrowD[]={7,8, +/* | ##|# | */ 0x38, +/* | ##|# | */ 0x38, +/* | ##|# | */ 0x38, +/* | ##|# | */ 0x38, +/* |####|### | */ 0xFE, +/* | ###|## | */ 0x7C, +/* | ##|# | */ 0x38, +/* | #| | */ 0x10 }; + + static UI8 gfx_plus[]={7,7, +/* | ##|# | */ 0x38, +/* | # #| # | */ 0x54, +/* |# #| # | */ 0x92, +/* |####|### | */ 0xFE, +/* |# #| # | */ 0x92, +/* | # #| # | */ 0x54, +/* | ##|# | */ 0x38 }; + + static UI8 gfx_minus[]={7,7, +/* | ##|# | */ 0x38, +/* | # | # | */ 0x44, +/* |# | # | */ 0x82, +/* |####|### | */ 0xFE, +/* |# | # | */ 0x82, +/* | # | # | */ 0x44, +/* | ##|# | */ 0x38 }; +#endif /* CUSTOM_SEP */ + + +/*--------------------------------------------------------------------------*/ + +/* icon width */ +#define icon_W 20 + + static UI8 icon_spkr[]={8,6, +/* |### | ## | */ 0xE6, +/* |### |# # | */ 0xEA, +/* |####| # | */ 0xF2, +/* |####| # | */ 0xF2, +/* |### |# # | */ 0xEA, +/* |### | ## | */ 0xE6 }; + + static UI8 icon_vol[]={5,6, +/* | # | | */ 0x40, +/* |# # |# | */ 0xA8, +/* | #| | */ 0x10, +/* | # | | */ 0x40, +/* |# # |# | */ 0xA8, +/* | #| | */ 0x10 }; + + static UI8 icon_avol[]={5,6, +/* | | | */ 0x00, +/* | ###|# | */ 0x78, +/* | | | */ 0x00, +/* | ###|# | */ 0x78, +/* | | | */ 0x00, +/* | | | */ 0x00 }; + + static UI8 icon_balL[]={8,6, +/* |## |####| */ 0xCF, +/* |# # |####| */ 0xAF, +/* |# #|####| */ 0x9F, +/* |# #|####| */ 0x9F, +/* |# # |####| */ 0xAF, +/* |## |####| */ 0xCF }; + + static UI8 icon_sepL[]={8,6, +/* |## |# | */ 0xC8, +/* |# # |# | */ 0xA8, +/* |# #|# | */ 0x98, +/* |# #|# | */ 0x98, +/* |# # |# | */ 0xA8, +/* |## |# | */ 0xC8 }; + + static UI8 icon_balR[]={5,6, +/* |# #|# | */ 0x98, +/* |# # |# | */ 0xA8, +/* |## |# | */ 0xC8, +/* |## |# | */ 0xC8, +/* |# # |# | */ 0xA8, +/* |# #|# | */ 0x98 }; + + static UI8 icon_treb[]={5,6, +/* | # | | */ 0x20, +/* | # #| | */ 0x50, +/* |# |# | */ 0x88, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00 }; + + static UI8 icon_loud[]={5,6, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }; + + static UI8 icon_bass[]={5,6, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* |# |# | */ 0x88, +/* | # #| | */ 0x50, +/* | # | | */ 0x20 }; + + static UI8 icon_mdb[]={5,6, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* |####|# | */ 0xF8, +/* |####|# | */ 0xF8 }; + +/*--------------------------------------------------------------------------*/ + +/* font height */ +#define font_H 6 + +/* kerning (space between letters) */ +#define kern 1 + +static UI8 font[][2+6]={ +{4+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00 }, +{4+kern,font_H, +/* | ## | | */ 0x60, +/* | ## | | */ 0x60, +/* | ## | | */ 0x60, +/* | ## | | */ 0x60, +/* | | | */ 0x00, +/* | ## | | */ 0x60 }, +{6+kern,font_H, +/* | ## |## | */ 0x6C, +/* | ## |## | */ 0x6C, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* | # #| | */ 0x50, +/* |####|# | */ 0xF8, +/* | # #| | */ 0x50, +/* |####|# | */ 0xF8, +/* | # #| | */ 0x50 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# # |# | */ 0xA8, +/* |### | | */ 0xE0, +/* | ##|# | */ 0x38, +/* |# # |# | */ 0xA8, +/* | ###| | */ 0x70 }, +{6+kern,font_H, +/* |## |# | */ 0xC8, +/* |## #|# | */ 0xD8, +/* | #| | */ 0x10, +/* | # | | */ 0x20, +/* | ## |## | */ 0x6C, +/* | # |## | */ 0x4C }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# # |# | */ 0xA8, +/* |# ##| | */ 0xB0, +/* | ## |# | */ 0x68, +/* |# # | | */ 0xA0, +/* | ###|# | */ 0x78 }, +{4+kern,font_H, +/* | ##| | */ 0x30, +/* | ## | | */ 0x60, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00 }, +{4+kern,font_H, +/* | #| | */ 0x10, +/* | # | | */ 0x20, +/* | # | | */ 0x40, +/* | # | | */ 0x40, +/* | # | | */ 0x20, +/* | #| | */ 0x10 }, +{4+kern,font_H, +/* | # | | */ 0x40, +/* | # | | */ 0x20, +/* | #| | */ 0x10, +/* | #| | */ 0x10, +/* | # | | */ 0x20, +/* | # | | */ 0x40 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* |# |# | */ 0x88, +/* | # #| | */ 0x50, +/* |####|# | */ 0xF8, +/* | # #| | */ 0x50, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* |####|# | */ 0xF8, +/* | # | | */ 0x20, +/* | # | | */ 0x20 }, +{3+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | ## | | */ 0x60, +/* |## | | */ 0xC0 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* |####|# | */ 0xF8, +/* | | | */ 0x00, +/* | | | */ 0x00 }, +{4+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | ## | | */ 0x60, +/* | ## | | */ 0x60 }, +{6+kern,font_H, +/* | |## | */ 0x0C, +/* | #|# | */ 0x18, +/* | #|# | */ 0x18, +/* | ##| | */ 0x30, +/* | ##| | */ 0x30, +/* | ## | | */ 0x60 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* | # | | */ 0x20, +/* | ## | | */ 0x60, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* |####|# | */ 0xF8 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* | #| | */ 0x10, +/* | ## | | */ 0x60, +/* |# | | */ 0x80, +/* |####|# | */ 0xF8 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* | ##| | */ 0x30, +/* | |# | */ 0x08, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* | ##| | */ 0x30, +/* | # #| | */ 0x50, +/* |# #| | */ 0x90, +/* |####|# | */ 0xF8, +/* | #| | */ 0x10, +/* | #| | */ 0x10 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* |# | | */ 0x80, +/* |####| | */ 0xF0, +/* | |# | */ 0x08, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# | | */ 0x80, +/* |####| | */ 0xF0, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* | |# | */ 0x08, +/* | #| | */ 0x10, +/* | #| | */ 0x10, +/* | # | | */ 0x20, +/* | # | | */ 0x20 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###|# | */ 0x78, +/* | |# | */ 0x08, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* | ##| | */ 0x30, +/* | ##| | */ 0x30, +/* | | | */ 0x00, +/* | ##| | */ 0x30, +/* | ##| | */ 0x30 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* | ##| | */ 0x30, +/* | ##| | */ 0x30, +/* | | | */ 0x00, +/* | ##| | */ 0x30, +/* | ## | | */ 0x60 }, +{5+kern,font_H, +/* | #|# | */ 0x18, +/* | ## | | */ 0x60, +/* |# | | */ 0x80, +/* | ## | | */ 0x60, +/* | #|# | */ 0x18, +/* | | | */ 0x00 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* |####|# | */ 0xF8, +/* | | | */ 0x00, +/* |####|# | */ 0xF8, +/* | | | */ 0x00 }, +{5+kern,font_H, +/* | | | */ 0x00, +/* |## | | */ 0xC0, +/* | ##| | */ 0x30, +/* | |# | */ 0x08, +/* | ##| | */ 0x30, +/* |## | | */ 0xC0 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* | ##| | */ 0x30, +/* | # | | */ 0x20, +/* | | | */ 0x00, +/* | # | | */ 0x20 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# ##|# | */ 0xB8, +/* |# # |# | */ 0xA8, +/* |# ##| | */ 0xB0, +/* | # | | */ 0x40 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |####|# | */ 0xF8, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* |####| | */ 0xF0, +/* |# |# | */ 0x88, +/* |####| | */ 0xF0, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |####| | */ 0xF0 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* |####| | */ 0xF0, +/* | # |# | */ 0x48, +/* | # |# | */ 0x48, +/* | # |# | */ 0x48, +/* | # |# | */ 0x48, +/* |####| | */ 0xF0 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* |# | | */ 0x80, +/* |####| | */ 0xF0, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |####|# | */ 0xF8 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* |# | | */ 0x80, +/* |####| | */ 0xF0, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |# | | */ 0x80 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# | | */ 0x80, +/* |# #|# | */ 0x98, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |####|# | */ 0xF8, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* |####|# | */ 0xF8 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* |# # | | */ 0xA0, +/* | ## | | */ 0x60 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |# #| | */ 0x90, +/* |### | | */ 0xE0, +/* |# # | | */ 0xA0, +/* |# #| | */ 0x90, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |# | | */ 0x80, +/* |####|# | */ 0xF8 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |## #|# | */ 0xD8, +/* |# # |# | */ 0xA8, +/* |# |# | */ 0xA8, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |## |# | */ 0xC8, +/* |# # |# | */ 0xA8, +/* |# # |# | */ 0xA8, +/* |# #|# | */ 0x98, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* |####| | */ 0xF0, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |####| | */ 0xF0, +/* |# | | */ 0x80, +/* |# | | */ 0x80 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# # |# | */ 0xA8, +/* |# #| | */ 0x90, +/* | ###|# | */ 0x78 }, +{5+kern,font_H, +/* |####| | */ 0xF0, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |####| | */ 0xF0, +/* |# #| | */ 0x90, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* | ###| | */ 0x70, +/* |# |# | */ 0x88, +/* |### | | */ 0xE0, +/* | ##|# | */ 0x38, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | # #| | */ 0x50, +/* | # #| | */ 0x50, +/* | # | | */ 0x20, +/* | # | | */ 0x20 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* |# # |# | */ 0xA8, +/* |## #|# | */ 0xD8, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* | # #| | */ 0x50, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # #| | */ 0x50, +/* |# |# | */ 0x88 }, +{5+kern,font_H, +/* |# |# | */ 0x88, +/* |# |# | */ 0x88, +/* | ###| | */ 0x70, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x20 }, +{5+kern,font_H, +/* |####|# | */ 0xF8, +/* | #| | */ 0x10, +/* | # | | */ 0x20, +/* | # | | */ 0x20, +/* | # | | */ 0x40, +/* |####|# | */ 0xF8 } +}; + + /* used for "KHz" */ + static UI8 font_z[]={4+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* |####| | */ 0xF0, +/* | # | | */ 0x20, +/* | # | | */ 0x40, +/* |####| | */ 0xF0 }; + + /* used for "mS" */ + static UI8 font_m[]={5+kern,font_H, +/* | | | */ 0x00, +/* | | | */ 0x00, +/* | ###| | */ 0x70, +/* |# # |# | */ 0xA8, +/* |# # |# | */ 0xA8, +/* |# |# | */ 0x88 }; + + static UI8 gfx_db[]={9,font_H, +/* | | | | | */ 0x00, 0x00, +/* | #| ###| | | */ 0x17, 0x00, +/* | #| # |# | | */ 0x14, 0x80, +/* | ###| ###| | | */ 0x77, 0x00, +/* | # #| # |# | | */ 0x54, 0x80, +/* | ###| ###| | | */ 0x77, 0x00 }; + + +#include "mas.h" + + +/* + mono-l, mono-r, custom, karaoke, stereo wide, stereo, stereo narrow, mono, + mono l, mono r, karaoke, custom, stereo, stereo wide, stereo narrow, mono, + MONO_L, MONO_R, MONO, CUSTOM, ST, ST_N, ST_W, sKAR +*/ +#ifdef CUSTOM_SEP +enum sepMode {sMONO_LD, sMONO_L, sMONO_R, sMONO, sCUSTOM, sST, sST_N, sST_W, sKAR, sLOOP}; +#else +enum sepMode {sMONO_LD, sMONO_L, sMONO_R, sMONO, sST, sST_N, sST_W, sKAR, sLOOP}; +#endif + +enum Ycoord {yVOL, yAVOL, yBAL, ySEP, yTREB, yLOUD, yBASS, yMDB, yALL}; + +/* MAS registers */ +#define rVOL 0x10 +#define rBAL 0x11 +#define rAVOL MAS_REG_KAVC +#define rBASS 0x14 +#define rTREB 0x15 +#define rLOUD MAS_REG_KLOUDNESS +#define rMDB_SHAP MAS_REG_KMDB_SWITCH +#define rMDB_STR MAS_REG_KMDB_STR +#define rMDB_HAR MAS_REG_KMDB_HAR +#define rMDB_FC MAS_REG_KMDB_FC +#define rLL 0x7FC +#define rLR 0x7FE +#define rRL 0x7FD +#define rRR 0x7FF + +/* flags for stereo seperation stuff */ +#define aLL 0x01 +#define aLR 0x02 +#define aRL 0x04 +#define aRR 0x08 + +/* line height */ +#define line_H (font_H+2) + +/* Borders Left & Top */ +#define bordL 2 +#define bordT 1 + + +/******************************************************************** + * global stuff + * these options need to be saved between calls + * either to a file ...if it's a plugin + * or to the RTC RAM/Disk Sector + ********************************************************************/ +static struct Globals { + bool volhex; + bool balhex; + UI8 order[yALL]; +#ifdef CUSTOM_SEP + int sepMode; + UI32 cLL, cLR, cRL, cRR; + bool sephex; +#endif + +} globals; + + + +/******************************************************************** + * sim_init_regs + * l_mas_readreg + ********************************************************************/ +#ifdef SIMULATOR + +static UI16 mas_reg[0x100]; +static UI32 sepreg[4]; + + +/*************************************/ +static UI16 l_mas_readreg(int reg) +{ + return(mas_reg[reg]); +} + +/*************************************/ +static UI16 l_mas_writereg(int reg, UI16 val) +{ + mas_reg[reg] = val; + return(0); +} + +/*************************************/ +static int l_mas_readmem(int bank, int addr, unsigned long* dest, int len) +{ + (void)bank; + (void)len; + *dest = sepreg[addr-0x7fc]; + return(0); +} + +/*************************************/ +static int l_mas_writemem(int bank, int addr, unsigned long* src, int len) +{ + (void)bank; + (void)len; + sepreg[addr-0x7fc] = *src; + return(0); +} + + +/*************************************/ +/* This is called in SIM mode so that + * the registers have sensible values + */ +static void sim_init_regs(void) +{ + int i; + + for (i=0; i<0x100; i++) + mas_reg[i] = 0; + + mas_reg[rVOL ] = 0x7300; /* 0 dB */ + mas_reg[rBAL ] = 0x0000; /* -CENTRE- */ + mas_reg[rAVOL ] = 0x0000; /* OFF */ + mas_reg[rBASS ] = 0x0000; /* 0 dB */ + mas_reg[rTREB ] = 0x0000; /* 0 dB */ + mas_reg[rLOUD ] = 0x0000; /* 0 dB @ 1 KHz */ + mas_reg[rMDB_SHAP] = 0x0E00; /* */ + mas_reg[rMDB_STR ] = 0x0000; /* */ + mas_reg[rMDB_HAR ] = 0x6400; /* */ + mas_reg[rMDB_FC ] = 0x0900; /* */ + + sepreg[0] = 0x80000; + sepreg[1] = 0x00000; + sepreg[2] = 0x00000; + sepreg[3] = 0x80000; + + return; +} + +#else /* ! SIMULATOR */ + +/* This is done especially to add simulation support */ + +#define l_mas_readreg(reg) \ + ((UI16)rb->mas_codec_readreg(reg)) + +#define l_mas_writereg(reg, val) \ + ((UI16)rb->mas_codec_writereg(reg, val)) + +#define l_mas_readmem(bank, reg, pval, len) \ + (rb->mas_readmem(bank, reg, pval, len)) + +#define l_mas_writemem(bank, reg, pval, len) \ + (rb->mas_writemem(bank, reg, pval, len)) + +#endif /* SIMULATOR */ + + +/******************************************************************** + * read all seperation register + ********************************************************************/ +#define sep_readall \ +{ \ + l_mas_readmem(MAS_BANK_D0, rLL, &ll, 1); \ + l_mas_readmem(MAS_BANK_D0, rLR, &lr, 1); \ + l_mas_readmem(MAS_BANK_D0, rRL, &rl, 1); \ + l_mas_readmem(MAS_BANK_D0, rRR, &rr, 1); \ +} + + +/******************************************************************** + * As a plugin, this util will need to ensure the custom values + * are set up correctly + ********************************************************************/ +static void custom_default(void) +#ifndef IS_PLUGIN +{ + +#ifdef CUSTOM_SEP + globals.cLL = 0x80000; + globals.cLR = 0x00000; + globals.cRL = 0x00000; + globals.cRR = 0x80000; + globals.sepMode = sST; +#endif + + globals.volhex = false; + globals.balhex = false; + globals.sephex = false; + for (i=0; iL | L->R | R->L | R->R | + * | | D0:7FC | D0:7FD | D0:7FE | D0:7FF | + * |-----------------+--------+--------+--------+--------| + * | Mono | C0000 | C0000 | C0000 | C0000 | + * | Left-only | 80000 | 80000 | 00000 | 00000 | + * | Right-only | 00000 | 00000 | 80000 | 80000 | + * | | | | | | + * | Stereo-narrow | A0000 | E0000 | E0000 | A0000 | + * | @Stereo | 80000 | 00000 | 00000 | 80000 | + * | Stereo-wide | 80000 | 40000 | 40000 | 80000 | + * | | | | | | + * | Karaoke | 80001 | 7FFFF | 7FFFF | 80001 | Extreme Wide + * + * Values gratuitously stolen from Rockbox Source! + ********************************************************************/ + + /* Default Custom is Stereo */ + globals.cLL = 0x80000; + globals.cLR = 0x00000; + globals.cRL = 0x00000; + globals.cRR = 0x80000; + + sep_readall; + + if ( (ll==0x80000)&&(lr==0x00000)&& + (rl==0x00000)&&(rr==0x80000) ) globals.sepMode = sST; + + else if ( (ll==0xA0000)&&(lr==0xE0000)&& + (rl==0xE0000)&&(rr==0xA0000) ) globals.sepMode = sST_N; + + else if ( (ll==0x80000)&&(lr==0x40000)&& + (rl==0x40000)&&(rr==0x80000) ) globals.sepMode = sST_W; + + else if ( (ll==0x80001)&&(lr==0x7FFFF)&& + (rl==0x7FFFF)&&(rr==0x80001) ) globals.sepMode = sKAR; + + else if ( (ll==0x80000)&&(lr==0x80000)&& + (rl==0x00000)&&(rr==0x00000) ) globals.sepMode = sMONO_L; + + else if ( (ll==0x00000)&&(lr==0x00000)&& + (rl==0x80000)&&(rr==0x80000) ) globals.sepMode = sMONO_R; + + else if ( (ll==0xC0000)&&(lr==0xC0000)&& + (rl==0xC0000)&&(rr==0xC0000) ) globals.sepMode = sMONO; + + else if ( (ll==0x80000)&&(lr==0x80000)&& + (rl==0x80000)&&(rr==0x80000) ) globals.sepMode = sMONO_LD; + + else + { + globals.sepMode = sCUSTOM; + globals.cLL = ll; + globals.cLR = lr; + globals.cRL = rl; + globals.cRR = rr; + } +#endif /* CUSTOM_SEP */ + + globals.volhex = false; + globals.balhex = false; + globals.sephex = false; + for (i=0; i>(7-(px%8))) &1) ) + rb->lcd_drawpixel(x+px, y+py); + else + rb->lcd_clearpixel(x+px, y+py); + + rb->lcd_update_rect(x,y, mx, my); + + return(mx); +} + +/*==================================================================== + * return the ascii value of a character + */ +#define asc(c) ((c)-32) + +/*==================================================================== + * print an ascii char at x,y and return width + */ +#define print(x,y, chr) ( draw(x,y,font[asc(chr)]) ) + +/*==================================================================== + * print an ascii char at x,y and increment x by width + */ +#define printc(c) { x += print(x,y, (c)); } + +/*==================================================================== + * print an icon or graphic at x,y and increment x by width + */ +#define printi(i) { x += draw(x,y, (i)); } + +/*==================================================================== + * print an ascii string at x,y and return the width + */ +static UI8 printstr(UI8 x, UI8 y, char* s) +{ + UI8 tx = x; + while(*s) + printc(*s++); + return(x-tx); +} + +/*==================================================================== + * print an ascii string at x,y and increment x by width + */ +#define prints(s) { x += printstr(x,y, (s)); } + +/*==================================================================== + * cls! + */ +#define cls() \ +{ \ + rb->lcd_clear_display(); \ + rb->lcd_update(); \ +} + +/*==================================================================== + * show a value as a decimal number at x,y and return the last x coord + */ +static UI8 draw_dec_rec(UI8 x, UI8 y, UI16 val) +{ + if (val>9) x = draw_dec_rec(x,y, val/10); + printc('0'+(val%10)); + return(x); +} + +/*==================================================================== + * show a value as a decimal number at x,y and return the width + */ +#define draw_dec (draw_dec_rec(x,y, val) -x) + +/*==================================================================== + * show a value as a decimal number at x,y and increment x by width + */ +#define printd(v) { x = draw_dec_rec(x,y, (v)); } + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * Custom seperation screen specific screen io functions + */ +#ifdef CUSTOM_SEP + + /*==================================================================== + * due to an 32-bit ovreflow problem when trying to obtain a decimal + * convresion acurate to 3 decimal places we do this in two halves + * since it got complicated - this conversion has been turned into a + * function + * the value returned is the decimal value times 1000 + */ + static UI16 hex2dec(UI32 value) + { + /* nb. 820 * 10,000 > 0xFFFF'FFFF */ + + UI16 dec = 0; + UI32 max = 0x7FFFF; + + if (value&0x80000) + { + value = ((~value)+1)&0xFFFFF; + max = 0x80000; + } + if (value>=0x40000) + { + value -= 0x40000; + dec = 500; + } + dec += (((value*10000)/max)+5)/10; + + return (dec); + + } + + /*==================================================================== + * as hex2dec got turned into a function ...this is defined so that + * the code is more readable + * a decimal number should be a value 0...1000 which represents + * 0.000...1.000 * 1000 + */ + #define dec2hex(d) \ + (((value&0x80000)?(~((((0x80000*(d))+500)/1000)-1)):((0x7FFFF*(d))+500)/1000)&0xFFFFF) + + + /*==================================================================== + * draw decimal number in the range 0...1000 as a value/1000 + * and return the screen width in pixels + */ + static UI8 draw_dec_1_3(UI8 x, UI8 y, UI32 value) + { + + UI16 dec; + UI8 tx = x; + + dec = hex2dec(value); + + if (dec==1000) + { + printc('1') + dec -= 1000; + } + else + { + printc('0') + } + printc('.') + if (dec<100) printc('0'); + if (dec<10) printc('0'); + printd(dec); + + return(tx-x); + + } + + /*==================================================================== + * draw decimal number in the range 0...1000 as a value/1000 + * and increment x by the screen width in pixels + */ + #define printd_1_3(v) { x += draw_dec_1_3(x,y, (v)); } + +#endif /* CUSTOM_SEP */ + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * Custom seperation & MDB screen specific screen io functions + */ +#if defined(CUSTOM_SEP) || defined(CUSTOM_MDB) + + /*==================================================================== + * show a value as hex at x,y and return the last x coord + */ + static UI8 draw_hex_rec(UI8 x, UI8 y, UI32 val) + { + + if (val>15) x = draw_hex_rec(x,y, val/16); + + if ((val&0xF)>9) + return(draw(x,y, font[asc('A')+((val&0xF)-10)])); + else + return(draw(x,y, font[asc('0')+(val&0xF)])); + + } + + /*==================================================================== + * show a value as hex at x,y and return the width + */ + #define draw_hex (draw_hex_rec(x,y, val) -x) + + /*==================================================================== + * show a value as hex at x,y and increment x by the width + */ + #define printh(v) { x += draw_hex(x,y, (v)); } + + /*==================================================================== + * show a value as hex as "%05X" at x,y and increment x by the width + */ + #define printh05(v) { \ + int i; \ + for (i=(5-1)*4; i>=0; i-=4) \ + x += draw_hex_rec(x,y, ((v)>>i) &0xF); \ + } + + /*==================================================================== + * return the width of a string in pixels + */ + static UI8 pixlen(char* s) + { + + int i; + UI8 cnt = 0; + + for (i=0; s[i]; i++) + cnt += font[asc(s[i])][1]; + + return(cnt); + + } + + /*==================================================================== + * just a useful alias for pixlen + */ + + #define width(s) pixlen((s)) + +#endif /* defined(CUSTOM_SEP) || defined(CUSTOM_MDB) */ + + +/******************************************************************** + * find seperation mode from currnt values in MAS + ********************************************************************/ +#ifndef CUSTOM_SEP +static int sep_findmode(void) +{ + + UI32 ll, lr, rl, rr; + + sep_readall; + + if ( (ll==0x80000)&&(lr==0x00000)&& + (rl==0x00000)&&(rr==0x80000) ) return(sST); + else if ( (ll==0xA0000)&&(lr==0xE0000)&& + (rl==0xE0000)&&(rr==0xA0000) ) return(sST_N); + else if ( (ll==0x80000)&&(lr==0x40000)&& + (rl==0x40000)&&(rr==0x80000) ) return(sST_W); + else if ( (ll==0x80001)&&(lr==0x7FFFF)&& + (rl==0x7FFFF)&&(rr==0x80001) ) return(sKAR); + else if ( (ll==0x80000)&&(lr==0x80000)&& + (rl==0x00000)&&(rr==0x00000) ) return(sMONO_L); + else if ( (ll==0x00000)&&(lr==0x00000)&& + (rl==0x80000)&&(rr==0x80000) ) return(sMONO_R); + else if ( (ll==0xC0000)&&(lr==0xC0000)&& + (rl==0xC0000)&&(rr==0xC0000) ) return(sMONO); + else if ( (ll==0x80000)&&(lr==0x80000)&& + (rl==0x80000)&&(rr==0x80000) ) return(sMONO_LD); + + else return(sLOOP); + +} +#endif /* !CUSTOM_SEP */ + + +/******************************************************************** + * given a seperation mode, write the correct values to the register + ********************************************************************/ +static void sep_writemode(int mode) +{ + + UI32 ll, lr, rl, rr; + + switch(mode) + { + case sST: ll = rr = 0x80000; lr = rl = 0x00000; break; + case sST_N: ll = rr = 0xA0000; lr = rl = 0xE0000; break; + case sST_W: ll = rr = 0x80000; lr = rl = 0x40000; break; + case sKAR: ll = rr = 0x80001; lr = rl = 0x7FFFF; break; + case sMONO_L: ll = lr = 0x80000; rl = rr = 0x00000; break; + case sMONO_R: ll = lr = 0x00000; rl = rr = 0x80000; break; + case sMONO: ll = lr = rl = rr = 0xC0000; break; + case sMONO_LD: ll = lr = rl = rr = 0x80000; break; +#ifdef CUSTOM_SEP + case sCUSTOM: ll = globals.cLL; lr = globals.cLR; + rl = globals.cRL; rr = globals.cRR; break; +#endif + } + l_mas_writemem(MAS_BANK_D0, rLL, &ll, 1); + l_mas_writemem(MAS_BANK_D0, rLR, &lr, 1); + l_mas_writemem(MAS_BANK_D0, rRL, &rl, 1); + l_mas_writemem(MAS_BANK_D0, rRR, &rr, 1); + +#ifdef CUSTOM_SEP + globals.sepMode = mode; +#endif /* CUSTOM_SEP */ + + return; + +} + + +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + * This is the specific Seperation Customisation screen stuff + * This is a BIIIG #ifdef which would have been better in a different + * source file, but you cannot split your code with the plugin system + * This section is not indented so look for the next line of +++'s + */ +#ifdef CUSTOM_SEP + +/************************************************************** + * where to put all the icons + * reserve [10] pixels at the bottom of the screen for F-key help + * boxes have a border of [2] all around + * there are [5] chars per box + * a 2 pixel border is left on the top and left of the screen + */ + +#define boxB (2) +#define boxW (boxB+(5*pixlen("0"))+boxB-kern) +#define boxH (boxB+font_H+boxB) + +#define bord (2) +#define fGap (10) + +#define llX (0+bord) +#define llY (((LCD_HEIGHT-fGap-bord)-boxH)/2) + +#define lrX (((LCD_WIDTH-bord)-boxW)/2) +#define lrY ((LCD_HEIGHT-fGap-bord)-boxH) + +#define rlX (lrX) +#define rlY (0+bord) + +#define rrX ((LCD_WIDTH-bord)-boxW) +#define rrY (llY) + +#define lWavX (0+bord+4) +#define lWavY (((LCD_HEIGHT-fGap-bord)-gfx_bigL[1])-1) + +#define rWavX ((LCD_WIDTH-bord)-(gfx_waveIN[0]+gfx_bigR[0])-4) +#define rWavY (0+bord) + +#define lSpkrX (0+bord) +#define lSpkrY (0+bord-1) + +#define rSpkrX (((LCD_WIDTH-bord)-(gfx_spkrR[0]+gfx_waveOUT[0]))-2) +#define rSpkrY (((LCD_HEIGHT-fGap-bord)-gfx_spkrR[1])-1) + +#define plmX ((((LCD_WIDTH/3)-(gfx_plus[0]+pixlen("/")+gfx_minus[0])+1)/2)+((LCD_WIDTH/3)*2)+1) +#define plmY (LCD_HEIGHT-(font_H+2)) + +#define modeX ( (( (LCD_WIDTH/3)-pixlen(str_MODE) )/2) + (LCD_WIDTH/3) +1 ) +#define modeY plmY + +#define modeWide (pixlen(str_KARAOKE)) +#define modeHigh ((font_H+1)*2) +#define modeTLx ((LCD_WIDTH-pixlen(str_KARAOKE))/2) +#define modeTLy (((LCD_HEIGHT-fGap-2)/2)-(font_H+1)) + + +/******************************************************************** + * This apparently oversized procedure ONLY prints all the + * values on the seperation customisation screen + * returns the seperation "mode" (eg sCUSTOM) + ********************************************************************/ +static int sep_show_vals(UI32 ll, UI32 lr, UI32 rl, UI32 rr) +{ + UI8 x, y; + int mode; + + /* See if the registers match a known mode */ + if ( (ll==0x80000)&&(lr==0x00000)&& + (rl==0x00000)&&(rr==0x80000) ) mode = sST; + else if ( (ll==0xA0000)&&(lr==0xE0000)&& + (rl==0xE0000)&&(rr==0xA0000) ) mode = sST_N; + else if ( (ll==0x80000)&&(lr==0x40000)&& + (rl==0x40000)&&(rr==0x80000) ) mode = sST_W; + else if ( (ll==0x80001)&&(lr==0x7FFFF)&& + (rl==0x7FFFF)&&(rr==0x80001) ) mode = sKAR; + else if ( (ll==0x80000)&&(lr==0x80000)&& + (rl==0x00000)&&(rr==0x00000) ) mode = sMONO_L; + else if ( (ll==0x00000)&&(lr==0x00000)&& + (rl==0x80000)&&(rr==0x80000) ) mode = sMONO_R; + else if ( (ll==0xC0000)&&(lr==0xC0000)&& + (rl==0xC0000)&&(rr==0xC0000) ) mode = sMONO; + else if ( (ll==0x80000)&&(lr==0x80000)&& + (rl==0x80000)&&(rr==0x80000) ) mode = sMONO_LD; + else mode = sCUSTOM; + + /* display the mode string in the middle of the screen */ + rb->lcd_clearrect(modeTLx,modeTLy, modeWide,modeHigh); + y = ((LCD_HEIGHT-10-2)-font_H)/2; + switch(mode) + { + case sST: x = (LCD_WIDTH-pixlen(str_STEREO))/2; + prints(str_STEREO); + break; + case sST_N: x = (LCD_WIDTH-pixlen(str_STEREO))/2; + y = ((LCD_HEIGHT-fGap-2)/2)-(font_H+1); + prints(str_STEREO); + x = (LCD_WIDTH-pixlen(str_NARROW))/2; + y += font_H+2; + prints(str_NARROW); + break; + case sST_W: x = (LCD_WIDTH-pixlen(str_STEREO))/2; + y = ((LCD_HEIGHT-fGap-2)/2)-(font_H+1); + prints(str_STEREO); + x = (LCD_WIDTH-pixlen(str_WIDE))/2; + y += font_H+2; + prints(str_WIDE); + break; + case sKAR: x = (LCD_WIDTH-pixlen(str_KARAOKE))/2; + prints(str_KARAOKE); + break; + case sMONO: x = (LCD_WIDTH-pixlen(str_MONO))/2; + prints(str_MONO); + break; + case sMONO_LD: x = (LCD_WIDTH-pixlen(str_MONO))/2; + y = ((LCD_HEIGHT-fGap-2)/2)-(font_H+1); + prints(str_MONO); + x = (LCD_WIDTH-pixlen(str_LOUD))/2; + y += font_H+2; + prints(str_LOUD); + break; + case sMONO_L: x = (LCD_WIDTH-pixlen(str_MONO))/2; + y = ((LCD_HEIGHT-fGap-2)/2)-(font_H+1); + prints(str_MONO); + x = (LCD_WIDTH-pixlen(str_LEFT))/2; + y += font_H+2; + prints(str_LEFT); + break; + case sMONO_R: x = (LCD_WIDTH-pixlen(str_MONO))/2; + y = ((LCD_HEIGHT-fGap-2)/2)-(font_H+1); + prints(str_MONO); + x = (LCD_WIDTH-pixlen(str_RIGHT))/2; + y += font_H+2; + prints(str_RIGHT); + break; + case sCUSTOM: x = (LCD_WIDTH-pixlen(str_CUSTOM))/2; + prints(str_CUSTOM); + break; + default: x = 0; y = 0; break; /* avoid compiler warnings */ + } + + /* Display all +/-'s and adjust values */ + /*************/ + if (ll&0x80000) + { + draw(llX+(boxW/2)-(gfx_minus[0]/2),llY+boxH+3, gfx_minus); + x = llX+boxB; y = llY+boxB; + if (globals.sephex) + { + ll = ((~ll)+1)&0xFFFFF; + printh05(ll) + } + else + { + printd_1_3(ll) + } + } + else + { + draw(llX+(boxW/2)-(gfx_plus[0]/2),llY+boxH+3, gfx_plus); + x = llX+boxB; y = llY+boxB; + if (globals.sephex) + printh05(ll) + else + printd_1_3(ll) + } + + /*************/ + if (lr&0x80000) + { + draw(lrX-3-gfx_minus[0],lrY+(boxH/2)-(gfx_minus[1]/2), gfx_minus); + x = lrX+boxB; y = lrY+boxB; + if (globals.sephex) + { + lr = ((~lr)+1)&0xFFFFF; + printh05(lr) + } + else + { + printd_1_3(lr) + } + } + else + { + draw(lrX-3-gfx_plus[0],lrY+(boxH/2)-(gfx_plus[1]/2), gfx_plus); + x = lrX+boxB; y = lrY+boxB; + if (globals.sephex) + printh05(lr) + else + printd_1_3(lr) + } + + /*************/ + if (rl&0x80000) + { + draw(rlX+boxW+3,rlY+(boxH/2)-(gfx_minus[1]/2), gfx_minus); + x = rlX+boxB; y = rlY+boxB; + if (globals.sephex) + { + rl = ((~rl)+1)&0xFFFFF; + printh05(rl) + } + else + { + printd_1_3(rl) + } + } + else + { + draw(rlX+boxW+3,rlY+(boxH/2)-(gfx_plus[1]/2), gfx_plus); + x = rlX+boxB; y = rlY+boxB; + if (globals.sephex) + printh05(rl) + else + printd_1_3(rl) + } + + /*************/ + if (rr&0x80000) + { + draw(rrX+(boxW/2)-(gfx_minus[0]/2),rrY-3-gfx_minus[1], gfx_minus); + x = rrX+boxB; y = rrY+boxB; + if (globals.sephex) + { + rr = ((~rr)+1)&0xFFFFF; + printh05(rr) + } + else + { + printd_1_3(rr) + } + } + else + { + draw(rrX+(boxW/2)-(gfx_plus[0]/2),rrY-3-gfx_plus[1], gfx_plus); + x = rrX+boxB; y = rrY+boxB; + if (globals.sephex) + printh05(rr) + else + printd_1_3(rr) + } + + /* F1 action */ + rb->lcd_clearrect( 0,LCD_HEIGHT-9, 36,9); + if (globals.sephex) + printstr((36-pixlen(str_DEC))/2,LCD_HEIGHT-8, str_DEC); + else + printstr((36-pixlen(str_HEX))/2,LCD_HEIGHT-8, str_HEX); + rb->lcd_invertrect( 0,LCD_HEIGHT-9, 36,9); + + + rb->lcd_update(); + return(mode); + +} + + +/******************************************************************** + * display the main seperation screen icons etc. + ********************************************************************/ +static void sep_show_screen(void) +{ + + UI8 x, y; + + /* number boxes */ + rb->lcd_drawrect(llX,llY, boxW,boxH); + rb->lcd_drawrect(lrX,lrY, boxW,boxH); + rb->lcd_drawrect(rlX,rlY, boxW,boxH); + rb->lcd_drawrect(rrX,rrY, boxW,boxH); + + /* L & R wav */ + x = lWavX; y = lWavY; printi(gfx_bigL); printi(gfx_waveIN); + x = rWavX; y = rWavY; printi(gfx_bigR); printi(gfx_waveIN); + + /* L & R speakers */ + x = lSpkrX; y = lSpkrY; printi(gfx_waveOUT); printi(gfx_spkrL); + x = rSpkrX; y = rSpkrY; printi(gfx_spkrR); printi(gfx_waveOUT); + + /* arrows */ + draw(llX+(boxW/2)-(gfx_arrowU[0]/2),llY-3-gfx_arrowU[1], gfx_arrowU); + draw(rrX+(boxW/2)-(gfx_arrowD[0]/2),rrY+boxH+3, gfx_arrowD); + + draw(lrX+boxW+3, lrY+(boxH/2)-(gfx_arrowR[1]/2), gfx_arrowR); + draw(rlX-3-gfx_arrowL[0],rlY+(boxH/2)-(gfx_arrowL[1]/2), gfx_arrowL); + + /* F2 action */ + x = modeX; y = modeY; prints(str_MODE); + rb->lcd_invertrect(38,LCD_HEIGHT-9, 36,9); + + /* F3 action */ + x = plmX; y = plmY; + printi(gfx_minus); printc('/'); printi(gfx_plus); + rb->lcd_invertrect(76,LCD_HEIGHT-9, 36,9); + + rb->lcd_update(); + + return; + +} + + +/******************************************************************** + * hilite a number + ********************************************************************/ +static void sep_hinum(UI8 active, UI8 digit, bool onoff) +{ + static bool ison = false; + + UI8 tlx, tly; + + switch(active) + { + case aLL: tlx = llX+1; tly = llY+1; break; + case aLR: tlx = lrX+1; tly = lrY+1; break; + case aRL: tlx = rlX+1; tly = rlY+1; break; + case aRR: tlx = rrX+1; tly = rrY+1; break; + default: tlx = 0; tly = 0; break; /* avoid compiler warnings */ + } + + if (ison!=onoff) + { + rb->lcd_invertrect(tlx+((4-digit)*pixlen("0")),tly, + (pixlen("0"))+1,(font_H)+2); + + rb->lcd_update_rect(tlx+((4-digit)*pixlen("0")),tly, + (pixlen("0"))+1,(font_H)+2); + ison = (ison)?false:true; + } + + return; + +} + + +/******************************************************************** + * hilite a box + ********************************************************************/ +static void sep_hibox(UI8 active, bool on) +{ + + UI8 x, y; + UI8 tlx, tly; + + switch(active) + { + case aLL: tlx = llX-2; tly = llY-2; break; + case aLR: tlx = lrX-2; tly = lrY-2; break; + case aRL: tlx = rlX-2; tly = rlY-2; break; + case aRR: tlx = rrX-2; tly = rrY-2; break; + default: tlx = 0; tly = 0; break; /* avoid compiler warnings */ + } + + for(y=0; y<(boxH+4); y++) + for(x=0; x<(boxW+4); x++) + if ( (!( ( (y>1)&&(y1)&&(xlcd_drawpixel(tlx+x,tly+y); + else + rb->lcd_clearpixel(tlx+x,tly+y); + } + + rb->lcd_update_rect(tlx, tly, boxW+4,boxH+4); + + return; + +} + + +/******************************************************************** + * This is where we end up when the user presses PLAY on the + * seperation option + ********************************************************************/ +static bool sep_custom(void) +{ + + UI32 ll, lr, rl, rr; + + int mode; + int key; + + UI8 active; + UI32 value; + + bool edit = false; + bool regupd = false; + UI8 digit = 0; + + cls(); + sep_show_screen(); + + sep_readall; + + active = aLL; + value = ll; + + while(true) + { + sep_hinum(active, digit, false); + mode = sep_show_vals(ll, lr, rl, rr); + sep_hibox(active, true); + sep_hinum(active, digit, edit); + key = rb->button_get(true); + sep_hinum(active, digit, false); + + switch(key) + { + case BUTTON_OFF: + if (!edit) + return(false); /* quit screen no save */ + else + edit = false; /* stop editing */ + + case BUTTON_ON: + if (!edit) + { + /* store these values as the new CUSTOM values */ + globals.cLL = ll; globals.cLR = lr; + globals.cRL = rl; globals.cRR = rr; + return(true); /* quit screen request save */ + } + else + break; + + /* cursor up */ + case BUTTON_UP: + case BUTTON_UP | BUTTON_REPEAT: + case BUTTON_UP | BUTTON_ON: + case BUTTON_UP | BUTTON_ON | BUTTON_REPEAT: + if (!edit) /* move highlight box */ + { + if (active!=aRL) + { + sep_hibox(active, false); + active = aRL; + value = rl; + } + } + else /* increase digit */ + { + if (globals.sephex) + { + if (value&0x80000) /* negative value */ + { + if (key&BUTTON_ON) /* max out value */ + value = 0x80000; + else /* increment digit */ + if ( (value>>(4*digit)) > (UI32)(0x80000>>(4*digit)) ) + value -= 1<<(4*digit); + } + else /* positive value */ + { + if (key&BUTTON_ON) /* max out value */ + value = 0x7FFFF; + else /* increment digit */ + if ( (value>>(4*digit)) < (UI32)(0x7FFFF>>(4*digit)) ) + value += 1<<(4*digit); + } + } + else /* decimal mode */ + { + I16 dec = hex2dec(value); /* returns value 0...1000 */ + dec = (digit==4)?1000:(dec+((!digit)?1:((digit<2)?10:100))); + if (dec<=1000) + value = dec2hex(dec); + } + regupd = true; /* trigger write to MAS */ + } + break; + + /* cursor down */ + case BUTTON_DOWN: + case BUTTON_DOWN | BUTTON_REPEAT: + case BUTTON_DOWN | BUTTON_ON: + case BUTTON_DOWN | BUTTON_ON | BUTTON_REPEAT: + if (!edit) /* hilite bottom box */ + { + if (active!=aLR) + { + sep_hibox(active, false); + active = aLR; + value = lr; + } + } + else /* decrement value */ + { + if (globals.sephex) + { + if (value&0x80000) /* negative */ + { + if (key&BUTTON_ON) + value = 0xFFFFF; /* min out */ + else /* decrement digit */ + if ( (value>>(4*digit)) < (UI32)(0xFFFFF>>(4*digit)) ) + value += 1<<(4*digit); + } + else /* positive value */ + { + if (key&BUTTON_ON) + value = 0; /* min out */ + else /* decrement digit */ + if ( (value>>(4*digit)) > 0) + value -= 1<<(4*digit); + } + } + else /* decimal mode */ + { + I16 dec = hex2dec(value); /* returns value 0...1000 */ + dec = (digit==4)?0:(dec-((!digit)?1:((digit<2)?10:100))); + if (dec>0) /* <0 is ignored */ + value = dec2hex(dec); + else if (dec==0) /* zero is actually 1 if negative */ + value = (value&0x80000)?0xFFFFF:0; + } + } + regupd = true; /* trigger write to MAS */ + break; + + /* cursor left */ + case BUTTON_LEFT: + case BUTTON_LEFT | BUTTON_REPEAT: + if (!edit) /* different box */ + { + if (active!=aLL) + { + sep_hibox(active, false); + active = aLL; + value = ll; + } + } + else /* different digit within a box */ + { + if (digit<4) + digit++; + if ((!globals.sephex) && digit==3) digit = 4; + } + break; + + /* cursor right */ + case BUTTON_RIGHT: + case BUTTON_RIGHT | BUTTON_REPEAT: + if (!edit) /* different box */ + { + if (active!=aRR) + { + sep_hibox(active, false); + active = aRR; + value = rr; + } + } + else /* different digit within a box */ + { + if (digit) + digit--; + if (!(globals.sephex) && digit==3) digit = 2; + } + break; + + /* toggle wave inversion */ + case BUTTON_F3: + if (value&0x80000) /* was negative */ + { + /* careful at the extremes */ + if (value==0x80000) /* obligatory */ + value = 0x7FFFF; + else if (value==0xFFFFF) /* cursory */ + value = 0x00000; + else + value = ((~value)+1) &0xFFFFF; /* 2's comp - -> + */ + } + else + { + /* careful at the extremes */ + if (value==0x00000) /* obligatory */ + value = 0xFFFFF; + else if (value==0x7FFFF) /* cursory */ + value = 0x80000; + else + value = (~(value-1)) &0xFFFFF; /* 2's comp + -> - */ + } + regupd = true; /* trigger write to MAS */ + break; + + /* toggle edit mode */ + case BUTTON_PLAY: + edit = (edit)?false:true; + break; + + /* toggle hex/dec mode */ + case BUTTON_F1: + globals.sephex = (globals.sephex)?false:true; + break; + + /* select from default modes */ + case BUTTON_F2: + if (mode>=sLOOP-1) + mode = 0; + else + mode++; + sep_writemode(mode); + sep_readall; + break; + + default: + break; + } /* case key */ + + /* write new value to MAS register if requested up up/down/f3 */ + if (regupd) + { + switch(active) + { + case aLL: ll = value; + l_mas_writemem(MAS_BANK_D0, rLL, &ll, 1); + break; + case aLR: lr = value; + l_mas_writemem(MAS_BANK_D0, rLR, &lr, 1); + break; + case aRL: rl = value; + l_mas_writemem(MAS_BANK_D0, rRL, &rl, 1); + break; + case aRR: rr = value; + l_mas_writemem(MAS_BANK_D0, rRR, &rr, 1); + break; + default: break; + } + regupd = false; + } + + + } /* while 1 */ + +} + +#endif /* CUSTOM_SEP */ +/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ + +/******************************************************************** + * hilite line on main screen + ********************************************************************/ +static void main_hiline(int line, bool onoff) +{ + + static bool ison = false; + + UI8 y = (bordT+(line*line_H)); + + if (1) /* highlight line */ + { + if (ison!=onoff) + { + rb->lcd_invertrect(bordL-1,y-1, 110,line_H); + rb->lcd_update_rect(bordL-1,y-1, 110,line_H); + ison = (ison)?false:true; + } + } + else /* little arrow head */ + { + if (onoff) + { + /* draw arrow head */ + } + else + { + /* remove arrow head */ + } + } + + return; + +} + + +/******************************************************************** + * show a single line of the main screen + * if yALL is specified, this procedure will redraw ALL lines + ********************************************************************/ +static void main_show_line(int line, int top) +{ + + if (line==yALL) + { + int line; + +#ifdef CAN_SCROLL + #error "HELP ME MAKE A NEW FONT FOR ROCKBOX AND I WILL WRITE SCROLLING CODE" +#else + (void)top; + for(line=0; linelcd_clearrect(0,y-1, LCD_WIDTH,line_H); + switch(icon) + { + case yVOL: /* ---------------------------------------------- */ + { + printi(icon_spkr); + printi(icon_vol); + x = bordL+icon_W; + + val = l_mas_readreg(rVOL); + val >>= 8; + if (!val) + { + prints("-"str_MUTE"-"); + } + else + { + if (globals.volhex) + { + if (val<0x73) /* 0x73 is 0 dB */ + { + printc('-'); + val = 0x73-val; + } + else + { + val -= 0x73; + } + printd(val); + printi(gfx_db); + } + else + { + /* from 70..100 we use 1dB steps */ + if (val>=0x61) /* 0x61 is -18 dB == 70% */ + printd(100-(127-val)) + /* below 70% we use a linear scale */ + else + printd( (((val*1000)/(9700/70))+5)/10 ) + printc('%') + /* flag up LINE OUT mode */ + if (val==0x73) val = 0; + } + if (!val) + prints(" "str_LINE_OUT); + } + + break; + } + case yAVOL: /* ---------------------------------------------- */ + { + printi(icon_spkr); + printi(icon_avol); + x = bordL+icon_W; + + val = l_mas_readreg(rAVOL); + val >>= 8; + + if (!(val&0x80)) /* top bit ie ENABLE */ + { + prints(str_OFF); + } + else + { + switch (val&0xF) + { + case 1: printd(20); + x++; printi(font_m); + break; + case 2: + case 4: + case 8: printd(val&0xF); + x += 2; + } + printc('S'); + + } + break; + } + + case yBAL: /* ---------------------------------------------- */ + { + val = l_mas_readreg(rBAL); + val >>= 8; + + printi(icon_balL); + printi(icon_balR); + x = bordL+icon_W; + + if (!val) /* centre */ + { + prints(str_CENTRE); + } + else + { + if (globals.balhex) + { + if (val&0x80) /* right fade */ + { + val = ((~val)+1) &0xFF; + prints(str_NORM" : "); + if (val) + { + if (val==128) + { + prints(str_MUTE); + } + else + { + printc('-'); + printd(val); + printi(gfx_db); + } + } + } + else /* left fade */ + { + if (val) + { + if (val==127) + { + prints(str_MUTE); + } + else + { + printc('-'); + printd(val); + printi(gfx_db); + } + } + prints(" : "str_NORM); + } + } + else /* !volhex */ + { + I8 ival = (I8)val; + UI8 dec = abs(ival); + if (dec>20) + dec = (((((dec-20)*10000)/(((ival<0)?(108000):(107000))/80))+5)/10)+20; + + prints((val&0x80)?(str_LEFT": "):(str_RIGHT": ")); + printd(dec); + printc('%'); + } + } + + break; + } + case ySEP: /* ---------------------------------------------- */ + { + printi(icon_sepL); + printi(icon_balR); + x = bordL+icon_W; + +/* if we are not supporting custom we need to read the regs and work out + what mode we are in. + by supporting the custom mode, we will already have stored the current + working mode in the "globals" area. */ +#ifdef CUSTOM_SEP + switch (globals.sepMode) +#else + switch(sep_findmode(ll,lr,rl,rr)) +#endif /* CUSTOM_SEP */ + { + case sST: prints(str_STEREO); + break; + case sST_N: prints(str_STEREO); prints("-"str_NARROW); + break; + case sST_W: prints(str_STEREO); prints("-"str_WIDE); + break; + case sKAR: prints(str_KARAOKE); + break; + case sMONO: prints(str_MONO); + break; + case sMONO_LD: prints(str_MONO); prints("-"str_LOUD); + break; + case sMONO_L: prints(str_MONO); prints("-"str_LEFT); + break; + case sMONO_R: prints(str_MONO); prints("-"str_RIGHT); + break; +#ifdef CUSTOM_SEP + case sCUSTOM: prints(str_CUSTOM); + break; +#endif /* CUSTOM_SEP */ + } + break; + } + case yBASS: /* ---------------------------------------------- */ + case yTREB: /* ---------------------------------------------- */ + { + /* display the right icon and read the right register */ + if (icon==yBASS) + { + printi(icon_spkr); + printi(icon_bass); + val = l_mas_readreg(rBASS); + } + else + { + printi(icon_spkr); + printi(icon_treb); + val = l_mas_readreg(rTREB); + } + x = bordL+icon_W; + val >>= 8; + + /* decimal output is same for both */ + if (val>=0xA0) + { + val = ((~val)+1) &0xFF; + printc('-'); + } + + /* eigths */ + whole = val>>3; + frac = (val&0x7)*125; + while(frac&&(!(frac%10))) frac /= 10; + + printd(whole) + if (frac) + { + printc('.'); + printd(frac); + } + printi(gfx_db); + + break; + } + case yLOUD: /* ---------------------------------------------- */ + { + char centre; + + printi(icon_spkr); + printi(icon_loud); + x = bordL+icon_W; + + val = l_mas_readreg(rLOUD); + if (val&0x4) + centre = '2'; + else + centre = '1'; + val >>= 8; + + /* quarters */ + whole = val>>2; + frac = (val&0x3)*25; + while(frac&&(!(frac%10))) frac /= 10; + + printd(whole) + if (frac) + { + printc('.'); + printd(frac); + } + printi(gfx_db); + + /* centre frequency */ + prints(" @ "); + printc(centre) + x++; prints("KH"); printi(font_z); + + break; + } + case yMDB: /* ---------------------------------------------- */ + { + UI16 har = l_mas_readreg(rMDB_HAR); /* shift is not required */ + UI16 shap = l_mas_readreg(rMDB_SHAP); /* we need the LSB for on/off */ + + UI16 str = l_mas_readreg(rMDB_STR) >>8; + UI8 dec = (((str*1000)/127)+5)/10; /* value as linear percentage */ + + UI16 fc = l_mas_readreg(rMDB_FC) >>8; + UI16 expected = ((fc*15)+5)/10; + if (expected>30) expected = 30; + if (expected<5) expected = 5; + + printi(icon_spkr); + printi(icon_mdb); + x = bordL+icon_W; + + if (shap&2) + { + printd(dec) + prints("% @") + } + else + { + prints(str_OFF" @") + } + printd(fc*10) + prints("H") + printi(font_z) + if ( (har) || ((shap>>8)!=expected) || (dec%5) ) + prints(" "str_CUSTOM2) /* custom setup */ + + break; + } + } + + rb->lcd_update_rect(0,y-1, 112,line_H); + + } + + return; + +} + + +/******************************************************************** + * update register + * + * 00 10 Volume 00(00)..7F(00) @73: 0dB (step=1dB) + * + * 00 11 Balance 80(00)..00(00)..7F(00) 80: L=0 R=-128 + * @00: L=0 R=0 + * 7F: L=-127 R=0 + * + * 00 12 Auto Volume xy(00) @x=0: OFF y=1: 20mS + * x=8: ON y=2: 2S + * *y=4: 4S + * y=8: 8S + * Must off/on between tracks + * + * 00 14 Bass A0(00)..00(00)..60(00) A0: -12dB + * @00: 0dB + * 60: 12dB + * step.1 ~= 0.125dB + * step.8 == 1dB + * + * 00 15 Treble A0(00)..00(00)..60(00) A0: -12dB + * @00: 0dB + * 60: 12dB + * step.1 ~= 0.125dB + * step.8 == 1dB + * + * 00 1E Loudness 00(xx)..44(xx) @00: 0dB + * step.1 ~= 0.25dB + * step.4 == 1dB + * @xx=0: Centre=1KHz + * xx=4: Centre=2KHz + * + * 00 21 MDB Shape 05(xx)..30(xx) Close to FC = Hard Bass + * @1.5 * FC [00'24] + * @xx=0: OFF + * xx=2: ON + * + * 00 22 MDB STRength 00(00)..7F(00) 00: OFF + * @40: Medium + * ((0x1 = 1dB)) + * + * 00 23 MDB HARmonics 00(00)..7F(00) @00: 100% Fundamentals + * 64: 50% fund + 50% harm + * 7F: 100% Harmonics + * + * 00 24 MDB Freq Centre 02(00)..30(00) f = n*10 + * @9 = 90Hz (cheap speakers) + * Set to speaker cut-off + * + ********************************************************************/ +static bool main_upd_reg(int line, int key) +{ + + UI16 val; + + bool retval = false; /* redraw main screen required? */ + + int icon = globals.order[line]; + + switch(icon) + { + case yVOL: /* ------------------------------------------------ */ + if (key&BUTTON_PLAY) + { + globals.volhex = (globals.volhex)?false:true; + } + else + { + UI8 dec; + + val = l_mas_readreg(rVOL); + val >>= 8; + + dec = (val>=0x61)?(val-27):((((val*1000)/(9700/70))+5)/10); + + if (key&BUTTON_LEFT) + { + if (key&BUTTON_ON) + { + val = 0; + dec = 0; + } + else + { + if (val) + { + val--; + dec--; + } + } + } + else if (key&BUTTON_RIGHT) + { + if (val<0x7F) + { + val++; + dec++; + } + } + else if (key&BUTTON_F3) + { +#ifdef DEFAULT_VOLUME_IS_LINE_LEVEL + val = 0x73; + dec = 88; +#else + val = 0x73 -12; /* -12dB */ + dec = 88 -12; +#endif + } + + if (!globals.volhex) + val = (dec>=70)?(dec+27):((dec*(9700/70)+50)/100); + + val <<= 8; + l_mas_writereg(rVOL, val); + } + break; + case yAVOL: /* ------------------------------------------------ */ + val = l_mas_readreg(rAVOL); + val >>= 8; + if (key&BUTTON_LEFT) + { + switch(val&0xF) + { + case 1: val = 0x00; break; + case 2: val = 0x81; break; + case 4: val = 0x82; break; + case 8: val = 0x84; break; + default: break; + } + } + else if (key&BUTTON_RIGHT) + { + switch(val&0xF) + { + case 0: val = 0x81; break; + case 1: val = 0x82; break; + case 2: val = 0x84; break; + case 4: val = 0x88; break; + default: break; + } + } + else if (key&BUTTON_F3) + { + val = 0x00; + } + val <<= 8; + l_mas_writereg(rAVOL, val); + break; + case yBAL: /* ------------------------------------------------ */ + { + I8 ival; + UI8 dec; + + val = l_mas_readreg(rBAL); + + ival = (I8)(val>>8); + dec = abs(ival); + if (dec>20) + dec = (((((dec-20)*10000)/(((ival<0)?(108000):(107000))/80))+5)/10)+20; + + if (key&BUTTON_PLAY) + { + globals.balhex = (globals.balhex)?false:true; + } + else if (key&BUTTON_LEFT) + { + if (key&BUTTON_ON) + { + ival = -128; + } + else + { + if (ival>-128) + { + ival--; + if (!globals.balhex) + { + UI8 newdec = abs(ival); + newdec = (newdec<=20)?(newdec): + (((((newdec-20)*10000)/(((ival<0)?(108000):(107000))/80))+5)/10)+20; + if (dec==newdec) ival--; + } + } + } + } + else if (key&BUTTON_RIGHT) + { + if (key&BUTTON_ON) + { + ival = 127; + } + else + { + if (ival<127) + { + ival++; + if (!globals.balhex) + { + UI8 newdec = abs(ival); + newdec = (newdec<=20)?(newdec): + (((((newdec-20)*10000)/(((ival<0)?(108000):(107000))/80))+5)/10)+20; + if (dec==newdec) ival++; + } + } + } + } + else if (key&BUTTON_F3) + { + ival = 0x00; + dec = 0; + } + + + val = ((UI16)ival)<<8; + l_mas_writereg(rBAL, val); + + + break; + } + case ySEP: /* ------------------------------------------------ */ + { + int mode; + +#ifdef CUSTOM_SEP + mode = globals.sepMode; +#else + mode = sep_findmode(); +#endif /* CUSTOM_SEP */ + + if (key&BUTTON_LEFT) + { + if (key&BUTTON_ON) + { + mode = sMONO; + } + else + { + if (mode) + mode--; + else + mode = sLOOP-1; + } + } + else if (key&BUTTON_RIGHT) + { + if (key&BUTTON_ON) + { + mode = sKAR; + } + else + { + if (mode<(sLOOP-1)) + mode++; + else + mode = 0; + } + } + else if (key&BUTTON_F3) + { + mode = sST; + } + +#ifdef CUSTOM_SEP + else if (key&BUTTON_PLAY) + { + if (sep_custom()) /* on returns true if user exist with ON key */ + mode = sCUSTOM; + retval = true; /* redraw main screen required */ + } +#endif /* CUSTOM_SEP */ + sep_writemode(mode); + break; + } + case yBASS: /* ------------------------------------------------ */ + case yTREB: /* ------------------------------------------------ */ + { + I8 ival; + UI16 reg; + + if (icon==yBASS) + reg = rBASS; + else + reg = rTREB; + + val = l_mas_readreg(reg); + ival = (I8)(val>>8); + + if (key&BUTTON_LEFT) + { + if (key&BUTTON_ON) + { + if (ival>-96) ival--; + } + else + { + if (abs(ival)&7) + ival &= 0xF8; + else + if (ival>-96) ival -= 8; + } + } + else if (key&BUTTON_RIGHT) + { + if (key&BUTTON_ON) + { + if (ival<96) ival++; + } + else + { + ival &= 0xF8; + if (ival<96) ival += 8; + } + } + else if (key&BUTTON_F3) + { + ival = 0; + } + + val = ((UI16)ival)<<8; + l_mas_writereg(reg, val); + + break; + } + case yLOUD: /* ------------------------------------------------ */ + { + UI16 flag2k; + + val = l_mas_readreg(rLOUD); + flag2k = val&0x04; + val >>= 8; + + if (key&BUTTON_LEFT) + { + if (key&BUTTON_ON) + { + if (val) val--; + } + else + { + if (val&0x3) + val &= 0xFC; + else + if (val) val -= 4; + } + } + else if (key&BUTTON_RIGHT) + { + if (key&BUTTON_ON) + { + if (val<0x44) val++; + } + else + { + val &= 0xFC; + if (val<0x44) val += 4; + } + } + else if (key&BUTTON_F3) + { + val = 0x00; + flag2k = 0x0; + } + else if (key&BUTTON_PLAY) + { + flag2k = (flag2k)?0x0:0x4; + } + + val = (val<<8)|flag2k; + l_mas_writereg(rLOUD, val); + + break; + } + case yMDB: /* ------------------------------------------------ */ + { + if (key&BUTTON_PLAY) + { +#ifdef CUSTOM_MDB + mdb_custom(); + retval = true; /* redraw main screen required */ +#endif + } + else + { + UI16 str = l_mas_readreg(rMDB_STR) >>8; + UI16 fc = l_mas_readreg(rMDB_FC) >>8; + UI16 shap = l_mas_readreg(rMDB_SHAP) >>8; + + if (key&BUTTON_F3) + { +/* str = 0x7F/2; */ + str = 0; + fc = 9; + shap = 14; + l_mas_writereg(rMDB_HAR, (UI16)0); + } + if (key&BUTTON_ON) + { + if (key&BUTTON_LEFT) + { + if (fc>2) fc--; + } + else if (key&BUTTON_RIGHT) + { + if (fc<30) fc++; + } + + shap = ((fc*15)+5)/10; + if (shap>30) shap = 30; + if (shap<5) shap = 5; + } + else + { + UI8 dec = (((str*1000)/127)+5)/10; + + if (key&BUTTON_LEFT) + { + if (dec) + { + if (dec%5) + dec -= dec%5; + else + dec -= 5; + } + } + else if (key&BUTTON_RIGHT) + { + if (dec<100) + { + if (dec%5) + dec += 5-(dec%5); + else + dec += 5; + } + } + + str = ((dec*127)+50)/100; + } + + l_mas_writereg(rMDB_SHAP, (shap<<8)|((str)?(2):(0))); + l_mas_writereg(rMDB_STR, str<<8); + l_mas_writereg(rMDB_FC, fc<<8); + } + break; + } + } + + return(retval); + +} + + +/******************************************************************** + * For plugin we have load and save options functions + ********************************************************************/ +#ifdef IS_PLUGIN + +#define filename ROCKBOX_DIR"/rocks/audio_3587.dat" + + +static bool custom_load() +{ + + int f; + + if ((f = rb->open(filename, O_RDONLY))>=0) + { + rb->read(f, &globals, sizeof(struct Globals)); + rb->close(f); + return(true); + } + else + { + return(false); + } +} + + +static void custom_save() +{ + + int f; + + if ((f = rb->creat(filename, O_WRONLY))>=0) + { + rb->write(f, &globals, sizeof(struct Globals)); + rb->close(f); + } + + return; +} + +#endif /* IS_PLUGIN */ + + +/******************************************************************** + * entry point + ********************************************************************/ +enum plugin_status plugin_start(struct plugin_api* api, void* parameter) +{ + + int line, top; + + /* Standard Startup Code */ + TEST_PLUGIN_API(api); + (void)parameter; + rb = api; + +#ifdef SIMULATOR + sim_init_regs(); +#endif + +#ifdef IS_PLUGIN + if (!custom_load()) + custom_default(); +#endif + + cls(); + top = 0; + main_show_line(yALL, top); + + for(line=0; linebutton_get(true); + + switch(key) + { + case BUTTON_F1: + case BUTTON_OFF: + line = yALL; /* the exit condition */ + break; + + case BUTTON_UP: + case BUTTON_UP | BUTTON_REPEAT: + main_hiline(line-top, false); + if (line) + line--; + else + line = yALL-1; +#ifdef CAN_SCROLL + #error "DID WE CAUSE A SCROLL UP OR WRAP?" + if (line==yALL-1) /* we wrapped */ + top = the number of the top line when the bottom line is at the bottom of the screen + else + top--; + main_show_line(yALL, top); +#endif + break; + + case BUTTON_DOWN: + case BUTTON_DOWN | BUTTON_REPEAT: + main_hiline(line-top, false); + if (line<(yALL-1)) + line++; + else + line = 0; +#ifdef CAN_SCROLL + #error "DID WE CAUSE A SCROLL DOWN OR WRAP?" + if (!line) /* we wrapped */ + top = 0; + else /* we scrolled */ + top++; + main_show_line(yALL, top); +#endif + break; + + case BUTTON_UP | BUTTON_ON: + case BUTTON_UP | BUTTON_ON | BUTTON_REPEAT: + if (line) + { + UI8 tmp = globals.order[line]; + globals.order[line] = globals.order[line-1]; + globals.order[line-1] = tmp; +#ifdef CAN_SCROLL + #error "DID WE CAUSE A SCROLL UP?" + top--; + main_show_line(yALL, top); +#endif + main_hiline(line-top, false); + main_show_line(line-1, top); + main_show_line(line, top); + line--; + + } + break; + + case BUTTON_DOWN | BUTTON_ON: + case BUTTON_DOWN | BUTTON_ON | BUTTON_REPEAT: + if (line<(yALL-1)) + { + UI8 tmp = globals.order[line]; + globals.order[line] = globals.order[line+1]; + globals.order[line+1] = tmp; +#ifdef CAN_SCROLL + #error "DID WE CAUSE A SCROLL DOWN?" + top++; + main_show_line(yALL, top); +#endif + main_hiline(line-top, false); + main_show_line(line+1, top); + main_show_line(line, top); + line++; + + } + break; + + case BUTTON_LEFT: + case BUTTON_LEFT | BUTTON_REPEAT: + + case BUTTON_LEFT | BUTTON_ON: + case BUTTON_LEFT | BUTTON_ON | BUTTON_REPEAT: + + case BUTTON_RIGHT: + case BUTTON_RIGHT | BUTTON_REPEAT: + + case BUTTON_RIGHT | BUTTON_ON: + case BUTTON_RIGHT | BUTTON_ON | BUTTON_REPEAT: + + case BUTTON_F3: + + case BUTTON_PLAY: + if (main_upd_reg(line, key)) /* returns TRUE to request a redraw */ + { + main_hiline(line-top, false); /* we need to reset hiline's internal flag */ + cls(); + main_show_line(yALL, top); + } + else + { + main_hiline(line-top, false); + main_show_line(line, top); + } + break; + + case BUTTON_F2: + { + UI8 x,y; + + UI8 xlen = pixlen(str_AUDIO_RESET); + UI8 x1 = (LCD_WIDTH-xlen)/2; + UI8 x2 = x1 + pixlen(str_OTHER" "); + + UI8 ylen = ((35*line_H)+5)/10; + UI8 y1 = (LCD_HEIGHT-ylen)/2; + + main_hiline(line-top, false); + + rb->lcd_invertrect(0,0, LCD_WIDTH,LCD_HEIGHT); + for (y=y1-3-3; y<(y1-3+ylen+4+3); y++) + for (x=x1-3-3; x<(x1-3+xlen+4+3); x++) + if ((x+y)&1) + rb->lcd_clearpixel(x,y); + else + rb->lcd_drawpixel(x,y); +/* + for (x=0; xlcd_drawpixel(x,y); + + for (x=0; xlcd_drawpixel(x,y); +*/ + rb->lcd_clearrect(x1-3,y1-3, xlen+4,ylen+4); + rb->lcd_drawrect(x1-3,y1-3, xlen+4,ylen+4); +/* + for (y=y1; y<(y1-3+ylen+4+3); y++) + for (x=(y<(y1-3+ylen+4))?(x1-3+xlen+4):(x1-3+3); x<(x1-3+xlen+4+3); x++) + if ((x+y)&1) + rb->lcd_clearpixel(x,y); +*/ + x = x1; y = y1; + prints(str_AUDIO_RESET) + + x = x1; y += ((15*line_H)+5)/10; + prints(str_PLAY); + x = x2; + prints("= "str_YES); + + x = x1; y += line_H; + prints(str_OTHER); + x = x2; + prints("= "str_NO); + + rb->lcd_update(); + + /* get a keyPRESS (not release) */ + for(key=BUTTON_REL; key&BUTTON_REL; key=rb->button_get(true)); + if (key==BUTTON_PLAY) + { + /* press F3 on every line */ + for (line=0; line