Rinnegatamante / lpp-3ds

Lua Player Plus for 3DS
GNU General Public License v3.0
179 stars 32 forks source link

[n3DS] Sleep Mode leads to Blackscreen #5

Open LauraWebdev opened 8 years ago

LauraWebdev commented 8 years ago

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:

Rinnegatamante commented 8 years ago

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.

gnmmarechal commented 8 years ago

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

Masamune3210 commented 7 years ago

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

SaturnSH2x2 commented 7 years ago

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.