SDL Audio in Caloric

Comments, problems, suggestions about Oric emulators (Euphoric, Mess, Amoric, etc...) it's the right place to ask. And don't hesitate to give your tips and tricks that help using these emulations in the best possible way on your favorite operating system.
Post Reply
mmu_man
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

SDL Audio in Caloric

Post by mmu_man » Sun Oct 21, 2007 4:03 pm

I just added SDL audio support to Caloric:
http://revolf.free.fr/beos/patches/calo ... ff.001.txt
(no it's not BeOS specific).
While it doesn't really add anything useful for Unix users (they'll use arts, esd, alsa or oss anyway, but it lets SDL choose by default), it will help porting to other platforms who have SDL but aren't Unix and as such lack any of those APIs. This way, SDL will just the available native audio subsystem of the OS.
It's one step towards a win32 build (there is an SDL port AFAIK, so it should be doable with cygwin or mingw).
This way XP users will again be able to have a windowed ORIC emulator :)

User avatar
Chema
Game master
Posts: 2081
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: SDL Audio in Caloric

Post by Chema » Thu Nov 15, 2007 8:46 pm

mmu_man wrote:I just added SDL audio support to Caloric:
http://revolf.free.fr/beos/patches/calo ... ff.001.txt
(no it's not BeOS specific).
While it doesn't really add anything useful for Unix users (they'll use arts, esd, alsa or oss anyway, but it lets SDL choose by default), it will help porting to other platforms who have SDL but aren't Unix and as such lack any of those APIs. This way, SDL will just the available native audio subsystem of the OS.
It's one step towards a win32 build (there is an SDL port AFAIK, so it should be doable with cygwin or mingw).
This way XP users will again be able to have a windowed ORIC emulator :)
Greetings. I have been spending some time trying to get Caloric compiled under cygwin. I declare my lack of experience here, but after many attempts, I ended up with the correct (?) cygwin configuration so configure does not complain.

After that I found a lot of trouble to make things compile. I had to include some lables (__CYGWIN__ and HAVE_OSS) and also add the include path /usr/include (surely something is misconfigured in this case) to the generated Makefile.

I also had to modify some sources (somethings did not work, like including linux/soundcard.h, or some other little things), but it ended up compiling.

However it did not pass the link stage. I get errors I can't solve at all. Here is an example:

Code: Select all

6502_c.o: In function `showState':
/home/Chema/caloric-0.1a/src/6502_c.c:98: undefined reference to `_Carry'
/home/Chema/caloric-0.1a/src/6502_c.c:98: undefined reference to `_Overflow'
/home/Chema/caloric-0.1a/src/6502_c.c:98: undefined reference to `_Flags'
6502_c.o: In function `on_buttonreset_clicked':
/home/Chema/caloric-0.1a/src/6502_c.c:243: undefined reference to `_Sys_Request'

