? Detect sleep mode or home menu ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password
Another contest? You asked for it!

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
10 Comment(s) DaSonicMario DaSonicMario Forum Contributor Hidden Achievements Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength how do you actually use this? i don't know how to use DEF lol TheV360 TheV360 April Fool's 2017 Contest Winner I won the SmileBASICSource April Fool's 2017 Contest! Programming Contest First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself DEF lets you make your own commands and functions. DEF TEST PRINT "Hello" ENDwould print "Hello" when you run it with TEST. More examples: DEF TALKPRINT T$ FOR I=0 TO LEN(T$)-1 PRINT T$[I] BEEP VSYNC 5 NEXT END TALKPRINT "blah blah blah" DEF ADD(NUM1,NUM2) RETURN NUM1+NUM2 END PRINT ADD(2,2)To run DEFined functions, just write their name like you would write PRINT. DaSonicMario DaSonicMario Forum Contributor Hidden Achievements Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength YOU DIDN'T EXPLAIN IT WELL ENOUGH! GIVE AN EXAMPLE OF WHAT TO DO TO GOTO A LABEL WITH THIS CODE PLS Lumage Lumage Head Admin Understanding is on you. A lot of your posts are low-quality or thoughtless, DaSonicMario. Please try to be more considerate; this is not miiverse and the expectations are different. DaSonicMario DaSonicMario Forum Contributor Hidden Achievements Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength i know it's not Miiverse but i thought it'd be similar to Miiverse. chicken chicken OSP Contest 1 Contest Participant I participated in the first SmileBASIC Source OSP Contest! Second Year My account is over 2 years old Website Good Page Hidden Achievements SBS is less of a get-help whereever whenever environment than Miiverse. You can learn a lot more here as well if you look and ask in the right places. Also, your question was in caps and badly phrased. Sometimes that will work, sometimes it won’t. But it’s usually the latter. Don’t use label loops, kids. Stay in WHILE and eat your DEFs. DaSonicMario DaSonicMario Forum Contributor Hidden Achievements Video Games I like to play video games! Hobbies Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength What. The. Heck? Picy3 Picy3 Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Banana For Scale Hidden Easter Eggs 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! Second Year My account is over 2 years old Website Good Page Hidden Achievements "HOW DARE YOU SHUT ME OUT WHILE I'M SPEAKING TO YOU?!" Picy3 Picy3 Halloween 2017 Contest Runner Up I placed 2nd in the SmileBASIC Source Halloween 2017 Contest! Programming Contest Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Banana For Scale Hidden Easter Eggs ^IM USING THAT!!!^