Jump to content
IGNORED

Mad Pascal


Recommended Posts

http://mads.atari8.info

 

Mad Pascal 1.5.1

1.5.1
- new switches -CODE:$address, -DATA:$address -STACK:$address, -ZPAGE:$address
- SYSTEM unit: RandomF (Result as Single), VAL (Integer, Single)
- GRAPH, FASTGRAPH unit: Bar, Bar3D, GetX, GetY, MoveRel, FloodFill
- MATH unit: RandomRange, RandomRangeF, RandG (gaussian distributed random number)
- CRT unit: SOUND (similar to Atari BASIC SOUND)
- VBXE unit: TVBXEMemoryStream
- new warning 'Comparison might be always true/false due to range of constant and expression'
- resources RCASM, CMCPLAY, MPTPLAY, added ability to load under ROM
- internal ANTIC-a code by '~'

 txt0: string = 'Atari'~;      // ANTIC code
 txt1: string = 'Spectrum'*~;  // ANTIC code + invers
  • Like 8
Link to comment
Share on other sites

  • 2 weeks later...

http://mads.atari8.info

 

Mad Pascal 1.5.2

 

- new data type FLOAT (SINGLE IEEE 754)
- SYSTEM unti: FileSize (SDX)
- SYSTEM unit: EXP:Single, LN:Single, LN:Real, EXP:Real (high accurate)
- SYSUTILS unit: AnsiUpperCase, ExtractFileExt
- TYPES unit: Bounds, CenterPoint, EqualRect, InflateRect, IntersectRect, IsRectEmpty, NormalizeRect, OffsetRect, Point, PointsEqual, PtInRect, PtInEllipse, Rect, RectWidth, RectHeight, Size, UnionRect
- IMAGE unit: LoadMIC, LoadPIC, LoadBMP, LoadPCX, LoadGIF
- VIMAGE unit: LoadVBMP, LoadVPCX, LoadVGIF
- GRAPH, FASTGRAPH unit: SetClipRect, ClipLine, FillRect(TRect), Rectangle(TRect)
p.s.

SDX 'RUNEXT.CFG'

BMP:GIF:PCX,CAR:X.COM,A:\PROGRAMS\VIMAGE.COM %
Natural Logarithm

function Ln(x: Float): Float; overload;
//----------------------------------------------------------------------------------------------
// Ln returns the natural logarithm of the Real parameter X. X must be positive.
// https://www.codeproject.com/Tips/311714/Natural-Logarithms-and-Exponent
//----------------------------------------------------------------------------------------------
var N, P, K, L, R, A, E: Float;
begin
		E := 2.71828182845905;
		P := x;
		N := 0;

	if x>Float(0) then begin

                // This speeds up the convergence by calculating the integral
		while(P >= E) do begin
			P := P / E;
			N := N + 1;
		end;

                N := N + (P / E);
		P := x;

		while true do begin
			A := N;
			K := N - 1;
			L := P / Exp(K);
			R := K * E;
			N := (L + R) / E;

			if A-N < Float(0.01) then Break;
		end;

	end;

		Result := N;
end;

post-4486-0-17155900-1507474421_thumb.png

vimage.zip

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

  • 3 weeks later...

When i compiled a jgp_engine.pas it generated an unoptimized code :(

; optimize OK (..\jgp\jgp_engine.pas), line = 41

	lda A
	and #$7F
	sta STACKORIGIN+10
	asl STACKORIGIN+10
	lda STACKORIGIN+10
	sta TMP

; optimize OK (..\jgp\jgp_engine.pas), line = 42

	lda TMP
	ora #$01
	sta W+1
	lda TMP
	sta W

Can You do a optimization pass on the whole generated mads assembly ?

Maybe this can be of any use to You :

http://hitmen.c02.at/files/cc65/opt65.c

Keep up the good work and i hope that mads and mad pascal can produce the fastest code on the atari 65 xe in the world :)

Link to comment
Share on other sites

Not sure this has been covered yet. How hard would it to use Mads Pascal for other 6502 based platforms. Atari 5200, 7800, Lynx. Commodore 64, Apple II?

 

I know with "uses" it loads in modules and one for the 8-bit. It may not be difficult to make something up to address 5200 and 7800 memory. Unless Mads Pascal is Atari 8-bit OS dependent.

Link to comment
Share on other sites

It is not, unless you use modules like crt that are A8 oriented.

To mitigate this you just need to replace them with appropriate equivalents (by writing them). Additionally, you need to modify mads settings to output binary in a desired format.

Link to comment
Share on other sites

  • 1 month later...

Thanks Tebe for better generation of code for 6502 :D Baby steps in great direction of faster code !!!

I don't see whole assembly optimization because of 'sta TMP' then 'lda TMP' yet :)

Why ?

