Jump to content

Photo

Mad Pascal


208 replies to this topic

#1 tebe OFFLINE  

tebe

    Dragonstomper

  • 610 posts
  • Location:Poznań - Poland

Posted Sun Jul 26, 2015 11:49 AM

http://mads.atari8.info

 

Mad Pascal 1.4.6

 

Based on Sub-Pascal 32-bit real mode compiler for 80386+ processors v. 2.0 by Vasiliy Tereshkov, 2009

 

Mad-Pascal is a subset of Pascal programming language. It includes:
 
1.  If, Case, For, While, Repeat statements.
2.  Compound statements.
3.  Label, Goto statements.
4.  Records.
5.  Arithmetic and boolean operators.
6.  Procedures and functions with up to 8 parameters. Returned value of a function is assigned to a predefined Result variable.
7.  Static local variables.
8.  Six primitive data types: Cardinal, Word, Char, Boolean, Pointer, Real (fixed-point), Single (fixed-point). All types except the Real/Single type are compatible. Pointers are dereferenced as pointers to Word.
9.  One-dimensional and Two-dimensional arrays (with zero lower bound) of any primitive type. Arrays are treated as pointers to their origins (like in C) and can be passed to subroutines as parameters.
10. Predefined type string [N] which is equivalent to array [0..N] of Char.
11. Separate program modules.
12. Recursion.
 
It does not include:
 
1.  Text file operations.
2.  Expanded RAM support.

Attached Files


Edited by tebe, Sun Mar 12, 2017 6:43 AM.


#2 as... OFFLINE  

as...

    Space Invader

  • 20 posts
  • Location:Warszawa /Poland

Posted Sun Jul 26, 2015 12:09 PM

oh my good!!!



#3 mani OFFLINE  

mani

    Space Invader

  • 14 posts
  • Location:London, UK.

Posted Sun Jul 26, 2015 5:45 PM

:-o



#4 Gury OFFLINE  

Gury

    Stargunner

  • 1,185 posts

Posted Mon Jul 27, 2015 2:33 AM

That's MEGA fascinating!!! Tebe, you are absolutely amazing, making even Turbo Pascal-like cross compiler available to Atari developers. I tried it and it works great. I like the way you mirrored the structure of Turbo Pascal units: crt, graph, math, system. It moves me to those nostalgic days of programming in TP in DOS :). Firstly I thought you used Free Pascal as the base compiler core but I read your information about Sub-Pascal. Just great! And congratulations for winning the Głuchołazy 2015 intro contest!!!

 

Gury



#5 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Mon Jul 27, 2015 3:22 AM

use graph.pas and crt.pas

begin
 
 InitGraph(8);
 
 SetColor(1);
 
 Circle(250,60,90);
 
 SetBkColor($86);
 
 MoveTo(10,10);
 LineTo(300,15);
 
 Circle(110,160,150);
 
 LineTo(22,190);
 
 SetBkColor($c6);
 
 Line(5,85, 311,190);
 
 repeat until keypressed;
 
end.


#6 Gury OFFLINE  

Gury

    Stargunner

  • 1,185 posts

Posted Mon Jul 27, 2015 10:50 AM

Hi, I prepared some simple examples demonstrating P/M graphics with Mad-Pascal. Code is simplified for clarity and readibility. I think there is still a bug in my code because of little garbage on-screen. Anyway, here it is.

 

First example with simple static player 0 on-screen and second example, which shows how to move player 0 with joystick. Source code is included in this post. Just invoke command prompt window and type pm or pm2 (and press enter key :))

 

pmgdemo.png  pmgdemo2.png

//
// P/M Graphics demonstration
// by Bostjan Gorisek 2015
//
// Developed in Mad-Pascal by Tebe / Madteam
//

const
  max = 10;  // Number of player 0 data values

var
	p0Data : array [0..max] of byte;
  px0 : byte;  // Sprite X position
  py0 : byte;  // Sprite Y position
  pmgMem : Word;
  i : Byte;
