Homebrew Homebrew game How to make a loading screen timer for a DS homebrew game?

andreixl5

Member
OP
Newcomer
Joined
Aug 19, 2024
Messages
10
Trophies
0
Age
25
XP
60
Country
Romania
Hello!

How can I make a loading screen that runs on a timer for a DS homebrew game? I don't want to load scenes too quickly and I need to create a "loading" transition between game states and scenes.

For example, when I start the game I show 2 logos on both screens, I want to display these logos for aprox. 3 seconds before fading out the screens and start a new timer for a loading screen that will lead to the main menu. I tried making this sort of thing using C++'s <thread> header, but unfortunately when I run the game with no$gba in debug this seems to crash my entire emulator. Maybe the ARM chips in the DS weren't made with multithreading in mind...

When I look at open-source DS homebrew games I can't find anything that would help me with loading screens, especially regarding my needs. Both devkitPro and nflib lack any examples for loading screens (or even fade in/out for that matter). What can I do here?
 

andreixl5

Member
OP
Newcomer
Joined
Aug 19, 2024
Messages
10
Trophies
0
Age
25
XP
60
Country
Romania
Not a DS dev so pardon any stupidity, but maybe a janky solution would be to just use loops with a counter, although maybe something like the GBA's timers might be useful?
https://problemkaputt.de/gbatek.htm#gbatimers

I would ideally aim for something hardware based though.

Or maybe even just sleep the CPU for the 3 seconds.
I managed to make the game run again by switching to usleep() but that doesn't seem to affect anything, the loading is still instantaneous. I see that the 3DS library has a dedicated sleep function, what would be an equivalent for GBA/DS?
 

tech3475

Well-Known Member
Member
Joined
Jun 12, 2009
Messages
3,895
Trophies
2
XP
6,490
Country
I managed to make the game run again by switching to usleep() but that doesn't seem to affect anything, the loading is still instantaneous. I see that the 3DS library has a dedicated sleep function, what would be an equivalent for GBA/DS?

How long are you sleeping for?
 

andreixl5

Member
OP
Newcomer
Joined
Aug 19, 2024
Messages
10
Trophies
0
Age
25
XP
60
Country
Romania
How long are you sleeping for?
I want the program to sleep for 3 seconds, I use a function that reads an integer representing the time in seconds and convert it into microseconds to be read by usleep:
void RunSleepStd(int seconds){ auto convertTime = std::chrono::microseconds(seconds * 1000000); usleep(convertTime.count()); }
 

tech3475

Well-Known Member
Member
Joined
Jun 12, 2009
Messages
3,895
Trophies
2
XP
6,490
Country
I want the program to sleep for 3 seconds, I use a function that reads an integer representing the time in seconds and convert it into microseconds to be read by usleep:
void RunSleepStd(int seconds){ auto convertTime = std::chrono::microseconds(seconds * 1000000); usleep(convertTime.count()); }

Maybe try just using a 'hardcoded' value, at least for testing e.g. usleep(3000000)?
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Psionic Roshambo @ Psionic Roshambo: I used to take plastic straws from fast food places and go to arcades and fix the machines...