From 075e6d34b09d40e13b483cad13ceeeda1b862c8c Mon Sep 17 00:00:00 2001 From: Joey Date: Fri, 20 Jul 2018 17:15:18 +0900 Subject: [PATCH 1/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb016b7..8070620 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # nim-libnx -Libnx ported to the Nim programming language. You will need a nim compiler with Nintendo switch support which can be found [here](https://github.com/jyapayne/Nim/tree/nintendo_switch_support) until the PR is accepted. +Libnx ported to the Nim programming language. You will need a Nim compiler with Nintendo switch support which can be found in the latest devel branch of the Nim compiler. You also must have DevkitPro and switch (libnx) libraries for [Mac and Linux](https://github.com/devkitPro/pacman/releases) or [Windows](https://github.com/devkitPro/installer/releases) installed. The DEVKITPRO environment variable must also exist and point to a directory with the following structure: From 09b93cef6227a7457aeca16768eaac3515941d63 Mon Sep 17 00:00:00 2001 From: Joey Date: Fri, 20 Jul 2018 17:19:24 +0900 Subject: [PATCH 2/7] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 8070620..062feca 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,13 @@ You also must have DevkitPro and switch (libnx) libraries for [Mac and Linux](ht - `DEVKITPRO/libnx/lib` - `DEVKITPRO/libnx/include` +OR you must specify a valid libnx path and/or devkitpro path to the `switch_build` utility: + +```bash +switch_build --libnxPath:"C:\devkitPro\libnx" --author:"Joey" --version:"1.0.0" .\examples\accounts\account_ex.nim +# OR +switch_build --devkitProPath:"C:\devkitPro" --author:"Joey" --version:"1.0.0" .\examples\accounts\account_ex.nim +``` ## Install From 8937928b3e8568649cbfb5ae3f8f14e372ea98f1 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Thu, 27 Sep 2018 20:17:30 -0600 Subject: [PATCH 3/7] Update config file for new libnx --- libnxGen.cfg | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libnxGen.cfg b/libnxGen.cfg index f13d50d..e2e4ecf 100644 --- a/libnxGen.cfg +++ b/libnxGen.cfg @@ -8,13 +8,14 @@ filter=lock "${output}/nx/include" "${output}/nx/include/switch" "${output}/nx/include/switch/arm" -"${output}/nx/include/switch/kernel" -"${output}/nx/include/switch/services" "${output}/nx/include/switch/audio" -"${output}/nx/include/switch/gfx" +"${output}/nx/include/switch/display" +"${output}/nx/include/switch/kernel" +"${output}/nx/include/switch/nvidia" "${output}/nx/include/switch/runtime" "${output}/nx/include/switch/runtime/util" "${output}/nx/include/switch/runtime/devices" +"${output}/nx/include/switch/services" "${DEVKITPRO}/devkitA64/aarch64-none-elf/include/" [n.exclude] From 4b7874c83704f3c0afc48448d4347d9e8fecb036 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sat, 29 Sep 2018 11:10:42 -0600 Subject: [PATCH 4/7] Fix more build script issues --- libnxGen.cfg | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/libnxGen.cfg b/libnxGen.cfg index e2e4ecf..4404075 100644 --- a/libnxGen.cfg +++ b/libnxGen.cfg @@ -34,6 +34,9 @@ defines=true [result.h] defines = true +[thread_context.h] +preprocess = false + [hid.h] defines = true search.static_assert = "static_assert" @@ -166,6 +169,26 @@ import libnx/ext/integer128 template BIT*(n): auto = (1.uint shl n) """ +[thread_context.nim] +search.timport = "../types" +replace.timport = "libnx/wrapper/types" + +prepend.o = """ +import libnx/ext/integer128 +""" + +search.cpuall = "RegisterGroup_CpuAll =" +comment.cpuall = 1 + +search.fpugprs = "RegisterGroup_FpuGprs =" +prepend.fpugprs = "RegisterGroup_CpuAll = BIT(0) or BIT(1), ## /< All CPU registers." + +search.fpuall = "RegisterGroup_FpuGprs or RegisterGroup_FpuSprs" +replace.fpuall = "BIT(2) or BIT(3)" + +search.groupall = "RegisterGroup_CpuAll or RegisterGroup_FpuAll" +replace.groupall = "BIT(0) or BIT(1) or BIT(2) or BIT(3)" + [svc.nim] search.timport = "../types" replace.timport = "libnx/wrapper/types" @@ -310,6 +333,11 @@ prepend.o = """ import libnx/ext/integer128 """ +[fence.nim] +prepend.o = """ +import libnx/wrapper/types +""" + [cons.nim] search.o = "type\n" prepend.o = """ @@ -346,11 +374,16 @@ replace.threedmoo = "debugDevice_3DMOO*" search.timport = "../types" replace.timport = "libnx/wrapper/types" +search.fimport = "../nvidia/fence" +replace.fimport = "libnx/wrapper/fence" + [romfs_dev.nim] search.timport = "../types" replace.timport = "libnx/wrapper/types" search.servimport = "../services/" replace.servimport = "libnx/wrapper/" +search.o = "../libnx" +replace.o = "libnx" [n.sourcefile] "${output}/*.nim" From 71d0f65903611a81519f10c4fb7645f7e21b7dd4 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sat, 29 Sep 2018 11:11:32 -0600 Subject: [PATCH 5/7] Fix graphics init error --- src/libnx/graphics.nim | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/libnx/graphics.nim b/src/libnx/graphics.nim index 668ab0f..eedc9a2 100644 --- a/src/libnx/graphics.nim +++ b/src/libnx/graphics.nim @@ -2,10 +2,12 @@ import strutils import libnx/wrapper/types, libnx/wrapper/gfx, + libnx/results, libnx/utils type GraphicsError* = object of Exception + GraphicsInitError* = object of GraphicsError InitResolutionError* = object of GraphicsError CropBoundsError* = object of GraphicsError @@ -53,7 +55,12 @@ var enabled = false ## proc initDefault*() = if not enabled: - gfxInitDefault() + let code = gfxInitDefault().newResult + if code.failed: + raiseEx( + GraphicsInitError, + "Error, graphics could not be initialized", code + ) enabled = true ## * @@ -184,10 +191,6 @@ proc getFramebuffer*(): Framebuffer = ## / Sets the \ref GfxMode. proc setMode*(mode: GfxMode) = gfxSetMode(gfx.GfxMode(mode)) -## / Controls whether a vertical-flip is done when determining the pixel-offset within -## the actual framebuffer. By default this is enabled. -proc setDrawFlip*(enabled: bool) = gfxSetDrawFlip(enabled) - ## / Configures transform. See the NATIVE_WINDOW_TRANSFORM_* enums in buffer_producer.h. ## The default is NATIVE_WINDOW_TRANSFORM_FLIP_V. proc configureTransform*(transform: BufferTransform) = From 497a07902051bf2fefe6faf03063c8f9f2dd399d Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Sat, 29 Sep 2018 11:12:21 -0600 Subject: [PATCH 6/7] Version bump --- libnx.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnx.nimble b/libnx.nimble index b8e3758..6724840 100644 --- a/libnx.nimble +++ b/libnx.nimble @@ -1,6 +1,6 @@ # Package -version = "0.2.1" +version = "0.2.2" author = "Joey Payne" description = "Nintendo Switch library libnx for Nim." license = "The Unlicense" From 01dda9d2ce50f3a2fc5b2601f43ffe8e533aa01d Mon Sep 17 00:00:00 2001 From: Joey Date: Sat, 7 Sep 2019 08:38:04 -0600 Subject: [PATCH 7/7] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 062feca..3c398da 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,17 @@ # nim-libnx Libnx ported to the Nim programming language. You will need a Nim compiler with Nintendo switch support which can be found in the latest devel branch of the Nim compiler. -You also must have DevkitPro and switch (libnx) libraries for [Mac and Linux](https://github.com/devkitPro/pacman/releases) or [Windows](https://github.com/devkitPro/installer/releases) installed. The DEVKITPRO environment variable must also exist and point to a directory with the following structure: +You also must have DevkitPro and switch (libnx) libraries for [Mac and Linux](https://github.com/devkitPro/pacman/releases) or [Windows](https://github.com/devkitPro/installer/releases) installed. + +From dkp-pacman, the switch libraries can be installed with: + +``` +dkp-pacman -Syu +dkp-pacman -S switch-dev +## When it asks for installation options, choose the default which will install everything +``` + +The DEVKITPRO environment variable must also exist and point to a directory with the following structure: - `DEVKITPRO/libnx/lib` - `DEVKITPRO/libnx/include`