Remember address of last used game
diff --git a/32blit-stm32/Inc/persistence.h b/32blit-stm32/Inc/persistence.h
index e2dc288..bf0c3f8 100644
--- a/32blit-stm32/Inc/persistence.h
+++ b/32blit-stm32/Inc/persistence.h
@@ -19,6 +19,7 @@
 

   PersistResetTarget reset_target;

   bool reset_error; // last reset was caused by an error

+  uint32_t last_game_offset;

 };

 

 extern Persist persist;

diff --git a/32blit-stm32/Src/32blit.cpp b/32blit-stm32/Src/32blit.cpp
index e5bed21..1e08c57 100644
--- a/32blit-stm32/Src/32blit.cpp
+++ b/32blit-stm32/Src/32blit.cpp
@@ -330,6 +330,7 @@
       persist.selected_menu_item = 0;

       persist.reset_target = prtFirmware;

       persist.reset_error = false;

+      persist.last_game_offset = 0;

     }

 

     init_api_shared();

@@ -497,7 +498,7 @@
         break;

       case SWITCH_EXE:

         if(button_a){

-          blit_switch_execution(0); // TODO: store offset for last used game

+          blit_switch_execution(persist.last_game_offset);

         }

         break;

       case LAST_COUNT:

@@ -901,6 +902,8 @@
     uint32_t magic = app_ptr[0];

 

     if(magic == 0x54494C42 /*BLIT*/) {

+      persist.last_game_offset = address;

+

       pFunction init = (pFunction) app_ptr[3];

       init();

 

diff --git a/32blit-stm32/Src/main.c b/32blit-stm32/Src/main.c
index 96bfad7..98b02f6 100644
--- a/32blit-stm32/Src/main.c
+++ b/32blit-stm32/Src/main.c
@@ -150,7 +150,7 @@
 #if (INITIALISE_QSPI==1)

   qspi_init();

   if((persist.reset_target == prtGame) && HAL_GPIO_ReadPin(BUTTON_MENU_GPIO_Port,  BUTTON_MENU_Pin) && !persist.reset_error)

-    blit_switch_execution(0); // TODO: store offset for last used game

+    blit_switch_execution(persist.last_game_offset);

 #endif