/home/Chema/caloric-0.1a/src/6502_c.c:243: undefined reference to `_Sys_Request'
And later on, the more surprising:

Code: Select all

traps.o:traps.S:169: undefined reference to `fgetc'
traps.o:traps.S:184: undefined reference to `fclose'
traps.o:traps.S:190: undefined reference to `feof'
traps.o:traps.S:198: undefined reference to `tap_open_read'
traps.o:traps.S:216: undefined reference to `tap_open_write'
traps.o:traps.S:229: undefined reference to `fputc'
traps.o:traps.S:236: undefined reference to `fflush'
traps.o:traps.S:247: undefined reference to `printf'
via1.o:via1.S:157: undefined reference to `printf'
Any idea? Maybe I can just give up trying? :(

And after that is solved I must figure out about the Windows port of SDL, as I just included the library and headers on Cygwin, but I think I need a component running on the Windows part.

Cheers.

mmu_man
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Re: SDL Audio in Caloric

Post by mmu_man » Thu Nov 15, 2007 10:02 pm

Chema wrote:After that I found a lot of trouble to make things compile. I had to include some lables (__CYGWIN__ and HAVE_OSS) and also add the include path /usr/include (surely something is misconfigured in this case) to the generated Makefile.
cygwin gcc should define it on its own...
Why are you defining HAVE_OSS ??? windows doesn't have that, there is no reason to do so. And that's why configure didn't define it, because it didn't detect it.
It's actually the whole reason I added SDL audio support, so SDL uses the native audio system on the OS. Because BeOS doesn't have OSS (not as an API at least).
I also had to modify some sources (somethings did not work, like including linux/soundcard.h, or some other little things), but it ended up compiling.
Of course if you define HAVE_OSS it will try to use it!
However it did not pass the link stage. I get errors I can't solve at all. Here is an example:

Code: Select all

6502_c.o: In function `showState':
/home/Chema/caloric-0.1a/src/6502_c.c:98: undefined reference to `_Carry'
/home/Chema/caloric-0.1a/src/6502_c.c:98: undefined reference to `_Overflow'
/home/Chema/caloric-0.1a/src/6502_c.c:98: undefined reference to `_Flags'
6502_c.o: In function `on_buttonreset_clicked':
/home/Chema/caloric-0.1a/src/6502_c.c:243: undefined reference to `_Sys_Request'

/home/Chema/caloric-0.1a/src/6502_c.c:243: undefined reference to `_Sys_Request'
Hmm that's likely due to the name mangling on windows... symbols get a _ prefix automatically by the compiler, but the asm code doesn't have them, so they aren't found.

Code: Select all

traps.o:traps.S:169: undefined reference to `fgetc'
traps.o:traps.S:184: undefined reference to `fclose'
traps.o:traps.S:190: undefined reference to `feof'
traps.o:traps.S:198: undefined reference to `tap_open_read'
traps.o:traps.S:216: undefined reference to `tap_open_write'
traps.o:traps.S:229: undefined reference to `fputc'
traps.o:traps.S:236: undefined reference to `fflush'
traps.o:traps.S:247: undefined reference to `printf'
via1.o:via1.S:157: undefined reference to `printf'
Same here, but the other way, the asm code references symbols that are _ prefixed... that's ugly (ugliest being calling libc funcs form asm) and should be fixed.

User avatar
Chema
Game master
Posts: 2081
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Re: SDL Audio in Caloric

Post by Chema » Fri Nov 16, 2007 12:35 pm

mmu_man wrote: cygwin gcc should define it on its own...
Why are you defining HAVE_OSS ??? windows doesn't have that, there is no reason to do so. And that's why configure didn't define it, because it didn't detect it.
It's actually the whole reason I added SDL audio support, so SDL uses the native audio system on the OS. Because BeOS doesn't have OSS (not as an API at least).
For sure there is something misconfigured in my cygwin installation, I will try to solve it. I had to define HAVE_OSS because else I had problems when compiling. I think the problem is in dsp.c in this piece of code:

Code: Select all

#if HAVE_ALSA
        if (alsa_open () == 0)
        {
            sound_write = alsa_write;
            sound_close = alsa_close;
            return 0;
        }
        return 1;
#else
        if (oss_open () == 0)
        {
            sound_write = oss_write;
            sound_close = oss_close;
            return 0;
        }
#endif
As neither HAVE_ALSA nor HAVE_OSS are defined, functions oss_write and oss_close are undefined, but still used... I had an error about that.

I can't remember exactly if this is the problem, but I remember having compile errors with oss_write and others not being defined.
I also had to modify some sources (somethings did not work, like including linux/soundcard.h, or some other little things), but it ended up compiling.
Of course if you define HAVE_OSS it will try to use it!
Well, that is not the only problem (cygwin has a /usr/lib/sys/soundcard.h IIRC). Also the sources usually issue #include <SDL/SDL.h> and I had to change that to #include<SDL.h> as the rest is already issued by -I flags.

Another thing is with signals. In static const int fatal_signals[] = in hosttraps.c I had to remove some of them (SIGIOT, SIGSTKFLT, SIGPWR, and SIGUNUSED) as the compiler issued undefined errors.

Finally serial_desc=open(serial_name,O_RDWR | O_NDELAY); in host.c issued an error about O_NDELAY not being defined.
However it did not pass the link stage. I get errors I can't solve at all. Here is an example:
Hmm that's likely due to the name mangling on windows... symbols get a _ prefix automatically by the compiler, but the asm code doesn't have them, so they aren't found.

...

Same here, but the other way, the asm code references symbols that are _ prefixed... that's ugly (ugliest being calling libc funcs form asm) and should be fixed.
So nothing I can do on my part, I suppose... :(

Another thing, which is not a problem in Caloric I think, is that each time something changes and I have to run ./configure again, it takes ages to perform all the tests and generate the Makefile.

One silly question. Where should I configure the path where gcc should look for the includes? I do have the INCLUDE_PATH variable set in .bash_profile as

Code: Select all

INCLUDE_PATH=/usr/include:${INCLUDE_PATH}
export INCLUDE_PATH
but still have to add -I/usr/include to the Makefile to make gcc find everything under sys (#include<sys/whatever>). Sorry to feel stupid here, it has been a loooong time since I stopped using unix :oops:

Cheers

mmu_man
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Re: SDL Audio in Caloric

Post by mmu_man » Sat Nov 17, 2007 12:05 am

Chema wrote:For sure there is something misconfigured in my cygwin installation, I will try to solve it. I had to define HAVE_OSS because else I had problems when compiling. I think the problem is in dsp.c in this piece of code:

Code: Select all

#if HAVE_ALSA
        if (alsa_open () == 0)
        {
            sound_write = alsa_write;
            sound_close = alsa_close;
            return 0;
        }
        return 1;
#else
        if (oss_open () == 0)
        {
            sound_write = oss_write;
            sound_close = oss_close;
            return 0;
        }
#endif
As neither HAVE_ALSA nor HAVE_OSS are defined, functions oss_write and oss_close are undefined, but still used... I had an error about that.
Did you apply the diff I posted the url in that same thread ???
It fixes just that and other stuff. 8)
Well, that is not the only problem (cygwin has a /usr/lib/sys/soundcard.h IIRC). Also the sources usually issue #include <SDL/SDL.h> and I had to change that to #include<SDL.h> as the rest is already issued by -I flags.
If you use SDL only you don't need soundcard.h.
Just use the patch!
Another thing is with signals. In static const int fatal_signals[] = in hosttraps.c I had to remove some of them (SIGIOT, SIGSTKFLT, SIGPWR, and SIGUNUSED) as the compiler issued undefined errors.
The patch I made for BeOS fixes those as BeOS doesn't have them either:
http://revolf.free.fr/beos/patches/calo ... ff.001.txt
Finally serial_desc=open(serial_name,O_RDWR | O_NDELAY); in host.c issued an error about O_NDELAY not being defined.
http://revolf.free.fr/beos/patches/calo ... ff.001.txt :D

So nothing I can do on my part, I suppose... :(
You can use mangling macros to prepend the underscore in asm depending on the platform. Best would be of course to replace the asm with plain C. Won't be much slower really.
Another thing, which is not a problem in Caloric I think, is that each time something changes and I have to run ./configure again, it takes ages to perform all the tests and generate the Makefile.
As long as you only modify the C code there is no reason to rerun configure.
One silly question. Where should I configure the path where gcc should look for the includes? I do have the INCLUDE_PATH variable set in .bash_profile as

Code: Select all

INCLUDE_PATH=/usr/include:${INCLUDE_PATH}
export INCLUDE_PATH
but still have to add -I/usr/include to the Makefile to make gcc find everything under sys (#include<sys/whatever>). Sorry to feel stupid here, it has been a loooong time since I stopped using unix :oops:
Should work just running
CFLAGS=-I/usr/include ./configure ...

User avatar
Chema
Game master
Posts: 2081
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Mon Dec 03, 2007 1:15 pm

One note I forgot to post :)

I managed to compile everything with no errors (after modifying some sources about the problem with exporting symbols mentioned before), but did not succeed in the end.

For what I read in the net, SDL imposes mingw libaries (even when compiled from sources) which seems to be incompatible with other libraries needed by Caloric (thread support, at least, IIRC). I got several errors like this:

Code: Select all

/home/Chema/caloric-0.1a/src/interrup.c:66: undefined reference to `_sigaction
locate.o: In function `locate_file':
/home/Chema/caloric-0.1a/src/locate.c:96: undefined reference to `___errno'
/home/Chema/caloric-0.1a/src/locate.c:186: undefined reference to `___errno'
oric.o: In function `SDL_main':
/home/Chema/caloric-0.1a/src/oric.c:95: undefined reference to `__impure_ptr'
It seems to be a known issue, but have not the slightest idea about how it could be solved.

Anyway we are really near :)

mmu_man
Flying Officer
Posts: 215
Joined: Thu Sep 21, 2006 7:45 pm
Location: 26000 Valence, FRANCE
Contact:

Post by mmu_man » Sat May 31, 2008 10:05 pm

I just ported Caloric to win32, sorry for being faster :D
See new topic

User avatar
Chema
Game master
Posts: 2081
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema » Mon Jun 02, 2008 9:01 am

mmu_man wrote:I just ported Caloric to win32, sorry for being faster :D
See new topic
:) A pleasure :)

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests