Rinnegatamante/lpp-3ds

[n3DS] Sleep Mode leads to Blackscreen

Opened this issue · 4 comments

My System:
new 3DS, Europe, 10.0.1-27

Steps to reproduce the Issue:

  1. Download https://gbatemp.net/threads/release-super-simple-calculator.399475/ (or any other HB)
  2. Close the n3DS
  3. Open it again

What should happen:
The app initializes itself again

What happens instead:

  • blackscreen / no output
  • input does not work (neither does start)
  • to fix this state you have to completely hard-reset the 3DS

It's a common issue, apparently, removing SD card fix the output when this bug appears. I'm waitinh for NH 2.5 release to solve it cause it should bring home / power supports.

hum, I still have this issue, hax 2.7, 2DS 10.3.0. It's not troublesome, but it's annoying.

Still happens on o3DS, 11.3.0-36U, noticed on Homebr3w, as of 2/11/2017

Hope I'm not too late, but...

It's because the main program loop is under a while true do end loop; this ignores possible flags regarding sleep mode and such, which are normally processed by aptMainLoop(). See here: https://github.com/smealum/ctrulib/blob/master/libctru/source/services/apt.c#L499

I was able to fix this by adding System.mainLoop() function to the System module. This is essentially a wrapper for aptMainLoop(), thereby allowing support for sleep mode.

I tested this using this script on a Red N3DS, 11.3.0-36U, with A9LH, using a 3dsx build:

while System.mainLoop() do
	Screen.waitVblankStart()
	Screen.refresh()
	Screen.clear(TOP_SCREEN)

	pad = Controls.read()

	if Controls.check(pad, KEY_A) then
		System.exit()
	end

	Screen.debugPrint(0, 0, "Close the lid!", Color.new(255, 255, 255), TOP_SCREEN)

	Screen.flip()
end

In the future, while System.mainLoop() should be used in place of while true in Lua scripts.

Here's the commit in my fork of LPP-3DS: https://github.com/laxex/lpp-3ds/commit/fd574ea17132908d99cb64c2b49f1fccac496c65.

I created a pull request for this, just in case you want to add this feature.