? Detect sleep mode or home menu ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Creep into the Halloween / Horror Programming Contest (Deadline Extended)

Detect sleep mode or home menu

MILLISEC is a millisecond (1/1000) timer. It uses the 3DS's internal clock, which runs constantly. MAINCNT is a counter, which increments during screen refresh (59.834 times per second). Since this is controlled by SB, it doesn't happen during sleep mode or when you're on the home menu. When you go to the menu or close your 3DS, they become desynchronized, which is easy to detect. VAR _OLDMS%=MILLISEC VAR _OLDMC%=MAINCNT DEF PAUSED() VAR MS%=MILLISEC VAR MC%=MAINCNT VAR DIFF#=(MS%-_OLDMS%)-(MC%-_OLDMC%)/59.834*1000 '3DS runs at 59.834 FPS, not exactly 60 _OLDMS%=MS% _OLDMC%=MC% IF DIFF#<2 THEN DIFF#=0 'ignore differences of less than 2 milliseconds RETURN DIFF# ENDThis function does not need to run constantly. It will return the number of milliseconds spent in sleep mode or the home menu since the last call.
Author
12Me21
Updated
Rating
3 votes
Categories
Keywords
  • home
  • menu
  • sleep
  • mode
  • pause
  • millisec
  • maincnt
  • time
3 Comment(s) Picy3 Picy3 Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Disguised Hidden Website Night Person I like the quiet night and sleep late. Express Yourself oh awesome, so you could make it so after closing your 3ds the game auto pauses so when you come back it dosent automatically go.. right..? or a game about closing your 3ds lol. chicken chicken OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Avatar Embargo I didn't change my avatar for 90 days Website Good Page Hidden Achievements "HOW DARE YOU SHUT ME OUT WHILE I'M SPEAKING TO YOU?!" Picy3 Picy3 Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Disguised Hidden Website Night Person I like the quiet night and sleep late. Express Yourself ^IM USING THAT!!!^