mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-10 21:52:28 -05:00
Patch #939307 by Eric Lassauge
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5562 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
ae75ea8858
commit
c5efd8b64c
1 changed files with 21 additions and 17 deletions
|
|
@ -48,6 +48,9 @@ static const char cfg_filename[] = "euroconverter.cfg";
|
||||||
#define CFGFILE_VERSION 0 /* Current config file version */
|
#define CFGFILE_VERSION 0 /* Current config file version */
|
||||||
#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */
|
#define CFGFILE_MINVERSION 0 /* Minimum config file version to accept */
|
||||||
|
|
||||||
|
/* typedef for simplifying usage of long long type */
|
||||||
|
typedef long long int longlong_t;
|
||||||
|
|
||||||
/*Pattern for the converter*/
|
/*Pattern for the converter*/
|
||||||
static unsigned char pattern_euro[]={0x07, 0x08, 0x1E, 0x10, 0x1E, 0x08, 0x07}; /* € */
|
static unsigned char pattern_euro[]={0x07, 0x08, 0x1E, 0x10, 0x1E, 0x08, 0x07}; /* € */
|
||||||
static unsigned char pattern_home[]={0x04, 0x0A, 0x11, 0x1F, 0x11, 0x11, 0x1F}; /* Home icon*/
|
static unsigned char pattern_home[]={0x04, 0x0A, 0x11, 0x1F, 0x11, 0x11, 0x1F}; /* Home icon*/
|
||||||
|
|
@ -85,7 +88,7 @@ static int nb_digit[12]={
|
||||||
};
|
};
|
||||||
|
|
||||||
/* max euro to have home currency */
|
/* max euro to have home currency */
|
||||||
static long long max_euro[12]={
|
static longlong_t max_euro[12]={
|
||||||
99999999000LL, /*FRF France 999 999.99 */
|
99999999000LL, /*FRF France 999 999.99 */
|
||||||
99999999000LL, /*DEM Germany 999 999.99 */
|
99999999000LL, /*DEM Germany 999 999.99 */
|
||||||
99999999000LL, /*ATS Austria 999 999.99 */
|
99999999000LL, /*ATS Austria 999 999.99 */
|
||||||
|
|
@ -102,7 +105,7 @@ static long long max_euro[12]={
|
||||||
|
|
||||||
/* max home to have euro currency */
|
/* max home to have euro currency */
|
||||||
/* 92233720300000 Limitation due to the max capacity of long long (2^63)*/
|
/* 92233720300000 Limitation due to the max capacity of long long (2^63)*/
|
||||||
static long long max_curr[12]={
|
static longlong_t max_curr[12]={
|
||||||
99999999000LL, /*FRF France 152449.02 */
|
99999999000LL, /*FRF France 152449.02 */
|
||||||
99999999000LL, /*DEM Germany 511291.88 */
|
99999999000LL, /*DEM Germany 511291.88 */
|
||||||
99999999000LL, /*ATS Austria 72672.83 */
|
99999999000LL, /*ATS Austria 72672.83 */
|
||||||
|
|
@ -152,9 +155,10 @@ static char *currency_str[12] = {
|
||||||
"Greece"
|
"Greece"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int country; /*Country selected*/
|
static int country; /*Country selected*/
|
||||||
static int cur_pos; /*Cursor position*/
|
static int cur_pos; /*Cursor position*/
|
||||||
static long long inc;
|
static longlong_t inc;
|
||||||
|
|
||||||
/* Persistent settings */
|
/* Persistent settings */
|
||||||
static struct configdata config[] = {
|
static struct configdata config[] = {
|
||||||
|
|
@ -163,23 +167,23 @@ static struct configdata config[] = {
|
||||||
|
|
||||||
|
|
||||||
/* 64bits*64 bits with 5 digits after the . */
|
/* 64bits*64 bits with 5 digits after the . */
|
||||||
static long long mul(long long a, long long b)
|
static longlong_t mymul(longlong_t a, longlong_t b)
|
||||||
{
|
{
|
||||||
return((a*b)/100000);
|
return((a*b)/100000LL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 64bits/64 bits with 5 digits after the . */
|
/* 64bits/64 bits with 5 digits after the . */
|
||||||
static long long mydiv(long long a, long long b)
|
static longlong_t mydiv(longlong_t a, longlong_t b)
|
||||||
{
|
{
|
||||||
return((a*100000)/b);
|
return((a*100000LL)/b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* 123.45=12345000 split => i=123 f=45000*/
|
/* 123.45=12345000 split => i=123 f=45000*/
|
||||||
static void split(long long v, long long* i, long long* f)
|
static void split(longlong_t v, longlong_t* i, longlong_t* f)
|
||||||
{
|
{
|
||||||
long long t;
|
longlong_t t;
|
||||||
|
|
||||||
t=v/100000LL;
|
t=v/100000LL;
|
||||||
(*i)=t;
|
(*i)=t;
|
||||||
|
|
@ -188,10 +192,10 @@ static void split(long long v, long long* i, long long* f)
|
||||||
|
|
||||||
|
|
||||||
/* result=10^n */
|
/* result=10^n */
|
||||||
static long long pow10(int n)
|
static longlong_t pow10(int n)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
long long r;
|
longlong_t r;
|
||||||
|
|
||||||
r=1;
|
r=1;
|
||||||
for (i=0;i<n;i++)
|
for (i=0;i<n;i++)
|
||||||
|
|
@ -201,10 +205,10 @@ static long long pow10(int n)
|
||||||
|
|
||||||
|
|
||||||
/* round the i.f at n digit after the . */
|
/* round the i.f at n digit after the . */
|
||||||
static void round(long long* i, long long* f, int n)
|
static void round(longlong_t* i, longlong_t* f, int n)
|
||||||
{
|
{
|
||||||
|
|
||||||
long long m;
|
longlong_t m;
|
||||||
int add=0;
|
int add=0;
|
||||||
|
|
||||||
m=(int)pow10(5-n-1);
|
m=(int)pow10(5-n-1);
|
||||||
|
|
@ -231,10 +235,10 @@ static void round(long long* i, long long* f, int n)
|
||||||
pos: false : first line
|
pos: false : first line
|
||||||
: true : second line
|
: true : second line
|
||||||
*/
|
*/
|
||||||
static void display(long long euro, long long home, bool pos)
|
static void display(longlong_t euro, longlong_t home, bool pos)
|
||||||
{
|
{
|
||||||
char c1,c2;
|
char c1,c2;
|
||||||
long long i,f;
|
longlong_t i,f;
|
||||||
unsigned char str[20];
|
unsigned char str[20];
|
||||||
unsigned char s1[20];
|
unsigned char s1[20];
|
||||||
unsigned char s2[20];
|
unsigned char s2[20];
|
||||||
|
|
@ -398,7 +402,7 @@ static void euro_exit(void *parameter)
|
||||||
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
{
|
{
|
||||||
bool end, pos;
|
bool end, pos;
|
||||||
long long e,h,old_e,old_h;
|
longlong_t e,h,old_e,old_h;
|
||||||
int button;
|
int button;
|
||||||
|
|
||||||
/* this macro should be called as the first thing you do in the plugin.
|
/* this macro should be called as the first thing you do in the plugin.
|
||||||
|
|
@ -598,7 +602,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
|
||||||
}
|
}
|
||||||
/*Display*/
|
/*Display*/
|
||||||
if (!pos) /*Euro>home*/
|
if (!pos) /*Euro>home*/
|
||||||
h=mul(e,currency[country]);
|
h=mymul(e,currency[country]);
|
||||||
else /*Home>euro*/
|
else /*Home>euro*/
|
||||||
e=mydiv(h,currency[country]);
|
e=mydiv(h,currency[country]);
|
||||||
display(e,h,pos);
|
display(e,h,pos);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue