From 1d6df54df27cb41c02226678a2c8f9feddd1a1e0 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Sun, 7 Jun 2009 21:27:05 +0000 Subject: Convert a number of places in core and plugins to use the BIT_N() macro instead of 1< #include #include "config.h" +#include "system.h" /* Format a large-range value for output, using the appropriate unit so that * 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); * - position: 0-based number of the value * - valid_vals: value after the call to 'parse_list' */ -#define LIST_VALUE_PARSED(setvals, position) ((setvals)&(1<<(position))) +#define LIST_VALUE_PARSED(setvals, position) ((setvals) & BIT_N(position)) const char* parse_list(const char *fmt, uint32_t *set_vals, const char sep, const char* str, ...); 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) bool bit_test(unsigned char* buf, unsigned bit) { - return (buf[bit/4] & (0x01 << bit%4)) != 0; + return (buf[bit>>2] & BIT_N(bit&3)) != 0; } void bit_set(unsigned char* buf, unsigned bit, bool val) { if (val) - buf[bit/4] |= (0x01 << bit%4); + buf[bit>>2] |= BIT_N(bit&3); else - buf[bit/4] &= ~(0x01 << bit%4); + buf[bit>>2] &= ~BIT_N(bit&3); } 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) INLINE int get_bits(struct bitstream* pb, int nbits) { - return ((int) (pb->get_buffer >> (pb->bits_left -= nbits))) & ((1<get_buffer >> (pb->bits_left -= nbits))) & (BIT_N(nbits)-1); } INLINE int peek_bits(struct bitstream* pb, int nbits) { - return ((int) (pb->get_buffer >> (pb->bits_left - nbits))) & ((1<get_buffer >> (pb->bits_left - nbits))) & (BIT_N(nbits)-1); } 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 @@ ****************************************************************************/ #include +#include "plugin.h" #include "fixedpoint.h" /* Inverse gain of circular cordic rotation in s0.31 format. */ @@ -144,7 +145,7 @@ long fsincos(unsigned long phase, long *cos) */ long fsqrt(long a, unsigned int fracbits) { - long b = a/2 + (1 << fracbits); /* initial approximation */ + long b = a/2 + BIT_N(fracbits); /* initial approximation */ unsigned n; const unsigned iterations = 4; 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) + _GREY_MULUQ(_grey_info.width, gy & ~_GREY_BMASK); #if LCD_DEPTH == 1 - mask = 1 << (y & 7); + mask = BIT_N(y & 7); src = rb->lcd_framebuffer + _GREY_MULUQ(LCD_WIDTH, y >> 3); 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 @@ #include "plugin.h" #include "helper.h" +#ifdef CPU_SH +/* Lookup table for using the BIT_N() macro in plugins */ +const unsigned bit_n_table[32] = { + 1LU<< 0, 1LU<< 1, 1LU<< 2, 1LU<< 3, + 1LU<< 4, 1LU<< 5, 1LU<< 6, 1LU<< 7, + 1LU<< 8, 1LU<< 9, 1LU<<10, 1LU<<11, + 1LU<<12, 1LU<<13, 1LU<<14, 1LU<<15, + 1LU<<16, 1LU<<17, 1LU<<18, 1LU<<19, + 1LU<<20, 1LU<<21, 1LU<<22, 1LU<<23, + 1LU<<24, 1LU<<25, 1LU<<26, 1LU<<27, + 1LU<<28, 1LU<<29, 1LU<<30, 1LU<<31 +}; +#endif + /* Force the backlight on */ void backlight_force_on(void) { 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]; } (r) = swap_table[(r)]; \ F = ZFLAG((r)); } -#define BIT(n,r) { F = (F & FC) | ZFLAG(((r) & (1 << (n)))) | FH; } -#define RES(n,r) { (r) &= ~(1 << (n)); } -#define SET(n,r) { (r) |= (1 << (n)); } +#define BIT(n,r) { F = (F & FC) | ZFLAG(((r) & BIT_N(n))) | FH; } +#define RES(n,r) { (r) &= ~BIT_N(n); } +#define SET(n,r) { (r) |= BIT_N(n); } #define CB_REG_CASES(r, n) \ case 0x00|(n): RLC(r); break; \ @@ -225,7 +225,7 @@ label: op(b); break; #define PRE_INT ( DI, PUSH(PC) ) -#define THROW_INT(n) ( (IF &= ~(1<<(n))), (PC = 0x40+((n)<<3)) ) +#define THROW_INT(n) ( (IF &= ~BIT_N(n)), (PC = 0x40+((n)<<3)) ) #ifdef DYNAREC un32 reg_backup[16]; @@ -355,7 +355,7 @@ static int cpu_idle(int max) /* Figure out when the next timer interrupt will happen */ unit = ((-R_TAC) & 3) << 1; - cnt = (511 - cpu.tim + (1<> unit; + cnt = (511 - cpu.tim + BIT_N(unit)) >> unit; cnt += (255 - R_TIMA) << (9 - unit); 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) a = ((i<<4) | (j<<1)); for (k = 0; k < 8; k++) { - c = vram[a] & (1<lcd_vline(XOFS+cellxpos[r]-2,YOFSSCRATCHPAD, YOFSSCRATCHPAD+CELL_HEIGHT+1); #endif - if ((r>0) && state->possiblevals[state->y][state->x]&(1<<(r))) + if ((r>0) && state->possiblevals[state->y][state->x]&BIT_N(r)) rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, BITMAP_STRIDE,XOFS+cellxpos[r-1], YOFSSCRATCHPAD+1,CELL_WIDTH,CELL_HEIGHT); @@ -976,7 +976,7 @@ void display_board(struct sudoku_state_t* state) rb->lcd_vline(XOFS+cellxpos[8]+CELL_WIDTH+1,YOFSSCRATCHPAD, YOFSSCRATCHPAD+CELL_HEIGHT+1); #endif - if (state->possiblevals[state->y][state->x]&(1<<(r))) + if (state->possiblevals[state->y][state->x]&BIT_N(r)) rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, BITMAP_STRIDE,XOFS+cellxpos[8],YOFSSCRATCHPAD+1, CELL_WIDTH,CELL_HEIGHT); @@ -1004,7 +1004,7 @@ void display_board(struct sudoku_state_t* state) rb->lcd_hline(XOFSSCRATCHPAD,XOFSSCRATCHPAD+CELL_WIDTH+1, YOFS+cellypos[r]-2); #endif - if ((r>0) && state->possiblevals[state->y][state->x]&(1<<(r))) + if ((r>0) && state->possiblevals[state->y][state->x]&BIT_N(r)) rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, BITMAP_STRIDE,XOFSSCRATCHPAD+1, YOFS+cellypos[r-1],CELL_WIDTH,CELL_HEIGHT); @@ -1015,7 +1015,7 @@ void display_board(struct sudoku_state_t* state) rb->lcd_hline(XOFSSCRATCHPAD,XOFSSCRATCHPAD+CELL_WIDTH+1, YOFS+cellypos[8]+CELL_HEIGHT+1); #endif - if (state->possiblevals[state->y][state->x]&(1<<(r))) + if (state->possiblevals[state->y][state->x]&BIT_N(r)) rb->lcd_bitmap_part(sudoku_normal,NUMBER_TYPE,BITMAP_HEIGHT*r, BITMAP_STRIDE,XOFSSCRATCHPAD+1,YOFS+cellypos[8], CELL_WIDTH,CELL_HEIGHT); @@ -1552,7 +1552,7 @@ enum plugin_status plugin_start(const void* parameter) /* Toggle current number in the possiblevals structure */ if (state.currentboard[state.y][state.x]!='0') { state.possiblevals[state.y][state.x]^= - (1 << (state.currentboard[state.y][state.x] - '0')); + BIT_N(state.currentboard[state.y][state.x] - '0'); } break; #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 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -20,7 +20,7 @@ #include "spperif.h" -#define MARK_SCR(addr) SPNM(scr_mark)[(addr) >> 5] |= 1 << ((addr) & 0x1F) +#define MARK_SCR(addr) SPNM(scr_mark)[(addr) >> 5] |= BIT_N((addr) & 0x1F) #define PUTMEM(addr, ptr, val) \ { \ 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; #define SKE {0, 0, 0, 0, 0, 0, 0, 0} -#define SKP(x) (1 << x) +#define SKP(x) BIT_N(x) #define SKN0(x) {SKP(x), 0, 0, 0, 0, 0, 0, 0} #define SKN1(x) {0, SKP(x), 0, 0, 0, 0, 0, 0} @@ -617,7 +617,7 @@ static void copy_basekeys(struct spbasekey *addk) static unsigned transform_shift(int modif) { if(!modif) return 0; - else return (1 << (modif - 1)); + else return BIT_N(modif - 1); } 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 @@ -/* +/* * Copyright (C) 1996-1998 Szeredi Miklos * Email: mszeredi@inf.bme.hu * @@ -82,7 +82,7 @@ byte *update_screen_line(byte *scrp, int coli, int scri, int border, SPNM(imag_mark)[coli] |= mark; SPNM(imag_horiz) |= mark; coli >>= 3; - SPNM(imag_vert) |= (1 << coli); + SPNM(imag_vert) |= BIT_N(coli); spmp = PRNM(proc).mem + (scri << 5); 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, if (depth <= 8) { numcolors = letoh32(bmph.clr_used); if (numcolors == 0) - numcolors = 1 << depth; + numcolors = BIT_N(depth); } else numcolors = (compression == 3) ? 3 : 0; @@ -795,7 +795,7 @@ int read_bmp_fd(int fd, #ifndef PLUGIN { unsigned char *p = bitmap + bm->width * (row >> 3); - unsigned char mask = 1 << (row & 7); + unsigned char mask = BIT_N(row & 7); int col; for (col = 0; col < bm->width; col++, p++) #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) */ INLINE void fix_quant_tables(struct jpeg *p_jpeg) { - int shift, i, x, y, a; + int shift, i, a; + unsigned x, y; for (i = 0; i < 2; i++) { shift = idct_tbl[p_jpeg->v_scale[i]].v_scale + @@ -1514,9 +1515,9 @@ INLINE void fix_quant_tables(struct jpeg *p_jpeg) if (shift) { a = 0; - for (y = 0; y < 1 << p_jpeg->h_scale[i]; y++) + for (y = 0; y < BIT_N(p_jpeg->h_scale[i]); y++) { - for (x = 0; x < 1 << p_jpeg->v_scale[i]; x++) + for (x = 0; x < BIT_N(p_jpeg->v_scale[i]); x++) p_jpeg->quanttable[i][zig[a+x]] <<= shift; a += 8; } @@ -1586,7 +1587,7 @@ INLINE int get_bits(struct jpeg *p_jpeg, int nbits) #ifdef JPEG_BS_DEBUG if (nbits > p_jpeg->bitbuf_bits) DEBUGF("bitbuffer underrun\n"); - int mask = 1 << (p_jpeg->bitbuf_bits - 1); + int mask = BIT_N(p_jpeg->bitbuf_bits - 1); int i; DEBUGF("get %d bits: ", nbits); for (i = 0; i < nbits; i++) @@ -1594,13 +1595,13 @@ INLINE int get_bits(struct jpeg *p_jpeg, int nbits) DEBUGF("\n"); #endif return ((int) (p_jpeg->bitbuf >> (p_jpeg->bitbuf_bits -= nbits))) & - ((1<bitbuf_bits - 1); + int mask = BIT_N(p_jpeg->bitbuf_bits - 1); int i; DEBUGF("peek %d bits: ", nbits); for (i = 0; i < nbits; i++) @@ -1608,13 +1609,13 @@ INLINE int peek_bits(struct jpeg *p_jpeg, int nbits) DEBUGF("\n"); #endif return ((int) (p_jpeg->bitbuf >> (p_jpeg->bitbuf_bits - nbits))) & - ((1<bitbuf_bits - 1); + int mask = BIT_N(p_jpeg->bitbuf_bits - 1); int i; DEBUGF("drop %d bits: ", nbits); for (i = 0; i < nbits; i++) @@ -1675,7 +1676,7 @@ static const int extend_offset[16] = /* entry n is (-1 << n) + 1 */ ({ \ int x__ = x; \ int s__ = s; \ - x__ & (1 << (s__- 1)) ? x__ : x__ + (-1 << s__) + 1; \ + x__ & BIT_N(s__- 1) ? x__ : x__ + (-1 << s__) + 1; \ }) #endif @@ -1764,14 +1765,14 @@ static struct img_part *store_row_jpeg(void *jpeg_args) #endif unsigned int width = p_jpeg->x_mbl << mcu_hscale; unsigned int b_width = width * JPEG_PIX_SZ; - int height = 1U << mcu_vscale; + int height = BIT_N(mcu_vscale); int x; if (!p_jpeg->mcu_row) /* Need to decode a new row of MCUs */ { p_jpeg->out_ptr = (unsigned char *)p_jpeg->img_buf; int store_offs[4]; #ifdef HAVE_LCD_COLOR - unsigned mcu_width = 1U << mcu_hscale; + unsigned mcu_width = BIT_N(mcu_hscale); #endif int mcu_offset = JPEG_PIX_SZ << mcu_hscale; unsigned char *out = p_jpeg->out_ptr; @@ -1868,8 +1869,8 @@ static struct img_part *store_row_jpeg(void *jpeg_args) if (!ci) #endif { - int idct_cols = 1 << MIN(p_jpeg->h_scale[!!ci], 3); - int idct_rows = 1 << p_jpeg->v_scale[!!ci]; + int idct_cols = BIT_N(MIN(p_jpeg->h_scale[!!ci], 3)); + int idct_rows = BIT_N(p_jpeg->v_scale[!!ci]); unsigned char *b_out = out + (ci ? ci : store_offs[blkn]); if (idct_tbl[p_jpeg->v_scale[!!ci]].v_idct) idct_tbl[p_jpeg->v_scale[!!ci]].v_idct(block, @@ -2043,8 +2044,8 @@ int read_jpeg_fd(int fd, } p_jpeg->h_scale[0] = calc_scale(p_jpeg->x_size, bm->width); p_jpeg->v_scale[0] = calc_scale(p_jpeg->y_size, bm->height); - JDEBUGF("luma IDCT size: %dx%d\n", 1 << p_jpeg->h_scale[0], - 1 << p_jpeg->v_scale[0]); + JDEBUGF("luma IDCT size: %dx%d\n", BIT_N(p_jpeg->h_scale[0]), + BIT_N(p_jpeg->v_scale[0])); if ((p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3 == bm->width && (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3 == bm->height) resize = false; @@ -2053,24 +2054,24 @@ int read_jpeg_fd(int fd, p_jpeg->frameheader[0].horizontal_sampling - 1; p_jpeg->v_scale[1] = p_jpeg->v_scale[0] + p_jpeg->frameheader[0].vertical_sampling - 1; - JDEBUGF("chroma IDCT size: %dx%d\n", 1 << p_jpeg->h_scale[1], - 1 << p_jpeg->v_scale[1]); + JDEBUGF("chroma IDCT size: %dx%d\n", BIT_N(p_jpeg->h_scale[1]), + BIT_N(p_jpeg->v_scale[1])); #endif JDEBUGF("scaling from %dx%d -> %dx%d\n", (p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3, (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3, bm->width, bm->height); fix_quant_tables(p_jpeg); - int decode_w = (1 << p_jpeg->h_scale[0]) - 1; - int decode_h = (1 << p_jpeg->v_scale[0]) - 1; + int decode_w = BIT_N(p_jpeg->h_scale[0]) - 1; + int decode_h = BIT_N(p_jpeg->v_scale[0]) - 1; src_dim.width = (p_jpeg->x_size << p_jpeg->h_scale[0]) >> 3; src_dim.height = (p_jpeg->y_size << p_jpeg->v_scale[0]) >> 3; p_jpeg->zero_need[0] = (decode_h << 3) + decode_w; p_jpeg->k_need[0] = zig[p_jpeg->zero_need[0]]; JDEBUGF("need luma components to %d\n", p_jpeg->k_need[0]); #ifdef HAVE_LCD_COLOR - decode_w = (1 << MIN(p_jpeg->h_scale[1],3)) - 1; - decode_h = (1 << MIN(p_jpeg->v_scale[1],3)) - 1; + decode_w = BIT_N(MIN(p_jpeg->h_scale[1],3)) - 1; + decode_h = BIT_N(MIN(p_jpeg->v_scale[1],3)) - 1; p_jpeg->zero_need[1] = (decode_h << 3) + decode_w; p_jpeg->k_need[1] = zig[p_jpeg->zero_need[1]]; 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) y = -y; } - while ((x & (1 << (30 - msb))) == 0) + while ((x & BIT_N(30 - msb)) == 0) { msb++; } - while ((y & (1 << lsb)) == 0) + while ((y & BIT_N(lsb)) == 0) { lsb++; } @@ -216,7 +216,7 @@ static long fp_exp10(long x) static long fp_atof(const char* s, int precision) { long int_part = 0; - long int_one = 1 << precision; + long int_one = BIT_N(precision); long frac_part = 0; long frac_count = 0; 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) bitpos = (phase + i/8) % 15; /* "bounce" effect */ if (bitpos > 7) bitpos = 14 - bitpos; - charging_logo[i] = 0x01 << bitpos; + charging_logo[i] = BIT_N(bitpos); } } lcd_mono_bitmap(charging_logo, pox_x, pox_y + 8, diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 88633f0ec9..adc720eaf8 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -1268,7 +1268,7 @@ static int set_multiple_mode(int sectors) #ifdef HAVE_ATA_DMA static int get_best_mode(unsigned short identword, int max, int modetype) { - unsigned short testbit = 1u << max; + unsigned short testbit = BIT_N(max); while (1) { if (identword & testbit) @@ -1335,7 +1335,7 @@ static int set_features(void) } for (i=0; i < (int)(sizeof(features)/sizeof(features[0])); i++) { - if (identify_info[features[i].id_word] & (1u << features[i].id_bit)) { + if (identify_info[features[i].id_word] & BIT_N(features[i].id_bit)) { SET_REG(ATA_FEATURE, features[i].subcommand); SET_REG(ATA_NSECTOR, features[i].parameter); SET_REG(ATA_COMMAND, CMD_SET_FEATURES); @@ -1461,7 +1461,7 @@ int ata_init(void) #ifdef MAX_PHYS_SECTOR_SIZE /* Find out the physical sector size */ if((identify_info[106] & 0xe000) == 0x6000) - phys_sector_mult = 1 << (identify_info[106] & 0x000f); + phys_sector_mult = BIT_N(identify_info[106] & 0x000f); else phys_sector_mult = 1; diff --git a/firmware/drivers/ata_mmc.c b/firmware/drivers/ata_mmc.c index 5104f8cf97..3396149602 100644 --- a/firmware/drivers/ata_mmc.c +++ b/firmware/drivers/ata_mmc.c @@ -450,7 +450,7 @@ static int initialize_card(int card_no) card->tsac = card->tsac * exponent[taac_exp] / 10; /* r2w_factor, write timeout */ - card->r2w_factor = 1 << card_extract_bits(card->csd, 99, 3); + card->r2w_factor = BIT_N(card_extract_bits(card->csd, 99, 3)); card->write_timeout = card->read_timeout * card->r2w_factor; if (card->r2w_factor > 32) /* Such cards often need extra read delay */ diff --git a/firmware/drivers/lcd-1bit-vert.c b/firmware/drivers/lcd-1bit-vert.c index b09ce0e76d..5fb652431c 100644 --- a/firmware/drivers/lcd-1bit-vert.c +++ b/firmware/drivers/lcd-1bit-vert.c @@ -155,17 +155,17 @@ int LCDFN(getstringsize)(const unsigned char *str, int *w, int *h) static void setpixel(int x, int y) { - LCDFN(framebuffer)[y>>3][x] |= 1 << (y & 7); + LCDFN(framebuffer)[y>>3][x] |= BIT_N(y & 7); } static void clearpixel(int x, int y) { - LCDFN(framebuffer)[y>>3][x] &= ~(1 << (y & 7)); + LCDFN(framebuffer)[y>>3][x] &= ~BIT_N(y & 7); } static void flippixel(int x, int y) { - LCDFN(framebuffer)[y>>3][x] ^= 1 << (y & 7); + LCDFN(framebuffer)[y>>3][x] ^= BIT_N(y & 7); } static void nopixel(int x, int y) @@ -401,7 +401,7 @@ void LCDFN(hline)(int x1, int x2, int y) bfunc = LCDFN(blockfuncs)[current_vp->drawmode]; dst = &LCDFN(framebuffer)[y>>3][x1]; - mask = 1 << (y & 7); + mask = BIT_N(y & 7); dst_end = dst + width; do diff --git a/firmware/screendump.c b/firmware/screendump.c index 3a3985505e..e84afb9511 100644 --- a/firmware/screendump.c +++ b/firmware/screendump.c @@ -169,7 +169,7 @@ void screen_dump(void) #if LCD_DEPTH == 1 dst_end = dst + LCD_WIDTH/2; src = lcd_framebuffer[y >> 3]; - mask = 1 << (y & 7); + mask = BIT_N(y & 7); do { @@ -333,7 +333,7 @@ void remote_screen_dump(void) #if LCD_REMOTE_DEPTH == 1 dst_end = dst + LCD_REMOTE_WIDTH/2; src = lcd_remote_framebuffer[y >> 3]; - mask = 1 << (y & 7); + mask = BIT_N(y & 7); do { -- cgit v1.2.3