Free Pascal target Atari

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

Post Reply
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

just recompiled the tools again from fresh sources. Just in case somebody needs them.
You do not have the required permissions to view the files attached to this post.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

Log attached.

Thanks.
You do not have the required permissions to view the files attached to this post.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

Something is wrong with your unit path. It only searches in ..../units/atari/rtl, but not in other subdirectories of units/atari
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

Yes, it looks like it searches it twice.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

PeterS wrote: Thu Jan 27, 2022 5:15 pm Yes, it looks like it searches it twice.

PS
I can't fit an absolute path for the units into the ttp dialogue field.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I moved fpc to a short path so I could give an absolute path to the units but it did the same thing.
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

What if you specify "-Fuunits/atari/*" ? In the log you specified "-Fuunits/*". I don't think it will search the whole dir structure in this case, just the level where "*" is specified. I'm kinda surprised it even finds the rtl directory. :)

It even tells you in the log near the start:

Code: Select all

00020000:Interpreting option "-Fuunits/*"
00008000:Path "./units/*/" not found
If you need shorter paths, you can try to get rid of the "atari" part of the path, and move your units to "units/rtl", "units/tosunits", etc. Then you can use "-Fuunits/*".

But there is a better way: put all the options and path you need into an "fpc.cfg" config file next to your program. This file should be just a list of options, one option per line, which then aren't limited (see screenshot). Then you can just do "ppc68k myprogram.pas" and the config file will be read and the options from there will be used. BTW, the paths can be both relative, or absolute, whatever fits better. In this example I used absolute paths.
FPC with config file
So on major platforms, FPC's installer would write you a quite extensive config file and put it to some default location (/etc or similar on most Un*xes, but current directory works for "custom" config files), then the compiler would always find it. But of course on Atari we don't have an installer (yet), so to simplify command lines, you probably want to write a config file for yourself. As the above small example shows, it's not difficult. I just rarely use this feature, and prefer to specify all options on the command line instead, it's sometimes less confusing for compiler development. But it might fit your use case a lot better indeed.

Maybe this helps to settle your path woes?
You do not have the required permissions to view the files attached to this post.
Last edited by ChainQ on Thu Jan 27, 2022 7:07 pm, edited 2 times in total.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

Duplicate again, sorry. :(
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I had a relative path to units/atari before, now using an absolute path it has built the .prg :-)

I had to shorten the FP installation path down to f:\f and the app name to hi.pas, in order to fit it all into the dialogue with an absolute path for the units.

