Usually retro computer enthusiasts have a “thing” for pixelated graphics. This is so true that you can see the myriad of modern games mimicking 8 or 16 bits graphics being released all the time. I have to confess that I am one of those, but I sometimes go further and graphics like the TRS-80 and ZX81 just makes me happy. This is also true for the Lo-Res Apple II graphics. Those colorful big blocks are just amazing.
I believe that this passion for blocky graphics can be explained by how amazes me the creativity that one has to have to create one that resembles the object it tries to represent.
ZX-81’s 3D Monster Maze and TRS-80’s Dancing Demon are good examples of creativity over resolution. Even with no colors and very low resolution, the authors could achieve excellent results and the user knows exactly what they represent.
My Retrochallenge for this 2016 ‘Winter Warmup’ edition will focus on the Apple II low-resolution graphics. I want to be able to code fast using this graphic mode and, hopefully, having more people using the library to develop games, demos, and simple animations.
Apple II Lo-Res
Apple II Lo-Res mode is activated by the BASIC commmand GR and by default would deliver 40×40 pixels plus 4 lines of text at the bottom. Poking some memory address can make the screen been 40×48 pixels, always with 16 colors. The pixels have the same width of a text character, but half its size. In other words, two pixels stacked on top of each other occupies the same space of one character (In 40 column mode).
Applesoft BASIC has few commands to manipulate lo-res graphics:
GR – Turn lo-res mode on (mixed with 4 lines of text)
PLOT – Plot a pixel into the coordinates X,Y
HLIN – Plots an horizontal line from X1 to X2 at specific row
VLIN – Plots a vertical line from Y1 to Y2 at specific column
COLOR – Sets the color use on the commands above
SCRN – Gets the current color at coordinates X,Y
The C Library
I decided to create a C library to manipulate lo-res graphics on the Apple II. It will be used with the cc65 compuler, is a modern cross-compiler supporting several different platforms based on CPU 6502, including the Apple II.
The first step is to replicate the Applesoft BASIC commands, with few additions, like an option to plot on either of the two video pages as well as to be able to select the video mode features 40×48 without the four lines of text that the default BASIC GR command only allows to be activated.
Since I am fairly new to the Apple II platform. I am reading a lot of different Apple II books, mostly related to the lo-res graphics, but I could find the foundation of my library on the webiste Apple Oldies by Bill Buckels. There he wrote an example the shows some nice lo-res graphics being plotted, all using C that could be compiled using Aztec C or cc65.
From there, I started to write the functions of my library. So far I was able to write everything Applesoft offers but VLIN. My HLIN function seems still to be even slower than the Applesoft one, but I am not worried about performance for now.
As soon as I get VLIN done, I will host the library on Github and keep adding new features under everybody’s eyes. Stay tuned but for now a little teaser :)