There are many different IDEs you can use to make games. My preference for Game Boy games is VS Code. One of the best features in IDEs are Intellisense, Syntax Highlighting, and Code Navigation. By default, VS code might not properly be able to implement these features for GBDK related functions. For this, we’ll need free extension from microsoft: Microsoft C/C++ extension.
With the plugin installed, and properly setup, the editor will help you find pre-defined GBDK functions.
For example, if you wanted to set background tile data, as you start typing out “set_bkg_data”, VS Code will give you suggestions. This is great if you commonly forget the names of functions, and/or which parameters they take.
The extension can also search for your own functions, once you’ve properly declared them via extern or header file:
Additionally, If you mouse over a function (that’s been properly commented), the extension will tell you what it does.
Getting the C/C++ Extension
The first step, is getting Microsoft’s c/c++ extension on the VS Code marketplace. This extension will give us intellisense and syntax highlighting for our .c files.
Install this, as you would any VS Code extension. If you are not familiar, you can learn more about that here: Extension Marketplace – Install a extension.
Editing your configuration
With the C/C++ extension installed, you now need to setup your project’s properties file. The extension looks for .vscode/c_cpp_properties.json file. You can edit this file directly, or you can use the VS Code preferences UI:
Setting up your GBDK and project includes
You need to add some items to your include path. VS code will scan these locations when searching for types.
- The absolute path to GBDK’s ‘include’ folder.
- Any folder that has “.h” files in it.
- Any folder that has “.lib” (library) files you are using. (if any)
When adding project folders containing .h files, You can use the “${workspaceFolder}” to reference the root of your project.
When you edit these preferences, a file will be created locally saving them. This file, located in a .vscode folder, is called c_cpp_properties.json. Alternatively, you can directly create and edit a .vscode/c_cpp_properties.json:
Adding preprocessor definitions
To be safe, you can add the “__PORT_sm83” and “__TARGET_gb” preprocessor definitions. GBDK supports multiple platforms, this will ensure VS Code is looking at the Game Boy version of the code.
Learn more about GBDK-2020’s cross platform support here: Cross Compiling for Different Consoles.
Conclusion
That’s everything you need to know. You’ll need to setup the configuration for each GBDK project. You can simply copy and paste the ‘.vscode/c_cpp_properties.json‘ file once you’ve installed the extension.