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.

DS Flash Equipment > M3: switching between CF interface and RAM

#94498 - Dwedit - Tue Jul 25, 2006 2:12 am

I'd like to load data from the CF, then switch back to the 32MB of RAM on the M3.
Since Moonshell's M3 loader plugin does it, how does it work?
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#94510 - Dwedit - Tue Jul 25, 2006 3:15 am

Never mind, found it buried in the moonshell source code:
Code:
// --- M3 stuff

static void SetM3_EnableCard(void)
{
   // run unlock sequence
   volatile unsigned short tmp ;
   tmp = *(volatile unsigned short *)0x08000000 ;
   tmp = *(volatile unsigned short *)0x08E00002 ;
   tmp = *(volatile unsigned short *)0x0800000E ;
   tmp = *(volatile unsigned short *)0x08801FFC ;
   tmp = *(volatile unsigned short *)0x0800104A ;
   tmp = *(volatile unsigned short *)0x08800612 ;
   tmp = *(volatile unsigned short *)0x08000000 ;
   tmp = *(volatile unsigned short *)0x08801B66 ;
   tmp = *(volatile unsigned short *)0x08800006 ;
   tmp = *(volatile unsigned short *)0x08000000 ;
}

static void SetM3_EnablePSRAM(void)
{
   // run unlock sequence
   volatile unsigned short tmp ;
   tmp = *(volatile unsigned short *)0x08000000 ;
   tmp = *(volatile unsigned short *)0x08E00002 ;
   tmp = *(volatile unsigned short *)0x0800000E ;
   tmp = *(volatile unsigned short *)0x08801FFC ;
   tmp = *(volatile unsigned short *)0x0800104A ;
   tmp = *(volatile unsigned short *)0x08800612 ;
   tmp = *(volatile unsigned short *)0x08000000 ;
   tmp = *(volatile unsigned short *)0x08801B66 ;
   tmp = *(volatile unsigned short *)0x08800004 ; // 0=bios?, 4 or c=8MByte?
   tmp = *(volatile unsigned short *)0x08000000 ;

        *(volatile u16*)0x09FFEFFE=0xAA55; // PepsiMan vote: The RAM on the M3 is made writable by writing 0xaa55 to 0x09ffeffe.
}

_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."