Showing posts with label Graphics. Show all posts
Showing posts with label Graphics. Show all posts

Friday, May 1, 2020

CUSTCHAR.P

[Table of Contents]
CUSTCHAR.ATR Disk Image

Kyan Pascal 2.x has a few include files to help you modify the Atari ATASCII character set. Custom character sets can be used for program icons, objects, maps, animations, etc.

Simple Atari BASIC magazine type-in games such as Concentration and Gold Rush! make good use of these custom character sets.

You can use a program such as InstEdit to designed a custom character set. You can use a program such as MapMaker to use a customer character set to design a map.

ATASCII stands for ATARI Standard Code for Information Interchange, or a combination of ATARI ASCII, is the variation on the more general ASCII characters set code.

For reference, here is the standard Atari ATASCII character set:


Characters from 128 to 255 are the inverse video (blue character on white background for example) of characters 0 to 127. Some of the characters don't actually print on the screen by default, but are "control characters". For example, character 125 will clear the screen instead of displaying.

Note that the Atari's standard character set is at address 57344. Kyan Pascal only supports up to a two-byte signed integers (-32,768 to 32,767), so you will need to use a Two’s Complement conversion to reach that address:

  1. Take the number: 57344
  2. Convert the Decimal to Binary: 1110000000000000
  3. Moving from RIGHT to LEFT, flip every bit AFTER the first 1: 0010000000000000
  4. Convert the Binary to Decimal: 8192
  5. Use the negated value: -8192

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 ...


Source Code


PROGRAM CUSTCHAR(INPUT,OUTPUT);
TYPE
#I IOTYPES.I

VAR
   FN    : PATHSTRING;
   ADDR1 : INTEGER;
   ADDR2 : INTEGER;
   I     : INTEGER;

#I LOADCSET.I
#I ACTCSET.I

