DEV Community

Cover image for How I sync live coding from my Atari 1200XL to Github
Ryan Collins
Ryan Collins

Posted on • Originally published at gozgeek.com on

How I sync live coding from my Atari 1200XL to Github

For the past few weeks I’ve been streaming a live coding session from my Atari 1200XL, programming a Snake game in AtariBasic. Last week I had the idea, what if I could share the code live while streaming so others could follow along? I figured out how to do it.

Prerequisites

For this to work, you’ll need the following:

  • An Atari 8-bit computer. The 800 and 1200XL have the best keyboards, but the 800XL is the most common and thus cheaper. For the 800 you’ll need the AtariBasic cartridge
  • A Fujinet. This is a wifi enabled device that adds all sorts of cool networking capabilities to your Atari 8-bit. We’re only using it for disk emulation.
  • Local Linux host. The Linux host will run tnfsd to share the disk image to the Atari. It will also run a script that will extract the files from the disk image, convert line endings for files that end in .LST, and commit these to Github.
  • Public Github repo and SSH logins set up. The Linux host will commit the changes and push them to the repo, and to do this automatically you’ll need to have ssh keys set up.

On the Linux host you’ll need to install:

  • tnfsd - Download the binary under TNFS server.
  • git
  • atrcopy - The script that extracts files from a disk image.
  • tmux - Not required, but makes it easier to run the TNSF server and the script at the same time.
  • entr - Monitors a file for changes and then runs a script

a8syncdev.sh

Here’s the script that syncs the files from the disk image to the git repo:

#!/bin/bash

diskimage="${HOME}/atari8/GozSnake.atr"

cp "${diskimage}" .

cd src
~/.local/bin/atrcopy "${diskimage}" extract --all -f

for file in *.LST
do
.
.
tr '\233\177' '\12\11' <"${file}" > /tmp/temp.lst
.
.
cp /tmp/temp.lst "${file}"
done

cd ..
git add *
git commit -am "Automated commit `date`..."
git push

Enter fullscreen mode Exit fullscreen mode

The TNFS server is sharing out the ~/atari8 directory, which in this case contains our disk image GozSnake.atr which is mounted on the Atari. The script is run in the local repo folder. When this script runs, it will:

  • copies the current disk image into the repo
  • extract the contents of the disk to the src directory
  • translate the line ends for any file that ends in .LST
  • Adds everything to git
  • Commits everything with an automated message
  • Pushes it to Github

Now, how do we run this automatically? We could set it up to run every 10 seconds, but that seems wasteful, especially when we have entr.

Enter entr

entr is a command that can watch a file or folder and run other commands when the file or folder changes. In our case, we want it to watch our GozSnake.atr disk image file and run a8syncdev.sh when it changes. We can do that with:

ls ~/atari8/GozSnake.atr | entr ../a8syncdev.sh

Enter fullscreen mode Exit fullscreen mode

I run in from my repo directory so the paths are correct. The a8syncdev.sh script is one level up. Anytime the disk image file changes, the script is ran and the git repo is updated.

Watch it in action

Follow me over on Twitter, Mastodon, and/or Twitch to know when I’m streaming. Let me know if you can see any improvements!

Top comments (0)