Compare commits

...

7 commits

Author SHA1 Message Date
Joey
01dda9d2ce
Update README.md 2019-09-07 08:38:04 -06:00
Joey Yakimowich-Payne
497a079020 Version bump 2018-09-29 11:12:21 -06:00
Joey Yakimowich-Payne
71d0f65903 Fix graphics init error 2018-09-29 11:11:32 -06:00
Joey Yakimowich-Payne
4b7874c837 Fix more build script issues 2018-09-29 11:10:42 -06:00
Joey Yakimowich-Payne
8937928b3e Update config file for new libnx 2018-09-27 20:17:30 -06:00
Joey
09b93cef62
Update README.md 2018-07-20 17:19:24 +09:00
Joey
075e6d34b0
Update README.md 2018-07-20 17:15:18 +09:00
4 changed files with 65 additions and 11 deletions

View file

@ -1,11 +1,28 @@
# 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:
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`
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

View file

@ -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"

View file

@ -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]
@ -33,6 +34,9 @@ defines=true
[result.h]
defines = true
[thread_context.h]
preprocess = false
[hid.h]
defines = true
search.static_assert = "static_assert"
@ -165,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"
@ -309,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 = """
@ -345,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"

View file

@ -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) =