Jump to content

Photo

Mad Pascal


297 replies to this topic

#276 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Wed May 16, 2018 3:14 PM

thx DMSC, you are right, it's BUG



#277 Lastic OFFLINE  

Lastic

    Star Raider

  • 51 posts

Posted Wed May 16, 2018 11:11 PM

Hi!
 
.

The provided mp.pas source has an error, I don't know if the posted EXE cames from the same source. In line 16945, changes the "j" inside the function call to "i", so the line changes from:

j := CompileConstFactor(j, ConstVal, ConstValType);
to read:
j := CompileConstFactor(i, ConstVal, ConstValType);
.

Without this, the program fails depending on the uninitialized value of "j". Also, another error on line 23193, change "i" to "j" on the Error call, the line must read:
         Error(j, 'Unresolved forward declaration of ' + Ident[j].Name);
.

After that, compile with " fpc -MDelphi -Os -Xi -Xs -XX mp-155.fix.pas " to get a working executable.

 

 

 

Thanks a lot for the quick reply, it works now.

 

Now I'm stuck with the workflow on how to create an Atari executable.

 

I compile the Pascal source with mp sourcename.pas, this creates an sourcename.a65 , which is Mads assembler if I'm correct.

 

Then I should create the executable with : mads source name.a65 , correct ?

 

I'll have another look at the mads documentation also.



#278 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Thu May 17, 2018 12:24 AM

mads filename.a65 -x -i:base

 

\base\ is MP folder



#279 Lastic OFFLINE  

Lastic

    Star Raider

  • 51 posts

Posted Thu May 17, 2018 8:53 AM

mads filename.a65 -x -i:base

\base\ is MP folder

 

 

 

Thanks, it kept failing until I figured out that you have to give the absolute filepath to the base folder.

Mads & Mad Pascal is absolutely fabulous, all the examples included will provide me with a lot of learning material , loving it.



#280 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Fri Jun 29, 2018 3:37 AM

Looks like the UNIT parsing is screwed up in MP 1.5.5.

I cannot compile the UNITs anymore.

I even tried to compile the Mad Kingdom cardgui.pas, but that only gets me:

Error: Syntax error, 'BEGIN' expected but 'UNIT' found.



#281 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Fri Jun 29, 2018 4:01 AM

compile UNIT? there has never been such functionality

 

http://wiki.freepascal.org/Unit


Edited by tebe, Fri Jun 29, 2018 7:40 AM.


#282 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Fri Jun 29, 2018 5:09 AM

So, you compile the main program. And MP compiles the necessary units.

Then, why it doesn't recognize the function I have in a unit? See the attached code.

Attached Files

  • Attached File  8ray.zip   979bytes   17 downloads


#283 bocianu OFFLINE  

bocianu

    Space Invader

  • 13 posts
  • Location:Silesia, Poland

Posted Fri Jun 29, 2018 6:46 AM

You need to put headers of public functions into interface section.

 

 

 

Attached Files

  • Attached File  8ray.zip   988bytes   15 downloads


#284 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Fri Jun 29, 2018 7:44 AM

I didn't? Well, the code is two years old. So, I missed something.

Stupid me.



#285 bocianu OFFLINE  

bocianu

    Space Invader

  • 13 posts
  • Location:Silesia, Poland

Posted Fri Jun 29, 2018 8:21 AM

Don't be so self critical, that could work 2 years ago :)

In previous versions of MP, there was no distinction between public and private methods.

It was introduced in version 1.4.5, on my personal request as far as I remember ;)



#286 pirx OFFLINE  

pirx

    Moonsweeper

  • 437 posts
  • Location:Poland

Posted Sat Jun 30, 2018 2:10 AM

Question / idea:

 

asm {} block is fantastic and stuff and I see only one serious drawback of using it on a wider scale - Pascal code can not access asm labels / addresses. It is fully understandable, it is just a foreign body in a Pascal source code.

maybe it could be possible to define variables in Pascal as placeholders for asm variables, so when the code gets to be assembled by MADS, the variables are naturally recognised and used in assembly. No really good example on hand, but I had this idea:

var
dl_addr1 : word; //?????? pointer?


//display list internals
asm{
    .by $41
dl_addr1 .word scr
}

so dl_addr1 could be accessed directly in Mad Pascal.

 

Is such a construct possible already? If not, would it be possible to have it added?



#287 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Mon Jul 2, 2018 1:35 AM

Don't be so self critical, that could work 2 years ago :)

In previous versions of MP, there was no distinction between public and private methods.

It was introduced in version 1.4.5, on my personal request as far as I remember ;)

Yeah, but I could have researched that. Or open my eyes, because the samples have the interface declaration ;-)

BTW, shouldn't the missing interface be flagged as error?



#288 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Mon Jul 2, 2018 1:39 AM

Question / idea:

[...]

 

Is such a construct possible already? If not, would it be possible to have it added?

How about:

var dl_arr1: word asm = $4000; # Adress is optional.

asm {
  sta dl_arr1
}


#289 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Mon Jul 2, 2018 2:24 AM

var dst: word absolute $8000;
 
procedure test; assembler;
var src: word absolute $4000;
asm
{
 lda src
 sta dst
 lda src+1
 sta dst+1
 
 mwa #111 src
};
end;
 
function test2: word; assembler;
asm
{
 lda MAIN.TEST.src
 sta Result
 lda MAIN.TEST.src+1
 sta Result+1
};
end;

begin
 test;
 writeln(test2);
end.

