Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
IWRAM code overlays?   Message List  
Reply | Forward Message #12306 of 15019 |
Re: [gbadev] IWRAM code overlays?

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/
>
>
>





Thu Aug 1, 2002 4:14 pm

mike.wynn@...
Send Email Send Email

Forward
Message #12306 of 15019 |
Expand Messages Author Sort by Date

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...
yerricde
Offline Send Email
Jul 31, 2002
8:13 am

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,...
Mike Wynn
mike.wynn@...
Send Email
Aug 1, 2002
4:04 pm

There is support in Jeff's linkscript for overlays. Segments .iwram0 through .iwram9 form overlays in IWRAM. Segments .ewram0 through .ewram9 form overlays in...
John Seghers
johnse98072
Offline Send Email
Aug 1, 2002
4:55 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help