Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01dda9d2ce |
||
|
|
497a079020 | ||
|
|
71d0f65903 | ||
|
|
4b7874c837 | ||
|
|
8937928b3e | ||
|
|
09b93cef62 |
||
|
|
075e6d34b0 |
4 changed files with 65 additions and 11 deletions
21
README.md
21
README.md
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
40
libnxGen.cfg
40
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]
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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) =
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue