Apple II Pascal SHORTGRAPHICS Module
Apple II Technical Notes
_____________________________________________________________________________
Developer Technical Support
Pascal #15: Apple II Pascal SHORTGRAPHICS Module
Revised by: Cheryl Ewy Dan Strnad November 1988
Written by: Cheryl Ewy December 1983
This Technical Note describes the Apple II Pascal SHORTGRAPHICS routine, which
is available as part of the 48K Run-Time System.
_____________________________________________________________________________
Introduction
Many applications, especially those designed to use the 48K Run-Time System,
run out of memory quickly if they use the TURTLEGRAPHICS unit provided with
the standard SYSTEM.LIBRARY.
This document describes a library unit called SHORTGRAPHICS which removes the
relative polar coordinate features of TURTLEGRAPHICS to save memory.
General Comments
If your application uses (or can be modified to use) only those TURTLEGRAPHICS
procedures which refer to absolute screen coordinates, you can use the
SHORTGRAPHICS unit. The SHORTGRAPHICS unit has the same segment numbers
assigned to it, as does TURTLEGRAPHICS, thus you may not use both in the same
program.
Deletions
The following routines are not available in the SHORTGRAPHICS unit:
PROCEDURE TURN(ANGLE: INTEGER);
PROCEDURE TURNTO(ANGLE: INTEGER);
PROCEDURE MOVE(DIST: INTEGER);
FUNCTION TURTLEANG: INTEGER;
Additions
The following definitions have been added to the INTERFACE section of
SHORTGRAPHICS:
TYPE
FONT=3DPACKED ARRAY[0..127,0..7] OF 0..255;
VAR
FONTPTR:^FONT;
The variable FONTPTR is a pointer to the memory area used by the WCHAR and
WSTRING procedures to display text on the graphics screen.
Thus, if you have a character set named KATAKANA.FONT, you could load it into
memory and use it as follows:
VAR
SPECIALFONT:^FONT; (* where the new font goes *)
SAVEFONT:^FONT; (* to save pointer to standard font =
area *)
PROCEDURE LOADFONT;
VAR
F:FILE;
NIO:INTEGER;
BEGIN
NEW(SPECIALFONT);
RESET(F,'KATAKANA.FONT');
NIO:=3DBLOCKREAD(F,SPECIALFONT^,2,0);
CLOSE(F)
END;
PROCEDURE USESPECIAL;
BEGIN
SAVEFONT:=3DFONTPTR; (* save standard font pointer *)
FONTPTR:=3DSPECIALFONT; (* and point to special font *)
END;
PROCEDURE USENORMAL;
BEGIN
FONTPTR:=3DSAVEFONT (* restore pointer to normal font *)
END;
Memory Considerations
When the system is booted, the heap pointer is normally below the start of
high-resolution page one. The TURTLEGRAPHICS unit automatically sets the heap
pointer above high-resolution page one. This protects the high-resolution
page from being overwritten by your program, but it also prevents you from
using the space between the original top of the heap and the start of high-
resolution page one for your own variables.
SHORTGRAPHICS does not protect the high-resolution page, thus you may use this
extra space for yourself. The following code will check to see if you have n
bytes available between the top of the heap and high-resolution page one. If
the room is not available, the heap pointer will be jumped to the top of the
high-resolution page.
PROCEDURE MAKEROOM(N:INTEGER);
CONST
BOTTOM=3D8192;
TOP=3D16384;
VAR
CHEAT:RECORD CASE BOOLEAN
TRUE:(IPART:INTEGER);
FALSE:(PPART:^INTEGER);
END;
BEGIN
MARK(CHEAT.PPART);
IF (CHEAT.IPART+N)>=3DBOTTOM THEN BEGIN
CHEAT.IPART:=3DTOP;
RELEASE(CHEAT.PPART)
END
END;
Thus, if you wanted to allocate a special font (which requires 1,024 bytes)
below the high-resolution page, you could use this code:
MAKEROOM(1024);
NEW(SPECIALFONT);
If there are at least 1,024 bytes beneath the high-resolution page, the new
font will be allocated there. If there is not enough space there, the new
font will be allocated above the high-resolution page.
All of these heap allocations should be done as the very first actions of your
program. When you finish allocating your variables, you should invoke the
following procedure to make sure the heap pointer is above high-resolution
page one (thus protecting it).
PROCEDURE PROTECT;
CONST
TOP=3D16384;
VAR
CHEAT:RECORD CASE BOOLEAN OF
TRUE:(IPART:INTEGER);
FALSE:(PPART:^INTEGER);
END;
BEGIN
MARK(CHEAT.PPART);
IF CHEAT.IPART