Uses Eben Upton's base64-encoding and the dasm assembler to assemble 6502 and encode it into a BASIC-wrapped tweet for Dominic Pajak's @bbcmicrobot.
npm install
./codec.js examples/test.asm
This should generate the following
$3097="HM^cgxx@vGBWOGdzizBzfdIjt~ut~"
F.I=3105TO3125:?I=?I*4+(?(2062+I/3)/4^(I MOD3)):N.
CA.3105
Running this (e.g. by pasting it into jsbeeb or the BBCMicroBot editor) should print **OK**
and return to the BASIC prompt.
Note there are three lines: the first pokes the data, the second does the base64-decoding, and the third runs the code. You can introduce additional lines of BASIC if you want, e.g. to print text, clear the screen, change MODE, etc.
./codec.js examples/wright-fisher.asm --exec INIT
This is a simulation of a Wright-Fisher model (or, more precisely, a Moran model: see the Genetic Drift page on Wikipedia for more info).
Note the use of --exec
to change the start of execution.
The code calls the BBC BASIC RND subroutine at $af87 (documented here), as well as OSWRCH at $ffee.
./codec.js examples/diffusion.asm
This implements a simple diffusion, shown in action here.
Unfortunately some of the generated strings don't work when you give them to the bot, because of things in the code that look like Twitter handles (@...
), which the bot strips out.
You can work around this by specifying the --unspam
option, which breaks these strings with quotes (at a cost of 3 bytes per case).