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

Thursday, April 30, 2020

PMG32BIT.P

[Table of Contents]
PMG32BIT.ATR Disk Image



This is an example program from page 322 of the classic book, Your Atari Computer, on how to use all four of Atari's player missile graphics players as one 32-bit object. I ported the code to Kyan Pascal. The original program just moved the object from left to right. I added vertical movement as well.

Its interesting to note that both the original edition of the book and the updated XL Series edition have a bug in the BASIC program. It is missing one datum in line 45. To fix the BASIC program, just add a 0 to the end of the line.

For vertical movement, the first and last byte of each player's image bitmap needs to be a zero so as to "clean up" the trailing byte when the players are moved through memory. As such, each player's bitmap was increased by two bytes, and a zero was added at the start and at the end.

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

  •   P.OUT - Pascal intermediate file
  •   PMG32BIT - Executable file 
  •   PMG32BIT.P - Pascal Source
  •   PMG32BIT.BAS - Original BASIC program
  •   PMLIB.I - Kyan Pascal Include file
  •   PMSETUP.I- Kyan Pascal Include file
  •   PMTYPES.I - Kyan Pascal Include file

Source Code


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

(* Port of a BASIC Language PMG Example       *)
(* from the book 'Your Atari Computer'        *)
(* Uses four players to make one large object *)

(* Set up some assembly langauge equates *)
#i pmsetup.i

program pmg32bit(input,output);

type

(* Creates an array type for  pmg bit maps *)
#i pmtypes.i

var
   p0, p1, p2, p3 : pmarray;
   d, p, t, w     : Integer;

(* Imports a bunch of pmg routines *)
#i pmlib.i

(* Main Program *)
begin

   write(chr(125)); (* Clear screen *)

   writeln('This is a sample program of using');
   writeln('Atari''s Player Missile Graphics');
   writeln;
   writeln('It uses four players as one object');

   (* Player 0 bit map *)
   P0[1]:=CHR(0);
   p0[2]:=chr(0);
   p0[3]:=chr(0);
   p0[4]:=chr(0);
   p0[5]:=chr(0);
   p0[6]:=chr(3);
   p0[7]:=chr(15);
   p0[8]:=chr(119);
   p0[9]:=chr(254);
   p0[10]:=chr(255);
   p0[11]:=chr(63);
   p0[12]:=chr(31);
   p0[13]:=chr(7);
   p0[14]:=chr(4);
   p0[15]:=chr(14);
   p0[16]:=chr(14);
   p0[17]:=chr(0);

   (* Player 1 bit map *)
   P1[1]:=chr(0); 
   p1[2]:=chr(1);
   p1[3]:=chr(2);
   p1[4]:=chr(2);
   p1[5]:=chr(31);
   p1[6]:=chr(240);
   p1[7]:=chr(255);
   p1[8]:=chr(255);
   p1[9]:=chr(255);
   p1[10]:=chr(239);
   p1[11]:=chr(254);
   p1[12]:=chr(255);
   p1[13]:=chr(255);
   p1[14]:=chr(240);
   p1[15]:=chr(15);
   p1[16]:=chr(0);
   p1[17]:=chr(0);

   (* Player 2 bit map *)
   p2[1]:=chr(0);
   p2[2]:=chr(128);
   p2[3]:=chr(64);
   p2[4]:=chr(64);
   p2[5]:=chr(248);
   p2[6]:=chr(15);
   p2[7]:=chr(255);
   p2[8]:=chr(255);
   p2[9]:=chr(255);
   p2[10]:=chr(247);
   p2[11]:=chr(127);
   p2[12]:=chr(255);
   p2[13]:=chr(255);
   p2[14]:=chr(15);
   p2[15]:=chr(240);
   p2[16]:=chr(0);
   p2[17]:=chr(0);

   (* Player 3 bit map *)
   p3[1]:=chr(0);
   p3[2]:=chr(0);
   p3[3]:=chr(0);
   p3[4]:=chr(0);
   p3[5]:=chr(0);
   p3[6]:=chr(192);
   p3[7]:=chr(240);
   p3[8]:=chr(236);
   p3[9]:=chr(127);
   p3[10]:=chr(255);
   p3[11]:=chr(252);
   p3[12]:=chr(248);
   p3[13]:=chr(224);
   p3[14]:=chr(32);
   p3[15]:=chr(112);
   p3[16]:=chr(0);
   p3[17]:=chr(0);

   pmstartup;

   (* Turn on pmg *)
   pminitialize(1);

   (* Clear shape buffer *)
   clear_pm_buffer(1);

   for p:=0 to 3 do
   begin
      (* Set player width *)
      player_width(p,0);
      (* Set player color *)
      pmcolor(p,188);
   end;

   (* Plr#,Offset,Shape Size,Array *)
   (* Offset is the vertical pos *)
   putshape(0,140,17,p0);
   putshape(1,140,17,p1);
   putshape(2,140,17,p2);
   putshape(3,140,17,p3);

(* Move players across screen *)
for t:=0 to 1 do
begin  
 for d:=0 to 228 do
 begin
  for p:=0 to 3 do
  begin
   (* 8 for single width *)
   (* 16 for double width *)
   horiz_player_pos(p,d+(8*p));
   for w:=1 to 200 do; (* slow down *)
  end;
 end;
end;

(* Clear the PMG ribbon *)
clear_pm_buffer(1);

(* Move players to middle of screen *)
for p:= 0 to 3 do
   horiz_player_pos(p,100+(8*p));

(* Move players vertically *)
for t:=0 to 1 do 
begin
   for d:=240 downto 0 do
   begin
      putshape(0,d,17,p0);
      putshape(1,d,17,p1);
      putshape(2,d,17,p2);
      putshape(3,d,17,p3);
      for w:=1 to 400 do; (* slow down *)
   end;
end;  

   (* Turn off pmg *)
   pminitialize(0);

end.

Sample Run



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