1
0
Fork 0
forked from len0rd/rockbox

Code Police raid. Mostly changed // comments and indented to Rockbox style.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8894 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2006-03-03 08:14:44 +00:00
parent e248eac20f
commit 220fafdd72
15 changed files with 1052 additions and 1006 deletions

View file

@ -404,4 +404,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
return ret; return ret;
} }
#endif // #ifdef HAVE_LCD_BITMAP #endif /* #ifdef HAVE_LCD_BITMAP */

View file

@ -362,13 +362,13 @@ tCheckResult CheckFirmwareFile(char* filename, int chipsize, bool is_romless)
} }
if (fileleft == 256*1024) if (fileleft == 256*1024)
{ // original dumped firmware file has no CRC nor platform ID { /* original dumped firmware file has no CRC nor platform ID */
has_crc = false; has_crc = false;
} }
else else
{ {
has_crc = true; has_crc = true;
fileleft -= sizeof(unsigned); // exclude the last 4 bytes fileleft -= sizeof(unsigned); /* exclude the last 4 bytes */
} }
/* do some sanity checks */ /* do some sanity checks */

View file

@ -328,11 +328,11 @@ int main(void)
enum plugin_status plugin_start(struct plugin_api* api, void* parameter) enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{ {
rb = api; // copy to global api pointer rb = api; /* copy to global api pointer */
(void)parameter; (void)parameter;
return main(); return main();
} }
#endif // #ifdef HAVE_LCD_BITMAP #endif /* #ifdef HAVE_LCD_BITMAP */

View file

