Fix crash on app exit
This commit is contained in:
parent
446ffda6fe
commit
41ccfa39df
5 changed files with 44 additions and 6 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import sets, strutils
|
import sets, strutils
|
||||||
import libnx/graphics
|
import libnx/graphics
|
||||||
import libnx/wrapper/hid
|
import libnx/wrapper/con
|
||||||
import libnx/wrapper/console
|
|
||||||
import libnx/ext/integer128
|
import libnx/ext/integer128
|
||||||
import libnx/account
|
import libnx/account
|
||||||
import libnx/input
|
import libnx/input
|
||||||
|
|
@ -38,7 +37,6 @@ proc main() =
|
||||||
echo msg
|
echo msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mainLoop:
|
mainLoop:
|
||||||
let keysDown = keysDown(Controller.P1_AUTO)
|
let keysDown = keysDown(Controller.P1_AUTO)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import sets
|
import sets
|
||||||
import libnx/graphics
|
import libnx/graphics
|
||||||
import libnx/wrapper/console
|
import libnx/wrapper/con
|
||||||
import libnx/wrapper/hid
|
import libnx/wrapper/hid
|
||||||
import libnx/app
|
import libnx/app
|
||||||
import libnx/input
|
import libnx/input
|
||||||
|
|
||||||
|
|
||||||
proc main() =
|
proc main() =
|
||||||
initDefault()
|
initDefault()
|
||||||
discard consoleInit(nil)
|
discard consoleInit(nil)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Package
|
# Package
|
||||||
|
|
||||||
version = "0.1.2"
|
version = "0.1.3"
|
||||||
author = "Joey Payne"
|
author = "Joey Payne"
|
||||||
description = "Nintendo Switch library libnx for Nim."
|
description = "Nintendo Switch library libnx for Nim."
|
||||||
license = "The Unlicense"
|
license = "The Unlicense"
|
||||||
|
|
|
||||||
33
libnxGen.cfg
33
libnxGen.cfg
|
|
@ -22,6 +22,10 @@ filter=lock
|
||||||
"${output}/nim.cfg"
|
"${output}/nim.cfg"
|
||||||
"${output}/config.nims"
|
"${output}/config.nims"
|
||||||
|
|
||||||
|
[n.wildcard]
|
||||||
|
wildcard = "console.h"
|
||||||
|
rename = "$replace(console=con)"
|
||||||
|
|
||||||
[n.prepare]
|
[n.prepare]
|
||||||
git = "https://github.com/switchbrew/libnx"
|
git = "https://github.com/switchbrew/libnx"
|
||||||
execute = """
|
execute = """
|
||||||
|
|
@ -323,3 +327,32 @@ search.o = "import libnx"
|
||||||
prepend.o = """
|
prepend.o = """
|
||||||
import libnx/ext/integer128
|
import libnx/ext/integer128
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
[con.nim]
|
||||||
|
search.o = "type\n"
|
||||||
|
prepend.o = """
|
||||||
|
|
||||||
|
template CONSOLE_ESC*(x: string): string = "\x1b[" & $x
|
||||||
|
# Colors
|
||||||
|
template CONSOLE_RESET*: string = CONSOLE_ESC("0m")
|
||||||
|
template CONSOLE_BLACK*: string = CONSOLE_ESC("30m")
|
||||||
|
template CONSOLE_RED*: string = CONSOLE_ESC("31;1m")
|
||||||
|
template CONSOLE_GREEN*: string = CONSOLE_ESC("32;1m")
|
||||||
|
template CONSOLE_YELLOW*: string = CONSOLE_ESC("33;1m")
|
||||||
|
template CONSOLE_BLUE*: string = CONSOLE_ESC("34;1m")
|
||||||
|
template CONSOLE_MAGENTA*: string = CONSOLE_ESC("35;1m")
|
||||||
|
template CONSOLE_CYAN*: string = CONSOLE_ESC("36;1m")
|
||||||
|
template CONSOLE_WHITE*: string = CONSOLE_ESC("37;1m")
|
||||||
|
|
||||||
|
# Styles
|
||||||
|
template CONSOLE_COLOR_BOLD*: int = (1 shl 0)
|
||||||
|
template CONSOLE_COLOR_FAINT*: int = (1 shl 1)
|
||||||
|
template CONSOLE_ITALIC*: int = (1 shl 2)
|
||||||
|
template CONSOLE_UNDERLINE*: int = (1 shl 3)
|
||||||
|
template CONSOLE_BLINK_SLOW*: int =(1 shl 4)
|
||||||
|
template CONSOLE_BLINK_FAST*: int = (1 shl 5)
|
||||||
|
template CONSOLE_COLOR_REVERSE*: int = (1 shl 6)
|
||||||
|
template CONSOLE_CONCEAL*: int = (1 shl 7)
|
||||||
|
template CONSOLE_CROSSED_OUT*: int = (1 shl 8)
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,13 @@ proc initDefault*() =
|
||||||
## @warning Do not use \ref viExit when using this function.
|
## @warning Do not use \ref viExit when using this function.
|
||||||
##
|
##
|
||||||
proc exit*() =
|
proc exit*() =
|
||||||
|
# XXX Important!!! This deallocHeap call must be here
|
||||||
|
# in order for the switch not to crash. It must be run right
|
||||||
|
# before gfxExit() to leave a clean slate in the OS. This call
|
||||||
|
# will disable any further allocations and free all consumed
|
||||||
|
# memory on the heap.
|
||||||
if enabled:
|
if enabled:
|
||||||
|
deallocHeap(runFinalizers = true, allowGcAfterwards = false)
|
||||||
gfxExit()
|
gfxExit()
|
||||||
enabled = false
|
enabled = false
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue