AppleIIbot 280 char Applesoft Demos
Kay Savetz set up the
Apple II bot which lives on twitter and will take a 280 character
tweet you send it and run it in Applesoft BASIC on an Apple II emulator.
Of course this led to a lot of fun, and a bit of a rush to see if
we could do more interesting things than the already existing
BBC Micro bots. Below are some of the programs I came up with
and some explanations of the techniques used.
List of Exciting 280-char BASIC programs (80 and counting)
There were too many of them to list on one page, so I have broken things
out into multiple pages.
- Part 1:
Flame, Circles, Autumn, Spaceship,
Nyan Cat, Double Hi-res Pattern, Double Hi-res "Raster" Bars, Box Pumpkin,
Box Person, Box Apple II, 4am Bitmap, QR Code,
A2 Forever, Color Picture, 80s Grid, Horizon Flyer
- Part 2:
Snowflake, Plasma, C64, Sierpinski,
Sierpinski Zoom, Water Drops, Rickroll, Dual Apple II/GWBASIC,
Wire Spark, Tie Fighter, Amiga Ball, Floppy Rain,
Pastel Scroll, 16x16 8-color images, Bresenham Lines, Cube
- Part 3:
X xor Y mod 9, XOR Zoom, Hires Mod 9, Hires Sierpinski Zoom,
LIST blocks, Scrolling Tokens, Window Boxes, XOR Xtravaganza,
Alligator Disk, Giant Cursor, Raycaster, Stargate, Tunnel (BASIC),
Tunnel (ASM), Starfield (Lores), Starburst
- Part 4:
Starfield (Hires), Bresenham Circles, Hires Myst Scene,
Animated Boxes, Spiderweb, Mystic Sphere, Thinking/Cracking,
Fireworks, LOGO machine language, Plain Text machine language loader,
LOGO Line Two Sides, Dragon Fractal, Hires Wires, Static Sweep,
Pink Plasma, Purple Waves
- Part 5:
Hires Moving Waves, LOGO Ocean Scene, Thick Sine, Turkey Time,
Hires Doom Fire, Hires Screen Wipe, Christmas Scene, Edgarware,
Cosine Effect 3, Cosine Effect 4, Orb Horror, Lemming,
Rainbow Cosine, Particle Effect, Lunar Lander, Background Scroll
The Demosplash Demo
I took some of these programs, wrote an assembly language wrapper that
can start/stop BASIC programs, added some music and graphics, and came
up with a Demoscene Demo that won 1st place for retro demos at
the Demosplash 2020 demo party.
You can read more about that
- Q. Which is better for twitter-sized code, BASIC or assembly language?
A. This is a hard call, it depends a bit on what you're trying to do.
Assembly code is almost always faster. It's not necessarily
smaller though. BASIC wins in a lot of cases, especially ones
where you have 16-bit math, multiplies, divides,
trig functions, etc.
- Q. Could you write 6502 machine code that's valid ASCII
and just jump to it?
A. I wasted a lot of time looking into this. It is in theory possible
but very verbose so it doesn't match well with the 280 character
limit. The problem is the subset of instructions you get
is extremely limited, and it's hard to load useful
constant/variables into registers.
- Q. Could you load your assembly language programs to the zero
page and get some space savings?
A. It turns out Applesoft depends on a bunch of variables
scattered all over the zero page so it's hard to overwrite
things without crashing Applesoft before it's done.
- Q. Could you use some sort of compression algorithm? Even
A. Maybe, but 280 bytes isn't a lot to begin with, and
most things, even RLE, involve bit shifting and
masking something Applesoft is not really that
- Q. Are there any secret BASIC tricks left you haven't used?
There are still a few tricks remaining. There is some deep magic you can
do if you call into the Applesoft interpreter direct from assembly language.
Lots of articles on this from the 1980s.
Applesoft supports calls like USR and & besides CALL to call into
assembly language. The most useful is & which just does a plain
jump to $3F5. If you load your assembly properly you can use this to
save another few characters by getting rid of the CALL768. (Also if
you load your code at $3F5 you can watch it being decoded as it writes
to the $400 text page).
- Q. Are you the first person to do some of these tricks?
A. Probably not. The Apple II has a long, long history and
I was a bit young in the 80s so not really following
all the tricks in use then. I'm sure many of these things
were thought up and used at some point. For example
I came up with putting data in REM statements on my own,
but if you do a search you can find at least
where someone else had been doing it before me and even
presented at Kansasfest/published in Juiced.GS about it
back before I followed those venues.
- Q. But I've seen the REM trick on other architectures!
A. As far as I know qkumba and I came up with it independent from
other groups, but apparently it's some sort of optimal
way to load assembly on twitter across all 6502 architectures.
It's used by users of the atari bot
and something similar was used much earlier than us by users of the
BBC micro bot
The code and utilities I used to make these can be found on github:
A disk image for use in an emulator (or real hardware!) can be found here:
You can in theory try out the above in an in-browser emulator at
the internet archive here:
appleiibot at internet archive
So am I done for now?
Definitely not, however I have some other projects I need to finish up
which will take priority. It's been fun so far!
More Apple II Demos
Demos for GW-BASIC / PC BASIC Bot
Back to VMW Productions Page