Proof of concept for calling APIs from GB Studio.

It's pretty messy but works well enough for simple use cases.

Note: Use this concept sparingly, if you're not careful your game may include functionality that is visibly broken when played on real hardware or other emulators.


1. Download the latest dev build from GitHub links at (is currently required as this version makes sure the first 100 variables are always in a deterministic memory location).

2. When you want to call some Javascript in your game add an event "Variable: Set to 'True'" and choose one of the first 100 variables (important!) that you haven't used anywhere previously.

2. Using the dev version GB Studio, open and export your project as a ROM file.

3. Open the file `` in a text editor and look for the line containing "_script_variables"

_script_variables C545

Where C545 is the location in memory (as a hexadecimal value) of your game's variables. The exact value in your game will probably be different, and if you modify your game by adding/removing content it is likely to change, just make a note of the value for now.

4. Without changing any content rebuild your game but this time for web

5. Edit the generated index.html to add something like the following to the bottom of the page just before "</body>"

          var variablesPtr = 0xC545; // Make sure to change this to your _script_variables location (note the 0x at the front too)
          var variableIndex = 21; // The variable that is set to true when you want to call the API (using $21$ here)
          if(gameboy && gameboy.memory[variablesPtr + variableIndex]) {
            // API call goes here
            alert("Do something...");
            // Reset the variable back to zero once done to stop repeated calls
            gameboy.memory[variablesPtr + variableIndex] = 0;
      }, 10);

6. Run your web build in a browser, when you set the variable you're looking at to true your API should be called.

Rated 5.0 out of 5 stars
(3 total ratings)
AuthorChris Maltby


Log in with to leave a comment.

This is honestly amazing work. Do you know if this will be supported in version 3.0?


This has tremendous potential!!! ... I imagine continuing the game 'outside' the game.

Thanks for sharing! 


Great feature ! I will probably use it for the game that I develop for a birth announcement (coming soon) =D!