Jump to content
IGNORED

Mad Pascal


Recommended Posts

http://mads.atari8.info

https://github.com/tebe6502/Mad-Pascal/releases

https://github.com/tebe6502/Mad-Pascal

 

https://mads.atari8.info/library/doc/index.html

http://bocianu.atari.pl/blog/blibs

https://github.com/Ripjetski6502/A8MadPascalLibrary

 

Mad Pascal 1.6.9

 

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

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. Primitive data types (All types except the ShortReal/Real type are compatible. Pointers are dereferenced as pointers to Word):

 + Cardinal Word, Byte

 + Integer, SmallInt, ShortInt

 + Char, PChar

 + Boolean

 + Pointer

 + File, Text

 + ShortReal/Real (fixed-point), Single (IEEE-754), Float16 (Half Single)

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.

 

System:

- Atari XE/XL

- Commodore 64 (-t c64)

- Commodore Plus/4 (-t c4p)

- Neo6502 (-t neo)

- Raw (-t raw)

 

PasIntro.zip

 

 

Edited by tebe
update
  • Like 9
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

use graph.pas and crt.pas

 

begin
 
 InitGraph(;
 
 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.
  • Like 1
Link to comment
Share on other sites

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 :))

 

post-7301-0-47233500-1438015561_thumb.png post-7301-0-02551600-1438015578_thumb.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(;
  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-;

    // 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-;
    end;
  until keypressed;

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

pmgdemos.zip

  • Like 2
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.


post-31221-0-82064600-1438106548_thumb.jpg

Link to comment
Share on other sites

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

post-11721-0-35094900-1438108164_thumb.png

Edited by ascrnet
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...