randomouscrap98 / ardugotools

A CLI toolset for Arduboy
MIT License
2 stars 0 forks source link

Ardugotools

A simple, single-binary CLI toolset for Arduboy. Runs on many systems

Features

Building / Using

Once you have the code and go installed, just run go build in the repo and it should produce an executable:

cd cmd/ardugotools
go build
./ardugotools --help

Commands

You can get a list of all commands with ardugotools --help. Further information about each command can be found by running help on said command, like ardugotools flashcart write --help. Note that help is auto-generated, so I'm sorry for any funny formatting issues...

Many commands run against a device. You must specify the port a device is on (usually something like COM5 on Windows or /dev/ttyACM0), or you can substitute any to connect to the first device found.

Here's some examples of what you might do:

ardugotools device scan            # See all currently connected devices
ardugotools device query any       # Get deep information about the first connected device
ardugotools sketch read any        # Read the sketch that's on the first connected device
ardugotools eeprom read COM5       # Read the eeprom that's on a particular device
ardugotools flashcart scan any --images --html > flashcart.html    # Get a webpage you can browse which shows what's on the flashcart

Note that for most commands, you can omit the "any" and it will still default to the first connected device.

Installing

Choose one of two methods:

FX data generation

In order to utilize the FX external flash chip in the Arduboy, you would generally write an fxdata.txt configuration file, which describes the layout of the data and save. You would use the python scripts to generate a header, data binary, and optionally save binary. However, I found that the format of fxdata.txt was difficult to parse, and didn't give me the flexibility I desired. Most people end up writing scripts to generate the intermediate configuration, which is then used to generate the FX header and data.

Ardugotools attempts to shortcut this process by replacing fxdata.txt with lua scripting. This way, you can script your data generation but then immediately write the FX headers and data without an intermediate step.

Examples

There are a few example lua scripts. Please see fxdata.lua for a thorough rundown of all the available functions as well as a small example. For a far more complicated example, see the slendemake script.

Flashcart generation

Like FX data generation, you can generate full flashcart files using lua scripting. Generating flashcarts is a complicated task that generally requires writing the entire flashcart all at once, meaning you must know precisely how you want your flashcart to look, such as the categories, games, images, and order of everything. This is usually best done with a UI, since it is inherently a visual product intended for human use. However, for those who want maximum control over their flashcarts and are willing to put in the effort, I've included a system for generating flashcarts programmatically.

In general, you will be writing a script in which you will:

Examples

Currently there is one pure example file: flashart.lua. It goes over the basics of generating a flashcart using the lua script. There's more you can do with this system though, so you may want to look at the flashcart helpers for more examples of what you can do.

Flashcart helpers

Since generating flashcarts is complicated, I've provided some helper scripts for common tasks, located in the helpers folder. To run these, simply run the ardugotools flashcart generate command with the appropriate lua script, and pass in the required arguments. Each script will indicate the required arguments if they are used incorrectly, so simply running the script with no arguments is enough to see.

Add or update helper

Adding or updating an individual game in a flashcart is a very common task. This script will attempt to add a .arduboy package to a flashcart in the given category. If the program already exists in that category, it is instead updated, so you don't have duplicates.

You must specify the package to add, the devices you'll accept from the package, the category, the old flashcart, and the new flashcart (can't be the same). Example:

ardugotools flashcart generate helpers/addorupdate.lua mygame.arduboy "Arduboy,ArduboyFX", Action, flashcart.bin newflashcart.bin

You can repeatedly call this script to add many files to a flashcart, though note that it's rather inefficient to do so.

Apply FX saves from one flashcart into another

Another very common task is updating your flashcart. Doing so in lua is quite a chore, so instead I've provided a script which takes fxsaves from one flashcart and applies them to another. This way, you can download the flashcart of your choosing, perhaps from the cart builder website, then apply the saves from your existing flashcart into the new one, letting you have all the latest games without losing your saves.

You must specify the base flashcart (that has your saves), the flashcart to apply the saves to (will NOT be overwritten), and the new flashcart to write to (can't be either of the other flashcarts). Example:

ardugotools flashcart generate helpers/applysaves.lua myflashcart.bin newflashcart.bin outflashcart.bin

Then you can flash outflashcart.bin to your Arduboy.

Make Cart from folder

If you don't want to write a script yourself to create a custom flashcart, you can instead set up a folder with all the categories and games and use helpers/makecart.lua to generate it for you. The folder must be setup in a certain way; see the comments in makecart.lua to get started. In general, you simply setup a folder where:

The arguments to pass in are the folder to read from, the devices to choose inside the packages, and the path to save the flashcart binary to. An optional fourth parameter lets you indicate ignored folders by name, comma separated. Example:

ardugotools flashcart generate helpers/makecart mycart "Arduboy,ArduboyFX" flashcart.bin "ignore,trash"