--- a/SLEngine/battle.h +++ b/SLEngine/battle.h @@ -760,7 +760,7 @@ drawMessageCompressed(messageGameOver); arduboy.display(); waitButtons(A_BUTTON | B_BUTTON); - arduboy.exitToBootloader(); + softReset(); } else if (flags & FLAG_BATTLE_ESCAPE) { --- a/SLEngine/game.h +++ b/SLEngine/game.h @@ -435,7 +435,7 @@ gameState = STATE_PLAYING; } else if (selection == 3) //QUIT GAME - arduboy.exitToBootloader(); + softReset(); selection = 0; globalCounter = 0; } @@ -572,9 +572,8 @@ cursorY = 0; lineStartX = 0; drawMessageCompressed(messageUpload); - if (justPressed & DOWN_BUTTON) - arduboy.exitToBootloader(); - else if (justPressed & A_BUTTON) + // FredyGames: nothing to upload to in the browser, so Down also goes back to the title screen + if ((justPressed & DOWN_BUTTON) || (justPressed & A_BUTTON)) gameState = STATE_TITLE; } @@ -604,7 +603,7 @@ player.seal = 0; player.equipment = 0; saveGame(); - arduboy.exitToBootloader(); + softReset(); } } --- a/SLEngine/globals.h +++ b/SLEngine/globals.h @@ -22,6 +22,14 @@ #include #include "Arduboy2Ext.h" +// FredyGames: the original jumps to the Arduboy bootloader here (to pick the next game of the series). +// There is no bootloader in the browser, so restart the game instead. +static inline void softReset() +{ + cli(); + asm volatile("jmp 0"); +} + #define READ_WORD(x) __builtin_bswap16(pgm_read_word(x)) #define READ_DWORD(x) __builtin_bswap32(pgm_read_dword(x))