Skip to content

Commodore 64 twitter bot inspired by @bbcmicrobot

License

Notifications You must be signed in to change notification settings

markhamilton/c64bot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

c64bot

Commodore 64 twitter bot inspired by @bbcmicrobot

Background

These are initial notes on a project to create a Commodore 64 Twitter bot which runs users' tweets on an emulator and returns a video of the execution in a similar style to my BBC Micro Bot.

Prerequisites

Cloud Commodore 64

A key piece of this project is to get a C64 emulator running programs and generating video purely via Linux command line. VICE looks like the best emulator for the job.

We don't want to run VICE in headless mode because we want video output to capture. However in the cloud we have no display to attach to and even trying to load VICE causes it to segfault.

The solution is to use X virtual framebuffer (xvfb) as the X server for the headless c64 cloud instance and capture the Display to video using ffmpeg x11grab as follows:

Xvfb :99 -screen 0 1280x1024x16 

DISPLAY=:99 x64 &

ffmpeg -f x11grab -y -r 50 -video_size 718x546 -i :99.0 0,27  -pix_fmt yuv420p output.mp4

It works! Here's a screenshot of video back from a VICE Commodore 64 emulator running on an AWS EC2 instance:

C64 boot screen

Input

Using the Twitter API we can take tweet text containing a Commodore 64 BASIC program listing and then convert it into a .prg file ready for autorun on the emulator.

It is important to note that by default the C64 is in PETSCII character mode. To allow for mixed case we are going to prepend the user's code with a POKE to switch to mixed case mode.

poke 53272,23

Next use the petcat utility included with vice to tokenize the basic code:

petcat -w2 -o basic.prg -- input.bas

Auto loader

Using the Autostart C64 plus disk, the idea is to load the disk, copy the basic program you outputted onto the autostart disk, and then begin execution. This command will do this all automatically:

DISPLAY=:99 x64 -default -parallel8 1 -autostartprgmode 2 -8 "/home/working/autostart.d64" -autostartprgdiskimage "/home/working/autostart.d64" -autostart "/home/mark/basic.prg"

That's all for now... let me know if you have any corrections / suggestions

About

Commodore 64 twitter bot inspired by @bbcmicrobot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published