From f373c97c90e816404c00ab48b2e36b18fd5e6c49 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 30 Sep 2022 10:25:28 +0100 Subject: Define LCD_STRIDEFORMAT unconditionally Instead of putting "#ifdef LCD_STRIDEFORMAT" at every usage of the macro it's simpler to have config.h define LCD_STRIDEFORMAT to the default of horizontal stride when the target leaves it unspecified. Change-Id: Ib187012aad65ac678dbd837b1464a83bad722411 --- apps/plugins/SOURCES | 3 +-- apps/plugins/SUBDIRS | 3 +-- apps/plugins/bitmaps/native/SOURCES | 3 +-- apps/plugins/imageviewer/jpeg/yuv2rgb.c | 2 +- apps/plugins/imageviewer/ppm/ppm_decoder.c | 2 +- apps/plugins/invadrox.c | 2 +- apps/plugins/lib/bmp_smooth_scale.c | 2 +- apps/plugins/lib/osd.c | 8 ++++---- apps/plugins/lib/pluginlib_bmp.c | 2 +- apps/plugins/lib/xlcd_scroll.c | 4 ++-- apps/plugins/lua/rocklib_img.c | 2 +- apps/plugins/pictureflow/pictureflow.c | 2 +- apps/plugins/puzzles/rockbox.c | 2 +- apps/plugins/test_viewports.c | 2 +- apps/plugins/xworld/sys.c | 12 ++++++------ apps/recorder/resize.c | 2 +- 16 files changed, 25 insertions(+), 28 deletions(-) (limited to 'apps') diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 942f9a5b20..85227d80d7 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES @@ -82,8 +82,7 @@ crypt_firmware.c /* Overlays loaders */ -#if defined(HAVE_LCD_COLOR) && \ - (!defined(LCD_STRIDEFORMAT) || (LCD_STRIDEFORMAT != VERTICAL_STRIDE)) +#if defined(HAVE_LCD_COLOR) && (LCD_STRIDEFORMAT == HORIZONTAL_STRIDE) #if (PLUGIN_BUFFER_SIZE > 0x14000) && (CONFIG_PLATFORM & (PLATFORM_NATIVE |PLATFORM_HOSTED)) && (defined(CPU_ARM) || defined(CPU_MIPS)) duke3d.c quake.c diff --git a/apps/plugins/SUBDIRS b/apps/plugins/SUBDIRS index 8479e4b3dd..4cb57edb1b 100644 --- a/apps/plugins/SUBDIRS +++ b/apps/plugins/SUBDIRS @@ -9,8 +9,7 @@ clock #endif /* color horizontal-stride LCDs */ -#if defined(HAVE_LCD_COLOR) && \ - (!defined(LCD_STRIDEFORMAT) || (LCD_STRIDEFORMAT != VERTICAL_STRIDE)) +#if defined(HAVE_LCD_COLOR) && (LCD_STRIDEFORMAT == HORIZONTAL_STRIDE) xworld /* for duke3d, wolf3d and quake */ diff --git a/apps/plugins/bitmaps/native/SOURCES b/apps/plugins/bitmaps/native/SOURCES index f207f358b2..d0cc853f5b 100644 --- a/apps/plugins/bitmaps/native/SOURCES +++ b/apps/plugins/bitmaps/native/SOURCES @@ -548,8 +548,7 @@ pegbox_pieces.9x7x1.bmp #endif /* Puzzles */ -#if defined(HAVE_LCD_COLOR) && \ - (!defined(LCD_STRIDEFORMAT) || (LCD_STRIDEFORMAT != VERTICAL_STRIDE)) +#if defined(HAVE_LCD_COLOR) && (LCD_STRIDEFORMAT == HORIZONTAL_STRIDE) puzzles_cursor.11x16x24.bmp #endif diff --git a/apps/plugins/imageviewer/jpeg/yuv2rgb.c b/apps/plugins/imageviewer/jpeg/yuv2rgb.c index 61d7fd6487..3e7f08d8bc 100644 --- a/apps/plugins/imageviewer/jpeg/yuv2rgb.c +++ b/apps/plugins/imageviewer/jpeg/yuv2rgb.c @@ -238,7 +238,7 @@ static fb_data (* const pixel_funcs[COLOUR_NUM_MODES][DITHER_NUM_MODES])(void) = }; /* These defines are used fornormal horizontal strides and vertical strides. */ -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #define LCDADDR(x, y) (lcd_fb + LCD_HEIGHT*(x) + (y)) #define ROWENDOFFSET (width*LCD_HEIGHT) #define ROWOFFSET (1) diff --git a/apps/plugins/imageviewer/ppm/ppm_decoder.c b/apps/plugins/imageviewer/ppm/ppm_decoder.c index 4a86be1a3a..ccb208b80b 100644 --- a/apps/plugins/imageviewer/ppm/ppm_decoder.c +++ b/apps/plugins/imageviewer/ppm/ppm_decoder.c @@ -177,7 +177,7 @@ static int read_ppm_row(int fd, struct ppm_info *ppm, int row) int col; int r, g, b; #ifdef HAVE_LCD_COLOR -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE fb_data *dst = (fb_data *) ppm->buf + row; const int stride = ppm->x; #else diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index a164b95cf0..d130ab6108 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c @@ -785,7 +785,7 @@ static fb_data *lcd_fb; /* No standard get_pixel function yet, use this hack instead */ #if (LCD_DEPTH >= 8) -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE static inline fb_data get_pixel(int x, int y) { return lcd_fb[x*LCD_HEIGHT+y]; diff --git a/apps/plugins/lib/bmp_smooth_scale.c b/apps/plugins/lib/bmp_smooth_scale.c index c5f258cdbf..378ff96448 100644 --- a/apps/plugins/lib/bmp_smooth_scale.c +++ b/apps/plugins/lib/bmp_smooth_scale.c @@ -78,7 +78,7 @@ void smooth_resize_bitmap(struct bitmap *src_bmp, struct bitmap *dest_bmp) fb_data *sptr, *dptr; int x, y, end; int val_y = 0, val_x; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE const int sw = src_bmp->height; const int sh = src_bmp->width; const int dw = dest_bmp->height; diff --git a/apps/plugins/lib/osd.c b/apps/plugins/lib/osd.c index 7d6e10a410..99f77da7dc 100644 --- a/apps/plugins/lib/osd.c +++ b/apps/plugins/lib/osd.c @@ -106,10 +106,10 @@ static struct osd grey_osd; # error Unknown 2-bit format; please define macros # endif /* LCD_PIXELFORMAT */ #elif LCD_DEPTH == 16 -# if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +# if LCD_STRIDEFORMAT == VERTICAL_STRIDE # define _OSD_HEIGHT2BYTES(h) ((h)*2) # define _OSD_BYTES2HEIGHT(b) ((b)/2) -# else /* !defined(LCD_STRIDEFORMAT) || LCD_STRIDEFORMAT != VERTICAL_STRIDE */ +# else /* LCD_STRIDEFORMAT != VERTICAL_STRIDE */ # define _OSD_WIDTH2BYTES(w) ((w)*2) # define _OSD_BYTES2WIDTH(b) ((b)/2) # endif /* end stride type selection */ @@ -160,7 +160,7 @@ static void * _osd_lcd_init_buffers(struct osd *osd, unsigned flags, rb->viewport_set_fullscreen(&osd->vp, SCREEN_MAIN); -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE int colbytes = _OSD_HEIGHT2BYTES(LCD_HEIGHT); int bytecols = *bufsize / colbytes; int w = _OSD_BYTES2WIDTH(bytecols); @@ -193,7 +193,7 @@ static void * _osd_lcd_init_buffers(struct osd *osd, unsigned flags, w = _OSD_BYTES2WIDTH(_OSD_WIDTH2BYTES(w)); osd->lcd_bitmap_stride = _OSD_BYTES2HEIGHT(_OSD_HEIGHT2BYTES(LCD_HEIGHT)); osd->back_bitmap_stride = h; -#else /* !defined(LCD_STRIDEFORMAT) || LCD_STRIDEFORMAT != VERTICAL_STRIDE */ +#else /* LCD_STRIDEFORMAT != VERTICAL_STRIDE */ int rowbytes = _OSD_WIDTH2BYTES(LCD_WIDTH); int byterows = *bufsize / rowbytes; int w = _OSD_BYTES2WIDTH(rowbytes); diff --git a/apps/plugins/lib/pluginlib_bmp.c b/apps/plugins/lib/pluginlib_bmp.c index f3edfbf425..82f84b05af 100644 --- a/apps/plugins/lib/pluginlib_bmp.c +++ b/apps/plugins/lib/pluginlib_bmp.c @@ -94,7 +94,7 @@ int save_bmp_file( char* filename, struct bitmap *bm ) */ void simple_resize_bitmap(struct bitmap *src, struct bitmap *dst) { -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE const int srcw = src->height; const int srch = src->width; const int dstw = dst->height; diff --git a/apps/plugins/lib/xlcd_scroll.c b/apps/plugins/lib/xlcd_scroll.c index 5ac4a366e8..906f4eaae1 100644 --- a/apps/plugins/lib/xlcd_scroll.c +++ b/apps/plugins/lib/xlcd_scroll.c @@ -30,7 +30,7 @@ static const unsigned short patterns[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000}; #endif -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE void xlcd_scroll_left(int count) { /*size_t dst_stride;*/ @@ -668,4 +668,4 @@ void xlcd_scroll_down(int count) } #endif /* LCD_PIXELFORMAT, LCD_DEPTH */ -#endif /* defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE */ +#endif /* LCD_STRIDEFORMAT == VERTICAL_STRIDE */ diff --git a/apps/plugins/lua/rocklib_img.c b/apps/plugins/lua/rocklib_img.c index b0ca769ca4..68e5325ce0 100644 --- a/apps/plugins/lua/rocklib_img.c +++ b/apps/plugins/lua/rocklib_img.c @@ -380,7 +380,7 @@ static inline fb_data* rli_get_element(struct rocklua_image* img, int x, int y) pixel_to_native(x, y, &x, &y); -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE /* column major address */ size_t data_address = (stride * (x - 1)) + (y - 1); diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 0e5585681d..eec8313485 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -3101,7 +3101,7 @@ static void render_slide(struct slide_data *slide, const int alpha) const pix_t *ptr = &src[column * bmp->height]; -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #define PIXELSTEP_Y 1 #define LCDADDR(x, y) (&buffer[BUFFER_HEIGHT*(x) + (y)]) #else diff --git a/apps/plugins/puzzles/rockbox.c b/apps/plugins/puzzles/rockbox.c index 6e34adb1db..9a82cdde10 100644 --- a/apps/plugins/puzzles/rockbox.c +++ b/apps/plugins/puzzles/rockbox.c @@ -1465,7 +1465,7 @@ static void rb_blitter_free(void *handle, blitter *bl) static void rb_blitter_save(void *handle, blitter *bl, int x, int y) { /* no viewport offset */ -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #error no vertical stride #else if(bl && bl->bmp.data) diff --git a/apps/plugins/test_viewports.c b/apps/plugins/test_viewports.c index 2bada01f79..76f1a9da9b 100644 --- a/apps/plugins/test_viewports.c +++ b/apps/plugins/test_viewports.c @@ -130,7 +130,7 @@ static void *test_address_fn(int x, int y) struct frame_buffer_t *fb = vp0.buffer; /* LCD_STRIDEFORMAT & LCD_NATIVE_STRIDE macros allow Horiz screens to work with RB */ -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE size_t element = (x * LCD_NATIVE_STRIDE(fb->stride)) + y; #else size_t element = (y * LCD_NATIVE_STRIDE(fb->stride)) + x; diff --git a/apps/plugins/xworld/sys.c b/apps/plugins/xworld/sys.c index c57da9456b..a806de5297 100644 --- a/apps/plugins/xworld/sys.c +++ b/apps/plugins/xworld/sys.c @@ -496,7 +496,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 for (int i = 0; i < w / 2; ++i) { uint8_t pix1 = *(buf + i) >> 4; uint8_t pix2 = *(buf + i) & 0xF; -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE framebuffer[( (h * 2) ) * 320 + i] = sys->palette[pix1]; framebuffer[( (h * 2) + 1) * 320 + i] = sys->palette[pix2]; #else @@ -515,7 +515,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 for (int i = 0; i < w / 2; ++i) { uint8_t pix1 = *(buf + i) >> 4; uint8_t pix2 = *(buf + i) & 0xF; -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE framebuffer[(200 - h * 2 ) * 320 + ( 320 - i )] = sys->palette[pix1]; framebuffer[(200 - h * 2 - 1) * 320 + ( 320 - i )] = sys->palette[pix2]; #else @@ -531,7 +531,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 else { int next = 0; -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE for(int x = 0; x < w / 2; ++x) { for(int y = 0; y < h; ++y) @@ -565,7 +565,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 struct bitmap in_bmp; if(sys->settings.rotation_option) { -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE in_bmp.width = 320; in_bmp.height = 200; #else @@ -575,7 +575,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 } else { -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE in_bmp.width = 200; in_bmp.height = 320; #else @@ -600,7 +600,7 @@ void sys_copyRect(struct System* sys, uint16_t x, uint16_t y, uint16_t w, uint16 } else { -#if defined(LCD_STRIDEFORMAT) && (LCD_STRIDEFORMAT == VERTICAL_STRIDE) +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE for(int x = 0; x < 320; ++x) { for(int y = 0; y < 200; ++y) diff --git a/apps/recorder/resize.c b/apps/recorder/resize.c index 6f561039c3..c16cec9dc9 100644 --- a/apps/recorder/resize.c +++ b/apps/recorder/resize.c @@ -593,7 +593,7 @@ static inline bool scale_v_linear(struct rowset *rset, static void output_row_32_native_fromyuv(uint32_t row, void * row_in, struct scaler_context *ctx) { -#if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE +#if LCD_STRIDEFORMAT == VERTICAL_STRIDE #define DEST_STEP (ctx->bm->height) #define Y_STEP (1) #else -- cgit v1.2.3