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 development > Booting into GBA mode

#161875 - cornaljoe - Sat Aug 16, 2008 2:33 pm

I'm using DevkitARM r21 and I can compile this code but GBA mode doesn't boot properly. I get a white screen on the screen set for GBA in the firmware and a black screen on the other. I can hear the GBA startup logo but nothing else just a white screen.

Code:

ARM9

#include <nds.h>

int main(void) {
    if(((PERSONAL_DATA *)0x023FFC80)->_user_data.gbaScreen) {
            REG_POWERCNT &= ~POWER_SWAP_LCDS;
    }
    else {
            REG_POWERCNT |= POWER_SWAP_LCDS;
    }
    return 0;
}

ARM7

#include <nds.h>

int main(void) {
    uint8 current, backlight;
    if(((PERSONAL_DATA *)0x023FFC80)->_user_data.gbaScreen) {
            backlight = ~PM_BACKLIGHT_TOP;
    }
    else {
            backlight = ~PM_BACKLIGHT_BOTTOM;
    }
    // Reset the clock if needed
    rtcReset();

    //enable sound
    powerON(POWER_SOUND);
    SOUND_CR = SOUND_ENABLE | SOUND_VOL(0x7F);

    REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz | SPI_CONTINUOUS;
    REG_SPIDATA = 0x80;

    SerialWaitBusy();
    REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHz ;
    REG_SPIDATA = 0;

    SerialWaitBusy();
    current = REG_SPIDATA & 0xff;

    current = current & backlight;

    SerialWaitBusy();
    REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHZ | SPI_CONTINUOUS;
    REG_SPIDATA = 0;
    SerialWaitBusy();
    REG_SPICNT = SPI_ENABLE | SPI_DEVICE_POWER | SPI_BAUD_1MHZ;
    REG_SPIDATA = current;

    SerialWaitBusy();
    swiSwitchToGBAMode();

    return 0;
}

#161889 - spinal_cord - Sun Aug 17, 2008 12:15 am

if you can hear the sound, and you have one white screen and one black, it seems to me that your screens are the wrong way round. Try not switching them.
_________________
I'm not a boring person, it's just that boring things keep happening to me.
Homepage

#161901 - cornaljoe - Mon Aug 18, 2008 2:18 am

The problem seems to be the code to initiate the bottom screen. If the top screen is set in the firmware it shows fine. I just removed the check for the firmware setting and put it on the top screen.

But now there is another problem. When it boots the Nintendo logo doesn't appear and it freezes at the GBA logo. I tested it on anotherr DS and it works. I believe this GBA boot code isn't compatible with newer DSL. Anyone know how this can be fixed?

#161902 - chuckstudios - Mon Aug 18, 2008 3:06 am

Try executing readUserSettings() before accessing the gbaScreen variable (it's used in the combined template).

However, I remembered having a similar issue and checked some old source:

Code:

   // read User Settings from firmware
   //readUserSettings();
   // what the fuck, wintermute? - this fubars PersonalData->_user_data.gbaScreen for some reason


But maybe your issue is the exact opposite of mine - your loader destroys that data and readUserSettings works fine now?

#161948 - cornaljoe - Wed Aug 20, 2008 12:37 am

Weird... I just went ahead and compiled the code in my project and it works. If I compile it as a standalone it still malfunctions.

I still have the problem with it not working on new DSL and some garbage gfx appearing in the border. I'll look into the problem and try to find a fix. I'll try clearing VRAM before the boot.