Jump to content
IGNORED

Mad Pascal


Recommended Posts

  • 2 weeks later...


Mad Pascal Compiler version 1.6.1 [2019/08/07] for 6502
Compiling pacmad.pas
d:\!Delphi\PAS6502\lib\graph.inc (672) Warning: lo/hi(dword/qword) returns the upper/lower word/dword
d:\!Delphi\PAS6502\lib\graph.inc (673) Warning: lo/hi(dword/qword) returns the upper/lower word/dword
interrupts.inc (1) Note: Use assembler block instead pascal
interrupts.inc (13) Note: Use assembler block instead pascal
interrupts.inc (26) Note: Use assembler block instead pascal
interrupts.inc (43) Note: Use assembler block instead pascal
interrupts.inc (64) Note: Use assembler block instead pascal
interrupts.inc (76) Note: Use assembler block instead pascal
interrupts.inc (89) Note: Use assembler block instead pascal
interrupts.inc (111) Note: Use assembler block instead pascal
dlist.inc (2) Note: Local const 'DL_NULL' not used
1599 lines compiled, 5.80 sec, 22861 tokens, 1667 idents, 374 blocks, 10 types
2 warning(s) issued
9 note(s) issued

d:\!Delphi\PAS6502\test\games\PacMad>mads pacmad.a65 -x -i:..\..\..\base\
ZPFREE: $0000..$007F ; $00D8..$00FF
$R RCDATA  $C400..$C7FF 'assets/pacmad8solid.fnt'
$R RCDATA  $C800..$CBFF 'assets/NC5.FNT'
$R RCASM   $8000..$8437 'assets/pacmad.logo'
LEVELS SIZE: $10A7
LEVELS:  $8438..$94DF
$R RCASM   $8438..$94DE 'assets/levels.asm'
STRINGS SIZE: $0120
STRINGS : $B000..$B120
$R RCASM   $B000..$B11F 'assets/strings.asm'
$R RMTPLAY $B1E0..$B817 'assets/rmt.feat'
$R RMT     $B900..$BFB5 'assets/pacmad_strip_mono.rmt'
SYSTEM: $23E8..$2567
GRAPH: $2568..$2569
DATAMATRIX: $256A..$27DF
MYPMG: $27E0..$28A5
RMT: $28A6..$2982
CODE: $2000..$6F05
DATA: $6F06..$746C
Writing listing file...
Writing object file...
26963 lines of source assembled in 12 pass
32616 bytes written to the object file

Link to comment
Share on other sites

  • 3 weeks later...

Hi there, I'm tryin to port source from ACTION! to MP.

 

var colcrs: byte absolute $55;
var savmsc: ^byte absolute $58; << FAIL: tsystem.pas (9,23) Error: not possible in this case

 

How can I declare a pointer to a byte array (here screen) that is located in a fixed location (here $58)?

 

- Peter.

Link to comment
Share on other sites

54 minutes ago, bocianu said:

var vidmem: array [0..0] of byte absolute $a000;

 

this array is located at fixed location.

 

btw: savsmc is already declared in atari unit.  

Thanks for the hint, you example is not what I need because I need the pointer at a fixed address. But the Atari Units solves it:
savmsc: word absolute $58;        // (2) adres pamieci obrazu

Link to comment
Share on other sites

Hey.
Thanks to the developers of MAD Pascal!
I found out that there are problems in working with pointers.
For example:

program TestProgram;
var
  PA, PB: ^Word;
begin
  PA: = Pointer($1111);
  PB: = @PA; // Error: PB = PA {=$1111}, but should be PB = Addr(PA)
end.


Similarly, the problem is when calling a procedure with a var parameter pointer:

 

program TestProgram;
  procedure Tst(var P:Pointer);
  var
    TP: Pointer;
  begin
    TP:= Pointer(Word(P) + $123);
    //Error: TP <> ($1111+$0123) since in this case "Word (P)" is executed as "Word (P ^)"

    P:= TP;
  end;
var
  PA, PB: Pointer;
  PC: Pointer;
begin
  PA:= Pointer($1111);
  PC:= PA;
  Tst(PC);
  //Error: PC = PA {$1111}, but should be PC = $1234

  PB:= PC;
end.


If the type "pointer" is replaced by a "word", then the program runs correctly.

 

Link to comment
Share on other sites

On 7/28/2015 at 10:17 PM, funkheld said:
 
Hello, good evening.
 
what is missing are file commands (GET, PUT ...)
 
 

 

greeting

 

Hi,

 

the are there, they are called BlockRead/BlockWrite. You can use them like BGET/BPUT in Turbobasic.

