• Stars
    star
    147
  • Rank 251,347 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created over 6 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[WIP] C++ high-level JavaScript API for Nintendo 3DS/Switch

Brew.js - C++ high-level JavaScript API for Nintendo 3DS/Switch

  • Development version: 2.0 (only commits, still not released)

  • Latest released version: 1.0, very outdated, highly recommended to wait until 2.0 release

The engine: duktape

  • Duktape is an embeddable JavaScript engine, with a focus on portability and compact footprint, as it's described on its GitHub page.

  • It supports ES5 almost entirely, and a few elements of ES6. It has Node.js Buffer bindings and TypedArray from ES2015, plus a partial support of ECMAScript E6 and E7.

  • You can use duktape's functions from the code along with Brew.js API, but it's very unstable and it could fuck up the execution, so be sure to know what you're doing.

Platform support

  • Brew.js supports Nintendo 3DS (via libcrtu) and Nintendo Switch (libnx)

  • Originally, more platforms were going to be supported, but I've reached the conclusion that it's better yo focus and add more support on currently most important platforms.

  • That's why Nintendo DS support was deleted.

Basic examples of API usage

  • If you just want to evaluate JavaScript without messing up with the C++ API, that's easy to do:

  • First of all, include Brew.js's main header to use it. It may look like a JS file, but it is not:

#include <bjs/brew.js>
  • Then, create a environment and the native context to use within the environment:
bjs::js::NativeContext context = bjs::js::CreateContext();
bjs::Environment myenv(context);
  • There are 3 possibilities of evaluating JS source code:

    • From a std::string
    • From an external file
    • From a Node-like project (a folder with a package.json file)

    All of them return a execution result, which has information about the result of the execution (result string, original result type, whether it succeeded or failed...)

bjs::EvaluationResult res1 = myenv.EvaluateSourceCode("var num = 9;");
bjs::EvaluationResult res2 = myenv.EvaluateFile("sdmc:/test.js");
std::vector<bjs::Project> projects = myenv.GetProjectList("sdmc:/Projects");
bjs::EvaluationResult res3 = myenv.EvaluateProject(projects[0]);

Used extra libraries

  • duktape - lightweight C JavaScript engine, by svaarala
  • bitmap_image - C++ BMP image decoding and encoding, by ArashPartow
  • jsoncpp - modern JSON for C++, by nlohmann
  • nanojpeg - C JPEG image decoding and encoding, by Martin J. Fiedler
  • upng, C PNG image decoding and encoding, by elanthis
  • sf2dlib, C 3DS GPU rendering libraried (using citro3d), by xerpi

More Repositories

1

Goldleaf

๐Ÿ‚ Multipurpose homebrew tool for Nintendo Switch
C
2,619
star
2

uLaunch

๐Ÿš€ Custom, open-source qlaunch (Nintendo Switch HOME menu) replacement/reimplementation
C++
489
star
3

Plutonium

An easy-to-use UI framework for Nintendo Switch homebrew
C++
214
star
4

PlayerNX

First homebrew video player for Nintendo Switch! (using ffmpeg libraries)
C
62
star
5

NitroEdit

Nintendo DS(i) ROM editor for the Nintendo DS(i) consoles themselves
C++
51
star
6

fsp-usb

Custom Nintendo Switch service to mount and access USB drives
C
38
star
7

ModuleMania

Various useful sysmodules (kip files) for Nintendo Switch, to be used with CFW
C++
29
star
8

pegasus

Work-in-progress Nintendo Switch emulator, written in Rust and slightly less focused on gaming
Rust
22
star
9

libjavm

Small, header-only, zero-dependency C++17 Java VM library
C++
19
star
10

Brew.NET

Some homebrew tools written in C# and .NET - featuring NSPack (more soon!)
C#
17
star
11

CDNTool

CDN Nintendo's servers 3DS title downloader (as CIA)
CSS
15
star
12

CiaGenerate

Homebrew, DSiWare and retail CIA builder
Haxe
13
star
13

mint

Simple ecosystem for creating and compiling Visual Studio C# projects as Nintendo Switch homebrew, via Bridge.NET and QuickJS
C
13
star
14

LogViewer

Simple but useful UI to read Nintendo binary log files
C#
13
star
15

aoc-mitm

Mitm for aoc:u service, allowing for certain games to insta-unlock DLC
Rust
10
star
16

Biosphere-old

Bring life to Nintendo switch homebrew!
C
9
star
17

flog

Open-source flog (Nintendo Switch's Golf NES easter egg) reimplementation
C++
9
star
18

CustomKart

WPF program to easily create Mario Kart DS ROM hacks
C#
9
star
19

LogManager-reimpl

Custom reimplementation of LogManager service, redirecting logs to SD card
C++
9
star
20

bio.launch

PoC qlaunch replacement, written with C++ and Biosphere
C++
9
star
21

Trust

Rust + devkitPro (libnx) + Windows 10. Simple project for Nintendo Switch homebrew in Rust. (plus weird stuff I test with)
Rust
9
star
22

vax

Custom module/code injection ecosystem for Nintendo Switch games
C++
8
star
23

javm-nx-poc

[WIP] Java ecosystem PoC for Nintendo Switch homebrew using libjavm VM library
Makefile
7
star
24

cntx

Explore various Nintendo Switch file formats (PFS0, NCA) in pure Rust
Rust
5
star
25

Haywatch

Haylou Smart Watch 2 (LS02) reverse-engineering project
Rust
5
star
26

arc

Atmosphรจre (and custom) result database
Python
5
star
27

aarch64-switch-rs

Simple cross-compile aarch64 sample project and homebrew library made in nightly Rust
Rust
5
star
28

nashe

Intercepting NS service interfaces for fun and/or research I guess
Rust
4
star
29

ProjectGallium

Content mounting projects: homonym C++ libraries (hactool wrappers) + sysmodule implementing them [ncm:hbw]
C++
3
star
30

NXPlay

[Archive] NXPlay's sources, for historical purposes
C++
3
star
31

NSPD

My PoC test of NSP dumping (not recommended to use, Goldleaf already has NSP dumping)
C++
3
star
32

SaltyLime

๐Ÿ‹ SaltyNX plugin replacing nnMain entrypoint on any official game / title
C
3
star
33

lithium

Lightweight Nintendo Switch Title Installer
2
star
34

libnx-plus-plus

Simple, efficient, header-only C++17 libnx wrappers
C++
2
star
35

nn-dkA64

Skeleton project + guide to use nn official libraries on devkitPro + devkitA64
1
star
36

libnx-dyn

Dynamic modules in libnx
C
1
star
37

nx-webkit-tests

HTML
1
star
38

swipcgen

.NET Core application to translate SwIPC ID files to C, libnx-style IPC code
C#
1
star