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
This commit is contained in:
James Buren 2020-10-30 06:40:46 +00:00
parent fa3184f951
commit 2d85c72151

View file

@ -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)
{
/* check whether we're running from ROM */
uint16_t* RB = (uint16_t*) rb;
if (RB >= FB && RB < FB + (FLASH_SIZE / sizeof(*FB)))
{
/* 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 */
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;