UPDATE: since revision 45802 Free Pascal is not also compatible with X5000 processor, thanks to work by ChainQ. Support for X5000 start with Free Pascal 3.2.2.
Because I got this question already some times, and I do not want to write it again and again, I just make this blog post that I can simple point to at any time 😉
Why my Programs does not work on AmigaOS4 X5000?
The problem is, that FreePascal itself does not know the X5000 CPU, and it seems to be not a normal PowerPC, but needs some special care. I heard something about special alignment problems. I don’t have a X5000, Charlie doesn’t have a X5000 and we do not know whats special about it to fix that issue. Besides, we both are not really using OS4, we both use Classic and MorphOS and I use additionally a big Part AROS (mainly i386 a bit ARM).
As some might notice, long time there was no working AmigaOS4 FreePascal, because I did not have any OS4 capable computer. I used mainly AROS, Charlie used mainly MorphOS and both we used some kind of Amiga68k and that was exactly the work shares we did in FreePascal. Charlie asked and explained some times that there could be an AmigaOS4 port (an older Version was still inside) if someone would step up as Maintainer for it. We didn’t want to do, we had AROS and Amiga68k and MorphOS already. Which is already much to work on. Besides OS4 is a completely different kind of fish (because of the Interfaces).
Then one day this thread came along and if you follow the thread you can see, Charlie decided to make the initial OS4 implementation and someone said, he will step up as maintainer, but sadly this didn’t happen. I’m too much of a FreePascal Amiga guy to let that port in such sorry state and started to implement the rest nevertheless, making me the maintainer for OS4, even I had no interest to be. Of course I’m a big fan, that all four platforms are now supported by FreePascal and due our continuing work on it, they are 99% compatible. (e.g we hid the OS4 Interfaces away, so you do not need to care about that when writing your software)
Recently I bought a AmigaOS4 computer (thanks again to the one sold me that, its working nicely), because in UAE it’s not really usable. But I only use it to test FreePascal, my programs the installer and so on. But for that a some thousands Euro machine would be overkill (and also waste of space). I try to keep the FreePascal AmigaOS4 at least somehow working but not more. In the end the message stays:
If you are interested in Pascal and Amiga(OS4) and want to help with the compiler doing a better job on X5000 (or any other computer as well) you can just do it, it’s open source, send us a patch. If you want to step up as maintainer for AmigaOS4, even better, contact ChainQ/Charlie or me, of course we will happily help. Do not fear, you will not be left alone.
Charlie implemented a Amiga 1.x compatible version of the FreePascal compiler. It’s a little bit harder to write program for 1.x so many features are missing in Workbench 1.x. These machines are usually 7 Mhz and only very little RAM, so cross compiling is highly advised. Of course the Online compiler would be a good starting point for basic tests.
Updated Online Amiga FPC Compiler again with the latest CRT unit and also tried a bunch of console based games using CRT units, all work more or less (some need some adjustments in the code) some of them are even single file pascal source files, so can be used in the online compiler.
Someone might ask how the crt is going, and how useful this is already. I want to answer it with a little screenshot:
That is a nice little rouge-like game called DeadCold, written in FreePascal for the console. As you can see it runs and the picture looks right. (it’s not perfectly right, but somehow usable). And because a little video tells much more about how this game runs here is also a little video about it:
There are some drawing problems, especially on the messages and sometimes some of the map disappear but not bad I would say. There are also some messages about removing critter failed… but that seems some error in the game code.
The colors is badly hacked for now, and only works for AROS, I’m not sure if I can upload that this status to the official repository, I will work on it a bit more.
On the currently running 36. Chaos Communication Congress 2019 (36C3) there was a little lightning talk (5 min talks) about FreePascal where also the Amiga and Atari support got mentioned (all supported platforms).
Most Tutorials about Pascal use the CRT unit in a very early Lesson. They use it only for ReadKey() to wait for a key at end of Program. It would be of course the same to just use a ReadLn and wait for an Enter.
I tried already to implement CRT before using an old implementation, but exactly this ReadKey implementation does not work at all when KingCON or other console replacements is used.
Now I got a hint in MorphOS Forum (always a very good Source for Implementation hints) to set the console in RAW: mode (using SetMode()) and then just read from the console the pressed keys. If console in raw mode, one can read cursor keys and F keys from the console.
I tried that and on MorphOS and AmigaOS3 it works well, Read blocks until a Button is pressed. But AROS of course is different again 😉 it always returns a Value sometimes 185, sometimes 184, not really know what that means. I thought about some kind of timer event but this should look different.
But finally it works, mapped some keys like F-keys and cursor. Also worked on the output gotoxy and colors, the colors are a little bit tricky, because the Amiga console only supports the first 8 pens (as far as I see it) so I cannot just ObtainBestPen, and the first 8 Pens are usually fixed and not the colors I need. I try to change them with ObtainPen but when they are already taken I just try to find one which has a close color, which does not work very well. Solution unknown.
I compile the example of ReadKey as example3.pas and compiled a little RPG-Game I found which is console based, which is a good testcase for colors and GotoXY. Of course looks not the same as in the DOS console but it is usable.
I guess there was some confusion about the installers I presented the last days… these are not official Releases of FreePascal 3.2. In fact FreePascal 3.2 is not released yet and also no fixed date for it yet.
My work on the installers just show my work preparing the next release that we have a real Amiga style installers with all needed Readme and copyright text that they can serve as official packages and even published on the official FreePascal site.
You can download these packages and test the installer, and that was the purpose of showing them, but please do not distribute them as FreePascal 3.2 releases. (I added also a beta marker at the page and in the ReadMe to make it clear) And do not post news messages about FreePascal 3.2 Release until there is an official announcement.
And as promised the Installer for MorphOS also to the latest Version. I used my old MacMini (with the acient MorphOS3.8) for that, but somehow it is rather slow. Maybe I’m spoiled with my PowerBook now, which feels much faster. But the MacMini is much better for such tries, not destroying my working setup on MorphOS.
As mentioned yesterday the 68k Amiga Installer needed a little bit more work, but now it is working nicely the same way as the other two.
In the video the customized Option selection is shown.
Next I will test the MorphOS installer again and try to make an own Installer for AROS. Thats a little bit tricky because of the Package system they use, which is nice but no support for it in the Installer as far as I can see. Path and assigns are not added to user-startup but should be made via a Package-Startup file, in the folder and a text file in the Envarc: pointing to this Package-Startup File. I did this already for the AROS install process but not with the Install tool.