begin
  // Set graphics mode and playfield colors
  InitGraph(0);
  Poke(710, 0); Poke(712, 0);
  Poke(752, 1);  // Cursor off
  
  writeln(eol,'P/M Graphics demonstration');
  writeln(eol,'by Bostjan Gorisek 2015',eol);
  
  // Initialize P/M graphics
  Poke(53277, 0);
  pmgMem := Peek(106) - 4;
  Poke(54279, pmgMem);
  pmgMem := pmgMem * 256;
  Poke(559, 46);
  
  // Set player 0 coordinates
  px0 := 120; py0 := 60;
  
  // Draw player 0 image
  p0Data[0] := 60;
  p0Data[1] := 66;
  p0Data[2] := 129;
  p0Data[3] := 165;
  p0Data[4] := 129;
  p0Data[5] := 153;
  p0Data[6] := 129;
  p0Data[7] := 165;
  p0Data[8] := 153;
  p0Data[9] := 66;
  p0Data[10] := 60;
  
  // Clear player 0 memory
  fillchar(pointer(pmgMem+512), 128, 0);
  
  // Draw player 0

  // Vertical position of player 0
  //Move(pointer(p0Data), pointer(pmgMem+512+py0), 10);
  for i := 0 to max do begin
    Poke(pmgMem+512+py0+i, p0Data[i]);
  end;
  
  Poke(53277,3);  // Turn on P/M graphics  
  Poke(53256,1);  // Size of player 0 (double size)
  Poke(704,183);  // Player 0 color        
  Poke(53248,px0);  // Horizontal position of player 0
    
  repeat until keypressed;

  // Reset P/M graphics
  InitGraph(0);
  Poke(53277, 0);
end.

//
// P/M Graphics demonstration 2
// by Bostjan Gorisek 2015
//
// Developed in Mad-Pascal by Tebe / Madteam
//

const
  _max = 7;     // Number of player 0 data values
  _speed = 40;  // Player 0 movement speed

var
	p0Data : array [0.._max] of byte;
  px0 : byte;  // Sprite X position
  py0 : byte;  // Sprite Y position
  pmgMem : Word;
  i : Byte;
begin
  // Set graphics mode and playfield colors
  InitGraph(8);
  Poke(710, 122); Poke(712, 130);
  Poke(709, 64);
  Poke(752, 1);  // Cursor off

  // Set playfield graphics
  SetColor(1);
  MoveTo(10,10); LineTo(300,10);
  Line(30,50,100,50); Line(100,50,100,130);
  Line(30,130,100,130); Line(30,130,30,50);
  Circle(250,60,20);  

  // Initialize P/M graphics
  Poke(53277, 0);
  pmgMem := Peek(106) - 4;
  Poke(54279, pmgMem);    
  pmgMem := pmgMem * 256;
  Poke(559, 46);

  // Set player 0 coordinates
  px0 := 120; py0 := 60;

  // Draw player 0 image
  p0Data[0] := 48;
  p0Data[1] := 120;
  p0Data[2] := 252;
  p0Data[3] := 48;
  p0Data[4] := 48;
  p0Data[5] := 48;
  p0Data[6] := 48;
  p0Data[7] := 48;

  // Clear player 0 memory
  fillchar(pointer(pmgMem+512), 128, 0);

  // Draw player 0

  // Vertical position of player 0
  //Move(pointer(p0Data), pointer(pmgMem+512+py0), _max);
  for i := 0 to _max do begin
    Poke(pmgMem+512+py0+i, p0Data[i]);
  end;

  Poke(53277,3);  // Turn on P/M graphics  
  Poke(53256,0);  // Size of player 0 (normal size)
  Poke(704,44);  // Player 0 color
  Poke(53248,px0);  // Horizontal position of player 0

  repeat
    // Move player 0 left  
    if Peek(632)=11 then begin
      Dec(px0);
      if px0 < 45 then px0 := 45;
      Poke(53248,px0);
      Delay(_speed);

    // Move player 0 right
    end else if Peek(632)=7 then begin
      Inc(px0);
      if px0 > 203 then px0 := 203;
      Poke(53248,px0);
      Delay(_speed);

    // Move player 0 up
    end else if Peek(632)=14 then begin
      Dec(py0);
      if py0 < 16 then py0 := 16;      
      Poke(pmgMem+512+py0-1, 0);
      Poke(pmgMem+512+py0+_max+1, 0);
      for i := 0 to _max do begin
        Poke(pmgMem+512+py0+i, p0Data[i]);
      end;
      Delay(_speed-8);

    // Move player 0 down
    end else if Peek(632)=13 then begin
      Inc(py0);
      if py0 > 97 then py0 := 97;
      Poke(pmgMem+512+py0-1, 0);
      Poke(pmgMem+512+py0+_max+1, 0);
      for i := 0 to _max do begin
        Poke(pmgMem+512+py0+i, p0Data[i]);
      end;
      Delay(_speed-8);
    end;
  until keypressed;

  // Reset P/M graphics
  InitGraph(0);
  Poke(53277, 0);
