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



No comments:

Post a Comment