BEGIN
   (* NORMAL SET AT 57344 *)
   (* OR -8192 IN 2'S COMPLEMENT *)
   ADDR1 := -8192; (* 57344 *)

   (* RANDOM ADDRESS SPACE *)
   ADDR2 := 4000; (* CUSTOM *)

   (* DISPLAY SOME CHARACTERS *)
   WRITELN;
   FOR I := 32 TO 90 DO
      WRITE(CHR(I));
   WRITELN;
   WRITELN;

   WRITE('ENTER FILENAME: ');
   READLN(FN);
   WRITELN;

   (* LOAD FULL SET FROM FILE *)
   LOAD_CHAR_SET(FN,ADDR2);

   (* ACTIVATE CUSTOM SET *)
   ACTIVATE_CHAR_SET(ADDR2);

   READLN;

   (* ACTIVATE NORMAL SET *)
   ACTIVATE_CHAR_SET(ADDR1);

END.


Sample Run




Here are a few more screenshots:


Pascal Program Compiled 


Prompting For Character Set Filename


Custom Character Set Activated


Back To The Standard Character Set

Sunday, April 26, 2020

LINES.PA

[Table of Contents]
LINES.ATR Disk Image



The LINES.PA program was extracted from a German language Kyan Pascal Tutorial disk.

I made the following modifications:

  • Moved all the required files to a single DOS 2.5 disk image
  • Modified LINES.PA to look for include files in the root directory
  • Remove special ATASCII characters from the program listing so it could be listed here
  • Translated the German text to English text
  • Commented out the CHAIN command near the end of the program
  • Compiled with “pc lines.pa -o lines -p"

Source Code


#i graphics.h

program Lines;

#i inline.h

const maxLines     =20;
      maxLines_1   =19;
      maxDrawLines =500;
      maxX         =319;
      maxY         =191;

type  LineDescr  = array [0..3] of integer;

var   Ball,
      Vel,
      max          : LineDescr;
      Lines        : array [0..maxLines] of LineDescr;
      index, t,
      i, new, old  : integer;

#i rnd.f
#i consol.f

#i plot.p
#i drawto.p
#i setcolor.p
#i graphics.p
#i textmode.p

begin
  setcolor(2,0,0);
  setcolor(1,0,7);
  setcolor(4,0,7);
  write(chr(125));
  write('Kyan Pascal Graphics Demo QX-Lines      ');
  write('    (c) 1985, 1986 by TDI Software Inc.');
  writeln('              (c) 1988 by Martin Krischik');
  writeln('This Demo is written in Kyan Pascal');
  writeln;
  writeln;
  writeln('The QX-Lines are drawn with the DRAWTO');
  writeln('command. Quicker execution can be');
  writeln('attained by writing your own Fast Line');
  writeln('routines in Assembly Language, but then');
  writeln('the program will no longer be easily');
  writeln('portable to other computer systems.');
  writeln;
  writeln('Press START to Begin and End.');
  repeat until consol<>7;
  graphics(8+16);
  setcolor(2,0,0);
  setcolor(1,0,7);
  setcolor(4,0,7);
  max[0]:=maxX;
  max[1]:=maxY;
  max[2]:=maxX;
  max[3]:=maxY;
  for i := 0 to 3 do
    begin
      Vel[i] :=rnd(16)-8;
      Ball[i]:=rnd(max[i]-100)+50;
    end;
  new   := 0;
  old   := 0;
  index :=0;
  repeat
    for i := 0 to 3 do
      begin 
        t:=Ball[i]+Vel[i];
        if t>=max[i] then
          begin
            t     :=max[i]*2 - Vel[i] - Ball[i];
            Vel[i]:=-Vel[i];
          end;
        if t<0 then
          begin
            t:=-t;
            Vel[i]:=-Vel[i];
          end;
        Ball[i]:=t;
      end; 
    if (index>=maxLines) then
      begin
        plot  (lines[old,0], lines[old,1],0);
        drawto(lines[old,2], lines[old,3],0);
        old:=(old+1) mod maxLines;
      end;
    Lines[new MOD maxLines]:=Ball;
    new:=(new+1) mod maxLines;
    Plot  (ball[0], ball[1],1);
    drawto(ball[2], ball[3],1);
    index:=index+1;
  until (consol<>7) or (index=MaxDrawLines);
  repeat until consol<>7;
  textmode;
  setcolor(2,0,0);
  setcolor(1,0,7);
  setcolor(4,0,7);
(*  chain('grdemo'); *)
end.



Sample Run



THREEDIM.P

[Table of Contents]



THREEDIM.P is a sample program on the Kyan Pascal 2.x Advanced Graphics Toolkit disk. The program generates the outline of a F-14 Tomcat figher jet and rotates around 3D space.

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

The FIGHTER file must be on the disk to run it as well.

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


Source Code


#A
_ORIGIN EQU $4000
#
program threedimdemo(input,output);
    const
        max = 6;
#i      graph3.con
    var
        x,y,z,t,step:real;
        e,d         :real;
        i,j,color   :integer;
        points,lines:integer;
        rep         :char;
        a,b,c:array[1..44] of real;
        lf,lt:array[1..58] of integer;
        f    :text;
#i      graph3.gbl
#i      hires.i
#i      plotter.i
#i      graph3.i
    begin
    writeln(chr(125));
    writeln('This program rotates an object through');
    writeln('110 degrees in seven views.  While also');
    writeln('zooming and changing elevation of the');
    writeln('object.');
    writeln;
    writeln('Press [RETURN] to start the demo');
    readln;
    writeln;
    writeln('Output to plotter?(Y/N)');
    readln(rep);
#A
    LDA #$40
    STA $6A
#
    graphics(8+16);
    if (rep='y') or (rep='Y') then
        plotter:=true
    else
        plotter:=false;
    if plotter then begin
       set_plotter_port(40,440,0,290);
       set_plotter_window(-5,5,-5,0);
       init_plotter;
       advance;
       frame;
       plotter_color(2);
    end;
    reset(f,'fighter');
    read(f,points);
    for i:= 1 to points do
        read(f,a[i]);
    for i:= 1 to points do
        read(f,b[i]);
    for i:= 1 to points do
        read(f,c[i]);
    read(f,lines);
    for i:= 1 to lines do begin
        read(f,lf[i]);
        read(f,lt[i]);
    end;
    SetWindow(-30,30,-20,20);
    color:=1;
    for i:=3 to 9 do begin
        d:=sin(1.6*i/5);
        e:=cos(1.6*i/5);
        setviewreferencepoint(0,0,0);
        setviewplanenormal(d,e,1-i/10);
        setviewdistance(40-6*i);
        setviewup(0,0,1);
        setprojection(perspective,60*d,60*e,60-6*i);
        makeviewplanexfm;
        clearscreen;
        for j:=1 to lines do begin
            display(move_abs,a[lf[j]],
                             b[lf[j]],
                             c[lf[j]]);
            display(draw_abs,a[lt[j]],
                             b[lt[j]],
                             c[lt[j]]);
        end;
    end;
#A
   LDA #$C0
   STA $6A 
#
graphics(0)
end.

Sample Run



TEST3D.P

[Table of Contents]

TEST3D.P is a sample program on 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 Test3D from the menu.

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

  • graph3.con
  • graph3.gbl
  • HiRes.i
  • plotter.i
  • graph3.i

Source Code


#A
_ORIGIN EQU $4000
#
program threedimdemo(input,output);
    const
        max = 6;
#i d1:graph3.con
    var
        x,y,z,t,step:real;
        i,color     :integer;
        rep         :char;
#i d1:graph3.gbl
#i d1:HiRes.i
#i d1:plotter.i
#i d1:graph3.i
    begin
    writeln(chr(125));
    writeln('This program demos a simultaneous zoom');
    writeln('and roll of an object.');
    writeln;
    writeln('Press [RETURN] to start the demo');
    readln;
    writeln;
    writeln('Output to plotter?(Y/N)');
    readln(rep);
#A
    LDA #$40
    STA $6A
#
    graphics(8+16);
    if (rep='y') or (rep='Y') then
        plotter:=true
    else
        plotter:=false;
    if plotter then begin
       set_plotter_port(40,440,0,290);
       set_plotter_window(-5,5,-5,0);
       init_plotter;
       advance;
       frame;
       plotter_color(2);
    end;
    for i:= 1 to 10 do begin
        color:=1;
        setviewreferencepoint(i/12,i/12,-i/6);
        setviewplanenormal(0,0,-1);
        setviewdistance(2);
        setviewup(i/10-0.1,1,0);
        setprojection(perspective,i/12,i/12,3-i/6);
        makeviewplanexfm;
        clearscreen;
        SetWindow(-5,5,-5,5);
        display(move_abs,0,0,0);
        display(draw_abs,0,0,1);
        display(draw_abs,0,1,1);
        display(draw_abs,1,1,1);
        display(draw_abs,1,0,1);
        display(draw_abs,1,0,0);
        display(draw_abs,1,1,0);
        display(draw_abs,0,1,0);
        display(draw_abs,0,0,0);
        display(move_abs,1,1,1);
        display(draw_abs,1,1,0);
        display(move_abs,0,1,1);
        display(draw_abs,0,1,0);
        display(move_abs,1,0.4,0.4);
        display(draw_rel,0,0,0.2);
        display(draw_rel,0,0.2,0);
        display(draw_rel,0,0,-0.2);
        display(draw_rel,0,-0.2,0);
   end;
#A
   LDA #$C0
   STA $6A
#
   GRAPHICS(0);
end.


Sample Run




Sunday, April 19, 2020

BOUNCE.P

[Table of Contents]
BOUNCE.ATR Disk Image


BOUNCE.P shows how to use the GRAPHICS.I, PLOT.I, and DRAWTO.I include files to get a "ball" bouncing around the screen.

What's one 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
BOUNCE.P - Source code file
P.OUT - Kyan Pascal intermediate file
BOUNCE - Executable file

Source Code


#A
_ORIGIN EQU $4000
#

Program BOUNCE(Input,Output);
Var
   x,y : Integer;
   dx, dy : Integer;
   minX, minY : Integer;
   maxX, maxY : Integer;
   oldX, oldY : Integer;
   i, j : Integer;   

#i Graphics.i
#i Plot.i
#i Drawto.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 3 with text 40x20 *)
   Graphics(3);

   minX := 0;
   minY := 0;
   maxX := 39;
   maxY := 19;
   dx := 1;
   dy := 1;

   (* Draw a border *)
   Plot(minX,minY,1);
   Drawto(maxX,minY,1);
   Drawto(maxX,maxY,1);
   Drawto(minX,maxY,1);
   Drawto(minX,minY,1);   

   (* Start location *)
   x := round(maxX / 2);
   y := round(maxY / 2);

   for i := 1 to 500 do
   begin
   
     plot(x,y,2);
     oldX := x;
     oldY := y;
  
     if (x<=minX+1) or (x>=maxX-1) then
        dx := -dx;

     if (y<=minY+1) or (y>=maxY-1) then
        dy := -dy;
     
     x := x + dx;
     y := y + dy;

     for j := 1 to 1500 do
     begin
        (* slow down *);
     end;

     plot(oldX,oldY,0);

   end;

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


Sample Run