var file f;
begin
  Assign(result, 'D1:EXAMPLE.TXT');
  Reset(f,1);
  Blockread(f,target,length);
  if (IOResult>=127) then beep;
  Close(f);

 

there are more detailed example in the MP download.

On 7/28/2015 at 10:24 PM, funkheld said:

hello tebe.

 

what this: ???

fpc -Mtp filename.pas

 

 

 

greeting

That is how you compile the same on a PC using "FPC.EXE". On the Atari use mp.exe and then mads.exe on the result of mp.exe.

Link to comment
Share on other sites

@tebe: Mad Pascal is REALLY cool. I love static type checking, boolean and enums. My ACTION! project is now converted and basically runs. 

 

I have added support for Mad Pascal in WUDSN to the todo list ?

Can you please add the orignal File/line/code in the ".a65" file as comment?

Otherwise debugging is really hard.

 

  • Like 2
Link to comment
Share on other sites

Thanks, I knew they exist, but I didn't have the time to look at them yet. My focus is getting my game to work.

 

I just tried to implement a minimal MP syntax highlighting that can be integrated in my WUDSN IDE using the new Eclipse 4.7 generic editor.  And I am very statisfied with the (not yet 100% of course) result from just around 80 lines of Java code.

 

 

 

MP.png

  • Like 2
Link to comment
Share on other sites

On 8/29/2019 at 10:17 AM, pvaWatson said:

 


program TestProgram;
  procedure Tst(var P:Pointer);
  var
    TP: Pointer;
  begin
    TP:= Pointer(Word(P) + $123);
    //Error: TP <> ($1111+$0123) since in this case "Word (P)" is executed as "Word (P ^)"

    P:= TP;
  end;
var
  PA, PB: Pointer;
  PC: Pointer;
begin
  PA:= Pointer($1111);
  PC:= PA;
  Tst(PC);
  //Error: PC = PA {$1111}, but should be PC = $1234

  PB:= PC;
end.


If the type "pointer" is replaced by a "word", then the program runs correctly.

 

fixed

 

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

 

Link to comment
Share on other sites

Rectangle Overlap, Which Side Was Hit

 

use joy in port 0

 


uses crt, joystick, fastgraph;

type

TColision = (left=1, right, top, bottom);

 TTile = record
     width, height, centerX, centerY: byte;
    end;    
    
var 
 A,B: TTile;
 
 Hero: record x,y, _x, _y: byte end;
 
 hit: byte;
 
 
function CollisionTile(var B: TTile): byte;
var w,h: byte;
    dx,dy,wy,hx: smallint;
begin

Result:=0;
 
w := (A.width + B.width) shr 1;
h := (A.height + B.height) shr 1;
dx := A.centerX - B.centerX;
dy := A.centerY - B.centerY;

if (abs(dx) <= w) and (abs(dy) <= h) then begin

    (* collision! *)
    wy := w * dy;
    hx := h * dx;

    if (wy > hx) then begin
    
        if (wy > -hx) then
            (* collision at the bottom *)
        Result := ord(bottom)
        else
            (* on the left *)
        Result := ord(left);
        
    end else 
        if (wy > -hx) then
            (* on the right *)
        Result := ord(right)
        else
            (* at the top *)
        Result := ord(top);

end; 
  
end; 
 
 
procedure DrawTile(var a: TTile; color: Byte);
var px,py,x,y,w,h: byte;
begin
 
  w:=A.width;
  h:=A.height;
 
  x:=w shr 1;
  y:=h shr 1;
  
  px:=A.CenterX - x;
  py:=A.CenterY - y;
 
  SetColor(color);
  
  Rectangle(px,py,px+w,py+h); 
 
end;


procedure HeroMovement;
begin

 case joy_1 of
   joy_left: dec(Hero.X);
  joy_right: inc(Hero.X);
     joy_up: dec(Hero.Y);
   joy_down: inc(Hero.Y); 
 end;
 
 if (Hero.x <> Hero._x) or (Hero.y <> Hero._y) then begin
 
  DrawTile(A, 0);
  
  A.CenterX := Hero.X;
  A.CenterY := Hero.Y;
  
  DrawTile(A, 1);

  Hero._x := Hero.x; 
  Hero._y := Hero.y; 
  
  DrawTile(B, 3);
 
 end;
 
end;


begin

InitGraph(7);

A.width:=8; 
A.height:=8;
A.CenterX:=84;
A.CenterY:=53;

Hero.X:=A.CenterX;
Hero.Y:=A.CenterY;

B.width:=32; 
B.height:=16;
B.CenterX:=93;
B.CenterY:=45;


