Archives for Compiler Core

Mouse Move Release

Posted by ALB42 on 9. August 2014No Comments

I worked a little bit more on this mouse movement problem and I think now I got it and voila also the displacement bug of Menu disappeared. so now menu and combobox looks ok to me.
The maximus editor didn’t start at my machine anymore.. a little threading bug was the reason.. I didn’t know they use threading… in a EDITOR! how useless.. seems its meant to check for filesystem changes. But… to be honest.. a Timer would do it in this case.
I wanted to try maximus because I remember there was a strange font bug inside: The position of cursor does not fit to the char position. I tried a little bit, but in the end I have to say.. the maximus ist just poorly written. It just takes a width of a char to calculate the cursor position. By default a fixed width font is set, of course with fixes font it works. But this font seems not available by default in AROS so it uses the default font which is NOT fixed width. If no ini file is there for maximus it uses „#Edit2“ as the default font which is „Courier New“.. I changed the default to „ttcourier“ which is available by default in AROS. The #Edit1 I changed to „fixed“ which looks nicer for me. but also other fonts like sans mono or so work nicely.

Bildschirmfoto vom 2014-08-09 13:56:12

The uidesigner is working.. but the movement of items is hard.. because it always jumps around. I noticed a hack in the GDI (Windows) implementation of FPGUI which captures the mouse when the editor is there. I also implemented this behaviour and now it moves smoothly.. In fact I did implement before already.. but the initial call to activate this function was missing.
As last I tried every single example in fpgui (/example/gui) and the most of them work really nice now. There I found a strange bug for TimerTest or animation examples.. seems the timer fire very seldom.
Initially I thought the reason is that there comes so seldom messages from aros.. but then I measured the time between messages and it is really short.. 0 to 20 ms, so no or one task switch. so thats not the reason it fires so seldom. In the timertest there is a Timer should fire every 50 ms but it looks more like 500ms-1s. Finally I found the reason, the time when the Timer should fire is determined by a Now() call. My Millisecond count in the result was just wrong, alawys an order to small. Type mismatch in the converter routine.
So now the animtest also works rather fast.. hmm I always thought my image drawing routine is so slow that I should improve it, seems it is not THAT slow 😉 OK in the colorwheel example you can see that it is VERY slow ;).

I think this changing are very important, it really improves the fpgui functionality a lot. So I created a release today for public again.

Available at the FPC DownloadPage

Fresh on Sock(et)s

Posted by ALB42 on 12. Juli 2014No Comments

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.

Freepascal Threading

Posted by ALB42 on 22. September 2013No Comments

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

New Release (mainly bugfixes)

Posted by ALB42 on 16. August 2013No Comments

After a long time again a little bugfix release of fpc, and first release of clipboard support for aros (there is an example script in the src directory of fp)
The news:

  • lower case filenames for FP-ide
  • better handling of parameter with quotes and empty parameter
  • NewObjectA in intuition with right calling
  • fixed wrong pathes when started from WB and file is in root
  • Bugfixes for Copyfile-routine in fileutil (lcl) and some other fileutil routines
  • Copy to AROS Clipboard, paste from AROS Clipboard added to FP IDE
  • GetTextFromClip and PutTextToClip functions added (as easy function to use clipboard in aros)
  • Iffparse unit added

Download like always on the fpc aros page

Clipboard

Posted by ALB42 on 23. Januar 2013No Comments

Today I cared about the Clipboard in aros, how to get a text from there and how to put a text here.

I should say it was not that difficult, but only because  I had a example source code in C functions toClip and fromCli. But first I had to create an iffparse unit because the informations are saved as IFF in the clipboard. Has the advantage that you can everything what you can transport via IFF format, so pictures, sounds and of course Text.

The first function GetTextFromClip was really simple and worked directly, PutTextToClip in principle the same easy task but it didn’t work always end with error -6 on PushChunks. I compared all calls and variables but all seems to be correct. Then I tried to make copy paste in editor but there it also didn’t work. So Something was wrong with AROS self. After a restart of AROS both routines worked very nice, strange like always.

