Skip to content

Mark-LaCroix/vscode-playdate-debug

 
 

Repository files navigation

Playdate Debug

Unofficial Playdate debug extension for Visual Studio Code

Features

  • Debug Lua code running in the Playdate Simulator
  • Compile games to .pdx using pdc
  • Problem matchers for pdc
  • Open the Playdate Simulator

Requirements

Quick Setup

Use cookiecutter and cookiecutter-playdate to quickly create a project skeleton.

Manual Setup

Debugging

  1. Click on the debug icon (play symbol with a bug) in the toolbar to open the "Run and Debug" view
  2. Click the link that says Create a launch.json file
  3. Select Playdate Debug in the dropdown to create the configuration in .vscode/launch.json
  4. (Optional) Run the default build task before debugging by setting the preLaunchTask property in the Debug (Simulator) configuration:
"preLaunchTask": "${defaultBuildTask}"

Your .vscode/launch.json should now look like this:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "playdate",
      "request": "launch",
      "name": "Debug (Simulator)",
      "preLaunchTask": "${defaultBuildTask}"
    }
  ]
}

Tasks (Optional)

Build

  1. Enter Cmd/Ctrl + Shift + P on the keybord to open the Command Palette
  2. Type Configure Task and hit enter
  3. Select Playdate: Build in the dropdown to add it to .vscode/tasks.json

Simulator

  1. Enter Cmd/Ctrl + Shift + P on the keybord to open the Command Palette
  2. Type Configure Task and hit enter
  3. Select Playdate: Simulator in the dropdown to add it to .vscode/tasks.json

Build and Run

  1. Open .vscode/tasks.json
  2. Paste the following configuration into the tasks array after the Playdate: Simulator task:
{
  "label": "Playdate: Build and Run (Simulator)",
  "dependsOn": ["Playdate: Build", "Playdate: Simulator"],
  "dependsOrder": "sequence"
}
  1. Enter Cmd/Ctrl + Shift + P on the keybord to open the Command Palette
  2. Type Configure Default Build Task and hit enter
  3. Select Playdate: Build and Run (Simulator) in the dropdown

Your .vscode/tasks.json file should now look like this:

{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "pdc",
      "problemMatcher": ["$pdc-lua", "$pdc-external"],
      "label": "Playdate: Build"
    },
    {
      "type": "playdate-simulator",
      "problemMatcher": ["$pdc-external"],
      "label": "Playdate: Simulator"
    },
    {
      "label": "Playdate: Build and Run (Simulator)",
      "dependsOn": ["Playdate: Build", "Playdate: Simulator"],
      "dependsOrder": "sequence",
      "problemMatcher": [],
      "group": {
        "kind": "build",
        "isDefault": true
      }
    }
  ]
}

Configuration

The tasks and debugger will attempt to automatically resolve the correct configuration using the environment. The following configuration must exist for this to work:

  • Either of the following:
    • ~/.Playdate/config exists and the SDKRoot property is set to the Playdate SDK path
    • The PLAYDATE_SDK_PATH environment variable is set to the Playdate SDK path
  • The Playdate SDK bin directory is in your PATH
  • A pdxinfo file exists in your game's source directory and the name property is set

The default behavior can be overridden by setting the SDK path, game source path, compiled game path or game name in your workspace's settings.json file. The extension will fall back to the default behavior for any configuration fields that are not set.

// .vscode/settings.json
{
  "sdkPath": "/path/to/PlaydateSDK",
  "sourcePath": "/path/to/MyGame/source",
  "outputPath": "/path/to/MyGame",
  "productName": "My Game"
}

The Playdate Simulator task launches the Playdate Simulator once and leaves it running in the background by default. The kill property can be used to instead have the task stop running instances of the Playdate Simulator before launching a new one.

// .vscode/tasks.json
{
  "version": "2.0.0",
  "tasks": [
    {
      "type": "playdate-simulator",
      "problemMatcher": ["$pdc-external"],
      "label": "Playdate: Simulator",
      "kill": true
    }
  ]
}

Known Issues

  • Debugging is not supported on Windows or Linux.
  • make and cmake-based projects are not supported.
  • Breakpoints are in an unverified state.
  • Stepping into C functions causes the debugger to continue executing.

About

Unofficial Playdate debug extension for Visual Studio Code

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 99.8%
  • Shell 0.2%