!lm10
!rm75
Applesoft Hi-Res Subroutines.................Bob Sander-Cederlof

One of the questions I hear the most is "How can I call the Hi-Res subroutines in the Applesoft ROMs?"  The basic information about those subroutines has been published (in Apple Orchard, Vol. 1 No. 1), but with an error in the subroutine addresses.

First, some important locations in page zero:
!lm15

$1A,1B  Shape pointer used by DRAW and XDRAW
$1C     Last used color byte
$26,27  Address of byte containing X,Y point
$30     Bit mask for bit in that byte
$E0,E1  X-coordinate (0-279)
$E2     Y-coordinate (0-191)
$E4     Color
$E6     Page ($20 if HGR, $40 if HGR2)
$E7     SCALE= value
$E8,E9  Address of beginning of shape table
$EA     Collision counter
$F9     ROT= value
!lm10

The software uses some other page zero variables, but I am not too clear yet on their purpose.

Now here are the major entry points:
!lm15

HGR2     $F3D8   Initialize and clear hi-res page 2.

HGR      $F3E2   Initialize and clear hi-res page 1.

HCLR     $F3F2   Clear the current hi-res screen to black.

BKGND    $F3F6   Clear the current hi-res screen to the
                 last plotted color (from ($1C).

HPOSN    $F411   Positions the hi-res cursor without
                 plotting a point.
                 Enter with (A) = Y-coordinate, and
                 (Y,X) = X-coordinate.

HPLOT    $F457   Calls HPOSN and tries to plot a dot at
                 the cursor's position.  If you are
                 trying to plot a non-white color at
                 a complementary color position, no
                 dot will be plotted.

HLIN     $F53A   Draws a line from the last plotted
                 point or line destination to:
                 (X,A) = X-coordinate, and
                 (Y) = Y-coordinate.

HFIND    $F5CB   Converts the hi-res coursor's position
                 back to X- and Y-coordinates; stores
                 X-coordinate at $E0,E1 and Y-coordinate
                 at $E2.
!np
DRAW     $F601   Draws a shape.  Enter with (Y,X) = the
                 address of the shape table, and (A) =
                 the rotation factor.  Uses the current
                 color.

XDRAW    $F65D   Draws a shape by inverting the existing
                 color of the dots the shape draws over.
                 Same entry parameters as DRAW.

SETHCOL  $F6EC   Set the hi-res color to (X), where (X)
                 must be between 0 and 7.

!lm10
I wrote a sample demonstration program of the hi-res subroutines.  First, here is an Applesoft version.  Note that it first sets the whole screen to a particular color, and then draws a series of nested squares in a complementary color.  Since it is nice and short, why don't you type it in and try it?

    <code here for applesoft version>

Now here is the assembly language program for the same task.  It seemed to run about twice as fast as the Applesoft version, but I didn't use the stopwatch on it.