end.

Attached Files



#7 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Mon Jul 27, 2015 11:54 AM

hello, what happens next if I have the "pmgdemo.obx".
as it is a xex?
 
thanks


#8 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Mon Jul 27, 2015 11:57 AM

yes, OBX = XEX



#9 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Mon Jul 27, 2015 12:04 PM

hello, thanks....ist ok.

 

Pascal loops wonderful .  :)  :)  :)

 

 

greeting.



#10 fujidude OFFLINE  

fujidude

    River Patroller

  • 4,309 posts
  • Location:United States of America

Posted Mon Jul 27, 2015 1:42 PM

hello, what happens next if I have the "pmgdemo.obx".
as it is a xex?

 

 

.OBX is to .OBJ as .XEX is to .EXE.  Although the Atari doesn't care what extension you use, usually .OBJ (and presumably then .OBX), is usually object code that is not yet in a final executable application form.  For example for languages which first compile object code, then link the object code to a run time or library (which is itself plain object code) that is needed to make a full working program, it would be best practice to choose an .OBJ extension.  Once you have various object code components linked together in a complete executable though, you would use .EXE.  The .COM extension is typically for .EXE files that are external commands for a CLI driven DOS.

 

I think the main (only?) reason some people are using .OBX or .XEX on Atari now days, is to make it easier to distinguish such files from DOS/WIN files with the extensions of .EXE or.COM. 

 

It can get confusing!  Especially when the extensions are used somewhat willy nilly without care as to differences of meaning.  The computer itself cares little what you use though.  The differences are for people's benefit of understanding.


Edited by fujidude, Mon Jul 27, 2015 1:45 PM.


#11 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Mon Jul 27, 2015 1:43 PM

loops

if INDEX is BYTE

 for i:=0 to 255 do      // infinite loop
 
 for i:=15 downto 0 do   // infinite loop
 
 while i<=255 do inc(i); // infinite loop

REPEAT UNTIL, is safe
 i:=0;
 repeat
 inc(i);
 until i=0;  // 256x

Edited by tebe, Mon Jul 27, 2015 1:45 PM.


#12 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Mon Jul 27, 2015 2:14 PM

please where is the starting address from the OBX in atari800?
 
greeting


#13 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Mon Jul 27, 2015 3:28 PM

$ff, $ff, lo(address), hi(address)



#14 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Mon Jul 27, 2015 4:24 PM

Gury, pmgdemo.pas

  // Draw player 0
  // Vertical position of player 0
  Move(@p0Data, pointer(pmgMem+512+py0), max+1);

@ address

 

p.s.

pmgMem = $BC00, screen mem = $BC40 -> garbage


Edited by tebe, Mon Jul 27, 2015 4:24 PM.


#15 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 3:01 AM

Hello, this "pasintro" runs with graphics and sound also wonderful on the "MIST"
 
best regards

Attached Thumbnails

  • DSCN3182.JPG
  • DSCN3183.JPG


#16 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 3:07 AM

Hi good afternoon.
I wish for this Pascal please times a Command Reference.
it's a wonderful pascal.
 
Pointer, Byte, Word, Char .........
 
greeting


#17 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 5:49 AM

hello, good day.

 

as you can for Poke and Peek also use pointers in Pascal?
 
thank you.
 
greeting


#18 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 7:18 AM

ASM with MAD Pascal ok.
 
 
greeting

Edited by funkheld, Wed Jul 29, 2015 9:24 AM.


