C64 tweeting

The page is on the internet for a while now, but I had some trouble getting everything working properly, but now I think it’s good enough to post about:

I have an account on twitter that’s not doing very much, mostly tweeting the cartoons I post here. While staring at tweets I thought:

can you tweet a (Commodore 64) executable program?

Twitter now has a 280 character tweet limit, so how much binary can you fit into it? First of all, there is the encoding, you can’t just post a binary, you have to encode it. You could post in zeroes and ones, Twitter would allow that, but that leaves 280/8 = 35 bytes. That’s not much!

And I think you would like to add maybe a hashtag, a link and a simple message, so you wouldn’t even have 35 bytes.

HEX is a bit better, and Twitter can handle that easily. You could code directly from keyboard if you have the programmers handbook ready.

Here’s a Hello World in HEX:
010815080100992248454C4C4F20574F524C442122001D080200892032000000

It takes 2 characters to encode a byte, so at most you can tweet a 140 bytes program.

I knew about Base64, where you use 64 different but standard characters to encode a binary. With Base64 you can encode 6 bytes in 8 characters. It’s used a lot on the internet and the VICE.js demo uses it to encode en decode .prg and d64 files.

Encoding is not easily done without tooling, you have to get all the separate bits from your program and make characters from that. But luckily there are enough tools online to help you with that. You could also use some script to automate the process.

At most you can use 75% of the 280 characters of a tweet. Pretty good. But that could be improved on, surely?

I started searching the internet and found out people were already using twitter to post binary data (of course!).

Someone developed Base65536 where you can encode  2 bytes into every character. Follow the link to get several implementations of the algorithm. The author of the algorithm also has a more thorough  explanation of the background.

The algorithm uses characters that are not your standard latin characters, but Twitter should accept them.

EDIT 10-8-2018: Twitter has its own way of calulating length, the longest program I managed to tweet was 256 bytes. So

2 bytes into every character

is not true. But still better then BASE64

A program could look like this:

㰁㰋㐊枞欰㐴㐀㐀唀䊩喍玢炽㝀䓊㯸㒍㖩䦍臐㰸㐀㐀㐀㐀㭀門瓠䏀咀吘㯠㞀㓿㐀㐀㐀㔀

Of course you’d want to be able to see what the program would do, so I tried to string everything together on a page on my website:

  • The page would extract tweets with a certain hashtag (in this case: #twt6510)
  • it would have to be able to identify an encoded part
  • it would have to be able to identfy what the encoding was (my solution is: prepend the code with a number that signifies the encoding: ‘1’ for base65536, ‘2’ for base64, ‘3’ for HEX (base16).
  • it would then decode it, then encode it to Base64 (if it wasn’t already)
  • the base64 encoded program would then be passed to an instance of vice.js and run

This is all running at the moment, but there are still some things left to solve:

  • I don’t properly understand the Twitter search API. Sometimes tweets are found, but sometimes not and I have no idea why.
  • The search API is different from the online Twitter search page and probably  older tweets are not found this way, so I
  • have to save older tweets  on my site.
  • I have thought about being able to tweet BASIC programs, but I don’t know how to encode that to binary without duplicating the BASIC interpreter (maybe sending keyboard events to vice.js?).
  • You still have to press a button to get the search results

Anyway it’s working OK, so here is  finally the link:

http://www.goerp.nl/C64/6510twt.html

There are some instructions how to get you own program to run there

example tweet:

result:

You have about 256 bytes, here’s what I did in 256 bytes. Not that impressive, but it is a game.

Flappy twirds

Press space to go up, but be quick! You’ll die quickly then it will reset (but SYS2062 will restart or F5 for browser refresh).

 


here’s what others can do in 256 bytes, ‘A Mind Is Born’ by Linus Åkesson.

 

Leave A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.