-l -veiw -Xs -O2 -FDbin -Fu/f/f/units/atari/* ..\..\hi.pas
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Thu Jan 27, 2022 7:47 pm I had a relative path to units/atari before, now using an absolute path it has built the .prg :-)
Well, yeah, it might have worked now for the test case, but to avoid a mess on your disk, and for hopefully upcoming bigger projects, I'd still recommend the config file approach. :)
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I created a fcp.cfg file (one option per line) and was able to compile a few test .pas

-l
-view
-Xs
-O2
-FDbin
-Fu/f/fpascal/units/atari/*


A picture paints a thousand words.
Free Pascal.jpg
This is indeed cool.

I will try to explore what works on the Atari and what doesn't by building a few of my old Pure Pascal apps and modifying to suit.

A big thank you to ChainQ, Thorsten and all those who work on Free Pascal.
You do not have the required permissions to view the files attached to this post.
User avatar
mfro
Atari God
Atari God
Posts: 1098
Joined: Thu Aug 02, 2012 10:33 am
Location: SW Germany

Re: Free Pascal target Atari

Post by mfro »

Congratulations!
(A very nice example for successful collaboration)
User avatar
jfl
Atari Super Hero
Atari Super Hero
Posts: 921
Joined: Tue Jul 18, 2006 10:55 pm
Location: Liège, Belgium
Contact:

Re: Free Pascal target Atari

Post by jfl »

I don't know anything about Free Pascal but it is awesome to see this kind of development on this platform. Very cool indeed. Congratulations to all involved.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

With a few changes I was able to build and run my console calendar application.

The binary is a lot larger than the Pure Pascal one so I tried to strip the binary but the file format is rejected. Does FP use its own version of strip ?

Then I got ambitious and tried building ObjectGEM. It did better than I thought but hit issues with definitions of K_LSHIFT and K_RSHIFT.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

What strip binary are you using? FP generates plain tos executables (not mint ones) so the strip binary from mint does not work. There is a tool "cstrip" in the mintbin archive that should still work, though. Using the "-Xs" switch when compiling should also work.

Edit: great to here that you are working on ObjectGEM. If you have success, next thing would be to try Texel ;)
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I just tried the mint strip. I had used the -Xs option but the ttp was 3x the size of the Pure Pascal one so I thought it might be debug tables. I just tried cstrip but it says there is no symbol table. Perhaps it is just the extra size of the libraries.

The FP tosunits might be missing the NKCC keyboard conversion stuff. I only know it because I added it to Highwire from CFLib.

FP was built on TurboPascal and Pure Pascal was as well. It would be very nice to get FP units to the same level as PP so the apps can be built. It might need more knowledge of the AES/VDI than I have.

While writing GEMiCal I spent a lot of time writing calculations for Julian Date, epoch, date conversions and other low level stuff, now I see they are all in FP so it would be nice to be able to build it with FP.
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Sat Jan 29, 2022 6:16 pm I just tried the mint strip. I had used the -Xs option but the ttp was 3x the size of the Pure Pascal one so I thought it might be debug tables. I just tried cstrip but it says there is no symbol table. Perhaps it is just the extra size of the libraries.
It usually is. The advanced features and platform independence (FPC's slogan is 'Write once, compile anywhere') comes with quite some extra weight and internal abstractions, when it comes to the default libraries. These allowed a relatively easy port to Atari, and many other platforms, but they come with a price. This might indeed be a problem when targeting low-end machines for sure, but there are ways to address this if it really matters, that the executable is not 50K but 150K. (Or not 5K but 25K, you get the idea.)

About existing PurePascal libraries - I don't know if they came with source, or only as a binary. If they came with source, maybe one can try to build them with FPC. If something doesn't build, we can try to figure out if the compiler can be made compatible.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

This is the FP build of my console calendar app.

Run it with the path to a folder that has an ics file.

e.g
bash# ./calndr.ttp ./
You do not have the required permissions to view the files attached to this post.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

ChainQ wrote: Sun Jan 30, 2022 12:58 pm The advanced features and platform independence (FPC's slogan is 'Write once, compile anywhere') comes with quite some extra weight and internal abstractions, when it comes to the default libraries.
Its still acceptable i think. The hello world compiles to ~25k. A similar C-progam using mintlib would be ~100k (mintlib cannot use smart-linking, however every function is defined in a separate sourecfile, which has the same effect). Its done for the same reason: easy porting of unix tools.

If there is some way to omit codepages that aren't relevant for Atari, i think you can even reduce that size a bit.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

As far as I know the source for the Pure Pascal units is not available. It was distributed by Application Systems Heidelberg but they don't have the sources. It was written by Pure Software GmbH in about 1992



ObjectGEM:

Adding a couple of constants helps:

K_LSHIFT = $0200;
K_RSHIFT = $0100;

These should possible be added to tosunits/src/aes.pas

The next issues are type definitions, here are the errors and the relevant lines of code highlighted with >>

00008000:Searching file u:/usr/src/ogembeta.fp/otypes.pas... found
00004000:Adding dependency: OTYPES depends on GEMDOS
10004000:otypes.pas(68,1) Parsing interface of unit OTypes
10000002:otypes.pas(816,26) Error: Identifier not found "AESTreePtr"
10000002:otypes.pas(816,36) Error: Error in type definition

>>PTree = AESTreePtr;

10000002:otypes.pas(817,26) Error: Identifier not found "AESOBJECTPtr"
10000002:otypes.pas(817,38) Error: Error in type definition

>>PObj = AESOBJECTPtr;

10000002:otypes.pas(820,26) Error: Identifier not found "ARRAY_8"
10000002:otypes.pas(820,33) Error: Error in type definition

>>Pipearray = ARRAY_8;

10000002:otypes.pas(827,29) Error: Identifier not found "ARRAY_4"
10000002:otypes.pas(827,36) Error: Error in type definition

GRECT = record
case integer of
0: (g_x,g_y,g_w,g_h : integer);
1: (X,Y,W,H,X1,Y1,X2,Y2: integer);
>> 2: (A1,A2 : ARRAY_4)
end;

10000002:otypes.pas(894,9) Error: Illegal expression

TToolbarDescr = record
Indx,
Size: integer;
>> Tree: PTree
end;

10000002:otypes.pas(1006,18) Error: Illegal expression

TWndClass = record
Style : longint;
hCursor : HCursor;
hbrBackground: HBrush;
MenuTree,
>> ToolbarTree : PTree;
lpszClassName: PString
end;

10000002:otypes.pas(1102,28) Error: Identifier not found "ARRAY_3"
10000002:otypes.pas(1102,35) Error: Error in type definition

TRGB = record
case boolean of
>> false: (RGB : ARRAY_3);
true: (Red,Green,Blue: integer)
end;

10000002:otypes.pas(1115,19) Error: Identifier not found "AESPBPtr"
10000002:otypes.pas(1115,27) Error: Error in type definition

TOLGAObjectInfo = record
Filename : PChar;
>> ClientGEMPB : AESPBPtr;
ClientData,
ServerData : longint;
CBLock,
CBCount : integer;
CBDraw : procedure(d1,d2: pointer; d3,d4,d5: longint; objectinfo: POLGAObjectInfo; outScreen,outHandle,outDevID: integer; Size,Clip: PGRECT);
CBUnembed : procedure(d1,d2: pointer; d3,d4,d5: longint; objectinfo: POLGAObjectInfo);
CBXDraw : procedure(d1,d2: pointer; d3,d4,d5: longint; objectinfo: POLGAObjectInfo; outScreen,outHandle,outDevID: integer; Size,Clip: PGRECT; Width_mm1000, Height_mm1000, Scale: longint);
cbColorTable : POLGAColorTable;
cbClientID,
cbServerID : integer;
CBIEActivate : procedure(d1,d2: pointer; d3,d4,d5: longint; objectinfo: POLGAObjectInfo);
CBIEDeactivate: procedure(d1,d2: pointer; d3,d4,d5: longint; objectinfo: POLGAObjectInfo);
end;

10000002:otypes.pas(1158,11) Error: Illegal expression

TEventData = record
>> Pipe : Pipearray;
mX,
mY,
BStat,
KStat,
Key,
Clicks: integer
end;

10000002:otypes.pas(1170,17) Error: Identifier not found "RSHDR"
10000002:otypes.pas(1170,22) Error: Error in type definition

TRsFile = record
case boolean of
>> false: (rsh: RSHDR);
true: (rsd: array [0..65535] of byte)
end;

10000001:otypes.pas(1194,1) Fatal: There were 17 errors compiling module, stopping
User avatar
ChainQ
Atari maniac
Atari maniac
Posts: 80
Joined: Sat Jan 21, 2017 9:35 am
Location: 1 AU, EU, DE/HU
Contact:

Re: Free Pascal target Atari

Post by ChainQ »

PeterS wrote: Sun Jan 30, 2022 1:36 pm The next issues are type definitions, here are the errors and the relevant lines of code highlighted with >>
This is very helpful, thanks.

I've been wondering, do you think it would be better to add like a "purepascal compatibility unit" to FPC, or just have these types added to default aes/etc units?

For example, we already have AESObjectPtr, but it's called PAESObject, because that's more like "modern" Object Pascal naming style. On Amiga, we have some sort of compatibility unit for PCQ Pascal, so all the types and helper functions that are required for PCQ compatibility are in a unit named "pcq". When one needs to compile code that was originally written for PCQ, the only thing they need to do is include unit "pcq" to the uses line. I wonder if that's a solution which could work here too, so create a "purepas" unit, or these types are so generic across Atari Pascal compilers that it's better to just add them anyway directly into the interface units.

Edit: note that there might be other small changes one need to do for the original units, including adding the right {$MODE} directive for the compiler, or specifying {$PACKRECORDS 2}, for word alignment inside the structures/records, etc.
Free Pascal Compiler for m68k - an Amiga fan outside his comfort zone
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

Hi,

Interesting idea.

Personally I don't have a problem modifying my apps or even ObjectGEM to work with FreePascal, it's easy enough to keep separate copies of ObjectGEM for PP and FP. I all ready changed AESOBJECTPtr to PAESOBJECT to see if it was accepted.

Others might disagree and prefer the idea of a separate purepas ppu.

I don't think there are many apps written with PP and ObjectGEM, but the Texel spreadsheet is one of the better ones.
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

You don't have to (or should not) keep duplicate sources. Both PurePascal and FPC support {$IFDEF ...} So you could do something like

Code: Select all

{$IFDEF FPC}
{$i fpc_purepascal.inc}
{$ENDIF}
Then define the missing/different definitions in fpc_purepascal.inc.

OTOH, all those types in tosunits are already Atari specific, so it might not hurt to just change the AES units to eg declare both AESObjectPtr and PAESObject.
PeterS
Atari Super Hero
Atari Super Hero
Posts: 601
Joined: Fri Nov 09, 2007 1:53 pm
Location: England, GB

Re: Free Pascal target Atari

Post by PeterS »

I can see the case for keeping the FP code clean and consistent so maybe add a purepas ppu with those inconsistent objects in it.

At this moment I'm really happy that anything works. :-)
ThorstenOtto
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2082
Joined: Sun Aug 03, 2014 5:54 pm

Re: Free Pascal target Atari

Post by ThorstenOtto »

BTW, how about usage of gemdos functions? Are they directly called in ObjectGEM/Texel? I think they suffer from a similar problem: PP uses the C-like function names (without gemdos_* prefix), and types like DOSTIMEPtr. Not to mentions that is only a single TOS unit, which includes all bios/xbios/gemdos functions.
Post Reply

Return to “Coding”