fragglet / lhasa

Free Software LHA implementation
http://fragglet.github.io/lhasa/
ISC License
80 stars 15 forks source link

Support for Amiga architecture #25

Open tehKaiN opened 6 years ago

tehKaiN commented 6 years ago

LHA has always been important for Amiga users. We have aminet.net, which is massive repository of Amiga-related software, and everything there is packed with LHA or LZX. With such strong tradition in mind I think it's very appropriate to have Amiga arch support. ;)

There is a precompiled lhasa versions on aminet, but its performance and size are not so well optimized. With some patches to Amiga GCC toolchain standard library, I've managed to build lhasa to filesize of 79KB, which is almost twice as small as one found on aminet. I'd gladly contribute lha_arch_amiga.c so that future versions may be built from source without any effort. Dunno how to do it with build system though: I'm not an automake guy and I've built it using self-made makefile. If you're willing to accept my pull request I'll try to learn a bit more and add required changes for automake too.

fragglet commented 6 years ago

Yes, please feel free to submit a pull request. Using autotools would be ideal but I don't know what the tooling situation is like on AmigaOS or whether it's practical to use it. So I encourage you to use that but it's not essential.

tehKaiN commented 6 years ago

Okay, will do.

Currently most of folks are cross-compiling anyway and currently best-looking toolchain is using automake for its submodules, so that shouldn't be a problem. There are still some people who compile everything on their Amigas where at most only make is present, but they mostly have enough skill to come up with custom makefile. ;)

Also, I've noticed that you're using floats only for ratio calculation - removing this one usage adds many more optimization opportunities (stock Amigas don't have FPU so floats are slowly emulated), so I've made function which was returning float percents to return integer promilles, which are then displayed as dual %d - one with /10, the other with % 10. Dunno how you feel with this kind of optimization being added to your prog ;)

tehKaiN commented 6 years ago

Okay, I've added pull request. There's still some work to be done.

I've read some tutorials about autotools, so I get the main concept, and there are even means to crosscompile. Since Amiga GCC toolchain has m68k-amigaos- one can simply write ./configure --host=m68k-amigaos to trigger crosscompiling. Problem is that autotools have some weird preset for some obsolete toolchain version and use strange cc flags, and also tool for linking library which is not really present in recent tooling.

My guess is that we need to override stuff that ./configure guessed with some lines in configure.ac. I still don't know how to do this but we need to set CC flags to include -fomit-frame-pointer -fbaserel and link flags to have -noixemul and optionally -flto to squeeze some more optimizations out of compiler. See Makefile.amiga on my branch for reference. I'll look into it right now, but I wouldn't mind hearing any ideas for doing such thing. ;)

Also, I'd like your opinion if scrapping float percentage for integer permilles stays or should I revert it.

tehKaiN commented 6 years ago

The problem with autotools is that it uses libtool, which tries to build liblhasa in some prehistoric manner. Everything would be cool if automake could use $(AR) for Amiga linkage. I've searched the net for forcing such behavior but couldn't find anything.