@@ -491,12 +491,6 @@ rg_app_t *rg_system_init(const rg_config_t *config)
491491 app .sampleRate = config -> sampleRate ;
492492 app .tickRate = config -> frameRate ;
493493 // app.frameskip = config->frameSkip;
494- if (config -> mallocAlwaysInternal > 0 )
495- {
496- #ifdef ESP_PLATFORM
497- heap_caps_malloc_extmem_enable (config -> mallocAlwaysInternal );
498- #endif
499- }
500494 if (config -> storageRequired && !rg_storage_ready ())
501495 {
502496 rg_display_clear (C_SKY_BLUE );
@@ -506,6 +500,13 @@ rg_app_t *rg_system_init(const rg_config_t *config)
506500 if (config -> romRequired && !app .romPath && !* app .romPath )
507501 {
508502 // show rom picking dialog
503+ // app.romPath = rg_gui_file_picker(_("Choose ROM"), RG_BASE_PATH_ROMS, NULL, true, false);
504+ }
505+ if (config -> mallocAlwaysInternal > 0 )
506+ {
507+ #ifdef ESP_PLATFORM
508+ heap_caps_malloc_extmem_enable (config -> mallocAlwaysInternal );
509+ #endif
509510 }
510511 app .isLauncher = config -> isLauncher ;
511512 app .handlers = config -> handlers ;
@@ -641,11 +642,12 @@ rg_task_t *rg_task_current(void)
641642 return NULL ;
642643}
643644
644- bool rg_task_send (rg_task_t * task , const rg_task_msg_t * msg )
645+ bool rg_task_send (rg_task_t * task , const rg_task_msg_t * msg , int timeoutMS )
645646{
646647 RG_ASSERT_ARG (task && msg );
647648#if defined(ESP_PLATFORM )
648- return xQueueSend (task -> queue , msg , portMAX_DELAY ) == pdTRUE ;
649+ TickType_t timeout = timeoutMS < 0 ? portMAX_DELAY : pdMS_TO_TICKS (timeoutMS );
650+ return xQueueSend (task -> queue , msg , timeout ) == pdTRUE ;
649651#elif defined(RG_TARGET_SDL2 )
650652 while (task -> msgWaiting > 0 )
651653 continue ;
@@ -655,15 +657,16 @@ bool rg_task_send(rg_task_t *task, const rg_task_msg_t *msg)
655657#endif
656658}
657659
658- bool rg_task_peek (rg_task_msg_t * out )
660+ bool rg_task_peek (rg_task_msg_t * out , int timeoutMS )
659661{
660662 rg_task_t * task = rg_task_current ();
661663 bool success = false;
662664 if (!task || !out )
663665 return false;
664666 // task->blocked = true;
665667#if defined(ESP_PLATFORM )
666- success = xQueuePeek (task -> queue , out , portMAX_DELAY ) == pdTRUE ;
668+ TickType_t timeout = timeoutMS < 0 ? portMAX_DELAY : pdMS_TO_TICKS (timeoutMS );
669+ success = xQueuePeek (task -> queue , out , timeout ) == pdTRUE ;
667670#elif defined(RG_TARGET_SDL2 )
668671 while (task -> msgWaiting < 1 )
669672 continue ;
@@ -673,15 +676,16 @@ bool rg_task_peek(rg_task_msg_t *out)
673676 return success ;
674677}
675678
676- bool rg_task_receive (rg_task_msg_t * out )
679+ bool rg_task_receive (rg_task_msg_t * out , int timeoutMS )
677680{
678681 rg_task_t * task = rg_task_current ();
679682 bool success = false;
680683 if (!task || !out )
681684 return false;
682685 // task->blocked = true;
683686#if defined(ESP_PLATFORM )
684- success = xQueueReceive (task -> queue , out , portMAX_DELAY ) == pdTRUE ;
687+ TickType_t timeout = timeoutMS < 0 ? portMAX_DELAY : pdMS_TO_TICKS (timeoutMS );
688+ success = xQueueReceive (task -> queue , out , timeout ) == pdTRUE ;
685689#elif defined(RG_TARGET_SDL2 )
686690 while (task -> msgWaiting < 1 )
687691 continue ;
@@ -759,7 +763,7 @@ bool rg_mutex_take(rg_mutex_t *mutex, int timeoutMS)
759763{
760764 RG_ASSERT_ARG (mutex );
761765#if defined(ESP_PLATFORM )
762- int timeout = timeoutMS >= 0 ? pdMS_TO_TICKS (timeoutMS ) : portMAX_DELAY ;
766+ int timeout = timeoutMS < 0 ? portMAX_DELAY : pdMS_TO_TICKS (timeoutMS );
763767 return xSemaphoreTake ((QueueHandle_t )mutex , timeout ) == pdPASS ;
764768#elif defined(RG_TARGET_SDL2 )
765769 return SDL_LockMutex ((SDL_mutex * )mutex ) == 0 ;
0 commit comments