Larold’s Jubilant Junkyard” has become “Larold’s Retro Gameyard“. I’ve been working on this re-branding and migration for a while. All old tutorials should redirect you to this new site. If you see any errors, please let me know! See here for more information: What happened to Larold’s Jubilant Junkyard?

using vs code with gbdk-2020

Setting up Visual Studio Code for making Game Boy Games

Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. There is some slight configuration needed to get it working with GBDK-2020.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

THANKS FOR READING!

If you have any suggestions, and/or are confused about anything: feel free to leave a comment, send me a email, or a message on social media. Constructive criticism will help the gameyard, and others like yourself. If you learned something from this tutorial, and are looking for more content, check other these other tutorials. 

Setting up Visual Studio Code for making Game Boy Games

Thanks for reading my tutorial, here are the files for that tutorial. 

Download Instructions

Sign-Up for the "Gameyard Newsletter" for MOre Game Development News

If you like Retro Game Development, subscribe to the Gameyard Newsletter. Stay up-to-date with all the latest Game Boy news. It’s free, and you can unsubscribe any time!

Be sure to check your email inbox for a confirmation email.