Last Cyber Monday I picked up the awesome PocketChip by The Next Thing. The pleasant bonus to the very capable Linux based system, is that it comes packaged with the Pico-8 virtual console.
The game system, as it’s name suggests, is reminiscent of an 8-bit machine. Complete with the limitations of 32kb “carts” that hold game code, artwork and music. 16 colors and very chippy, chip tune sound generation. The screen size is 127 x 127 pixels. All together the systems capabilities amount to a very convincing retro machine.
The Pico-8 environment also includes a three part IDE: code editor, sprite sheet art package and sound tracker. While it’s possible to use the built in code editor pretty effectively, when the code length gets into the hundreds of lines, code management gets complicated.
To establish a more modern working environment, I installed Pico-8 onto an OSX system. The following guide is intended for Mac users but aspects can be applied to Linux, Windows and CHIP/Raspberry Pi.
Editing Pico-8 Carts
OSX stores Pico-8 carts in the /Users/$USERNAME/Library/Application Support/pico-8/carts folder, $USERNAME is your user on the system. On the PocketCHIP and Linux, you can find carts in /home/chip/.lexaloffle/pico-8/carts. Replace “chip” with the systems user.
To make life easier, create a symlink from a dev directory to the cart location.
First create a dev folder in you desired location.
Then from within the cart folder execute:
ln -s /Users/USERNAME/Library/Application\ Support/pico-8/carts ~/pico-8-dev
Note the escaped space in “Application Support”. The above example will link the cart location within Pico-8 to the folder pico-8-dev located in the users home folder.
Choosing an Editor
Pico-8 carts are coded in a simplified version of Lua, so any editor that can recognize the language will be able to visually format your code, personally I use Coda 2. Regarding cart structure, Pico-8 can use either .png or .p8 file format to store code, art and sound data. When starting a project, it’s advisable to save out a .p8 file from the Pico-8 IDE and the switch over to an alternate editor to include any required cart syntax.
Also, make sure to save and reload before editing when switching editors to avoid overwrites.
Transferring Files to a PocketCHIP
The simplest way to transfer a game cart is over SCP. To start, navigate to your dev folder and then execute:
scp filename.p8 firstname.lastname@example.org:/home/chip/.lexaloffle/pico-8/carts
You can now play your project directly on your device!
Creating a Git Repository
As with any modern development project, putting your work into version control is a good practice.
git init git add -A git commit -a -m "Initial commit."
From here you can optionally add your repository to a remote service like Github.
From the Github interface initialize a new project, without creating the readme file. Github should provide you with the option and command to set the origin of your local repo to Github’s.
git remote add origin https://github.com/username/repo-name.git git push -u origin master
Where to Next?
With the ability to see your code in a more structured format and effectively manage your code, you’ve freed yourself to explore and develop within the Pico-8 architecture. While the restraints of Pico-8 are huge, I personally find the environment liberating, the very nature of the platform eliminates feature creep.
In my next article, I’ll get down to the nitty gritty of writing within Pico’s function structure.