I will put both routines into Clipboard unit for easy access from fpc programs. Perhaps later also make a version for images.

As first test I added it to the FP IDE, there is already something prepared for windows to get the Clipboard from Windows.

FP IDE with Clipboard support

New Release

Posted by ALB42 on 21. Januar 2013No Comments

Today I bring all together and release. A not complete lists of changes/bugfixes for this realease:

* some basic units moved from arosunits to rtl, also helpful if later joined with amiga and morphos
– amigados, agraphics, exec, inputevent, intuition, layers,
– longarray, pastoc, tagsarray, timer, utility
– IMPORTANT: DELETE UNITS BEFORE INSTALL NEW VERSION TO GET RID OF UNITS IN OLD DIRECTORY
* changed all library calls to cdecl
* Startup and finishing code improved
* FileGetDate/FileSetDate implemented
* GetEnvironmentVariableCount/GetEnvironmentString implemented (example code by magorium)
* Video unit with fullscreen support (color tag = False)
* Keyboard unit rewritten, better identification of keys for fp ide, mousewheel as pgup/pgdwn
* free vision GetDosTicks implemented (needed for double click)
* layers aros unit (thanks to anon and magorium)
* FPGUI:
– MOUSEENTER/MOUSELEAVE implemented
– MOUSEMOVE with mouse grabbing
– KEYRELEASE implemented
– Input focus implemented
– Modal windows, blocking of other windows
– save closing of window (removing of messages from message port)
– combobox closing when a entry is selected repaired (hopefully)

check out https://blog.alb42.de/fpc-aros/ for the last Version

Buggy Bugs and difficult keys

Posted by ALB42 on 15. Januar 2013No Comments

Sometimes when a Button or so is destroyed in runtime the software crashed because in the messageport still some messages for this particular object and I have no chance to see if it is still alive.

First Idea was to poll all messages before destroy this windowthis was implemented when writing the Message for 07.01.2013 in this blog the first error report. But now I noticed sometimes a stack overflow appear when large windows are closed.

When searching for CloseWindowSafely Amiga  you find a lot of source snips which all do the same, remove all messages for this window from the messageport.
for example this
So the StripIntuiMessage is exactly what I need, conversation to Pascal is simple, the problem was it didn’t change the problem. I changed the routine that it counts how many messages are there and how many are removed. So at least it does something. Then I let the routine run twice one after the other so the second should not find a message and the overall should be smaller (because removed messages). I was surprised that the messages are not be removed.. so both runs are identical, I’m not sure whats wrong with my routine it does exactly the same as this C routine. So in the end I wrote a complete new routine, which gets all messages with GetMsg and then put them back with PutMsg when they not belong the removed window. Task done, now its working.

Another task I set for myself was the keybinding for fp-editor, and this is really crap, finally I think it would be easier to make a very big table for all cases, so all keys combinations with shift, alt, ctrl, sounds crazy but this keycodes have no real systematics. The most keys are working already… so menu keys, copy paste and so on, are working also mark text with keys is working, but still need some testing.

Stack me up

Posted by ALB42 on 13. Januar 2013No Comments

When I started to bring FreePascal to AROS I had no idea how this should be especially the startup code was something like magic. The startup codes are mostly in Assembler, I used much i386 and x64 Assembler, even machine code already (created an compiler to machine code). But for this you have to know about the inner system of aros and freepascal and additionally this assembler uses a rather strange syntax AT&T, ok when look right to it the intel syntax is strange… but I’m more used to it.

So I just looked into the different i386 implementations for linux, ppc for amiga and tried to guess how it should look like, in principle it was just a lucky shot. And I was rather surprise that the startup worked, just the finish was nearly impossible, for me this was more or less obvious because I do not know what AROS expect on the stack after the program.

The simple approach was DosExit, a call in dos.library which ends the process directly, but because its such a hard end it leaves some memory leaks open, especially the dos.library stays open (of course it must be open to call this DosExit). The conseqeuence was when calling very often after a while you get some strange effects like „out of memory“ even there are some hundred megabytes free.

Finally I got disturbed by it and try to find a different solution.

