I found out whats wrong with my OpenGL Shift-it. There is a Division by zero exception in the gl library, especially on tiny vertextes (like the one on tip of a sphere) or on tiny slices of clipped boxes.
The question was, why it does work in C, but not work in freepascal. because I tried to make a sphere using gluSphere() in C, and it worked perfectly, but in my program it always crashed.
On the Hunt of the source of Exception, I first had to find out which kind of FPU exception/Trap it is. So I wrote my own traphandler and checked the parameters when enter the traphandler, sadly the fpu content was already cleared and the buffer where the content of the FPU registers should be noted was not assigned.
So I took an other way.. and set the FPU exception one by one to masked and checked when the crash disappeared.
I expected bad things with the masked expections on other parts of the calculation. It surprigingly worked VERY nicely. That way I found out, that Division by Zero exception flag mask this crash.
This made me curious and I checked how the setting of standard C programs are in AROS. I made a simple C program which reads out the FPU Control register (which controls the exceptions) and I got a $37F.. this reallly made me laughing loud (my wife must thinking, that I became mad.) becasue that simply mean, all FPU exceptions are masked… means ignored. I also checked my C-OpenGL program, the same. In my Freepascal programs I always find $1372: which means „Invalid Operation“, „Division By Zero“ and „Overflow“ are not masked.
I found out that also at Delphi, they deactivate all FPU exceptions by default if OpenGL is used (in the opengl unit initialization section). Now I’m thinking: one way would be to deactivate FPU exceptions for all FPC programs at AROS (becasue I have no way to catch them), or simply deactivate it for programs using OpenGL (as Delphi is doing).
A nice sidemark: This error only happen for software rendering, if you use hardware rendering it disappears completely. I didn’t know that I can use hardware rendering in linux-hosted mode, a user at aros-exec told me I should try the mesa.library in sys:storage/libs which has hardware support for linux-hosted installations. This indeed is very nice and then the game makes really fun.
The next step for the game would be to include sounds, the password system and some GUI for configuration, but all this things I postponed now. The game is already rather nice, the coding was really fun. And a proof that you really can make nice games/programs for AROS with FPC 😉
This days I played around with the OpenGL functions in AROS. Sadly very buggy… so my dream to port Shift IT GL to aros moved rather far away… but finally I managed to create a Version which does not crash the whole time (but still rather often). But it works… I’m already very satisfied. 40 levels of fun 😉
Download Package:
Shift it GL for i386-aros
Install: unpack the archive to the place you want (Games folder or so) the game comes in an own folder with Icon.
Aim: Remove all colored blocks from the level
How: Equal colored blocks disappear if 2 or more lay next to each other (one side is touching). If you click on a block and if a movement to right or left is possible empty boxes are showed next to block. Click on an empty box to move the block to there. Blocks can not float in free space, but fall down if no other block or level is underneath.
In the upper left edge the statistics are shown: Level number and moves you did. „Best“ shows shortest (known) way to remove all blocks. For hard mode you have to find this optimal solution. (I remember for at least one level there is a even shorter solution than the „Best“ given.)

