Specifications

Apple IIGS
#70: Fast Graphics Hints 1 of 4
Apple II
Technical Notes
Developer Technical Support
Apple IIGS
#70: Fast Graphics Hints
Written by: Don Marsh & Jim Luther September 1989
This Technical Note discusses techniques for fast animation on the Apple IIGS.
QuickDraw II gives programmers a very generalized way to draw something to the Super Hi-Res
screen or to other parts of Apple IIGS memory. Unfortunately, the overhead in QuickDraw II
makes it an unacceptable tool for all but simple animations. If you bypass QuickDraw II, your
application has to write pixel data directly to the Super Hi-Res graphics display buffer. It also
has to control the New-Video register at $C029, and set up the scan-line control bytes and
color palettes in the graphics display buffer. Chapter 4 of the Apple IIGS Hardware Reference
documents where you can find the graphics display buffer in memory and how the scan-line
control bytes, color palettes, and pixel data bytes are used in Super Hi-Res graphics mode. The
techniques described in this Note should be used with discretion—we do not recommend
bypassing the Apple IIGS Toolbox unless it is absolutely necessary.
Map the Stack Onto Video Memory
To achieve the fastest screen updates possible, you must remove all unnecessary overhead from
the instructions that perform graphics memory writes. The obvious method for achieving
sequential writes to the graphics memory uses an index register, which must be incremented or
decremented between writes. These operations can be avoided by using the stack. Each time a
byte or word is pushed onto the stack, the stack pointer is automatically decremented by the
appropriate amount. This is faster than doing an indexed store followed by a decrement
instruction.
But how is the stack mapped onto the graphics memory? The stack can be located in bank $01
instead of bank $00 by writing to the WrCardRAM auxiliary-memory select switch at $C005.
Bank $01 is shadowed into $E1 by clearing bit 3 of the Shadow register at $C035. Under these
conditions, if the stack pointer is set to $3000, the next byte pushed onto the stack is written to
$013000, then shadowed into $E13000. The stack pointer is automatically decremented so the
stage is set for another byte to be written at $E12FFF.
Warning: While the stack is mapped into bank $01, you may not call any firmware,
toolbox or operating system routines (ProDOS 8 or GS/OS). Don’t even
think about it.
Unroll All Loops