Classic Computer Magazine Archive ANTIC VOL. 1, NO. 2 / JUNE 1982

PASCAL

A First Look

by Gary and Susan Frederick

After months of waiting, the PASCAL language is available through the Atari Program Exchange. It's a bargain at less than $50, BUT the user will have to have access to two (2) disc drives to operate PASCAL on his system.

PASCAL is fast becoming a favorite language of many computer scientists. It is taught as a first language in many colleges the way FORTRAN was a few years ago. PASCAL is structured, offering ease in design and debugging. A program written in standard PASCAL, with just a few modifications, can be used on a number of different computers.

Atari PASCAL is based on the International Standards Organization's (ISO) version with a few enhancements to support the Atari's unique capabilities, such as player missiles, joysticks, paddles, and sound. The PASCAL Reference and Operations manual states differences between Atari PASCAL and UCSD PASCAL. UCSD PASCAL is a popular version of the language available on a variety of computers including Apple.

As the reference manual states, Atari PASCAL is not meant for someone unfamiliar with programming or the internals of the Atari. However, we feel that those of you who have been using BASIC for some time and are familiar with your machine, could teach yourself PASCAL, with an appropriate book on the language, and a lot of patience. The reference manual is full of information but requires a lot of study to understand. (We need a De Re Pascal, perhaps?)

A number of different editors can be used to create your source. We have used Text Wizard and the Assembler editor from Optimized System Software to edit our programs. Remember that if your text is numbered the included files must be numbered also.

When it comes time to compile and run your program, a great deal of disk manipulation is required. The pseudo-code compiler performs several passes of error checking so initially it may seem like your program is error free but all is not clean until the final linkage is complete. Everytime a program is compiled, you will need two disc drives, one disc with your source, one compiler disc and one linker disc. The linker and compiler disc are included in the package and should be backed up before you run anything. One fault we found is the screen tells you to "Insert D1" at the end of a compile. We feel it would be clearer to say "Insert linker disc" or "Insert disc number one". Leaving the wrong disc in drive one causes PASCAL to die and you have to start over.

Some comments about Atari PASCAL: Sets use too much space. A set with two items like SCRN_TYPE is 32 bytes long. The set should occupy the largest space needed to store it in memory, in this case, one byte. Also, WRITE is slow compared to BASIC. But, you can link PASCAL to Atari's new Macro Assembler. So for the disadvantages to this version, there are quite a few advantages.

We have included an example of display lists in PASCAL here. In the next few issues we will go into detail on using Atari PASCAL. We will demonstrate some of the features of PASCAL that need examples such as calling Assembler and using the 850 Interface with a modem.

We will contribute our examples to ANTIC's Public Domain library. This will help those of you starting out and will we hope result in other users contributing to the Library.

If you have problems, send an example and we will help find what went wrong. Because PASCAL is an APEX program, Atari can not answer questions concerning its operation.

Program D1Demo

Our example program is the scrolling example from De Re Atari chapter 6-4 written in PASCAL. The main features of Atari PASCAL demonstrated are:

1. Using ABSOLUTE in the declaration of DLADDR to read the address of the display list.

2. Setting a pointer to the location of the data structure DL to modify the display list easily.

3. Using logical arithmetic to update an address.

type
  adr = integer;

  dlinst = record
             op : byte; (* display list instruction *)
             addrop: adr; (* address for op *)
           end; (* dlinst *)
  dlrec = record
            bl8lines : array [0..2] of byte; (* blank 8 lines *)
            lms : array [0..12] of dlinst; (* 3 byte DL instructions *)
          end; (* dlrec *)
var
  i,j : adr;
  dl : ^dlrec; (* pointer to type dlrec *)
  draddr : absolute [$230] ^dlrec; (* address of display list pointer *)

procedure initdl; (* initialize display list *)
  var
    i : integer;

begin
  dl := dladdr; (* point to the current DL *)

  dl^.bl8lines[0] := 112; (* blank 8 scan lines *)
  dl^.bl8lines[1] := 112;
  dl^.bl8lines[2] := 112;

  for i := 0 to 11 do
    begin (* set the op on address inmodified DL *)
      dl^.lms[i].op := 71; (* load memory scan basic 2 *)
      dl^.lms[i].addrop := i*256
    end; (* for *)

  dl^.lms[12].op := 65; (* jump vertical blank *)
  dl^.lms[12].addrop := dladdr; 
end; (* initdl *)

begin (* main procedure *)
  initdl;
  while TRUE do
    begin
      for i := 0 to 235 do
        begin (* loop through a page *)
          for j := 0 to 11 do
            begin (* set the 12 lines addresses *)
              dl^.lms[j].addrop := (dl^.lms[j].addrop & $ff00) + i
(* add one to the address, do not change the page the address points to *)
            end; (* for j *)
        end; (* for i *)
    end;
end.

Atari's implementation of PASCAL is very rich. We could have written this program many different ways, all of them equally valid. One important fact is that the screen scrolls FAST!! PASCAL programs are much faster than the equivalent BASIC program.

Our Pascal editors may be reached for questions at the following address:

3357 W. Kings Ave.
Phoenix, AZ 85023
Please send SASE with your inquiry.