Edited by tebe, Mon Jul 2, 2018 2:37 AM.


#290 pirx OFFLINE  

pirx

    Moonsweeper

  • 437 posts
  • Location:Poland

Posted Mon Jul 2, 2018 3:40 AM

 

How about:

var dl_arr1: word asm = $4000; # Adress is optional.
asm {
  sta dl_arr1
}

 

Yes, this way it is easy, I was rather thinking about being able to DPoke(dl_addr1, scr2); from Pascal so it changes the value inside the asm{} block. 

But I need to analyse TeBe's example, possibly it is what I wanted, just do not understand it on a first glance.



#291 pirx OFFLINE  

pirx

    Moonsweeper

  • 437 posts
  • Location:Poland

Posted Mon Jul 2, 2018 2:13 PM

Hi!

Thanks again for the example, I was not clear enough, but I meant something like in the example below - way to access variables that are defined inside ASM{} block.

The code below compiles, but obviously does not work as MP does not know what "src_mod" is. Proposal: define it like this

var src_mod: word asm_placeholder;

and pass just the label "src_mod" itself without any value to MADS, that would be able to compile it using correct address.

 

I understand it might be impossible, just asking. 

var src_mod: word; //???

procedure test; assembler;
var src: word absolute $4000;
asm
{
src_mod 
    lda #111
    sta src     
};
end;

function test2: word; assembler;
asm
{
 lda MAIN.TEST.src
 sta Result
 lda MAIN.TEST.src+1
 sta Result+1
};
end;

begin
 test;
 writeln(test2);
 Poke(src_mod+1,112);
 writeln(test2);
end.

Edited by pirx, Mon Jul 2, 2018 2:14 PM.


#292 bocianu OFFLINE  

bocianu

    Space Invader

  • 13 posts
  • Location:Silesia, Poland

Posted Mon Jul 2, 2018 4:00 PM

It's possible to access asm labels, but you have to write some kind of 'accessor function' ;)

 

Not very convenient, especialy when you wish to access plenty of labels... but still possible.

function test:byte; assembler;
asm {
mylabel
    lda #123
    sta result
};
end;
 
function mylabel:word; assembler;
asm { mwa #test.mylabel result }; 
end;

begin
    writeln(test); // 123
    poke(mylabel+1, 33);
    writeln(test); // 33 ! ;)
    Readkey;
end.


Edited by bocianu, Mon Jul 2, 2018 4:18 PM.


#293 pirx OFFLINE  

pirx

    Moonsweeper

  • 437 posts
  • Location:Poland

Posted Mon Jul 2, 2018 4:51 PM

ha, nice! Indeed, I was thinking about many labels, as many as lines on the screen in fact ;)



#294 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Tue Jul 3, 2018 12:24 AM

Hi.

 

This doesn't seem to be supported at the moment. Am I correct?

type
  Vector = object
    function add(x, y: Vector): Vector;
  end;

FreePascal uses this syntax for classes:

type
  Vector = Class;
  Vector = Class
    function add(x, y: Vector): Vector;
  end;

Is it possible to implement something like that?


Edited by JoSch, Tue Jul 3, 2018 12:24 AM.


#295 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Fri Jul 13, 2018 11:43 PM

Hi.

 

This doesn't seem to be supported at the moment. Am I correct?

type
  Vector = object
    function add(x, y: Vector): Vector;
  end;

 

yes, you're right



#296 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Fri Jul 13, 2018 11:54 PM

MadPascal 1.5.6

 

http://mads.atari8.info

- SYSUTILS: Click
- SYSTEM: Sqrt(Integer): Single
- MATH: Sign
- added new functionality, function returns result by its name, previously only through the variable RESULT
- adding support for STRING arrays (example /games/tower.pas)
- new directive {$LIBRARYPATH path1;path2;...}
- new library BLIBS
- PASDOC (https://gitlab.com/bocianu/pasdoc)
(* source: CLSN PASCAL            *)
(* This program uses a mutually   *)
(* recursive routine to calculate *)
(* the number PI                  *)
 
uses crt;
 
function a(t: byte): single; forward;
 
function b(n: byte): single;
begin
  if (n=0) then
    b:=1/sqrt(2)
  else
    b:=sqrt(a(n-1)*b(n-1));
end;
 
function a(t:byte): single;
begin
  if (t=0) then
    a:=1
  else
    a:=(a(t-1)+b(t-1))*0.5;
end;
 
function d(n: byte): single;
var
  j: byte;
  s: single;
begin
  s:=0;
 
  for j:=1 to n do
    s:=s+(1 shl (j+1))*(sqr(a(j))-sqr(b(j)));
 
  d:=1-s;
end;
 
function x_pi: single;
const
  level=2;
 
begin
  x_pi:=4*a(level)*b(level)/d(level);
end;
 
begin
  writeln('PI=',x_pi);
 
  repeat until keypressed;
end.

Edited by tebe, Fri Jul 13, 2018 11:55 PM.


#297 JoSch OFFLINE  

JoSch

    Moonsweeper

  • 440 posts
  • Location:Germany

Posted Sat Jul 14, 2018 1:17 AM

 

yes, you're right

Any chance for support?



#298 tebe OFFLINE  

tebe

    Dragonstomper

  • Topic Starter
  • 741 posts
  • Location:Poland

Posted Mon Jul 16, 2018 11:37 AM

MadPascal 1.5.7 is arrived (bugs were slaughtered)

 

 

Any chance for support?

 

maybe in the future






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users