From 2d85c7215169780168032617603e9e7b06d7ba25 Mon Sep 17 00:00:00 2001 From: James Buren Date: Fri, 30 Oct 2020 06:40:46 +0000 Subject: [PATCH] iriver_flash: fix issues with DoUserDialog First the argument should be const since the original parameter is. Second the pointer arithmetic for detecting whether rockbox is running from ROM or not is incorrect. It ends up being at a location twice as far as intended since the arithmetic does not account for the pointer type's underlying size. It should also be dependent on the target's FLASH_SIZE. Third the LCD setup is moved to the entry point since it is the best place to setup and restore the LCD changes. Change-Id: If9ddaf2cd937f1edf61c82a8a27f48d01807068a --- apps/plugins/iriver_flash.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/plugins/iriver_flash.c b/apps/plugins/iriver_flash.c index aa1bdb62b8..9d1c3456a6 100644 --- a/apps/plugins/iriver_flash.c +++ b/apps/plugins/iriver_flash.c @@ -701,11 +701,12 @@ int load_romdump(const char *filename) } /* Kind of our main function, defines the application flow. */ -void DoUserDialog(char* filename) +static void DoUserDialog(const char* filename) { - /* this can only work if Rockbox runs in DRAM, not flash ROM */ - if ((uint16_t*)rb >= FB && (uint16_t*)rb < FB + 4096*1024) /* 4 MB max */ - { /* we're running from flash */ + /* check whether we're running from ROM */ + uint16_t* RB = (uint16_t*) rb; + if (RB >= FB && RB < FB + (FLASH_SIZE / sizeof(*FB))) + { rb->splash(HZ*3, "Not from ROM"); return; /* exit */ } @@ -717,14 +718,13 @@ void DoUserDialog(char* filename) return; /* exit */ } - rb->lcd_setfont(FONT_SYSFIXED); if (!show_info()) - return ; + return; /* exit */ if (filename == NULL) { rb->splash(HZ*3, "Please use this plugin with \"Open with...\""); - return ; + return; /* exit */ } audiobuf = rb->plugin_get_audio_buffer((size_t *)&audiobuf_size); @@ -752,7 +752,9 @@ enum plugin_status plugin_start(const void* parameter) /* now go ahead and have fun! */ oldmode = rb->system_memory_guard(MEMGUARD_NONE); /*disable memory guard */ - DoUserDialog((char*) parameter); + rb->lcd_setfont(FONT_SYSFIXED); + DoUserDialog(parameter); + rb->lcd_setfont(FONT_UI); rb->system_memory_guard(oldmode); /* re-enable memory guard */ return PLUGIN_OK;