Index: android/src/org/rockbox/RockboxService.java =================================================================== --- android/src/org/rockbox/RockboxService.java (revision 30759) +++ android/src/org/rockbox/RockboxService.java (working copy) @@ -38,6 +38,7 @@ import android.os.Environment; import android.os.IBinder; import android.os.ResultReceiver; +import android.util.DisplayMetrics; import android.util.Log; import android.view.KeyEvent; @@ -82,6 +83,12 @@ return instance; } + public int[] getResolution() + { + DisplayMetrics metrics = getResources().getDisplayMetrics(); + return new int[] {metrics.widthPixels, metrics.heightPixels}; + } + public boolean isRockboxRunning() { return rockbox_running; Index: tools/configure =================================================================== --- tools/configure (revision 30759) +++ tools/configure (working copy) @@ -111,8 +111,8 @@ ARG_LCDWIDTH=$app_lcd_width ARG_LCDHEIGHT=$app_lcd_height - app_lcd_width="#define LCD_WIDTH $app_lcd_width" - app_lcd_height="#define LCD_HEIGHT $app_lcd_height" + app_lcd_width="#define DEFAULT_LCD_WIDTH $app_lcd_width" + app_lcd_height="#define DEFAULT_LCD_HEIGHT $app_lcd_height" } findarmgcc() { Index: apps/screen_access.c =================================================================== --- apps/screen_access.c (revision 30759) +++ apps/screen_access.c (working copy) @@ -122,8 +122,10 @@ { { .screen_type=SCREEN_MAIN, +#ifndef HAVE_DYNAMIC_LCD_SIZE .lcdwidth=LCD_WIDTH, .lcdheight=LCD_HEIGHT, +#endif .depth=LCD_DEPTH, .getnblines=&screen_helper_getnblines, #if defined(HAVE_LCD_COLOR) @@ -333,3 +335,11 @@ display->set_drawmode(DRMODE_SOLID); } #endif + +#ifdef HAVE_DYNAMIC_LCD_SIZE +void screen_init(void) +{ + screens[SCREEN_MAIN].lcdwidth = LCD_WIDTH; + screens[SCREEN_MAIN].lcdheight = LCD_HEIGHT; +} +#endif Index: apps/screen_access.h =================================================================== --- apps/screen_access.h (revision 30759) +++ apps/screen_access.h (working copy) @@ -175,4 +175,6 @@ */ extern struct screen screens[NB_SCREENS]; +void screen_init(void) INIT_ATTR; + #endif /*_SCREEN_ACCESS_H_*/ Index: apps/recorder/keyboard.c =================================================================== --- apps/recorder/keyboard.c (revision 30759) +++ apps/recorder/keyboard.c (working copy) @@ -370,10 +370,8 @@ const unsigned char *p; int len = 0; -#if LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 - struct screen *sc = &screens[l]; - - if (sc->getwidth() >= 160 && sc->getheight() >= 96) + if (LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 && + screens[l].getwidth() >= 160 && screens[l].getheight() >= 96) { p = "ABCDEFG abcdefg !?\" @#$%+'\n" "HIJKLMN hijklmn 789 &_()-`\n" @@ -388,7 +386,6 @@ pm->max_line_len = 26; } else -#endif /* LCD_WIDTH >= 160 && LCD_HEIGHT >= 96 */ { p = "ABCDEFG !?\" @#$%+'\n" "HIJKLMN 789 &_()-`\n" Index: apps/recorder/bmp.h =================================================================== --- apps/recorder/bmp.h (revision 30759) +++ apps/recorder/bmp.h (working copy) @@ -33,7 +33,7 @@ #define IMG_NORESIZE 0 #define IMG_RESIZE 1 -#define BM_MAX_WIDTH (((LCD_WIDTH) + 7) & ~7) +#define BM_MAX_WIDTH (((MAX_LCD_WIDTH) + 7) & ~7) struct uint8_rgb { uint8_t blue; Index: apps/plugins/SOURCES.app_build =================================================================== --- apps/plugins/SOURCES.app_build (revision 30759) +++ apps/plugins/SOURCES.app_build (working copy) @@ -1,5 +1,7 @@ /* plugins common to all models */ +#ifndef HAVE_DYNAMIC_LCD_SIZE credits.c +#endif properties.c random_folder_advance_config.c search.c Index: apps/plugins/SUBDIRS.app_build =================================================================== --- apps/plugins/SUBDIRS.app_build (revision 30759) +++ apps/plugins/SUBDIRS.app_build (working copy) @@ -1,7 +1,7 @@ /* For all targets with a bitmap display */ #ifdef HAVE_LCD_BITMAP -#ifdef HAVE_TAGCACHE +#if defined(HAVE_TAGCACHE) && !defined(HAVE_DYNAMIC_LCD_SIZE) pictureflow #endif @@ -11,7 +11,9 @@ #if CONFIG_CODEC == SWCODEC #if MEMORYSIZE > 2 /* we need a lot of RAM for instruments */ +#ifndef HAVE_DYNAMIC_LCD_SIZE mikmod #endif +#endif #endif /* CONFIG_CODEC == SWCODEC */ Index: apps/plugins/bitmaps/native/SOURCES =================================================================== --- apps/plugins/bitmaps/native/SOURCES (revision 30759) +++ apps/plugins/bitmaps/native/SOURCES (working copy) @@ -1,5 +1,13 @@ #ifdef HAVE_LCD_BITMAP +#ifdef HAVE_DYNAMIC_LCD_SIZE +/* This is a hack to prevent buildtime errors popping up */ +#undef LCD_WIDTH +#undef LCD_HEIGHT +#define LCD_WIDTH 0 +#define LCD_HEIGHT 0 +#endif + /* Brickmania */ #ifdef HAVE_LCD_COLOR brickmania_gameover.112x54x16.bmp Index: apps/plugins/bitmaps/mono/SOURCES =================================================================== --- apps/plugins/bitmaps/mono/SOURCES (revision 30759) +++ apps/plugins/bitmaps/mono/SOURCES (working copy) @@ -1,5 +1,13 @@ #ifdef HAVE_LCD_BITMAP +#ifdef HAVE_DYNAMIC_LCD_SIZE +/* This is a hack to prevent buildtime errors popping up */ +#undef LCD_WIDTH +#undef LCD_HEIGHT +#define LCD_WIDTH 0 +#define LCD_HEIGHT 0 +#endif + /* Bubbles */ #if (LCD_WIDTH == 112) && (LCD_HEIGHT == 64) bubbles_bubble.112x64x1.bmp Index: apps/plugins/lib/simple_viewer.c =================================================================== --- apps/plugins/lib/simple_viewer.c (revision 30759) +++ apps/plugins/lib/simple_viewer.c (working copy) @@ -182,7 +182,11 @@ static void draw_text(struct view_info *info) { #ifdef HAVE_LCD_BITMAP +#ifdef HAVE_DYNAMIC_LCD_SIZE +#define OUTPUT_SIZE MAX_LCD_WIDTH+1 +#else #define OUTPUT_SIZE LCD_WIDTH+1 +#endif #else #define OUTPUT_SIZE LCD_WIDTH*3+1 #endif Index: apps/gui/skin_engine/skin_parser.c =================================================================== --- apps/gui/skin_engine/skin_parser.c (revision 30759) +++ apps/gui/skin_engine/skin_parser.c (working copy) @@ -76,11 +76,15 @@ #define WPS_ERROR_INVALID_PARAM -1 +#ifdef HAVE_DYNAMIC_LCD_SIZE +#define SKIN_FONT_SIZE (LCD_HEIGHT > 160 ? 1024*10 : 1024*3) +#else #if LCD_HEIGHT > 160 #define SKIN_FONT_SIZE (1024*10) #else #define SKIN_FONT_SIZE (1024*3) #endif +#endif #define GLYPHS_TO_CACHE 256 static bool isdefault(struct skin_tag_parameter *param) @@ -2140,7 +2144,8 @@ if (isfile) { /* get the bitmap dir */ - char *dot = strrchr(buf, '.'); + char *slash = strrchr(buf, '/'); + char *dot = strchr(slash, '.'); strlcpy(bmpdir, buf, dot - buf + 1); } else Index: apps/gui/skin_engine/skin_engine.c =================================================================== --- apps/gui/skin_engine/skin_engine.c (revision 30759) +++ apps/gui/skin_engine/skin_engine.c (working copy) @@ -30,6 +30,7 @@ #include "settings.h" #include "wps.h" #include "file.h" +#include "filefuncs.h" #include "buffer.h" #if CONFIG_TUNER #include "radio.h" @@ -239,6 +240,14 @@ if (strcmp(setting, "rockbox_failsafe")) { snprintf(buf, sizeof buf, WPS_DIR "/%s.%s", setting, ext); +#ifdef HAVE_DYNAMIC_LCD_SIZE + if (!file_exists(buf)) + { + snprintf(buf, sizeof buf, WPS_DIR "/%s.%dx%dx%d.%s", + setting, screens[screen].lcdwidth, + screens[screen].lcdheight, screens[screen].depth, ext); + } +#endif } cpu_boost(true); skin_load(skin, screen, buf, true); Index: apps/gui/skin_engine/skin_backdrops.c =================================================================== --- apps/gui/skin_engine/skin_backdrops.c (revision 30759) +++ apps/gui/skin_engine/skin_backdrops.c (working copy) @@ -27,6 +27,7 @@ #include "settings.h" #include "wps_internals.h" #include "skin_engine.h" +#include "filefuncs.h" #if !defined(__PCTOOL__) && \ ((LCD_DEPTH > 1) || (defined(HAVE_REMOTE_LCD) && (LCD_REMOTE_DEPTH > 1))) @@ -144,6 +145,21 @@ global_settings.backdrop_file[0] != '-' && filename[0] == '-') { filename = global_settings.backdrop_file; +#ifdef HAVE_DYNAMIC_LCD_SIZE + if (!file_exists(filename)) + { + char copy[MAX_PATH]; + char* temp = backdrops[i].name+2; /* slightly hacky to get a buffer */ + char *ext = strrchr(copy, '.'); + size_t size = sizeof(backdrops[i].name) -2; + *ext = '\0'; ext++; + snprintf(temp, size, "%s.%dx%dx%d.%s", copy, + screens[screen].lcdwidth, + screens[screen].lcdheight, + screens[screen].depth, ext); + filename = temp; + } +#endif } if (*filename && *filename != '-') { Index: apps/bitmaps/native/SOURCES =================================================================== --- apps/bitmaps/native/SOURCES (revision 30759) +++ apps/bitmaps/native/SOURCES (working copy) @@ -1,5 +1,13 @@ #ifdef HAVE_LCD_BITMAP +#ifdef HAVE_DYNAMIC_LCD_SIZE +/* This is a hack to prevent buildtime errors popping up */ +#undef LCD_WIDTH +#undef LCD_HEIGHT +#define LCD_WIDTH 0 +#define LCD_HEIGHT 0 +#endif + /* Rockbox logo */ #if (LCD_DEPTH == 1) #if (LCD_WIDTH == 160) @@ -9,6 +17,12 @@ #else rockboxlogo.112x30x1.bmp #endif +#elif defined(HAVE_DYNAMIC_LCD_SIZE) +/* Currently only one screen size is supported. + * Ideally, we should compile in multiple logos and choose the correct one + * at runtime (and optionally discard the others using INIT_ATTR). + */ +rockboxlogo.320x98x16.bmp #elif (LCD_WIDTH == 96) && (LCD_DEPTH == 16) rockboxlogo.96x30x16.bmp #elif (LCD_WIDTH == 128) && (LCD_DEPTH == 2) @@ -43,8 +57,10 @@ /* USB logo */ #ifdef HAVE_LCD_COLOR -#if LCD_WIDTH > 176 +#if defined(HAVE_DYNAMIC_LCD_SIZE) usblogo.176x48x16.bmp +#elif LCD_WIDTH > 176 +usblogo.176x48x16.bmp #elif LCD_WIDTH >= 128 usblogo.128x37x16.bmp #elif LCD_WIDTH >= 88 Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 30759) +++ apps/settings_list.c (working copy) @@ -205,7 +205,7 @@ #define DEFAULT_SBSNAME "-" #define DEFAULT_FMS_NAME DEFAULT_WPSNAME -#ifdef HAVE_LCD_BITMAP +#if defined(HAVE_LCD_BITMAP) && !defined(HAVE_DYNAMIC_LCD_SIZE) #if LCD_HEIGHT <= 64 #define DEFAULT_FONTNAME "08-Rockfont" @@ -224,7 +224,7 @@ #endif #else - #define DEFAULT_FONTNAME "" + #define DEFAULT_FONTNAME "27-Adobe-Helvetica" #endif #ifdef HAVE_REMOTE_LCD @@ -738,7 +738,7 @@ LANG_SCROLL_BAR, SCROLLBAR_LEFT, "scrollbar","off,left,right", NULL, 3, ID2P(LANG_OFF), ID2P(LANG_LEFT), ID2P(LANG_RIGHT)), INT_SETTING(F_THEMESETTING, scrollbar_width, LANG_SCROLLBAR_WIDTH, 6, - "scrollbar width",UNIT_INT, 3, MAX(LCD_WIDTH/10,25), 1, + "scrollbar width",UNIT_INT, 3, 25, 1, NULL, NULL, NULL), #if CONFIG_KEYPAD == RECORDER_PAD OFFON_SETTING(F_THEMESETTING,buttonbar, LANG_BUTTON_BAR ,true,"buttonbar", NULL), @@ -935,9 +935,9 @@ false, "Screen Scrolls Out Of View", gui_list_screen_scroll_out_of_view), INT_SETTING(F_PADTITLE, scroll_step, LANG_SCROLL_STEP, 6, "scroll step", - UNIT_PIXEL, 1, LCD_WIDTH, 1, NULL, NULL, lcd_scroll_step), + UNIT_PIXEL, 1, 400/*LCD_WIDTH*/, 1, NULL, NULL, lcd_scroll_step), INT_SETTING(F_PADTITLE, screen_scroll_step, LANG_SCREEN_SCROLL_STEP, 16, - "screen scroll step", UNIT_PIXEL, 1, LCD_WIDTH, 1, NULL, NULL, + "screen scroll step", UNIT_PIXEL, 1, 400/*LCD_WIDTH*/, 1, NULL, NULL, gui_list_screen_scroll_step), #endif /* HAVE_LCD_BITMAP */ OFFON_SETTING(0,scroll_paginated,LANG_SCROLL_PAGINATED, Index: apps/plugin.c =================================================================== --- apps/plugin.c (revision 30759) +++ apps/plugin.c (working copy) @@ -145,7 +145,7 @@ static int creat_wrapper(const char *pathname, mode_t mode); #endif -static const struct plugin_api rockbox_api = { +static struct plugin_api rockbox_api = { /* lcd */ #ifdef HAVE_LCD_CONTRAST @@ -170,7 +170,11 @@ lcd_icon, lcd_double_height, #else +#ifdef HAVE_DYNAMIC_LCD_SIZE + NULL, /* will get filled in later */ +#else &lcd_framebuffer[0][0], +#endif lcd_update_rect, lcd_set_drawmode, lcd_get_drawmode, @@ -862,6 +866,9 @@ #else plugin_size = 0; #endif +#ifdef HAVE_DYNAMIC_LCD_SIZE + rockbox_api.lcd_framebuffer = lcd_framebuffer; +#endif *(p_hdr->api) = &rockbox_api; Index: apps/debug_menu.c =================================================================== --- apps/debug_menu.c (revision 30759) +++ apps/debug_menu.c (working copy) @@ -346,8 +346,13 @@ screens[i].putsf(0, line++, "alloc: %6ld/%ld", audio_filebufused(), (long) filebuflen); -#if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80) - if (screens[i].lcdheight > 80) + if ((LCD_HEIGHT > 80 || +#ifdef HAVE_REMOTE_LCD + LCD_REMOTE_HEIGHT > 80 +#else + 0 +#endif + ) && screens[i].lcdheight > 80) { gui_scrollbar_draw(&screens[i],0, line*8, screens[i].lcdwidth, 6, filebuflen, 0, audio_filebufused(), HORIZONTAL); @@ -360,19 +365,22 @@ filebuflen, 0, (long)d.buffered_data, HORIZONTAL); line++; } -#endif screens[i].putsf(0, line++, "usefl: %6ld/%ld", (long)(d.useful_data), (long)filebuflen); -#if LCD_HEIGHT > 80 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_HEIGHT > 80) - if (screens[i].lcdheight > 80) + if ((LCD_HEIGHT > 80 || +#ifdef HAVE_REMOTE_LCD + LCD_REMOTE_HEIGHT > 80 +#else + 0 +#endif + ) && screens[i].lcdheight > 80) { gui_scrollbar_draw(&screens[i],0, line*8, screens[i].lcdwidth, 6, filebuflen, 0, d.useful_data, HORIZONTAL); line++; } -#endif screens[i].putsf(0, line++, "data_rem: %ld", (long)d.data_rem); Index: apps/main.c =================================================================== --- apps/main.c (revision 30759) +++ apps/main.c (working copy) @@ -158,19 +158,24 @@ FOR_NB_SCREENS(i) { screens[i].clear_display(); + screens[i].puts(0,0,"Hello"); screens[i].update(); } + screens[0].puts(0,1,"list_init"); screens[0].update(); #ifdef HAVE_LCD_BITMAP list_init(); #endif + screens[0].puts(0,2,"tree");screens[0].update(); tree_gui_init(); /* Keep the order of this 3 * Must be done before any code uses the multi-screen API */ + screens[0].puts(0,3,"usb");screens[0].update(); #ifdef HAVE_USBSTACK /* All threads should be created and public queues registered by now */ usb_start_monitoring(); #endif + screens[0].puts(0,4,"rock");screens[0].update(); #ifdef AUTOROCK { char filename[MAX_PATH]; @@ -192,6 +197,7 @@ /* no calls INIT_ATTR functions after this point anymore! * see definition of INIT_ATTR in config.h */ CHART(">root_menu"); + screens[0].puts(0,5,"menu");screens[0].update(); root_menu(); } @@ -351,6 +357,9 @@ global_status.font_id[i] = FONT_SYSFIXED; font_init(); #endif +#ifdef HAVE_DYNAMIC_LCD_SIZE + screen_init(); +#endif show_logo(); button_init(); powermgmt_init(); Index: firmware/export/scroll_engine.h =================================================================== --- firmware/export/scroll_engine.h (revision 30759) +++ firmware/export/scroll_engine.h (working copy) @@ -49,7 +49,11 @@ struct scrollinfo { struct viewport* vp; +#ifdef HAVE_DYNAMIC_LCD_SIZE + char *line; +#else char line[SCROLL_LINE_SIZE]; +#endif #ifdef HAVE_LCD_CHARCELLS int len; /* length of line in chars */ #endif @@ -68,9 +72,12 @@ struct scroll_screen_info { - struct scrollinfo * const scroll; + struct scrollinfo * scroll; const int num_scroll; /* number of scrollable lines (also number of scroll structs) */ int lines; /* Number of currently scrolling lines */ +#ifdef HAVE_DYNAMIC_LCD_SIZE + int line_size; /* max chars storable on each scroll line */ +#endif long ticks; /* # of ticks between updates*/ long delay; /* ticks delay before start */ int bidir_limit; /* percent */ Index: firmware/export/config.h =================================================================== --- firmware/export/config.h (revision 30759) +++ firmware/export/config.h (working copy) @@ -611,6 +611,24 @@ #define LCD_SPLIT_LINES 0 #endif +#ifdef HAVE_DYNAMIC_LCD_SIZE +#define LCD_WIDTH lcd_width +#define LCD_HEIGHT lcd_height +#ifdef HAVE_REMOTE_LCD +#error unsupported config (HAVE_REMOTE_LCD && HAVE_DYNAMIC_LCD_SIZE) +#endif +#else /* HAVE_DYNAMIC_LCD_SIZE */ +#ifdef DEFAULT_LCD_HEIGHT +#define LCD_HEIGHT DEFAULT_LCD_HEIGHT +#endif +#ifdef DEFAULT_LCD_WIDTH +#define LCD_WIDTH DEFAULT_LCD_WIDTH +#endif +#ifndef MAX_LCD_WIDTH +#define MAX_LCD_WIDTH LCD_WIDTH +#endif +#endif /* HAVE_DYNAMIC_LCD_SIZE */ + /* Simulator LCD dimensions. Set to standard dimensions if undefined */ #ifndef SIM_LCD_WIDTH #define SIM_LCD_WIDTH LCD_WIDTH Index: firmware/export/lcd.h =================================================================== --- firmware/export/lcd.h (revision 30759) +++ firmware/export/lcd.h (working copy) @@ -407,7 +407,13 @@ #define LCD_FBHEIGHT LCD_HEIGHT #endif /* The actual framebuffer */ +#ifdef HAVE_DYNAMIC_LCD_SIZE +extern fb_data *lcd_framebuffer; +extern int lcd_width; +extern int lcd_height; +#else extern fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH]; +#endif /** Port-specific functions. Enable in port config file. **/ #ifdef HAVE_REMOTE_LCD_AS_MAIN Index: firmware/export/config/android.h =================================================================== --- firmware/export/config/android.h (revision 30759) +++ firmware/export/config/android.h (working copy) @@ -36,22 +36,14 @@ /* define this if you would like tagcache to build on this target */ #define HAVE_TAGCACHE -/* LCD dimensions - * - * overriden by configure for application builds */ -#ifndef LCD_WIDTH -#define LCD_WIDTH 320 -#endif - -#ifndef LCD_HEIGHT -#define LCD_HEIGHT 480 -#endif - #define LCD_DEPTH 16 #define LCD_PIXELFORMAT 565 #define HAVE_LCD_ENABLE +//#define HAVE_DYNAMIC_LCD_SIZE +#define MAX_LCD_WIDTH 1024 + /* define this to indicate your device's keypad */ #define HAVE_TOUCHSCREEN #define HAVE_BUTTON_DATA Index: firmware/export/config/sdlapp.h =================================================================== --- firmware/export/config/sdlapp.h (revision 30759) +++ firmware/export/config/sdlapp.h (working copy) @@ -39,13 +39,9 @@ /* LCD dimensions * * overriden by configure for application builds */ -#ifndef LCD_WIDTH -#define LCD_WIDTH 320 -#endif -#ifndef LCD_HEIGHT -#define LCD_HEIGHT 480 -#endif +#define HAVE_DYNAMIC_LCD_SIZE +#define MAX_LCD_WIDTH 1024 #define LCD_DEPTH 16 #define LCD_PIXELFORMAT 565 Index: firmware/font.c =================================================================== --- firmware/font.c (revision 30759) +++ firmware/font.c (working copy) @@ -45,16 +45,22 @@ /* max static loadable font buffer size */ #ifndef MAX_FONT_SIZE + +#ifdef HAVE_DYNAMIC_LCD_SIZE +#define MAX_FONT_SIZE (LCD_HEIGHT > 64 ? (MEMORYSIZE > 2 ? 60000 : 10000) : 4000) +#else /* HAVE_DYNAMIC_LCD_SIZE */ #if LCD_HEIGHT > 64 #if MEMORYSIZE > 2 #define MAX_FONT_SIZE 60000 -#else +#else /* MEMORYSIZE */ #define MAX_FONT_SIZE 10000 -#endif -#else +#define MAX_FONT_SIZE (LCD_HEIGHT > 64 ? (MEMORYSIZE > 2 ? 60000 : 10000) : 4000) +#endif /* MEMORYSIZE */ +#else /* LCD_HEIGHT */ #define MAX_FONT_SIZE 4000 -#endif -#endif +#endif /* LCD_HEIGHT */ +#endif /* HAVE_DYNAMIC_LCD_SIZE */ +#endif /* MAX_FONT_SIZE */ #ifndef FONT_HEADER_SIZE #define FONT_HEADER_SIZE 36 Index: firmware/target/hosted/android/lcd-android.c =================================================================== --- firmware/target/hosted/android/lcd-android.c (revision 30759) +++ firmware/target/hosted/android/lcd-android.c (working copy) @@ -30,6 +30,7 @@ extern JNIEnv *env_ptr; extern jobject RockboxService_instance; +extern jclass RockboxService_class; static jobject RockboxFramebuffer_instance; static jmethodID java_lcd_update; @@ -75,11 +76,10 @@ /* Create native_buffer */ jobject buffer = (*env)->NewDirectByteBuffer(env, lcd_framebuffer, - (jlong) sizeof(lcd_framebuffer)); - + (jlong) (lcd_width * lcd_height * sizeof(fb_data))); /* we need to setup parts for the java object every time */ - (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, - (jint)LCD_WIDTH, (jint)LCD_HEIGHT, buffer); + (*env)->CallVoidMethod(env, fb_instance, java_lcd_init, lcd_width, + lcd_height, buffer); } /* @@ -87,6 +87,19 @@ */ void lcd_init_device(void) { +#ifdef HAVE_DYNAMIC_LCD_SIZE + jmethodID getResolution = (*env_ptr)->GetMethodID(env_ptr, RockboxService_class, "getResolution", "()[I"); + jintArray resolution = (jintArray) (*env_ptr)->CallObjectMethod(env_ptr, RockboxService_instance, getResolution); + jint *resolutionElements = (*env_ptr)->GetIntArrayElements(env_ptr, resolution, NULL); + + lcd_width = resolutionElements[0]; + lcd_height = resolutionElements[1]; + (*env_ptr)->ReleaseIntArrayElements(env_ptr, resolution, resolutionElements, 0); +#else + lcd_height = LCD_HEIGHT; + lcd_width = LCD_WIDTH; +#endif + lcd_framebuffer = malloc(sizeof(fb_data) * lcd_width * lcd_height); } void lcd_update(void) @@ -190,6 +203,8 @@ (void)options; } +#define LCDADDR(x, y) (lcd_framebuffer + y * LCD_WIDTH + x) + /* Draw a partial YUV colour bitmap - similiar behavior to lcd_blit_yuv in the core */ void lcd_blit_yuv(unsigned char * const src[3], @@ -205,13 +220,13 @@ width &= ~1; linecounter = height >> 1; -#if LCD_WIDTH >= LCD_HEIGHT - dst = &lcd_framebuffer[y][x]; - row_end = dst + width; -#else - dst = &lcd_framebuffer[x][LCD_WIDTH - y - 1]; + if (LCD_WIDTH >= LCD_HEIGHT) { + dst = LCDADDR(y, x); + row_end = dst + width; + } else { + dst = LCDADDR(x, LCD_WIDTH - y - 1); row_end = dst + LCD_WIDTH * width; -#endif + } z = stride * src_y; ysrc = src[0] + z + src_x; @@ -250,11 +265,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; y = YFAC*(*ysrc++ - 16); r = y + rv; @@ -270,11 +284,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; } while (dst < row_end); @@ -282,13 +295,13 @@ usrc -= width >> 1; vsrc -= width >> 1; -#if LCD_WIDTH >= LCD_HEIGHT - row_end += LCD_WIDTH; - dst += LCD_WIDTH - width; -#else - row_end -= 1; - dst -= LCD_WIDTH*width + 1; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) { + row_end += LCD_WIDTH; + dst += LCD_WIDTH - width; + } else { + row_end -= 1; + dst -= LCD_WIDTH*width + 1; + } do { @@ -315,11 +328,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; y = YFAC*(*ysrc++ - 16); r = y + rv; @@ -335,11 +347,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; } while (dst < row_end); @@ -347,19 +358,18 @@ usrc += stride >> 1; vsrc += stride >> 1; -#if LCD_WIDTH >= LCD_HEIGHT - row_end += LCD_WIDTH; - dst += LCD_WIDTH - width; -#else - row_end -= 1; - dst -= LCD_WIDTH*width + 1; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) { + row_end += LCD_WIDTH; + dst += LCD_WIDTH - width; + } else { + row_end -= 1; + dst -= LCD_WIDTH*width + 1; + } } while (--linecounter > 0); -#if LCD_WIDTH >= LCD_HEIGHT - lcd_update_rect(x, y, width, height); -#else - lcd_update_rect(LCD_WIDTH - y - height, x, height, width); -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + lcd_update_rect(x, y, width, height); + else + lcd_update_rect(LCD_WIDTH - y - height, x, height, width); } Index: firmware/target/hosted/sdl/system-sdl.c =================================================================== --- firmware/target/hosted/sdl/system-sdl.c (revision 30759) +++ firmware/target/hosted/sdl/system-sdl.c (working copy) @@ -61,6 +61,10 @@ bool sim_alarm_wakeup = false; const char *sim_root_dir = NULL; extern int display_zoom; +#ifdef HAVE_DYNAMIC_LCD_SIZE +int lcd_width = DEFAULT_LCD_WIDTH; +int lcd_height = DEFAULT_LCD_HEIGHT; +#endif static SDL_Thread *evt_thread = NULL; @@ -298,6 +302,19 @@ background = false; printf("Disabling background image.\n"); } +#ifdef HAVE_DYNAMIC_LCD_SIZE + else if (!strcmp("--display", argv[x])) + { + x++; + if(x < argc) + { + /* x */ + char *xchar = strchr(argv[x], 'x'); + lcd_width = atoi(argv[x]); + lcd_height = atoi(xchar+1); + } + } +#endif #ifdef HAVE_REMOTE_LCD else if (!strcmp("--noremote", argv[x])) { @@ -353,6 +370,9 @@ #endif printf(" --debugwps \t Print advanced WPS debug info\n"); printf(" --nobackground \t Disable the background image\n"); +#ifdef HAVE_DYNAMIC_LCD_SIZE + printf(" --display WIDTHxHEIGHT\t Set the window size\n"); +#endif #ifdef HAVE_REMOTE_LCD printf(" --noremote \t Disable the remote image (will disable backgrounds)\n"); #endif Index: firmware/target/hosted/sdl/lcd-bitmap.c =================================================================== --- firmware/target/hosted/sdl/lcd-bitmap.c (revision 30759) +++ firmware/target/hosted/sdl/lcd-bitmap.c (working copy) @@ -88,6 +88,12 @@ static const unsigned char colorindex[4] = {128, 85, 43, 0}; #endif +#ifdef HAVE_DYNAMIC_LCD_SIZE +#define LCD_PIXEL(x, y) (lcd_framebuffer + y * LCD_WIDTH + x) +#else +#define LCD_PIXEL(x, y) &(lcd_framebuffer[y][x]) +#endif + static unsigned long get_lcd_pixel(int x, int y) { #if LCD_DEPTH == 1 @@ -113,7 +119,7 @@ #if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE return *(&lcd_framebuffer[0][0]+LCD_HEIGHT*x+y); #else - return lcd_framebuffer[y][x]; + return *LCD_PIXEL(x, y); #endif #endif #endif @@ -140,7 +146,7 @@ sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, LCD_HEIGHT, get_lcd_pixel); sdl_gui_update(lcd_surface, x_start, y_start, width, - height + LCD_SPLIT_LINES, SIM_LCD_WIDTH, SIM_LCD_HEIGHT, + height + LCD_SPLIT_LINES, LCD_WIDTH, LCD_HEIGHT, background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); } @@ -168,7 +174,7 @@ #endif /* LCD_DEPTH */ sdl_gui_update(lcd_surface, 0, 0, SIM_LCD_WIDTH, SIM_LCD_HEIGHT, - SIM_LCD_WIDTH, SIM_LCD_HEIGHT, + LCD_WIDTH, LCD_HEIGHT, background ? UI_LCD_POSX : 0, background? UI_LCD_POSY : 0); } #endif /* HAVE_BACKLIGHT */ @@ -176,10 +182,14 @@ /* initialise simulator lcd driver */ void lcd_init_device(void) { +#ifdef HAVE_DYNAMIC_LCD_SIZE + lcd_framebuffer = malloc(lcd_width * lcd_height * sizeof(fb_data)); +#endif + #if LCD_DEPTH == 16 lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, - SIM_LCD_WIDTH * display_zoom, - SIM_LCD_HEIGHT * display_zoom, + LCD_WIDTH * display_zoom, + LCD_HEIGHT * display_zoom, LCD_DEPTH, 0, 0, 0, 0); #elif LCD_DEPTH <= 8 lcd_surface = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -217,7 +227,7 @@ sdl_update_rect(lcd_surface, x_start, y_start, width, height, LCD_WIDTH, LCD_HEIGHT, lcd_ex_getpixel); sdl_gui_update(lcd_surface, x_start, y_start, width, - height + LCD_SPLIT_LINES, SIM_LCD_WIDTH, SIM_LCD_HEIGHT, + height + LCD_SPLIT_LINES, LCD_WIDTH, LCD_HEIGHT, background ? UI_LCD_POSX : 0, background ? UI_LCD_POSY : 0); } @@ -269,13 +279,16 @@ width &= ~1; linecounter = height >> 1; -#if LCD_WIDTH >= LCD_HEIGHT - dst = &lcd_framebuffer[y][x]; - row_end = dst + width; -#else - dst = &lcd_framebuffer[x][LCD_WIDTH - y - 1]; - row_end = dst + LCD_WIDTH * width; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + { + dst = LCD_PIXEL(x, y); + row_end = dst + width; + } + else + { + dst = LCD_PIXEL(x, LCD_WIDTH - y - 1); + row_end = dst + LCD_WIDTH * width; + } z = stride * src_y; ysrc = src[0] + z + src_x; @@ -314,11 +327,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; y = YFAC*(*ysrc++ - 16); r = y + rv; @@ -334,11 +346,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; } while (dst < row_end); @@ -346,13 +357,16 @@ usrc -= width >> 1; vsrc -= width >> 1; -#if LCD_WIDTH >= LCD_HEIGHT - row_end += LCD_WIDTH; - dst += LCD_WIDTH - width; -#else - row_end -= 1; - dst -= LCD_WIDTH*width + 1; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + { + row_end += LCD_WIDTH; + dst += LCD_WIDTH - width; + } + else + { + row_end -= 1; + dst -= LCD_WIDTH*width + 1; + } do { @@ -379,11 +393,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; y = YFAC*(*ysrc++ - 16); r = y + rv; @@ -399,11 +412,10 @@ *dst = LCD_RGBPACK_LCD(r >> 9, g >> 8, b >> 9); -#if LCD_WIDTH >= LCD_HEIGHT - dst++; -#else - dst += LCD_WIDTH; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + dst++; + else + dst += LCD_WIDTH; } while (dst < row_end); @@ -411,20 +423,22 @@ usrc += stride >> 1; vsrc += stride >> 1; -#if LCD_WIDTH >= LCD_HEIGHT - row_end += LCD_WIDTH; - dst += LCD_WIDTH - width; -#else - row_end -= 1; - dst -= LCD_WIDTH*width + 1; -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + { + row_end += LCD_WIDTH; + dst += LCD_WIDTH - width; + } + else + { + row_end -= 1; + dst -= LCD_WIDTH*width + 1; + } } while (--linecounter > 0); -#if LCD_WIDTH >= LCD_HEIGHT - lcd_update_rect(x, y, width, height); -#else - lcd_update_rect(LCD_WIDTH - y - height, x, height, width); -#endif + if (LCD_WIDTH >= LCD_HEIGHT) + lcd_update_rect(x, y, width, height); + else + lcd_update_rect(LCD_WIDTH - y - height, x, height, width); } #endif /* HAVE_LCD_COLOR */ Index: firmware/target/hosted/sdl/key_to_touch-sdl.c =================================================================== --- firmware/target/hosted/sdl/key_to_touch-sdl.c (revision 30759) +++ firmware/target/hosted/sdl/key_to_touch-sdl.c (working copy) @@ -25,6 +25,7 @@ #include "button.h" #include "buttonmap.h" #include "touchscreen.h" +#include "lcd.h" int key_to_touch(int keyboard_button, unsigned int mouse_coords) { Index: firmware/screendump.c =================================================================== --- firmware/screendump.c (revision 30759) +++ firmware/screendump.c (working copy) @@ -53,25 +53,44 @@ #define BMP_DATASIZE (DUMP_BMP_LINESIZE * (LCD_HEIGHT+LCD_SPLIT_LINES)) #define BMP_TOTALSIZE (BMP_HEADERSIZE + BMP_DATASIZE) -static const unsigned char bmpheader[] = -{ - 0x42, 0x4d, /* 'BM' */ - LE32_CONST(BMP_TOTALSIZE), /* Total file size */ - 0x00, 0x00, 0x00, 0x00, /* Reserved */ - LE32_CONST(BMP_HEADERSIZE), /* Offset to start of pixel data */ +#define ASSIGN_LE32(dst, x) memcpy((dst), (unsigned char[4]){LE32_CONST(x)}, 4); - 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */ - LE32_CONST(LCD_WIDTH), /* Width in pixels */ - LE32_CONST(LCD_HEIGHT+LCD_SPLIT_LINES), /* Height in pixels */ - 0x01, 0x00, /* Number of planes (always 1) */ - LE16_CONST(DUMP_BMP_BPP), /* Bits per pixel 1/4/8/16/24 */ - LE32_CONST(BMP_COMPRESSION),/* Compression mode */ - LE32_CONST(BMP_DATASIZE), /* Size of bitmap data */ - 0xc4, 0x0e, 0x00, 0x00, /* Horizontal resolution (pixels/meter) */ - 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */ - LE32_CONST(BMP_NUMCOLORS), /* Number of used colours */ - LE32_CONST(BMP_NUMCOLORS), /* Number of important colours */ +static struct { + const unsigned char header[2]; + unsigned char file_size[4]; + const unsigned char reserved[4]; + unsigned char header_size[4]; + const unsigned char second_header_size[4]; + unsigned char lcd_width[4]; + unsigned char lcd_height[4]; + const unsigned char nr_planes[2]; + const unsigned char bpp[2]; + const unsigned char compression[4]; + unsigned char data_size[4]; + const unsigned char horizontal_resolution[4]; + const unsigned char vertical_resolution[4]; + const unsigned char nr_used_colors[4]; + const unsigned char nr_important_colors[4]; + const unsigned char colors[BMP_NUMCOLORS*4]; +} __attribute__((__packed__)) bmpheader = { + {0x42, 0x4d}, /* 'BM' */ + {}, /* Total file size */ + {0x00, 0x00, 0x00, 0x00}, /* Reserved */ + {}, /* Offset to start of pixel data */ + {0x28, 0x00, 0x00, 0x00}, /* Size of (2nd) header */ + {}, /* Width in pixels */ + {}, /* Height in pixels */ + {0x01, 0x00}, /* Number of planes (always 1) */ + {LE16_CONST(DUMP_BMP_BPP)}, /* Bits per pixel 1/4/8/16/24 */ + {LE32_CONST(BMP_COMPRESSION)},/* Compression mode */ + {}, /* Size of bitmap data */ + {0xc4, 0x0e, 0x00, 0x00}, /* Horizontal resolution (pixels/meter) */ + {0xc4, 0x0e, 0x00, 0x00}, /* Vertical resolution (pixels/meter) */ + {LE32_CONST(BMP_NUMCOLORS)}, /* Number of used colours */ + {LE32_CONST(BMP_NUMCOLORS)}, /* Number of important colours */ + + { #if LCD_DEPTH == 1 #ifdef HAVE_NEGATIVE_LCD BMP_COLOR(LCD_BL_DARKCOLOR), @@ -94,6 +113,7 @@ 0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */ 0x1f, 0x00, 0x00, 0x00, /* blue bitfield mask */ #endif + } }; static void (*screen_dump_hook)(int fh) = NULL; @@ -136,7 +156,12 @@ } else { - write(fd, bmpheader, sizeof(bmpheader)); + ASSIGN_LE32(bmpheader.file_size, BMP_TOTALSIZE); + ASSIGN_LE32(bmpheader.header_size, BMP_HEADERSIZE); + ASSIGN_LE32(bmpheader.lcd_width, LCD_WIDTH); + ASSIGN_LE32(bmpheader.lcd_height, LCD_HEIGHT+LCD_SPLIT_LINES); + ASSIGN_LE32(bmpheader.data_size, BMP_DATASIZE); + write(fd, &bmpheader, sizeof(bmpheader)); /* BMP image goes bottom up */ for (y = LCD_HEIGHT - 1; y >= 0; y--) @@ -214,8 +239,11 @@ #endif #elif LCD_DEPTH == 16 dst_end = dst + LCD_WIDTH; +#ifdef HAVE_DYNAMIC_LCD_SIZE + src = &lcd_framebuffer[y]; +#else src = lcd_framebuffer[y]; - +#endif do { #if (LCD_PIXELFORMAT == RGB565SWAPPED) Index: firmware/bidi.c =================================================================== --- firmware/bidi.c (revision 30759) +++ firmware/bidi.c (working copy) @@ -137,14 +137,32 @@ unsigned short *bidi_l2v(const unsigned char *str, int orientation) { +#ifdef HAVE_DYNAMIC_LCD_SIZE + static unsigned short *utf16_buf = NULL; +#else static unsigned short utf16_buf[SCROLL_LINE_SIZE]; +#endif unsigned short *target, *tmp; #ifndef BOOTLOADER +#ifdef HAVE_DYNAMIC_LCD_SIZE + static unsigned short *bidi_buf = NULL; +#else static unsigned short bidi_buf[SCROLL_LINE_SIZE]; +#endif unsigned short *heb_str; /* *broken_str */ int block_start, block_end, block_type, block_length, i; int length = utf8length(str); #endif + + +#ifdef HAVE_DYNAMIC_LCD_SIZE + /* FIXME: find somewhere better for this. */ + if (utf16_buf == NULL) + utf16_buf = malloc(SCROLL_LINE_SIZE); + if (bidi_buf == NULL) + bidi_buf = malloc(SCROLL_LINE_SIZE); +#endif + /* long max_chars=0; int begin, end, char_count, orig_begin; Index: firmware/scroll_engine.c =================================================================== --- firmware/scroll_engine.c (revision 30759) +++ firmware/scroll_engine.c (working copy) @@ -45,16 +45,23 @@ static char scroll_stack[DEFAULT_STACK_SIZE*3]; static const char scroll_name[] = "scroll"; +#ifdef HAVE_DYNAMIC_LCD_SIZE +static struct scrollinfo* lcd_scroll; +#else static struct scrollinfo lcd_scroll[LCD_SCROLLABLE_LINES]; +#endif #ifdef HAVE_REMOTE_LCD +#ifdef HAVE_DYNAMIC_LCD_SIZE +static struct scrollinfo* lcd_remote_scroll; +#else static struct scrollinfo lcd_remote_scroll[LCD_REMOTE_SCROLLABLE_LINES]; +#endif static struct event_queue scroll_queue SHAREDBSS_ATTR; #endif struct scroll_screen_info lcd_scroll_info = { - .scroll = lcd_scroll, .lines = 0, .ticks = 12, .delay = HZ/2, @@ -71,7 +78,6 @@ #ifdef HAVE_REMOTE_LCD struct scroll_screen_info lcd_remote_scroll_info = { - .scroll = lcd_remote_scroll, .lines = 0, .ticks = 12, .delay = HZ/2, @@ -348,5 +354,30 @@ sizeof(scroll_stack), 0, scroll_name IF_PRIO(, PRIORITY_USER_INTERFACE) IF_COP(, CPU)); + +#ifdef HAVE_DYNAMIC_LCD_SIZE + int line_size = SCROLL_LINE_SIZE; + + lcd_scroll = + malloc(sizeof(struct scrollinfo) * LCD_SCROLLABLE_LINES); + lcd_scroll_info.line_size = line_size; + + for (int i = 0; i < LCD_SCROLLABLE_LINES; i++) + lcd_scroll[i].line = malloc(line_size); + +#ifdef HAVE_REMOTE_LCD + lcd_remote_scroll = + malloc(sizeof(struct scrollinfo) * LCD_REMOTE_SCROLLABLE_LINES); + lcd_remote_scroll_info.line_size = line_size; + + for (int i = 0; i < LCD_REMOTE_SCROLLABLE_LINES; i++) + lcd_remote_scroll[i].line = malloc(line_size); +#endif /* HAVE_REMOTE_LCD */ +#endif /* HAVE_DYNAMIC_LCD_SIZE */ + + lcd_scroll_info.scroll = lcd_scroll; +#ifdef HAVE_REMOTE_LCD + lcd_remote_scroll_info.scroll = lcd_remote_scroll; +#endif } Index: firmware/drivers/lcd-bitmap-common.c =================================================================== --- firmware/drivers/lcd-bitmap-common.c (revision 30759) +++ firmware/drivers/lcd-bitmap-common.c (working copy) @@ -40,6 +40,11 @@ #define MAIN_LCD #endif +#ifdef HAVE_DYNAMIC_LCD_SIZE +int lcd_width; +int lcd_height; +#endif + #if defined(MAIN_LCD) && defined(HAVE_LCD_COLOR) /* Fill a rectangle with a gradient */ static void lcd_gradient_rect(int x1, int x2, int y, unsigned h, @@ -383,7 +388,11 @@ s->start_tick = current_tick + LCDFN(scroll_info).delay; s->style = style; +#ifdef HAVE_DYNAMIC_LCD_SIZE + strlcpy(s->line, string, LCDFN(scroll_info).line_size); +#else strlcpy(s->line, string, sizeof s->line); +#endif /* get width */ s->width = LCDFN(getstringsize)(s->line, &w, &h); Index: firmware/drivers/lcd-16bit.c =================================================================== --- firmware/drivers/lcd-16bit.c (revision 30759) +++ firmware/drivers/lcd-16bit.c (working copy) @@ -46,10 +46,13 @@ }; /*** globals ***/ +#ifdef HAVE_DYNAMIC_LCD_SIZE +fb_data *lcd_framebuffer; +#else fb_data lcd_framebuffer[LCD_FBHEIGHT][LCD_FBWIDTH] IRAM_LCDFRAMEBUFFER CACHEALIGN_AT_LEAST_ATTR(16); +#endif - static fb_data* lcd_backdrop = NULL; static long lcd_backdrop_offset IDATA_ATTR = 0; @@ -57,8 +60,6 @@ { .x = 0, .y = 0, - .width = LCD_WIDTH, - .height = LCD_HEIGHT, .font = FONT_SYSFIXED, .drawmode = DRMODE_SOLID, .fg_pattern = LCD_DEFAULT_FG, @@ -73,11 +74,13 @@ /* LCD init */ void lcd_init(void) { - lcd_clear_display(); - /* Call device specific init */ lcd_init_device(); + lcd_clear_display(); scroll_init(); + + default_vp.width = LCD_WIDTH; + default_vp.height = LCD_HEIGHT; } /*** Viewports ***/ @@ -203,7 +206,11 @@ /*** low-level drawing functions ***/ +#ifdef HAVE_DYNAMIC_LCD_SIZE +#define LCDADDR(x, y) (lcd_framebuffer + y * LCD_WIDTH + x) +#else #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) +#endif static void ICODE_ATTR setpixel(fb_data *address) { @@ -247,7 +254,7 @@ lcd_backdrop = backdrop; if (backdrop) { - lcd_backdrop_offset = (long)backdrop - (long)&lcd_framebuffer[0][0]; + lcd_backdrop_offset = (long)backdrop - (long)lcd_framebuffer; lcd_fastpixelfuncs = lcd_fastpixelfuncs_backdrop; } else