Archives for Coding

HexEdit 0.2

Posted by ALB42 on 22. Oktober 2015No Comments

The Hex Editor slowly gets into shape. Most important function, editing and Value showing. The Value is automatically showed in different types (as Byte, Word, LongWord, QWord) and even more important both endian styles(Big / Little). Later will insert also a function to insert a value as the combined types in both endian styles. For now I only need it for small files, so I load the complete file to RAM and then show it. Later maybe I make a viewer version for very big files, which work directly on Harddisk. But at the moment its not needed.

HexEdit 0.2

HexEdit 0.2

HexEdit 0.2

HexEdit 0.1

Posted by ALB42 on 20. Oktober 2015No Comments

At the moment I need a HexViewer and sometimes also a HexEditor but even at Linux I’m not very satisfied with the functions with the available HexEditors. So I decided to write my own, of course I write it for Linux/Windows (there I need it) but now I always care about that it will also work for AROS. So I compiled it for AROS as well and it worked without any additional actions. At the moment its just a HexViewer. (use cursor keys for move the cursor, page up down to scroll a page, home and end jump to start/end, Tab change binary part to char part)
But I need Editing, search and replace and jump to special positions.

HexEdit 0.1

HexEdit 0.1

HexEdit 0.1

There is music in the air

Posted by ALB42 on 17. Oktober 2015No Comments

Deadwood announced a ALSA AHI driver for AROS Hosted which I tried today, the first version crashed AROS completely. But now the second really works very nice. I take out my mp3player again and it is working very nicely, debugging this way is much better ;-).
When I wrote the mp3 player I wanted to make a video with sound, but sadly I noticed the sound recording of RecordMyDesktop seems not to work, its all quiet the whole time. I tried some trick I found online, (direct alsa, pulseaudio and so on) but nothing helped its all quiet. Then I tried some other programs and finally I found one working kazam has not so many options but enough for my needs. So here is my first youtube video with sound 😉

The sound is a free one from youtube Hero Theme by MK2.

Linking directly

Posted by ALB42 on 16. Oktober 2015One Comment

As I said before much better would be to link directly to the C LinkLibs instead of writing this wrapper libraries, in the past I always failed because of the autoinit stuff. But now when creating the libraries I learned a little bit more about how it work and finally I was able to make a statically linked connection directly from freepascal unit to AROS C LinkLib. And it works 🙂

Freepascal program links to C Linklib

Freepascal program links to C Linklib

BinShifter 1.0

Posted by ALB42 on 15. Oktober 2015No Comments

I played a while ago a funny tiny game on my phone called 2048, really easy concept but makes fun to play. So I wrote an own game for AROS which is inspired by it really easy and nice to program.
Its called BinShifter Bin because of Binary numbers which results from it and shifter because you have to shift the blocks around. With the arrow buttons or cursor keys you shift all blocks to one
direction. If two blocks with the same number are stacked in this direction they are added together and you earn points. The maximum number for one block is 4096 (like the numbers of colors
of the original Amiga ;-)). The game ends when no movement is possible.

BinShifter 1.0 i386-aros

Bin Shifter 1.0

Bin Shifter 1.0

sqlite64 Library

Posted by ALB42 on 12. Oktober 2015One Comment

Good news, the Libraries I created are also compilable at AROS x64, so this learns us two things. First it also works on 64Bit (also with 64Bit freepascal) and Second it also works on ABIv1 (64bit AROS is ABIv1 only). The testlib worked just without any additional actions. sqlite3.library needed some work, seems some C Linklibs are changed so the Makefile libs had to change a lot. The compilation worked well then, but the example program crashed. Seems it always crash when it tries to convert a float to a string, if I read the double by Hand and use the pascal routine to convert it to string it works without problems. Hmm strange problem, especially because the rest is working without any problems. Because of the previous problems with AROS64… it’s maybe a just a AROS64 bug. so I changed my example source 😛 and now it works perfectly.

Freepascal SQLite3 on AROS64

Freepascal SQLite3 on AROS64

SQLite3 is landing

Posted by ALB42 on 11. Oktober 2015One Comment

Worked a little bit more on the sqlite3.library for AROS to use in freepascal. Its more or less only diligent working, and take care not to mix up anything. I didn’t include all the functions only the most important until now (at least what I think is most important) until now its already 106 functions inside the library.

Now I tried some test codes… the one from fpc directly are rather boring, even less impressive than my own examplecode.
But I found a german Tutorial how to use databases in Lazarus, with some tiny changes in in Lazarus component it compiles really nicely and works as expected.

SQLite3 freepascal example program

SQLite3 freepascal example program

Left side Linux, Right side AROS.

C Linklibs to Libraries

Posted by ALB42 on 5. Oktober 20154 Comments

Currently we are only able to use the shared AROS .libraries, so every C link lib is not available in freepascal for AROS. For example sqlite3, SDL, GLUT, SSL and and and much things only available as c linklibs.
I tried once long time before to use the c link libs directly but failed because of the „auto library init“ needed by them.

But of course the other way round, maybe would be possible to specially create a library in C which can be used in freepascal later. I’m not very good in C neither in Makefile magic but hey worth a try. First the official documentation is just crap, not existing (many 404 there, seems someone deleted/moved the documentation) or very old (already written in there that it will change in 2006 and the docu gets not updated) and what I found is just a documentation about how to create a library inside the AROS core build process. I don’t want to compile the complete AROS just to get my Library compiled. Shit, luckily I found an other library which had the same problem and which also come with the source (which is rather seldom on Amiga-style systems, but on AROS more common, but there not so many 3rd party libraries available, one I found)
With this it was rather easy to create a own custom build library with a simple function inside.
The next step was to include sqlite3 to the library. I decided for sqlite3 because its the easiest to check for success and even with some functions its already useful. The task sounded easy but exactly there the problems started, as always.

Again the „compiler magic“ autoinit killed me many times. Finally I found out that I can invoke this autoinit from my initialization by hand. And finally it worked.
This is now a single instance library, a pertask library would make more sense but I didn’t find out how to change that behavior (just to change a flag in the libinit structure was maybe too easy for the designer of this system). But for sqlite3 its not a big problem, it mostly work on a db which have to be opened and closed before using and then always must be supplied to the library. There are some calls which are not threadsafe like sqlite3_config or so but they could be protected via a mutex later. So for now not a big problem, maybe later I find a way to switch to pertask behavior.

The library includes now: sqlite3_open(), sqlite3_close(), sqlite3_free(), sqlite3_exec(). Which is enough to create a database, create a table, add some data and make some selections + output which I tested with a tiny pascal program.

The make process is not complete done and understood by me, there I have some more work to do and then one could begin to include all the sqlite3 functions to the library and make some more tests and of course write a pascal wrapper unit 😉

The long term idea would be also again to check how one could use the link libs directly in freepascal, when creating the c library I got much more knowledge how this autoinit things are working, maybe one could copy this to freepascal.