You should be able to get gcc to create 4K "overlay objects"
BUT you will not be able to link directly to the other code by doing this :
compile your file, link, use objcopy to create a self contained binary image
(max 4k) to be loaded into your 4k iwram area.
use something like gbafs or similar to include these overlays into your rom.
tweek the linker script to make sure the required area is free (I would use
the last 4k of Iwram)
to make life easyer I would give each overlay object an entry point
something like
typdef void (* workFuncPtr )( void * );
bool hasLoaded( workFuncPtr * availableFuncs, int len )
{
/* returns the addresses of the worker functions; */
if ( len < this_overlays_funcs )
{
availableFuncs[0] = myFunc1;
availableFuncs[1] = myFunc2;
/* etc */
return 1;
}
return 0;
}
void myFunc1( void * param ) { /* bla bla bla */ }
void myFunc2( void * param ) { /* bla bla bla */ }
-----
then in your code use
typedef bool (* overlayEntryFuncPtr)( workFuncPtr * , int );
void * currentOverlay;
workFuncPtr overlayFuncs[16];
#define OverlayAddress ((void*)0x03007000)
invokeOverlay( void * overlayData, int funcNo, void * parameter )
{
if ( currentOverlay != overlayData )
{
memcpy( OverlayAddress, overlayData , 0x1000 );
currentOverlay = overlayData;
((overlayEntryFuncPtr)OverlayAddress)( overlayFuncs, 16 );
}
overlayFuncs[funcNo]( parameter );
}
this is by no means the best way, but an example of how to proceed.
Mike.
----- Original Message -----
From: "yerricde" <d_yerrick@...>
To: <gbadev@yahoogroups.com>
Sent: Wednesday, July 31, 2002 4:09 AM
Subject: [gbadev] IWRAM code overlays?
> Has anybody figured out how to do an IWRAM code overlay?
> For instance, if I want to devote only 4 KB of IWRAM to code,
> but I have 40 KB of code that wants to run in IWRAM, how do
> I get GCC to compile a function that I can load into a 4 KB
> part of IWRAM when needed?
>
> --
> Damian
>
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>