diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/viewport.h | 5 | ||||
-rw-r--r-- | apps/misc.c | 2 | ||||
-rw-r--r-- | apps/misc.h | 3 | ||||
-rw-r--r-- | apps/plugins/alpine_cdc.c | 6 | ||||
-rw-r--r-- | apps/plugins/jpeg/jpeg_decoder.c | 4 | ||||
-rw-r--r-- | apps/plugins/lib/fixedpoint.c | 3 | ||||
-rw-r--r-- | apps/plugins/lib/grey_core.c | 2 | ||||
-rw-r--r-- | apps/plugins/lib/helper.c | 14 | ||||
-rw-r--r-- | apps/plugins/rockboy/cpu.c | 10 | ||||
-rw-r--r-- | apps/plugins/rockboy/lcd.c | 4 | ||||
-rw-r--r-- | apps/plugins/rockboy/sound.c | 2 | ||||
-rw-r--r-- | apps/plugins/sudoku/generator.c | 4 | ||||
-rw-r--r-- | apps/plugins/sudoku/sudoku.c | 12 | ||||
-rw-r--r-- | apps/plugins/zxbox/sp_def.h | 4 | ||||
-rw-r--r-- | apps/plugins/zxbox/spkey.c | 4 | ||||
-rw-r--r-- | apps/plugins/zxbox/spscr.c | 4 | ||||
-rw-r--r-- | apps/recorder/bmp.c | 4 | ||||
-rw-r--r-- | apps/recorder/jpeg_load.c | 43 | ||||
-rw-r--r-- | apps/replaygain.c | 6 | ||||
-rw-r--r-- | apps/screens.c | 2 |
20 files changed, 78 insertions, 60 deletions
diff --git a/apps/gui/viewport.h b/apps/gui/viewport.h index 76ed327f69..acc9758ee3 100644 --- a/apps/gui/viewport.h +++ b/apps/gui/viewport.h | |||
@@ -22,6 +22,7 @@ | |||
22 | 22 | ||
23 | #include "config.h" | 23 | #include "config.h" |
24 | #include "lcd.h" | 24 | #include "lcd.h" |
25 | #include "system.h" | ||
25 | #include "screen_access.h" | 26 | #include "screen_access.h" |
26 | 27 | ||
27 | /* return the number of text lines in the vp viewport */ | 28 | /* return the number of text lines in the vp viewport */ |
@@ -58,8 +59,8 @@ void viewport_set_defaults(struct viewport *vp, enum screen_type screen); | |||
58 | * SB "displaying rules". | 59 | * SB "displaying rules". |
59 | */ | 60 | */ |
60 | #define VP_SB_HIDE_ALL 0 | 61 | #define VP_SB_HIDE_ALL 0 |
61 | #define VP_SB_ONSCREEN(screen) (1u<<screen) | 62 | #define VP_SB_ONSCREEN(screen) BIT_N(screen) |
62 | #define VP_SB_IGNORE_SETTING(screen) (1u<<(4+screen)) | 63 | #define VP_SB_IGNORE_SETTING(screen) BIT_N(4+screen) |
63 | #define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) | 64 | #define VP_SB_ALLSCREENS (VP_SB_ONSCREEN(0)|VP_SB_ONSCREEN(1)) |
64 | int viewportmanager_set_statusbar(int enabled); | 65 | int viewportmanager_set_statusbar(int enabled); |
65 | 66 | ||
diff --git a/apps/misc.c b/apps/misc.c index 3e423b3082..cf356a37f9 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1045,7 +1045,7 @@ const char* parse_list(const char *fmt, uint32_t *set_vals, | |||
1045 | break; | 1045 | break; |
1046 | } | 1046 | } |
1047 | if (set_vals && set) | 1047 | if (set_vals && set) |
1048 | *set_vals |= (1<<i); | 1048 | *set_vals |= BIT_N(i); |
1049 | i++; | 1049 | i++; |
1050 | } | 1050 | } |
1051 | 1051 | ||
diff --git a/apps/misc.h b/apps/misc.h index 1ac63da773..7e71101ba1 100644 --- a/apps/misc.h +++ b/apps/misc.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <stdbool.h> | 24 | #include <stdbool.h> |
25 | #include <inttypes.h> | 25 | #include <inttypes.h> |
26 | #include "config.h" | 26 | #include "config.h" |
27 | #include "system.h" | ||
27 | 28 | ||
28 | /* Format a large-range value for output, using the appropriate unit so that | 29 | /* Format a large-range value for output, using the appropriate unit so that |
29 | * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" | 30 | * the displayed value is in the range 1 <= display < 1000 (1024 for "binary" |
@@ -103,7 +104,7 @@ char *strip_extension(char* buffer, int buffer_size, const char *filename); | |||
103 | * - position: 0-based number of the value | 104 | * - position: 0-based number of the value |
104 | * - valid_vals: value after the call to 'parse_list' | 105 | * - valid_vals: value after the call to 'parse_list' |
105 | */ | 106 | */ |
106 | #define LIST_VALUE_PARSED(setvals, position) ((setvals)&(1<<(position))) | 107 | #define LIST_VALUE_PARSED(setvals, position) ((setvals) & BIT_N(position)) |
107 | const char* parse_list(const char *fmt, uint32_t *set_vals, | 108 | const char* parse_list(const char *fmt, uint32_t *set_vals, |
108 | const char sep, const char* str, ...); | 109 | const char sep, const char* str, ...); |
109 | 110 | ||
diff --git a/apps/plugins/alpine_cdc.c b/apps/plugins/alpine_cdc.c index a7aeec306f..494fa17842 100644 --- a/apps/plugins/alpine_cdc.c +++ b/apps/plugins/alpine_cdc.c | |||
@@ -669,16 +669,16 @@ void dump_packet(char* dest, int dst_size, char* src, int n) | |||
669 | 669 | ||
670 | bool bit_test(unsigned char* buf, unsigned bit) | 670 | bool bit_test(unsigned char* buf, unsigned bit) |
671 | { | 671 | { |
672 | return (buf[bit/4] & (0x01 << bit%4)) != 0; | 672 | return (buf[bit>>2] & BIT_N(bit&3)) != 0; |
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | void bit_set(unsigned char* buf, unsigned bit, bool val) | 676 | void bit_set(unsigned char* buf, unsigned bit, bool val) |
677 | { | 677 | { |
678 | if (val) | 678 | if (val) |
679 | buf[bit/4] |= (0x01 << bit%4); | 679 | buf[bit>>2] |= BIT_N(bit&3); |
680 | else | 680 | else |
681 | buf[bit/4] &= ~(0x01 << bit%4); | 681 | buf[bit>>2] &= ~BIT_N(bit&3); |
682 | } | 682 | } |
683 | 683 | ||
684 | 684 | ||
diff --git a/apps/plugins/jpeg/jpeg_decoder.c b/apps/plugins/jpeg/jpeg_decoder.c index 71d50888c3..c90bff87a4 100644 --- a/apps/plugins/jpeg/jpeg_decoder.c +++ b/apps/plugins/jpeg/jpeg_decoder.c | |||
@@ -1067,12 +1067,12 @@ INLINE void check_bit_buffer(struct bitstream* pb, int nbits) | |||
1067 | 1067 | ||
1068 | INLINE int get_bits(struct bitstream* pb, int nbits) | 1068 | INLINE int get_bits(struct bitstream* pb, int nbits) |
1069 | { | 1069 | { |
1070 | return ((int) (pb->get_buffer >> (pb->bits_left -= nbits))) & ((1<<nbits)-1); | 1070 | return ((int) (pb->get_buffer >> (pb->bits_left -= nbits))) & (BIT_N(nbits)-1); |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | INLINE int peek_bits(struct bitstream* pb, int nbits) | 1073 | INLINE int peek_bits(struct bitstream* pb, int nbits) |
1074 | { | 1074 | { |
1075 | return ((int) (pb->get_buffer >> (pb->bits_left - nbits))) & ((1<<nbits)-1); | 1075 | return ((int) (pb->get_buffer >> (pb->bits_left - nbits))) & (BIT_N(nbits)-1); |
1076 | } | 1076 | } |
1077 | 1077 | ||
1078 | INLINE void drop_bits(struct bitstream* pb, int nbits) | 1078 | INLINE void drop_bits(struct bitstream* pb, int nbits) |
diff --git a/apps/plugins/lib/fixedpoint.c b/apps/plugins/lib/fixedpoint.c index 7b9b68a1e8..0ae2cded69 100644 --- a/apps/plugins/lib/fixedpoint.c +++ b/apps/plugins/lib/fixedpoint.c | |||
@@ -22,6 +22,7 @@ | |||
22 | ****************************************************************************/ | 22 | ****************************************************************************/ |
23 | 23 | ||
24 | #include <inttypes.h> | 24 | #include <inttypes.h> |
25 | #include "plugin.h" | ||
25 | #include "fixedpoint.h" | 26 | #include "fixedpoint.h" |
26 | 27 | ||
27 | /* Inverse gain of circular cordic rotation in s0.31 format. */ | 28 | /* Inverse gain of circular cordic rotation in s0.31 format. */ |
@@ -144,7 +145,7 @@ long fsincos(unsigned long phase, long *cos) | |||
144 | */ | 145 | */ |
145 | long fsqrt(long a, unsigned int fracbits) | 146 | long fsqrt(long a, unsigned int fracbits) |
146 | { | 147 | { |
147 | long b = a/2 + (1 << fracbits); /* initial approximation */ | 148 | long b = a/2 + BIT_N(fracbits); /* initial approximation */ |
148 | unsigned n; | 149 | unsigned n; |
149 | const unsigned iterations = 4; | 150 | const unsigned iterations = 4; |
150 | 151 | ||
diff --git a/apps/plugins/lib/grey_core.c b/apps/plugins/lib/grey_core.c index 18b2716d4d..ea70ae942b 100644 --- a/apps/plugins/lib/grey_core.c +++ b/apps/plugins/lib/grey_core.c | |||
@@ -860,7 +860,7 @@ static void grey_screendump_hook(int fd) | |||
860 | + _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK); | 860 | + _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK); |
861 | 861 | ||
862 | #if LCD_DEPTH == 1 | 862 | #if LCD_DEPTH == 1 |
863 | mask = 1 << (y & 7); | 863 | mask = BIT_N(y & 7); |
864 | src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); | 864 | src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); |
865 | 865 | ||
866 | do | 866 | do |
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c index e35e43a40a..b95ee7ab35 100644 --- a/apps/plugins/lib/helper.c +++ b/apps/plugins/lib/helper.c | |||
@@ -22,6 +22,20 @@ | |||
22 | #include "plugin.h" | 22 | #include "plugin.h" |
23 | #include "helper.h" | 23 | #include "helper.h" |
24 | 24 | ||
25 | #ifdef CPU_SH | ||
26 | /* Lookup table for using the BIT_N() macro in plugins */ | ||
27 | const unsigned bit_n_table[32] = { | ||
28 | 1LU<< 0, 1LU<< 1, 1LU<< 2, 1LU<< 3, | ||
29 | 1LU<< 4, 1LU<< 5, 1LU<< 6, 1LU<< 7, | ||
30 | 1LU<< 8, 1LU<< 9, 1LU<<10, 1LU<<11, | ||
31 | 1LU<<12, 1LU<<13, 1LU<<14, 1LU<<15, | ||
32 | 1LU<<16, 1LU<<17, 1LU<<18, 1LU<<19, | ||
33 | 1LU<<20, 1LU<<21, 1LU<<22, 1LU<<23, | ||
34 | 1LU<<24, 1LU<<25, 1LU<<26, 1LU<<27, | ||
35 | 1LU<<28, 1LU<<29, 1LU<<30, 1LU<<31 | ||
36 | }; | ||
37 | #endif | ||
38 | |||
25 | /* Force the backlight on */ | 39 | /* Force the backlight on */ |
26 | void backlight_force_on(void) | 40 | void backlight_force_on(void) |
27 | { | 41 | { |
diff --git a/apps/plugins/rockboy/cpu.c b/apps/plugins/rockboy/cpu.c index 1aca06f337..2fc7411411 100644 --- a/apps/plugins/rockboy/cpu.c +++ b/apps/plugins/rockboy/cpu.c | |||
@@ -147,9 +147,9 @@ F = (F & (FN)) | ZFLAG(A) | daa_carry_table[LB(acc)>>2]; } | |||
147 | (r) = swap_table[(r)]; \ | 147 | (r) = swap_table[(r)]; \ |
148 | F = ZFLAG((r)); } | 148 | F = ZFLAG((r)); } |
149 | 149 | ||
150 | #define BIT(n,r) { F = (F & FC) | ZFLAG(((r) & (1 << (n)))) | FH; } | 150 | #define BIT(n,r) { F = (F & FC) | ZFLAG(((r) & BIT_N(n))) | FH; } |
151 | #define RES(n,r) { (r) &= ~(1 << (n)); } | 151 | #define RES(n,r) { (r) &= ~BIT_N(n); } |
152 | #define SET(n,r) { (r) |= (1 << (n)); } | 152 | #define SET(n,r) { (r) |= BIT_N(n); } |
153 | 153 | ||
154 | #define CB_REG_CASES(r, n) \ | 154 | #define CB_REG_CASES(r, n) \ |
155 | case 0x00|(n): RLC(r); break; \ | 155 | case 0x00|(n): RLC(r); break; \ |
@@ -225,7 +225,7 @@ label: op(b); break; | |||
225 | 225 | ||
226 | 226 | ||
227 | #define PRE_INT ( DI, PUSH(PC) ) | 227 | #define PRE_INT ( DI, PUSH(PC) ) |
228 | #define THROW_INT(n) ( (IF &= ~(1<<(n))), (PC = 0x40+((n)<<3)) ) | 228 | #define THROW_INT(n) ( (IF &= ~BIT_N(n)), (PC = 0x40+((n)<<3)) ) |
229 | 229 | ||
230 | #ifdef DYNAREC | 230 | #ifdef DYNAREC |
231 | un32 reg_backup[16]; | 231 | un32 reg_backup[16]; |
@@ -355,7 +355,7 @@ static int cpu_idle(int max) | |||
355 | 355 | ||
356 | /* Figure out when the next timer interrupt will happen */ | 356 | /* Figure out when the next timer interrupt will happen */ |
357 | unit = ((-R_TAC) & 3) << 1; | 357 | unit = ((-R_TAC) & 3) << 1; |
358 | cnt = (511 - cpu.tim + (1<<unit)) >> unit; | 358 | cnt = (511 - cpu.tim + BIT_N(unit)) >> unit; |
359 | cnt += (255 - R_TIMA) << (9 - unit); | 359 | cnt += (255 - R_TIMA) << (9 - unit); |
360 | 360 | ||
361 | if (max < cnt) | 361 | if (max < cnt) |
diff --git a/apps/plugins/rockboy/lcd.c b/apps/plugins/rockboy/lcd.c index da3b138e51..372e9e0736 100644 --- a/apps/plugins/rockboy/lcd.c +++ b/apps/plugins/rockboy/lcd.c | |||
@@ -216,8 +216,8 @@ static void updatepatpix(void) | |||
216 | a = ((i<<4) | (j<<1)); | 216 | a = ((i<<4) | (j<<1)); |
217 | for (k = 0; k < 8; k++) | 217 | for (k = 0; k < 8; k++) |
218 | { | 218 | { |
219 | c = vram[a] & (1<<k) ? 1 : 0; | 219 | c = vram[a] & BIT_N(k) ? 1 : 0; |
220 | c |= vram[a+1] & (1<<k) ? 2 : 0; | 220 | c |= vram[a+1] & BIT_N(k) ? 2 : 0; |
221 | patpix[i+1024][j][k] = c; | 221 | patpix[i+1024][j][k] = c; |
222 | } | 222 | } |
223 | for (k = 0; k < 8; k++) | 223 | for (k = 0; k < 8; k++) |
diff --git a/apps/plugins/rockboy/sound.c b/apps/plugins/rockboy/sound.c index 041b7831d3..6efc01b11c 100644 --- a/apps/plugins/rockboy/sound.c +++ b/apps/plugins/rockboy/sound.c | |||
@@ -182,7 +182,7 @@ static void gbSoundChannel1(int *r, int *l) | |||
182 | int newfreq = 0; | 182 | int newfreq = 0; |
183 | if(S1.swsteps) | 183 | if(S1.swsteps) |
184 | { | 184 | { |
185 | newfreq = freq + updown * freq / (1 << S1.swsteps); | 185 | newfreq = freq + updown * freq / BIT_N(S1.swsteps); |
186 | if(newfreq == freq) | 186 | if(newfreq == freq) |
187 | newfreq = 0; | 187 | newfreq = 0; |
188 | } | 188 | } |
diff --git a/apps/plugins/sudoku/generator.c b/apps/plugins/sudoku/generator.c index 3d37bde22a..59bb9066cc 100644 --- a/apps/plugins/sudoku/generator.c +++ b/apps/plugins/sudoku/generator.c | |||
@@ -54,7 +54,7 @@ | |||
54 | 54 | ||
55 | #define STATE_MASK 0x0000ff80 | 55 | #define STATE_MASK 0x0000ff80 |
56 | #define STATE_SHIFT (7-1) /* digits 1..9 */ | 56 | #define STATE_SHIFT (7-1) /* digits 1..9 */ |
57 | #define DIGIT_STATE(digit) (1<<(STATE_SHIFT+(digit))) | 57 | #define DIGIT_STATE(digit) BIT_N(STATE_SHIFT+(digit)) |
58 | 58 | ||
59 | #define DIGIT_MASK 0x000f0000 | 59 | #define DIGIT_MASK 0x000f0000 |
60 | #define DIGIT_SHIFT 16 | 60 | #define DIGIT_SHIFT 16 |
@@ -266,7 +266,7 @@ numset( int mask ) | |||
266 | { | 266 | { |
267 | int i, n = 0; | 267 | int i, n = 0; |
268 | for( i = STATE_SHIFT + 1 ; i <= STATE_SHIFT + 9 ; ++i ) | 268 | for( i = STATE_SHIFT + 1 ; i <= STATE_SHIFT + 9 ; ++i ) |
269 | if( mask & (1<<i) ) | 269 | if( mask & BIT_N(i) ) |
270 | ++n; | 270 | ++n; |
271 | else | 271 | else |
272 | ++counts[ i - STATE_SHIFT - 1 ]; | 272 | ++counts[ i - STATE_SHIFT - 1 ]; |
diff --git a/apps/plugins/sudoku/sudoku.c b/apps/plugins/sudoku/sudoku.c index 69c41f476e..413be298ea 100644 --- a/apps/plugins/sudoku/sudoku.c +++ b/apps/plugins/sudoku/sudoku.c | |||
@@ -337,7 +337,7 @@ void sudoku_init(Sudoku* sud); | |||
337 | void sudoku_set(Sudoku* sud, int x, int y, int num, bool original); | 337 | void sudoku_set(Sudoku* sud, int x, int y, int num, bool original); |
338 | int sudoku_get(Sudoku* sud, int x, int y, bool* original); | 338 | int sudoku_get(Sudoku* sud, int x, int y, bool* original); |
339 | 339 | ||
340 | #define BIT(n) ((Bitset)(1<<(n))) | 340 | #define BIT(n) ((Bitset)BIT_N(n)) |
341 | #define BIT_TEST(v,n) ((((Bitset)v) & BIT(n)) != 0) | 341 | #define BIT_TEST(v,n) ((((Bitset)v) & BIT(n)) != 0) |
342 | #define BIT_CLEAR(v,n) (v) &= ~BIT(n) | 342 | #define BIT_CLEAR(v,n) (v) &= ~BIT(n) |
343 | #define MARK_BIT BIT(0) | 343 | #define MARK_BIT BIT(0) |
@@ -965,7 +965,7 @@ void display_board(struct sudoku_state_t* state) | |||
965 | rb->lcd_vline(XOFS+cellxpos[r]-2,YOFSSCRATCHPAD, | 965 | rb->lcd_vline(XOFS+cellxpos[r]-2,YOFSSCRATCHPAD, |
966 | YOFSSCRATCHPAD+CELL_HEIGHT+1); | 966 | YOFSSCRATCHPAD+CELL_HEIGHT+1); |
967 | #endif | 967 | #endif |
968 | if ((r>0) && state->possiblevals[state->y][state->x]&(1<<(r))) | 968 | if ((r>0) && state->possiblevals[state->y][state->x]&BIT_N(r)) |
969 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, | 969 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, |
970 | BITMAP_STRIDE,XOFS+cellxpos[r-1], | 970 | BITMAP_STRIDE,XOFS+cellxpos[r-1], |
971 | YOFSSCRATCHPAD+1,CELL_WIDTH,CELL_HEIGHT); | 971 | YOFSSCRATCHPAD+1,CELL_WIDTH,CELL_HEIGHT); |
@@ -976,7 +976,7 @@ void display_board(struct sudoku_state_t* state) | |||
976 | rb->lcd_vline(XOFS+cellxpos[8]+CELL_WIDTH+1,YOFSSCRATCHPAD, | 976 | rb->lcd_vline(XOFS+cellxpos[8]+CELL_WIDTH+1,YOFSSCRATCHPAD, |
977 | YOFSSCRATCHPAD+CELL_HEIGHT+1); | 977 | YOFSSCRATCHPAD+CELL_HEIGHT+1); |
978 | #endif | 978 | #endif |
979 | if (state->possiblevals[state->y][state->x]&(1<<(r))) | 979 | if (state->possiblevals[state->y][state->x]&BIT_N(r)) |
980 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, | 980 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, |
981 | BITMAP_STRIDE,XOFS+cellxpos[8],YOFSSCRATCHPAD+1, | 981 | BITMAP_STRIDE,XOFS+cellxpos[8],YOFSSCRATCHPAD+1, |
982 | CELL_WIDTH,CELL_HEIGHT); | 982 | CELL_WIDTH,CELL_HEIGHT); |
@@ -1004,7 +1004,7 @@ void display_board(struct sudoku_state_t* state) | |||
1004 | rb->lcd_hline(XOFSSCRATCHPAD,XOFSSCRATCHPAD+CELL_WIDTH+1, | 1004 | rb->lcd_hline(XOFSSCRATCHPAD,XOFSSCRATCHPAD+CELL_WIDTH+1, |
1005 | YOFS+cellypos[r]-2); | 1005 | YOFS+cellypos[r]-2); |
1006 | #endif | 1006 | #endif |
1007 | if ((r>0) && state->possiblevals[state->y][state->x]&(1<<(r))) | 1007 | if ((r>0) && state->possiblevals[state->y][state->x]&BIT_N(r)) |
1008 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, | 1008 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, |
1009 | BITMAP_STRIDE,XOFSSCRATCHPAD+1, | 1009 | BITMAP_STRIDE,XOFSSCRATCHPAD+1, |
1010 | YOFS+cellypos[r-1],CELL_WIDTH,CELL_HEIGHT); | 1010 | YOFS+cellypos[r-1],CELL_WIDTH,CELL_HEIGHT); |
@@ -1015,7 +1015,7 @@ void display_board(struct sudoku_state_t* state) | |||
1015 | rb->lcd_hline(XOFSSCRATCHPAD,XOFSSCRATCHPAD+CELL_WIDTH+1, | 1015 | rb->lcd_hline(XOFSSCRATCHPAD,XOFSSCRATCHPAD+CELL_WIDTH+1, |
1016 | YOFS+cellypos[8]+CELL_HEIGHT+1); | 1016 | YOFS+cellypos[8]+CELL_HEIGHT+1); |
1017 | #endif | 1017 | #endif |
1018 | if (state->possiblevals[state->y][state->x]&(1<<(r))) | 1018 | if (state->possiblevals[state->y][state->x]&BIT_N(r)) |
1019 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, | 1019 | rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, |
1020 | BITMAP_STRIDE,XOFSSCRATCHPAD+1,YOFS+cellypos[8], | 1020 | BITMAP_STRIDE,XOFSSCRATCHPAD+1,YOFS+cellypos[8], |
1021 | CELL_WIDTH,CELL_HEIGHT); | 1021 | CELL_WIDTH,CELL_HEIGHT); |
@@ -1552,7 +1552,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
1552 | /* Toggle current number in the possiblevals structure */ | 1552 | /* Toggle current number in the possiblevals structure */ |
1553 | if (state.currentboard[state.y][state.x]!='0') { | 1553 | if (state.currentboard[state.y][state.x]!='0') { |
1554 | state.possiblevals[state.y][state.x]^= | 1554 | state.possiblevals[state.y][state.x]^= |
1555 | (1 << (state.currentboard[state.y][state.x] - '0')); | 1555 | BIT_N(state.currentboard[state.y][state.x] - '0'); |
1556 | } | 1556 | } |
1557 | break; | 1557 | break; |
1558 | #endif | 1558 | #endif |
diff --git a/apps/plugins/zxbox/sp_def.h b/apps/plugins/zxbox/sp_def.h index 1030be120c..931804ff9c 100644 --- a/apps/plugins/zxbox/sp_def.h +++ b/apps/plugins/zxbox/sp_def.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1996-1998 Szeredi Miklos | 2 | * Copyright (C) 1996-1998 Szeredi Miklos |
3 | * Email: mszeredi@inf.bme.hu | 3 | * Email: mszeredi@inf.bme.hu |
4 | * | 4 | * |
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | #include "spperif.h" | 21 | #include "spperif.h" |
22 | 22 | ||
23 | #define MARK_SCR(addr) SPNM(scr_mark)[(addr) >> 5] |= 1 << ((addr) & 0x1F) | 23 | #define MARK_SCR(addr) SPNM(scr_mark)[(addr) >> 5] |= BIT_N((addr) & 0x1F) |
24 | 24 | ||
25 | #define PUTMEM(addr, ptr, val) \ | 25 | #define PUTMEM(addr, ptr, val) \ |
26 | { \ | 26 | { \ |
diff --git a/apps/plugins/zxbox/spkey.c b/apps/plugins/zxbox/spkey.c index a21aed6af2..77427e8015 100644 --- a/apps/plugins/zxbox/spkey.c +++ b/apps/plugins/zxbox/spkey.c | |||
@@ -85,7 +85,7 @@ int spkb_state_changed; | |||
85 | 85 | ||
86 | #define SKE {0, 0, 0, 0, 0, 0, 0, 0} | 86 | #define SKE {0, 0, 0, 0, 0, 0, 0, 0} |
87 | 87 | ||
88 | #define SKP(x) (1 << x) | 88 | #define SKP(x) BIT_N(x) |
89 | 89 | ||
90 | #define SKN0(x) {SKP(x), 0, 0, 0, 0, 0, 0, 0} | 90 | #define SKN0(x) {SKP(x), 0, 0, 0, 0, 0, 0, 0} |
91 | #define SKN1(x) {0, SKP(x), 0, 0, 0, 0, 0, 0} | 91 | #define SKN1(x) {0, SKP(x), 0, 0, 0, 0, 0, 0} |
@@ -617,7 +617,7 @@ static void copy_basekeys(struct spbasekey *addk) | |||
617 | static unsigned transform_shift(int modif) | 617 | static unsigned transform_shift(int modif) |
618 | { | 618 | { |
619 | if(!modif) return 0; | 619 | if(!modif) return 0; |
620 | else return (1 << (modif - 1)); | 620 | else return BIT_N(modif - 1); |
621 | } | 621 | } |
622 | 622 | ||
623 | 623 | ||
diff --git a/apps/plugins/zxbox/spscr.c b/apps/plugins/zxbox/spscr.c index 2c24fb37a8..d419ff0c66 100644 --- a/apps/plugins/zxbox/spscr.c +++ b/apps/plugins/zxbox/spscr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 1996-1998 Szeredi Miklos | 2 | * Copyright (C) 1996-1998 Szeredi Miklos |
3 | * Email: mszeredi@inf.bme.hu | 3 | * Email: mszeredi@inf.bme.hu |
4 | * | 4 | * |
@@ -82,7 +82,7 @@ byte *update_screen_line(byte *scrp, int coli, int scri, int border, | |||
82 | SPNM(imag_mark)[coli] |= mark; | 82 | SPNM(imag_mark)[coli] |= mark; |
83 | SPNM(imag_horiz) |= mark; | 83 | SPNM(imag_horiz) |= mark; |
84 | coli >>= 3; | 84 | coli >>= 3; |
85 | SPNM(imag_vert) |= (1 << coli); | 85 | SPNM(imag_vert) |= BIT_N(coli); |
86 | 86 | ||
87 | spmp = PRNM(proc).mem + (scri << 5); | 87 | spmp = PRNM(proc).mem + (scri << 5); |
88 | spcp = PRNM(proc).mem + 0x5800 + (coli << 5); | 88 | spcp = PRNM(proc).mem + 0x5800 + (coli << 5); |
diff --git a/apps/recorder/bmp.c b/apps/recorder/bmp.c index 1d5d378708..8fcd8ca92e 100644 --- a/apps/recorder/bmp.c +++ b/apps/recorder/bmp.c | |||
@@ -617,7 +617,7 @@ int read_bmp_fd(int fd, | |||
617 | if (depth <= 8) { | 617 | if (depth <= 8) { |
618 | numcolors = letoh32(bmph.clr_used); | 618 | numcolors = letoh32(bmph.clr_used); |
619 | if (numcolors == 0) | 619 | if (numcolors == 0) |
620 | numcolors = 1 << depth; | 620 | numcolors = BIT_N(depth); |
621 | } else | 621 | } else |
622 | numcolors = (compression == 3) ? 3 : 0; | 622 | numcolors = (compression == 3) ? 3 : 0; |
623 | 623 | ||
@@ -795,7 +795,7 @@ int read_bmp_fd(int fd, | |||
795 | #ifndef PLUGIN | 795 | #ifndef PLUGIN |
796 | { | 796 | { |
797 | unsigned char *p = bitmap + bm->width * (row >> 3); | 797 | unsigned char *p = bitmap + bm->width * (row >> 3); |
798 | unsigned char mask = 1 << (row & 7); | 798 | unsigned char mask = BIT_N(row & 7); |
799 | int col; | 799 | int col; |
800 | for (col = 0; col < bm->width; col++, p++) | 800 | for (col = 0; col < bm->width; col++, p++) |
801 | #if !defined(HAVE_LCD_COLOR) && \ | 801 | #if !defined(HAVE_LCD_COLOR) && \ |
diff --git a/apps/recorder/jpeg_load.c b/apps/recorder/jpeg_load.c index 027ddaf5a8..3334019958 100644 --- a/apps/recorder/jpeg_load.c +++ b/apps/recorder/jpeg_load.c | |||
@@ -1506,7 +1506,8 @@ INLINE void fix_huff_tables(struct jpeg *p_jpeg) | |||
1506 | */ | 1506 | */ |
1507 | INLINE void fix_quant_tables(struct jpeg *p_jpeg) | 1507 | INLINE void fix_quant_tables(struct jpeg *p_jpeg) |
1508 | { | 1508 | { |
1509 | int shift, i, x, y, a; | 1509 | int shift, i, a; |
1510 | unsigned x, y; | ||
1510 | for (i = 0; i < 2; i++) | 1511 | for (i = 0; i < 2; i++) |
1511 | { | 1512 | { |
1512 | shift = idct_tbl[p_jpeg->v_scale[i]].v_scale + | 1513 | shift = idct_tbl[p_jpeg->v_scale[i]].v_scale + |
@@ -1514,9 +1515,9 @@ INLINE void fix_quant_tables(struct jpeg *p_jpeg) | |||
1514 | if (shift) | 1515 | if (shift) |
1515 | { | 1516 | { |
1516 | a = 0; | 1517 | a = 0; |
1517 | for (y = 0; y < 1 << p_jpeg->h_scale[i]; y++) | 1518 | for (y = 0; y < BIT_N(p_jpeg->h_scale[i]); y++) |
1518 | { | 1519 | { |
1519 | for (x = 0; x < 1 << p_jpeg->v_scale[i]; x++) | 1520 | for (x = 0; x < BIT_N(p_jpeg->v_scale[i]); x++) |
1520 | p_jpeg->quanttable[i][zig[a+x]] <<= shift; | 1521 | p_jpeg->quanttable[i][zig[a+x]] <<= shift; |
1521 | a += 8; | 1522 | a += 8; |
1522 | } | 1523 | } |
@@ -1586,7 +1587,7 @@ INLINE int get_bits(struct jpeg *p_jpeg, int nbits) | |||
1586 | #ifdef JPEG_BS_DEBUG | 1587 | #ifdef JPEG_BS_DEBUG |
1587 | if (nbits > p_jpeg->bitbuf_bits) | 1588 | if (nbits > p_jpeg->bitbuf_bits) |
1588 | DEBUGF("bitbuffer underrun\n"); | 1589 | DEBUGF("bitbuffer underrun\n"); |
1589 | int mask = 1 << (p_jpeg->bitbuf_bits - 1); | 1590 | int mask = BIT_N(p_jpeg->bitbuf_bits - 1); |
1590 | int i; | 1591 | int i; |
1591 | DEBUGF("get %d bits: ", nbits); | 1592 | DEBUGF("get %d bits: ", nbits); |
1592 | for (i = 0; i < nbits; i++) | 1593 | for (i = 0; i < nbits; i++) |
@@ -1594,13 +1595,13 @@ INLINE int get_bits(struct jpeg *p_jpeg, int nbits) | |||
1594 | DEBUGF("\n"); | 1595 | DEBUGF("\n"); |
1595 | #endif | 1596 | #endif |
1596 | return ((int) (p_jpeg->bitbuf >> (p_jpeg->bitbuf_bits -= nbits))) & | 1597 | return ((int) (p_jpeg->bitbuf >> (p_jpeg->bitbuf_bits -= nbits))) & |
1597 | ((1<<nbits)-1); | 1598 | (BIT_N(nbits)-1); |
1598 | } | 1599 | } |
1599 | 1600 | ||
1600 | INLINE int peek_bits(struct jpeg *p_jpeg, int nbits) | 1601 | INLINE int peek_bits(struct jpeg *p_jpeg, int nbits) |
1601 | { | 1602 | { |
1602 | #ifdef JPEG_BS_DEBUG | 1603 | #ifdef JPEG_BS_DEBUG |
1603 | int mask = 1 << (p_jpeg->bitbuf_bits - 1); | 1604 | int mask = BIT_N(p_jpeg->bitbuf_bits - 1); |
1604 | int i; | 1605 | int i; |
1605 | DEBUGF("peek %d bits: ", nbits); | 1606 | DEBUGF("peek %d bits: ", nbits); |
1606 | for (i = 0; i < nbits; i++) | 1607 | for (i = 0; i < nbits; i++) |
@@ -1608,13 +1609,13 @@ INLINE int peek_bits(struct jpeg *p_jpeg, int nbits) | |||
1608 | DEBUGF("\n"); | 1609 | DEBUGF("\n"); |
1609 | #endif | 1610 | #endif |
1610 | return ((int) (p_jpeg->bitbuf >> (p_jpeg->bitbuf_bits - nbits))) & | 1611 | return ((int) (p_jpeg->bitbuf >> (p_jpeg->bitbuf_bits - nbits))) & |
1611 | ((1<<nbits)-1); | 1612 | (BIT_N(nbits)-1); |
1612 | } | 1613 | } |
1613 | 1614 | ||
1614 | INLINE void drop_bits(struct jpeg *p_jpeg, int nbits) | 1615 | INLINE void drop_bits(struct jpeg *p_jpeg, int nbits) |
1615 | { | 1616 | { |
1616 | #ifdef JPEG_BS_DEBUG | 1617 | #ifdef JPEG_BS_DEBUG |
1617 | int mask = 1 << (p_jpeg->bitbuf_bits - 1); | 1618 | int mask = BIT_N(p_jpeg->bitbuf_bits - 1); |
1618 | int i; | 1619 | int i; |
1619 | DEBUGF("drop %d bits: ", nbits); | 1620 | DEBUGF("drop %d bits: ", nbits); |
1620 | for (i = 0; i < nbits; i++) | 1621 | for (i = 0; i < nbits; i++) |
@@ -1675,7 +1676,7 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ | |||
1675 | ({ \ | 1676 | ({ \ |
1676 | int x__ = x; \ | 1677 | int x__ = x; \ |
1677 | int s__ = s; \ | 1678 | int s__ = s; \ |
1678 | x__ & (1 << (s__- 1)) ? x__ : x__ + (-1 << s__) + 1; \ | 1679 | x__ & BIT_N(s__- 1) ? x__ : x__ + (-1 << s__) + 1; \ |
1679 | }) | 1680 | }) |
1680 | #endif | 1681 | #endif |
1681 | 1682 | ||
@@ -1764,14 +1765,14 @@ static struct img_part *store_row_jpeg(void *jpeg_args) | |||
1764 | #endif | 1765 | #endif |
1765 | unsigned int width = p_jpeg->x_mbl << mcu_hscale; | 1766 | unsigned int width = p_jpeg->x_mbl << mcu_hscale; |
1766 | unsigned int b_width = width * JPEG_PIX_SZ; | 1767 | unsigned int b_width = width * JPEG_PIX_SZ; |
1767 | int height = 1U << mcu_vscale; | 1768 | int height = BIT_N(mcu_vscale); |
1768 | int x; | 1769 | int x; |
1769 | if (!p_jpeg->mcu_row) /* Need to decode a new row of MCUs */ | 1770 | if (!p_jpeg->mcu_row) /* Need to decode a new row of MCUs */ |
1770 | { | 1771 | { |
1771 | p_jpeg->out_ptr = (unsigned char *)p_jpeg->img_buf; | 1772 | p_jpeg->out_ptr = (unsigned char *)p_jpeg->img_buf; |
1772 | int store_offs[4]; | 1773 | int store_offs[4]; |
1773 | #ifdef HAVE_LCD_COLOR | 1774 | #ifdef HAVE_LCD_COLOR |
1774 | unsigned mcu_width = 1U << mcu_hscale; | 1775 | unsigned mcu_width = BIT_N(mcu_hscale); |
1775 | #endif | 1776 | #endif |
1776 | int mcu_offset = JPEG_PIX_SZ << mcu_hscale; | 1777 | int mcu_offset = JPEG_PIX_SZ << mcu_hscale; |
1777 | unsigned char *out = p_jpeg->out_ptr; | 1778 | unsigned char *out = p_jpeg->out_ptr; |
@@ -1868,8 +1869,8 @@ static struct img_part *store_row_jpeg(void *jpeg_args) | |||
1868 | if (!ci) | 1869 | if (!ci) |
1869 | #endif | 1870 | #endif |
1870 | { | 1871 | { |
1871 | int idct_cols = 1 << MIN(p_jpeg->h_scale[!!ci], 3); | 1872 | int idct_cols = BIT_N(MIN(p_jpeg->h_scale[!!ci], 3)); |
1872 | int idct_rows = 1 << p_jpeg->v_scale[!!ci]; | 1873 | int idct_rows = BIT_N(p_jpeg->v_scale[!!ci]); |
1873 | unsigned char *b_out = out + (ci ? ci : store_offs[blkn]); | 1874 | unsigned char *b_out = out + (ci ? ci : store_offs[blkn]); |
1874 | if (idct_tbl[p_jpeg->v_scale[!!ci]].v_idct) | 1875 | if (idct_tbl[p_jpeg->v_scale[!!ci]].v_idct) |
1875 | idct_tbl[p_jpeg->v_scale[!!ci]].v_idct(block, | 1876 | idct_tbl[p_jpeg->v_scale[!!ci]].v_idct(block, |
@@ -2043,8 +2044,8 @@ int read_jpeg_fd(int fd, | |||
2043 | } | 2044 | } |
2044 | p_jpeg->h_scale[0] = calc_scale(p_jpeg->x_size, bm->width); | 2045 | p_jpeg->h_scale[0] = calc_scale(p_jpeg->x_size, bm->width); |
2045 | p_jpeg->v_scale[0] = calc_scale(p_jpeg->y_size, bm->height); | 2046 | p_jpeg->v_scale[0] = calc_scale(p_jpeg->y_size, bm->height); |
2046 | JDEBUGF("luma IDCT size: %dx%d\n", 1 << p_jpeg->h_scale[0], | 2047 | JDEBUGF("luma IDCT size: %dx%d\n", BIT_N(p_jpeg->h_scale[0]), |
2047 | 1 << p_jpeg->v_scale[0]); | 2048 | BIT_N(p_jpeg->v_scale[0])); |
2048 | if ((p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3 == bm->width && | 2049 | if ((p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3 == bm->width && |
2049 | (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3 == bm->height) | 2050 | (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3 == bm->height) |
2050 | resize = false; | 2051 | resize = false; |
@@ -2053,24 +2054,24 @@ int read_jpeg_fd(int fd, | |||
2053 | p_jpeg->frameheader[0].horizontal_sampling - 1; | 2054 | p_jpeg->frameheader[0].horizontal_sampling - 1; |
2054 | p_jpeg->v_scale[1] = p_jpeg->v_scale[0] + | 2055 | p_jpeg->v_scale[1] = p_jpeg->v_scale[0] + |
2055 | p_jpeg->frameheader[0].vertical_sampling - 1; | 2056 | p_jpeg->frameheader[0].vertical_sampling - 1; |
2056 | JDEBUGF("chroma IDCT size: %dx%d\n", 1 << p_jpeg->h_scale[1], | 2057 | JDEBUGF("chroma IDCT size: %dx%d\n", BIT_N(p_jpeg->h_scale[1]), |
2057 | 1 << p_jpeg->v_scale[1]); | 2058 | BIT_N(p_jpeg->v_scale[1])); |
2058 | #endif | 2059 | #endif |
2059 | JDEBUGF("scaling from %dx%d -> %dx%d\n", | 2060 | JDEBUGF("scaling from %dx%d -> %dx%d\n", |
2060 | (p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3, | 2061 | (p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3, |
2061 | (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3, | 2062 | (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3, |
2062 | bm->width, bm->height); | 2063 | bm->width, bm->height); |
2063 | fix_quant_tables(p_jpeg); | 2064 | fix_quant_tables(p_jpeg); |
2064 | int decode_w = (1 << p_jpeg->h_scale[0]) - 1; | 2065 | int decode_w = BIT_N(p_jpeg->h_scale[0]) - 1; |
2065 | int decode_h = (1 << p_jpeg->v_scale[0]) - 1; | 2066 | int decode_h = BIT_N(p_jpeg->v_scale[0]) - 1; |
2066 | src_dim.width = (p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3; | 2067 | src_dim.width = (p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3; |
2067 | src_dim.height = (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3; | 2068 | src_dim.height = (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3; |
2068 | p_jpeg->zero_need[0] = (decode_h << 3) + decode_w; | 2069 | p_jpeg->zero_need[0] = (decode_h << 3) + decode_w; |
2069 | p_jpeg->k_need[0] = zig[p_jpeg->zero_need[0]]; | 2070 | p_jpeg->k_need[0] = zig[p_jpeg->zero_need[0]]; |
2070 | JDEBUGF("need luma components to %d\n", p_jpeg->k_need[0]); | 2071 | JDEBUGF("need luma components to %d\n", p_jpeg->k_need[0]); |
2071 | #ifdef HAVE_LCD_COLOR | 2072 | #ifdef HAVE_LCD_COLOR |
2072 | decode_w = (1 << MIN(p_jpeg->h_scale[1],3)) - 1; | 2073 | decode_w = BIT_N(MIN(p_jpeg->h_scale[1],3)) - 1; |
2073 | decode_h = (1 << MIN(p_jpeg->v_scale[1],3)) - 1; | 2074 | decode_h = BIT_N(MIN(p_jpeg->v_scale[1],3)) - 1; |
2074 | p_jpeg->zero_need[1] = (decode_h << 3) + decode_w; | 2075 | p_jpeg->zero_need[1] = (decode_h << 3) + decode_w; |
2075 | p_jpeg->k_need[1] = zig[p_jpeg->zero_need[1]]; | 2076 | p_jpeg->k_need[1] = zig[p_jpeg->zero_need[1]]; |
2076 | JDEBUGF("need chroma components to %d\n", p_jpeg->k_need[1]); | 2077 | JDEBUGF("need chroma components to %d\n", p_jpeg->k_need[1]); |
diff --git a/apps/replaygain.c b/apps/replaygain.c index 8f6fe4c738..90944f91d0 100644 --- a/apps/replaygain.c +++ b/apps/replaygain.c | |||
@@ -134,12 +134,12 @@ static long fp_div(long x, long y) | |||
134 | y = -y; | 134 | y = -y; |
135 | } | 135 | } |
136 | 136 | ||
137 | while ((x & (1 << (30 - msb))) == 0) | 137 | while ((x & BIT_N(30 - msb)) == 0) |
138 | { | 138 | { |
139 | msb++; | 139 | msb++; |
140 | } | 140 | } |
141 | 141 | ||
142 | while ((y & (1 << lsb)) == 0) | 142 | while ((y & BIT_N(lsb)) == 0) |
143 | { | 143 | { |
144 | lsb++; | 144 | lsb++; |
145 | } | 145 | } |
@@ -216,7 +216,7 @@ static long fp_exp10(long x) | |||
216 | static long fp_atof(const char* s, int precision) | 216 | static long fp_atof(const char* s, int precision) |
217 | { | 217 | { |
218 | long int_part = 0; | 218 | long int_part = 0; |
219 | long int_one = 1 << precision; | 219 | long int_one = BIT_N(precision); |
220 | long frac_part = 0; | 220 | long frac_part = 0; |
221 | long frac_count = 0; | 221 | long frac_count = 0; |
222 | long frac_max = ((precision * 4) + 12) / 13; | 222 | long frac_max = ((precision * 4) + 12) / 13; |
diff --git a/apps/screens.c b/apps/screens.c index 44ec2b64d8..096b81411e 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -339,7 +339,7 @@ static void charging_display_info(bool animate) | |||
339 | bitpos = (phase + i/8) % 15; /* "bounce" effect */ | 339 | bitpos = (phase + i/8) % 15; /* "bounce" effect */ |
340 | if (bitpos > 7) | 340 | if (bitpos > 7) |
341 | bitpos = 14 - bitpos; | 341 | bitpos = 14 - bitpos; |
342 | charging_logo[i] = 0x01 << bitpos; | 342 | charging_logo[i] = BIT_N(bitpos); |
343 | } | 343 | } |
344 | } | 344 | } |
345 | lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8, | 345 | lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8, |