gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Audio > c++, DevKitAdv & FRAS

#9021 - mtg101 - Sat Jul 26, 2003 5:17 pm

I'm using DevKitAdv (R4), and programming in C++. And I'd like to have a MOD file playing in the background. So I've found FRAS and I'm having trouble using it.

Firstly - is FRAS the best thing to use? Is there anything significantly better out there?

So onto the the problem... I've generated, from the sample country.mod file, country.cpp & country.h; and included stuff into my project with the following makefile:

Code:

CFLAGS = -c -O3
MODEL = -mthumb -mthumb-interwork
NAME = mydemo
LIST =  $(NAME).o tilebg.o bgtext.o intro.o country.o


all: $(NAME).mb.gba

$(NAME).mb.gba: $(NAME).elf
   objcopy -O binary $(NAME).elf $(NAME).mb.gba
   c:/gba/dev/gbaromfixer/gbafix -t$(NAME) $(NAME).mb.gba

$(NAME).elf: $(LIST) crt0.o
   gcc $(MODEL) -nostartfiles -T lnkscript -o $(NAME).elf crt0.o obj/crtbegin.o obj/crtend.o fras.lib $(LIST) -lm

$(LIST): %.o: %.cpp
   gcc $(MODEL) $(CFLAGS) $<

crt0.o: crt0.s
   gcc $(CFLAGS) $(MODEL) crt0.S

clean:
   rm -f *.o
   rm -f *.elf
   rm -f $(NAME).mb.gba


It compiles fine, but the linker fails (undefined reference) on the FRAS functions. What am I doing wrong?


Cheers
Russell
_________________
---
Speaker for the Dead

#9024 - tepples - Sat Jul 26, 2003 5:35 pm

Try putting the FRAS library after the $(LIST).

I also see that you downloaded a .lib file rather than a .a file. GNU Binutils tends to use .a files for static libraries. Are you dealing with a library that was compiled for use with ARM SDT rather than with the GNU toolchain?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#9033 - mtg101 - Sat Jul 26, 2003 9:02 pm

I've tried changing the order, putting extern "C" {} in the fras.h file, but none of that didn't help.

I don't know for sure how the .lib was compiled - but the devrs.com link says it's GCC. Maybe I'll haveto compile it myself... which as I don't know ASM willbe a challenge...

Can anyone suggest a GBA MOD player that might be easier to get up and running with DevKitAdv?
_________________
---
Speaker for the Dead

#9035 - mtg101 - Sat Jul 26, 2003 10:04 pm

OK - I've done somemore work and realised I had to hack the crt0.S file to enable inturupts and provide an interrupt table - done that, and unsuprisingly it didn't help. But at least I got rid of a future problem :)
_________________
---
Speaker for the Dead

#9054 - mtg101 - Sun Jul 27, 2003 12:45 pm

After lots of tweaking lots of code with extern "C" {}, making sure fras.lib comes after the object files in the makefile, and realising that the FrasModStop() function doesn't exist, I've got it building now. Doesn't actually play anything yet... but it'sa step in the right direction. Thanks.
_________________
---
Speaker for the Dead

#9088 - mtg101 - Mon Jul 28, 2003 11:34 am

I'm still having problems here. Not only does sound not play, but the pattern/line counter global vars don't get updated (yes - I have declared them volatile).

Looks to me like the inturrupts aren't being called... I guess i'll have to go and find out more about how to get inturrupts working... I was hoping just uncommenting the right lie in crt0.S would do it... ho hum....
_________________
---
Speaker for the Dead

#9148 - mtg101 - Tue Jul 29, 2003 10:23 am

Ah - maybe because it's becuase I'm not doing...
Code:

REG_DISPSTAT=0x0020;


...to enable the VCOUNT interrupt. I'll try that later when I get home (at work I'm not allowed to code GBAs :( )
_________________
---
Speaker for the Dead

#9168 - mtg101 - Tue Jul 29, 2003 9:50 pm

Setting REG_DISPSTAT worked - phew. Thanks for the help, and I'm off to read the Pern project tutorial om interrupts again...
_________________
---
Speaker for the Dead

#9177 - tepples - Tue Jul 29, 2003 11:22 pm

In general you have to do four things to enable an interrupts, preferably in this order:
  1. set the ISR to point at ARM code, preferably in IWRAM,
  2. turn on the interrupt source,
  3. turn on the corresponding mask flag in REG_IE, and
  4. turn on the interrupt master enable.
What you forgot was step 2.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.