@ -1235,7 +1235,7 @@ void build_lut(struct jpeg* p_jpeg)
} }
else else
{ {
// error /* error */
} }
} }
@ -1429,7 +1429,7 @@ int jpeg_decode(struct jpeg* p_jpeg, unsigned char* p_pixel[3],
int k_need; /* AC coefficients needed up to here */ int k_need; /* AC coefficients needed up to here */
int zero_need; /* init the block with this many zeros */ int zero_need; /* init the block with this many zeros */
int last_dc_val[3] = {0, 0, 0}; // or 128 for chroma? int last_dc_val[3] = {0, 0, 0}; /* or 128 for chroma? */
int store_offs[4]; /* memory offsets: order of Y11 Y12 Y21 Y22 U V */ int store_offs[4]; /* memory offsets: order of Y11 Y12 Y21 Y22 U V */
int restart = p_jpeg->restart_interval; /* MCUs until restart marker */ int restart = p_jpeg->restart_interval; /* MCUs until restart marker */
@ -1483,7 +1483,7 @@ int jpeg_decode(struct jpeg* p_jpeg, unsigned char* p_pixel[3],
for(y=0; y<p_jpeg->y_mbl && bs.next_input_byte <= bs.input_end; y++) for(y=0; y<p_jpeg->y_mbl && bs.next_input_byte <= bs.input_end; y++)
{ {
for (i=0; i<3; i++) // scan line init for (i=0; i<3; i++) /* scan line init */
{ {
p_byte[i] = p_line[i]; p_byte[i] = p_line[i];
p_line[i] += skip_strip[i]; p_line[i] += skip_strip[i];
@ -1567,7 +1567,7 @@ int jpeg_decode(struct jpeg* p_jpeg, unsigned char* p_pixel[3],
skip_line[ci]); skip_line[ci]);
} }
} /* for blkn */ } /* for blkn */
p_byte[0] += skip_mcu[0]; // unrolled for (i=0; i<3; i++) loop p_byte[0] += skip_mcu[0]; /* unrolled for (i=0; i<3; i++) loop */
p_byte[1] += skip_mcu[1]; p_byte[1] += skip_mcu[1];
p_byte[2] += skip_mcu[2]; p_byte[2] += skip_mcu[2];
if (p_jpeg->restart_interval && --restart == 0) if (p_jpeg->restart_interval && --restart == 0)

View file

@ -321,14 +321,14 @@ void recalc_parameters(void)
void init_mandelbrot_set(void) void init_mandelbrot_set(void)
{ {
#if CONFIG_LCD == LCD_SSD1815 /* Recorder, Ondio. */ #if CONFIG_LCD == LCD_SSD1815 /* Recorder, Ondio. */
x_min = -38L<<22; // -2.375<<26 x_min = -38L<<22; /* -2.375<<26 */
x_max = 15L<<22; // 0.9375<<26 x_max = 15L<<22; /* 0.9375<<26 */
#else /* all others (square pixels) */ #else /* all others (square pixels) */
x_min = -36L<<22; // -2.25<<26 x_min = -36L<<22; /* -2.25<<26 */
x_max = 12L<<22; // 0.75<<26 x_max = 12L<<22; /* 0.75<<26 */
#endif #endif
y_min = -19L<<22; // -1.1875<<26 y_min = -19L<<22; /* -1.1875<<26 */
y_max = 19L<<22; // 1.1875<<26 y_max = 19L<<22; /* 1.1875<<26 */
recalc_parameters(); recalc_parameters();
} }

View file

@ -746,7 +746,7 @@ void play_tock(void) {
void calc_period(void) void calc_period(void)
{ {
period = 61440/bpm-1; // (60*1024)/bpm; period = 61440/bpm-1; /* (60*1024)/bpm; */
} }
@ -904,7 +904,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter){
rb = api; rb = api;
if (MET_IS_PLAYING) if (MET_IS_PLAYING)
MET_PLAY_STOP; // stop audio IS MET_PLAY_STOP; /* stop audio IS */
#if CONFIG_CODEC != SWCODEC #if CONFIG_CODEC != SWCODEC
rb->bitswap(sound, sizeof(sound)); rb->bitswap(sound, sizeof(sound));

View file

@ -23,7 +23,7 @@
/* Only define LOCAL_DSP on Simulator or else we're asking for trouble */ /* Only define LOCAL_DSP on Simulator or else we're asking for trouble */
#if defined(SIMULATOR) #if defined(SIMULATOR)
/*Enable this to write to the soundcard via a /dsv/dsp symlink in */ /*Enable this to write to the soundcard via a /dsv/dsp symlink in */
//#define LOCAL_DSP /*#define LOCAL_DSP */
#endif #endif
@ -39,7 +39,7 @@
#include "../../plugin.h" #include "../../plugin.h"
//#include "../codecs/lib/xxx2wav.h" /*#include "../codecs/lib/xxx2wav.h" */
PLUGIN_HEADER PLUGIN_HEADER
@ -200,14 +200,14 @@ int midimain(void * filename)
* why this happens. * why this happens.
*/ */
outputBuffer[outputBufferPosition]=outputSampleOne&0XFF; // Low byte first outputBuffer[outputBufferPosition]=outputSampleOne&0XFF; /* Low byte first */
outputBufferPosition++; outputBufferPosition++;
outputBuffer[outputBufferPosition]=outputSampleOne>>8; //High byte second outputBuffer[outputBufferPosition]=outputSampleOne>>8; /*High byte second */
outputBufferPosition++; outputBufferPosition++;
outputBuffer[outputBufferPosition]=outputSampleTwo&0XFF; // Low byte first outputBuffer[outputBufferPosition]=outputSampleTwo&0XFF; /* Low byte first */
outputBufferPosition++; outputBufferPosition++;
outputBuffer[outputBufferPosition]=outputSampleTwo>>8; //High byte second outputBuffer[outputBufferPosition]=outputSampleTwo>>8; /*High byte second */
outputBufferPosition++; outputBufferPosition++;

View file

@ -33,7 +33,7 @@ use F3 to see how many mines are left (supposing all your flags are correct)
PLUGIN_HEADER PLUGIN_HEADER
//what the minesweeper() function can return /*what the minesweeper() function can return */
#define MINESWEEPER_USB 3 #define MINESWEEPER_USB 3
#define MINESWEEPER_QUIT 2 #define MINESWEEPER_QUIT 2
#define MINESWEEPER_LOSE 1 #define MINESWEEPER_LOSE 1
@ -402,10 +402,10 @@ int minesweeper(void)
while(true){ while(true){
//clear the screen buffer /*clear the screen buffer */
rb->lcd_clear_display(); rb->lcd_clear_display();
//display the mine field /*display the mine field */
for(i=0;i<height;i++){ for(i=0;i<height;i++){
for(j=0;j<width;j++){ for(j=0;j<width;j++){
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1

View file

@ -1,15 +1,15 @@
// Shine is an MP3 encoder /* Shine is an MP3 encoder
// Copyright (C) 1999-2000 Gabriel Bouvigne * Copyright (C) 1999-2000 Gabriel Bouvigne
// *
// This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
// *
// This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details. * Library General Public License for more details. */
#define samp_per_frame 1152 #define samp_per_frame 1152
#define samp_per_frame2 576 #define samp_per_frame2 576
@ -112,55 +112,55 @@ struct huffcodetab {
}; };
/* !!!!!!!! start of IRAM area: do not insert before x_int1 array !!!!!!!!!!!!! */ /* !!!!!!!! start of IRAM area: do not insert before x_int1 array !!!!!!!!!!!!! */
short x_int0 [HAN_SIZE] IBSS_ATTR; // 1024 Bytes short x_int0 [HAN_SIZE] IBSS_ATTR; /* 1024 Bytes */
int mdct_freq [2][2][samp_per_frame2] IBSS_ATTR; // 9216 Bytes int mdct_freq [2][2][samp_per_frame2] IBSS_ATTR; /* 9216 Bytes */
short x_int1 [HAN_SIZE] IBSS_ATTR; // 1024 Bytes short x_int1 [HAN_SIZE] IBSS_ATTR; /* 1024 Bytes */
/* !!!!!!!!!!!!!!!!!!!!! here you may insert other data !!!!!!!!!!!!!!!!!!!!!!! */ /* !!!!!!!!!!!!!!!!!!!!! here you may insert other data !!!!!!!!!!!!!!!!!!!!!!! */
uint8 int2idx [4096] IBSS_ATTR; // 4096 Bytes uint8 int2idx [4096] IBSS_ATTR; /* 4096 Bytes */
enct8 enc_data [2][2][samp_per_frame2] IBSS_ATTR; // 4608 Bytes enct8 enc_data [2][2][samp_per_frame2] IBSS_ATTR; /* 4608 Bytes */
short y_int [64] IBSS_ATTR; // 256 Bytes short y_int [64] IBSS_ATTR; /* 256 Bytes */
int off [2] IBSS_ATTR; // 16 Bytes int off [2] IBSS_ATTR; /* 16 Bytes */
int scalefac_long[23] IBSS_ATTR; // 96 Bytes int scalefac_long[23] IBSS_ATTR; /* 96 Bytes */
int mdct_in [36] IBSS_ATTR; // 144 Bytes int mdct_in [36] IBSS_ATTR; /* 144 Bytes */
int sb_sample [2][3][18][SBLIMIT] IBSS_ATTR; // 13824 Bytes int sb_sample [2][3][18][SBLIMIT] IBSS_ATTR; /* 13824 Bytes */
BF_Data CodedData IBSS_ATTR; // 1040 Bytes BF_Data CodedData IBSS_ATTR; /* 1040 Bytes */
int ca_int [8] IBSS_ATTR; // 32 Bytes int ca_int [8] IBSS_ATTR; /* 32 Bytes */
int cs_int [8] IBSS_ATTR; // 32 Bytes int cs_int [8] IBSS_ATTR; /* 32 Bytes */
int win_int [18][36] IBSS_ATTR; // 2592 Bytes int win_int [18][36] IBSS_ATTR; /* 2592 Bytes */
short filter_int [SBLIMIT][64] IBSS_ATTR; // 8192 Bytes short filter_int [SBLIMIT][64] IBSS_ATTR; /* 8192 Bytes */
short enwindow_int[512] IBSS_ATTR; // 1024 Bytes short enwindow_int[512] IBSS_ATTR; /* 1024 Bytes */
uint8 ht_count1 [2][2][16] IBSS_ATTR; // 64 Bytes uint8 ht_count1 [2][2][16] IBSS_ATTR; /* 64 Bytes */
uint16 t1HB [ 4] IBSS_ATTR; // Bytes uint16 t1HB [ 4] IBSS_ATTR; /* Bytes */
uint16 t2HB [ 9] IBSS_ATTR; // Bytes uint16 t2HB [ 9] IBSS_ATTR; /* Bytes */
uint16 t3HB [ 9] IBSS_ATTR; // Bytes uint16 t3HB [ 9] IBSS_ATTR; /* Bytes */
uint16 t5HB [ 16] IBSS_ATTR; // Bytes uint16 t5HB [ 16] IBSS_ATTR; /* Bytes */
uint16 t6HB [ 16] IBSS_ATTR; // Bytes uint16 t6HB [ 16] IBSS_ATTR; /* Bytes */
uint16 t7HB [ 36] IBSS_ATTR; // Bytes uint16 t7HB [ 36] IBSS_ATTR; /* Bytes */
uint16 t8HB [ 36] IBSS_ATTR; // Bytes uint16 t8HB [ 36] IBSS_ATTR; /* Bytes */
uint16 t9HB [ 36] IBSS_ATTR; // Bytes uint16 t9HB [ 36] IBSS_ATTR; /* Bytes */
uint16 t10HB [ 64] IBSS_ATTR; // Bytes uint16 t10HB [ 64] IBSS_ATTR; /* Bytes */
uint16 t11HB [ 64] IBSS_ATTR; // Bytes uint16 t11HB [ 64] IBSS_ATTR; /* Bytes */
uint16 t12HB [ 64] IBSS_ATTR; // Bytes uint16 t12HB [ 64] IBSS_ATTR; /* Bytes */
uint16 t13HB [256] IBSS_ATTR; // Bytes uint16 t13HB [256] IBSS_ATTR; /* Bytes */
uint16 t15HB [256] IBSS_ATTR; // Bytes uint16 t15HB [256] IBSS_ATTR; /* Bytes */
uint16 t16HB [256] IBSS_ATTR; // Bytes uint16 t16HB [256] IBSS_ATTR; /* Bytes */
uint16 t24HB [256] IBSS_ATTR; // Bytes uint16 t24HB [256] IBSS_ATTR; /* Bytes */
uint8 t1l [ 4] IBSS_ATTR; // Bytes uint8 t1l [ 4] IBSS_ATTR; /* Bytes */
uint8 t2l [ 9] IBSS_ATTR; // Bytes uint8 t2l [ 9] IBSS_ATTR; /* Bytes */
uint8 t3l [ 9] IBSS_ATTR; // Bytes uint8 t3l [ 9] IBSS_ATTR; /* Bytes */
uint8 t5l [ 16] IBSS_ATTR; // Bytes uint8 t5l [ 16] IBSS_ATTR; /* Bytes */
uint8 t6l [ 16] IBSS_ATTR; // Bytes uint8 t6l [ 16] IBSS_ATTR; /* Bytes */
uint8 t7l [ 36] IBSS_ATTR; // Bytes uint8 t7l [ 36] IBSS_ATTR; /* Bytes */
uint8 t8l [ 36] IBSS_ATTR; // Bytes uint8 t8l [ 36] IBSS_ATTR; /* Bytes */
uint8 t9l [ 36] IBSS_ATTR; // Bytes uint8 t9l [ 36] IBSS_ATTR; /* Bytes */
uint8 t10l [ 64] IBSS_ATTR; // Bytes uint8 t10l [ 64] IBSS_ATTR; /* Bytes */
uint8 t11l [ 64] IBSS_ATTR; // Bytes uint8 t11l [ 64] IBSS_ATTR; /* Bytes */
uint8 t12l [ 64] IBSS_ATTR; // Bytes uint8 t12l [ 64] IBSS_ATTR; /* Bytes */
uint8 t13l [256] IBSS_ATTR; // Bytes uint8 t13l [256] IBSS_ATTR; /* Bytes */
uint8 t15l [256] IBSS_ATTR; // Bytes uint8 t15l [256] IBSS_ATTR; /* Bytes */
uint8 t16l [256] IBSS_ATTR; // Bytes uint8 t16l [256] IBSS_ATTR; /* Bytes */
uint8 t24l [256] IBSS_ATTR; // Bytes uint8 t24l [256] IBSS_ATTR; /* Bytes */
struct huffcodetab ht [HTN] IBSS_ATTR; // Bytes struct huffcodetab ht [HTN] IBSS_ATTR; /* Bytes */
static const uint8 ht_count1_const[2][2][16] = static const uint8 ht_count1_const[2][2][16] =
{ { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1 }, /* table0 */ { { { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1 }, /* table0 */
@ -240,7 +240,7 @@ const struct huffcodetab ht_const[HTN] =
{ 2, 2, 0, 0, t1HB, t1l}, { 2, 2, 0, 0, t1HB, t1l},
{ 3, 3, 0, 0, t2HB, t2l}, { 3, 3, 0, 0, t2HB, t2l},
{ 3, 3, 0, 0, t3HB, t3l}, { 3, 3, 0, 0, t3HB, t3l},
{ 0, 0, 0, 0, NULL, NULL},// Apparently not used { 0, 0, 0, 0, NULL, NULL},/* Apparently not used */
{ 4, 4, 0, 0, t5HB, t5l}, { 4, 4, 0, 0, t5HB, t5l},
{ 4, 4, 0, 0, t6HB, t6l}, { 4, 4, 0, 0, t6HB, t6l},
{ 6, 6, 0, 0, t7HB, t7l}, { 6, 6, 0, 0, t7HB, t7l},
@ -250,7 +250,7 @@ const struct huffcodetab ht_const[HTN] =
{ 8, 8, 0, 0,t11HB, t11l}, { 8, 8, 0, 0,t11HB, t11l},
{ 8, 8, 0, 0,t12HB, t12l}, { 8, 8, 0, 0,t12HB, t12l},
{16,16, 0, 0,t13HB, t13l}, {16,16, 0, 0,t13HB, t13l},
{ 0, 0, 0, 0, NULL, NULL},// Apparently not used { 0, 0, 0, 0, NULL, NULL},/* Apparently not used */
{16,16, 0, 0,t15HB, t15l}, {16,16, 0, 0,t15HB, t15l},
{16,16, 1, 1,t16HB, t16l}, {16,16, 1, 1,t16HB, t16l},
{16,16, 2, 3,t16HB, t16l}, {16,16, 2, 3,t16HB, t16l},
@ -1025,7 +1025,7 @@ int count_bit(enct8 ix[samp_per_frame2], unsigned int start, unsigned int end, u
ylen = h->ylen; ylen = h->ylen;
if(table > 15) if(table > 15)
{ // ESC-table is used { /* ESC-table is used */
linbits = h->linbits; linbits = h->linbits;
for(i=start; i<end; i+=2) for(i=start; i<end; i+=2)
{ {
@ -1532,7 +1532,7 @@ void filter_subband(short *buffer, int s[SBLIMIT], int k)
#endif #endif
/* 147456=72*2048 */ /* 147456=72*2048 */
for(i=SBLIMIT; i--; ) // SBLIMIT: 32 for(i=SBLIMIT; i--; ) /* SBLIMIT: 32 */
{ {
short *filt = filter_int[i]; short *filt = filter_int[i];
@ -1691,11 +1691,11 @@ void compress(void)
memcpy(ht , ht_const , sizeof(ht )); memcpy(ht , ht_const , sizeof(ht ));
/* I don't know, wether this is really necessary */ /* I don't know, wether this is really necessary */
ht[ 0].table = NULL; ht[ 0].hlen = NULL;// Apparently not used ht[ 0].table = NULL; ht[ 0].hlen = NULL;/* Apparently not used */
ht[ 1].table = t1HB; ht[ 1].hlen = t1l; ht[ 1].table = t1HB; ht[ 1].hlen = t1l;
ht[ 2].table = t2HB; ht[ 2].hlen = t2l; ht[ 2].table = t2HB; ht[ 2].hlen = t2l;
ht[ 3].table = t3HB; ht[ 3].hlen = t3l; ht[ 3].table = t3HB; ht[ 3].hlen = t3l;
ht[ 4].table = NULL; ht[ 4].hlen = NULL;// Apparently not used ht[ 4].table = NULL; ht[ 4].hlen = NULL;/* Apparently not used */
ht[ 5].table = t5HB; ht[ 5].hlen = t5l; ht[ 5].table = t5HB; ht[ 5].hlen = t5l;
ht[ 6].table = t6HB; ht[ 6].hlen = t6l; ht[ 6].table = t6HB; ht[ 6].hlen = t6l;
ht[ 7].table = t7HB; ht[ 7].hlen = t7l; ht[ 7].table = t7HB; ht[ 7].hlen = t7l;
@ -1705,7 +1705,7 @@ void compress(void)
ht[11].table = t11HB; ht[11].hlen = t11l; ht[11].table = t11HB; ht[11].hlen = t11l;
ht[12].table = t12HB; ht[12].hlen = t12l; ht[12].table = t12HB; ht[12].hlen = t12l;
ht[13].table = t13HB; ht[13].hlen = t13l; ht[13].table = t13HB; ht[13].hlen = t13l;
ht[14].table = NULL; ht[14].hlen = NULL;// Apparently not used ht[14].table = NULL; ht[14].hlen = NULL;/* Apparently not used */
ht[15].table = t15HB; ht[15].hlen = t15l; ht[15].table = t15HB; ht[15].hlen = t15l;
ht[16].table = t16HB; ht[16].hlen = t16l; ht[16].table = t16HB; ht[16].hlen = t16l;
ht[17].table = t16HB; ht[17].hlen = t16l; ht[17].table = t16HB; ht[17].hlen = t16l;

View file

@ -326,7 +326,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{ {
int ret; int ret;
rb = api; // copy to global api pointer rb = api; /* copy to global api pointer */
(void)parameter; (void)parameter;
if (rb->global_settings->backlight_timeout > 0) if (rb->global_settings->backlight_timeout > 0)
rb->backlight_set_timeout(1);/* keep the light on */ rb->backlight_set_timeout(1);/* keep the light on */

View file

@ -448,19 +448,19 @@ static void star_display_text(char *str, bool waitkey)
line[chars_for_line] = '\0'; line[chars_for_line] = '\0';
// test if we have cutted a word. If it is the case we don't have to /* test if we have cutted a word. If it is the case we don't have to */
// skip the space /* skip the space */
if (i == chars_by_line && chars_for_line == chars_by_line) if (i == chars_by_line && chars_for_line == chars_by_line)
first_char_index += chars_for_line; first_char_index += chars_for_line;
else else
first_char_index += chars_for_line + 1; first_char_index += chars_for_line + 1;
// print the line on the screen /* print the line on the screen */
rb->lcd_putsxy(0, current_line * char_height, line); rb->lcd_putsxy(0, current_line * char_height, line);
// if the number of line showed on the screen is equals to the /* if the number of line showed on the screen is equals to the */
// maximum number of line we can show, we wait for a key pressed to /* maximum number of line we can show, we wait for a key pressed to */
// clear and show the remaining text. /* clear and show the remaining text. */
current_line++; current_line++;
if (current_line == lines_by_screen || *ptr_char == '\0') if (current_line == lines_by_screen || *ptr_char == '\0')
{ {

View file

@ -267,7 +267,7 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
{ {
int ret; int ret;
rb = api; // copy to global api pointer rb = api; /* copy to global api pointer */
(void)parameter; (void)parameter;
if (rb->global_settings->backlight_timeout > 0) if (rb->global_settings->backlight_timeout > 0)
rb->backlight_set_timeout(1);/* keep the light on */ rb->backlight_set_timeout(1);/* keep the light on */
@ -277,4 +277,4 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
return ret; return ret;
} }
#endif // #ifdef HAVE_LCD_BITMAP #endif /* #ifdef HAVE_LCD_BITMAP */

View file

@ -268,7 +268,8 @@ int sudoku_get(Sudoku* sud, int x, int y, bool* original);
#define ALL_BITS (BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) | BIT(9)) #define ALL_BITS (BIT(1) | BIT(2) | BIT(3) | BIT(4) | BIT(5) | BIT(6) | BIT(7) | BIT(8) | BIT(9))
/* initialize a sudoku problem, should be called before using set or get */ /* initialize a sudoku problem, should be called before using set or get */
void sudoku_init(Sudoku* sud){ void sudoku_init(Sudoku* sud)
{
int y, x; int y, x;
for (y = 0; y < SIZE; y++){ for (y = 0; y < SIZE; y++){
for (x = 0; x < SIZE; x++){ for (x = 0; x < SIZE; x++){
@ -278,17 +279,18 @@ void sudoku_init(Sudoku* sud){
} }
/* set the number at a particular x and y column */ /* set the number at a particular x and y column */
void sudoku_set(Sudoku* sud, int x, int y, int num, bool original){ void sudoku_set(Sudoku* sud, int x, int y, int num, bool original)
{
int i, j; int i, j;
int bx, by; int bx, by;
Bitset orig; Bitset orig;
// clear the row and columns /* clear the row and columns */
for (i = 0; i < SIZE; i++){ for (i = 0; i < SIZE; i++){
BIT_CLEAR(sud->table[i][y], num); BIT_CLEAR(sud->table[i][y], num);
BIT_CLEAR(sud->table[x][i], num); BIT_CLEAR(sud->table[x][i], num);
} }
// clear the block /* clear the block */
bx = x - (x % BLOCK); bx = x - (x % BLOCK);
by = y - (y % BLOCK); by = y - (y % BLOCK);
for (i = 0; i < BLOCK; i++){ for (i = 0; i < BLOCK; i++){
@ -296,19 +298,20 @@ void sudoku_set(Sudoku* sud, int x, int y, int num, bool original){
BIT_CLEAR(sud->table[bx+j][by+i], num); BIT_CLEAR(sud->table[bx+j][by+i], num);
} }
} }
// mark the table /* mark the table */
orig = original ? ORIGINAL_BIT : 0; orig = original ? ORIGINAL_BIT : 0;
sud->table[x][y] = BIT(num) | MARK_BIT | orig; sud->table[x][y] = BIT(num) | MARK_BIT | orig;
} }
/* get the number at a particular x and y column, if this /* get the number at a particular x and y column, if this
is not unique return 0 */ is not unique return 0 */
int sudoku_get(Sudoku* sud, int x, int y, bool* original){ int sudoku_get(Sudoku* sud, int x, int y, bool* original)
{
Bitset val = sud->table[x][y]; Bitset val = sud->table[x][y];
int result = 0; int result = 0;
int i; int i;
if (original){ if (original) {
*original = val & ORIGINAL_BIT; *original = val & ORIGINAL_BIT;
} }
for (i = 1; i <= SIZE; i++){ for (i = 1; i <= SIZE; i++){
@ -324,7 +327,8 @@ int sudoku_get(Sudoku* sud, int x, int y, bool* original){
/* returns true if this is a valid problem, this is necessary because the input /* returns true if this is a valid problem, this is necessary because the input
problem might be degenerate which breaks the solver algorithm. */ problem might be degenerate which breaks the solver algorithm. */
static bool is_valid(const Sudoku* sud){ static bool is_valid(const Sudoku* sud)
{
int x, y; int x, y;
for (y = 0; y < SIZE; y++){ for (y = 0; y < SIZE; y++){
@ -337,10 +341,11 @@ static bool is_valid(const Sudoku* sud){
return true; return true;
} }
/* scan the table for the most constrained item, giving all it's options, /* scan the table for the most constrained item, giving all it's options, sets
sets the best x and y coordinates, the number of options and the options for that coordinate and the best x and y coordinates, the number of options and the options for
returns true if the puzzle is finished */ that coordinate and returns true if the puzzle is finished */
static bool scan(const Sudoku* sud, int* rX, int* rY, int *num, int* options){ static bool scan(const Sudoku* sud, int* rX, int* rY, int *num, int* options)
{
int x, y, i, j; int x, y, i, j;
int bestCount = SIZE+1; int bestCount = SIZE+1;
Bitset val; Bitset val;
@ -352,8 +357,8 @@ static bool scan(const Sudoku* sud, int* rX, int* rY, int *num, int* options){
int i; int i;
int count = 0; int count = 0;
if (val & MARK_BIT){ if (val & MARK_BIT) {
// already set /* already set */
continue; continue;
} }
allMarked = false; allMarked = false;
@ -367,14 +372,14 @@ static bool scan(const Sudoku* sud, int* rX, int* rY, int *num, int* options){
*rX = x; *rX = x;
*rY = y; *rY = y;
if (count == 0){ if (count == 0){
// can't possibly be beaten /* can't possibly be beaten */
*num = 0; *num = 0;
return false; return false;
} }
} }
} }
} }
// now copy into options /* now copy into options */
*num = bestCount; *num = bestCount;
val = sud->table[*rX][*rY]; val = sud->table[*rX][*rY];
for (i = 1, j = 0; i <= SIZE; i++){ for (i = 1, j = 0; i <= SIZE; i++){
@ -387,9 +392,11 @@ static bool scan(const Sudoku* sud, int* rX, int* rY, int *num, int* options){
static bool solve(Sudoku* sud, Stats* stats, const Options* options); static bool solve(Sudoku* sud, Stats* stats, const Options* options);
/* try a particular option and return true if that gives a solution /* try a particular option and return true if that gives a solution or false
or false if it doesn't, restores board on backtracking */ if it doesn't, restores board on backtracking */
static bool spawn_option(Sudoku* sud, Stats* stats, const Options* options, int x, int y, int num){ static bool spawn_option(Sudoku* sud, Stats* stats, const Options* options,
int x, int y, int num)
{
Sudoku copy; Sudoku copy;
rb->memcpy(&copy,sud,sizeof(Sudoku)); rb->memcpy(&copy,sud,sizeof(Sudoku));
@ -406,42 +413,44 @@ static bool spawn_option(Sudoku* sud, Stats* stats, const Options* options, int
return false; return false;
} }
/* solve a sudoku problem, returns true if there is a solution and false otherwise. /* solve a sudoku problem, returns true if there is a solution and false
stats is used to track statisticss */ otherwise. stats is used to track statisticss */
static bool solve(Sudoku* sud, Stats* stats, const Options* options){ static bool solve(Sudoku* sud, Stats* stats, const Options* options)
{
while (true){ while (true){
int x, y, i, num; int x, y, i, num;
int places[SIZE]; int places[SIZE];
if (scan(sud, &x, &y, &num, places)){ if (scan(sud, &x, &y, &num, places)){
// a solution was found! /* a solution was found! */
if (options->uniquenessCheck && stats->solutionFound){ if (options->uniquenessCheck && stats->solutionFound){
//printf("\n\t... But the solution is not unique!\n"); /*printf("\n\t... But the solution is not unique!\n"); */
return true; return true;
} }
stats->solutionFound = true; stats->solutionFound = true;
if (options->allSolutions || options->uniquenessCheck){ if (options->allSolutions || options->uniquenessCheck){
//printf("\n\tSolution after %d iterations\n", stats->numTries); /*printf("\n\tSolution after %d iterations\n", stats->numTries); */
//sudoku_print(sud); /*sudoku_print(sud); */
return false; return false;
}else{ }
else{
return true; return true;
} }
} }
if (num == 0){ if (num == 0){
// can't be satisfied /* can't be satisfied */
return false; return false;
} }
// try all the places (except the last one) /* try all the places (except the last one) */
for (i = 0; i < num-1; i++){ for (i = 0; i < num-1; i++){
if (spawn_option(sud, stats, options, x, y, places[i])){ if (spawn_option(sud, stats, options, x, y, places[i])){
// solution found! /* solution found! */
if (!options->allSolutions && stats->solutionFound){ if (!options->allSolutions && stats->solutionFound){
return true; return true;
} }
} }
} }
// take the last place ourself /* take the last place ourself */
stats->numTries += 1; stats->numTries += 1;
sudoku_set(sud, x, y, places[num-1], false); sudoku_set(sud, x, y, places[num-1], false);
} }
@ -451,7 +460,8 @@ static bool solve(Sudoku* sud, Stats* stats, const Options* options){
/* A wrapper function between the Sudoku plugin and the above solver code */ /* A wrapper function between the Sudoku plugin and the above solver code */
void sudoku_solve(struct sudoku_state_t* state) { void sudoku_solve(struct sudoku_state_t* state)
{
bool ret; bool ret;
Stats stats; Stats stats;
Options options; Options options;
@ -474,7 +484,7 @@ void sudoku_solve(struct sudoku_state_t* state) {
} }
} }
// need to check for degenerate input problems ... /* need to check for degenerate input problems ... */
if (is_valid(&sud)){ if (is_valid(&sud)){
ret = solve(&sud, &stats, &options); ret = solve(&sud, &stats, &options);
} else { } else {
@ -485,7 +495,8 @@ void sudoku_solve(struct sudoku_state_t* state) {
/* Populate the board with the solution. */ /* Populate the board with the solution. */
for (r=0;r<9;r++) { for (r=0;r<9;r++) {
for (c=0;c<9;c++) { for (c=0;c<9;c++) {
state->currentboard[r][c]='0'+sudoku_get(&sud, c, r, &original); state->currentboard[r][c]='0'+
sudoku_get(&sud, c, r, &original);
} }
} }
} else { } else {
@ -519,7 +530,8 @@ void clear_state(struct sudoku_state_t* state)
/* Load game - only ".ss" is officially supported, but any sensible /* Load game - only ".ss" is officially supported, but any sensible
text representation (one line per row) may load. text representation (one line per row) may load.
*/ */
bool load_sudoku(struct sudoku_state_t* state, char* filename) { bool load_sudoku(struct sudoku_state_t* state, char* filename)
{
int fd; int fd;
size_t n; size_t n;
int r = 0, c = 0; int r = 0, c = 0;
@ -565,16 +577,19 @@ bool load_sudoku(struct sudoku_state_t* state, char* filename) {
case '_': case '.': case '_': case '.':
valid=1; valid=1;
if (c >= SIZE || r >= SIZE){ if (c >= SIZE || r >= SIZE){
LOGF("ERROR: sudoku problem is the wrong size (%d,%d)\n", c, r); LOGF("ERROR: sudoku problem is the wrong size (%d,%d)\n",
c, r);
return(false); return(false);
} }
c++; c++;
break; break;
default: default:
if (((buf[i]>='A') && (buf[i]<='I')) || ((buf[i]>='0') && (buf[i]<='9'))) { if (((buf[i]>='A') && (buf[i]<='I')) ||
((buf[i]>='0') && (buf[i]<='9'))) {
valid=1; valid=1;
if (r >= SIZE || c >= SIZE){ if (r >= SIZE || c >= SIZE){
LOGF("ERROR: sudoku problem is the wrong size (%d,%d)\n", c, r); LOGF("ERROR: sudoku problem is the wrong size "
"(%d,%d)\n", c, r);
return(false); return(false);
} }
if ((buf[i]>='0') && (buf[i]<='9')) { if ((buf[i]>='0') && (buf[i]<='9')) {
@ -591,13 +606,14 @@ bool load_sudoku(struct sudoku_state_t* state, char* filename) {
i++; i++;
} }
/* Save a copy of the saved state - so we can reload without /* Save a copy of the saved state - so we can reload without using the
using the disk */ disk */
rb->memcpy(state->savedboard,state->currentboard,81); rb->memcpy(state->savedboard,state->currentboard,81);
return(true); return(true);
} }
bool save_sudoku(struct sudoku_state_t* state) { bool save_sudoku(struct sudoku_state_t* state)
{
int fd; int fd;
int r,c; int r,c;
int i; int i;
@ -624,7 +640,9 @@ bool save_sudoku(struct sudoku_state_t* state) {
line[i]='.'; line[i]='.';
} }
i++; i++;
if ((c==2) || (c==5)) { i++; } if ((c==2) || (c==5)) {
i++;
}
} }
rb->write(fd,line,sizeof(line)-1); rb->write(fd,line,sizeof(line)-1);
if ((r==2) || (r==5)) { if ((r==2) || (r==5)) {
@ -670,15 +688,24 @@ void update_cell(struct sudoku_state_t* state, int r, int c)
*/ */
if ((r==state->y) && (c==state->x)) { if ((r==state->y) && (c==state->x)) {
rb->lcd_bitmap_part(sudoku_inverse,0,BITMAP_HEIGHT*(state->currentboard[r][c]-'0'),BITMAP_STRIDE, rb->lcd_bitmap_part(sudoku_inverse,0,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,CELL_HEIGHT); BITMAP_HEIGHT*(state->currentboard[r][c]-'0'),
BITMAP_STRIDE,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,
CELL_HEIGHT);
} else { } else {
if (state->startboard[r][c]!='0') { if (state->startboard[r][c]!='0') {
rb->lcd_bitmap_part(sudoku_start,0,BITMAP_HEIGHT*(state->startboard[r][c]-'0'),BITMAP_STRIDE, rb->lcd_bitmap_part(sudoku_start,0,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,CELL_HEIGHT); BITMAP_HEIGHT*(state->startboard[r][c]-'0'),
BITMAP_STRIDE,
XOFS+cellxpos[c],YOFS+cellypos[r],
CELL_WIDTH,CELL_HEIGHT);
} else { } else {
rb->lcd_bitmap_part(sudoku_normal,0,BITMAP_HEIGHT*(state->currentboard[r][c]-'0'),BITMAP_STRIDE, rb->lcd_bitmap_part(sudoku_normal,0,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,CELL_HEIGHT); BITMAP_HEIGHT*(state->currentboard[r][c]-'0'),
BITMAP_STRIDE,
XOFS+cellxpos[c],YOFS+cellypos[r],
CELL_WIDTH,CELL_HEIGHT);
} }
} }
@ -729,7 +756,7 @@ void display_board(struct sudoku_state_t* state)
rb->lcd_hline(XOFS,XOFS+BOARD_WIDTH-1,YOFS+cellypos[8]+CELL_HEIGHT); rb->lcd_hline(XOFS,XOFS+BOARD_WIDTH-1,YOFS+cellypos[8]+CELL_HEIGHT);
rb->lcd_vline(XOFS+cellxpos[8]+CELL_WIDTH,YOFS,YOFS+BOARD_HEIGHT-1); rb->lcd_vline(XOFS+cellxpos[8]+CELL_WIDTH,YOFS,YOFS+BOARD_HEIGHT-1);
#else #else
#error SUDOKU: Unsupported LCD height #error SUDOKU: Unsupported LCD height
#endif #endif
#ifdef SUDOKU_BUTTON_POSSIBLE #ifdef SUDOKU_BUTTON_POSSIBLE
@ -783,15 +810,27 @@ void display_board(struct sudoku_state_t* state)
*/ */
if ((r==state->y) && (c==state->x)) { if ((r==state->y) && (c==state->x)) {
rb->lcd_bitmap_part(sudoku_inverse,0,BITMAP_HEIGHT*(state->currentboard[r][c]-'0'),BITMAP_STRIDE, rb->lcd_bitmap_part(sudoku_inverse,0,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,CELL_HEIGHT); BITMAP_HEIGHT*(state->currentboard[r][c]-
'0'),
BITMAP_STRIDE,
XOFS+cellxpos[c],YOFS+cellypos[r],
CELL_WIDTH,CELL_HEIGHT);
} else { } else {
if (state->startboard[r][c]!='0') { if (state->startboard[r][c]!='0') {
rb->lcd_bitmap_part(sudoku_start,0,BITMAP_HEIGHT*(state->startboard[r][c]-'0'),BITMAP_STRIDE, rb->lcd_bitmap_part(sudoku_start,0,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,CELL_HEIGHT); BITMAP_HEIGHT*(state->startboard[r][c]-
'0'),
BITMAP_STRIDE,
XOFS+cellxpos[c],YOFS+cellypos[r],
CELL_WIDTH,CELL_HEIGHT);
} else { } else {
rb->lcd_bitmap_part(sudoku_normal,0,BITMAP_HEIGHT*(state->currentboard[r][c]-'0'),BITMAP_STRIDE, rb->lcd_bitmap_part(sudoku_normal,0,
XOFS+cellxpos[c],YOFS+cellypos[r],CELL_WIDTH,CELL_HEIGHT); BITMAP_HEIGHT*
(state->currentboard[r][c]-'0'),
BITMAP_STRIDE,
XOFS+cellxpos[c],YOFS+cellypos[r],
CELL_WIDTH,CELL_HEIGHT);
} }
} }
} }
@ -802,14 +841,17 @@ void display_board(struct sudoku_state_t* state)
} }
/* Check the status of the board, assuming a change at the cursor location */ /* Check the status of the board, assuming a change at the cursor location */
bool check_status(struct sudoku_state_t* state) { bool check_status(struct sudoku_state_t* state)
{
int check[9]; int check[9];
int r,c; int r,c;
int r1,c1; int r1,c1;
int cell; int cell;
/* First, check the column */ /* First, check the column */
for (cell=0;cell<9;cell++) { check[cell]=0; } for (cell=0;cell<9;cell++) {
check[cell]=0;
}
for (r=0;r<9;r++) { for (r=0;r<9;r++) {
cell=state->currentboard[r][state->x]; cell=state->currentboard[r][state->x];
if (cell!='0') { if (cell!='0') {
@ -821,7 +863,9 @@ bool check_status(struct sudoku_state_t* state) {
} }
/* Second, check the row */ /* Second, check the row */
for (cell=0;cell<9;cell++) { check[cell]=0; } for (cell=0;cell<9;cell++) {
check[cell]=0;
}
for (c=0;c<9;c++) { for (c=0;c<9;c++) {
cell=state->currentboard[state->y][c]; cell=state->currentboard[state->y][c];
if (cell!='0') { if (cell!='0') {
@ -833,7 +877,9 @@ bool check_status(struct sudoku_state_t* state) {
} }
/* Finally, check the 3x3 sub-grid */ /* Finally, check the 3x3 sub-grid */
for (cell=0;cell<9;cell++) { check[cell]=0; } for (cell=0;cell<9;cell++) {
check[cell]=0;
}
r1=(state->y/3)*3; r1=(state->y/3)*3;
c1=(state->x/3)*3; c1=(state->x/3)*3;
for (r=r1;r<r1+3;r++) { for (r=r1;r<r1+3;r++) {
@ -925,7 +971,8 @@ bool sudoku_menu(struct sudoku_state_t* state)
return (result==MENU_ATTACHED_USB); return (result==MENU_ATTACHED_USB);
} }
void move_cursor(struct sudoku_state_t* state, int newx, int newy) { void move_cursor(struct sudoku_state_t* state, int newx, int newy)
{
int oldx, oldy; int oldx, oldy;
/* Check that the character at the cursor position is legal */ /* Check that the character at the cursor position is legal */

File diff suppressed because it is too large Load diff

View file

@ -161,7 +161,7 @@ static int wav2wv (char *filename)
num_chans = config.num_channels = native_header.NumChannels; num_chans = config.num_channels = native_header.NumChannels;
total_samples = native_header.data_ckSize / native_header.BlockAlign; total_samples = native_header.data_ckSize / native_header.BlockAlign;
// config.flags |= CONFIG_HIGH_FLAG; /* config.flags |= CONFIG_HIGH_FLAG; */
if (!WavpackSetConfiguration (wpc, &config, total_samples)) { if (!WavpackSetConfiguration (wpc, &config, total_samples)) {
rb->splash(HZ*2, true, "internal error!"); rb->splash(HZ*2, true, "internal error!");