var tmp:byte;
    hwscroll:^byte absoulute $d404;

hwscroll^:=tmp;


generate :

mwa HWSCROLL bp2
ldy #$00
lda TMP
sta (bp2),y

when :

var tmp:byte;
    hwscroll:byte absolute $d404;

hwscroll:=tmp;

gives :

mva TMP HWSCROLL 

I care more about faster code on Atari XL than compatibility of mad pascal with x86. This is silly for me and it's slows down generated code :)

Yes i can code in mads but i like pascal :)

Do You want me to stop nitpicking? :D

Link to comment
Share on other sites

Estece, pointer is slower

 

this examples not comparable

 

var hscroll: ^byte;

begin
 hscroll:=pointer($d404);

 hscroll^:=tmp;

 hscroll:=pointer($d405);

 hscroll^:=tmp+1;
end;
var hscroll: byte absolute $d404;

begin
 hscroll:=pointer($d405);

Incompatible types: got "POINTER" expected "BYTE"
Link to comment
Share on other sites

I understand what i typed.

It's too hard for You to write better.Your example is absolute different case that not use absolute keyword :)

I will stop nitpicking and code in mads like You do when You wrote mod player example.

Mod example will not compile on x86.

Good luck with maintaining mad pascal to people that will care about it :D

Link to comment
Share on other sites

  • 2 months later...
  • 1 month later...

I am looking to use Mad Pascal to program some of the less elaborate game ideas that had been pitched toward me by Video 61 and others. (like Zoo Keeper and Klax.) The type of games I had been compressing to execute from a 16K cartridge with sections decompressed to RAM using Deflate/Inflate. That would cut down on development time and is something I can teach to other team members. One issue is that some of these guys use Apple Macintosh and Mads Assembler and Mad Pascal seem to only run in DOS mode, Command Prompt, or BAT batch file. I would need to set something up for them.

Link to comment
Share on other sites

One issue is that some of these guys use Apple Macintosh and Mads Assembler and Mad Pascal seem to only run in DOS mode, Command Prompt, or BAT batch file. I would need to set something up for them.

Well, the compilers aren't GUI apps: they're CLI tools. If you read the documentation for either (MADS assembler or MAD Pascal), you'll see you can download the source for both and build them using the Free Pascal Compiler on whichever target platform you like. I believe there are even pre-compiled versions of MADS available for macOS (courtesy of Jac!).

  • Like 1
Link to comment
Share on other sites

Well, the compilers aren't GUI apps: they're CLI tools. If you read the documentation for either (MADS assembler or MAD Pascal), you'll see you can download the source for both and build them using the Free Pascal Compiler on whichever target platform you like. I believe there are even pre-compiled versions of MADS available for macOS (courtesy of Jac!).

 

Yes, I've compiled it for macOS. I think I used brew to install fpc (Freepascal) and then used it to compile MADS and MAD Pascal. If they can program, they should be able to install it.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

How much free memory is there available for coding ?

 

For instance, in cc65 is like 30kb.

 

Cheers,

 

Devwebcl

 

$D8..$FF

$0500..$06FF

$2000...$BFFF

 

TMemoryStream is available (PORTB), unit OBJECTS

THighMemStream is available (CPU65816 - 16MB), unit HIGHMEM

TVBXEMemoryStream is available (VBXE - 512 KB), unit VBXE

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

  • 2 weeks later...

 

Yes, I've compiled it for macOS. I think I used brew to install fpc (Freepascal) and then used it to compile MADS and MAD Pascal. If they can program, they should be able to install it.

 

Super interesting topic for me coming from a school Turbo Pascal, C , inline assembler 8 bit PC background (and Fortran,Cobol,RPG, bweurk ...)

 

Noob question, I've installed Freepascal via Macports on both my Intel OS X 10.10 Macbook and my PPC OS X 10.5.8 Powerbook and compiled mads and mad pascal successfully.

 

However on both when I try to compile the PasIntro.pas with Mad Pascal 1.5.5 I get the following error :

 

Mad Pascal Compiler version 1.5.5 [2018/04/29] for 6502

Compiling PasIntro/pasintro.pas

(0,0) Error: Identifier, number or expression expected but 'unknown token' found

Am I missing something , should I've compiled Mad Pascal patched with a diff or what am I missing ?
Link to comment
Share on other sites

Hi!

 

However on both when I try to compile the PasIntro.pas with Mad Pascal 1.5.5 I get the following error :

 

Mad Pascal Compiler version 1.5.5 [2018/04/29] for 6502

 

Compiling PasIntro/pasintro.pas

(0,0) Error: Identifier, number or expression expected but 'unknown token' found

 

Am I missing something , should I've compiled Mad Pascal patched with a diff or what am I missing ?

 

-

.

 

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.

  • Like 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...