First I tried what happen when I just leave the program directly again, seems everything works nicely.. so it seems Aros expect the same stack as started, so more or less its just a CDECL call of „start“ with CommandLine, CommandLineLength and Execbase as arguments. As in the copied startup code of linux I saved the stack pointer called my program restored the stack pointer. Sadly this did not work, on „ret“ it looked like it jumped back into my fpc program and not back to  aros system., so for me it looked like the stack is not at right position. I compared the stack entry by entry, its exactly the saem before and after my routine, so this was not my problem. Of course I didn’t noticed this directly, this would be too easy. First I tried 3 days to debug this situation why my stack could be wrong or destroyed or whatever and thats all without a real debugger and without output (writeln does not work at this position of course). In germany we say  „I was barking at the wrong tree.“

Ok back to problem, I noticed that the stack is completely the same, so what else could it be, of course the other registers. So I added pushad/popad (in AT&T syntax its pushal/popal) and its working I was really surprised about this. It seems that the starting of a program in AROS is really just like call a subroutine… which was not obvious for me because I guessed you get a new process so also get a clean set of registers.

I’m not really sure if I saved now enough… how about SSE registers? FPU registers? until now fpu seems always be empty, sse register difficult to say. Much more interresting will be for x64 if one day I will also bring fpc to there (its my wish) there is no pushal/popal and much registers.

Nevertheless its working now, included in the next release.

Changing FreePascal

Posted by ALB42 on 10. August 20114 Comments

long time no blog entry… too busy over all work.. house.. family too much to do besides programming.

Some days before some guys asked me to bring the aros fpc into the official Sources. So I created a Patch and announced at mailing list, then Charlie and Florian contacted me and I got an own branch for aros. First aros will be implemented, then checked (I guess by Charlie?) and finally, hopefully come to main trunk. After it, it would be a very good idea to bring the 3 Amiga Systems together (AROS, MorphOS and AmigaOS) Charlie did the implementation for MorphOS, I did Aros… so there should be enough knowledge to bring it together to a much smaller codebase.

Besides this today I checked a little bit about bug reports/wishes… first is rather strange… when you open a Modal requester the Windows behind should be disabled/not click-able… and Aros „shows“ also so.. so if you try to click a Button it shows no click animation. But after closing the modal requester all your clicks done meanwhile the requester was open will fire one after the other…. very bad! … the MUIA_Application_Sleep let the application and all windows sleep.. and shows a Busy pointer… but even here you can still click the button… So now I took the hard way…. I just deactivate all Windows before show the requester.. then it really works.. its just slower because the window must be redrawn.

Modal Requester now deaktivates the Windows behind

The second thing is the OnChange Event in the TMemo now always fired when there is a text change done. This was again a rather easy thing… ok also needed long time.. but just because I forget to set the Hook-procedure to stdcall… seems too long I didn’t care about Events.

Uploaded also a new Version of fpc (Link section)

FPC, MUI, LCL and other nice things

Posted by ALB42 on 8. Mai 2011No Comments

 An Update for FPC is published at AROS exec, in princple the first really working. Already included now some aros/amiga units like exec, amigados, agraphics (instead of graphics which exists in lcl), intuition gadtoos and of course MUI. Also I put in the MUI example program (see yesterday) into the examples folder.

Last Version of fpc for AROS

Today I started to implement the MUI classes for LCL. For this purpose I wrote a wrapper unit, which makes the classes existing in the MUI library directly accessible, like any other Pascal class. The first results look already very promising… in fact the handling of MUI and LCL is not that different especially the events are much easier to handle than gadtools. A little bit bad on the first view was, that MUI does not allow own position of Components, only automatic positions available (group concept very close to GTK) but by setting and Layout Hook and add and Left, Top, Width and Height to every Object I was able to disable this behaviour… I know this behaviour is very nice, special for scaled GUIs, but sadly LCL does not support such behaviour, as fas as I know. After some work I got

LCL MUI Test

which looks already very nice, at least much better than gadtools. Events also already working very nicely… just some class fields are a little bit strange… the documentation of MUI is hmmm how to say.. not very nice to use.