Rippled Shaded Plate (Atari 8-Bit) by Chris Chiesa
A downloadable project
This document accompanies my first-ever entry to the BASIC 10 Liner Contest, in the year 2023. My entry is an Atari BASIC (i.e. for the Atari 8-bit computers of the 1980s) “demo” program which generates a 16-level-grayscale (Atari BASIC “GRAPHICS 9”) image of a a rippled surface illuminated from a userspecified direction. For detail of the math, see the Appendix of this document. This program makes heavy use of Atari’s notoriously slow floating-point package. On my original Atari 800XL in 1987 (!) this program took 56 minutes to generate an image occupying only half the screen – I literally didn’t have the patience to sit and wait for a version that would have filled the whole screen! Today we have the tremendous advantage of being able to run this program on emulators that can run faster than the physical Atari hardware, in “turbo” or “warp speed” or “run as fast as possible” modes. I highly recommend their use when running this program, unless you really, really, want the authentic 1987 experience of plodding through it at a mere 100% of hardware speed! (I hear tell that the emulator Altirra offers a drop-in replacement for the slow floating-point package, but I haven’t tried that yet.)
The package that includes this document should also include a disk-image file named contest_2023.atr . Mount this as Drive 1 in an Atari emulator (or copy it to a physical floppy and place it in Drive 1 of a real Atari) that supports GTIA graphics (specifically, BASIC “Graphics 9” (grayscale) mode. Boot it with BASIC enabled, and at the READY prompt type RUN “D:PLAT10LN.BAS” . The program will not bother to clear the text screen when run, but will simply prompt you for an “illumination direction.” I suggest starting with -1, 1. This is the screen-relative direction “where the light should come from” to illuminate a rippled surface, which the screen now represents. You are to enter a pair of values representing X and Y directions, relative to the origin at the center of the screen, but not in any particular units. I think of these values in terms analogous to the Atari joystick directions: leftand-right are represented by negative-and-positive X values, respectively, and up-and-down are represented by negative-and-positive Y values. Values of 0 for either X or Y refer to “dead center.” I am not sure I am explaining this clearly, so start with various combinations of the values -1, 0, and 1, and you’ll soon get the idea. (There is a sort of relative scale to the values you enter. The light source’s Z coordinate is fixed at 1, so X and Y values of “about the same size,” either positive or negative, will result in illumination from an angle of about 35 degrees above the “horizon”; X and Y values “significantly larger” than 1 (again either positive or negative) will result in illumination from a lower angle (causing deeper, darker, shadows), and X and Y values “significantly smaller” than 1 (positive or negative) will result in illumination from a higher angle, potentially impairing the desired 3D effect. (X and Y both 0 produces a horrible thing with no 3D at all, and I recommend you avoid it.)
Leave a comment
Log in with itch.io to leave a comment.