repeat

 HeroMovement;
 
 hit:=CollisionTile(B);
 
 case hit of
    ord(left): writeln('left');
   ord(right): writeln('right');
     ord(top): writeln('top');
  ord(bottom): writeln('bottom');
 else
  writeln;
 end;

until false;

end.

rect_overlap.pas

  • Like 2
Link to comment
Share on other sites

On 9/15/2019 at 1:43 AM, tebe said:

I successfully compiled and run mentioned game code with new version of Mads and Mad Pascal.

You already have compiled version of Mad Assembler on github, but I compiled it also anyway, with Free Pascal 3.0.4.

 

Thank you!

 

mads209.zip

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...

 

Hello.
The MADPascal compiler removes unused procedures without checking their use in assembler inserts.
For example:

program TestProject;

  procedure TestProc;
  var
    a: Byte;
  begin
    a:= 10;
  end;

begin
//  TestProc;
  asm
  {
    jsr  TestProc
  };
end.

mp generates note: "Note: Local proc 'TESTPROC' not used"

and mads generates error: "TestProject.a65 (185) ERROR: Undeclared label TESTPROC (BANK=0)",

but if you uncomment the call to the TestProc procedure, then mads compiler will be successful. Is there any way around this problem?

 

And another question: will the procedural type be implemented in MADPascal in the future?

Link to comment
Share on other sites

3 hours ago, pvaWatson said:

 

Hello.
The MADPascal compiler removes unused procedures without checking their use in assembler inserts.
For example:


program TestProject;

  procedure TestProc;
  var
    a: Byte;
  begin
    a:= 10;
  end;

begin
//  TestProc;
  asm
  {
    jsr  TestProc
  };
end.

mp generates note: "Note: Local proc 'TESTPROC' not used"

and mads generates error: "TestProject.a65 (185) ERROR: Undeclared label TESTPROC (BANK=0)",

but if you uncomment the call to the TestProc procedure, then mads compiler will be successful. Is there any way around this problem?

 

And another question: will the procedural type be implemented in MADPascal in the future?

It is a known and documented limitation, as Mad Pascal doesn't interpret the contents of the asm {} blocks at all.

I guess a circumvention would be to place an unreachable call to the procedure somewhere, so it is not removed by the pascal compiler.

 

 

Link to comment
Share on other sites

12 hours ago, baktra said:

It is a known and documented limitation, as Mad Pascal doesn't interpret the contents of the asm {} blocks at all.

I guess a circumvention would be to place an unreachable call to the procedure somewhere, so it is not removed by the pascal compiler. 

 

 

Ok! Thanks for the answer.
I will do so. I thought that maybe there is a more beautiful solution, but if not, then no. ;-)

Link to comment
Share on other sites

  • 1 month later...

http://mads.atari8.info/

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

Mad Pascal 1.6.2

- new unit EFAST, accelerated E:
- SYSTEM: function Copy(var S: String; Index: Byte; Count: Byte): String;
- SYSTEM: Palette, HPalette
- added support for 'array [0..x] of ^RECORD'
- new optimization for conditional blocks
- add PChar, https://www.freepascal.org/docs-html/rtl/system/pchar.html
- new switch -define:symbol
- new switch -ipath:includepath

example: plasma from Rascal Tutorials

plasma_2.obx plasma_2.pas

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

  • 1 month later...
On 8/26/2017 at 10:17 PM, bocianu said:

I think there is no problem using memory above A000.

You can take a look into sources of PacMad,

I'm switching off OS (procedure SystemOff), taking over vblank, and using all memory above A000 (except D000-D800).

 

In MadPascal examples, system is also switched off in 'pasintro'.

There is a little problem when BASIC is not switched off when starting a game. I am talking about additional code which would do that automatically, by not needing to press Option key.

Link to comment
Share on other sites

I took bocianu's example on using special graphics mode 10++ (resolution 80x48, 9 colors) and modified it to show graphics similar to graphics mode 7 screen (pixel 2 scanlines high), but with more colors. It uses gr10pp unit and the most important procedure is Gr10Init, where you can set graphics mode 10 screen in different ways. I set it to 2 blank mode lines on top, 2 scanline mode line with effective resolution of 80x102.

I designed a set of alphanumeric and other characters, which can be used on the screen. These are collections of PutPixel, Line and Rectangle combinations.

 

nyan10p7.png.4a39ff9e207c20bb0564e5e01cc49e9f.png

 

nyan10p7.zip

nyan10p7.xex

Edited by Gury
  • Like 2
  • Haha 1
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...