oh no

i think the prefab djgpp+allegro dos cross compiler i have doesn't recognize 0b binary constants

oh noooooo

after several hours of messing around i have djgpp with a modern version of gcc and allegro 4.2.2 on windows (with soundblaster fix) as well as a test program in dos working!

instructions will be in my next post(s)

#RetroComputing #DOS #RetroDev

i got djgpp binaries from https://github.com/andrewwutw/build-djgpp

and allegro 4 source from https://github.com/msikma/allegro-4.2.2-xc

then i edited xmake.sh to point at djgpp and ran ./xmake.sh lib

but it turns out i needed dependencies anyway so i used this from build-djgpp's readme:

sudo apt-get update
sudo apt-get install bison flex curl gcc g++ make texinfo zlib1g-dev g++ unzip

and then it worked, leaving liballeg.a in lib/djgpp

GitHub - andrewwutw/build-djgpp: Build DJGPP cross compiler and binutils on Windows (MinGW/Cygwin), Mac OSX and Linux

Build DJGPP cross compiler and binutils on Windows (MinGW/Cygwin), Mac OSX and Linux - andrewwutw/build-djgpp

GitHub

i then copied liballeg.a and the include folder from allegro to my windows box where i put liballeg.a in \lib\ and the includes in \include\ folders inside the djgpp folder that i got from the DJGPP for MinGW standalone binaries

i then took this allegro test from here https://github.com/msikma/allegro-dos-example/blob/master/src/main.c

and used i586-pc-msdosdjgpp-gcc to compile it. made a batch file for it which you can find below

oh and i *think* you might want -march=i386 -mtune=i386 cause the prefix for this is i586-pc-msdosdjgpp- and i586 is pentium so idk if it compiles 386/486 compatible binaries without that?
Gosh allegro is annoying. I had to define AL_INLINE to work around inlining/duplicate definition issues. I'll post about it in more detail when I'm actually at my computer again

ok so when i tried to include <allegro.h> from multiple compilation units i got a whole bunch of duplicate definitions error. turns out it's allegro's special inline functions

i found this https://stackoverflow.com/questions/12747198/compiling-error-when-std-gnu99-and-inline-function-is-used which says you can use -fgnu89-inline to fix it

but i didn't wanna do that because it's not 1989 anymore

so i looked and found they use an `AL_INLINE` function-like macro

so i defined this before including allegro.h:

#define AL_INLINE(ret, func, args, ...) static inline __attribute__((always_inline)) ret func args __VA_ARGS__

you can get rid of the __attribute__((always_inline)) i guess if you want

oh i also define ALLEGRO_HAVE_STDINT_H before including allegro.h (i made a wrapper h file that handles all of this) because otherwise i get a bunch of errors from allegro's astdint.h