Sunday, April 26, 2020

PLAYDEMO.P

[Table of Contents]

PLAYDEMO.P is a demo program from the Kyan Pascal 2.x Advanced Graphics Toolkit disk.

It can be run by booting the Kyan Pascal 2.x Advanced Graphics Toolkit and choosing PlayDemo from the menu.

To compile this example program, the following include files need to be available to the compiler:


Source Code


#i pmsetup.i
program pmdemo(input,output);
    type
#i pmtypes.i
    var
        b    :pmarray;
        j,dis:integer;
        a    :integer;
        x,y  :array[1..100] of integer;
        i,step,z:real;
#i pmlib.i
    begin
        writeln(chr(125));
        writeln('This is a demo of smooth movement');
        writeln('of players in both horizontal and');
        writeln('vertical directions.');
        writeln;
        writeln('one moment please...');
        (*The b array contains the*)
        (*shape data for the ship.*)
        b[1]:=chr(66);
        b[2]:=chr(129);
        b[3]:=chr(153);
        b[4]:=chr(255);
        b[5]:=chr(255);
        b[6]:=chr(153);
        b[7]:=chr(129);
        b[8]:=chr(66);
        (*Now make a circle divided*)
        (*into 100 parts.          *)
        i:=0;
        j:=1;
        step:=0.062831853;
        while j<51 do begin
            a:=trunc(50*cos(i));
            z:=70*sin(i);

            x[j]:=120+a;
            y[j]:=120-trunc(z);
            x[j+50]:=120-a;
            y[j+50]:=trunc(120+z+0.5);
            i:=i+step;
            j:=j+1;
        end;
        pmstartup;
        (*save VBI vector*)
        pminitialize(1);
        (*set up for hires player*)
        (*missle graphics. Then  *)
        (*clear out the buffer   *)
        clear_pm_buffer(1);
        pmcolor(0,125);
        pmcolor(1,155);
        pmcolor(2,155);
        pmcolor(3,165);
        (*Give the players the *)
        (*colors which we want.*)
        (*Then put the ship in *)
        (*each player at offset*)
        (*120.  The ship is 8  *)
        (*bytes in length.     *)
        putshape(0,120,8,b);
        putshape(1,120,8,b);
        putshape(2,120,8,b);
        putshape(3,120,8,b);
        j:=2;
        a:=0;
        horiz_player_pos(2,120);
        while j<101 do begin
          dis:=y[j-1]-y[j];
          horiz_player_pos(0,x[j]);
          horiz_player_pos(1,255-x[j]);
          horiz_player_pos(3,x[j]);
          roll_player_buffer(0,dis);
          wait;
          (*The wait command will    *)
          (*suspend execution until  *)
          (*the vertical blank.  This*)
          (*will result in the roll  *)
          (*instruction executing.   *)
          roll_player_buffer(2,dis);
          (*This roll command will be*)
          (*executed in the next VBI *)
          (*which will occur before  *)
          (*the next roll instruction*)
          (*since arithmetic is time *)
          (*consuming.               *)
          j:=j+1;
          if (a<5) and (j=101) then
              begin
              a:=a+1;
              j:=2;
          end;
          (*The if makes the ship    *)
          (*circle 4 times the stop. *)
        end;
        (*This next command turns off*)
        (*PM graphics and revectors  *)
        (*the VBI to it's default.   *)
        pminitialize(0);
end.

Sample Run



Friday, April 24, 2020

BDEMO.P

[Table of Contents]
BDEMO.ATR Disk Image

BDEMO.P is an example program on Kyan Pascal 2.x Utility Disk 2. It has been compiled to BDEMO which is also on the same disk. The BDEMO.ATR disk image has had all the files needed to compile and run BDEMO copied to it.

If you want to run BDEMO from Kyan Pascal 2.x Utility Disk 2, you will need to copy the LIB file to that disk.

If you want to compile BDEMO yourself, you will need to have the following include files on the same disk as BDEMO.P:


Source Code


program bdemo(input,output);
    type
       pathstring=array[1..20] of char;
    var
       fyle:pathstring;
       r,amount,place:integer;
#i adddev.i
#i bsave.i
#i bload.i
    begin
       fyle:='memory.imm          ';
       place:=-17407;
       amount:=1024;
       r:=bsave(fyle,amount,place);
       writeln(r);
       writeln('This line is going to disappear');
       r:=bload(fyle,amount,place);
       writeln(r);
end.

Sample Run



FILL.P

[Table of Contents]
FILL.ATR Disk Image

I believe that the Kyan Pascal FILL procedure that resides on the Kyan Pascal 2.x Utility Disk 1 should work similar to the Atari BASIC Fill Example on page 54 of the Atari BASIC Reference Manual, but I haven't gotten it to work just yet.

The FILL.ATR has a PEEKPOKE.I include file that can be used for PEEKing and POKEing address.

What's on the Disk?


The disk image includes the various Atari DOS 2.5 files, Kyan Pascal Include files, Kyan Pascal Run-time library, and ...

GRAPHICS.I - Include file
PLOT.I - Include file
DRAWTO.I - Include file
FILL.I - Include file
POSITION.I - Include file
PEEKPOKE.I - Include file
FILL.P - Source code file
P.OUT - Kyan Pascal intermediate file
FILL - Executable file
FILL.BAS - Atari BASIC Fill Example

Example Code


(* FILL.P *)
(* Kyan Pascal / Atari 8-bit *)

#A
_ORIGIN EQU $4000
#

Program Fill(Input,Output);

#i Graphics.i
#i Plot.i
#i Drawto.i
#i Fill.i
#i Position.i
#i Peekpoke.i

Procedure Use_Graphics;
Begin
#A
   LDA #<_origin
   STA $6A
#
End;

Procedure Use_Text;
Begin
#A
   LDA #$C0
   STA $6A
#
End; (* of the Use_Text procedure *)

Begin
   (* Initialize graphics *)
   Use_Graphics;

   (* GR 5 *)
   Graphics(5);

   (* Draw a shape *)
   Plot(70,35,3);
   Drawto(50,10,3);
   Drawto(30,10,3);
   
   Writeln('Press <RETURN> To Fill');
      Readln;

   (* Fill area *)
   Position(10,35);
   Poke(765,3);
   Fill(10,35,3);

   Writeln('Press <RETURN> To Exit');
      Readln;

   (* Back to text mode *)
   Use_Text;
   Graphics(0)
End.

Thursday, April 23, 2020

CSET.P

[Table of Contents]
CSET.ATR Disk Image

CSET.P is a short sample program that shows how to use the CSET.I include file procedures. The four procedures in the include file manipulate the Atari's character set.

Source Code


(* CSET.P *)
(* Kyan Pascal 2.x / Atari 8-bit *)

Program CSET(Input, Output);
Var
   i : Integer;

#I CSET.I

(* Main Program *)
Begin
   write(chr(125)); (* Clear screen *)

   for i := 0 to 26 do
      write(chr(i));

   writeln;
   writeln;

   write('Press <RETURN> to Invert Set');
      readln;
   Invert_Char_Set;

   write('Press <RETURN> for Normal Set');
      readln;
   Normal_Char_Set;

   write('Press <RETURN> for International set');
      readln;
   Intl_Char_Set;

   write('Press <RETURN> for Atari set');
      readln;

   Atari_Char_Set;

End.



Sample Run










PRINT.P

[Table of Contents]

PRINT.P is a sample program that resides on the Kyan Pascal 2.x Disk 2. It is a sample program / utility used to output text files from disk to the printer, with the option of including line numbers. Here the sample run uses the utility to print itself.

Source Code


PROGRAM Print;
TYPE
    String15 = ARRAY[1..15] OF Char;
VAR
  n,x: Integer;
    c: Char;
    f,printer: Text;
    s: String15;

BEGIN
 x:=0;
 n:=1;
 Write('FILENAME? '); Readln(s);
 Write('Line numbers(Y/N)? '); Readln(c);
Rewrite(Printer,'P:');
 Reset(f,s);
WHILE NOT EOF(f) DO
 BEGIN
  IF (c='Y') AND (x=0) THEN
   BEGIN
    x:=1;
    IF n<10 THEN Write(printer,'000',n,'  ');
    IF (n>9) AND (n<100) THEN Write(printer,'00',n,'  ');
    IF (n>99) AND (n<1000) THEN Write(printer,'0',n,'  ');
    IF n>999 THEN Write(printer,n,'  ')
 END;
 IF EOLn(f) THEN
            BEGIN
             x:=0;
             n:=n+1;
             Writeln(printer)
            END
    ELSE Write(printer,f^);
 Get(f);
END;
END.

Sample Run (Printer Output)


0001  PROGRAM Print;
0002  TYPE
0003      String15 = ARRAY[1..15] OF Char;
0004  VAR
0005    n,x: Integer;
0006      c: Char;
0007      f,printer: Text;
0008      s: String15;
0009  
0010  BEGIN
0011   x:=0;
0012   n:=1;
0013   Write('FILENAME? '); Readln(s);
0014   Write('Line numbers(Y/N)? '); Readln(c);
0015  Rewrite(Printer,'P:');
0016   Reset(f,s);
0017  WHILE NOT EOF(f) DO
0018   BEGIN
0019    IF (c='Y') AND (x=0) THEN
0020     BEGIN
0021      x:=1;
0022      IF n<10 THEN Write(printer,'000',n,'  ');
0023      IF (n>9) AND (n<100) THEN Write(printer,'00',n,'  ');
0024      IF (n>99) AND (n<1000) THEN Write(printer,'0',n,'  ');
0025      IF n>999 THEN Write(printer,n,'  ')
0026   END;
0027   IF EOLn(f) THEN
0028              BEGIN
0029               x:=0;
0030               n:=n+1;
0031               Writeln(printer)
0032              END
0033      ELSE Write(printer,f^);
0034   Get(f);

0035  END;

PRIME.P

[Table of Contents]

PRIME.P is a sample program that resides on the Kyan Pascal 2.x Disk 2. I assume that this sample program is mostly used in bench marking tests, to compare how fast different Pascal versions (for example, the Atari Pascal Language System PRIMES), different languages, and/or different platforms run.

Source Code


PROGRAM Prime;
CONST Size=8190;
VAR
  f: ARRAY[0..Size] OF Boolean;
  i,k,prime,count: Integer;
BEGIN
  Writeln('1 iteration');
  count:=0;
  FOR i:=0 TO Size DO f[i]:=TRUE;
  FOR i:=0 TO Size DO
   IF f[i] THEN BEGIN
    prime:=i+i+3;
    (* writeln(prime); *)
    k:=i+prime;
    WHILE K<=Size DO BEGIN
      f[k]:=FALSE;
      k:=k+prime;
    END;
    count:=count+1
   END;
  Writeln(count,' primes')
END.

Sample Run




Tuesday, April 21, 2020

CALC.P

[Table of Contents]
CALC.ATR Disk Image

CALC.P is from the SCOPE section of the Kyan Pascal 2.x User's Manaul.

What's on the disk?


The disk image includes the various Atari DOS 2.5 files, Kyan Pascal Include files, Kyan Pascal Run-time library, and ...

CALC.P - Source code file
P.OUT - Kyan Pascal intermediate file
CALC - Executable file

Source Code


(* CALC.P *)
(* Kyan Pascal / Atari 8-bit *)

PROGRAM CALC(Input,Output);

VAR
   Pick : Char;
   X, Y, Answer : Real;

   PROCEDURE Choice(Select : Char; N1, N2 : Real);

      FUNCTION Sum(Val1, Val2 : Real) : Real;
         BEGIN
            Sum := Val1 + Val2
         END;

      FUNCTION Average(Val1, Val2 : Real) : Real;
         CONST
            D = 2;
         BEGIN
            Average := (Val1 + Val2) / d
         END;

      FUNCTION Difference(Val1, Val2 : Real) : Real;
         BEGIN
            Difference := Val1 - Val2
         END;

   BEGIN (* of Procedure containing nested Functions *)
      CASE Select OF
         'S' : Answer := Sum(N1,N2);
         'A' : Answer := Average(N1,N2);
         'D' : Answer := Difference(N1,N2);
      END (* of CASE *)
   END; (* of PROCEDURE *)

BEGIN (* of Program *)
   Writeln;
   Writeln;
   Writeln('This program computes the Sum,');
   Writeln('Average, or Difference of two numbers.');
   Writeln;
   Writeln;
   Writeln('Enter S, A, or D: .');
      Readln(Pick);
   Writeln;
   Write('Enter the first number: ');
      Readln(X);
   Writeln;
   Write('Enter the second number: ');
      Readln(Y);
   Writeln;
   Choice(Pick, X, Y); (* Call Choice Procedure *)
   Writeln;
   If Pick = 'S' Then
      Writeln('The sum is ', Answer:5:2);
   If Pick = 'A' Then
      Writeln('The Average is ', Answer:5:2);
   If Pick = 'D' Then
      Writeln('The Difference is ', Answer:5:2)
END.

Sample Run