From 9f84fbf1bb0db0c121d576643f078ace27ce4f65 Mon Sep 17 00:00:00 2001 From: Jademalo <386846+Jademalo@users.noreply.github.com> Date: Tue, 10 Mar 2026 21:23:05 +0000 Subject: [PATCH 1/4] Add Dev Container configuration --- .devcontainer/Dockerfile | 18 +++++++++++++++ .devcontainer/devcontainer.json | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000000..3523d22019f --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,18 @@ +# See here for image contents: https://github.com/devcontainers/images/blob/main/src/base-ubuntu/.devcontainer/Dockerfile + +# [Choice] Ubuntu version: jammy, noble. Noble is set as the default, with the argument editable in devcontainer.json. +ARG VARIANT="noble" +FROM mcr.microsoft.com/devcontainers/base:2-${VARIANT} + +# Install necessary packages for building pokefirered +RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends \ + binutils-arm-none-eabi \ + build-essential \ + git \ + libpng-dev \ + gcc-arm-none-eabi \ + libnewlib-arm-none-eabi + +# Download and compile agbcc +WORKDIR /tmp/tools/agbcc +RUN git clone https://github.com/pret/agbcc . && ./build.sh \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000000..ba106f7b12c --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,40 @@ +{ + "name": "pokefirered", + "build": { + "dockerfile": "Dockerfile", + // Update 'VARIANT' to pick an Ubuntu version: jammy, noble + "args": { "VARIANT": "noble" } + }, + + "customizations": { + "vscode": { + + "settings": { + + "files.associations": { + "*.inc": "arm", + "*.h": "c" + }, + + "files.exclude": { + "**/build": true // This is to exclude the build folder from IntelliSense, though also removes it from the Explorer + }, + "search.exclude": { + "**/tools": true + } + + }, + + "extensions": [ + "ms-vscode.cpptools", + "dan-c-underwood.arm", + "ms-vscode-remote.remote-containers" + ] + } + }, + + // Install agbcc + "postCreateCommand": "workspaceFolder=$(pwd) && (cd /tmp/tools/agbcc && ./install.sh $workspaceFolder)", + + "remoteUser": "vscode" +} From d07efb2a24fabed53536794731033e8457ac6b4e Mon Sep 17 00:00:00 2001 From: Jademalo <386846+Jademalo@users.noreply.github.com> Date: Tue, 10 Mar 2026 21:24:05 +0000 Subject: [PATCH 2/4] Add VSCode build tasks and intellisense configurations --- .gitignore | 2 + .vscode/c_cpp_properties.json | 189 ++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 55 ++++++++++ 3 files changed, 246 insertions(+) create mode 100644 .vscode/c_cpp_properties.json create mode 100644 .vscode/tasks.json diff --git a/.gitignore b/.gitignore index 05c7c0314fd..961e2e0f9bf 100644 --- a/.gitignore +++ b/.gitignore @@ -60,6 +60,8 @@ _Deparsed_XSubs.pm porymap.*.cfg prefabs.json .vscode/*.* +!.vscode/c_cpp_properties.json +!.vscode/tasks.json *.js *.sym build-cmake-*/ diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000000..0014eeee6b5 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,189 @@ +{ + "env": { + "workspace_include": [ + "${workspaceFolder}/include" + ], + "agbcc": "${workspaceFolder}/tools/agbcc/bin/agbcc_arm", + "agbcc_include": [ + "${workspaceFolder}/tools/agbcc/**" + ], + "agbcc_args": [ + "-mthumb-interwork", + "-Wimplicit", + "-Wparentheses", + "-Werror", + "-O2", + "-fhex-asm" + ], + "modern": "/usr/bin/arm-none-eabi-gcc", + "modern_args": [ + "-mthumb", + "-mthumb-interwork", + "-O2", + "-mabi=apcs-gnu", + "-mtune=arm7tdmi", + "-march=armv4t", + "-fno-toplevel-reorder", + "-Wno-pointer-to-int-cast" + ] + }, + "configurations": [ + { + "name": "firered", + "includePath": [ + "${workspace_include}", + "${agbcc_include}" + ], + "compilerPath": "${agbcc}", + "cStandard": "gnu99", + "cppStandard": "gnu++98", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "FIRERED", + "REVISION=0", + "MODERN=0" + ], + "compilerArgs": [ + "${agbcc_args}" + ] + }, + { + "name": "firered_rev1", + "includePath": [ + "${workspace_include}", + "${agbcc_include}" + ], + "compilerPath": "${agbcc}", + "cStandard": "gnu99", + "cppStandard": "gnu++98", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "FIRERED", + "REVISION=1", + "MODERN=0" + ], + "compilerArgs": [ + "${agbcc_args}" + ] + }, + { + "name": "firered_modern", + "includePath": [ + "${workspace_include}" + ], + "compilerPath": "${modern}", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "FIRERED", + "REVISION=0", + "MODERN=1" + ], + "compilerArgs": [ + "${modern_args}" + ] + }, + { + "name": "firered_rev1_modern", + "includePath": [ + "${workspace_include}" + ], + "compilerPath": "${modern}", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "FIRERED", + "REVISION=1", + "MODERN=1" + ], + "compilerArgs": [ + "${modern_args}" + ] + }, + { + "name": "leafgreen", + "includePath": [ + "${workspace_include}", + "${agbcc_include}" + ], + "compilerPath": "${agbcc}", + "cStandard": "gnu99", + "cppStandard": "gnu++98", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "LEAFGREEN", + "REVISION=0", + "MODERN=0" + ], + "compilerArgs": [ + "${agbcc_args}" + ] + }, + { + "name": "leafgreen_rev1", + "includePath": [ + "${workspace_include}", + "${agbcc_include}" + ], + "compilerPath": "${agbcc}", + "cStandard": "gnu99", + "cppStandard": "gnu++98", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "LEAFGREEN", + "REVISION=1", + "MODERN=0" + ], + "compilerArgs": [ + "${agbcc_args}" + ] + }, + { + "name": "leafgreen_modern", + "includePath": [ + "${workspace_include}" + ], + "compilerPath": "${modern}", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "LEAFGREEN", + "REVISION=0", + "MODERN=1" + ], + "compilerArgs": [ + "${modern_args}" + ] + }, + { + "name": "leafgreen_rev1_modern", + "includePath": [ + "${workspace_include}" + ], + "compilerPath": "${modern}", + "cStandard": "gnu17", + "cppStandard": "gnu++17", + "intelliSenseMode": "linux-gcc-arm", + "defines": [ + "ENGLISH", + "LEAFGREEN", + "REVISION=1", + "MODERN=1" + ], + "compilerArgs": [ + "${modern_args}" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000000..d5f69c63da9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,55 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Clean", + "type": "shell", + "promptOnClose": true, + "command": "make", + "args": ["clean"], + "presentation": { + "reveal": "silent", + "panel": "shared", + "close": true + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "Build", + "type": "shell", + "promptOnClose": true, + "command": "make", + "args": [ + "-j$(nproc)", + "${command:cpptools.activeConfigName}" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": false + }, + "problemMatcher": [ + "$gcc" + ] + }, + { + "label": "Clean and Build", + "dependsOrder": "sequence", + "dependsOn": [ + "Clean", + "Build", + ], + "options": { + "statusbar": { + "hide": true + } + } + } + ] +} \ No newline at end of file From aa550a29fa68bf273c860b1b530a3c0d9aad49a3 Mon Sep 17 00:00:00 2001 From: Jademalo <386846+Jademalo@users.noreply.github.com> Date: Tue, 10 Mar 2026 22:41:16 +0000 Subject: [PATCH 3/4] Add support for VSCode step debugger --- .devcontainer/Dockerfile | 3 ++- .devcontainer/devcontainer.json | 5 ++++- .gitignore | 1 + .vscode/launch.json | 26 ++++++++++++++++++++++++++ .vscode/tasks.json | 24 ++++++++++++++++++++++++ Makefile | 2 +- 6 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 3523d22019f..8677029337d 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -11,7 +11,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y instal git \ libpng-dev \ gcc-arm-none-eabi \ - libnewlib-arm-none-eabi + libnewlib-arm-none-eabi \ + gdb-multiarch # Download and compile agbcc WORKDIR /tmp/tools/agbcc diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ba106f7b12c..653f1d8ef73 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -21,7 +21,10 @@ }, "search.exclude": { "**/tools": true - } + }, + + "mgba_debug_ip": "host.docker.internal", + "mgba_debug_port": 2345 }, diff --git a/.gitignore b/.gitignore index 961e2e0f9bf..b4dc602e9c5 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,7 @@ prefabs.json .vscode/*.* !.vscode/c_cpp_properties.json !.vscode/tasks.json +!.vscode/launch.json *.js *.sym build-cmake-*/ diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000000..cf6500a2213 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "mGBA GDB Remote", + "type": "cppdbg", + "request": "launch", + "program": "./poke${command:cpptools.activeConfigName}.elf", + "cwd": "${workspaceFolder}", + "preLaunchTask": "Build Debug", + "linux": { + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb-multiarch", + "miDebuggerServerAddress": "${config:mgba_debug_ip}:${config:mgba_debug_port}", + }, + "targetArchitecture": "arm", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index d5f69c63da9..300360b02d4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -38,6 +38,30 @@ "$gcc" ] }, + { + "label": "Build Debug", + "type": "shell", + "promptOnClose": true, + "dependsOn": "Clean", + "command": "make", + "args": [ + "-j$(nproc)", + "${command:cpptools.activeConfigName}", + "DINFO=1" + ], + "group": { + "kind": "test", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "dedicated", + "clear": false + }, + "problemMatcher": [ + "$gcc" + ] + }, { "label": "Clean and Build", "dependsOrder": "sequence", diff --git a/Makefile b/Makefile index ef6a66de7c0..da9c59c7295 100644 --- a/Makefile +++ b/Makefile @@ -100,7 +100,7 @@ else endif # Enable debug info if set ifeq ($(DINFO),1) - override CFLAGS += -g + override CFLAGS += -g -O0 endif # Variable filled out in other make files From d8c16cc9227a0641ff85c8528e8360b089b141cb Mon Sep 17 00:00:00 2001 From: Jademalo <386846+Jademalo@users.noreply.github.com> Date: Tue, 10 Mar 2026 22:41:22 +0000 Subject: [PATCH 4/4] Add README --- .devcontainer/README.md | 56 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .devcontainer/README.md diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 00000000000..f77dc13add1 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,56 @@ +# VSCode Dev Container Configuration + +This repo has been set up with support for VSCode Dev Containers. This provides a fully working build environment complete with linting and a remote debugger. + +## Initial Installation + +To get started, first [install Docker Desktop](https://docs.docker.com/desktop/features/wsl/#turn-on-docker-desktop-wsl-2), and select the prompt to enable WSL 2 support during the installation. Make sure to follow the instructions to set Docker to use the WSL 2 based engine. + +Next, install the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension for VSCode. + +### Creating the Dev Container + +From here, if you want to get up and running quickly you can clone the repo into a container volume in VSCode by opening the command palette with `Crtl+Shift+P`, running `Dev Containers: Clone Repository in Container Volume`, and pasting the link to the repo. + +This will clone the repo, and automatically configure a full build environment complete with all necessary dependencies. + +### Building the ROM + +First select the build target by opening the command palette and running `C/C++: Select a Configuration...`, or by selecting it in the bottom right hand corner when browsing any source file. This will set up Intellisense to give error information for that specific build, as well as make it the target. + +To build the rom, open the command palette and run `Tasks: Run Build Task`, or use the shortcut `Ctrl+Shift+B`. This will build the target selected in the previous step. + +If you need to clean the repo for a fresh build, you can open the command palette, run `Tasks: Run Task`, and select `Clean` or `Clean and Build`. + +## Debugging with mGBA + +The modern build targets support step debugging within VSCode. This allows you to set up breakpoints, view variables, and see the current call stack of the game. + +To get started, [download and install mGBA](https://mgba.io/). + +**Make sure that a modern build target is selected in VSCode, or the debugger will not work correctly.** + +Next, go to Run and Debug in VSCode by either selecting it in the panel on the left or the shortcut `Ctrl+Shift+D`. From here make sure `mGBA Debug Remote` is selected, and click the play icon. + +This will compile the selected build for debugging, and once complete wait for the GDB server to start. + +Once the build has completed, download the ROM from VSCode by right clicking on it and selecting download. Open the ROM in mGBA, then go into `Tools -> Start GDB Server` and enable the server. You can also launch mGBA with the `-g` argument to start the server automatically. It may time out before you connect, but if it does so simply click the play icon again in VSCode. + +If the game starts and the bar at the bottom of VSCode changes colour, then the debugger has been successfully linked to the emulator. + +From here you can set breakpoints by clicking on the red dot to the left of any line in any source file, and when code execution gets to that point the emulator will pause and give information on the current state of the game. You can then either resume, or step over the functions line by line. + +## Advanced Configuration + +### Accessing Files + +While cloning the repo into a Docker volume is convenient, it unfortunately makes it difficult to access and modify other files within using tools such as [Porymap](https://github.com/huderlem/porymap). + +If you need direct access to the source folder, then it is possible to mount a directory directly into the Dev Container. + +In a fresh VSCode window, clone the repo and select a destination. Once the repo has been cloned and opened, you can then open the command palette with `Ctrl+Shift+P` and select `Dev Containers: Reopen in Container`. This is also easily accessible from the icon with two arrows in the bottom left of VSCode. + +This will open the local folder in the container, allowing much easier access to the source files. However on Windows, this comes at a serious penalty to build speed, increasing compilation times by up to 5x. + +It is possible to get the best of both worlds on Windows by cloning into and then opening the source folder from within the WSL filesystem, which can be accessed at `\\wsl.localhost\`. +