Apple IIe "Midline" 256B Demo


Presented at Outline 2023 Demoparty

By -=DEsIRE=-: code by deater

Note: only runs on Apple IIe


Video

Capture on an actual Apple IIe Platinum.

Sourcecode and Disk Image

You can get the disk image here: midline.dsk (140k), 20 May 2023

You can get the submission here: midline_small.zip (16k), 20 May 2023

You can get the sourcecode here in the demos/outline2023 directory of my dos33fsprogs github repository:
git clone https://github.com/deater/dos33fsprogs/
Vote for this at Pouet

Run-through of the Effects

Text Mode Scrolling



This really isn't an effect, but it sets up text page1 for later.

It uses the built-in COUT ROM routine to print the scrolling text efficiently.

There is a graphic apple printed, this is from the "mousetext" character set introduced with the later Apple IIe Enhanced system (yes, the 'e' in IIe also stands for Enhanced, so it's "enhanced enhanced", the model so nice they named it twice)

Hi-res Background



This is some compact shape-table based code to draw a fancy background in 16 bytes or so. We only wanted to loop around 64 bytes or so, for a countdown timer we decrement a zero page location that the BASIC ROM sets to $4C (jmp) at boot time.

Cycle-Counted Mid-screen Scrolling Window



The main event. I have been doing some cycle-counting recently with some Atari 2600 demos, and was doing some fancy double-graphics-mode switching demos lately.

Cycle-counted mode-switching is complicated on the Apple II as there's no standard way to find when VBLANK is to synchronize things. On older models you actually have to do horrible hacks with the floating bus to detect the beam location and I don't think you can do that in under 256 bytes (though maybe I should try). The Apple IIe and IIgs models in theory you can detect VBLANK by just reading a location in memory (though for some reason the value is inverted in the IIgs). The IIc model does something completely different. In any case that's why this demo is limited to the IIe, there isn't room to support all possible models.

Even though VBLANK detection on IIe is just reading a single memory location, you actually can only get the start within a 7-cycle range or so, which is enough for per-line mode-switching (because you can hide this in the HBLANK) but it's not good enough for exact mid-screen updates. This is a trick though, described by Sather in his "Understanding the Apple IIe" book from 1984. To do this you can repeat the detection 7 times, backing off by a cycle each time, to find out where things exactly happen. This is a pain though because you need 7 frames to find VBLANK, so you can't use it each frame. I use a variant of this, but only once and then I have to cycle count exactly the rest of the demo.

Once you have the VBLANK it's easy enough to change mid-screen to get a rectangular window. For variety it switches the background between hi-res (the design we drew earlier) and lo-res (which re-used the text page, but shows the ``apple ii forever'' text as chunky colored blocks instead.

Getting a nice scroll effect required a sine wave, which is actually a big chunk of the code. I re-used a trick described at the codebase64 site that uses a parabola instead of a sine wave, as it's much easier to calculate and close enough for our purposes.
Back to my Demos