Press „r“ to restart a level, „Esc“ to quit program. You can rotate the level just by clicking on the background and move around, a middle mouse click recenters the view.
The ToolTypes of the program supply some additional options: (all possibilities are included disabled via parenthesis).
„HARD“ Hard mode. You must find the best solution with the number of moves denoted in „Best“, if not given Easy mode is enabled, no limit of movements
„CHEAT“ Cheat mode. do not use it! haha just a joke! I didn’t include the password system, so its the only way to go to a specific level after closing the program, (not have to play all the levels again, which would be very frustrating, especially when if the program crashed and THIS WILL HAPPEN!) press n to jump to next level.
„STARTLEVEL=x“ replace the „x“ by a number 1-40 to jump directly to this level, only available if „CHEAT“ is also set
„SAFE“ = Safe mode, deactiave all block animation and view changes -> much faster.
„HIDEBG“ = Hide background (no gradient in back, just white), much faster for software rendering machines
„SHOWFPS“ = Show fps of last frame, and average over last 10 frames. Should be only for testing, because usually the pciture is only drawn when needed, if this option is activated its drawn by timer, so this option generates much higher load.
New Version of Freepascal is available:
– Sockets, fcl-net (SSockets, resolve unit)
– IncludeTrailingPathDelimiter repaired to NOT c: -> C:\ (fpgui requester works better now)
– AllFilesmask changed to ‚#?‘ (its the normal Amiga-style mask) but PathConv/FindFirst support ‚*‘ and ‚#?‘ also.
if you want to try out sockets.. look into packages/fcl-base/examples/isocksrv.pp and isockcli.pp
maybe I will copy them to examples next time.
After very long time finally finished the Intuition unit including all macros, varargs Versions and documentation, this was really hard work, and I was very busy the last month.
So today there is a release of the newest FPC for AROS with completed Intuition.
As next I will clean the code a little bit and try to update the official SVN.
A source snapshot is included this time. Finished Intuition is a good state I think to make a source release.
Besides this I released the raw XMLs needed to created the HTML/CHM developer documentation for the included aros specific Units.
Releases can be found at FPC AROS Page.
A new Release of FPC for AROS is out today.
The only new thing is:
* Support for Threads (using TThread class)
Thanks to Mag, he supplied some example codes and the library wrapper unit in the FPC-AROS Wiki.
So my interrest was awaked and I need a little break from the boring basic library rewriting and documentary work.
Implemented id the TThread Class and the Critical sections functionality, „TEvents“ are still not supported as long I dont know exactly how they are working, it seems its not directly possible to do such thing in AROS, maybe must self write a mechanism for it.
AROS Threads (with thread.library) have no chance to suspend/kill from outside and so on.
The suspend I managed with a Mutex Condition, wich can be fired with a „resume“, but this makes it impossible to Suspend the Thread from outside. But this is not allowed at some other platforms as well, Resume and Suspend are even marked as deprecated in newer Delphi/Freepascal versions.
I known a nice replacement for Suspend is the TEvent feature which is still not available for aros… but I’m working on this until this the suspend inside the thread and resume from outside must do it.
An example for the us of threads with suspend resume and critical sections can be found in pp/fp/src/threadtest.pas inside the archive
After a half month of hard work of rewrite the basic units of AROS and make the documentation, I think its time for a new Release to let the people play with it (and find errors, maybe)
So whats new:
Complete rewrite: Exec, AmigaDos, Workbench, Icon, AGraphics
Many new types and constants added. Addtional procedures/functions for variable number of tags as arguments (like known from C). One function in AGraphics is renamed from „GText“ to „GFXText“ comparable to the „DOSFlush“ in AmigaDOS Unit or „ExecInsert“ in Exec.
There are some function which are deprecated or not implemented atm, or only work on real Amigas i try to flag this functions with the right function flags (‚deprecated‘ e.g. „BltClear“, ‚platform‘ e.g. „SetChipRev“, ‚unimplemented‘ e.g. „WaitBlit“) do they should give a warning if a user use them in own code.
Documentation: Exec, AmigaDos, Icon, AGraphics
as HTML here on the Webpage or as CHM as part of the archive file pp/fp/docs/arosunits.chm. For view this files you can use the fp editor, Help->Files but it does not work very well. better is the HH.exe in Windows or the kchmviewer for linux both searchable with index and so on.
like always the download available on the FPC Page
The AGraphics unit is finished. And all Circular type calls are solved… I’m a little Bit curious if it is possible in Intuition as well… I noticed there are much more of such problems.
Sadly, because of this change, the Structure and the corresponding Constants are now a little bit far form each other. But I think the right type is much more important, especially when nicely linked in the Docu (As I Did in AmigaOS and little bit in Exec) there is no need to look to the Source.
The FPDoc util can also create the CHM file we need as help for FP-IDE would be nice to add it as context sensitive help. Next Days I will start/continue with AGraphics Documentation. Stay tuned.
I got another idea for better convert C-structs to pascal
for example:
struct XXX
{
Int abc;
}
#define cde abc
Such things you can find everywhere in AROS includes (because of compatibility with AOS4, MorphOS? MayBe)
There is a functionality that records can act like classes in Delphi compat mode, so this record would look like this in Pascal:
TXXX = record
abc: Integer;
property cde: Integer read abc write abc;
end;
Needs to be tested but should work well. The property does not mark an other field so it does not extend the records size (SizeOf should stay the same) just an other Access function is added. This also work into other records for example, maybe even some unions could be replaced with this functionality:
TTextFont = record
tf_Message: TMessage;
// .... more fields
property tf_extension: PMsgPort read tf_Message.mn_ReplyPort write tf_Message.mn_ReplyPort;
end;
Finished work at „AmigaDOS“ unit. also changed the documentation.. some of the functions are not descripted in the official reference. Can add a Description later. I’m still thinking how to „save“ the documentation source files. as archive? as seperate SVN (like fpc is doing) or add it into (but then can not add to official SVN)
Now starting with AGraphics unit. wrapper for graphics.library, there ar esome problems to solve… some cycle type uses.. but I think the most of them I can solve.
Again a release, not much changed.
Only a small bug in FP-IDE: Copy to/from AROS only copied 256 Chars. Now it should work also with longer texts. I also will from now on always post the MD5 of the archive file.
I didn’t find a md5 tool for Aros so I wrote one (GenerateMD5) and also set it for download.
it does not compare, just give out the Hash, so you have to compare by eye. Later I will a better one which also can compare from a *.md5 file.
A new Release of Freepascal for AROS is out today:
News:
- Added function ‚GetToolTypes(Filename)‘ to „Icon“-Unit. To get fast the Tooltype entries from the icon
of a file. Filename (without .info) must be supplied, Result is an array of string (TToolTypeArray)
- Complete rework Exec, AmigaDos(not completely finished), Icon, Workbench
- corrected Date in SearchRecord (FindFirst/FindNext) for example FP-IDE Dialog
- DebugLn/Debug calls to get DebugOutput to AROS Debug Output (for example Sashimi or with hosted AROS the console it was started from)
Like always the download is available at FPC Page