#19 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 9:04 AM

how can you please fill an array of pointers?
 
there is an error message.
 
thank you
var
dlist: array [0..110] of byte;
dl_idx : word;
  
begin
dl_idx= @dlist;
 
Poke(dl_idx+0,255);
Poke(dl_idx+1,23);
DPoke(dl_idx+2,476);
Poke(dl_idx+4,76);
 
repeat
until keypressed;
 
end.

Edited by funkheld, Tue Jul 28, 2015 9:05 AM.


#20 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Tue Jul 28, 2015 10:15 AM

var
dlist: array [0..110] of byte;
dl_idx : word;
  
begin
dl_idx:= word(@dlist);
 
Poke(dl_idx+0,255);
Poke(dl_idx+1,23);
DPoke(dl_idx+2,476);
Poke(dl_idx+4,76);


#21 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 12:02 PM

i have an own dplist designed with the image address: 36960
this is dplist stored here: dlist: array [0..110] of byte;
here the dplist describes: procedure initdlist (a: word);
dl_idx is taken for poke / peek.
 
then follows the poken in the screen and the graphics commands are through this
command set to the new dplist: dpoke ($58,36960);
 
this order is important:
init graph (7);
dpoke (560,word(dlist));
dpoke ($58,36960);
 
greeting
 
var
dlist: array [0..110] of byte;
  dl_idx: word;
    
procedure DLByte(a: byte);
begin
  Poke(dl_idx, a);
  inc(dl_idx);
end;
 
procedure DLWord(a: word);
begin
  DPoke(dl_idx, a);
  inc(dl_idx, 2);
end;  
 
procedure InitDlist(a: word);
begin
  DLByte($70); DLByte($70); DLByte($70); DLByte($4d);
  DLWord(36960);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);DLByte($0d);
  DLByte($41); DLWord(a);
end;
 
begin
  dl_idx:= word(@dlist);
  
  InitDlist(word(@dlist));
  
  InitGraph(7);   
  DPoke(560,word(@dlist));
  DPoke($58,36960);
  
  SetColor(1);
  MoveTo(5,5);
  LineTo(159,95);
  
  SetColor(2);
  MoveTo(159,0);
  LineTo(0,95);
  
  SetColor(3);
  Circle(80,50,45);
 
  Poke(36960,129);
  Poke(36961,255);
  Poke(36962,129);
 
 repeat
 until keypressed;
end.
 

Attached Thumbnails

  • Bild2.jpg


#22 ascrnet OFFLINE  

ascrnet

    Chopper Commander

  • 140 posts

Posted Tue Jul 28, 2015 12:28 PM

I really liked the idea, I hope that in the future contains everything you need to develop a game or application quickly as serious a framework.

Here I made a small test example.

// Show colors
// AsCrNet

var
	num : byte; 

begin
	ClrScr;
	TextColor(15);	
	GotoXY(14,9);
	write('Show colors');
	repeat 
		num := Random(255);
		TextBackground(num);
		Delay(900);
	until keypressed;
end.

greetings

Attached Thumbnails

  • colors.png

Edited by ascrnet, Tue Jul 28, 2015 12:29 PM.


#23 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 610 posts
  • Location:Poznań - Poland

Posted Tue Jul 28, 2015 2:14 PM

fpc -Mtp filename.pas

// Show colors
// AsCrNet
 
uses crt;
 
var
num : byte; 
 
begin
ClrScr;
TextColor(15); 
repeat 
            num := Random(255);
            TextBackground(num);
 
            GotoXY(14,9);
            write('Show colors');
 
            Delay(900);
until keypressed;
end.

run application on PC and XE/XL :)


Edited by tebe, Tue Jul 28, 2015 2:17 PM.


#24 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 2:17 PM

Hello, good evening.
what is missing are file commands (GET, PUT ...)
 
greeting

Edited by funkheld, Mon Aug 3, 2015 6:25 AM.


#25 funkheld OFFLINE  

funkheld

    Chopper Commander

  • 182 posts

Posted Tue Jul 28, 2015 2:24 PM

hello tebe.

 

what this: ???

fpc -Mtp filename.pas

 

 

 

greeting






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users