summaryrefslogtreecommitdiff
path: root/apps/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins')
-rw-r--r--apps/plugins/alpine_cdc.c6
-rw-r--r--apps/plugins/jpeg/jpeg_decoder.c4
-rw-r--r--apps/plugins/lib/fixedpoint.c3
-rw-r--r--apps/plugins/lib/grey_core.c2
-rw-r--r--apps/plugins/lib/helper.c14
-rw-r--r--apps/plugins/rockboy/cpu.c10
-rw-r--r--apps/plugins/rockboy/lcd.c4
-rw-r--r--apps/plugins/rockboy/sound.c2
-rw-r--r--apps/plugins/sudoku/generator.c4
-rw-r--r--apps/plugins/sudoku/sudoku.c12
-rw-r--r--apps/plugins/zxbox/sp_def.h4
-rw-r--r--apps/plugins/zxbox/spkey.c4
-rw-r--r--apps/plugins/zxbox/spscr.c4
13 files changed, 44 insertions, 29 deletions
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
670bool bit_test(unsigned char* buf, unsigned bit) 670bool 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
676void bit_set(unsigned char* buf, unsigned bit, bool val) 676void 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
1068INLINE int get_bits(struct bitstream* pb, int nbits) 1068INLINE 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
1073INLINE int peek_bits(struct bitstream* pb, int nbits) 1073INLINE 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
1078INLINE void drop_bits(struct bitstream* pb, int nbits) 1078INLINE 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 */
145long fsqrt(long a, unsigned int fracbits) 146long 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 */
27const 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 */
26void backlight_force_on(void) 40void 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)]; \
148F = ZFLAG((r)); } 148F = 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) \
155case 0x00|(n): RLC(r); break; \ 155case 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
231un32 reg_backup[16]; 231un32 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);
337void sudoku_set(Sudoku* sud, int x, int y, int num, bool original); 337void sudoku_set(Sudoku* sud, int x, int y, int num, bool original);
338int sudoku_get(Sudoku* sud, int x, int y, bool* original); 338int 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)
617static unsigned transform_shift(int modif) 617static 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);