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.

Coding > Maximum Array Size

#23907 - enliteneer - Sat Jul 24, 2004 1:09 am

I tried compiling the tk-keys demo that I d/led from the source section
and it *LOOKS* like it was compiled with the ARM SDK.

Im having trouble compiling it with devkitadv.

I think I narrowed the problem to a data array. If I just try to
include the header file that declares this array into a known working
project, my project will compile but not run (it crashes the emulator!)

The only weird thing I see about the array is that its rather big
unsigned char openingData[33280] ,
with some experimenting, I notice that any array size larger than
15896, will cause a violent crash.

Is there a limit on array sizes? Is there some tweak that I need to do to compile code that was originally for the arm sdk onto the devkitadv?



*http://www.gbadev.org/download.php?section=demos&filename=tk-keys.zip

#23910 - dagamer34 - Sat Jul 24, 2004 2:01 am

In devkitAdvance, any non-const data is automatically put in IWRAM, which you only have 32 KB of. Try putting the array in EWRAM and see if that makes a difference. It should work.

Code:

#define IN_EWRAM         __attribute__ ((section (".ewram")))


And use it like this:
Code:

char largeArray [15386]IN_EWRAM;


It should work then.
_________________
Little kids and Playstation 2's don't mix. :(

#23923 - enliteneer - Sat Jul 24, 2004 8:04 am

Thanks dagamer34, putting it in external ram fixed it!

Interestingly, I think const data must also be placed internally by
default because declaring the large array as const still caused the
emu to crash.


#define IN_EWRAM __attribute__ ((section (".ewram"))) = {0}