This commit is contained in:
Zy 2024-09-26 00:59:50 +02:00
parent 38b8fa6c79
commit 82cca59ddd
90 changed files with 18056 additions and 28 deletions

17
.vscode/c_cpp_properties.json vendored Normal file
View file

@ -0,0 +1,17 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/.vscode/dummyinclude/"
],
"defines": [],
"compilerPath": "/usr/bin/clang",
"cStandard": "c17",
"cppStandard": "c++14",
"intelliSenseMode": "linux-clang-x64"
}
],
"version": 4
}

154
.vscode/dummyinclude/3ds.h vendored Normal file
View file

@ -0,0 +1,154 @@
/**
* @file 3ds.h
* @brief Central 3DS header. Includes all others.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_3DS) && !defined(__3DS__)
#warning "Please update your Makefile and replace -DARM11 -D_3DS with -D__3DS__"
#define __3DS__
#endif
//might be missing some
#include <3ds/types.h>
#include <3ds/result.h>
#include <3ds/ipc.h>
#include <3ds/svc.h>
#include <3ds/exheader.h>
#include <3ds/srv.h>
#include <3ds/errf.h>
#include <3ds/os.h>
#include <3ds/synchronization.h>
#include <3ds/thread.h>
#include <3ds/gfx.h>
#include <3ds/console.h>
#include <3ds/env.h>
#include <3ds/util/decompress.h>
#include <3ds/util/utf.h>
#include <3ds/allocator/linear.h>
#include <3ds/allocator/mappable.h>
#include <3ds/allocator/vram.h>
#include <3ds/services/ac.h>
#include <3ds/services/am.h>
#include <3ds/services/ampxi.h>
#include <3ds/services/apt.h>
#include <3ds/services/boss.h>
#include <3ds/services/cam.h>
#include <3ds/services/cfgnor.h>
#include <3ds/services/cfgu.h>
#include <3ds/services/csnd.h>
#include <3ds/services/dsp.h>
#include <3ds/services/fs.h>
#include <3ds/services/fspxi.h>
#include <3ds/services/fsreg.h>
#include <3ds/services/frd.h>
#include <3ds/services/gspgpu.h>
#include <3ds/services/gsplcd.h>
#include <3ds/services/hid.h>
#include <3ds/services/irrst.h>
#include <3ds/services/sslc.h>
#include <3ds/services/httpc.h>
#include <3ds/services/uds.h>
#include <3ds/services/ndm.h>
#include <3ds/services/nim.h>
#include <3ds/services/nwmext.h>
#include <3ds/services/ir.h>
#include <3ds/services/ns.h>
#include <3ds/services/pmapp.h>
#include <3ds/services/pmdbg.h>
#include <3ds/services/ps.h>
#include <3ds/services/ptmu.h>
#include <3ds/services/ptmsysm.h>
#include <3ds/services/ptmgets.h>
#include <3ds/services/ptmsets.h>
#include <3ds/services/pxidev.h>
#include <3ds/services/pxipm.h>
#include <3ds/services/soc.h>
#include <3ds/services/mic.h>
#include <3ds/services/mvd.h>
#include <3ds/services/nfc.h>
#include <3ds/services/news.h>
#include <3ds/services/qtm.h>
#include <3ds/services/qtmc.h>
#include <3ds/services/srvpm.h>
#include <3ds/services/loader.h>
#include <3ds/services/y2r.h>
#include <3ds/services/mcuhwc.h>
#include <3ds/services/cdcchk.h>
#include <3ds/gpu/gx.h>
#include <3ds/gpu/gpu.h>
#include <3ds/gpu/shbin.h>
#include <3ds/gpu/shaderProgram.h>
#include <3ds/ndsp/ndsp.h>
#include <3ds/ndsp/channel.h>
#include <3ds/applets/swkbd.h>
#include <3ds/applets/error.h>
#include <3ds/applets/miiselector.h>
#include <3ds/archive.h>
#include <3ds/romfs.h>
#include <3ds/font.h>
#include <3ds/mii.h>
#include <3ds/gdbhio_dev.h>
#include <3ds/3dslink.h>
#ifdef __cplusplus
}
#endif
/**
* @example app_launch/source/main.c
* @example audio/filters/source/main.c
* @example audio/mic/source/main.c
* @example audio/streaming/source/main.c
* @example camera/image/source/main.c
* @example camera/video/source/main.c
* @example get_system_language/source/main.c
* @example graphics/bitmap/24bit-color/source/main.c
* @example graphics/gpu/both_screens/source/main.c
* @example graphics/gpu/fragment_light/source/main.c
* @example graphics/gpu/geoshader/source/main.c
* @example graphics/gpu/gpusprites/source/main.c
* @example graphics/gpu/immediate/source/main.c
* @example graphics/gpu/lenny/source/main.c
* @example graphics/gpu/loop_subdivision/source/main.c
* @example graphics/gpu/mipmap_fog/source/main.c
* @example graphics/gpu/particles/source/main.c
* @example graphics/gpu/proctex/source/main.c
* @example graphics/gpu/simple_tri/source/main.c
* @example graphics/gpu/textured_cube/source/main.c
* @example graphics/gpu/toon_shading/source/main.c
* @example graphics/printing/both-screen-text/source/main.c
* @example graphics/printing/colored-text/source/main.c
* @example graphics/printing/hello-world/source/main.c
* @example graphics/printing/multiple-windows-text/source/main.c
* @example graphics/printing/system-font/source/main.c
* @example input/read-controls/source/main.c
* @example input/software-keyboard/source/main.c
* @example input/touch-screen/source/main.c
* @example libapplet_launch/source/main.c
* @example mvd/source/main.c
* @example network/boss/source/main.c
* @example network/http/source/main.c
* @example network/http_post/source/main.c
* @example network/sockets/source/sockets.c
* @example network/sslc/source/ssl.c
* @example network/uds/source/uds.c
* @example nfc/source/main.c
* @example qtm/source/main.c
* @example romfs/source/main.c
* @example sdmc/source/main.c
* @example threads/event/source/main.c
* @example threads/thread-basic/source/main.c
* @example time/rtc/source/main.c
*/

34
.vscode/dummyinclude/3ds/3dslink.h vendored Normal file
View file

@ -0,0 +1,34 @@
/**
* @file 3dslink.h
* @brief Netloader (3dslink) utilities
*/
#pragma once
#include <stdbool.h>
struct in_addr;
/// Address of the host connected through 3dslink
extern struct in_addr __3dslink_host;
#define LINK3DS_COMM_PORT 17491 ///< 3dslink TCP server port
/**
* @brief Connects to the 3dslink host, setting up an output stream.
* @param[in] redirStdout Whether to redirect stdout to nxlink output.
* @param[in] redirStderr Whether to redirect stderr to nxlink output.
* @return Socket fd on success, negative number on failure.
* @note The socket should be closed with close() during application cleanup.
*/
int link3dsConnectToHost(bool redirStdout, bool redirStderr);
/// Same as \ref link3dsConnectToHost but redirecting both stdout/stderr.
static inline int link3dsStdio(void) {
return link3dsConnectToHost(true, true);
}
/// Same as \ref link3dsConnectToHost but redirecting only stderr.
static inline int link3dsStdioForDebug(void) {
return link3dsConnectToHost(false, true);
}

View file

@ -0,0 +1,49 @@
/**
* @file linear.h
* @brief Linear memory allocator.
*/
#pragma once
#include <stddef.h>
/**
* @brief Allocates a 0x80-byte aligned buffer.
* @param size Size of the buffer to allocate.
* @return The allocated buffer.
*/
void* linearAlloc(size_t size);
/**
* @brief Allocates a buffer aligned to the given size.
* @param size Size of the buffer to allocate.
* @param alignment Alignment to use.
* @return The allocated buffer.
*/
void* linearMemAlign(size_t size, size_t alignment);
/**
* @brief Reallocates a buffer.
* Note: Not implemented yet.
* @param mem Buffer to reallocate.
* @param size Size of the buffer to allocate.
* @return The reallocated buffer.
*/
void* linearRealloc(void* mem, size_t size);
/**
* @brief Retrieves the allocated size of a buffer.
* @return The size of the buffer.
*/
size_t linearGetSize(void* mem);
/**
* @brief Frees a buffer.
* @param mem Buffer to free.
*/
void linearFree(void* mem);
/**
* @brief Gets the current linear free space.
* @return The current linear free space.
*/
u32 linearSpaceFree(void);

View file

@ -0,0 +1,27 @@
/**
* @file mappable.h
* @brief Mappable memory allocator.
*/
#pragma once
#include <3ds/types.h>
/**
* @brief Initializes the mappable allocator.
* @param addrMin Minimum address.
* @param addrMax Maxium address.
*/
void mappableInit(u32 addrMin, u32 addrMax);
/**
* @brief Finds a mappable memory area.
* @param size Size of the area to find.
* @return The mappable area.
*/
void* mappableAlloc(size_t size);
/**
* @brief Frees a mappable area (stubbed).
* @param mem Mappable area to free.
*/
void mappableFree(void* mem);

View file

@ -0,0 +1,71 @@
/**
* @file vram.h
* @brief VRAM allocator.
*/
#pragma once
typedef enum vramAllocPos
{
VRAM_ALLOC_A = BIT(0),
VRAM_ALLOC_B = BIT(1),
VRAM_ALLOC_ANY = VRAM_ALLOC_A | VRAM_ALLOC_B,
} vramAllocPos;
/**
* @brief Allocates a 0x80-byte aligned buffer.
* @param size Size of the buffer to allocate.
* @return The allocated buffer.
*/
void* vramAlloc(size_t size);
/**
* @brief Allocates a 0x80-byte aligned buffer in the given VRAM bank.
* @param size Size of the buffer to allocate.
* @param pos VRAM bank to use (see \ref vramAllocPos).
* @return The allocated buffer.
*/
void* vramAllocAt(size_t size, vramAllocPos pos);
/**
* @brief Allocates a buffer aligned to the given size.
* @param size Size of the buffer to allocate.
* @param alignment Alignment to use.
* @return The allocated buffer.
*/
void* vramMemAlign(size_t size, size_t alignment);
/**
* @brief Allocates a buffer aligned to the given size in the given VRAM bank.
* @param size Size of the buffer to allocate.
* @param alignment Alignment to use.
* @param pos VRAM bank to use (see \ref vramAllocPos).
* @return The allocated buffer.
*/
void* vramMemAlignAt(size_t size, size_t alignment, vramAllocPos pos);
/**
* @brief Reallocates a buffer.
* Note: Not implemented yet.
* @param mem Buffer to reallocate.
* @param size Size of the buffer to allocate.
* @return The reallocated buffer.
*/
void* vramRealloc(void* mem, size_t size);
/**
* @brief Retrieves the allocated size of a buffer.
* @return The size of the buffer.
*/
size_t vramGetSize(void* mem);
/**
* @brief Frees a buffer.
* @param mem Buffer to free.
*/
void vramFree(void* mem);
/**
* @brief Gets the current VRAM free space.
* @return The current VRAM free space.
*/
u32 vramSpaceFree(void);

View file

@ -0,0 +1,91 @@
/**
* @file error.h
* @brief Error applet.
*/
#pragma once
#include <3ds/types.h>
enum
{
ERROR_LANGUAGE_FLAG = 0x100, ///<??-Unknown flag
ERROR_WORD_WRAP_FLAG = 0x200 ///<??-Unknown flag
};
///< Type of Error applet to be called
typedef enum
{
ERROR_CODE = 0, ///< Displays the infrastructure communications-related error message corresponding to the error code.
ERROR_TEXT, ///< Displays text passed to this applet.
ERROR_EULA, ///< Displays the EULA
ERROR_TYPE_EULA_FIRST_BOOT, ///< Use prohibited.
ERROR_TYPE_EULA_DRAW_ONLY, ///< Use prohibited.
ERROR_TYPE_AGREE, ///< Use prohibited.
ERROR_CODE_LANGUAGE = ERROR_CODE | ERROR_LANGUAGE_FLAG, ///< Displays a network error message in a specified language.
ERROR_TEXT_LANGUAGE = ERROR_TEXT | ERROR_LANGUAGE_FLAG, ///< Displays text passed to this applet in a specified language.
ERROR_EULA_LANGUAGE = ERROR_EULA | ERROR_LANGUAGE_FLAG, ///< Displays EULA in a specified language.
ERROR_TEXT_WORD_WRAP = ERROR_TEXT | ERROR_WORD_WRAP_FLAG,///< Displays the custom error message passed to this applet with automatic line wrapping
ERROR_TEXT_LANGUAGE_WORD_WRAP = ERROR_TEXT | ERROR_LANGUAGE_FLAG | ERROR_WORD_WRAP_FLAG ///< Displays the custom error message with automatic line wrapping and in the specified language.
}errorType;
///< Flags for the Upper Screen.Does nothing even if specified.
typedef enum
{
ERROR_NORMAL = 0,
ERROR_STEREO
}errorScreenFlag;
///< Return code of the Error module.Use UNKNOWN for simple apps.
typedef enum
{
ERROR_UNKNOWN = -1,
ERROR_NONE = 0,
ERROR_SUCCESS,
ERROR_NOT_SUPPORTED,
ERROR_HOME_BUTTON = 10,
ERROR_SOFTWARE_RESET,
ERROR_POWER_BUTTON
}errorReturnCode;
///< Structure to be passed to the applet.Shouldn't be modified directly.
typedef struct
{
errorType type;
int errorCode;
errorScreenFlag upperScreenFlag;
u16 useLanguage;
u16 Text[1900];
bool homeButton;
bool softwareReset;
bool appJump;
errorReturnCode returnCode;
u16 eulaVersion;
}errorConf;
/**
* @brief Init the error applet.
* @param err Pointer to errorConf.
* @param type errorType Type of error.
* @param lang CFG_Language Lang of error.
*/
void errorInit(errorConf* err, errorType type, CFG_Language lang);
/**
* @brief Sets error code to display.
* @param err Pointer to errorConf.
* @param error Error-code to display.
*/
void errorCode(errorConf* err, int error);
/**
* @brief Sets error text to display.
* @param err Pointer to errorConf.
* @param text Error-text to display.
*/
void errorText(errorConf* err, const char* text);
/**
* @brief Displays the error applet.
* @param err Pointer to errorConf.
*/
void errorDisp(errorConf* err);

View file

@ -0,0 +1,188 @@
/**
* @file miiselector.h
* @brief Mii Selector Applet (appletEd).
*/
#pragma once
#include <3ds/types.h>
#include <3ds/mii.h>
/// Magic value needed to launch the applet.
#define MIISELECTOR_MAGIC 0x13DE28CF
/// Maximum length of title to be displayed at the top of the Mii selector applet
#define MIISELECTOR_TITLE_LEN 64
/// Number of Guest Miis available for selection
#define MIISELECTOR_GUESTMII_SLOTS 6
/// Maximum number of user Miis available for selection
#define MIISELECTOR_USERMII_SLOTS 100
/// Parameter structure passed to AppletEd
typedef struct
{
u8 enable_cancel_button; ///< Enables canceling of selection if nonzero.
u8 enable_selecting_guests; ///< Makes Guets Miis selectable if nonzero.
u8 show_on_top_screen; ///< Shows applet on top screen if nonzero,
///< otherwise show it on the bottom screen.
u8 _unk0x3[5]; ///< @private
u16 title[MIISELECTOR_TITLE_LEN]; ///< UTF16-LE string displayed at the top of the applet. If
///< set to the empty string, a default title is displayed.
u8 _unk0x88[4]; ///< @private
u8 show_guest_page; ///< If nonzero, the applet shows a page with Guest
///< Miis on launch.
u8 _unk0x8D[3]; ///< @private
u32 initial_index; ///< Index of the initially selected Mii. If
///< @ref MiiSelectorConf.show_guest_page is
///< set, this is the index of a Guest Mii,
///< otherwise that of a user Mii.
u8 mii_guest_whitelist[MIISELECTOR_GUESTMII_SLOTS]; ///< Each byte set to a nonzero value
///< enables its corresponding Guest
///< Mii to be enabled for selection.
u8 mii_whitelist[MIISELECTOR_USERMII_SLOTS]; ///< Each byte set to a nonzero value enables
///< its corresponding user Mii to be enabled
///< for selection.
u16 _unk0xFE; ///< @private
u32 magic; ///< Will be set to @ref MIISELECTOR_MAGIC before launching the
///< applet.
} MiiSelectorConf;
/// Maximum length of the localized name of a Guest Mii
#define MIISELECTOR_GUESTMII_NAME_LEN 12
/// Structure written by AppletEd
typedef struct
{
u32 no_mii_selected; ///< 0 if a Mii was selected, 1 if the selection was
///< canceled.
u32 guest_mii_was_selected; ///< 1 if a Guest Mii was selected, 0 otherwise.
u32 guest_mii_index; ///< Index of the selected Guest Mii,
///< 0xFFFFFFFF if no guest was selected.
MiiData mii; ///< Data of selected Mii.
u16 _pad0x68; ///< @private
u16 checksum; ///< Checksum of the returned Mii data.
///< Stored as a big-endian value; use
///< @ref miiSelectorChecksumIsValid to
///< verify.
u16 guest_mii_name[MIISELECTOR_GUESTMII_NAME_LEN]; ///< Localized name of a Guest Mii,
///< if one was selected (UTF16-LE
///< string). Zeroed otherwise.
} MiiSelectorReturn;
/// AppletEd options
enum
{
MIISELECTOR_CANCEL = BIT(0), ///< Show the cancel button
MIISELECTOR_GUESTS = BIT(1), ///< Make Guets Miis selectable
MIISELECTOR_TOP = BIT(2), ///< Show AppletEd on top screen
MIISELECTOR_GUESTSTART = BIT(3), ///< Start on guest page
};
/**
* @brief Initialize Mii selector config
* @param conf Pointer to Miiselector config.
*/
void miiSelectorInit(MiiSelectorConf *conf);
/**
* @brief Launch the Mii selector library applet
*
* @param conf Configuration determining how the applet should behave
*/
void miiSelectorLaunch(const MiiSelectorConf *conf, MiiSelectorReturn* returnbuf);
/**
* @brief Sets title of the Mii selector library applet
*
* @param conf Pointer to miiSelector configuration
* @param text Title text of Mii selector
*/
void miiSelectorSetTitle(MiiSelectorConf *conf, const char* text);
/**
* @brief Specifies which special options are enabled in the Mii selector
*
* @param conf Pointer to miiSelector configuration
* @param options Options bitmask
*/
void miiSelectorSetOptions(MiiSelectorConf *conf, u32 options);
/**
* @brief Specifies which guest Miis will be selectable
*
* @param conf Pointer to miiSelector configuration
* @param index Index of the guest Miis that will be whitelisted.
* @ref MIISELECTOR_GUESTMII_SLOTS can be used to whitelist all the guest Miis.
*/
void miiSelectorWhitelistGuestMii(MiiSelectorConf *conf, u32 index);
/**
* @brief Specifies which guest Miis will be unselectable
*
* @param conf Pointer to miiSelector configuration
* @param index Index of the guest Miis that will be blacklisted.
* @ref MIISELECTOR_GUESTMII_SLOTS can be used to blacklist all the guest Miis.
*/
void miiSelectorBlacklistGuestMii(MiiSelectorConf *conf, u32 index);
/**
* @brief Specifies which user Miis will be selectable
*
* @param conf Pointer to miiSelector configuration
* @param index Index of the user Miis that will be whitelisted.
* @ref MIISELECTOR_USERMII_SLOTS can be used to whitlist all the user Miis
*/
void miiSelectorWhitelistUserMii(MiiSelectorConf *conf, u32 index);
/**
* @brief Specifies which user Miis will be selectable
*
* @param conf Pointer to miiSelector configuration
* @param index Index of the user Miis that will be blacklisted.
* @ref MIISELECTOR_USERMII_SLOTS can be used to blacklist all the user Miis
*/
void miiSelectorBlacklistUserMii(MiiSelectorConf *conf, u32 index);
/**
* @brief Specifies which Mii the cursor should start from
*
* @param conf Pointer to miiSelector configuration
* @param index Indexed number of the Mii that the cursor will start on.
* If there is no mii with that index, the the cursor will start at the Mii
* with the index 0 (the personal Mii).
*/
static inline void miiSelectorSetInitialIndex(MiiSelectorConf *conf, u32 index)
{
conf->initial_index = index;
}
/**
* @brief Get Mii name
*
* @param returnbuf Pointer to miiSelector return
* @param out String containing a Mii's name
* @param max_size Size of string. Since UTF8 characters range in size from 1-3 bytes
* (assuming that no non-BMP characters are used), this value should be 36 (or 30 if you are not
* dealing with guest miis).
*/
void miiSelectorReturnGetName(const MiiSelectorReturn *returnbuf, char* out, size_t max_size);
/**
* @brief Get Mii Author
*
* @param returnbuf Pointer to miiSelector return
* @param out String containing a Mii's author
* @param max_size Size of string. Since UTF8 characters range in size from 1-3 bytes
* (assuming that no non-BMP characters are used), this value should be 30.
*/
void miiSelectorReturnGetAuthor(const MiiSelectorReturn *returnbuf, char* out, size_t max_size);
/**
* @brief Verifies that the Mii data returned from the applet matches its
* checksum
*
* @param returnbuf Buffer filled by Mii selector applet
* @return `true` if `returnbuf->checksum` is the same as the one computed from `returnbuf`
*/
bool miiSelectorChecksumIsValid(const MiiSelectorReturn *returnbuf);

321
.vscode/dummyinclude/3ds/applets/swkbd.h vendored Normal file
View file

@ -0,0 +1,321 @@
/**
* @file swkbd.h
* @brief Software keyboard applet.
*/
#pragma once
#include <3ds/types.h>
/// Keyboard types.
typedef enum
{
SWKBD_TYPE_NORMAL = 0, ///< Normal keyboard with several pages (QWERTY/accents/symbol/mobile)
SWKBD_TYPE_QWERTY, ///< QWERTY keyboard only.
SWKBD_TYPE_NUMPAD, ///< Number pad.
SWKBD_TYPE_WESTERN, ///< On JPN systems, a text keyboard without Japanese input capabilities, otherwise same as SWKBD_TYPE_NORMAL.
} SwkbdType;
/// Accepted input types.
typedef enum
{
SWKBD_ANYTHING = 0, ///< All inputs are accepted.
SWKBD_NOTEMPTY, ///< Empty inputs are not accepted.
SWKBD_NOTEMPTY_NOTBLANK, ///< Empty or blank inputs (consisting solely of whitespace) are not accepted.
SWKBD_NOTBLANK_NOTEMPTY = SWKBD_NOTEMPTY_NOTBLANK,
SWKBD_NOTBLANK, ///< Blank inputs (consisting solely of whitespace) are not accepted, but empty inputs are.
SWKBD_FIXEDLEN, ///< The input must have a fixed length (specified by maxTextLength in swkbdInit).
} SwkbdValidInput;
/// Keyboard dialog buttons.
typedef enum
{
SWKBD_BUTTON_LEFT = 0, ///< Left button (usually Cancel)
SWKBD_BUTTON_MIDDLE, ///< Middle button (usually I Forgot)
SWKBD_BUTTON_RIGHT, ///< Right button (usually OK)
SWKBD_BUTTON_CONFIRM = SWKBD_BUTTON_RIGHT,
SWKBD_BUTTON_NONE, ///< No button (returned by swkbdInputText in special cases)
} SwkbdButton;
/// Keyboard password modes.
typedef enum
{
SWKBD_PASSWORD_NONE = 0, ///< Characters are not concealed.
SWKBD_PASSWORD_HIDE, ///< Characters are concealed immediately.
SWKBD_PASSWORD_HIDE_DELAY, ///< Characters are concealed a second after they've been typed.
} SwkbdPasswordMode;
/// Keyboard input filtering flags.
enum
{
SWKBD_FILTER_DIGITS = BIT(0), ///< Disallow the use of more than a certain number of digits (0 or more)
SWKBD_FILTER_AT = BIT(1), ///< Disallow the use of the @ sign.
SWKBD_FILTER_PERCENT = BIT(2), ///< Disallow the use of the % sign.
SWKBD_FILTER_BACKSLASH = BIT(3), ///< Disallow the use of the \ sign.
SWKBD_FILTER_PROFANITY = BIT(4), ///< Disallow profanity using Nintendo's profanity filter.
SWKBD_FILTER_CALLBACK = BIT(5), ///< Use a callback in order to check the input.
};
/// Keyboard features.
enum
{
SWKBD_PARENTAL = BIT(0), ///< Parental PIN mode.
SWKBD_DARKEN_TOP_SCREEN = BIT(1), ///< Darken the top screen when the keyboard is shown.
SWKBD_PREDICTIVE_INPUT = BIT(2), ///< Enable predictive input (necessary for Kanji input in JPN systems).
SWKBD_MULTILINE = BIT(3), ///< Enable multiline input.
SWKBD_FIXED_WIDTH = BIT(4), ///< Enable fixed-width mode.
SWKBD_ALLOW_HOME = BIT(5), ///< Allow the usage of the HOME button.
SWKBD_ALLOW_RESET = BIT(6), ///< Allow the usage of a software-reset combination.
SWKBD_ALLOW_POWER = BIT(7), ///< Allow the usage of the POWER button.
SWKBD_DEFAULT_QWERTY = BIT(9), ///< Default to the QWERTY page when the keyboard is shown.
};
/// Keyboard filter callback return values.
typedef enum
{
SWKBD_CALLBACK_OK = 0, ///< Specifies that the input is valid.
SWKBD_CALLBACK_CLOSE, ///< Displays an error message, then closes the keyboard.
SWKBD_CALLBACK_CONTINUE, ///< Displays an error message and continues displaying the keyboard.
} SwkbdCallbackResult;
/// Keyboard return values.
typedef enum
{
SWKBD_NONE = -1, ///< Dummy/unused.
SWKBD_INVALID_INPUT = -2, ///< Invalid parameters to swkbd.
SWKBD_OUTOFMEM = -3, ///< Out of memory.
SWKBD_D0_CLICK = 0, ///< The button was clicked in 1-button dialogs.
SWKBD_D1_CLICK0, ///< The left button was clicked in 2-button dialogs.
SWKBD_D1_CLICK1, ///< The right button was clicked in 2-button dialogs.
SWKBD_D2_CLICK0, ///< The left button was clicked in 3-button dialogs.
SWKBD_D2_CLICK1, ///< The middle button was clicked in 3-button dialogs.
SWKBD_D2_CLICK2, ///< The right button was clicked in 3-button dialogs.
SWKBD_HOMEPRESSED = 10, ///< The HOME button was pressed.
SWKBD_RESETPRESSED, ///< The soft-reset key combination was pressed.
SWKBD_POWERPRESSED, ///< The POWER button was pressed.
SWKBD_PARENTAL_OK = 20, ///< The parental PIN was verified successfully.
SWKBD_PARENTAL_FAIL, ///< The parental PIN was incorrect.
SWKBD_BANNED_INPUT = 30, ///< The filter callback returned SWKBD_CALLBACK_CLOSE.
} SwkbdResult;
/// Maximum dictionary word length, in UTF-16 code units.
#define SWKBD_MAX_WORD_LEN 40
/// Maximum button text length, in UTF-16 code units.
#define SWKBD_MAX_BUTTON_TEXT_LEN 16
/// Maximum hint text length, in UTF-16 code units.
#define SWKBD_MAX_HINT_TEXT_LEN 64
/// Maximum filter callback error message length, in UTF-16 code units.
#define SWKBD_MAX_CALLBACK_MSG_LEN 256
/// Keyboard dictionary word for predictive input.
typedef struct
{
u16 reading[SWKBD_MAX_WORD_LEN+1]; ///< Reading of the word (that is, the string that needs to be typed).
u16 word[SWKBD_MAX_WORD_LEN+1]; ///< Spelling of the word.
u8 language; ///< Language the word applies to.
bool all_languages; ///< Specifies if the word applies to all languages.
} SwkbdDictWord;
/// Keyboard filter callback function.
typedef SwkbdCallbackResult (* SwkbdCallbackFn)(void* user, const char** ppMessage, const char* text, size_t textlen);
/// Keyboard status data.
typedef struct { u32 data[0x11]; } SwkbdStatusData;
/// Keyboard predictive input learning data.
typedef struct { u32 data[0x291B]; } SwkbdLearningData;
/// Internal libctru book-keeping structure for software keyboards.
typedef struct
{
const char* initial_text;
const SwkbdDictWord* dict;
SwkbdStatusData* status_data;
SwkbdLearningData* learning_data;
SwkbdCallbackFn callback;
void* callback_user;
} SwkbdExtra;
/// Software keyboard parameter structure, it shouldn't be modified directly.
typedef struct
{
int type;
int num_buttons_m1;
int valid_input;
int password_mode;
int is_parental_screen;
int darken_top_screen;
u32 filter_flags;
u32 save_state_flags;
u16 max_text_len;
u16 dict_word_count;
u16 max_digits;
u16 button_text[3][SWKBD_MAX_BUTTON_TEXT_LEN+1];
u16 numpad_keys[2];
u16 hint_text[SWKBD_MAX_HINT_TEXT_LEN+1];
bool predictive_input;
bool multiline;
bool fixed_width;
bool allow_home;
bool allow_reset;
bool allow_power;
bool unknown; // XX: what is this supposed to do? "communicateWithOtherRegions"
bool default_qwerty;
bool button_submits_text[4];
u16 language; // XX: not working? supposedly 0 = use system language, CFG_Language+1 = pick language
int initial_text_offset;
int dict_offset;
int initial_status_offset;
int initial_learning_offset;
size_t shared_memory_size;
u32 version;
SwkbdResult result;
int status_offset;
int learning_offset;
int text_offset;
u16 text_length;
int callback_result;
u16 callback_msg[SWKBD_MAX_CALLBACK_MSG_LEN+1];
bool skip_at_check;
union
{
u8 reserved[171];
SwkbdExtra extra;
};
} SwkbdState;
/**
* @brief Initializes software keyboard status.
* @param swkbd Pointer to swkbd state.
* @param type Keyboard type.
* @param numButtons Number of dialog buttons to display (1, 2 or 3).
* @param maxTextLength Maximum number of UTF-16 code units that input text can have (or -1 to let libctru use a big default).
*/
void swkbdInit(SwkbdState* swkbd, SwkbdType type, int numButtons, int maxTextLength);
/**
* @brief Configures password mode in a software keyboard.
* @param swkbd Pointer to swkbd state.
* @param mode Password mode.
*/
static inline void swkbdSetPasswordMode(SwkbdState* swkbd, SwkbdPasswordMode mode)
{
swkbd->password_mode = mode;
}
/**
* @brief Configures input validation in a software keyboard.
* @param swkbd Pointer to swkbd state.
* @param validInput Specifies which inputs are valid.
* @param filterFlags Bitmask specifying which characters are disallowed (filtered).
* @param maxDigits In case digits are disallowed, specifies how many digits are allowed at maximum in input strings (0 completely restricts digit input).
*/
static inline void swkbdSetValidation(SwkbdState* swkbd, SwkbdValidInput validInput, u32 filterFlags, int maxDigits)
{
swkbd->valid_input = validInput;
swkbd->filter_flags = filterFlags;
swkbd->max_digits = (filterFlags & SWKBD_FILTER_DIGITS) ? maxDigits : 0;
}
/**
* @brief Configures what characters will the two bottom keys in a numpad produce.
* @param swkbd Pointer to swkbd state.
* @param left Unicode codepoint produced by the leftmost key in the bottom row (0 hides the key).
* @param left Unicode codepoint produced by the rightmost key in the bottom row (0 hides the key).
*/
static inline void swkbdSetNumpadKeys(SwkbdState* swkbd, int left, int right)
{
swkbd->numpad_keys[0] = left;
swkbd->numpad_keys[1] = right;
}
/**
* @brief Specifies which special features are enabled in a software keyboard.
* @param swkbd Pointer to swkbd state.
* @param features Feature bitmask.
*/
void swkbdSetFeatures(SwkbdState* swkbd, u32 features);
/**
* @brief Sets the hint text of a software keyboard (that is, the help text that is displayed when the textbox is empty).
* @param swkbd Pointer to swkbd state.
* @param text Hint text.
*/
void swkbdSetHintText(SwkbdState* swkbd, const char* text);
/**
* @brief Configures a dialog button in a software keyboard.
* @param swkbd Pointer to swkbd state.
* @param button Specifies which button to configure.
* @param text Button text.
* @param submit Specifies whether pushing the button will submit the text or discard it.
*/
void swkbdSetButton(SwkbdState* swkbd, SwkbdButton button, const char* text, bool submit);
/**
* @brief Sets the initial text that a software keyboard will display on launch.
* @param swkbd Pointer to swkbd state.
* @param text Initial text.
*/
void swkbdSetInitialText(SwkbdState* swkbd, const char* text);
/**
* @brief Configures a word in a predictive dictionary for use with a software keyboard.
* @param word Pointer to dictionary word structure.
* @param reading Reading of the word, that is, the sequence of characters that need to be typed to trigger the word in the predictive input system.
* @param text Spelling of the word, that is, the actual characters that will be produced when the user decides to select the word.
*/
void swkbdSetDictWord(SwkbdDictWord* word, const char* reading, const char* text);
/**
* @brief Sets the custom word dictionary to be used with the predictive input system of a software keyboard.
* @param swkbd Pointer to swkbd state.
* @param dict Pointer to dictionary words.
* @param wordCount Number of words in the dictionary.
*/
void swkbdSetDictionary(SwkbdState* swkbd, const SwkbdDictWord* dict, int wordCount);
/**
* @brief Configures software keyboard internal status management.
* @param swkbd Pointer to swkbd state.
* @param data Pointer to internal status structure (can be in, out or both depending on the other parameters).
* @param in Specifies whether the data should be read from the structure when the keyboard is launched.
* @param out Specifies whether the data should be written to the structure when the keyboard is closed.
*/
void swkbdSetStatusData(SwkbdState* swkbd, SwkbdStatusData* data, bool in, bool out);
/**
* @brief Configures software keyboard predictive input learning data management.
* @param swkbd Pointer to swkbd state.
* @param data Pointer to learning data structure (can be in, out or both depending on the other parameters).
* @param in Specifies whether the data should be read from the structure when the keyboard is launched.
* @param out Specifies whether the data should be written to the structure when the keyboard is closed.
*/
void swkbdSetLearningData(SwkbdState* swkbd, SwkbdLearningData* data, bool in, bool out);
/**
* @brief Configures a custom function to be used to check the validity of input when it is submitted in a software keyboard.
* @param swkbd Pointer to swkbd state.
* @param callback Filter callback function.
* @param user Custom data to be passed to the callback function.
*/
void swkbdSetFilterCallback(SwkbdState* swkbd, SwkbdCallbackFn callback, void* user);
/**
* @brief Launches a software keyboard in order to input text.
* @param swkbd Pointer to swkbd state.
* @param buf Pointer to output buffer which will hold the inputted text.
* @param bufsize Maximum number of UTF-8 code units that the buffer can hold (including null terminator).
* @return The identifier of the dialog button that was pressed, or SWKBD_BUTTON_NONE if a different condition was triggered - in that case use swkbdGetResult to check the condition.
*/
SwkbdButton swkbdInputText(SwkbdState* swkbd, char* buf, size_t bufsize);
/**
* @brief Retrieves the result condition of a software keyboard after it has been used.
* @param swkbd Pointer to swkbd state.
* @return The result value.
*/
static inline SwkbdResult swkbdGetResult(SwkbdState* swkbd)
{
return swkbd->result;
}

43
.vscode/dummyinclude/3ds/archive.h vendored Normal file
View file

@ -0,0 +1,43 @@
/**
* @file archive.h
* @brief FS_Archive driver
*/
#pragma once
#include <sys/types.h>
#include <3ds/types.h>
#include <3ds/services/fs.h>
#define ARCHIVE_DIRITER_MAGIC 0x68637261 /* "arch" */
/*! Open directory struct */
typedef struct
{
u32 magic; /*! "arch" */
Handle fd; /*! CTRU handle */
ssize_t index; /*! Current entry index */
size_t size; /*! Current batch size */
FS_DirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
} archive_dir_t;
/// Mounts the SD
Result archiveMountSdmc(void);
/// Mounts and opens an archive as deviceName
/// Returns either an archive open error code, or -1 for generic failure
Result archiveMount(FS_ArchiveID archiveID, FS_Path archivePath, const char *deviceName);
/// Uses FSUSER_ControlArchive with control action ARCHIVE_ACTION_COMMIT_SAVE_DATA on the opened archive. Not done automatically at unmount.
/// Returns -1 if the specified device is not found
Result archiveCommitSaveData(const char *deviceName);
/// Unmounts the specified device, closing its archive in the process
/// Returns -1 if the specified device was not found
Result archiveUnmount(const char *deviceName);
/// Unmounts all devices and cleans up any resources used by the driver
Result archiveUnmountAll(void);
/// Get a file's mtime
Result archive_getmtime(const char *name, u64 *mtime);

21
.vscode/dummyinclude/3ds/asminc.h vendored Normal file
View file

@ -0,0 +1,21 @@
#pragma once
#if !__ASSEMBLER__
#error This header file is only for use in assembly files!
#endif // !__ASSEMBLER__
.macro BEGIN_ASM_FUNC name, linkage=global, section=text
.section .\section\().\name, "ax", %progbits
.align 2
.\linkage \name
.type \name, %function
.func \name
.cfi_sections .debug_frame
.cfi_startproc
\name:
.endm
.macro END_ASM_FUNC
.cfi_endproc
.endfunc
.endm

176
.vscode/dummyinclude/3ds/console.h vendored Normal file
View file

@ -0,0 +1,176 @@
/**
* @file console.h
* @brief 3ds stdio support.
*
* Provides stdio integration for printing to the 3DS screen as well as debug print
* functionality provided by stderr.
*
* General usage is to initialize the console by:
* @code
* consoleDemoInit()
* @endcode
* or to customize the console usage by:
* @code
* consoleInit()
* @endcode
*/
#pragma once
#include <3ds/types.h>
#include <3ds/gfx.h>
#ifdef __cplusplus
extern "C" {
#endif
#define CONSOLE_ESC(x) "\x1b[" #x
#define CONSOLE_RESET CONSOLE_ESC(0m)
#define CONSOLE_BLACK CONSOLE_ESC(30m)
#define CONSOLE_RED CONSOLE_ESC(31;1m)
#define CONSOLE_GREEN CONSOLE_ESC(32;1m)
#define CONSOLE_YELLOW CONSOLE_ESC(33;1m)
#define CONSOLE_BLUE CONSOLE_ESC(34;1m)
#define CONSOLE_MAGENTA CONSOLE_ESC(35;1m)
#define CONSOLE_CYAN CONSOLE_ESC(36;1m)
#define CONSOLE_WHITE CONSOLE_ESC(37;1m)
/// A callback for printing a character.
typedef bool(*ConsolePrint)(void* con, int c);
/// A font struct for the console.
typedef struct ConsoleFont
{
u8* gfx; ///< A pointer to the font graphics
u16 asciiOffset; ///< Offset to the first valid character in the font table
u16 numChars; ///< Number of characters in the font graphics
}ConsoleFont;
/**
* @brief Console structure used to store the state of a console render context.
*
* Default values from consoleGetDefault();
* @code
* PrintConsole defaultConsole =
* {
* //Font:
* {
* (u8*)default_font_bin, //font gfx
* 0, //first ascii character in the set
* 128, //number of characters in the font set
* },
* 0,0, //cursorX cursorY
* 0,0, //prevcursorX prevcursorY
* 40, //console width
* 30, //console height
* 0, //window x
* 0, //window y
* 32, //window width
* 24, //window height
* 3, //tab size
* 0, //font character offset
* 0, //print callback
* false //console initialized
* };
* @endcode
*/
typedef struct PrintConsole
{
ConsoleFont font; ///< Font of the console
u16 *frameBuffer; ///< Framebuffer address
int cursorX; ///< Current X location of the cursor (as a tile offset by default)
int cursorY; ///< Current Y location of the cursor (as a tile offset by default)
int prevCursorX; ///< Internal state
int prevCursorY; ///< Internal state
int consoleWidth; ///< Width of the console hardware layer in characters
int consoleHeight; ///< Height of the console hardware layer in characters
int windowX; ///< Window X location in characters (not implemented)
int windowY; ///< Window Y location in characters (not implemented)
int windowWidth; ///< Window width in characters (not implemented)
int windowHeight; ///< Window height in characters (not implemented)
int tabSize; ///< Size of a tab
u16 fg; ///< Foreground color
u16 bg; ///< Background color
int flags; ///< Reverse/bright flags
ConsolePrint PrintChar; ///< Callback for printing a character. Should return true if it has handled rendering the graphics (else the print engine will attempt to render via tiles).
bool consoleInitialised; ///< True if the console is initialized
}PrintConsole;
#define CONSOLE_COLOR_BOLD (1<<0) ///< Bold text
#define CONSOLE_COLOR_FAINT (1<<1) ///< Faint text
#define CONSOLE_ITALIC (1<<2) ///< Italic text
#define CONSOLE_UNDERLINE (1<<3) ///< Underlined text
#define CONSOLE_BLINK_SLOW (1<<4) ///< Slow blinking text
#define CONSOLE_BLINK_FAST (1<<5) ///< Fast blinking text
#define CONSOLE_COLOR_REVERSE (1<<6) ///< Reversed color text
#define CONSOLE_CONCEAL (1<<7) ///< Concealed text
#define CONSOLE_CROSSED_OUT (1<<8) ///< Crossed out text
#define CONSOLE_FG_CUSTOM (1<<9) ///< Foreground custom color
#define CONSOLE_BG_CUSTOM (1<<10) ///< Background custom color
/// Console debug devices supported by libnds.
typedef enum {
debugDevice_NULL, ///< Swallows prints to stderr
debugDevice_SVC, ///< Outputs stderr debug statements using svcOutputDebugString, which can then be captured by interactive debuggers
debugDevice_CONSOLE, ///< Directs stderr debug statements to 3DS console window
debugDevice_3DMOO = debugDevice_SVC,
} debugDevice;
/**
* @brief Loads the font into the console.
* @param console Pointer to the console to update, if NULL it will update the current console.
* @param font The font to load.
*/
void consoleSetFont(PrintConsole* console, ConsoleFont* font);
/**
* @brief Sets the print window.
* @param console Console to set, if NULL it will set the current console window.
* @param x X location of the window.
* @param y Y location of the window.
* @param width Width of the window.
* @param height Height of the window.
*/
void consoleSetWindow(PrintConsole* console, int x, int y, int width, int height);
/**
* @brief Gets a pointer to the console with the default values.
* This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit().
* @return A pointer to the console with the default values.
*/
PrintConsole* consoleGetDefault(void);
/**
* @brief Make the specified console the render target.
* @param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)).
* @return A pointer to the previous console.
*/
PrintConsole *consoleSelect(PrintConsole* console);
/**
* @brief Initialise the console.
* @param screen The screen to use for the console.
* @param console A pointer to the console data to initialize (if it's NULL, the default console will be used).
* @return A pointer to the current console.
*/
PrintConsole* consoleInit(gfxScreen_t screen, PrintConsole* console);
/**
* @brief Initializes debug console output on stderr to the specified device.
* @param device The debug device (or devices) to output debug print statements to.
*/
void consoleDebugInit(debugDevice device);
/// Clears the screen by using iprintf("\x1b[2J");
void consoleClear(void);
#ifdef __cplusplus
}
#endif

73
.vscode/dummyinclude/3ds/env.h vendored Normal file
View file

@ -0,0 +1,73 @@
/**
* @file env.h
* @brief Homebrew environment information.
*/
#pragma once
/// System run-flags.
enum {
RUNFLAG_APTWORKAROUND = BIT(0), ///< Use APT workaround.
RUNFLAG_APTREINIT = BIT(1), ///< Reinitialize APT.
RUNFLAG_APTCHAINLOAD = BIT(2), ///< Chainload APT on return.
};
/**
* @brief Gets whether the application was launched from a homebrew environment.
* @return Whether the application was launched from a homebrew environment.
*/
static inline bool envIsHomebrew(void) {
extern void* __service_ptr;
return __service_ptr != NULL;
}
/**
* @brief Retrieves a handle from the environment handle list.
* @param name Name of the handle.
* @return The retrieved handle.
*/
Handle envGetHandle(const char* name);
/**
* @brief Gets the environment-recommended app ID to use with APT.
* @return The APT app ID.
*/
static inline u32 envGetAptAppId(void) {
extern u32 __apt_appid;
return __apt_appid;
}
/**
* @brief Gets the size of the application heap.
* @return The application heap size.
*/
static inline u32 envGetHeapSize(void) {
extern u32 __ctru_heap_size;
return __ctru_heap_size;
}
/**
* @brief Gets the size of the linear heap.
* @return The linear heap size.
*/
static inline u32 envGetLinearHeapSize(void) {
extern u32 __ctru_linear_heap_size;
return __ctru_linear_heap_size;
}
/**
* @brief Gets the environment argument list.
* @return The argument list.
*/
static inline const char* envGetSystemArgList(void) {
extern const char* __system_arglist;
return __system_arglist;
}
/**
* @brief Gets the environment run flags.
* @return The run flags.
*/
static inline u32 envGetSystemRunFlags(void) {
extern u32 __system_runflags;
return __system_runflags;
}

137
.vscode/dummyinclude/3ds/errf.h vendored Normal file
View file

@ -0,0 +1,137 @@
/**
* @file errf.h
* @brief Error Display API
*/
#pragma once
#include <3ds/types.h>
/// Types of errors that can be thrown by err:f.
typedef enum {
ERRF_ERRTYPE_GENERIC = 0, ///< Generic fatal error. Shows miscellaneous info, including the address of the caller
ERRF_ERRTYPE_NAND_DAMAGED = 1, ///< Damaged NAND (CC_ERROR after reading CSR)
ERRF_ERRTYPE_CARD_REMOVED = 2, ///< Game content storage medium (cartridge and/or SD card) ejected. Not logged
ERRF_ERRTYPE_EXCEPTION = 3, ///< CPU or VFP exception
ERRF_ERRTYPE_FAILURE = 4, ///< Fatal error with a message instead of the caller's address
ERRF_ERRTYPE_LOG_ONLY = 5, ///< Log-level failure. Does not display the exception and does not force the system to reboot
} ERRF_ErrType;
/// Types of 'Exceptions' thrown for ERRF_ERRTYPE_EXCEPTION
typedef enum {
ERRF_EXCEPTION_PREFETCH_ABORT = 0, ///< Prefetch Abort
ERRF_EXCEPTION_DATA_ABORT = 1, ///< Data abort
ERRF_EXCEPTION_UNDEFINED = 2, ///< Undefined instruction
ERRF_EXCEPTION_VFP = 3, ///< VFP (floating point) exception.
} ERRF_ExceptionType;
typedef struct {
ERRF_ExceptionType type; ///< Type of the exception. One of the ERRF_EXCEPTION_* values.
u8 reserved[3];
u32 fsr; ///< ifsr (prefetch abort) / dfsr (data abort)
u32 far; ///< pc = ifar (prefetch abort) / dfar (data abort)
u32 fpexc;
u32 fpinst;
u32 fpinst2;
} ERRF_ExceptionInfo;
typedef struct {
ERRF_ExceptionInfo excep; ///< Exception info struct
CpuRegisters regs; ///< CPU register dump.
} ERRF_ExceptionData;
typedef struct {
ERRF_ErrType type; ///< Type, one of the ERRF_ERRTYPE_* enum
u8 revHigh; ///< High revison ID
u16 revLow; ///< Low revision ID
u32 resCode; ///< Result code
u32 pcAddr; ///< PC address at exception
u32 procId; ///< Process ID of the caller
u64 titleId; ///< Title ID of the caller
u64 appTitleId; ///< Title ID of the running application
union {
ERRF_ExceptionData exception_data; ///< Data for when type is ERRF_ERRTYPE_EXCEPTION
char failure_mesg[0x60]; ///< String for when type is ERRF_ERRTYPE_FAILURE
} data; ///< The different types of data for errors.
} ERRF_FatalErrInfo;
/// Initializes ERR:f. Unless you plan to call ERRF_Throw yourself, do not use this.
Result errfInit(void);
/// Exits ERR:f. Unless you plan to call ERRF_Throw yourself, do not use this.
void errfExit(void);
/**
* @brief Gets the current err:f API session handle.
* @return The current err:f API session handle.
*/
Handle *errfGetSessionHandle(void);
/**
* @brief Throws a system error and possibly logs it.
* @param[in] error Error to throw.
*
* ErrDisp may convert the error info to \ref ERRF_ERRTYPE_NAND_DAMAGED or \ref ERRF_ERRTYPE_CARD_REMOVED
* depending on the error code.
*
* Except with \ref ERRF_ERRTYPE_LOG_ONLY, the system will panic and will need to be rebooted.
* Fatal error information will also be logged into a file, unless the type either \ref ERRF_ERRTYPE_NAND_DAMAGED
* or \ref ERRF_ERRTYPE_CARD_REMOVED.
*
* No error will be shown if the system is asleep.
*
* On retail units with vanilla firmware, no detailed information will be displayed on screen.
*
* You may wish to use ERRF_ThrowResult() or ERRF_ThrowResultWithMessage() instead of
* constructing the ERRF_FatalErrInfo struct yourself.
*/
Result ERRF_Throw(const ERRF_FatalErrInfo* error);
/**
* @brief Throws (and logs) a system error with the given Result code.
* @param[in] failure Result code to throw.
*
* This calls \ref ERRF_Throw with error type \ref ERRF_ERRTYPE_GENERIC and fills in the required data.
*
* This function \em does fill in the address where this function was called from.
*/
Result ERRF_ThrowResult(Result failure);
/**
* @brief Logs a system error with the given Result code.
* @param[in] failure Result code to log.
*
* Similar to \ref ERRF_Throw, except that it does not display anything on the screen,
* nor does it force the system to reboot.
*
* This function \em does fill in the address where this function was called from.
*/
Result ERRF_LogResult(Result failure);
/**
* @brief Throws a system error with the given Result code and message.
* @param[in] failure Result code to throw.
* @param[in] message The message to display.
*
* This calls \ref ERRF_Throw with error type \ref ERRF_ERRTYPE_FAILURE and fills in the required data.
*
* This function does \em not fill in the address where this function was called from because it
* would not be displayed.
*/
Result ERRF_ThrowResultWithMessage(Result failure, const char* message);
/**
* @brief Specify an additional user string to use for error reporting.
* @param[in] user_string User string (up to 256 bytes, not including NUL byte)
*/
Result ERRF_SetUserString(const char* user_string);
/**
* @brief Handles an exception using ErrDisp.
* @param excep Exception information
* @param regs CPU registers
*
* You might want to clear ENVINFO's bit0 to be able to see any debugging information.
* @sa threadOnException
*/
void ERRF_ExceptionHandler(ERRF_ExceptionInfo* excep, CpuRegisters* regs) __attribute__((noreturn));

199
.vscode/dummyinclude/3ds/exheader.h vendored Normal file
View file

@ -0,0 +1,199 @@
/**
* @file exheader.h
* @brief NCCH extended header definitions.
*/
#pragma once
#include <3ds/types.h>
/// ARM9 descriptor flags
enum
{
ARM9DESC_MOUNT_NAND = BIT(0), ///< Mount "nand:/"
ARM9DESC_MOUNT_NANDRO_RW = BIT(1), ///< Mount nand:/ro/ as read-write
ARM9DESC_MOUNT_TWLN = BIT(2), ///< Mount "twln:/"
ARM9DESC_MOUNT_WNAND = BIT(3), ///< Mount "wnand:/"
ARM9DESC_MOUNT_CARDSPI = BIT(4), ///< Mount "cardspi:/"
ARM9DESC_USE_SDIF3 = BIT(5), ///< Use SDIF3
ARM9DESC_CREATE_SEED = BIT(6), ///< Create seed (movable.sed)
ARM9DESC_USE_CARD_SPI = BIT(7), ///< Use card SPI, required by multiple pxi:dev commands
ARM9DESC_SD_APPLICATION = BIT(8), ///< SD application (not checked)
ARM9DESC_MOUNT_SDMC_RW = BIT(9), ///< Mount "sdmc:/" as read-write
};
/// Filesystem access flags
enum
{
FSACCESS_CATEGORY_SYSTEM_APPLICATION = BIT(0), ///< Category "system application"
FSACCESS_CATEGORY_HARDWARE_CHECK = BIT(1), ///< Category "hardware check"
FSACCESS_CATEGORY_FILESYSTEM_TOOL = BIT(2), ///< Category "filesystem tool"
FSACCESS_DEBUG = BIT(3), ///< Debug
FSACCESS_TWLCARD_BACKUP = BIT(4), ///< TWLCARD backup
FSACCESS_TWLNAND_DATA = BIT(5), ///< TWLNAND data
FSACCESS_BOSS = BIT(6), ///< BOSS (SpotPass)
FSACCESS_SDMC_RW = BIT(7), ///< SDMC (read-write)
FSACCESS_CORE = BIT(8), ///< Core
FSACCESS_NANDRO_RO = BIT(9), ///< nand:/ro/ (read-only)
FSACCESS_NANDRW = BIT(10), ///< nand:/rw/
FSACCESS_NANDRO_RW = BIT(11), ///< nand:/ro/ (read-write)
FSACCESS_CATEGORY_SYSTEM_SETTINGS = BIT(12), ///< Category "System Settings"
FSACCESS_CARDBOARD = BIT(13), ///< Cardboard (System Transfer)
FSACCESS_EXPORT_IMPORT_IVS = BIT(14), ///< Export/Import IVs (movable.sed)
FSACCESS_SDMC_WO = BIT(15), ///< SDMC (write-only)
FSACCESS_SWITCH_CLEANUP = BIT(16), ///< "Switch cleanup" (3.0+)
FSACCESS_SAVEDATA_MOVE = BIT(17), ///< Savedata move (5.0+)
FSACCESS_SHOP = BIT(18), ///< Shop (5.0+)
FSACCESS_SHELL = BIT(19), ///< Shop (5.0+)
FSACCESS_CATEGORY_HOME_MENU = BIT(20), ///< Category "Home Menu" (6.0+)
FSACCESS_SEEDDB = BIT(21), ///< Seed DB (9.6+)
};
/// The resource limit category of a title
typedef enum
{
RESLIMIT_CATEGORY_APPLICATION = 0, ///< Regular application
RESLIMIT_CATEGORY_SYS_APPLET = 1, ///< System applet
RESLIMIT_CATEGORY_LIB_APPLET = 2, ///< Library applet
RESLIMIT_CATEGORY_OTHER = 3, ///< System modules running inside the BASE memregion
} ResourceLimitCategory;
/// The system mode a title should be launched under
typedef enum
{
SYSMODE_O3DS_PROD = 0, ///< 64MB of usable application memory
SYSMODE_N3DS_PROD = 1, ///< 124MB of usable application memory. Unusable on O3DS
SYSMODE_DEV1 = 2, ///< 97MB/178MB of usable application memory
SYSMODE_DEV2 = 3, ///< 80MB/124MB of usable application memory
SYSMODE_DEV3 = 4, ///< 72MB of usable application memory. Same as "Prod" on N3DS
SYSMODE_DEV4 = 5, ///< 32MB of usable application memory. Same as "Prod" on N3DS
} SystemMode;
/// The system info flags and remaster version of a title
typedef struct
{
u8 reserved[5]; ///< Reserved
bool compress_exefs_code : 1; ///< Whether the ExeFS's .code section is compressed
bool is_sd_application : 1; ///< Whether the title is meant to be used on an SD card
u16 remaster_version; ///< Remaster version
} ExHeader_SystemInfoFlags;
/// Information about a title's section
typedef struct
{
u32 address; ///< The address of the section
u32 num_pages; ///< The number of pages the section occupies
u32 size; ///< The size of the section
} ExHeader_CodeSectionInfo;
/// The name of a title and infomation about its section
typedef struct
{
char name[8]; ///< Title name
ExHeader_SystemInfoFlags flags; ///< System info flags, see @ref ExHeader_SystemInfoFlags
ExHeader_CodeSectionInfo text; ///< .text section info, see @ref ExHeader_CodeSectionInfo
u32 stack_size; ///< Stack size
ExHeader_CodeSectionInfo rodata; ///< .rodata section info, see @ref ExHeader_CodeSectionInfo
u32 reserved; ///< Reserved
ExHeader_CodeSectionInfo data; ///< .data section info, see @ref ExHeader_CodeSectionInfo
u32 bss_size; ///< .bss section size
} ExHeader_CodeSetInfo;
/// The savedata size and jump ID of a title
typedef struct
{
u64 savedata_size; ///< Savedata size
u64 jump_id; ///< Jump ID
u8 reserved[0x30]; ///< Reserved
} ExHeader_SystemInfo;
/// The code set info, dependencies and system info of a title (SCI)
typedef struct
{
ExHeader_CodeSetInfo codeset_info; ///< Code set info, see @ref ExHeader_CodeSetInfo
u64 dependencies[48]; ///< Title IDs of the titles that this program depends on
ExHeader_SystemInfo system_info; ///< System info, see @ref ExHeader_SystemInfo
} ExHeader_SystemControlInfo;
/// The ARM11 filesystem info of a title
typedef struct
{
u64 extdata_id; ///< Extdata ID
u32 system_savedata_ids[2]; ///< IDs of the system savedata accessible by the title
u64 accessible_savedata_ids; ///< IDs of the savedata accessible by the title, 20 bits each, followed by "Use other variation savedata"
u32 fs_access_info; ///< FS access flags
u32 reserved : 24; ///< Reserved
bool no_romfs : 1; ///< Don't use any RomFS
bool use_extended_savedata_access : 1; ///< Use the "extdata_id" field to store 3 additional accessible savedata IDs
} ExHeader_Arm11StorageInfo;
/// The CPU-related and memory-layout-related info of a title
typedef struct
{
u32 core_version; ///< The low title ID of the target firmware
bool use_cpu_clockrate_804MHz : 1; ///< Whether to start the title with the 804MHz clock rate
bool enable_l2c : 1; ///< Whether to start the title with the L2C-310 enabled enabled
u8 flag1_unused : 6; ///< Unused
SystemMode n3ds_system_mode : 4; ///< The system mode to use on N3DS
u8 flag2_unused : 4; ///< Unused
u8 ideal_processor : 2; ///< The ideal processor to start the title on
u8 affinity_mask : 2; ///< The affinity mask of the title
SystemMode o3ds_system_mode : 4; ///< The system mode to use on N3DS
u8 priority; ///< The priority of the title's main thread
} ExHeader_Arm11CoreInfo;
/// The ARM11 system-local capabilities of a title
typedef struct
{
u64 title_id; ///< Title ID
ExHeader_Arm11CoreInfo core_info; ///< Core info, see @ref ExHeader_Arm11CoreInfo
u16 reslimits[16]; ///< Resource limit descriptors, only "CpuTime" (first byte) sems to be used
ExHeader_Arm11StorageInfo storage_info; ///< Storage info, see @ref ExHeader_Arm11StorageInfo
char service_access[34][8]; ///< List of the services the title has access to. Limited to 32 prior to system version 9.3
u8 reserved[15]; ///< Reserved
ResourceLimitCategory reslimit_category; ///< Resource limit category, see @ref ExHeader_Arm11SystemLocalCapabilities
} ExHeader_Arm11SystemLocalCapabilities;
/// The ARM11 kernel capabilities of a title
typedef struct
{
u32 descriptors[28]; ///< ARM11 kernel descriptors, see 3dbrew
u8 reserved[16]; ///< Reserved
} ExHeader_Arm11KernelCapabilities;
/// The ARM9 access control of a title
typedef struct
{
u8 descriptors[15]; ///< Process9 FS descriptors, see 3dbrew
u8 descriptor_version; ///< Descriptor version
} ExHeader_Arm9AccessControl;
/// The access control information of a title
typedef struct
{
ExHeader_Arm11SystemLocalCapabilities local_caps; ///< ARM11 system-local capabilities, see @ref ExHeader_Arm11SystemLocalCapabilities
ExHeader_Arm11KernelCapabilities kernel_caps; ///< ARM11 kernel capabilities, see @ref ExHeader_Arm11SystemLocalCapabilities
ExHeader_Arm9AccessControl access_control; ///< ARM9 access control, see @ref ExHeader_Arm9AccessControl
} ExHeader_AccessControlInfo;
/// Main extended header data, as returned by PXIPM, Loader and FSREG service commands
typedef struct
{
ExHeader_SystemControlInfo sci; ///< System control info, see @ref ExHeader_SystemControlInfo
ExHeader_AccessControlInfo aci; ///< Access control info, see @ref ExHeader_AccessControlInfo
} ExHeader_Info;
/// Extended header access descriptor
typedef struct
{
u8 signature[0x100]; ///< The signature of the access descriptor (RSA-2048-SHA256)
u8 ncchModulus[0x100]; ///< The modulus used for the above signature, with 65537 as public exponent
ExHeader_AccessControlInfo acli; ///< This is compared for equality with the first ACI by Process9, see @ref ExHeader_AccessControlInfo
} ExHeader_AccessDescriptor;
/// The NCCH Extended Header of a title
typedef struct
{
ExHeader_Info info; ///< Main extended header data, see @ref ExHeader_Info
ExHeader_AccessDescriptor access_descriptor; ///< Access descriptor, see @ref ExHeader_AccessDescriptor
} ExHeader;

236
.vscode/dummyinclude/3ds/font.h vendored Normal file
View file

@ -0,0 +1,236 @@
/**
* @file font.h
* @brief Shared font support.
*/
#pragma once
#include <3ds/types.h>
///@name Data types
///@{
/// Character width information structure.
typedef struct
{
s8 left; ///< Horizontal offset to draw the glyph with.
u8 glyphWidth; ///< Width of the glyph.
u8 charWidth; ///< Width of the character, that is, horizontal distance to advance.
} charWidthInfo_s;
/// Font texture sheet information.
typedef struct
{
u8 cellWidth; ///< Width of a glyph cell.
u8 cellHeight; ///< Height of a glyph cell.
u8 baselinePos; ///< Vertical position of the baseline.
u8 maxCharWidth; ///< Maximum character width.
u32 sheetSize; ///< Size in bytes of a texture sheet.
u16 nSheets; ///< Number of texture sheets.
u16 sheetFmt; ///< GPU texture format (GPU_TEXCOLOR).
u16 nRows; ///< Number of glyphs per row per sheet.
u16 nLines; ///< Number of glyph rows per sheet.
u16 sheetWidth; ///< Texture sheet width.
u16 sheetHeight; ///< Texture sheet height.
u8* sheetData; ///< Pointer to texture sheet data.
} TGLP_s;
/// Font character width information block type.
typedef struct tag_CWDH_s CWDH_s;
/// Font character width information block structure.
struct tag_CWDH_s
{
u16 startIndex; ///< First Unicode codepoint the block applies to.
u16 endIndex; ///< Last Unicode codepoint the block applies to.
CWDH_s* next; ///< Pointer to the next block.
charWidthInfo_s widths[0]; ///< Table of character width information structures.
};
/// Font character map methods.
enum
{
CMAP_TYPE_DIRECT = 0, ///< Identity mapping.
CMAP_TYPE_TABLE = 1, ///< Mapping using a table.
CMAP_TYPE_SCAN = 2, ///< Mapping using a list of mapped characters.
};
/// Font character map type.
typedef struct tag_CMAP_s CMAP_s;
/// Font character map structure.
struct tag_CMAP_s
{
u16 codeBegin; ///< First Unicode codepoint the block applies to.
u16 codeEnd; ///< Last Unicode codepoint the block applies to.
u16 mappingMethod; ///< Mapping method.
u16 reserved;
CMAP_s* next; ///< Pointer to the next map.
union
{
u16 indexOffset; ///< For CMAP_TYPE_DIRECT: index of the first glyph.
u16 indexTable[0]; ///< For CMAP_TYPE_TABLE: table of glyph indices.
/// For CMAP_TYPE_SCAN: Mapping data.
struct
{
u16 nScanEntries; ///< Number of pairs.
/// Mapping pairs.
struct
{
u16 code; ///< Unicode codepoint.
u16 glyphIndex; ///< Mapped glyph index.
} scanEntries[0];
};
};
};
/// Font information structure.
typedef struct
{
u32 signature; ///< Signature (FINF).
u32 sectionSize; ///< Section size.
u8 fontType; ///< Font type
u8 lineFeed; ///< Line feed vertical distance.
u16 alterCharIndex; ///< Glyph index of the replacement character.
charWidthInfo_s defaultWidth; ///< Default character width information.
u8 encoding; ///< Font encoding (?)
TGLP_s* tglp; ///< Pointer to texture sheet information.
CWDH_s* cwdh; ///< Pointer to the first character width information block.
CMAP_s* cmap; ///< Pointer to the first character map.
u8 height; ///< Font height.
u8 width; ///< Font width.
u8 ascent; ///< Font ascent.
u8 padding;
} FINF_s;
/// Font structure.
typedef struct
{
u32 signature; ///< Signature (CFNU).
u16 endianness; ///< Endianness constant (0xFEFF).
u16 headerSize; ///< Header size.
u32 version; ///< Format version.
u32 fileSize; ///< File size.
u32 nBlocks; ///< Number of blocks.
FINF_s finf; ///< Font information.
} CFNT_s;
/// Font glyph position structure.
typedef struct
{
int sheetIndex; ///< Texture sheet index to use to render the glyph.
float xOffset; ///< Horizontal offset to draw the glyph width.
float xAdvance; ///< Horizontal distance to advance after drawing the glyph.
float width; ///< Glyph width.
/// Texture coordinates to use to render the glyph.
struct
{
float left, top, right, bottom;
} texcoord;
/// Vertex coordinates to use to render the glyph.
struct
{
float left, top, right, bottom;
} vtxcoord;
} fontGlyphPos_s;
/// Flags for use with fontCalcGlyphPos.
enum
{
GLYPH_POS_CALC_VTXCOORD = BIT(0), ///< Calculates vertex coordinates in addition to texture coordinates.
GLYPH_POS_AT_BASELINE = BIT(1), ///< Position the glyph at the baseline instead of at the top-left corner.
GLYPH_POS_Y_POINTS_UP = BIT(2), ///< Indicates that the Y axis points up instead of down.
};
///@}
///@name Initialization and basic operations
///@{
/// Ensures the shared system font is mapped.
Result fontEnsureMapped(void);
/**
* @brief Fixes the pointers internal to a just-loaded font
* @param font Font to fix
* @remark Should never be run on the system font, and only once on any other font.
*/
void fontFixPointers(CFNT_s* font);
/// Gets the currently loaded system font
static inline CFNT_s* fontGetSystemFont(void)
{
extern CFNT_s* g_sharedFont;
if (!g_sharedFont)
fontEnsureMapped();
return g_sharedFont;
}
/**
* @brief Retrieves the font information structure of a font.
* @param font Pointer to font structure. If NULL, the shared system font is used.
*/
static inline FINF_s* fontGetInfo(CFNT_s* font)
{
if (!font)
font = fontGetSystemFont();
return &font->finf;
}
/**
* @brief Retrieves the texture sheet information of a font.
* @param font Pointer to font structure. If NULL, the shared system font is used.
*/
static inline TGLP_s* fontGetGlyphInfo(CFNT_s* font)
{
if (!font)
font = fontGetSystemFont();
return fontGetInfo(font)->tglp;
}
/**
* @brief Retrieves the pointer to texture data for the specified texture sheet.
* @param font Pointer to font structure. If NULL, the shared system font is used.
* @param sheetIndex Index of the texture sheet.
*/
static inline void* fontGetGlyphSheetTex(CFNT_s* font, int sheetIndex)
{
if (!font)
font = fontGetSystemFont();
TGLP_s* tglp = fontGetGlyphInfo(font);
return &tglp->sheetData[sheetIndex*tglp->sheetSize];
}
/**
* @brief Retrieves the glyph index of the specified Unicode codepoint.
* @param font Pointer to font structure. If NULL, the shared system font is used.
* @param codePoint Unicode codepoint.
*/
int fontGlyphIndexFromCodePoint(CFNT_s* font, u32 codePoint);
/**
* @brief Retrieves character width information of the specified glyph.
* @param font Pointer to font structure. If NULL, the shared system font is used.
* @param glyphIndex Index of the glyph.
*/
charWidthInfo_s* fontGetCharWidthInfo(CFNT_s* font, int glyphIndex);
/**
* @brief Calculates position information for the specified glyph.
* @param out Output structure in which to write the information.
* @param font Pointer to font structure. If NULL, the shared system font is used.
* @param glyphIndex Index of the glyph.
* @param flags Calculation flags (see GLYPH_POS_* flags).
* @param scaleX Scale factor to apply horizontally.
* @param scaleY Scale factor to apply vertically.
*/
void fontCalcGlyphPos(fontGlyphPos_s* out, CFNT_s* font, int glyphIndex, u32 flags, float scaleX, float scaleY);
///@}

29
.vscode/dummyinclude/3ds/gdbhio.h vendored Normal file
View file

@ -0,0 +1,29 @@
/**
* @file gdbhio.h
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) functions.
*/
#pragma once
#include <fcntl.h>
#include <sys/time.h>
#include <sys/stat.h>
#define GDBHIO_STDIN_FILENO 0
#define GDBHIO_STDOUT_FILENO 1
#define GDBHIO_STDERR_FILENO 2
int gdbHioOpen(const char *pathname, int flags, mode_t mode);
int gdbHioClose(int fd);
int gdbHioRead(int fd, void *buf, unsigned int count);
int gdbHioWrite(int fd, const void *buf, unsigned int count);
off_t gdbHioLseek(int fd, off_t offset, int flag);
int gdbHioRename(const char *oldpath, const char *newpath);
int gdbHioUnlink(const char *pathname);
int gdbHioStat(const char *pathname, struct stat *st);
int gdbHioFstat(int fd, struct stat *st);
int gdbHioGettimeofday(struct timeval *tv, void *tz);
int gdbHioIsatty(int fd);
///< Host I/O 'system' function, requires 'set remote system-call-allowed 1'.
int gdbHioSystem(const char *command);

37
.vscode/dummyinclude/3ds/gdbhio_dev.h vendored Normal file
View file

@ -0,0 +1,37 @@
/**
* @file gdbhio_dev.h
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) devoptab wrapper.
*/
#pragma once
#include <stdbool.h>
struct timeval;
///< Initializes the GDB HIO devoptab wrapper, returns 0 on success, -1 on failure.
int gdbHioDevInit(void);
///< Deinitializes the GDB HIO devoptab wrapper.
void gdbHioDevExit(void);
///< Returns a file descriptor mapping to the GDB client console's standard input stream.
int gdbHioDevGetStdin(void);
///< Returns a file descriptor mapping to the GDB client console's standard output stream.
int gdbHioDevGetStdout(void);
///< Returns a file descriptor mapping to the GDB client console's standard error stream.
int gdbHioDevGetStderr(void);
///< Redirects 0 to 3 of the application's standard streams to GDB client console's. Returns -1, -2, or -3, resp., on failure; 0 on success.
int gdbHioDevRedirectStdStreams(bool in, bool out, bool err);
///< GDB HIO POSIX function gettimeofday.
int gdbHioDevGettimeofday(struct timeval *tv, void *tz);
///< GDB HIO POSIX function isatty.
int gdbHioDevIsatty(int fd);
///< GDB HIO POSIX function system. Requires 'set remote system-call-allowed 1'.
int gdbHioDevSystem(const char *command);

180
.vscode/dummyinclude/3ds/gfx.h vendored Normal file
View file

@ -0,0 +1,180 @@
/**
* @file gfx.h
* @brief Simple framebuffer API
*
* This API provides basic functionality needed to bring up framebuffers for both screens,
* as well as managing display mode (stereoscopic 3D) and double buffering.
* It is mainly an abstraction over the gsp service.
*
* Please note that the 3DS uses *portrait* screens rotated 90 degrees counterclockwise.
* Width/height refer to the physical dimensions of the screen; that is, the top screen
* is 240 pixels wide and 400 pixels tall; while the bottom screen is 240x320.
*/
#pragma once
#include <3ds/types.h>
#include <3ds/services/gspgpu.h>
/// Converts red, green, and blue components to packed RGB565.
#define RGB565(r,g,b) (((b)&0x1f)|(((g)&0x3f)<<5)|(((r)&0x1f)<<11))
/// Converts packed RGB8 to packed RGB565.
#define RGB8_to_565(r,g,b) (((b)>>3)&0x1f)|((((g)>>2)&0x3f)<<5)|((((r)>>3)&0x1f)<<11)
/// Screen IDs.
typedef enum {
GFX_TOP = GSP_SCREEN_TOP, ///< Top screen
GFX_BOTTOM = GSP_SCREEN_BOTTOM, ///< Bottom screen
} gfxScreen_t;
/**
* @brief Top screen framebuffer side.
*
* This is only meaningful when stereoscopic 3D is enabled on the top screen.
* In any other case, use \ref GFX_LEFT.
*/
typedef enum {
GFX_LEFT = 0, ///< Left eye framebuffer
GFX_RIGHT = 1, ///< Right eye framebuffer
} gfx3dSide_t;
///@name Initialization and deinitialization
///@{
/**
* @brief Initializes the LCD framebuffers with default parameters
* This is equivalent to calling: @code gfxInit(GSP_BGR8_OES,GSP_BGR8_OES,false); @endcode
*/
void gfxInitDefault(void);
/**
* @brief Initializes the LCD framebuffers.
* @param topFormat The format of the top screen framebuffers.
* @param bottomFormat The format of the bottom screen framebuffers.
* @param vramBuffers Whether to allocate the framebuffers in VRAM.
*
* This function allocates memory for the framebuffers in the specified memory region.
* Initially, stereoscopic 3D is disabled and double buffering is enabled.
*
* @note This function internally calls \ref gspInit.
*/
void gfxInit(GSPGPU_FramebufferFormat topFormat, GSPGPU_FramebufferFormat bottomFormat, bool vrambuffers);
/**
* @brief Deinitializes and frees the LCD framebuffers.
* @note This function internally calls \ref gspExit.
*/
void gfxExit(void);
///@}
///@name Control
///@{
/**
* @brief Enables or disables the 3D stereoscopic effect on the top screen.
* @param enable Pass true to enable, false to disable.
* @note Stereoscopic 3D is disabled by default.
*/
void gfxSet3D(bool enable);
/**
* @brief Retrieves the status of the 3D stereoscopic effect on the top screen.
* @return true if 3D enabled, false otherwise.
*/
bool gfxIs3D(void);
/**
* @brief Retrieves the status of the 800px (double-height) high resolution display mode of the top screen.
* @return true if wide mode enabled, false otherwise.
*/
bool gfxIsWide(void);
/**
* @brief Enables or disables the 800px (double-height) high resolution display mode of the top screen.
* @param enable Pass true to enable, false to disable.
* @note Wide mode is disabled by default.
* @note Wide and stereoscopic 3D modes are mutually exclusive.
* @note In wide mode pixels are not square, since scanlines are half as tall as they normally are.
* @warning Wide mode does not work on Old 2DS consoles (however it does work on New 2DS XL consoles).
*/
void gfxSetWide(bool enable);
/**
* @brief Changes the pixel format of a screen.
* @param screen Screen ID (see \ref gfxScreen_t)
* @param format Pixel format (see \ref GSPGPU_FramebufferFormat)
* @note If the currently allocated framebuffers are too small for the specified format,
* they are freed and new ones are reallocated.
*/
void gfxSetScreenFormat(gfxScreen_t screen, GSPGPU_FramebufferFormat format);
/**
* @brief Retrieves the current pixel format of a screen.
* @param screen Screen ID (see \ref gfxScreen_t)
* @return Pixel format (see \ref GSPGPU_FramebufferFormat)
*/
GSPGPU_FramebufferFormat gfxGetScreenFormat(gfxScreen_t screen);
/**
* @brief Enables or disables double buffering on a screen.
* @param screen Screen ID (see \ref gfxScreen_t)
* @param enable Pass true to enable, false to disable.
* @note Double buffering is enabled by default.
*/
void gfxSetDoubleBuffering(gfxScreen_t screen, bool enable);
///@}
///@name Rendering and presentation
///@{
/**
* @brief Retrieves the framebuffer of the specified screen to which graphics should be rendered.
* @param screen Screen ID (see \ref gfxScreen_t)
* @param side Framebuffer side (see \ref gfx3dSide_t) (pass \ref GFX_LEFT if not using stereoscopic 3D)
* @param width Pointer that will hold the width of the framebuffer in pixels.
* @param height Pointer that will hold the height of the framebuffer in pixels.
* @return A pointer to the current framebuffer of the chosen screen.
*
* Please remember that the returned pointer will change every frame if double buffering is enabled.
*/
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height);
/**
* @brief Flushes the data cache for the current framebuffers.
* @warning This is **only used during software rendering**. Since this function has significant overhead,
* it is preferred to call this only once per frame, after all software rendering is completed.
*/
void gfxFlushBuffers(void);
/**
* @brief Updates the configuration of the specified screen, swapping the buffers if double buffering is enabled.
* @param scr Screen ID (see \ref gfxScreen_t)
* @param hasStereo For the top screen in 3D mode: true if the framebuffer contains individual images
* for both eyes, or false if the left image should be duplicated to the right eye.
* @note Previously rendered content will be displayed on the screen after the next VBlank.
* @note This function is still useful even if double buffering is disabled, as it must be used to commit configuration changes.
* @warning Only call this once per screen per frame, otherwise graphical glitches will occur
* since this API does not implement triple buffering.
*/
void gfxScreenSwapBuffers(gfxScreen_t scr, bool hasStereo);
/**
* @brief Same as \ref gfxScreenSwapBuffers, but with hasStereo set to true.
* @param scr Screen ID (see \ref gfxScreen_t)
* @param immediate This parameter no longer has any effect and is thus ignored.
* @deprecated This function has been superseded by \ref gfxScreenSwapBuffers, please use that instead.
*/
CTR_DEPRECATED void gfxConfigScreen(gfxScreen_t scr, bool immediate);
/**
* @brief Updates the configuration of both screens.
* @note This function is equivalent to: \code gfxScreenSwapBuffers(GFX_TOP,true); gfxScreenSwapBuffers(GFX_BOTTOM,true); \endcode
*/
void gfxSwapBuffers(void);
/// Same as \ref gfxSwapBuffers (formerly different).
void gfxSwapBuffersGpu(void);
///@}

505
.vscode/dummyinclude/3ds/gpu/enums.h vendored Normal file
View file

@ -0,0 +1,505 @@
/**
* @file enums.h
* @brief GPU enumeration values.
*/
#pragma once
/// Creates a texture magnification filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
#define GPU_TEXTURE_MAG_FILTER(v) (((v)&0x1)<<1)
/// Creates a texture minification filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
#define GPU_TEXTURE_MIN_FILTER(v) (((v)&0x1)<<2)
/// Creates a texture mipmap filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
#define GPU_TEXTURE_MIP_FILTER(v) (((v)&0x1)<<24)
/// Creates a texture wrap S parameter from a @ref GPU_TEXTURE_WRAP_PARAM
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<12)
/// Creates a texture wrap T parameter from a @ref GPU_TEXTURE_WRAP_PARAM
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<8)
/// Creates a texture mode parameter from a @ref GPU_TEXTURE_MODE_PARAM
#define GPU_TEXTURE_MODE(v) (((v)&0x7)<<28)
/// Texture parameter indicating ETC1 texture.
#define GPU_TEXTURE_ETC1_PARAM BIT(5)
/// Texture parameter indicating shadow texture.
#define GPU_TEXTURE_SHADOW_PARAM BIT(20)
/// Creates a combiner buffer write configuration.
#define GPU_TEV_BUFFER_WRITE_CONFIG(stage0, stage1, stage2, stage3) ((stage0) | ((stage1) << 1) | ((stage2) << 2) | ((stage3) << 3))
/// Texture filters.
typedef enum
{
GPU_NEAREST = 0x0, ///< Nearest-neighbor interpolation.
GPU_LINEAR = 0x1, ///< Linear interpolation.
} GPU_TEXTURE_FILTER_PARAM;
/// Texture wrap modes.
typedef enum
{
GPU_CLAMP_TO_EDGE = 0x0, ///< Clamps to edge.
GPU_CLAMP_TO_BORDER = 0x1, ///< Clamps to border.
GPU_REPEAT = 0x2, ///< Repeats texture.
GPU_MIRRORED_REPEAT = 0x3, ///< Repeats with mirrored texture.
} GPU_TEXTURE_WRAP_PARAM;
/// Texture modes.
typedef enum
{
GPU_TEX_2D = 0x0, ///< 2D texture
GPU_TEX_CUBE_MAP = 0x1, ///< Cube map
GPU_TEX_SHADOW_2D = 0x2, ///< 2D Shadow texture
GPU_TEX_PROJECTION = 0x3, ///< Projection texture
GPU_TEX_SHADOW_CUBE = 0x4, ///< Shadow cube map
GPU_TEX_DISABLED = 0x5, ///< Disabled
} GPU_TEXTURE_MODE_PARAM;
/// Supported texture units.
typedef enum
{
GPU_TEXUNIT0 = 0x1, ///< Texture unit 0.
GPU_TEXUNIT1 = 0x2, ///< Texture unit 1.
GPU_TEXUNIT2 = 0x4, ///< Texture unit 2.
} GPU_TEXUNIT;
/// Supported texture formats.
typedef enum
{
GPU_RGBA8 = 0x0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
GPU_RGB8 = 0x1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
GPU_RGBA5551 = 0x2, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
GPU_RGB565 = 0x3, ///< 5-bit Red + 6-bit Green + 5-bit Blue
GPU_RGBA4 = 0x4, ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
GPU_LA8 = 0x5, ///< 8-bit Luminance + 8-bit Alpha
GPU_HILO8 = 0x6, ///< 8-bit Hi + 8-bit Lo
GPU_L8 = 0x7, ///< 8-bit Luminance
GPU_A8 = 0x8, ///< 8-bit Alpha
GPU_LA4 = 0x9, ///< 4-bit Luminance + 4-bit Alpha
GPU_L4 = 0xA, ///< 4-bit Luminance
GPU_A4 = 0xB, ///< 4-bit Alpha
GPU_ETC1 = 0xC, ///< ETC1 texture compression
GPU_ETC1A4 = 0xD, ///< ETC1 texture compression + 4-bit Alpha
} GPU_TEXCOLOR;
/// Texture faces.
typedef enum
{
GPU_TEXFACE_2D = 0, ///< 2D face
GPU_POSITIVE_X = 0, ///< +X face
GPU_NEGATIVE_X = 1, ///< -X face
GPU_POSITIVE_Y = 2, ///< +Y face
GPU_NEGATIVE_Y = 3, ///< -Y face
GPU_POSITIVE_Z = 4, ///< +Z face
GPU_NEGATIVE_Z = 5, ///< -Z face
} GPU_TEXFACE;
/// Procedural texture clamp modes.
typedef enum
{
GPU_PT_CLAMP_TO_ZERO = 0, ///< Clamp to zero.
GPU_PT_CLAMP_TO_EDGE = 1, ///< Clamp to edge.
GPU_PT_REPEAT = 2, ///< Symmetrical repeat.
GPU_PT_MIRRORED_REPEAT = 3, ///< Mirrored repeat.
GPU_PT_PULSE = 4, ///< Pulse.
} GPU_PROCTEX_CLAMP;
/// Procedural texture mapping functions.
typedef enum
{
GPU_PT_U = 0, ///< U
GPU_PT_U2 = 1, ///< U2
GPU_PT_V = 2, ///< V
GPU_PT_V2 = 3, ///< V2
GPU_PT_ADD = 4, ///< U+V
GPU_PT_ADD2 = 5, ///< U2+V2
GPU_PT_SQRT2 = 6, ///< sqrt(U2+V2)
GPU_PT_MIN = 7, ///< min
GPU_PT_MAX = 8, ///< max
GPU_PT_RMAX = 9, ///< rmax
} GPU_PROCTEX_MAPFUNC;
/// Procedural texture shift values.
typedef enum
{
GPU_PT_NONE = 0, ///< No shift.
GPU_PT_ODD = 1, ///< Odd shift.
GPU_PT_EVEN = 2, ///< Even shift.
} GPU_PROCTEX_SHIFT;
/// Procedural texture filter values.
typedef enum
{
GPU_PT_NEAREST = 0, ///< Nearest-neighbor
GPU_PT_LINEAR = 1, ///< Linear interpolation
GPU_PT_NEAREST_MIP_NEAREST = 2, ///< Nearest-neighbor with mipmap using nearest-neighbor
GPU_PT_LINEAR_MIP_NEAREST = 3, ///< Linear interpolation with mipmap using nearest-neighbor
GPU_PT_NEAREST_MIP_LINEAR = 4, ///< Nearest-neighbor with mipmap using linear interpolation
GPU_PT_LINEAR_MIP_LINEAR = 5, ///< Linear interpolation with mipmap using linear interpolation
} GPU_PROCTEX_FILTER;
/// Procedural texture LUT IDs.
typedef enum
{
GPU_LUT_NOISE = 0, ///< Noise table
GPU_LUT_RGBMAP = 2, ///< RGB mapping function table
GPU_LUT_ALPHAMAP = 3, ///< Alpha mapping function table
GPU_LUT_COLOR = 4, ///< Color table
GPU_LUT_COLORDIF = 5, ///< Color difference table
} GPU_PROCTEX_LUTID;
/// Supported color buffer formats.
typedef enum
{
GPU_RB_RGBA8 = 0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
GPU_RB_RGB8 = 1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
GPU_RB_RGBA5551 = 2, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
GPU_RB_RGB565 = 3, ///< 5-bit Red + 6-bit Green + 5-bit Blue
GPU_RB_RGBA4 = 4, ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
} GPU_COLORBUF;
/// Supported depth buffer formats.
typedef enum
{
GPU_RB_DEPTH16 = 0, ///< 16-bit Depth
GPU_RB_DEPTH24 = 2, ///< 24-bit Depth
GPU_RB_DEPTH24_STENCIL8 = 3, ///< 24-bit Depth + 8-bit Stencil
} GPU_DEPTHBUF;
/// Test functions.
typedef enum
{
GPU_NEVER = 0, ///< Never pass.
GPU_ALWAYS = 1, ///< Always pass.
GPU_EQUAL = 2, ///< Pass if equal.
GPU_NOTEQUAL = 3, ///< Pass if not equal.
GPU_LESS = 4, ///< Pass if less than.
GPU_LEQUAL = 5, ///< Pass if less than or equal.
GPU_GREATER = 6, ///< Pass if greater than.
GPU_GEQUAL = 7, ///< Pass if greater than or equal.
} GPU_TESTFUNC;
/// Early depth test functions.
typedef enum
{
GPU_EARLYDEPTH_GEQUAL = 0, ///< Pass if greater than or equal.
GPU_EARLYDEPTH_GREATER = 1, ///< Pass if greater than.
GPU_EARLYDEPTH_LEQUAL = 2, ///< Pass if less than or equal.
GPU_EARLYDEPTH_LESS = 3, ///< Pass if less than.
} GPU_EARLYDEPTHFUNC;
/// Gas depth functions.
typedef enum
{
GPU_GAS_NEVER = 0, ///< Never pass (0).
GPU_GAS_ALWAYS = 1, ///< Always pass (1).
GPU_GAS_GREATER = 2, ///< Pass if greater than (1-X).
GPU_GAS_LESS = 3, ///< Pass if less than (X).
} GPU_GASDEPTHFUNC;
/// Converts \ref GPU_TESTFUNC into \ref GPU_GASDEPTHFUNC.
#define GPU_MAKEGASDEPTHFUNC(n) (GPU_GASDEPTHFUNC)((0xAF02>>((int)(n)<<1))&3)
/// Scissor test modes.
typedef enum
{
GPU_SCISSOR_DISABLE = 0, ///< Disable.
GPU_SCISSOR_INVERT = 1, ///< Exclude pixels inside the scissor box.
// 2 is the same as 0
GPU_SCISSOR_NORMAL = 3, ///< Exclude pixels outside of the scissor box.
} GPU_SCISSORMODE;
/// Stencil operations.
typedef enum
{
GPU_STENCIL_KEEP = 0, ///< Keep old value. (old_stencil)
GPU_STENCIL_ZERO = 1, ///< Zero. (0)
GPU_STENCIL_REPLACE = 2, ///< Replace value. (ref)
GPU_STENCIL_INCR = 3, ///< Increment value. (old_stencil + 1 saturated to [0, 255])
GPU_STENCIL_DECR = 4, ///< Decrement value. (old_stencil - 1 saturated to [0, 255])
GPU_STENCIL_INVERT = 5, ///< Invert value. (~old_stencil)
GPU_STENCIL_INCR_WRAP = 6, ///< Increment value. (old_stencil + 1)
GPU_STENCIL_DECR_WRAP = 7, ///< Decrement value. (old_stencil - 1)
} GPU_STENCILOP;
/// Pixel write mask.
typedef enum
{
GPU_WRITE_RED = 0x01, ///< Write red.
GPU_WRITE_GREEN = 0x02, ///< Write green.
GPU_WRITE_BLUE = 0x04, ///< Write blue.
GPU_WRITE_ALPHA = 0x08, ///< Write alpha.
GPU_WRITE_DEPTH = 0x10, ///< Write depth.
GPU_WRITE_COLOR = 0x0F, ///< Write all color components.
GPU_WRITE_ALL = 0x1F, ///< Write all components.
} GPU_WRITEMASK;
/// Blend modes.
typedef enum
{
GPU_BLEND_ADD = 0, ///< Add colors.
GPU_BLEND_SUBTRACT = 1, ///< Subtract colors.
GPU_BLEND_REVERSE_SUBTRACT = 2, ///< Reverse-subtract colors.
GPU_BLEND_MIN = 3, ///< Use the minimum color.
GPU_BLEND_MAX = 4, ///< Use the maximum color.
} GPU_BLENDEQUATION;
/// Blend factors.
typedef enum
{
GPU_ZERO = 0, ///< Zero.
GPU_ONE = 1, ///< One.
GPU_SRC_COLOR = 2, ///< Source color.
GPU_ONE_MINUS_SRC_COLOR = 3, ///< Source color - 1.
GPU_DST_COLOR = 4, ///< Destination color.
GPU_ONE_MINUS_DST_COLOR = 5, ///< Destination color - 1.
GPU_SRC_ALPHA = 6, ///< Source alpha.
GPU_ONE_MINUS_SRC_ALPHA = 7, ///< Source alpha - 1.
GPU_DST_ALPHA = 8, ///< Destination alpha.
GPU_ONE_MINUS_DST_ALPHA = 9, ///< Destination alpha - 1.
GPU_CONSTANT_COLOR = 10, ///< Constant color.
GPU_ONE_MINUS_CONSTANT_COLOR = 11, ///< Constant color - 1.
GPU_CONSTANT_ALPHA = 12, ///< Constant alpha.
GPU_ONE_MINUS_CONSTANT_ALPHA = 13, ///< Constant alpha - 1.
GPU_SRC_ALPHA_SATURATE = 14, ///< Saturated alpha.
} GPU_BLENDFACTOR;
/// Logical operations.
typedef enum
{
GPU_LOGICOP_CLEAR = 0, ///< Clear.
GPU_LOGICOP_AND = 1, ///< Bitwise AND.
GPU_LOGICOP_AND_REVERSE = 2, ///< Reverse bitwise AND.
GPU_LOGICOP_COPY = 3, ///< Copy.
GPU_LOGICOP_SET = 4, ///< Set.
GPU_LOGICOP_COPY_INVERTED = 5, ///< Inverted copy.
GPU_LOGICOP_NOOP = 6, ///< No operation.
GPU_LOGICOP_INVERT = 7, ///< Invert.
GPU_LOGICOP_NAND = 8, ///< Bitwise NAND.
GPU_LOGICOP_OR = 9, ///< Bitwise OR.
GPU_LOGICOP_NOR = 10, ///< Bitwise NOR.
GPU_LOGICOP_XOR = 11, ///< Bitwise XOR.
GPU_LOGICOP_EQUIV = 12, ///< Equivalent.
GPU_LOGICOP_AND_INVERTED = 13, ///< Inverted bitwise AND.
GPU_LOGICOP_OR_REVERSE = 14, ///< Reverse bitwise OR.
GPU_LOGICOP_OR_INVERTED = 15, ///< Inverted bitwize OR.
} GPU_LOGICOP;
/// Fragment operation modes.
typedef enum
{
GPU_FRAGOPMODE_GL = 0, ///< OpenGL mode.
GPU_FRAGOPMODE_GAS_ACC = 1, ///< Gas mode (?).
GPU_FRAGOPMODE_SHADOW = 3, ///< Shadow mode (?).
} GPU_FRAGOPMODE;
/// Supported component formats.
typedef enum
{
GPU_BYTE = 0, ///< 8-bit byte.
GPU_UNSIGNED_BYTE = 1, ///< 8-bit unsigned byte.
GPU_SHORT = 2, ///< 16-bit short.
GPU_FLOAT = 3, ///< 32-bit float.
} GPU_FORMATS;
/// Cull modes.
typedef enum
{
GPU_CULL_NONE = 0, ///< Disabled.
GPU_CULL_FRONT_CCW = 1, ///< Front, counter-clockwise.
GPU_CULL_BACK_CCW = 2, ///< Back, counter-clockwise.
} GPU_CULLMODE;
/// Creates a VBO attribute parameter from its index, size, and format.
#define GPU_ATTRIBFMT(i, n, f) (((((n)-1)<<2)|((f)&3))<<((i)*4))
/// Texture combiner sources.
typedef enum
{
GPU_PRIMARY_COLOR = 0x00, ///< Primary color.
GPU_FRAGMENT_PRIMARY_COLOR = 0x01, ///< Primary fragment color.
GPU_FRAGMENT_SECONDARY_COLOR = 0x02, ///< Secondary fragment color.
GPU_TEXTURE0 = 0x03, ///< Texture unit 0.
GPU_TEXTURE1 = 0x04, ///< Texture unit 1.
GPU_TEXTURE2 = 0x05, ///< Texture unit 2.
GPU_TEXTURE3 = 0x06, ///< Texture unit 3.
GPU_PREVIOUS_BUFFER = 0x0D, ///< Previous buffer.
GPU_CONSTANT = 0x0E, ///< Constant value.
GPU_PREVIOUS = 0x0F, ///< Previous value.
} GPU_TEVSRC;
/// Texture RGB combiner operands.
typedef enum
{
GPU_TEVOP_RGB_SRC_COLOR = 0x00, ///< Source color.
GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR = 0x01, ///< Source color - 1.
GPU_TEVOP_RGB_SRC_ALPHA = 0x02, ///< Source alpha.
GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA = 0x03, ///< Source alpha - 1.
GPU_TEVOP_RGB_SRC_R = 0x04, ///< Source red.
GPU_TEVOP_RGB_ONE_MINUS_SRC_R = 0x05, ///< Source red - 1.
GPU_TEVOP_RGB_0x06 = 0x06, ///< Unknown.
GPU_TEVOP_RGB_0x07 = 0x07, ///< Unknown.
GPU_TEVOP_RGB_SRC_G = 0x08, ///< Source green.
GPU_TEVOP_RGB_ONE_MINUS_SRC_G = 0x09, ///< Source green - 1.
GPU_TEVOP_RGB_0x0A = 0x0A, ///< Unknown.
GPU_TEVOP_RGB_0x0B = 0x0B, ///< Unknown.
GPU_TEVOP_RGB_SRC_B = 0x0C, ///< Source blue.
GPU_TEVOP_RGB_ONE_MINUS_SRC_B = 0x0D, ///< Source blue - 1.
GPU_TEVOP_RGB_0x0E = 0x0E, ///< Unknown.
GPU_TEVOP_RGB_0x0F = 0x0F, ///< Unknown.
} GPU_TEVOP_RGB;
/// Texture Alpha combiner operands.
typedef enum
{
GPU_TEVOP_A_SRC_ALPHA = 0x00, ///< Source alpha.
GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA = 0x01, ///< Source alpha - 1.
GPU_TEVOP_A_SRC_R = 0x02, ///< Source red.
GPU_TEVOP_A_ONE_MINUS_SRC_R = 0x03, ///< Source red - 1.
GPU_TEVOP_A_SRC_G = 0x04, ///< Source green.
GPU_TEVOP_A_ONE_MINUS_SRC_G = 0x05, ///< Source green - 1.
GPU_TEVOP_A_SRC_B = 0x06, ///< Source blue.
GPU_TEVOP_A_ONE_MINUS_SRC_B = 0x07, ///< Source blue - 1.
} GPU_TEVOP_A;
/// Texture combiner functions.
typedef enum
{
GPU_REPLACE = 0x00, ///< Replace.
GPU_MODULATE = 0x01, ///< Modulate.
GPU_ADD = 0x02, ///< Add.
GPU_ADD_SIGNED = 0x03, ///< Signed add.
GPU_INTERPOLATE = 0x04, ///< Interpolate.
GPU_SUBTRACT = 0x05, ///< Subtract.
GPU_DOT3_RGB = 0x06, ///< Dot3. Scalar result is written to RGB only.
GPU_DOT3_RGBA = 0x07, ///< Dot3. Scalar result is written to RGBA.
GPU_MULTIPLY_ADD = 0x08, ///< Multiply then add.
GPU_ADD_MULTIPLY = 0x09, ///< Add then multiply.
} GPU_COMBINEFUNC;
/// Texture scale factors.
typedef enum
{
GPU_TEVSCALE_1 = 0x0, ///< 1x
GPU_TEVSCALE_2 = 0x1, ///< 2x
GPU_TEVSCALE_4 = 0x2, ///< 4x
} GPU_TEVSCALE;
/// Creates a texture combiner source parameter from three sources.
#define GPU_TEVSOURCES(a,b,c) (((a))|((b)<<4)|((c)<<8))
/// Creates a texture combiner operand parameter from three operands.
#define GPU_TEVOPERANDS(a,b,c) (((a))|((b)<<4)|((c)<<8))
/// Creates a light environment layer configuration parameter.
#define GPU_LIGHT_ENV_LAYER_CONFIG(n) ((n)+((n)==7))
/// Light shadow disable bits in GPUREG_LIGHT_CONFIG1.
#define GPU_LC1_SHADOWBIT(n) BIT(n)
/// Light spot disable bits in GPUREG_LIGHT_CONFIG1.
#define GPU_LC1_SPOTBIT(n) BIT((n)+8)
/// LUT disable bits in GPUREG_LIGHT_CONFIG1.
#define GPU_LC1_LUTBIT(n) BIT((n)+16)
/// Light distance attenuation disable bits in GPUREG_LIGHT_CONFIG1.
#define GPU_LC1_ATTNBIT(n) BIT((n)+24)
/// Creates a light permutation parameter.
#define GPU_LIGHTPERM(i,n) ((n) << ((i)*4))
/// Creates a light LUT input parameter.
#define GPU_LIGHTLUTINPUT(i,n) ((n) << ((i)*4))
/// Creates a light LUT index parameter.
#define GPU_LIGHTLUTIDX(c,i,o) ((o) | ((i) << 8) | ((c) << 11))
/// Creates a light color parameter from red, green, and blue components.
#define GPU_LIGHTCOLOR(r,g,b) (((b) & 0xFF) | (((g) << 10) & 0xFF) | (((r) << 20) & 0xFF))
/// Fresnel options.
typedef enum
{
GPU_NO_FRESNEL = 0, ///< None.
GPU_PRI_ALPHA_FRESNEL = 1, ///< Primary alpha.
GPU_SEC_ALPHA_FRESNEL = 2, ///< Secondary alpha.
GPU_PRI_SEC_ALPHA_FRESNEL = 3, ///< Primary and secondary alpha.
} GPU_FRESNELSEL;
/// Bump map modes.
typedef enum
{
GPU_BUMP_NOT_USED = 0, ///< Disabled.
GPU_BUMP_AS_BUMP = 1, ///< Bump as bump mapping.
GPU_BUMP_AS_TANG = 2, ///< Bump as tangent/normal mapping.
} GPU_BUMPMODE;
/// LUT IDs.
typedef enum
{
GPU_LUT_D0 = 0, ///< D0 LUT.
GPU_LUT_D1 = 1, ///< D1 LUT.
GPU_LUT_SP = 2, ///< Spotlight LUT.
GPU_LUT_FR = 3, ///< Fresnel LUT.
GPU_LUT_RB = 4, ///< Reflection-Blue LUT.
GPU_LUT_RG = 5, ///< Reflection-Green LUT.
GPU_LUT_RR = 6, ///< Reflection-Red LUT.
GPU_LUT_DA = 7, ///< Distance attenuation LUT.
} GPU_LIGHTLUTID;
/// LUT inputs.
typedef enum
{
GPU_LUTINPUT_NH = 0, ///< Normal*HalfVector
GPU_LUTINPUT_VH = 1, ///< View*HalfVector
GPU_LUTINPUT_NV = 2, ///< Normal*View
GPU_LUTINPUT_LN = 3, ///< LightVector*Normal
GPU_LUTINPUT_SP = 4, ///< -LightVector*SpotlightVector
GPU_LUTINPUT_CP = 5, ///< cosine of phi
} GPU_LIGHTLUTINPUT;
/// LUT scalers.
typedef enum
{
GPU_LUTSCALER_1x = 0, ///< 1x scale.
GPU_LUTSCALER_2x = 1, ///< 2x scale.
GPU_LUTSCALER_4x = 2, ///< 4x scale.
GPU_LUTSCALER_8x = 3, ///< 8x scale.
GPU_LUTSCALER_0_25x = 6, ///< 0.25x scale.
GPU_LUTSCALER_0_5x = 7, ///< 0.5x scale.
} GPU_LIGHTLUTSCALER;
/// LUT selection.
typedef enum
{
GPU_LUTSELECT_COMMON = 0, ///< LUTs that are common to all lights.
GPU_LUTSELECT_SP = 1, ///< Spotlight LUT.
GPU_LUTSELECT_DA = 2, ///< Distance attenuation LUT.
} GPU_LIGHTLUTSELECT;
/// Fog modes.
typedef enum
{
GPU_NO_FOG = 0, ///< Fog/Gas unit disabled.
GPU_FOG = 5, ///< Fog/Gas unit configured in Fog mode.
GPU_GAS = 7, ///< Fog/Gas unit configured in Gas mode.
} GPU_FOGMODE;
/// Gas shading density source values.
typedef enum
{
GPU_PLAIN_DENSITY = 0, ///< Plain density.
GPU_DEPTH_DENSITY = 1, ///< Depth density.
} GPU_GASMODE;
/// Gas color LUT inputs.
typedef enum
{
GPU_GAS_DENSITY = 0, ///< Gas density used as input.
GPU_GAS_LIGHT_FACTOR = 1, ///< Light factor used as input.
} GPU_GASLUTINPUT;
/// Supported primitives.
typedef enum
{
GPU_TRIANGLES = 0x0000, ///< Triangles.
GPU_TRIANGLE_STRIP = 0x0100, ///< Triangle strip.
GPU_TRIANGLE_FAN = 0x0200, ///< Triangle fan.
GPU_GEOMETRY_PRIM = 0x0300, ///< Geometry shader primitive.
} GPU_Primitive_t;
/// Shader types.
typedef enum
{
GPU_VERTEX_SHADER = 0x0, ///< Vertex shader.
GPU_GEOMETRY_SHADER = 0x1, ///< Geometry shader.
} GPU_SHADER_TYPE;

119
.vscode/dummyinclude/3ds/gpu/gpu.h vendored Normal file
View file

@ -0,0 +1,119 @@
/**
* @file gpu.h
* @brief Barebones GPU communications driver.
*/
#pragma once
#include "registers.h"
#include "enums.h"
/// Creates a GPU command header from its write increments, mask, and register.
#define GPUCMD_HEADER(incremental, mask, reg) (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF))
extern u32* gpuCmdBuf; ///< GPU command buffer.
extern u32 gpuCmdBufSize; ///< GPU command buffer size.
extern u32 gpuCmdBufOffset; ///< GPU command buffer offset.
/**
* @brief Sets the GPU command buffer to use.
* @param adr Pointer to the command buffer.
* @param size Size of the command buffer.
* @param offset Offset of the command buffer.
*/
static inline void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset)
{
gpuCmdBuf=adr;
gpuCmdBufSize=size;
gpuCmdBufOffset=offset;
}
/**
* @brief Sets the offset of the GPU command buffer.
* @param offset Offset of the command buffer.
*/
static inline void GPUCMD_SetBufferOffset(u32 offset)
{
gpuCmdBufOffset=offset;
}
/**
* @brief Gets the current GPU command buffer.
* @param addr Pointer to output the command buffer to.
* @param size Pointer to output the size (in words) of the command buffer to.
* @param offset Pointer to output the offset of the command buffer to.
*/
static inline void GPUCMD_GetBuffer(u32** addr, u32* size, u32* offset)
{
if(addr)*addr=gpuCmdBuf;
if(size)*size=gpuCmdBufSize;
if(offset)*offset=gpuCmdBufOffset;
}
/**
* @brief Adds raw GPU commands to the current command buffer.
* @param cmd Buffer containing commands to add.
* @param size Size of the buffer.
*/
void GPUCMD_AddRawCommands(const u32* cmd, u32 size);
/**
* @brief Adds a GPU command to the current command buffer.
* @param header Header of the command.
* @param param Parameters of the command.
* @param paramlength Size of the parameter buffer.
*/
void GPUCMD_Add(u32 header, const u32* param, u32 paramlength);
/**
* @brief Splits the current GPU command buffer.
* @param addr Pointer to output the command buffer to.
* @param size Pointer to output the size (in words) of the command buffer to.
*/
void GPUCMD_Split(u32** addr, u32* size);
/**
* @brief Converts a 32-bit float to a 16-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof16(float f);
/**
* @brief Converts a 32-bit float to a 20-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof20(float f);
/**
* @brief Converts a 32-bit float to a 24-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof24(float f);
/**
* @brief Converts a 32-bit float to a 31-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof31(float f);
/// Adds a command with a single parameter to the current command buffer.
static inline void GPUCMD_AddSingleParam(u32 header, u32 param)
{
GPUCMD_Add(header, &param, 1);
}
/// Adds a masked register write to the current command buffer.
#define GPUCMD_AddMaskedWrite(reg, mask, val) GPUCMD_AddSingleParam(GPUCMD_HEADER(0, (mask), (reg)), (val))
/// Adds a register write to the current command buffer.
#define GPUCMD_AddWrite(reg, val) GPUCMD_AddMaskedWrite((reg), 0xF, (val))
/// Adds multiple masked register writes to the current command buffer.
#define GPUCMD_AddMaskedWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(0, (mask), (reg)), (vals), (num))
/// Adds multiple register writes to the current command buffer.
#define GPUCMD_AddWrites(reg, vals, num) GPUCMD_AddMaskedWrites((reg), 0xF, (vals), (num))
/// Adds multiple masked incremental register writes to the current command buffer.
#define GPUCMD_AddMaskedIncrementalWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(1, (mask), (reg)), (vals), (num))
/// Adds multiple incremental register writes to the current command buffer.
#define GPUCMD_AddIncrementalWrites(reg, vals, num) GPUCMD_AddMaskedIncrementalWrites((reg), 0xF, (vals), (num))

206
.vscode/dummyinclude/3ds/gpu/gx.h vendored Normal file
View file

@ -0,0 +1,206 @@
/**
* @file gx.h
* @brief GX commands.
*/
#pragma once
/**
* @brief Creates a buffer dimension parameter from width and height values.
* @param w buffer width for GX_DisplayTransfer, linesize for GX_TextureCopy
* @param h buffer height for GX_DisplayTransfer, gap for GX_TextureCopy
*/
#define GX_BUFFER_DIM(w, h) (((h)<<16)|((w)&0xFFFF))
/**
* @brief Supported transfer pixel formats.
* @sa GSPGPU_FramebufferFormat
*/
typedef enum
{
GX_TRANSFER_FMT_RGBA8 = 0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
GX_TRANSFER_FMT_RGB8 = 1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
GX_TRANSFER_FMT_RGB565 = 2, ///< 5-bit Red + 6-bit Green + 5-bit Blue
GX_TRANSFER_FMT_RGB5A1 = 3, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
GX_TRANSFER_FMT_RGBA4 = 4 ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
} GX_TRANSFER_FORMAT;
/**
* @brief Anti-aliasing modes
*
* Please remember that the framebuffer is sideways.
* Hence if you activate 2x1 anti-aliasing the destination dimensions are w = 240*2 and h = 400
*/
typedef enum
{
GX_TRANSFER_SCALE_NO = 0, ///< No anti-aliasing
GX_TRANSFER_SCALE_X = 1, ///< 2x1 anti-aliasing
GX_TRANSFER_SCALE_XY = 2, ///< 2x2 anti-aliasing
} GX_TRANSFER_SCALE;
/// GX transfer control flags
typedef enum
{
GX_FILL_TRIGGER = 0x001, ///< Trigger the PPF event
GX_FILL_FINISHED = 0x002, ///< Indicates if the memory fill is complete. You should not use it when requesting a transfer.
GX_FILL_16BIT_DEPTH = 0x000, ///< The buffer has a 16 bit per pixel depth
GX_FILL_24BIT_DEPTH = 0x100, ///< The buffer has a 24 bit per pixel depth
GX_FILL_32BIT_DEPTH = 0x200, ///< The buffer has a 32 bit per pixel depth
} GX_FILL_CONTROL;
/// Creates a transfer vertical flip flag.
#define GX_TRANSFER_FLIP_VERT(x) ((x)<<0)
/// Creates a transfer tiled output flag.
#define GX_TRANSFER_OUT_TILED(x) ((x)<<1)
/// Creates a transfer raw copy flag.
#define GX_TRANSFER_RAW_COPY(x) ((x)<<3)
/// Creates a transfer input format flag.
#define GX_TRANSFER_IN_FORMAT(x) ((x)<<8)
/// Creates a transfer output format flag.
#define GX_TRANSFER_OUT_FORMAT(x) ((x)<<12)
/// Creates a transfer scaling flag.
#define GX_TRANSFER_SCALING(x) ((x)<<24)
/// Updates gas additive blend results.
#define GX_CMDLIST_UPDATE_GAS_ACC BIT(0)
/// Flushes the command list.
#define GX_CMDLIST_FLUSH BIT(1)
/// GX command entry
typedef union
{
u32 data[8]; ///< Raw command data
struct
{
u8 type; ///< Command type
u8 unk1;
u8 unk2;
u8 unk3;
u32 args[7]; ///< Command arguments
};
} gxCmdEntry_s;
/// GX command queue structure
typedef struct tag_gxCmdQueue_s
{
gxCmdEntry_s* entries; ///< Pointer to array of GX command entries
u16 maxEntries; ///< Capacity of the command array
u16 numEntries; ///< Number of commands in the queue
u16 curEntry; ///< Index of the first pending command to be submitted to GX
u16 lastEntry; ///< Number of commands completed by GX
void (* callback)(struct tag_gxCmdQueue_s*); ///< User callback
void* user; ///< Data for user callback
} gxCmdQueue_s;
/**
* @brief Clears a GX command queue.
* @param queue The GX command queue.
*/
void gxCmdQueueClear(gxCmdQueue_s* queue);
/**
* @brief Adds a command to a GX command queue.
* @param queue The GX command queue.
* @param entry The GX command to add.
*/
void gxCmdQueueAdd(gxCmdQueue_s* queue, const gxCmdEntry_s* entry);
/**
* @brief Runs a GX command queue, causing it to begin processing incoming commands as they arrive.
* @param queue The GX command queue.
*/
void gxCmdQueueRun(gxCmdQueue_s* queue);
/**
* @brief Stops a GX command queue from processing incoming commands.
* @param queue The GX command queue.
*/
void gxCmdQueueStop(gxCmdQueue_s* queue);
/**
* @brief Waits for a GX command queue to finish executing pending commands.
* @param queue The GX command queue.
* @param timeout Optional timeout (in nanoseconds) to wait (specify -1 for no timeout).
* @return false if timeout expired, true otherwise.
*/
bool gxCmdQueueWait(gxCmdQueue_s* queue, s64 timeout);
/**
* @brief Sets the completion callback for a GX command queue.
* @param queue The GX command queue.
* @param callback The completion callback.
* @param user User data.
*/
static inline void gxCmdQueueSetCallback(gxCmdQueue_s* queue, void (* callback)(gxCmdQueue_s*), void* user)
{
queue->callback = callback;
queue->user = user;
}
/**
* @brief Selects a command queue to which GX_* functions will add commands instead of immediately submitting them to GX.
* @param queue The GX command queue. (Pass NULL to remove the bound command queue)
*/
void GX_BindQueue(gxCmdQueue_s* queue);
/**
* @brief Requests a DMA.
* @param src Source to DMA from.
* @param dst Destination to DMA to.
* @param length Length of data to transfer.
*/
Result GX_RequestDma(u32* src, u32* dst, u32 length);
/**
* @brief Processes a GPU command list.
* @param buf0a Command list address.
* @param buf0s Command list size.
* @param flags Flags to process with.
*/
Result GX_ProcessCommandList(u32* buf0a, u32 buf0s, u8 flags);
/**
* @brief Fills the memory of two buffers with the given values.
* @param buf0a Start address of the first buffer.
* @param buf0v Dimensions of the first buffer.
* @param buf0e End address of the first buffer.
* @param control0 Value to fill the first buffer with.
* @param buf1a Start address of the second buffer.
* @param buf1v Dimensions of the second buffer.
* @param buf1e End address of the second buffer.
* @param control1 Value to fill the second buffer with.
*/
Result GX_MemoryFill(u32* buf0a, u32 buf0v, u32* buf0e, u16 control0, u32* buf1a, u32 buf1v, u32* buf1e, u16 control1);
/**
* @brief Initiates a display transfer.
* @note The PPF event will be signaled on completion.
* @param inadr Address of the input.
* @param indim Dimensions of the input.
* @param outadr Address of the output.
* @param outdim Dimensions of the output.
* @param flags Flags to transfer with.
*/
Result GX_DisplayTransfer(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags);
/**
* @brief Initiates a texture copy.
* @note The PPF event will be signaled on completion.
* @param inadr Address of the input.
* @param indim Dimensions of the input.
* @param outadr Address of the output.
* @param outdim Dimensions of the output.
* @param size Size of the data to transfer.
* @param flags Flags to transfer with.
*/
Result GX_TextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
/**
* @brief Flushes the cache regions of three buffers. (This command cannot be queued in a GX command queue)
* @param buf0a Address of the first buffer.
* @param buf0s Size of the first buffer.
* @param buf1a Address of the second buffer.
* @param buf1s Size of the second buffer.
* @param buf2a Address of the third buffer.
* @param buf2s Size of the third buffer.
*/
Result GX_FlushCacheRegions(u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s);

767
.vscode/dummyinclude/3ds/gpu/registers.h vendored Normal file
View file

@ -0,0 +1,767 @@
/**
* @file registers.h
* @description GPU registers.
*/
#pragma once
///@name Miscellaneous registers (0x000-0x03F)
///@{
#define GPUREG_0000 0x0000 ///< Unknown.
#define GPUREG_0001 0x0001 ///< Unknown.
#define GPUREG_0002 0x0002 ///< Unknown.
#define GPUREG_0003 0x0003 ///< Unknown.
#define GPUREG_0004 0x0004 ///< Unknown.
#define GPUREG_0005 0x0005 ///< Unknown.
#define GPUREG_0006 0x0006 ///< Unknown.
#define GPUREG_0007 0x0007 ///< Unknown.
#define GPUREG_0008 0x0008 ///< Unknown.
#define GPUREG_0009 0x0009 ///< Unknown.
#define GPUREG_000A 0x000A ///< Unknown.
#define GPUREG_000B 0x000B ///< Unknown.
#define GPUREG_000C 0x000C ///< Unknown.
#define GPUREG_000D 0x000D ///< Unknown.
#define GPUREG_000E 0x000E ///< Unknown.
#define GPUREG_000F 0x000F ///< Unknown.
#define GPUREG_FINALIZE 0x0010 ///< Used to finalize GPU drawing.
#define GPUREG_0011 0x0011 ///< Unknown.
#define GPUREG_0012 0x0012 ///< Unknown.
#define GPUREG_0013 0x0013 ///< Unknown.
#define GPUREG_0014 0x0014 ///< Unknown.
#define GPUREG_0015 0x0015 ///< Unknown.
#define GPUREG_0016 0x0016 ///< Unknown.
#define GPUREG_0017 0x0017 ///< Unknown.
#define GPUREG_0018 0x0018 ///< Unknown.
#define GPUREG_0019 0x0019 ///< Unknown.
#define GPUREG_001A 0x001A ///< Unknown.
#define GPUREG_001B 0x001B ///< Unknown.
#define GPUREG_001C 0x001C ///< Unknown.
#define GPUREG_001D 0x001D ///< Unknown.
#define GPUREG_001E 0x001E ///< Unknown.
#define GPUREG_001F 0x001F ///< Unknown.
#define GPUREG_0020 0x0020 ///< Unknown.
#define GPUREG_0021 0x0021 ///< Unknown.
#define GPUREG_0022 0x0022 ///< Unknown.
#define GPUREG_0023 0x0023 ///< Unknown.
#define GPUREG_0024 0x0024 ///< Unknown.
#define GPUREG_0025 0x0025 ///< Unknown.
#define GPUREG_0026 0x0026 ///< Unknown.
#define GPUREG_0027 0x0027 ///< Unknown.
#define GPUREG_0028 0x0028 ///< Unknown.
#define GPUREG_0029 0x0029 ///< Unknown.
#define GPUREG_002A 0x002A ///< Unknown.
#define GPUREG_002B 0x002B ///< Unknown.
#define GPUREG_002C 0x002C ///< Unknown.
#define GPUREG_002D 0x002D ///< Unknown.
#define GPUREG_002E 0x002E ///< Unknown.
#define GPUREG_002F 0x002F ///< Unknown.
#define GPUREG_0030 0x0030 ///< Unknown.
#define GPUREG_0031 0x0031 ///< Unknown.
#define GPUREG_0032 0x0032 ///< Unknown.
#define GPUREG_0033 0x0033 ///< Unknown.
#define GPUREG_0034 0x0034 ///< Unknown.
#define GPUREG_0035 0x0035 ///< Unknown.
#define GPUREG_0036 0x0036 ///< Unknown.
#define GPUREG_0037 0x0037 ///< Unknown.
#define GPUREG_0038 0x0038 ///< Unknown.
#define GPUREG_0039 0x0039 ///< Unknown.
#define GPUREG_003A 0x003A ///< Unknown.
#define GPUREG_003B 0x003B ///< Unknown.
#define GPUREG_003C 0x003C ///< Unknown.
#define GPUREG_003D 0x003D ///< Unknown.
#define GPUREG_003E 0x003E ///< Unknown.
#define GPUREG_003F 0x003F ///< Unknown.
///@}
///@name Rasterizer registers (0x040-0x07F)
///@{
#define GPUREG_FACECULLING_CONFIG 0x0040 ///< Face culling configuration.
#define GPUREG_VIEWPORT_WIDTH 0x0041 ///< Viewport width.
#define GPUREG_VIEWPORT_INVW 0x0042 ///< Inverted viewport width.
#define GPUREG_VIEWPORT_HEIGHT 0x0043 ///< Viewport height.
#define GPUREG_VIEWPORT_INVH 0x0044 ///< Inverted viewport height.
#define GPUREG_0045 0x0045 ///< Unknown
#define GPUREG_0046 0x0046 ///< Unknown
#define GPUREG_FRAGOP_CLIP 0x0047 ///< Unknown
#define GPUREG_FRAGOP_CLIP_DATA0 0x0048 ///< Unknown
#define GPUREG_FRAGOP_CLIP_DATA1 0x0049 ///< Unknown
#define GPUREG_FRAGOP_CLIP_DATA2 0x004A ///< Unknown
#define GPUREG_FRAGOP_CLIP_DATA3 0x004B ///< Unknown
#define GPUREG_004C 0x004C ///< Unknown
#define GPUREG_DEPTHMAP_SCALE 0x004D ///< Depth map scale.
#define GPUREG_DEPTHMAP_OFFSET 0x004E ///< Depth map offset.
#define GPUREG_SH_OUTMAP_TOTAL 0x004F ///< Shader output map total.
#define GPUREG_SH_OUTMAP_O0 0x0050 ///< Shader output map 0.
#define GPUREG_SH_OUTMAP_O1 0x0051 ///< Shader output map 1.
#define GPUREG_SH_OUTMAP_O2 0x0052 ///< Shader output map 2.
#define GPUREG_SH_OUTMAP_O3 0x0053 ///< Shader output map 3.
#define GPUREG_SH_OUTMAP_O4 0x0054 ///< Shader output map 4.
#define GPUREG_SH_OUTMAP_O5 0x0055 ///< Shader output map 5.
#define GPUREG_SH_OUTMAP_O6 0x0056 ///< Shader output map 6.
#define GPUREG_0057 0x0057 ///< Unknown
#define GPUREG_0058 0x0058 ///< Unknown
#define GPUREG_0059 0x0059 ///< Unknown
#define GPUREG_005A 0x005A ///< Unknown
#define GPUREG_005B 0x005B ///< Unknown
#define GPUREG_005C 0x005C ///< Unknown
#define GPUREG_005D 0x005D ///< Unknown
#define GPUREG_005E 0x005E ///< Unknown
#define GPUREG_005F 0x005F ///< Unknown
#define GPUREG_0060 0x0060 ///< Unknown
#define GPUREG_EARLYDEPTH_FUNC 0x0061 ///< Unknown
#define GPUREG_EARLYDEPTH_TEST1 0x0062 ///< Unknown
#define GPUREG_EARLYDEPTH_CLEAR 0x0063 ///< Unknown
#define GPUREG_SH_OUTATTR_MODE 0x0064 ///< Shader output attributes mode.
#define GPUREG_SCISSORTEST_MODE 0x0065 ///< Scissor test mode.
#define GPUREG_SCISSORTEST_POS 0x0066 ///< Scissor test position.
#define GPUREG_SCISSORTEST_DIM 0x0067 ///< Scissor text dimensions.
#define GPUREG_VIEWPORT_XY 0x0068 ///< Viewport X and Y.
#define GPUREG_0069 0x0069 ///< Unknown
#define GPUREG_EARLYDEPTH_DATA 0x006A ///< Unknown
#define GPUREG_006B 0x006B ///< Unknown
#define GPUREG_006C 0x006C ///< Unknown
#define GPUREG_DEPTHMAP_ENABLE 0x006D ///< Depth map enable.
#define GPUREG_RENDERBUF_DIM 0x006E ///< Renderbuffer dimensions.
#define GPUREG_SH_OUTATTR_CLOCK 0x006F ///< Shader output attributes clock enable.
#define GPUREG_0070 0x0070 ///< Unknown
#define GPUREG_0071 0x0071 ///< Unknown
#define GPUREG_0072 0x0072 ///< Unknown
#define GPUREG_0073 0x0073 ///< Unknown
#define GPUREG_0074 0x0074 ///< Unknown
#define GPUREG_0075 0x0075 ///< Unknown
#define GPUREG_0076 0x0076 ///< Unknown
#define GPUREG_0077 0x0077 ///< Unknown
#define GPUREG_0078 0x0078 ///< Unknown
#define GPUREG_0079 0x0079 ///< Unknown
#define GPUREG_007A 0x007A ///< Unknown
#define GPUREG_007B 0x007B ///< Unknown
#define GPUREG_007C 0x007C ///< Unknown
#define GPUREG_007D 0x007D ///< Unknown
#define GPUREG_007E 0x007E ///< Unknown
#define GPUREG_007F 0x007F ///< Unknown
///@}
///@name Texturing registers (0x080-0x0FF)
///@{
#define GPUREG_TEXUNIT_CONFIG 0x0080 ///< Texture unit configuration.
#define GPUREG_TEXUNIT0_BORDER_COLOR 0x0081 ///< Texture unit 0 border color.
#define GPUREG_TEXUNIT0_DIM 0x0082 ///< Texture unit 0 dimensions.
#define GPUREG_TEXUNIT0_PARAM 0x0083 ///< Texture unit 0 parameters.
#define GPUREG_TEXUNIT0_LOD 0x0084 ///< Texture unit 0 LOD.
#define GPUREG_TEXUNIT0_ADDR1 0x0085 ///< Texture unit 0 address.
#define GPUREG_TEXUNIT0_ADDR2 0x0086 ///< Unknown.
#define GPUREG_TEXUNIT0_ADDR3 0x0087 ///< Unknown.
#define GPUREG_TEXUNIT0_ADDR4 0x0088 ///< Unknown.
#define GPUREG_TEXUNIT0_ADDR5 0x0089 ///< Unknown.
#define GPUREG_TEXUNIT0_ADDR6 0x008A ///< Unknown.
#define GPUREG_TEXUNIT0_SHADOW 0x008B ///< Unknown.
#define GPUREG_008C 0x008C ///< Unknown.
#define GPUREG_008D 0x008D ///< Unknown.
#define GPUREG_TEXUNIT0_TYPE 0x008E ///< Texture unit 0 type.
#define GPUREG_LIGHTING_ENABLE0 0x008F ///< Lighting toggle.
#define GPUREG_0090 0x0090 ///< Unknown.
#define GPUREG_TEXUNIT1_BORDER_COLOR 0x0091 ///< Texture unit 1 border color.
#define GPUREG_TEXUNIT1_DIM 0x0092 ///< Texture unit 1 dimensions.
#define GPUREG_TEXUNIT1_PARAM 0x0093 ///< Texture unit 1 parameters.
#define GPUREG_TEXUNIT1_LOD 0x0094 ///< Texture unit 1 LOD.
#define GPUREG_TEXUNIT1_ADDR 0x0095 ///< Texture unit 1 address.
#define GPUREG_TEXUNIT1_TYPE 0x0096 ///< Texture unit 1 type.
#define GPUREG_0097 0x0097 ///< Unknown.
#define GPUREG_0098 0x0098 ///< Unknown.
#define GPUREG_TEXUNIT2_BORDER_COLOR 0x0099 ///< Texture unit 2 border color.
#define GPUREG_TEXUNIT2_DIM 0x009A ///< Texture unit 2 dimensions.
#define GPUREG_TEXUNIT2_PARAM 0x009B ///< Texture unit 2 parameters.
#define GPUREG_TEXUNIT2_LOD 0x009C ///< Texture unit 2 LOD.
#define GPUREG_TEXUNIT2_ADDR 0x009D ///< Texture unit 2 address.
#define GPUREG_TEXUNIT2_TYPE 0x009E ///< Texture unit 2 type.
#define GPUREG_009F 0x009F ///< Unknown.
#define GPUREG_00A0 0x00A0 ///< Unknown.
#define GPUREG_00A1 0x00A1 ///< Unknown.
#define GPUREG_00A2 0x00A2 ///< Unknown.
#define GPUREG_00A3 0x00A3 ///< Unknown.
#define GPUREG_00A4 0x00A4 ///< Unknown.
#define GPUREG_00A5 0x00A5 ///< Unknown.
#define GPUREG_00A6 0x00A6 ///< Unknown.
#define GPUREG_00A7 0x00A7 ///< Unknown.
#define GPUREG_TEXUNIT3_PROCTEX0 0x00A8 ///< Unknown.
#define GPUREG_TEXUNIT3_PROCTEX1 0x00A9 ///< Unknown.
#define GPUREG_TEXUNIT3_PROCTEX2 0x00AA ///< Unknown.
#define GPUREG_TEXUNIT3_PROCTEX3 0x00AB ///< Unknown.
#define GPUREG_TEXUNIT3_PROCTEX4 0x00A ///< Unknown.
#define GPUREG_TEXUNIT3_PROCTEX5 0x00D ///< Unknown.
#define GPUREG_00AE 0x00AE ///< Unknown.
#define GPUREG_PROCTEX_LUT 0x00AF ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA0 0x00B0 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA1 0x00B1 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA2 0x00B2 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA3 0x00B3 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA4 0x00B4 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA5 0x00B5 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA6 0x00B6 ///< Unknown.
#define GPUREG_PROCTEX_LUT_DATA7 0x00B7 ///< Unknown.
#define GPUREG_00B8 0x00B8 ///< Unknown.
#define GPUREG_00B9 0x00B9 ///< Unknown.
#define GPUREG_00BA 0x00BA ///< Unknown.
#define GPUREG_00BB 0x00BB ///< Unknown.
#define GPUREG_00BC 0x00BC ///< Unknown.
#define GPUREG_00BD 0x00BD ///< Unknown.
#define GPUREG_00BE 0x00BE ///< Unknown.
#define GPUREG_00BF 0x00BF ///< Unknown.
#define GPUREG_TEXENV0_SOURCE 0x00C0 ///< Texture env 0 source.
#define GPUREG_TEXENV0_OPERAND 0x00C1 ///< Texture env 0 operand.
#define GPUREG_TEXENV0_COMBINER 0x00C2 ///< Texture env 0 combiner.
#define GPUREG_TEXENV0_COLOR 0x00C3 ///< Texture env 0 color.
#define GPUREG_TEXENV0_SCALE 0x00C4 ///< Texture env 0 scale.
#define GPUREG_00C5 0x00C5 ///< Unknown.
#define GPUREG_00C6 0x00C6 ///< Unknown.
#define GPUREG_00C7 0x00C7 ///< Unknown.
#define GPUREG_TEXENV1_SOURCE 0x00C8 ///< Texture env 1 source.
#define GPUREG_TEXENV1_OPERAND 0x00C9 ///< Texture env 1 operand.
#define GPUREG_TEXENV1_COMBINER 0x00CA ///< Texture env 1 combiner.
#define GPUREG_TEXENV1_COLOR 0x00CB ///< Texture env 1 color.
#define GPUREG_TEXENV1_SCALE 0x00CC ///< Texture env 1 scale.
#define GPUREG_00CD 0x00CD ///< Unknown.
#define GPUREG_00CE 0x00CE ///< Unknown.
#define GPUREG_00CF 0x00CF ///< Unknown.
#define GPUREG_TEXENV2_SOURCE 0x00D0 ///< Texture env 2 source.
#define GPUREG_TEXENV2_OPERAND 0x00D1 ///< Texture env 2 operand.
#define GPUREG_TEXENV2_COMBINER 0x00D2 ///< Texture env 2 combiner.
#define GPUREG_TEXENV2_COLOR 0x00D3 ///< Texture env 2 color.
#define GPUREG_TEXENV2_SCALE 0x00D4 ///< Texture env 2 scale.
#define GPUREG_00D5 0x00D5 ///< Unknown.
#define GPUREG_00D6 0x00D6 ///< Unknown.
#define GPUREG_00D7 0x00D7 ///< Unknown.
#define GPUREG_TEXENV3_SOURCE 0x00D8 ///< Texture env 3 source.
#define GPUREG_TEXENV3_OPERAND 0x00D9 ///< Texture env 3 operand.
#define GPUREG_TEXENV3_COMBINER 0x00DA ///< Texture env 3 combiner.
#define GPUREG_TEXENV3_COLOR 0x00DB ///< Texture env 3 color.
#define GPUREG_TEXENV3_SCALE 0x00DC ///< Texture env 3 scale.
#define GPUREG_00DD 0x00DD ///< Unknown.
#define GPUREG_00DE 0x00DE ///< Unknown.
#define GPUREG_00DF 0x00DF ///< Unknown.
#define GPUREG_TEXENV_UPDATE_BUFFER 0x00E0 ///< Texture env buffer update flag.
#define GPUREG_FOG_COLOR 0x00E1 ///< Unknown.
#define GPUREG_00E2 0x00E2 ///< Unknown.
#define GPUREG_00E3 0x00E3 ///< Unknown.
#define GPUREG_GAS_ATTENUATION 0x00E4 ///< Unknown.
#define GPUREG_GAS_ACCMAX 0x00E5 ///< Unknown.
#define GPUREG_FOG_LUT_INDEX 0x00E6 ///< Unknown.
#define GPUREG_00E7 0x00E7 ///< Unknown.
#define GPUREG_FOG_LUT_DATA0 0x00E8 ///< Unknown.
#define GPUREG_FOG_LUT_DATA1 0x00E9 ///< Unknown.
#define GPUREG_FOG_LUT_DATA2 0x00EA ///< Unknown.
#define GPUREG_FOG_LUT_DATA3 0x00EB ///< Unknown.
#define GPUREG_FOG_LUT_DATA4 0x00EC ///< Unknown.
#define GPUREG_FOG_LUT_DATA5 0x00ED ///< Unknown.
#define GPUREG_FOG_LUT_DATA6 0x00EE ///< Unknown.
#define GPUREG_FOG_LUT_DATA7 0x00EF ///< Unknown.
#define GPUREG_TEXENV4_SOURCE 0x00F0 ///< Texture env 4 source.
#define GPUREG_TEXENV4_OPERAND 0x00F1 ///< Texture env 4 operand.
#define GPUREG_TEXENV4_COMBINER 0x00F2 ///< Texture env 4 combiner.
#define GPUREG_TEXENV4_COLOR 0x00F3 ///< Texture env 4 color.
#define GPUREG_TEXENV4_SCALE 0x00F4 ///< Texture env 4 scale.
#define GPUREG_00F5 0x00F5 ///< Unknown.
#define GPUREG_00F6 0x00F6 ///< Unknown.
#define GPUREG_00F7 0x00F7 ///< Unknown.
#define GPUREG_TEXENV5_SOURCE 0x00F8 ///< Texture env 5 source.
#define GPUREG_TEXENV5_OPERAND 0x00F9 ///< Texture env 5 operand.
#define GPUREG_TEXENV5_COMBINER 0x00FA ///< Texture env 5 combiner.
#define GPUREG_TEXENV5_COLOR 0x00FB ///< Texture env 5 color.
#define GPUREG_TEXENV5_SCALE 0x00FC ///< Texture env 5 scale.
#define GPUREG_TEXENV_BUFFER_COLOR 0x00FD ///< Texture env buffer color.
#define GPUREG_00FE 0x00FE ///< Unknown.
#define GPUREG_00FF 0x00FF ///< Unknown.
///@}
///@name Framebuffer registers (0x100-0x13F)
///@{
#define GPUREG_COLOR_OPERATION 0x0100 ///< Configures fragment operation and blend mode.
#define GPUREG_BLEND_FUNC 0x0101 ///< Blend function configuration.
#define GPUREG_LOGIC_OP 0x0102 ///< Logical operator configuration.
#define GPUREG_BLEND_COLOR 0x0103 ///< Blend color.
#define GPUREG_FRAGOP_ALPHA_TEST 0x0104 ///< Alpha test configuration.
#define GPUREG_STENCIL_TEST 0x0105 ///< Stencil test configuration.
#define GPUREG_STENCIL_OP 0x0106 ///< Stencil test operation.
#define GPUREG_DEPTH_COLOR_MASK 0x0107 ///< Depth test and color mask configuration.
#define GPUREG_0108 0x0108 ///< Unknown.
#define GPUREG_0109 0x0109 ///< Unknown.
#define GPUREG_010A 0x010A ///< Unknown.
#define GPUREG_010B 0x010B ///< Unknown.
#define GPUREG_010C 0x010C ///< Unknown.
#define GPUREG_010D 0x010D ///< Unknown.
#define GPUREG_010E 0x010E ///< Unknown.
#define GPUREG_010F 0x010F ///< Unknown.
#define GPUREG_FRAMEBUFFER_INVALIDATE 0x0110 ///< Invalidates the frame buffer.
#define GPUREG_FRAMEBUFFER_FLUSH 0x0111 ///< Flushes the frame buffer.
#define GPUREG_COLORBUFFER_READ 0x0112 ///< Reads from the color buffer.
#define GPUREG_COLORBUFFER_WRITE 0x0113 ///< Writes to the color buffer.
#define GPUREG_DEPTHBUFFER_READ 0x0114 ///< Reads from the depth buffer.
#define GPUREG_DEPTHBUFFER_WRITE 0x0115 ///< Writes to the depth buffer.
#define GPUREG_DEPTHBUFFER_FORMAT 0x0116 ///< Depth buffer format.
#define GPUREG_COLORBUFFER_FORMAT 0x0117 ///< Color buffer format.
#define GPUREG_EARLYDEPTH_TEST2 0x0118 ///< Unknown.
#define GPUREG_0119 0x0119 ///< Unknown.
#define GPUREG_011A 0x011A ///< Unknown.
#define GPUREG_FRAMEBUFFER_BLOCK32 0x011B ///< Frame buffer block 32.
#define GPUREG_DEPTHBUFFER_LOC 0x011C ///< Depth buffer location.
#define GPUREG_COLORBUFFER_LOC 0x011D ///< Color buffer location.
#define GPUREG_FRAMEBUFFER_DIM 0x011E ///< Frame buffer dimensions.
#define GPUREG_011F 0x011F ///< Unknown.
#define GPUREG_GAS_LIGHT_XY 0x0120 ///< Unknown.
#define GPUREG_GAS_LIGHT_Z 0x0121 ///< Unknown.
#define GPUREG_GAS_LIGHT_Z_COLOR 0x0122 ///< Unknown.
#define GPUREG_GAS_LUT_INDEX 0x0123 ///< Unknown.
#define GPUREG_GAS_LUT_DATA 0x0124 ///< Unknown.
#define GPUREG_GAS_ACCMAX_FEEDBACK 0x0125 ///< Unknown.
#define GPUREG_GAS_DELTAZ_DEPTH 0x0126 ///< Unknown.
#define GPUREG_0127 0x0127 ///< Unknown.
#define GPUREG_0128 0x0128 ///< Unknown.
#define GPUREG_0129 0x0129 ///< Unknown.
#define GPUREG_012A 0x012A ///< Unknown.
#define GPUREG_012B 0x012B ///< Unknown.
#define GPUREG_012C 0x012C ///< Unknown.
#define GPUREG_012D 0x012D ///< Unknown.
#define GPUREG_012E 0x012E ///< Unknown.
#define GPUREG_012F 0x012F ///< Unknown.
#define GPUREG_FRAGOP_SHADOW 0x0130 ///< Unknown.
#define GPUREG_0131 0x0131 ///< Unknown.
#define GPUREG_0132 0x0132 ///< Unknown.
#define GPUREG_0133 0x0133 ///< Unknown.
#define GPUREG_0134 0x0134 ///< Unknown.
#define GPUREG_0135 0x0135 ///< Unknown.
#define GPUREG_0136 0x0136 ///< Unknown.
#define GPUREG_0137 0x0137 ///< Unknown.
#define GPUREG_0138 0x0138 ///< Unknown.
#define GPUREG_0139 0x0139 ///< Unknown.
#define GPUREG_013A 0x013A ///< Unknown.
#define GPUREG_013B 0x013B ///< Unknown.
#define GPUREG_013C 0x013C ///< Unknown.
#define GPUREG_013D 0x013D ///< Unknown.
#define GPUREG_013E 0x013E ///< Unknown.
#define GPUREG_013F 0x013F ///< Unknown.
///@}
///@name Fragment lighting registers (0x140-0x1FF)
///@{
#define GPUREG_LIGHT0_SPECULAR0 0x0140 ///< Light 0 specular lighting.
#define GPUREG_LIGHT0_SPECULAR1 0x0141 ///< Light 0 specular lighting.
#define GPUREG_LIGHT0_DIFFUSE 0x0142 ///< Light 0 diffuse lighting.
#define GPUREG_LIGHT0_AMBIENT 0x0143 ///< Light 0 ambient lighting.
#define GPUREG_LIGHT0_XY 0x0144 ///< Light 0 X and Y.
#define GPUREG_LIGHT0_Z 0x0145 ///< Light 0 Z.
#define GPUREG_LIGHT0_SPOTDIR_XY 0x0146 ///< Light 0 spotlight direction X and Y.
#define GPUREG_LIGHT0_SPOTDIR_Z 0x0147 ///< Light 0 spotlight direction Z.
#define GPUREG_0148 0x0148 ///< Unknown.
#define GPUREG_LIGHT0_CONFIG 0x0149 ///< Light 0 configuration.
#define GPUREG_LIGHT0_ATTENUATION_BIAS 0x014A ///< Light 0 attenuation bias.
#define GPUREG_LIGHT0_ATTENUATION_SCALE 0x014B ///< Light 0 attenuation scale.
#define GPUREG_014C 0x014C ///< Unknown.
#define GPUREG_014D 0x014D ///< Unknown.
#define GPUREG_014E 0x014E ///< Unknown.
#define GPUREG_014F 0x014F ///< Unknown.
#define GPUREG_LIGHT1_SPECULAR0 0x0150 ///< Light 1 specular lighting.
#define GPUREG_LIGHT1_SPECULAR1 0x0151 ///< Light 1 specular lighting.
#define GPUREG_LIGHT1_DIFFUSE 0x0152 ///< Light 1 diffuse lighting.
#define GPUREG_LIGHT1_AMBIENT 0x0153 ///< Light 1 ambient lighting.
#define GPUREG_LIGHT1_XY 0x0154 ///< Light 1 X and Y.
#define GPUREG_LIGHT1_Z 0x0155 ///< Light 1 Z.
#define GPUREG_LIGHT1_SPOTDIR_XY 0x0156 ///< Light 1 spotlight direction X and Y.
#define GPUREG_LIGHT1_SPOTDIR_Z 0x0157 ///< Light 1 spotlight direction Z.
#define GPUREG_0158 0x0158 ///< Unknown.
#define GPUREG_LIGHT1_CONFIG 0x0159 ///< Light 1 configuration.
#define GPUREG_LIGHT1_ATTENUATION_BIAS 0x015A ///< Light 1 attenuation bias.
#define GPUREG_LIGHT1_ATTENUATION_SCALE 0x015B ///< Light 1 attenuation scale.
#define GPUREG_015C 0x015C ///< Unknown.
#define GPUREG_015D 0x015D ///< Unknown.
#define GPUREG_015E 0x015E ///< Unknown.
#define GPUREG_015F 0x015F ///< Unknown.
#define GPUREG_LIGHT2_SPECULAR0 0x0160 ///< Light 2 specular lighting.
#define GPUREG_LIGHT2_SPECULAR1 0x0161 ///< Light 2 specular lighting.
#define GPUREG_LIGHT2_DIFFUSE 0x0162 ///< Light 2 diffuse lighting.
#define GPUREG_LIGHT2_AMBIENT 0x0163 ///< Light 2 ambient lighting.
#define GPUREG_LIGHT2_XY 0x0164 ///< Light 2 X and Y.
#define GPUREG_LIGHT2_Z 0x0165 ///< Light 2 Z.
#define GPUREG_LIGHT2_SPOTDIR_XY 0x0166 ///< Light 2 spotlight direction X and Y.
#define GPUREG_LIGHT2_SPOTDIR_Z 0x0167 ///< Light 2 spotlight direction Z.
#define GPUREG_0168 0x0168 ///< Unknown.
#define GPUREG_LIGHT2_CONFIG 0x0169 ///< Light 2 configuration.
#define GPUREG_LIGHT2_ATTENUATION_BIAS 0x016A ///< Light 2 attenuation bias.
#define GPUREG_LIGHT2_ATTENUATION_SCALE 0x016B ///< Light 2 attenuation scale.
#define GPUREG_016C 0x016C ///< Unknown.
#define GPUREG_016D 0x016D ///< Unknown.
#define GPUREG_016E 0x016E ///< Unknown.
#define GPUREG_016F 0x016F ///< Unknown.
#define GPUREG_LIGHT3_SPECULAR0 0x0170 ///< Light 3 specular lighting.
#define GPUREG_LIGHT3_SPECULAR1 0x0171 ///< Light 3 specular lighting.
#define GPUREG_LIGHT3_DIFFUSE 0x0172 ///< Light 3 diffuse lighting.
#define GPUREG_LIGHT3_AMBIENT 0x0173 ///< Light 3 ambient lighting.
#define GPUREG_LIGHT3_XY 0x0174 ///< Light 3 X and Y.
#define GPUREG_LIGHT3_Z 0x0175 ///< Light 3 Z.
#define GPUREG_LIGHT3_SPOTDIR_XY 0x0176 ///< Light 3 spotlight direction X and Y.
#define GPUREG_LIGHT3_SPOTDIR_Z 0x0177 ///< Light 3 spotlight direction Z.
#define GPUREG_0178 0x0178 ///< Unknown.
#define GPUREG_LIGHT3_CONFIG 0x0179 ///< Light 3 configuration.
#define GPUREG_LIGHT3_ATTENUATION_BIAS 0x017A ///< Light 3 attenuation bias.
#define GPUREG_LIGHT3_ATTENUATION_SCALE 0x017B ///< Light 3 attenuation scale.
#define GPUREG_017C 0x017C ///< Unknown.
#define GPUREG_017D 0x017D ///< Unknown.
#define GPUREG_017E 0x017E ///< Unknown.
#define GPUREG_017F 0x017F ///< Unknown.
#define GPUREG_LIGHT4_SPECULAR0 0x0180 ///< Light 4 specular lighting.
#define GPUREG_LIGHT4_SPECULAR1 0x0181 ///< Light 4 specular lighting.
#define GPUREG_LIGHT4_DIFFUSE 0x0182 ///< Light 4 diffuse lighting.
#define GPUREG_LIGHT4_AMBIENT 0x0183 ///< Light 4 ambient lighting.
#define GPUREG_LIGHT4_XY 0x0184 ///< Light 4 X and Y.
#define GPUREG_LIGHT4_Z 0x0185 ///< Light 4 Z.
#define GPUREG_LIGHT4_SPOTDIR_XY 0x0186 ///< Light 4 spotlight direction X and Y.
#define GPUREG_LIGHT4_SPOTDIR_Z 0x0187 ///< Light 4 spotlight direction Z.
#define GPUREG_0188 0x0188 ///< Unknown.
#define GPUREG_LIGHT4_CONFIG 0x0189 ///< Light 4 configuration.
#define GPUREG_LIGHT4_ATTENUATION_BIAS 0x018A ///< Light 4 attenuation bias.
#define GPUREG_LIGHT4_ATTENUATION_SCALE 0x018B ///< Light 4 attenuation scale.
#define GPUREG_018C 0x018C ///< Unknown.
#define GPUREG_018D 0x018D ///< Unknown.
#define GPUREG_018E 0x018E ///< Unknown.
#define GPUREG_018F 0x018F ///< Unknown.
#define GPUREG_LIGHT5_SPECULAR0 0x0190 ///< Light 5 specular lighting.
#define GPUREG_LIGHT5_SPECULAR1 0x0191 ///< Light 5 specular lighting.
#define GPUREG_LIGHT5_DIFFUSE 0x0192 ///< Light 5 diffuse lighting.
#define GPUREG_LIGHT5_AMBIENT 0x0193 ///< Light 5 ambient lighting.
#define GPUREG_LIGHT5_XY 0x0194 ///< Light 5 X and Y.
#define GPUREG_LIGHT5_Z 0x0195 ///< Light 5 Z.
#define GPUREG_LIGHT5_SPOTDIR_XY 0x0196 ///< Light 5 spotlight direction X and Y.
#define GPUREG_LIGHT5_SPOTDIR_Z 0x0197 ///< Light 5 spotlight direction Z.
#define GPUREG_0198 0x0198 ///< Unknown.
#define GPUREG_LIGHT5_CONFIG 0x0199 ///< Light 5 configuration.
#define GPUREG_LIGHT5_ATTENUATION_BIAS 0x019A ///< Light 5 attenuation bias.
#define GPUREG_LIGHT5_ATTENUATION_SCALE 0x019B ///< Light 5 attenuation scale.
#define GPUREG_019C 0x019C ///< Unknown.
#define GPUREG_019D 0x019D ///< Unknown.
#define GPUREG_019E 0x019E ///< Unknown.
#define GPUREG_019F 0x019F ///< Unknown.
#define GPUREG_LIGHT6_SPECULAR0 0x01A0 ///< Light 6 specular lighting.
#define GPUREG_LIGHT6_SPECULAR1 0x01A1 ///< Light 6 specular lighting.
#define GPUREG_LIGHT6_DIFFUSE 0x01A2 ///< Light 6 diffuse lighting.
#define GPUREG_LIGHT6_AMBIENT 0x01A3 ///< Light 6 ambient lighting.
#define GPUREG_LIGHT6_XY 0x01A4 ///< Light 6 X and Y.
#define GPUREG_LIGHT6_Z 0x01A5 ///< Light 6 Z.
#define GPUREG_LIGHT6_SPOTDIR_XY 0x01A6 ///< Light 6 spotlight direction X and Y.
#define GPUREG_LIGHT6_SPOTDIR_Z 0x01A7 ///< Light 6 spotlight direction Z.
#define GPUREG_01A8 0x01A8 ///< Unknown.
#define GPUREG_LIGHT6_CONFIG 0x01A9 ///< Light 6 configuration.
#define GPUREG_LIGHT6_ATTENUATION_BIAS 0x01AA ///< Light 6 attenuation bias.
#define GPUREG_LIGHT6_ATTENUATION_SCALE 0x01AB ///< Light 6 attenuation scale.
#define GPUREG_01AC 0x01AC ///< Unknown.
#define GPUREG_01AD 0x01AD ///< Unknown.
#define GPUREG_01AE 0x01AE ///< Unknown.
#define GPUREG_01AF 0x01AF ///< Unknown.
#define GPUREG_LIGHT7_SPECULAR0 0x01B0 ///< Light 7 specular lighting.
#define GPUREG_LIGHT7_SPECULAR1 0x01B1 ///< Light 7 specular lighting.
#define GPUREG_LIGHT7_DIFFUSE 0x01B2 ///< Light 7 diffuse lighting.
#define GPUREG_LIGHT7_AMBIENT 0x01B3 ///< Light 7 ambient lighting.
#define GPUREG_LIGHT7_XY 0x01B4 ///< Light 7 X and Y.
#define GPUREG_LIGHT7_Z 0x01B5 ///< Light 7 Z.
#define GPUREG_LIGHT7_SPOTDIR_XY 0x01B6 ///< Light 7 spotlight direction X and Y.
#define GPUREG_LIGHT7_SPOTDIR_Z 0x01B7 ///< Light 7 spotlight direction Z.
#define GPUREG_01B8 0x01B8 ///< Unknown.
#define GPUREG_LIGHT7_CONFIG 0x01B9 ///< Light 7 configuration.
#define GPUREG_LIGHT7_ATTENUATION_BIAS 0x01BA ///< Light 7 attenuation bias.
#define GPUREG_LIGHT7_ATTENUATION_SCALE 0x01BB ///< Light 7 attenuation scale.
#define GPUREG_01BC 0x01BC ///< Unknown.
#define GPUREG_01BD 0x01BD ///< Unknown.
#define GPUREG_01BE 0x01BE ///< Unknown.
#define GPUREG_01BF 0x01BF ///< Unknown.
#define GPUREG_LIGHTING_AMBIENT 0x01C0 ///< Ambient lighting.
#define GPUREG_01C1 0x01C1 ///< Unknown.
#define GPUREG_LIGHTING_NUM_LIGHTS 0x01C2 ///< Number of lights.
#define GPUREG_LIGHTING_CONFIG0 0x01C3 ///< Lighting configuration.
#define GPUREG_LIGHTING_CONFIG1 0x01C4 ///< Lighting configuration.
#define GPUREG_LIGHTING_LUT_INDEX 0x01C5 ///< LUT index.
#define GPUREG_LIGHTING_ENABLE1 0x01C6 ///< Lighting toggle.
#define GPUREG_01C7 0x01C7 ///< Unknown.
#define GPUREG_LIGHTING_LUT_DATA0 0x01C8 ///< LUT data 0.
#define GPUREG_LIGHTING_LUT_DATA1 0x01C9 ///< LUT data 1.
#define GPUREG_LIGHTING_LUT_DATA2 0x01CA ///< LUT data 2.
#define GPUREG_LIGHTING_LUT_DATA3 0x01CB ///< LUT data 3.
#define GPUREG_LIGHTING_LUT_DATA4 0x01CC ///< LUT data 4.
#define GPUREG_LIGHTING_LUT_DATA5 0x01CD ///< LUT data 5.
#define GPUREG_LIGHTING_LUT_DATA6 0x01CE ///< LUT data 6.
#define GPUREG_LIGHTING_LUT_DATA7 0x01CF ///< LUT data 7.
#define GPUREG_LIGHTING_LUTINPUT_ABS 0x01D0 ///< LUT input abs.
#define GPUREG_LIGHTING_LUTINPUT_SELECT 0x01D1 ///< LUT input selector.
#define GPUREG_LIGHTING_LUTINPUT_SCALE 0x01D2 ///< LUT input scale.
#define GPUREG_01D3 0x01D3 ///< Unknown.
#define GPUREG_01D4 0x01D4 ///< Unknown.
#define GPUREG_01D5 0x01D5 ///< Unknown.
#define GPUREG_01D6 0x01D6 ///< Unknown.
#define GPUREG_01D7 0x01D7 ///< Unknown.
#define GPUREG_01D8 0x01D8 ///< Unknown.
#define GPUREG_LIGHTING_LIGHT_PERMUTATION 0x01D9 ///< Light permutation.
#define GPUREG_01DA 0x01DA ///< Unknown.
#define GPUREG_01DB 0x01DB ///< Unknown.
#define GPUREG_01DC 0x01DC ///< Unknown.
#define GPUREG_01DD 0x01DD ///< Unknown.
#define GPUREG_01DE 0x01DE ///< Unknown.
#define GPUREG_01DF 0x01DF ///< Unknown.
#define GPUREG_01E0 0x01E0 ///< Unknown.
#define GPUREG_01E1 0x01E1 ///< Unknown.
#define GPUREG_01E2 0x01E2 ///< Unknown.
#define GPUREG_01E3 0x01E3 ///< Unknown.
#define GPUREG_01E4 0x01E4 ///< Unknown.
#define GPUREG_01E5 0x01E5 ///< Unknown.
#define GPUREG_01E6 0x01E6 ///< Unknown.
#define GPUREG_01E7 0x01E7 ///< Unknown.
#define GPUREG_01E8 0x01E8 ///< Unknown.
#define GPUREG_01E9 0x01E9 ///< Unknown.
#define GPUREG_01EA 0x01EA ///< Unknown.
#define GPUREG_01EB 0x01EB ///< Unknown.
#define GPUREG_01EC 0x01EC ///< Unknown.
#define GPUREG_01ED 0x01ED ///< Unknown.
#define GPUREG_01EE 0x01EE ///< Unknown.
#define GPUREG_01EF 0x01EF ///< Unknown.
#define GPUREG_01F0 0x01F0 ///< Unknown.
#define GPUREG_01F1 0x01F1 ///< Unknown.
#define GPUREG_01F2 0x01F2 ///< Unknown.
#define GPUREG_01F3 0x01F3 ///< Unknown.
#define GPUREG_01F4 0x01F4 ///< Unknown.
#define GPUREG_01F5 0x01F5 ///< Unknown.
#define GPUREG_01F6 0x01F6 ///< Unknown.
#define GPUREG_01F7 0x01F7 ///< Unknown.
#define GPUREG_01F8 0x01F8 ///< Unknown.
#define GPUREG_01F9 0x01F9 ///< Unknown.
#define GPUREG_01FA 0x01FA ///< Unknown.
#define GPUREG_01FB 0x01FB ///< Unknown.
#define GPUREG_01FC 0x01FC ///< Unknown.
#define GPUREG_01FD 0x01FD ///< Unknown.
#define GPUREG_01FE 0x01FE ///< Unknown.
#define GPUREG_01FF 0x01FF ///< Unknown.
///@}
///@name Geometry pipeline registers (0x200-0x27F)
///@{
#define GPUREG_ATTRIBBUFFERS_LOC 0x0200 ///< Attribute buffers location.
#define GPUREG_ATTRIBBUFFERS_FORMAT_LOW 0x0201 ///< Attribute buffers format low.
#define GPUREG_ATTRIBBUFFERS_FORMAT_HIGH 0x0202 ///< Attribute buffers format high.
#define GPUREG_ATTRIBBUFFER0_OFFSET 0x0203 ///< Attribute buffers 0 offset.
#define GPUREG_ATTRIBBUFFER0_CONFIG1 0x0204 ///< Attribute buffers 0 configuration.
#define GPUREG_ATTRIBBUFFER0_CONFIG2 0x0205 ///< Attribute buffers 0 configuration.
#define GPUREG_ATTRIBBUFFER1_OFFSET 0x0206 ///< Attribute buffers 1 offset.
#define GPUREG_ATTRIBBUFFER1_CONFIG1 0x0207 ///< Attribute buffers 1 configuration.
#define GPUREG_ATTRIBBUFFER1_CONFIG2 0x0208 ///< Attribute buffers 1 configuration.
#define GPUREG_ATTRIBBUFFER2_OFFSET 0x0209 ///< Attribute buffers 2 offset.
#define GPUREG_ATTRIBBUFFER2_CONFIG1 0x020A ///< Attribute buffers 2 configuration.
#define GPUREG_ATTRIBBUFFER2_CONFIG2 0x020B ///< Attribute buffers 2 configuration.
#define GPUREG_ATTRIBBUFFER3_OFFSET 0x020C ///< Attribute buffers 3 offset.
#define GPUREG_ATTRIBBUFFER3_CONFIG1 0x020D ///< Attribute buffers 3 configuration.
#define GPUREG_ATTRIBBUFFER3_CONFIG2 0x020E ///< Attribute buffers 3 configuration.
#define GPUREG_ATTRIBBUFFER4_OFFSET 0x020F ///< Attribute buffers 4 offset.
#define GPUREG_ATTRIBBUFFER4_CONFIG1 0x0210 ///< Attribute buffers 4 configuration.
#define GPUREG_ATTRIBBUFFER4_CONFIG2 0x0211 ///< Attribute buffers 4 configuration.
#define GPUREG_ATTRIBBUFFER5_OFFSET 0x0212 ///< Attribute buffers 5 offset.
#define GPUREG_ATTRIBBUFFER5_CONFIG1 0x0213 ///< Attribute buffers 5 configuration.
#define GPUREG_ATTRIBBUFFER5_CONFIG2 0x0214 ///< Attribute buffers 5 configuration.
#define GPUREG_ATTRIBBUFFER6_OFFSET 0x0215 ///< Attribute buffers 6 offset.
#define GPUREG_ATTRIBBUFFER6_CONFIG1 0x0216 ///< Attribute buffers 6 configuration.
#define GPUREG_ATTRIBBUFFER6_CONFIG2 0x0217 ///< Attribute buffers 6 configuration.
#define GPUREG_ATTRIBBUFFER7_OFFSET 0x0218 ///< Attribute buffers 7 offset.
#define GPUREG_ATTRIBBUFFER7_CONFIG1 0x0219 ///< Attribute buffers 7 configuration.
#define GPUREG_ATTRIBBUFFER7_CONFIG2 0x021A ///< Attribute buffers 7 configuration.
#define GPUREG_ATTRIBBUFFER8_OFFSET 0x021B ///< Attribute buffers 8 offset.
#define GPUREG_ATTRIBBUFFER8_CONFIG1 0x021C ///< Attribute buffers 8 configuration.
#define GPUREG_ATTRIBBUFFER8_CONFIG2 0x021D ///< Attribute buffers 8 configuration.
#define GPUREG_ATTRIBBUFFER9_OFFSET 0x021E ///< Attribute buffers 9 offset.
#define GPUREG_ATTRIBBUFFER9_CONFIG1 0x021F ///< Attribute buffers 9 configuration.
#define GPUREG_ATTRIBBUFFER9_CONFIG2 0x0220 ///< Attribute buffers 9 configuration.
#define GPUREG_ATTRIBBUFFERA_OFFSET 0x0221 ///< Attribute buffers A offset.
#define GPUREG_ATTRIBBUFFERA_CONFIG1 0x0222 ///< Attribute buffers A configuration.
#define GPUREG_ATTRIBBUFFERA_CONFIG2 0x0223 ///< Attribute buffers A configuration.
#define GPUREG_ATTRIBBUFFERB_OFFSET 0x0224 ///< Attribute buffers B offset.
#define GPUREG_ATTRIBBUFFERB_CONFIG1 0x0225 ///< Attribute buffers B configuration.
#define GPUREG_ATTRIBBUFFERB_CONFIG2 0x0226 ///< Attribute buffers B configuration.
#define GPUREG_INDEXBUFFER_CONFIG 0x0227 ///< Index buffer configuration.
#define GPUREG_NUMVERTICES 0x0228 ///< Number of vertices.
#define GPUREG_GEOSTAGE_CONFIG 0x0229 ///< Geometry stage configuration.
#define GPUREG_VERTEX_OFFSET 0x022A ///< Vertex offset.
#define GPUREG_022B 0x022B ///< Unknown.
#define GPUREG_022C 0x022C ///< Unknown.
#define GPUREG_POST_VERTEX_CACHE_NUM 0x022D ///< Unknown.
#define GPUREG_DRAWARRAYS 0x022E ///< Draw arrays trigger.
#define GPUREG_DRAWELEMENTS 0x022F ///< Draw arrays elements.
#define GPUREG_0230 0x0230 ///< Unknown.
#define GPUREG_VTX_FUNC 0x0231 ///< Unknown.
#define GPUREG_FIXEDATTRIB_INDEX 0x0232 ///< Fixed attribute index.
#define GPUREG_FIXEDATTRIB_DATA0 0x0233 ///< Fixed attribute data 0.
#define GPUREG_FIXEDATTRIB_DATA1 0x0234 ///< Fixed attribute data 1.
#define GPUREG_FIXEDATTRIB_DATA2 0x0235 ///< Fixed attribute data 2.
#define GPUREG_0236 0x0236 ///< Unknown.
#define GPUREG_0237 0x0237 ///< Unknown.
#define GPUREG_CMDBUF_SIZE0 0x0238 ///< Command buffer size 0.
#define GPUREG_CMDBUF_SIZE1 0x0239 ///< Command buffer size 1.
#define GPUREG_CMDBUF_ADDR0 0x023A ///< Command buffer address 0.
#define GPUREG_CMDBUF_ADDR1 0x023B ///< Command buffer address 1.
#define GPUREG_CMDBUF_JUMP0 0x023C ///< Command buffer jump 0.
#define GPUREG_CMDBUF_JUMP1 0x023D ///< Command buffer jump 1.
#define GPUREG_023E 0x023E ///< Unknown.
#define GPUREG_023F 0x023F ///< Unknown.
#define GPUREG_0240 0x0240 ///< Unknown.
#define GPUREG_0241 0x0241 ///< Unknown.
#define GPUREG_VSH_NUM_ATTR 0x0242 ///< Unknown.
#define GPUREG_0243 0x0243 ///< Unknown.
#define GPUREG_VSH_COM_MODE 0x0244 ///< Unknown.
#define GPUREG_START_DRAW_FUNC0 0x0245 ///< Unknown.
#define GPUREG_0246 0x0246 ///< Unknown.
#define GPUREG_0247 0x0247 ///< Unknown.
#define GPUREG_0248 0x0248 ///< Unknown.
#define GPUREG_0249 0x0249 ///< Unknown.
#define GPUREG_VSH_OUTMAP_TOTAL1 0x024A ///< Unknown.
#define GPUREG_024B 0x024B ///< Unknown.
#define GPUREG_024C 0x024C ///< Unknown.
#define GPUREG_024D 0x024D ///< Unknown.
#define GPUREG_024E 0x024E ///< Unknown.
#define GPUREG_024F 0x024F ///< Unknown.
#define GPUREG_0250 0x0250 ///< Unknown.
#define GPUREG_VSH_OUTMAP_TOTAL2 0x0251 ///< Unknown.
#define GPUREG_GSH_MISC0 0x0252 ///< Unknown.
#define GPUREG_GEOSTAGE_CONFIG2 0x0253 ///< Unknown.
#define GPUREG_GSH_MISC1 0x0254 ///< Unknown.
#define GPUREG_0255 0x0255 ///< Unknown.
#define GPUREG_0256 0x0256 ///< Unknown.
#define GPUREG_0257 0x0257 ///< Unknown.
#define GPUREG_0258 0x0258 ///< Unknown.
#define GPUREG_0259 0x0259 ///< Unknown.
#define GPUREG_025A 0x025A ///< Unknown.
#define GPUREG_025B 0x025B ///< Unknown.
#define GPUREG_025C 0x025C ///< Unknown.
#define GPUREG_025D 0x025D ///< Unknown.
#define GPUREG_PRIMITIVE_CONFIG 0x025E ///< Primitive configuration.
#define GPUREG_RESTART_PRIMITIVE 0x025F ///< Restart primitive flag.
#define GPUREG_0260 0x0260 ///< Unknown.
#define GPUREG_0261 0x0261 ///< Unknown.
#define GPUREG_0262 0x0262 ///< Unknown.
#define GPUREG_0263 0x0263 ///< Unknown.
#define GPUREG_0264 0x0264 ///< Unknown.
#define GPUREG_0265 0x0265 ///< Unknown.
#define GPUREG_0266 0x0266 ///< Unknown.
#define GPUREG_0267 0x0267 ///< Unknown.
#define GPUREG_0268 0x0268 ///< Unknown.
#define GPUREG_0269 0x0269 ///< Unknown.
#define GPUREG_026A 0x026A ///< Unknown.
#define GPUREG_026B 0x026B ///< Unknown.
#define GPUREG_026C 0x026C ///< Unknown.
#define GPUREG_026D 0x026D ///< Unknown.
#define GPUREG_026E 0x026E ///< Unknown.
#define GPUREG_026F 0x026F ///< Unknown.
#define GPUREG_0270 0x0270 ///< Unknown.
#define GPUREG_0271 0x0271 ///< Unknown.
#define GPUREG_0272 0x0272 ///< Unknown.
#define GPUREG_0273 0x0273 ///< Unknown.
#define GPUREG_0274 0x0274 ///< Unknown.
#define GPUREG_0275 0x0275 ///< Unknown.
#define GPUREG_0276 0x0276 ///< Unknown.
#define GPUREG_0277 0x0277 ///< Unknown.
#define GPUREG_0278 0x0278 ///< Unknown.
#define GPUREG_0279 0x0279 ///< Unknown.
#define GPUREG_027A 0x027A ///< Unknown.
#define GPUREG_027B 0x027B ///< Unknown.
#define GPUREG_027C 0x027C ///< Unknown.
#define GPUREG_027D 0x027D ///< Unknown.
#define GPUREG_027E 0x027E ///< Unknown.
#define GPUREG_027F 0x027F ///< Unknown.
///@}
///@name Geometry shader registers (0x280-0x2AF)
///@{
#define GPUREG_GSH_BOOLUNIFORM 0x0280 ///< Geometry shader bool uniforms.
#define GPUREG_GSH_INTUNIFORM_I0 0x0281 ///< Geometry shader integer uniform 0.
#define GPUREG_GSH_INTUNIFORM_I1 0x0282 ///< Geometry shader integer uniform 1.
#define GPUREG_GSH_INTUNIFORM_I2 0x0283 ///< Geometry shader integer uniform 2.
#define GPUREG_GSH_INTUNIFORM_I3 0x0284 ///< Geometry shader integer uniform 3.
#define GPUREG_0285 0x0285 ///< Unknown.
#define GPUREG_0286 0x0286 ///< Unknown.
#define GPUREG_0287 0x0287 ///< Unknown.
#define GPUREG_0288 0x0288 ///< Unknown.
#define GPUREG_GSH_INPUTBUFFER_CONFIG 0x0289 ///< Geometry shader input buffer configuration.
#define GPUREG_GSH_ENTRYPOINT 0x028A ///< Geometry shader entry point.
#define GPUREG_GSH_ATTRIBUTES_PERMUTATION_LOW 0x028B ///< Geometry shader attribute permutations low.
#define GPUREG_GSH_ATTRIBUTES_PERMUTATION_HIGH 0x028C ///< Geometry shader attribute permutations high.
#define GPUREG_GSH_OUTMAP_MASK 0x028D ///< Geometry shader output map mask.
#define GPUREG_028E 0x028E ///< Unknown.
#define GPUREG_GSH_CODETRANSFER_END 0x028F ///< Geometry shader code transfer end trigger.
#define GPUREG_GSH_FLOATUNIFORM_CONFIG 0x0290 ///< Geometry shader float uniform configuration.
#define GPUREG_GSH_FLOATUNIFORM_DATA 0x0291 ///< Geometry shader float uniform data.
#define GPUREG_0299 0x0299 ///< Unknown.
#define GPUREG_029A 0x029A ///< Unknown.
#define GPUREG_GSH_CODETRANSFER_CONFIG 0x029B ///< Geometry shader code transfer configuration.
#define GPUREG_GSH_CODETRANSFER_DATA 0x029C ///< Geometry shader code transfer data.
#define GPUREG_02A4 0x02A4 ///< Unknown.
#define GPUREG_GSH_OPDESCS_CONFIG 0x02A5 ///< Geometry shader operand description configuration.
#define GPUREG_GSH_OPDESCS_DATA 0x02A6 ///< Geometry shader operand description data.
#define GPUREG_02AE 0x02AE ///< Unknown.
#define GPUREG_02AF 0x02AF ///< Unknown.
///@}
///@name Vertex shader registers (0x2B0-0x2DF)
///@{
#define GPUREG_VSH_BOOLUNIFORM 0x02B0 ///< Vertex shader bool uniforms.
#define GPUREG_VSH_INTUNIFORM_I0 0x02B1 ///< Vertex shader integer uniform 0.
#define GPUREG_VSH_INTUNIFORM_I1 0x02B2 ///< Vertex shader integer uniform 1.
#define GPUREG_VSH_INTUNIFORM_I2 0x02B3 ///< Vertex shader integer uniform 2.
#define GPUREG_VSH_INTUNIFORM_I3 0x02B4 ///< Vertex shader integer uniform 3.
#define GPUREG_02B5 0x02B5 ///< Unknown.
#define GPUREG_02B6 0x02B6 ///< Unknown.
#define GPUREG_02B7 0x02B7 ///< Unknown.
#define GPUREG_02B8 0x02B8 ///< Unknown.
#define GPUREG_VSH_INPUTBUFFER_CONFIG 0x02B9 ///< Vertex shader input buffer configuration.
#define GPUREG_VSH_ENTRYPOINT 0x02BA ///< Vertex shader entry point.
#define GPUREG_VSH_ATTRIBUTES_PERMUTATION_LOW 0x02BB ///< Vertex shader attribute permutations low.
#define GPUREG_VSH_ATTRIBUTES_PERMUTATION_HIGH 0x02BC ///< Vertex shader attribute permutations high.
#define GPUREG_VSH_OUTMAP_MASK 0x02BD ///< Vertex shader output map mask.
#define GPUREG_02BE 0x02BE ///< Unknown.
#define GPUREG_VSH_CODETRANSFER_END 0x02BF ///< Vertex shader code transfer end trigger.
#define GPUREG_VSH_FLOATUNIFORM_CONFIG 0x02C0 ///< Vertex shader float uniform configuration.
#define GPUREG_VSH_FLOATUNIFORM_DATA 0x02C1 ///< Vertex shader float uniform data.
#define GPUREG_02C9 0x02C9 ///< Unknown.
#define GPUREG_02CA 0x02CA ///< Unknown.
#define GPUREG_VSH_CODETRANSFER_CONFIG 0x02CB ///< Vertex shader code transfer configuration.
#define GPUREG_VSH_CODETRANSFER_DATA 0x02CC ///< Vertex shader code transfer data.
#define GPUREG_02D4 0x02D4 ///< Unknown.
#define GPUREG_VSH_OPDESCS_CONFIG 0x02D5 ///< Vertex shader operand description configuration.
#define GPUREG_VSH_OPDESCS_DATA 0x02D6 ///< Vertex shader operand description data.
#define GPUREG_02DE 0x02DE ///< Unknown.
#define GPUREG_02DF 0x02DF ///< Unknown.
///@}
///@name Unknown registers (0x2E0-0x2FF)
///@{
#define GPUREG_02E0 0x02E0 ///< Unknown.
#define GPUREG_02E1 0x02E1 ///< Unknown.
#define GPUREG_02E2 0x02E2 ///< Unknown.
#define GPUREG_02E3 0x02E3 ///< Unknown.
#define GPUREG_02E4 0x02E4 ///< Unknown.
#define GPUREG_02E5 0x02E5 ///< Unknown.
#define GPUREG_02E6 0x02E6 ///< Unknown.
#define GPUREG_02E7 0x02E7 ///< Unknown.
#define GPUREG_02E8 0x02E8 ///< Unknown.
#define GPUREG_02E9 0x02E9 ///< Unknown.
#define GPUREG_02EA 0x02EA ///< Unknown.
#define GPUREG_02EB 0x02EB ///< Unknown.
#define GPUREG_02EC 0x02EC ///< Unknown.
#define GPUREG_02ED 0x02ED ///< Unknown.
#define GPUREG_02EE 0x02EE ///< Unknown.
#define GPUREG_02EF 0x02EF ///< Unknown.
#define GPUREG_02F0 0x02F0 ///< Unknown.
#define GPUREG_02F1 0x02F1 ///< Unknown.
#define GPUREG_02F2 0x02F2 ///< Unknown.
#define GPUREG_02F3 0x02F3 ///< Unknown.
#define GPUREG_02F4 0x02F4 ///< Unknown.
#define GPUREG_02F5 0x02F5 ///< Unknown.
#define GPUREG_02F6 0x02F6 ///< Unknown.
#define GPUREG_02F7 0x02F7 ///< Unknown.
#define GPUREG_02F8 0x02F8 ///< Unknown.
#define GPUREG_02F9 0x02F9 ///< Unknown.
#define GPUREG_02FA 0x02FA ///< Unknown.
#define GPUREG_02FB 0x02FB ///< Unknown.
#define GPUREG_02FC 0x02FC ///< Unknown.
#define GPUREG_02FD 0x02FD ///< Unknown.
#define GPUREG_02FE 0x02FE ///< Unknown.
#define GPUREG_02FF 0x02FF ///< Unknown.
///@}

View file

@ -0,0 +1,120 @@
/**
* @file shaderProgram.h
* @brief Functions for working with shaders.
*/
#pragma once
#include <3ds/types.h>
#include <3ds/gpu/shbin.h>
/// 24-bit float uniforms.
typedef struct
{
u32 id; ///< Uniform ID.
u32 data[3]; ///< Uniform data.
}float24Uniform_s;
/// Describes an instance of either a vertex or geometry shader.
typedef struct
{
DVLE_s* dvle; ///< Shader DVLE.
u16 boolUniforms; ///< Boolean uniforms.
u16 boolUniformMask; ///< Used boolean uniform mask.
u32 intUniforms[4]; ///< Integer uniforms.
float24Uniform_s* float24Uniforms; ///< 24-bit float uniforms.
u8 intUniformMask; ///< Used integer uniform mask.
u8 numFloat24Uniforms; ///< Float uniform count.
}shaderInstance_s;
/// Describes an instance of a full shader program.
typedef struct
{
shaderInstance_s* vertexShader; ///< Vertex shader.
shaderInstance_s* geometryShader; ///< Geometry shader.
u32 geoShaderInputPermutation[2]; ///< Geometry shader input permutation.
u8 geoShaderInputStride; ///< Geometry shader input stride.
}shaderProgram_s;
/**
* @brief Initializes a shader instance.
* @param si Shader instance to initialize.
* @param dvle DVLE to initialize the shader instance with.
*/
Result shaderInstanceInit(shaderInstance_s* si, DVLE_s* dvle);
/**
* @brief Frees a shader instance.
* @param si Shader instance to free.
*/
Result shaderInstanceFree(shaderInstance_s* si);
/**
* @brief Sets a bool uniform of a shader.
* @param si Shader instance to use.
* @param id ID of the bool uniform.
* @param value Value to set.
*/
Result shaderInstanceSetBool(shaderInstance_s* si, int id, bool value);
/**
* @brief Gets a bool uniform of a shader.
* @param si Shader instance to use.
* @param id ID of the bool uniform.
* @param value Pointer to output the value to.
*/
Result shaderInstanceGetBool(shaderInstance_s* si, int id, bool* value);
/**
* @brief Gets the location of a shader's uniform.
* @param si Shader instance to use.
* @param name Name of the uniform.
*/
s8 shaderInstanceGetUniformLocation(shaderInstance_s* si, const char* name);
/**
* @brief Initializes a shader program.
* @param sp Shader program to initialize.
*/
Result shaderProgramInit(shaderProgram_s* sp);
/**
* @brief Frees a shader program.
* @param sp Shader program to free.
*/
Result shaderProgramFree(shaderProgram_s* sp);
/**
* @brief Sets the vertex shader of a shader program.
* @param sp Shader program to use.
* @param dvle Vertex shader to set.
*/
Result shaderProgramSetVsh(shaderProgram_s* sp, DVLE_s* dvle);
/**
* @brief Sets the geometry shader of a shader program.
* @param sp Shader program to use.
* @param dvle Geometry shader to set.
* @param stride Input stride of the shader (pass 0 to match the number of outputs of the vertex shader).
*/
Result shaderProgramSetGsh(shaderProgram_s* sp, DVLE_s* dvle, u8 stride);
/**
* @brief Configures the permutation of the input attributes of the geometry shader of a shader program.
* @param sp Shader program to use.
* @param permutation Attribute permutation to use.
*/
Result shaderProgramSetGshInputPermutation(shaderProgram_s* sp, u64 permutation);
/**
* @brief Configures the shader units to use the specified shader program.
* @param sp Shader program to use.
* @param sendVshCode When true, the vertex shader's code and operand descriptors are uploaded.
* @param sendGshCode When true, the geometry shader's code and operand descriptors are uploaded.
*/
Result shaderProgramConfigure(shaderProgram_s* sp, bool sendVshCode, bool sendGshCode);
/**
* @brief Same as shaderProgramConfigure, but always loading code/operand descriptors and uploading DVLE constants afterwards.
* @param sp Shader program to use.
*/
Result shaderProgramUse(shaderProgram_s* sp);

130
.vscode/dummyinclude/3ds/gpu/shbin.h vendored Normal file
View file

@ -0,0 +1,130 @@
/**
* @file shbin.h
* @brief Shader binary support.
*/
#pragma once
#include <3ds/gpu/gpu.h>
/// DVLE type.
typedef enum{
VERTEX_SHDR=GPU_VERTEX_SHADER, ///< Vertex shader.
GEOMETRY_SHDR=GPU_GEOMETRY_SHADER ///< Geometry shader.
}DVLE_type;
/// Constant type.
typedef enum{
DVLE_CONST_BOOL=0x0, ///< Bool.
DVLE_CONST_u8=0x1, ///< Unsigned 8-bit integer.
DVLE_CONST_FLOAT24=0x2, ///< 24-bit float.
}DVLE_constantType;
/// Output attribute.
typedef enum{
RESULT_POSITION = 0x0, ///< Position.
RESULT_NORMALQUAT = 0x1, ///< Normal Quaternion.
RESULT_COLOR = 0x2, ///< Color.
RESULT_TEXCOORD0 = 0x3, ///< Texture coordinate 0.
RESULT_TEXCOORD0W = 0x4, ///< Texture coordinate 0 W.
RESULT_TEXCOORD1 = 0x5, ///< Texture coordinate 1.
RESULT_TEXCOORD2 = 0x6, ///< Texture coordinate 2.
RESULT_VIEW = 0x8, ///< View.
RESULT_DUMMY = 0x9, ///< Dummy attribute (used as passthrough for geometry shader input).
}DVLE_outputAttribute_t;
/// Geometry shader operation modes.
typedef enum
{
GSH_POINT = 0, ///< Point processing mode.
GSH_VARIABLE_PRIM = 1, ///< Variable-size primitive processing mode.
GSH_FIXED_PRIM = 2, ///< Fixed-size primitive processing mode.
} DVLE_geoShaderMode;
/// DVLP data.
typedef struct{
u32 codeSize; ///< Code size.
u32* codeData; ///< Code data.
u32 opdescSize; ///< Operand description size.
u32* opcdescData; ///< Operand description data.
}DVLP_s;
/// DVLE constant entry data.
typedef struct{
u16 type; ///< Constant type. See @ref DVLE_constantType
u16 id; ///< Constant ID.
u32 data[4]; ///< Constant data.
}DVLE_constEntry_s;
/// DVLE output entry data.
typedef struct{
u16 type; ///< Output type. See @ref DVLE_outputAttribute_t
u16 regID; ///< Output register ID.
u8 mask; ///< Output mask.
u8 unk[3]; ///< Unknown.
}DVLE_outEntry_s;
/// DVLE uniform entry data.
typedef struct{
u32 symbolOffset; ///< Symbol offset.
u16 startReg; ///< Start register.
u16 endReg; ///< End register.
}DVLE_uniformEntry_s;
/// DVLE data.
typedef struct{
DVLE_type type; ///< DVLE type.
bool mergeOutmaps; ///< true = merge vertex/geometry shader outmaps ('dummy' output attribute is present).
DVLE_geoShaderMode gshMode; ///< Geometry shader operation mode.
u8 gshFixedVtxStart; ///< Starting float uniform register number for storing the fixed-size primitive vertex array.
u8 gshVariableVtxNum; ///< Number of fully-defined vertices in the variable-size primitive vertex array.
u8 gshFixedVtxNum; ///< Number of vertices in the fixed-size primitive vertex array.
DVLP_s* dvlp; ///< Contained DVLPs.
u32 mainOffset; ///< Offset of the start of the main function.
u32 endmainOffset; ///< Offset of the end of the main function.
u32 constTableSize; ///< Constant table size.
DVLE_constEntry_s* constTableData; ///< Constant table data.
u32 outTableSize; ///< Output table size.
DVLE_outEntry_s* outTableData; ///< Output table data.
u32 uniformTableSize; ///< Uniform table size.
DVLE_uniformEntry_s* uniformTableData; ///< Uniform table data.
char* symbolTableData; ///< Symbol table data.
u8 outmapMask; ///< Output map mask.
u32 outmapData[8]; ///< Output map data.
u32 outmapMode; ///< Output map mode.
u32 outmapClock; ///< Output map attribute clock.
}DVLE_s;
/// DVLB data.
typedef struct{
u32 numDVLE; ///< DVLE count.
DVLP_s DVLP; ///< Primary DVLP.
DVLE_s* DVLE; ///< Contained DVLE.
}DVLB_s;
/**
* @brief Parses a shader binary.
* @param shbinData Shader binary data.
* @param shbinSize Shader binary size.
* @return The parsed shader binary.
*/
DVLB_s* DVLB_ParseFile(u32* shbinData, u32 shbinSize);
/**
* @brief Frees shader binary data.
* @param dvlb DVLB to free.
*/
void DVLB_Free(DVLB_s* dvlb);
/**
* @brief Gets a uniform register index from a shader.
* @param dvle Shader to get the register from.
* @param name Name of the register.
* @return The uniform register index.
*/
s8 DVLE_GetUniformRegister(DVLE_s* dvle, const char* name);
/**
* @brief Generates a shader output map.
* @param dvle Shader to generate an output map for.
*/
void DVLE_GenerateOutmap(DVLE_s* dvle);

118
.vscode/dummyinclude/3ds/ipc.h vendored Normal file
View file

@ -0,0 +1,118 @@
/**
* @file ipc.h
* @brief Inter Process Communication helpers
*/
#pragma once
#include <3ds/types.h>
/// IPC buffer access rights.
typedef enum
{
IPC_BUFFER_R = BIT(1), ///< Readable
IPC_BUFFER_W = BIT(2), ///< Writable
IPC_BUFFER_RW = IPC_BUFFER_R | IPC_BUFFER_W ///< Readable and Writable
} IPC_BufferRights;
/**
* @brief Creates a command header to be used for IPC
* @param command_id ID of the command to create a header for.
* @param normal_params Size of the normal parameters in words. Up to 63.
* @param translate_params Size of the translate parameters in words. Up to 63.
* @return The created IPC header.
*
* Normal parameters are sent directly to the process while the translate parameters might go through modifications and checks by the kernel.
* The translate parameters are described by headers generated with the IPC_Desc_* functions.
*
* @note While #normal_params is equivalent to the number of normal parameters, #translate_params includes the size occupied by the translate parameters headers.
*/
static inline u32 IPC_MakeHeader(u16 command_id, unsigned normal_params, unsigned translate_params)
{
return ((u32) command_id << 16) | (((u32) normal_params & 0x3F) << 6) | (((u32) translate_params & 0x3F) << 0);
}
/**
* @brief Creates a header to share handles
* @param number The number of handles following this header. Max 64.
* @return The created shared handles header.
*
* The #number next values are handles that will be shared between the two processes.
*
* @note Zero values will have no effect.
*/
static inline u32 IPC_Desc_SharedHandles(unsigned number)
{
return ((u32)(number - 1) << 26);
}
/**
* @brief Creates the header to transfer handle ownership
* @param number The number of handles following this header. Max 64.
* @return The created handle transfer header.
*
* The #number next values are handles that will be duplicated and closed by the other process.
*
* @note Zero values will have no effect.
*/
static inline u32 IPC_Desc_MoveHandles(unsigned number)
{
return ((u32)(number - 1) << 26) | 0x10;
}
/**
* @brief Returns the code to ask the kernel to fill the handle with the current process ID.
* @return The code to request the current process ID.
*
* The next value is a placeholder that will be replaced by the current process ID by the kernel.
*/
static inline u32 IPC_Desc_CurProcessId(void)
{
return 0x20;
}
static inline CTR_DEPRECATED u32 IPC_Desc_CurProcessHandle(void)
{
return IPC_Desc_CurProcessId();
}
/**
* @brief Creates a header describing a static buffer.
* @param size Size of the buffer. Max ?0x03FFFF?.
* @param buffer_id The Id of the buffer. Max 0xF.
* @return The created static buffer header.
*
* The next value is a pointer to the buffer. It will be copied to TLS offset 0x180 + static_buffer_id*8.
*/
static inline u32 IPC_Desc_StaticBuffer(size_t size, unsigned buffer_id)
{
return (size << 14) | ((buffer_id & 0xF) << 10) | 0x2;
}
/**
* @brief Creates a header describing a buffer to be sent over PXI.
* @param size Size of the buffer. Max 0x00FFFFFF.
* @param buffer_id The Id of the buffer. Max 0xF.
* @param is_read_only true if the buffer is read-only. If false, the buffer is considered to have read-write access.
* @return The created PXI buffer header.
*
* The next value is a phys-address of a table located in the BASE memregion.
*/
static inline u32 IPC_Desc_PXIBuffer(size_t size, unsigned buffer_id, bool is_read_only)
{
u8 type = 0x4;
if(is_read_only)type = 0x6;
return (size << 8) | ((buffer_id & 0xF) << 4) | type;
}
/**
* @brief Creates a header describing a buffer from the main memory.
* @param size Size of the buffer. Max 0x0FFFFFFF.
* @param rights The rights of the buffer for the destination process.
* @return The created buffer header.
*
* The next value is a pointer to the buffer.
*/
static inline u32 IPC_Desc_Buffer(size_t size, IPC_BufferRights rights)
{
return (size << 4) | 0x8 | rights;
}

159
.vscode/dummyinclude/3ds/mii.h vendored Normal file
View file

@ -0,0 +1,159 @@
/**
* @file mii.h
* @brief Shared Mii struct.
*
* @see https://www.3dbrew.org/wiki/Mii#Mii_format
*/
#pragma once
#include <3ds/types.h>
/// Shared Mii struct
typedef struct
{
u8 magic; ///< Always 3?
/// Mii options
struct
{
bool allow_copying : 1; ///< True if copying is allowed
bool is_private_name : 1; ///< Private name?
u8 region_lock : 2; ///< Region lock (0=no lock, 1=JPN, 2=USA, 3=EUR)
u8 char_set : 2; ///< Character set (0=JPN+USA+EUR, 1=CHN, 2=KOR, 3=TWN)
} mii_options;
/// Mii position in Mii selector or Mii maker
struct
{
u8 page_index : 4; ///< Page index of Mii
u8 slot_index : 4; ///< Slot offset of Mii on its Page
} mii_pos;
/// Console Identity
struct
{
u8 unknown0 : 4; ///< Mabye padding (always seems to be 0)?
u8 origin_console : 3; ///< Console that the Mii was created on (1=WII, 2=DSI, 3=3DS)
} console_identity;
u64 system_id; ///< Identifies the system that the Mii was created on (Determines pants)
u32 mii_id; ///< ID of Mii
u8 mac[6]; ///< Creator's system's full MAC address
u8 pad[2]; ///< Padding
/// Mii details
struct {
bool sex : 1; ///< Sex of Mii (False=Male, True=Female)
u16 bday_month : 4; ///< Month of Mii's birthday
u16 bday_day : 5; ///< Day of Mii's birthday
u16 shirt_color : 4; ///< Color of Mii's shirt
bool favorite : 1; ///< Whether the Mii is one of your 10 favorite Mii's
} mii_details;
u16 mii_name[10]; ///< Name of Mii (Encoded using UTF16)
u8 height; ///< How tall the Mii is
u8 width; ///< How wide the Mii is
/// Face style
struct
{
bool disable_sharing : 1; ///< Whether or not Sharing of the Mii is allowed
u8 shape : 4; ///< Face shape
u8 skinColor : 3; ///< Color of skin
} face_style;
/// Face details
struct
{
u8 wrinkles : 4;
u8 makeup : 4;
} face_details;
u8 hair_style;
/// Hair details
struct
{
u8 color : 3;
bool flip : 1;
} hair_details;
/// Eye details
struct
{
u32 style : 6;
u32 color : 3;
u32 scale : 4;
u32 yscale : 3;
u32 rotation : 5;
u32 xspacing : 4;
u32 yposition : 5;
} eye_details;
/// Eyebrow details
struct
{
u32 style : 5;
u32 color : 3;
u32 scale : 4;
u32 yscale : 3;
u32 pad : 1;
u32 rotation : 5;
u32 xspacing : 4;
u32 yposition : 5;
} eyebrow_details;
/// Nose details
struct
{
u16 style : 5;
u16 scale : 4;
u16 yposition : 5;
} nose_details;
/// Mouth details
struct
{
u16 style : 6;
u16 color : 3;
u16 scale : 4;
u16 yscale : 3;
} mouth_details;
/// Mustache details
struct
{
u16 mouth_yposition : 5;
u16 mustach_style : 3;
u16 pad : 2;
} mustache_details;
/// Beard details
struct
{
u16 style : 3;
u16 color : 3;
u16 scale : 4;
u16 ypos : 5;
} beard_details;
/// Glasses details
struct
{
u16 style : 4;
u16 color : 3;
u16 scale : 4;
u16 ypos : 5;
} glasses_details;
/// Mole details
struct
{
bool enable : 1;
u16 scale : 5;
u16 xpos : 5;
u16 ypos : 5;
} mole_details;
u16 author_name[10]; ///< Name of Mii's author (Encoded using UTF16)
} CTR_PACKED MiiData;

264
.vscode/dummyinclude/3ds/ndsp/channel.h vendored Normal file
View file

@ -0,0 +1,264 @@
/**
* @file channel.h
* @brief Functions for interacting with DSP audio channels.
*/
#pragma once
///@name Data types
///@{
/// Supported sample encodings.
enum
{
NDSP_ENCODING_PCM8 = 0, ///< PCM8
NDSP_ENCODING_PCM16, ///< PCM16
NDSP_ENCODING_ADPCM, ///< DSPADPCM (GameCube format)
};
/// Specifies the number of channels used in a sample.
#define NDSP_CHANNELS(n) ((u32)(n) & 3)
/// Specifies the encoding used in a sample.
#define NDSP_ENCODING(n) (((u32)(n) & 3) << 2)
/// Channel format flags for use with ndspChnSetFormat.
enum
{
NDSP_FORMAT_MONO_PCM8 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM8), ///< Buffer contains Mono PCM8.
NDSP_FORMAT_MONO_PCM16 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM16), ///< Buffer contains Mono PCM16.
NDSP_FORMAT_MONO_ADPCM = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_ADPCM), ///< Buffer contains Mono ADPCM.
NDSP_FORMAT_STEREO_PCM8 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM8), ///< Buffer contains Stereo PCM8.
NDSP_FORMAT_STEREO_PCM16 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM16), ///< Buffer contains Stereo PCM16.
NDSP_FORMAT_PCM8 = NDSP_FORMAT_MONO_PCM8, ///< (Alias) Buffer contains Mono PCM8.
NDSP_FORMAT_PCM16 = NDSP_FORMAT_MONO_PCM16, ///< (Alias) Buffer contains Mono PCM16.
NDSP_FORMAT_ADPCM = NDSP_FORMAT_MONO_ADPCM, ///< (Alias) Buffer contains Mono ADPCM.
// Flags
NDSP_FRONT_BYPASS = BIT(4), ///< Front bypass.
NDSP_3D_SURROUND_PREPROCESSED = BIT(6), ///< (?) Unknown, under research
};
/// Interpolation types.
typedef enum
{
NDSP_INTERP_POLYPHASE = 0, ///< Polyphase interpolation
NDSP_INTERP_LINEAR = 1, ///< Linear interpolation
NDSP_INTERP_NONE = 2, ///< No interpolation
} ndspInterpType;
///@}
///@name Basic channel operation
///@{
/**
* @brief Resets a channel.
* @param id ID of the channel (0..23).
*/
void ndspChnReset(int id);
/**
* @brief Initializes the parameters of a channel.
* @param id ID of the channel (0..23).
*/
void ndspChnInitParams(int id);
/**
* @brief Checks whether a channel is currently playing.
* @param id ID of the channel (0..23).
* @return Whether the channel is currently playing.
*/
bool ndspChnIsPlaying(int id);
/**
* @brief Gets the current sample position of a channel.
* @param id ID of the channel (0..23).
* @return The channel's sample position.
*/
u32 ndspChnGetSamplePos(int id);
/**
* @brief Gets the sequence ID of the wave buffer that is currently playing in a channel.
* @param id ID of the channel (0..23).
* @return The sequence ID of the wave buffer.
*/
u16 ndspChnGetWaveBufSeq(int id);
/**
* @brief Checks whether a channel is currently paused.
* @param id ID of the channel (0..23).
* @return Whether the channel is currently paused.
*/
bool ndspChnIsPaused(int id);
/**
* @brief Sets the pause status of a channel.
* @param id ID of the channel (0..23).
* @param paused Whether the channel is to be paused (true) or unpaused (false).
*/
void ndspChnSetPaused(int id, bool paused);
///@}
///@name Configuration
///@{
/**
* @brief Sets the format of a channel.
* @param id ID of the channel (0..23).
* @param format Format to use.
*/
void ndspChnSetFormat(int id, u16 format);
/**
*
* @brief Gets the format of a channel.
* @param id ID of the channel (0..23).
* @return The format of the channel.
*/
u16 ndspChnGetFormat(int id);
/**
* @brief Sets the interpolation type of a channel.
* @param id ID of the channel (0..23).
* @param type Interpolation type to use.
*/
void ndspChnSetInterp(int id, ndspInterpType type);
/**
* @brief Gets the interpolation type of a channel.
* @param id ID of the channel (0..23).
* @return The interpolation type of the channel.
*/
ndspInterpType ndspChnGetInterp(int id);
/**
* @brief Sets the sample rate of a channel.
* @param id ID of the channel (0..23).
* @param rate Sample rate to use.
*/
void ndspChnSetRate(int id, float rate);
/**
* @brief Gets the sample rate of a channel.
* @param id ID of the channel (0..23).
* @return The sample rate of the channel.
*/
float ndspChnGetRate(int id);
/**
* @brief Sets the mix parameters (volumes) of a channel.
* @param id ID of the channel (0..23).
* @param mix Mix parameters to use. Working hypothesis:
* - 0: Front left volume.
* - 1: Front right volume.
* - 2: Back left volume:
* - 3: Back right volume:
* - 4..7: Same as 0..3, but for auxiliary output 0.
* - 8..11: Same as 0..3, but for auxiliary output 1.
*/
void ndspChnSetMix(int id, float mix[12]);
/**
* @brief Gets the mix parameters (volumes) of a channel.
* @param id ID of the channel (0..23)
* @param mix Mix parameters to write out to. See \ref ndspChnSetMix.
*/
void ndspChnGetMix(int id, float mix[12]);
/**
* @brief Sets the DSPADPCM coefficients of a channel.
* @param id ID of the channel (0..23).
* @param coefs DSPADPCM coefficients to use.
*/
void ndspChnSetAdpcmCoefs(int id, u16 coefs[16]);
///@}
///@name Wave buffers
///@{
/**
* @brief Clears the wave buffer queue of a channel and stops playback.
* @param id ID of the channel (0..23).
*/
void ndspChnWaveBufClear(int id);
/**
* @brief Adds a wave buffer to the wave buffer queue of a channel.
* @remark If the channel's wave buffer queue was empty before the use of this function, playback is started.
* @param id ID of the channel (0..23).
* @param buf Wave buffer to add.
*/
void ndspChnWaveBufAdd(int id, ndspWaveBuf* buf);
///@}
///@name IIR filters
///@{
/**
* @brief Configures whether the IIR monopole filter of a channel is enabled.
* @param id ID of the channel (0..23).
* @param enable Whether to enable the IIR monopole filter.
*/
void ndspChnIirMonoSetEnable(int id, bool enable);
/**
* @brief Manually sets up the parameters on monopole filter
* @param id ID of the channel (0..23).
* @param enable Whether to enable the IIR monopole filter.
*/
bool ndspChnIirMonoSetParamsCustomFilter(int id, float a0, float a1, float b0);
/**
* @brief Sets the monopole to be a low pass filter. (Note: This is a lower-quality filter than the biquad one.)
* @param id ID of the channel (0..23).
* @param f0 Low pass cut-off frequency.
*/
bool ndspChnIirMonoSetParamsLowPassFilter(int id, float f0);
/**
* @brief Sets the monopole to be a high pass filter. (Note: This is a lower-quality filter than the biquad one.)
* @param id ID of the channel (0..23).
* @param f0 High pass cut-off frequency.
*/
bool ndspChnIirMonoSetParamsHighPassFilter(int id, float f0);
/**
* @brief Configures whether the IIR biquad filter of a channel is enabled.
* @param id ID of the channel (0..23).
* @param enable Whether to enable the IIR biquad filter.
*/
void ndspChnIirBiquadSetEnable(int id, bool enable);
/**
* @brief Manually sets up the parameters of the biquad filter
* @param id ID of the channel (0..23).
*/
bool ndspChnIirBiquadSetParamsCustomFilter(int id, float a0, float a1, float a2, float b0, float b1, float b2);
/**
* @brief Sets the biquad to be a low pass filter.
* @param id ID of the channel (0..23).
* @param f0 Low pass cut-off frequency.
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
*/
bool ndspChnIirBiquadSetParamsLowPassFilter(int id, float f0, float Q);
/**
* @brief Sets the biquad to be a high pass filter.
* @param id ID of the channel (0..23).
* @param f0 High pass cut-off frequency.
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
*/
bool ndspChnIirBiquadSetParamsHighPassFilter(int id, float f0, float Q);
/**
* @brief Sets the biquad to be a band pass filter.
* @param id ID of the channel (0..23).
* @param f0 Mid-frequency.
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
*/
bool ndspChnIirBiquadSetParamsBandPassFilter(int id, float f0, float Q);
/**
* @brief Sets the biquad to be a notch filter.
* @param id ID of the channel (0..23).
* @param f0 Notch frequency.
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
*/
bool ndspChnIirBiquadSetParamsNotchFilter(int id, float f0, float Q);
/**
* @brief Sets the biquad to be a peaking equalizer.
* @param id ID of the channel (0..23).
* @param f0 Central frequency.
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
* @param gain Amount of gain (raw value = 10 ^ dB/40)
*/
bool ndspChnIirBiquadSetParamsPeakingEqualizer(int id, float f0, float Q, float gain);
///@}

267
.vscode/dummyinclude/3ds/ndsp/ndsp.h vendored Normal file
View file

@ -0,0 +1,267 @@
/**
* @file ndsp.h
* @brief Interface for Nintendo's default DSP component.
*/
#pragma once
#include <3ds/os.h>
#define NDSP_SAMPLE_RATE (SYSCLOCK_SOC / 512.0)
///@name Data types
///@{
/// Sound output modes.
typedef enum
{
NDSP_OUTPUT_MONO = 0, ///< Mono sound
NDSP_OUTPUT_STEREO = 1, ///< Stereo sound
NDSP_OUTPUT_SURROUND = 2, ///< 3D Surround sound
} ndspOutputMode;
// Clipping modes.
typedef enum
{
NDSP_CLIP_NORMAL = 0, ///< "Normal" clipping mode (?)
NDSP_CLIP_SOFT = 1, ///< "Soft" clipping mode (?)
} ndspClippingMode;
// Surround speaker positions.
typedef enum
{
NDSP_SPKPOS_SQUARE = 0, ///<?
NDSP_SPKPOS_WIDE = 1, ///<?
NDSP_SPKPOS_NUM = 2, ///<?
} ndspSpeakerPos;
/// ADPCM data.
typedef struct
{
u16 index; ///< Current predictor index
s16 history0; ///< Last outputted PCM16 sample.
s16 history1; ///< Second to last outputted PCM16 sample.
} ndspAdpcmData;
/// Wave buffer type.
typedef struct tag_ndspWaveBuf ndspWaveBuf;
/// Wave buffer status.
enum
{
NDSP_WBUF_FREE = 0, ///< The wave buffer is not queued.
NDSP_WBUF_QUEUED = 1, ///< The wave buffer is queued and has not been played yet.
NDSP_WBUF_PLAYING = 2, ///< The wave buffer is playing right now.
NDSP_WBUF_DONE = 3, ///< The wave buffer has finished being played.
};
/// Wave buffer struct.
struct tag_ndspWaveBuf
{
union
{
s8* data_pcm8; ///< Pointer to PCM8 sample data.
s16* data_pcm16; ///< Pointer to PCM16 sample data.
u8* data_adpcm; ///< Pointer to DSPADPCM sample data.
const void* data_vaddr; ///< Data virtual address.
};
u32 nsamples; ///< Total number of samples (PCM8=bytes, PCM16=halfwords, DSPADPCM=nibbles without frame headers)
ndspAdpcmData* adpcm_data; ///< ADPCM data.
u32 offset; ///< Buffer offset. Only used for capture.
bool looping; ///< Whether to loop the buffer.
u8 status; ///< Queuing/playback status.
u16 sequence_id; ///< Sequence ID. Assigned automatically by ndspChnWaveBufAdd.
ndspWaveBuf* next; ///< Next buffer to play. Used internally, do not modify.
};
/// Sound frame callback function. (data = User provided data)
typedef void (*ndspCallback)(void* data);
/// Auxiliary output callback function. (data = User provided data, nsamples = Number of samples, samples = Sample data)
typedef void (*ndspAuxCallback)(void* data, int nsamples, void* samples[4]);
///@}
///@name Initialization and basic operations
///@{
/**
* @brief Sets up the DSP component.
* @param binary DSP binary to load.
* @param size Size of the DSP binary.
* @param progMask Program RAM block mask to load the binary to.
* @param dataMask Data RAM block mask to load the binary to.
*/
void ndspUseComponent(const void* binary, u32 size, u16 progMask, u16 dataMask);
/// Initializes NDSP.
Result ndspInit(void);
/// Exits NDSP.
void ndspExit(void);
/**
* @brief Gets the number of dropped sound frames.
* @return The number of dropped sound frames.
*/
u32 ndspGetDroppedFrames(void);
/**
* @brief Gets the total sound frame count.
* @return The total sound frame count.
*/
u32 ndspGetFrameCount(void);
///@}
///@name General parameters
///@{
/**
* @brief Sets the master volume.
* @param volume Volume to set. Defaults to 1.0f.
*/
void ndspSetMasterVol(float volume);
/**
* @brief Gets the master volume.
* @return The master volume.
*/
float ndspGetMasterVol(void);
/**
* @brief Sets the output mode.
* @param mode Output mode to set. Defaults to NDSP_OUTPUT_STEREO.
*/
void ndspSetOutputMode(ndspOutputMode mode);
/**
* @brief Gets the output mode.
* @return The output mode.
*/
ndspOutputMode ndspGetOutputMode(void);
/**
* @brief Sets the clipping mode.
* @param mode Clipping mode to set. Defaults to NDSP_CLIP_SOFT.
*/
void ndspSetClippingMode(ndspClippingMode mode);
/**
* @brief Gets the clipping mode.
* @return The clipping mode.
*/
ndspClippingMode ndspGetClippingMode(void);
/**
* @brief Sets the output count.
* @param count Output count to set. Defaults to 2.
*/
void ndspSetOutputCount(int count);
/**
* @brief Gets the output count.
* @return The output count.
*/
int ndspGetOutputCount(void);
/**
* @brief Sets the wave buffer to capture audio to.
* @param capture Wave buffer to capture to.
*/
void ndspSetCapture(ndspWaveBuf* capture);
/**
* @brief Sets the sound frame callback.
* @param callback Callback to set.
* @param data User-defined data to pass to the callback.
*/
void ndspSetCallback(ndspCallback callback, void* data);
///@}
///@name Surround
///@{
/**
* @brief Sets the surround sound depth.
* @param depth Depth to set. Defaults to 0x7FFF.
*/
void ndspSurroundSetDepth(u16 depth);
/**
* @brief Gets the surround sound depth.
* @return The surround sound depth.
*/
u16 ndspSurroundGetDepth(void);
/**
* @brief Sets the surround sound position.
* @param pos Position to set. Defaults to NDSP_SPKPOS_SQUARE.
*/
void ndspSurroundSetPos(ndspSpeakerPos pos);
/**
* @brief Gets the surround sound position.
* @return The surround sound speaker position.
*/
ndspSpeakerPos ndspSurroundGetPos(void);
/**
* @brief Sets the surround sound rear ratio.
* @param ratio Rear ratio to set. Defaults to 0x8000.
*/
void ndspSurroundSetRearRatio(u16 ratio);
/**
* @brief Gets the surround sound rear ratio.
* @return The rear ratio.
*/
u16 ndspSurroundGetRearRatio(void);
///@}
///@name Auxiliary output
///@{
/**
* @brief Configures whether an auxiliary output is enabled.
* @param id ID of the auxiliary output.
* @param enable Whether to enable the auxiliary output.
*/
void ndspAuxSetEnable(int id, bool enable);
/**
* @brief Gets whether auxiliary output is enabled.
* @param id ID of the auxiliary output.
* @return Whether auxiliary output is enabled.
*/
bool ndspAuxIsEnabled(int id);
/**
* @brief Configures whether an auxiliary output should use front bypass.
* @param id ID of the auxiliary output.
* @param bypass Whether to use front bypass.
*/
void ndspAuxSetFrontBypass(int id, bool bypass);
/**
* @brief Gets whether auxiliary output front bypass is enabled.
* @param id ID of the auxiliary output.
* @return Whether auxiliary output front bypass is enabled.
*/
bool ndspAuxGetFrontBypass(int id);
/**
* @brief Sets the volume of an auxiliary output.
* @param id ID of the auxiliary output.
* @param volume Volume to set.
*/
void ndspAuxSetVolume(int id, float volume);
/**
* @brief Gets the volume of an auxiliary output.
* @param id ID of the auxiliary output.
* @return Volume of the auxiliary output.
*/
float ndspAuxGetVolume(int id);
/**
* @brief Sets the callback of an auxiliary output.
* @param id ID of the auxiliary output.
* @param callback Callback to set.
* @param data User-defined data to pass to the callback.
*/
void ndspAuxSetCallback(int id, ndspAuxCallback callback, void* data);
///@}

349
.vscode/dummyinclude/3ds/os.h vendored Normal file
View file

@ -0,0 +1,349 @@
/**
* @file os.h
* @brief OS related stuff.
*/
#pragma once
#include "svc.h"
///< The external clock rate for the SoC.
#define SYSCLOCK_SOC (16756991u)
///< The base system clock rate (for I2C, NDMA, etc.).
#define SYSCLOCK_SYS (SYSCLOCK_SOC * 2)
///< The base clock rate for the SDMMC controller (and some other peripherals).
#define SYSCLOCK_SDMMC (SYSCLOCK_SYS * 2)
///< The clock rate for the Arm9.
#define SYSCLOCK_ARM9 (SYSCLOCK_SYS * 4)
///< The clock rate for the Arm11 in CTR mode and in \ref svcGetSystemTick.
#define SYSCLOCK_ARM11 (SYSCLOCK_ARM9 * 2)
///< The clock rate for the Arm11 in LGR1 mode.
#define SYSCLOCK_ARM11_LGR1 (SYSCLOCK_ARM11 * 2)
///< The clock rate for the Arm11 in LGR2 mode.
#define SYSCLOCK_ARM11_LGR2 (SYSCLOCK_ARM11 * 3)
///< The highest possible clock rate for the Arm11 on known New 3DS units.
#define SYSCLOCK_ARM11_NEW SYSCLOCK_ARM11_LGR2
#define CPU_TICKS_PER_MSEC (SYSCLOCK_ARM11 / 1000.0)
#define CPU_TICKS_PER_USEC (SYSCLOCK_ARM11 / 1000000.0)
/// Packs a system version from its components.
#define SYSTEM_VERSION(major, minor, revision) \
(((major)<<24)|((minor)<<16)|((revision)<<8))
/// Retrieves the major version from a packed system version.
#define GET_VERSION_MAJOR(version) ((version) >>24)
/// Retrieves the minor version from a packed system version.
#define GET_VERSION_MINOR(version) (((version)>>16)&0xFF)
/// Retrieves the revision version from a packed system version.
#define GET_VERSION_REVISION(version) (((version)>> 8)&0xFF)
#define OS_HEAP_AREA_BEGIN 0x08000000 ///< Start of the heap area in the virtual address space
#define OS_HEAP_AREA_END 0x0E000000 ///< End of the heap area in the virtual address space
#define OS_MAP_AREA_BEGIN 0x10000000 ///< Start of the mappable area in the virtual address space
#define OS_MAP_AREA_END 0x14000000 ///< End of the mappable area in the virtual address space
#define OS_OLD_FCRAM_VADDR 0x14000000 ///< Old pre-8.x linear FCRAM mapping virtual address
#define OS_OLD_FCRAM_PADDR 0x20000000 ///< Old pre-8.x linear FCRAM mapping physical address
#define OS_OLD_FCRAM_SIZE 0x8000000 ///< Old pre-8.x linear FCRAM mapping size (128 MiB)
#define OS_QTMRAM_VADDR 0x1E800000 ///< New3DS QTM memory virtual address
#define OS_QTMRAM_PADDR 0x1F000000 ///< New3DS QTM memory physical address
#define OS_QTMRAM_SIZE 0x400000 ///< New3DS QTM memory size (4 MiB; last 128 KiB reserved by kernel)
#define OS_MMIO_VADDR 0x1EC00000 ///< Memory mapped IO range virtual address
#define OS_MMIO_PADDR 0x10100000 ///< Memory mapped IO range physical address
#define OS_MMIO_SIZE 0x400000 ///< Memory mapped IO range size (4 MiB)
#define OS_VRAM_VADDR 0x1F000000 ///< VRAM virtual address
#define OS_VRAM_PADDR 0x18000000 ///< VRAM physical address
#define OS_VRAM_SIZE 0x600000 ///< VRAM size (6 MiB)
#define OS_DSPRAM_VADDR 0x1FF00000 ///< DSP memory virtual address
#define OS_DSPRAM_PADDR 0x1FF00000 ///< DSP memory physical address
#define OS_DSPRAM_SIZE 0x80000 ///< DSP memory size (512 KiB)
#define OS_KERNELCFG_VADDR 0x1FF80000 ///< Kernel configuration page virtual address
#define OS_SHAREDCFG_VADDR 0x1FF81000 ///< Shared system configuration page virtual address
#define OS_FCRAM_VADDR 0x30000000 ///< Linear FCRAM mapping virtual address
#define OS_FCRAM_PADDR 0x20000000 ///< Linear FCRAM mapping physical address
#define OS_FCRAM_SIZE 0x10000000 ///< Linear FCRAM mapping size (256 MiB)
#define OS_KernelConfig ((osKernelConfig_s const*)OS_KERNELCFG_VADDR) ///< Pointer to the kernel configuration page (see \ref osKernelConfig_s)
#define OS_SharedConfig ((osSharedConfig_s*)OS_SHAREDCFG_VADDR) ///< Pointer to the shared system configuration page (see \ref osSharedConfig_s)
/// Kernel configuration page (read-only).
typedef struct
{
u32 kernel_ver;
u32 update_flag;
u64 ns_tid;
u32 kernel_syscore_ver;
u8 env_info;
u8 unit_info;
u8 boot_env;
u8 unk_0x17;
u32 kernel_ctrsdk_ver;
u32 unk_0x1c;
u32 firmlaunch_flags;
u8 unk_0x24[0xc];
u32 app_memtype;
u8 unk_0x34[0xc];
u32 memregion_sz[3];
u8 unk_0x4c[0x14];
u32 firm_ver;
u32 firm_syscore_ver;
u32 firm_ctrsdk_ver;
} osKernelConfig_s;
/// Time reference information struct (filled in by PTM).
typedef struct
{
u64 value_ms; ///< Milliseconds elapsed since January 1900 when this structure was last updated
u64 value_tick; ///< System ticks elapsed since boot when this structure was last updated
s64 sysclock_hz;///< System clock frequency in Hz adjusted using RTC measurements (usually around \ref SYSCLOCK_ARM11)
s64 drift_ms; ///< Measured time drift of the system clock (according to the RTC) in milliseconds since the last update
} osTimeRef_s;
/// Shared system configuration page structure (read-only or read-write depending on exheader).
typedef struct
{
vu32 timeref_cnt;
u8 running_hw;
u8 mcu_hwinfo;
u8 unk_0x06[0x1A];
volatile osTimeRef_s timeref[2];
u8 wifi_macaddr[6];
vu8 wifi_strength;
vu8 network_state;
u8 unk_0x68[0x18];
volatile float slider_3d;
vu8 led_3d;
vu8 led_battery;
vu8 unk_flag;
u8 unk_0x87;
u8 unk_0x88[0x18];
vu64 menu_tid;
vu64 cur_menu_tid;
u8 unk_0xB0[0x10];
vu8 headset_connected;
} osSharedConfig_s;
/// Tick counter.
typedef struct
{
u64 elapsed; ///< Elapsed CPU ticks between measurements.
u64 reference; ///< Point in time used as reference.
} TickCounter;
/// OS_VersionBin. Format of the system version: "<major>.<minor>.<build>-<nupver><region>"
typedef struct
{
u8 build;
u8 minor;
u8 mainver;//"major" in CVER, NUP version in NVer.
u8 reserved_x3;
char region;//"ASCII character for the system version region"
u8 reserved_x5[0x3];
} OS_VersionBin;
/**
* @brief Converts an address from virtual (process) memory to physical memory.
* @param vaddr Input virtual address.
* @return The corresponding physical address.
* It is sometimes required by services or when using the GPU command buffer.
*/
u32 osConvertVirtToPhys(const void* vaddr);
/**
* @brief Converts 0x14* vmem to 0x30*.
* @param vaddr Input virtual address.
* @return The corresponding address in the 0x30* range, the input address if it's already within the new vmem, or 0 if it's outside of both ranges.
*/
void* osConvertOldLINEARMemToNew(const void* vaddr);
/**
* @brief Retrieves basic information about a service error.
* @param error Error to retrieve information about.
* @return A string containing a summary of an error.
*
* This can be used to get some details about an error returned by a service call.
*/
const char* osStrError(Result error);
/**
* @brief Gets the system's FIRM version.
* @return The system's FIRM version.
*
* This can be used to compare system versions easily with @ref SYSTEM_VERSION.
*/
static inline u32 osGetFirmVersion(void)
{
return OS_KernelConfig->firm_ver &~ 0xFF;
}
/**
* @brief Gets the system's kernel version.
* @return The system's kernel version.
*
* This can be used to compare system versions easily with @ref SYSTEM_VERSION.
*
* @code
* if(osGetKernelVersion() > SYSTEM_VERSION(2,46,0)) printf("You are running 9.0 or higher\n");
* @endcode
*/
static inline u32 osGetKernelVersion(void)
{
return OS_KernelConfig->kernel_ver &~ 0xFF;
}
/// Gets the system's "core version" (2 on NATIVE_FIRM, 3 on SAFE_FIRM, etc.)
static inline u32 osGetSystemCoreVersion(void)
{
return OS_KernelConfig->kernel_syscore_ver;
}
/// Gets the system's memory layout ID (0-5 on Old 3DS, 6-8 on New 3DS)
static inline u32 osGetApplicationMemType(void)
{
return OS_KernelConfig->app_memtype;
}
/**
* @brief Gets the size of the specified memory region.
* @param region Memory region to check.
* @return The size of the memory region, in bytes.
*/
static inline u32 osGetMemRegionSize(MemRegion region)
{
if(region == MEMREGION_ALL) {
return osGetMemRegionSize(MEMREGION_APPLICATION) + osGetMemRegionSize(MEMREGION_SYSTEM) + osGetMemRegionSize(MEMREGION_BASE);
} else {
return OS_KernelConfig->memregion_sz[region-1];
}
}
/**
* @brief Gets the number of used bytes within the specified memory region.
* @param region Memory region to check.
* @return The number of used bytes of memory.
*/
static inline u32 osGetMemRegionUsed(MemRegion region)
{
s64 mem_used;
svcGetSystemInfo(&mem_used, 0, region);
return mem_used;
}
/**
* @brief Gets the number of free bytes within the specified memory region.
* @param region Memory region to check.
* @return The number of free bytes of memory.
*/
static inline u32 osGetMemRegionFree(MemRegion region)
{
return osGetMemRegionSize(region) - osGetMemRegionUsed(region);
}
/**
* @brief Reads the latest reference timepoint published by PTM.
* @return Structure (see \ref osTimeRef_s).
*/
osTimeRef_s osGetTimeRef(void);
/**
* @brief Gets the current time.
* @return The number of milliseconds since 1st Jan 1900 00:00.
*/
u64 osGetTime(void);
/**
* @brief Starts a tick counter.
* @param cnt The tick counter.
*/
static inline void osTickCounterStart(TickCounter* cnt)
{
cnt->reference = svcGetSystemTick();
}
/**
* @brief Updates the elapsed time in a tick counter.
* @param cnt The tick counter.
*/
static inline void osTickCounterUpdate(TickCounter* cnt)
{
u64 now = svcGetSystemTick();
cnt->elapsed = now - cnt->reference;
cnt->reference = now;
}
/**
* @brief Reads the elapsed time in a tick counter.
* @param cnt The tick counter.
* @return The number of milliseconds elapsed.
*/
double osTickCounterRead(const TickCounter* cnt);
/**
* @brief Gets the current Wifi signal strength.
* @return The current Wifi signal strength.
*
* Valid values are 0-3:
* - 0 means the signal strength is terrible or the 3DS is disconnected from
* all networks.
* - 1 means the signal strength is bad.
* - 2 means the signal strength is decent.
* - 3 means the signal strength is good.
*
* Values outside the range of 0-3 should never be returned.
*
* These values correspond with the number of wifi bars displayed by Home Menu.
*/
static inline u8 osGetWifiStrength(void)
{
return OS_SharedConfig->wifi_strength;
}
/**
* @brief Gets the state of the 3D slider.
* @return The state of the 3D slider (0.0~1.0)
*/
static inline float osGet3DSliderState(void)
{
return OS_SharedConfig->slider_3d;
}
/**
* @brief Checks whether a headset is connected.
* @return true or false.
*/
static inline bool osIsHeadsetConnected(void)
{
return OS_SharedConfig->headset_connected != 0;
}
/**
* @brief Configures the New 3DS speedup.
* @param enable Specifies whether to enable or disable the speedup.
*/
void osSetSpeedupEnable(bool enable);
/**
* @brief Gets the NAND system-version stored in NVer/CVer.
* @param nver_versionbin Output OS_VersionBin structure for the data read from NVer.
* @param cver_versionbin Output OS_VersionBin structure for the data read from CVer.
* @return The result-code. This value can be positive if opening "romfs:/version.bin" fails with stdio, since errno would be returned in that case. In some cases the error can be special negative values as well.
*/
Result osGetSystemVersionData(OS_VersionBin *nver_versionbin, OS_VersionBin *cver_versionbin);
/**
* @brief This is a wrapper for osGetSystemVersionData.
* @param nver_versionbin Optional output OS_VersionBin structure for the data read from NVer, can be NULL.
* @param cver_versionbin Optional output OS_VersionBin structure for the data read from CVer, can be NULL.
* @param sysverstr Output string where the printed system-version will be written, in the same format displayed by the System Settings title.
* @param sysverstr_maxsize Max size of the above string buffer, *including* NULL-terminator.
* @return See osGetSystemVersionData.
*/
Result osGetSystemVersionDataString(OS_VersionBin *nver_versionbin, OS_VersionBin *cver_versionbin, char *sysverstr, u32 sysverstr_maxsize);

191
.vscode/dummyinclude/3ds/result.h vendored Normal file
View file

@ -0,0 +1,191 @@
/**
* @file result.h
* @brief 3DS result code tools
*/
#pragma once
#include "types.h"
/// Checks whether a result code indicates success.
#define R_SUCCEEDED(res) ((res)>=0)
/// Checks whether a result code indicates failure.
#define R_FAILED(res) ((res)<0)
/// Returns the level of a result code.
#define R_LEVEL(res) (((res)>>27)&0x1F)
/// Returns the summary of a result code.
#define R_SUMMARY(res) (((res)>>21)&0x3F)
/// Returns the module ID of a result code.
#define R_MODULE(res) (((res)>>10)&0xFF)
/// Returns the description of a result code.
#define R_DESCRIPTION(res) ((res)&0x3FF)
/// Builds a result code from its constituent components.
#define MAKERESULT(level,summary,module,description) \
((((level)&0x1F)<<27) | (((summary)&0x3F)<<21) | (((module)&0xFF)<<10) | ((description)&0x3FF))
/// Result code level values.
enum
{
// >= 0
RL_SUCCESS = 0,
RL_INFO = 1,
// < 0
RL_FATAL = 0x1F,
RL_RESET = RL_FATAL - 1,
RL_REINITIALIZE = RL_FATAL - 2,
RL_USAGE = RL_FATAL - 3,
RL_PERMANENT = RL_FATAL - 4,
RL_TEMPORARY = RL_FATAL - 5,
RL_STATUS = RL_FATAL - 6,
};
/// Result code summary values.
enum
{
RS_SUCCESS = 0,
RS_NOP = 1,
RS_WOULDBLOCK = 2,
RS_OUTOFRESOURCE = 3,
RS_NOTFOUND = 4,
RS_INVALIDSTATE = 5,
RS_NOTSUPPORTED = 6,
RS_INVALIDARG = 7,
RS_WRONGARG = 8,
RS_CANCELED = 9,
RS_STATUSCHANGED = 10,
RS_INTERNAL = 11,
RS_INVALIDRESVAL = 63,
};
/// Result code module values.
enum
{
RM_COMMON = 0,
RM_KERNEL = 1,
RM_UTIL = 2,
RM_FILE_SERVER = 3,
RM_LOADER_SERVER = 4,
RM_TCB = 5,
RM_OS = 6,
RM_DBG = 7,
RM_DMNT = 8,
RM_PDN = 9,
RM_GSP = 10,
RM_I2C = 11,
RM_GPIO = 12,
RM_DD = 13,
RM_CODEC = 14,
RM_SPI = 15,
RM_PXI = 16,
RM_FS = 17,
RM_DI = 18,
RM_HID = 19,
RM_CAM = 20,
RM_PI = 21,
RM_PM = 22,
RM_PM_LOW = 23,
RM_FSI = 24,
RM_SRV = 25,
RM_NDM = 26,
RM_NWM = 27,
RM_SOC = 28,
RM_LDR = 29,
RM_ACC = 30,
RM_ROMFS = 31,
RM_AM = 32,
RM_HIO = 33,
RM_UPDATER = 34,
RM_MIC = 35,
RM_FND = 36,
RM_MP = 37,
RM_MPWL = 38,
RM_AC = 39,
RM_HTTP = 40,
RM_DSP = 41,
RM_SND = 42,
RM_DLP = 43,
RM_HIO_LOW = 44,
RM_CSND = 45,
RM_SSL = 46,
RM_AM_LOW = 47,
RM_NEX = 48,
RM_FRIENDS = 49,
RM_RDT = 50,
RM_APPLET = 51,
RM_NIM = 52,
RM_PTM = 53,
RM_MIDI = 54,
RM_MC = 55,
RM_SWC = 56,
RM_FATFS = 57,
RM_NGC = 58,
RM_CARD = 59,
RM_CARDNOR = 60,
RM_SDMC = 61,
RM_BOSS = 62,
RM_DBM = 63,
RM_CONFIG = 64,
RM_PS = 65,
RM_CEC = 66,
RM_IR = 67,
RM_UDS = 68,
RM_PL = 69,
RM_CUP = 70,
RM_GYROSCOPE = 71,
RM_MCU = 72,
RM_NS = 73,
RM_NEWS = 74,
RM_RO = 75,
RM_GD = 76,
RM_CARD_SPI = 77,
RM_EC = 78,
RM_WEB_BROWSER = 79,
RM_TEST = 80,
RM_ENC = 81,
RM_PIA = 82,
RM_ACT = 83,
RM_VCTL = 84,
RM_OLV = 85,
RM_NEIA = 86,
RM_NPNS = 87,
RM_AVD = 90,
RM_L2B = 91,
RM_MVD = 92,
RM_NFC = 93,
RM_UART = 94,
RM_SPM = 95,
RM_QTM = 96,
RM_NFP = 97,
RM_APPLICATION = 254,
RM_INVALIDRESVAL = 255,
};
/// Result code generic description values.
enum
{
RD_SUCCESS = 0,
RD_INVALID_RESULT_VALUE = 0x3FF,
RD_TIMEOUT = RD_INVALID_RESULT_VALUE - 1,
RD_OUT_OF_RANGE = RD_INVALID_RESULT_VALUE - 2,
RD_ALREADY_EXISTS = RD_INVALID_RESULT_VALUE - 3,
RD_CANCEL_REQUESTED = RD_INVALID_RESULT_VALUE - 4,
RD_NOT_FOUND = RD_INVALID_RESULT_VALUE - 5,
RD_ALREADY_INITIALIZED = RD_INVALID_RESULT_VALUE - 6,
RD_NOT_INITIALIZED = RD_INVALID_RESULT_VALUE - 7,
RD_INVALID_HANDLE = RD_INVALID_RESULT_VALUE - 8,
RD_INVALID_POINTER = RD_INVALID_RESULT_VALUE - 9,
RD_INVALID_ADDRESS = RD_INVALID_RESULT_VALUE - 10,
RD_NOT_IMPLEMENTED = RD_INVALID_RESULT_VALUE - 11,
RD_OUT_OF_MEMORY = RD_INVALID_RESULT_VALUE - 12,
RD_MISALIGNED_SIZE = RD_INVALID_RESULT_VALUE - 13,
RD_MISALIGNED_ADDRESS = RD_INVALID_RESULT_VALUE - 14,
RD_BUSY = RD_INVALID_RESULT_VALUE - 15,
RD_NO_DATA = RD_INVALID_RESULT_VALUE - 16,
RD_INVALID_COMBINATION = RD_INVALID_RESULT_VALUE - 17,
RD_INVALID_ENUM_VALUE = RD_INVALID_RESULT_VALUE - 18,
RD_INVALID_SIZE = RD_INVALID_RESULT_VALUE - 19,
RD_ALREADY_DONE = RD_INVALID_RESULT_VALUE - 20,
RD_NOT_AUTHORIZED = RD_INVALID_RESULT_VALUE - 21,
RD_TOO_LARGE = RD_INVALID_RESULT_VALUE - 22,
RD_INVALID_SELECTION = RD_INVALID_RESULT_VALUE - 23,
};

93
.vscode/dummyinclude/3ds/romfs.h vendored Normal file
View file

@ -0,0 +1,93 @@
/**
* @file romfs.h
* @brief RomFS driver.
*/
#pragma once
#include <3ds/types.h>
#include <3ds/services/fs.h>
/// RomFS header.
typedef struct
{
u32 headerSize; ///< Size of the header.
u32 dirHashTableOff; ///< Offset of the directory hash table.
u32 dirHashTableSize; ///< Size of the directory hash table.
u32 dirTableOff; ///< Offset of the directory table.
u32 dirTableSize; ///< Size of the directory table.
u32 fileHashTableOff; ///< Offset of the file hash table.
u32 fileHashTableSize; ///< Size of the file hash table.
u32 fileTableOff; ///< Offset of the file table.
u32 fileTableSize; ///< Size of the file table.
u32 fileDataOff; ///< Offset of the file data.
} romfs_header;
/// RomFS directory.
typedef struct
{
u32 parent; ///< Offset of the parent directory.
u32 sibling; ///< Offset of the next sibling directory.
u32 childDir; ///< Offset of the first child directory.
u32 childFile; ///< Offset of the first file.
u32 nextHash; ///< Directory hash table pointer.
u32 nameLen; ///< Name length.
u16 name[]; ///< Name. (UTF-16)
} romfs_dir;
/// RomFS file.
typedef struct
{
u32 parent; ///< Offset of the parent directory.
u32 sibling; ///< Offset of the next sibling file.
u64 dataOff; ///< Offset of the file's data.
u64 dataSize; ///< Length of the file's data.
u32 nextHash; ///< File hash table pointer.
u32 nameLen; ///< Name length.
u16 name[]; ///< Name. (UTF-16)
} romfs_file;
/**
* @brief Mounts the Application's RomFS.
* @param name Device mount name.
* @remark This function is intended to be used to access one's own RomFS.
* If the application is running as 3DSX, it mounts the embedded RomFS section inside the 3DSX.
* If on the other hand it's an NCCH, it behaves identically to \ref romfsMountFromCurrentProcess.
*/
Result romfsMountSelf(const char *name);
/**
* @brief Mounts RomFS from an open file.
* @param fd FSFILE handle of the RomFS image.
* @param offset Offset of the RomFS within the file.
* @param name Device mount name.
*/
Result romfsMountFromFile(Handle fd, u32 offset, const char *name);
/**
* @brief Mounts RomFS using the current process host program RomFS.
* @param name Device mount name.
*/
Result romfsMountFromCurrentProcess(const char *name);
/**
* @brief Mounts RomFS from the specified title.
* @param tid Title ID
* @param mediatype Mediatype
* @param name Device mount name.
*/
Result romfsMountFromTitle(u64 tid, FS_MediaType mediatype, const char* name);
/// Unmounts the RomFS device.
Result romfsUnmount(const char *name);
/// Wrapper for \ref romfsMountSelf with the default "romfs" device name.
static inline Result romfsInit(void)
{
return romfsMountSelf("romfs");
}
/// Wrapper for \ref romfsUnmount with the default "romfs" device name.
static inline Result romfsExit(void)
{
return romfsUnmount("romfs");
}

157
.vscode/dummyinclude/3ds/services/ac.h vendored Normal file
View file

@ -0,0 +1,157 @@
/**
* @file ac.h
* @brief AC service.
*/
#pragma once
#include <3ds/types.h>
/// Wifi security modes.
typedef enum {
AC_OPEN = 0, ///< Open authentication.
AC_WEP_40BIT = 1, ///< WEP 40-bit authentication.
AC_WEP_104BIT = 2, ///< WEP 104-bit authentication.
AC_WEP_128BIT = 3, ///< WEP 128-bit authentication.
AC_WPA_TKIP = 4, ///< WPA TKIP authentication.
AC_WPA2_TKIP = 5, ///< WPA2 TKIP authentication.
AC_WPA_AES = 6, ///< WPA AES authentication.
AC_WPA2_AES = 7, ///< WPA2 AES authentication.
} acSecurityMode;
/// Wifi access point types (bitfield).
enum {
AC_AP_TYPE_NONE = 0, ///< No access point/none allowed.
AC_AP_TYPE_SLOT1 = BIT(1), ///< Slot 1 in System Settings.
AC_AP_TYPE_SLOT2 = BIT(2), ///< Slot 2 in System Settings.
AC_AP_TYPE_SLOT3 = BIT(3), ///< Slot 3 in System Settings.
AC_AP_TYPE_ALL = 0x7FFFFFFF, ///< All access point types allowed.
};
/// Struct to contain the data for connecting to a Wifi network from a stored slot.
typedef struct {
u8 reserved[0x200];
} acuConfig;
/// Initializes AC.
Result acInit(void);
/// Exits AC.
void acExit(void);
/// Gets the current AC session handle.
Handle *acGetSessionHandle(void);
/// Waits for the system to connect to the internet.
Result acWaitInternetConnection(void);
/**
* @brief Describes the access point the console is currently connected to with AC_AP_TYPE_* flags.
* @param out Pointer to output the combination of AC_AP_TYPE_* flags describing the AP to.
*/
Result ACU_GetWifiStatus(u32 *out);
/**
* @brief Gets the connected Wifi status.
* @param out Pointer to output the connected Wifi status to. (1 = not connected, 3 = connected)
*/
Result ACU_GetStatus(u32 *out);
/**
* @brief Gets the connected Wifi security mode.
* @param mode Pointer to output the connected Wifi security mode to. (0 = Open Authentication, 1 = WEP 40-bit, 2 = WEP 104-bit, 3 = WEP 128-bit, 4 = WPA TKIP, 5 = WPA2 TKIP, 6 = WPA AES, 7 = WPA2 AES)
*/
Result ACU_GetSecurityMode(acSecurityMode *mode);
/**
* @brief Gets the connected Wifi SSID.
* @param SSID Pointer to output the connected Wifi SSID to.
*/
Result ACU_GetSSID(char *SSID);
/**
* @brief Gets the connected Wifi SSID length.
* @param out Pointer to output the connected Wifi SSID length to.
*/
Result ACU_GetSSIDLength(u32 *out);
/**
* @brief Determines whether proxy is enabled for the connected network.
* @param enable Pointer to output the proxy status to.
*/
Result ACU_GetProxyEnable(bool *enable);
/**
* @brief Gets the connected network's proxy port.
* @param out Pointer to output the proxy port to.
*/
Result ACU_GetProxyPort(u32 *out);
/**
* @brief Gets the connected network's proxy username.
* @param username Pointer to output the proxy username to. (The size must be at least 0x20-bytes)
*/
Result ACU_GetProxyUserName(char *username);
/**
* @brief Gets the connected network's proxy password.
* @param password Pointer to output the proxy password to. (The size must be at least 0x20-bytes)
*/
Result ACU_GetProxyPassword(char *password);
/**
* @brief Gets the last error to occur during a connection.
* @param errorCode Pointer to output the error code to.
*/
Result ACU_GetLastErrorCode(u32* errorCode);
/**
* @brief Gets the last detailed error to occur during a connection.
* @param errorCode Pointer to output the error code to.
*/
Result ACU_GetLastDetailErrorCode(u32* errorCode);
/**
* @brief Prepares a buffer to hold the configuration data to start a connection.
* @param config Pointer to an acuConfig struct to contain the data.
*/
Result ACU_CreateDefaultConfig(acuConfig* config);
/**
* @brief Sets something that makes the connection reliable.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
* @param area Always 2 ?
*/
Result ACU_SetNetworkArea(acuConfig* config, u8 area);
/**
* @brief Sets the slot to use when connecting.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
* @param type Allowed AP types bitmask, a combination of AC_AP_TYPE_* flags.
*/
Result ACU_SetAllowApType(acuConfig* config, u8 type);
/**
* @brief Sets something that makes the connection reliable.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
*/
Result ACU_SetRequestEulaVersion(acuConfig* config);
/**
* @brief Starts the connection procedure.
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
* @param connectionHandle Handle created with svcCreateEvent to wait on until the connection succeeds or fails.
*/
Result ACU_ConnectAsync(const acuConfig* config, Handle connectionHandle);
/**
* @brief Selects the WiFi configuration slot for further ac:i operations.
* @param slot WiFi slot (0, 1 or 2).
*/
Result ACI_LoadNetworkSetting(u32 slot);
/**
* @brief Fetches the SSID of the previously selected WiFi configuration slot.
* @param[out] ssid Pointer to the output buffer of size 32B the SSID will be stored in.
*/
Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid);

538
.vscode/dummyinclude/3ds/services/am.h vendored Normal file
View file

@ -0,0 +1,538 @@
/**
* @file am.h
* @brief AM (Application Manager) service.
*/
#pragma once
#include <3ds/services/fs.h>
/// Contains basic information about a title.
typedef struct
{
u64 titleID; ///< The title's ID.
u64 size; ///< The title's installed size.
u16 version; ///< The title's version.
u8 unk[6]; ///< Unknown title data.
} AM_TitleEntry;
/// Pending title status mask values.
enum
{
AM_STATUS_MASK_INSTALLING = BIT(0), ///< Titles currently installing.
AM_STATUS_MASK_AWAITING_FINALIZATION = BIT(1) ///< Titles awaiting finalization.
};
/// Pending title status values.
typedef enum
{
AM_STATUS_ABORTED = 0x0002, ///< Install aborted.
AM_STATUS_SAVED = 0x0003, ///< Title saved, but not installed.
AM_STATUS_INSTALL_IN_PROGRESS = 0x0802, ///< Install in progress.
AM_STATUS_AWAITING_FINALIZATION = 0x0803 ///< Awaiting finalization.
} AM_InstallStatus;
// Contains basic information about a pending title.
typedef struct
{
u64 titleId; ///< Title ID
u16 version; ///< Version
u16 status; ///< @ref AM_InstallStatus
u32 titleType; ///< Title Type
u8 unk[0x8]; ///< Unknown
} AM_PendingTitleEntry;
/// Pending title deletion flags.
enum
{
AM_DELETE_PENDING_NON_SYSTEM = BIT(0), ///< Non-system titles.
AM_DELETE_PENDING_SYSTEM = BIT(1) ///< System titles.
};
/// Information about the TWL NAND partition.
typedef struct {
u64 capacity; ///< Total capacity.
u64 freeSpace; ///< Total free space.
u64 titlesCapacity; ///< Capacity for titles.
u64 titlesFreeSpace; ///< Free space for titles.
} AM_TWLPartitionInfo;
/// Contains information about a title's content.
typedef struct {
u16 index; ///< Index of the content in the title.
u16 type; ///< ?
u32 contentId; ///< ID of the content in the title.
u64 size; ///< Size of the content in the title.
u8 flags; ///< @ref AM_ContentInfoFlags
u8 padding[7]; ///< Padding
} AM_ContentInfo;
/// Title ContentInfo flags.
typedef enum
{
AM_CONTENT_DOWNLOADED = BIT(0), ///< ?
AM_CONTENT_OWNED = BIT(1) ///< ?
} AM_ContentInfoFlags;
/// Initializes AM. This doesn't initialize with "am:app", see amAppInit().
Result amInit(void);
/// Initializes AM with a service which has access to the amapp-commands. This should only be used when using the amapp commands, not non-amapp AM commands.
Result amAppInit(void);
/// Exits AM.
void amExit(void);
/// Gets the current AM session handle.
Handle *amGetSessionHandle(void);
/**
* @brief Gets the number of titles for a given media type.
* @param mediatype Media type to get titles from.
* @param[out] count Pointer to write the title count to.
*/
Result AM_GetTitleCount(FS_MediaType mediatype, u32 *count);
/**
* @brief Gets a list of title IDs present in a mediatype.
* @param[out] titlesRead Pointer to output the number of read titles to.
* @param mediatype Media type to get titles from.
* @param titleCount Number of title IDs to get.
* @param titleIds Buffer to output the retrieved title IDs to.
*/
Result AM_GetTitleList(u32* titlesRead, FS_MediaType mediatype, u32 titleCount, u64 *titleIds);
/**
* @brief Gets a list of details about installed titles.
* @param mediatype Media type to get titles from.
* @param titleCount Number of titles to list.
* @param titleIds List of title IDs to retrieve details for.
* @param titleInfo Buffer to write AM_TitleEntry's to.
*/
Result AM_GetTitleInfo(FS_MediaType mediatype, u32 titleCount, u64 *titleIds, AM_TitleEntry *titleInfo);
/**
* @brief Gets the number of tickets installed on the system.
* @param[out] count Pointer to output the ticket count to.
*/
Result AM_GetTicketCount(u32 *count);
/**
* @brief Gets a list of tickets installed on the system.
* @param[out] ticketsRead Pointer to output the number of read tickets to.
* @param ticketCount Number of tickets to read.
* @param skip Number of tickets to skip.
* @param ticketIds Buffer to output the retrieved ticket IDs to.
*/
Result AM_GetTicketList(u32 *ticketsRead, u32 ticketCount, u32 skip, u64 *ticketIds);
/**
* @brief Gets the number of pending titles on this system.
* @param[out] count Pointer to output the pending title count to.
* @param mediatype Media type of pending titles to count.
* @param statusMask Bit mask of status values to include.
*/
Result AM_GetPendingTitleCount(u32 *count, FS_MediaType mediatype, u32 statusMask);
/**
* @brief Gets a list of pending titles on this system.
* @param[out] titlesRead Pointer to output the number of read pending titles to.
* @param titleCount Number of pending titles to read.
* @param mediatype Media type of pending titles to list.
* @param statusMask Bit mask of status values to include.
* @param titleIds Buffer to output the retrieved pending title IDs to.
*/
Result AM_GetPendingTitleList(u32 *titlesRead, u32 titleCount, FS_MediaType mediatype, u32 statusMask, u64 *titleIds);
/**
* @brief Gets information about pending titles on this system.
* @param titleCount Number of pending titles to read.
* @param mediatype Media type of pending titles to get information on.
* @param titleIds IDs of the titles to get information about.
* @param titleInfo Buffer to output the retrieved pending title info to.
*/
Result AM_GetPendingTitleInfo(u32 titleCount, FS_MediaType mediatype, u64 *titleIds, AM_PendingTitleEntry *titleInfo);
/**
* @brief Gets a 32-bit device-specific ID.
* @param deviceID Pointer to write the device ID to.
*/
Result AM_GetDeviceId(u32 *deviceID);
/**
* @brief Exports DSiWare to the specified filepath.
* @param titleID TWL titleID.
* @param operation DSiWare operation type.
* @param workbuf Work buffer.
* @param workbuf_size Work buffer size, must be >=0x20000.
* @param filepath UTF-8 filepath(converted to UTF-16 internally).
*/
Result AM_ExportTwlBackup(u64 titleID, u8 operation, void* workbuf, u32 workbuf_size, const char *filepath);
/**
* @brief Imports DSiWare from the specified file.
* @param filehandle FSUSER file handle.
* @param operation DSiWare operation type.
* @param buffer Work buffer.
* @param size Buffer size, must be >=0x20000.
*/
Result AM_ImportTwlBackup(Handle filehandle, u8 operation, void* buffer, u32 size);
/**
* @brief Reads info from the specified DSiWare export file. This can only be used with DSiWare exported with certain operation value(s).
* @param filehandle FSUSER file handle.
* @param outinfo Output info buffer.
* @param outinfo_size Output info buffer size.
* @param workbuf Work buffer.
* @param workbuf_size Work buffer size.
* @param banner Output banner buffer.
* @param banner_size Output banner buffer size.
*/
Result AM_ReadTwlBackupInfo(Handle filehandle, void* outinfo, u32 outinfo_size, void* workbuf, u32 workbuf_size, void* banner, u32 banner_size);
/**
* @brief Retrieves information about the NAND TWL partition.
* @param[out] info Pointer to output the TWL partition info to.
*/
Result AM_GetTWLPartitionInfo(AM_TWLPartitionInfo *info);
/**
* @brief Initializes the CIA install process, returning a handle to write CIA data to.
* @param mediatype Media type to install the CIA to.
* @param[out] ciaHandle Pointer to write the CIA handle to.
*/
Result AM_StartCiaInstall(FS_MediaType mediatype, Handle *ciaHandle);
/**
* @brief Initializes the CIA install process for Download Play CIAs, returning a handle to write CIA data to.
* @param[out] ciaHandle Pointer to write the CIA handle to.
*/
Result AM_StartDlpChildCiaInstall(Handle *ciaHandle);
/**
* @brief Aborts the CIA install process.
* @param ciaHandle CIA handle to cancel.
*/
Result AM_CancelCIAInstall(Handle ciaHandle);
/**
* @brief Finalizes the CIA install process.
* @param ciaHandle CIA handle to finalize.
*/
Result AM_FinishCiaInstall(Handle ciaHandle);
/**
* @brief Finalizes the CIA install process without committing the title to title.db or tmp*.db.
* @param ciaHandle CIA handle to finalize.
*/
Result AM_FinishCiaInstallWithoutCommit(Handle ciaHandle);
/**
* @brief Commits installed CIAs.
* @param mediaType Location of the titles to finalize.
* @param titleCount Number of titles to finalize.
* @param temp Whether the titles being finalized are in the temporary database.
* @param titleIds Title IDs to finalize.
*/
Result AM_CommitImportPrograms(FS_MediaType mediaType, u32 titleCount, bool temp, const u64* titleIds);
/**
* @brief Deletes a title.
* @param mediatype Media type to delete from.
* @param titleID ID of the title to delete.
*/
Result AM_DeleteTitle(FS_MediaType mediatype, u64 titleID);
/**
* @brief Deletes a title, provided that it is not a system title.
* @param mediatype Media type to delete from.
* @param titleID ID of the title to delete.
*/
Result AM_DeleteAppTitle(FS_MediaType mediatype, u64 titleID);
/**
* @brief Deletes a ticket.
* @param titleID ID of the ticket to delete.
*/
Result AM_DeleteTicket(u64 ticketId);
/**
* @brief Deletes a pending title.
* @param mediatype Media type to delete from.
* @param titleId ID of the pending title to delete.
*/
Result AM_DeletePendingTitle(FS_MediaType mediatype, u64 titleId);
/**
* @brief Deletes pending titles.
* @param mediatype Media type to delete from.
* @param flags Flags used to select pending titles.
*/
Result AM_DeletePendingTitles(FS_MediaType mediatype, u32 flags);
/**
* @brief Deletes all pending titles.
* @param mediatype Media type to delete from.
*/
Result AM_DeleteAllPendingTitles(FS_MediaType mediatype);
/// Installs the current NATIVE_FIRM title to NAND (firm0:/ & firm1:/)
Result AM_InstallNativeFirm(void);
/**
* @brief Installs a NATIVE_FIRM title to NAND. Accepts 0004013800000002 or 0004013820000002 (N3DS).
* @param titleID Title ID of the NATIVE_FIRM to install.
*/
Result AM_InstallFirm(u64 titleID);
/**
* @brief Gets the product code of a title.
* @param mediatype Media type of the title.
* @param titleID ID of the title.
* @param[out] productCode Pointer to output the product code to. (length = 16)
*/
Result AM_GetTitleProductCode(FS_MediaType mediatype, u64 titleId, char *productCode);
/**
* @brief Gets the ext data ID of a title.
* @param[out] extDataId Pointer to output the ext data ID to.
* @param mediatype Media type of the title.
* @param titleID ID of the title.
*/
Result AM_GetTitleExtDataId(u64 *extDataId, FS_MediaType mediatype, u64 titleId);
/**
* @brief Gets an AM_TitleEntry instance for a CIA file.
* @param mediatype Media type that this CIA would be installed to.
* @param[out] titleEntry Pointer to write the AM_TitleEntry instance to.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaFileInfo(FS_MediaType mediatype, AM_TitleEntry *titleEntry, Handle fileHandle);
/**
* @brief Gets the SMDH icon data of a CIA file.
* @param icon Buffer to store the icon data in. Must be of size 0x36C0 bytes.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaIcon(void *icon, Handle fileHandle);
/**
* @brief Gets the title ID dependency list of a CIA file.
* @param dependencies Buffer to store dependency title IDs in. Must be of size 0x300 bytes.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaDependencies(u64 *dependencies, Handle fileHandle);
/**
* @brief Gets the meta section offset of a CIA file.
* @param[out] metaOffset Pointer to output the meta section offset to.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaMetaOffset(u64 *metaOffset, Handle fileHandle);
/**
* @brief Gets the core version of a CIA file.
* @param[out] coreVersion Pointer to output the core version to.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaCoreVersion(u32 *coreVersion, Handle fileHandle);
/**
* @brief Gets the free space, in bytes, required to install a CIA file.
* @param[out] requiredSpace Pointer to output the required free space to.
* @param mediaType Media type to check free space needed to install to.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaRequiredSpace(u64 *requiredSpace, FS_MediaType mediaType, Handle fileHandle);
/**
* @brief Gets the full meta section of a CIA file.
* @param meta Buffer to store the meta section in.
* @param size Size of the buffer. Must be greater than or equal to the actual section data's size.
* @param fileHandle Handle of the CIA file.
*/
Result AM_GetCiaMetaSection(void *meta, u32 size, Handle fileHandle);
/**
* @brief Initializes the external (SD) title database.
* @param overwrite Overwrites the database if it already exists.
*/
Result AM_InitializeExternalTitleDatabase(bool overwrite);
/**
* @brief Queries whether the external title database is available.
* @param[out] available Pointer to output the availability status to.
*/
Result AM_QueryAvailableExternalTitleDatabase(bool* available);
/**
* @brief Begins installing a ticket.
* @param[out] ticketHandle Pointer to output a handle to write ticket data to.
*/
Result AM_InstallTicketBegin(Handle *ticketHandle);
/**
* @brief Aborts installing a ticket.
* @param ticketHandle Handle of the installation to abort.
*/
Result AM_InstallTicketAbort(Handle ticketHandle);
/**
* @brief Finishes installing a ticket.
* @param ticketHandle Handle of the installation to finalize.
*/
Result AM_InstallTicketFinish(Handle ticketHandle);
/**
* @brief Begins installing a title.
* @param mediaType Destination to install to.
* @param titleId ID of the title to install.
* @param unk Unknown. (usually false)
*/
Result AM_InstallTitleBegin(FS_MediaType mediaType, u64 titleId, bool unk);
/// Stops installing a title, generally to be resumed later.
Result AM_InstallTitleStop(void);
/**
* @brief Resumes installing a title.
* @param mediaType Destination to install to.
* @param titleId ID of the title to install.
*/
Result AM_InstallTitleResume(FS_MediaType mediaType, u64 titleId);
/// Aborts installing a title.
Result AM_InstallTitleAbort(void);
/// Finishes installing a title.
Result AM_InstallTitleFinish(void);
/**
* @brief Commits installed titles.
* @param mediaType Location of the titles to finalize.
* @param titleCount Number of titles to finalize.
* @param temp Whether the titles being finalized are in the temporary database.
* @param titleIds Title IDs to finalize.
*/
Result AM_CommitImportTitles(FS_MediaType mediaType, u32 titleCount, bool temp, const u64* titleIds);
/**
* @brief Begins installing a TMD.
* @param[out] tmdHandle Pointer to output a handle to write TMD data to.
*/
Result AM_InstallTmdBegin(Handle *tmdHandle);
/**
* @brief Aborts installing a TMD.
* @param tmdHandle Handle of the installation to abort.
*/
Result AM_InstallTmdAbort(Handle tmdHandle);
/**
* @brief Finishes installing a TMD.
* @param tmdHandle Handle of the installation to finalize.
* @param unk Unknown. (usually true)
*/
Result AM_InstallTmdFinish(Handle tmdHandle, bool unk);
/**
* @brief Prepares to import title contents.
* @param contentCount Number of contents to be imported.
* @param contentIndices Indices of the contents to be imported.
*/
Result AM_CreateImportContentContexts(u32 contentCount, u16* contentIndices);
/**
* @brief Begins installing title content.
* @param[out] contentHandle Pointer to output a handle to write content data to.
* @param index Index of the content to install.
*/
Result AM_InstallContentBegin(Handle *contentHandle, u16 index);
/**
* @brief Stops installing title content, generally to be resumed later.
* @param contentHandle Handle of the installation to abort.
*/
Result AM_InstallContentStop(Handle contentHandle);
/**
* @brief Resumes installing title content.
* @param[out] contentHandle Pointer to output a handle to write content data to.
* @param[out] resumeOffset Pointer to write the offset to resume content installation at to.
* @param index Index of the content to install.
*/
Result AM_InstallContentResume(Handle *contentHandle, u64* resumeOffset, u16 index);
/**
* @brief Cancels installing title content.
* @param contentHandle Handle of the installation to finalize.
*/
Result AM_InstallContentCancel(Handle contentHandle);
/**
* @brief Finishes installing title content.
* @param contentHandle Handle of the installation to finalize.
*/
Result AM_InstallContentFinish(Handle contentHandle);
/**
* @brief Imports up to four certificates into the ticket certificate chain.
* @param cert1Size Size of the first certificate.
* @param cert1 Data of the first certificate.
* @param cert2Size Size of the second certificate.
* @param cert2 Data of the second certificate.
* @param cert3Size Size of the third certificate.
* @param cert3 Data of the third certificate.
* @param cert4Size Size of the fourth certificate.
* @param cert4 Data of the fourth certificate.
*/
Result AM_ImportCertificates(u32 cert1Size, void* cert1, u32 cert2Size, void* cert2, u32 cert3Size, void* cert3, u32 cert4Size, void* cert4);
/**
* @brief Imports a certificate into the ticket certificate chain.
* @param certSize Size of the certificate.
* @param cert Data of the certificate.
*/
Result AM_ImportCertificate(u32 certSize, void* cert);
/**
* @brief Commits installed titles, and updates FIRM if necessary.
* @param mediaType Location of the titles to finalize.
* @param titleCount Number of titles to finalize.
* @param temp Whether the titles being finalized are in the temporary database.
* @param titleIds Title IDs to finalize.
*/
Result AM_CommitImportTitlesAndUpdateFirmwareAuto(FS_MediaType mediaType, u32 titleCount, bool temp, u64* titleIds);
/// Resets play count of all installed demos by deleting their launch info.
Result AM_DeleteAllDemoLaunchInfos(void);
/// Deletes temporary titles.
Result AM_DeleteAllTemporaryTitles(void);
/**
* @brief Deletes all expired titles.
* @param mediatype Media type to delete from.
*/
Result AM_DeleteAllExpiredTitles(FS_MediaType mediatype);
/// Deletes all TWL titles.
Result AM_DeleteAllTwlTitles(void);
/**
* @brief Gets the number of content index installed under the specified DLC title.
* @param[out] count Pointer to output the number of content indices to.
* @param mediatype Media type of the title.
* @param titleID Title ID to retrieve the count for (high-id is 0x0004008C).
*/
Result AMAPP_GetDLCContentInfoCount(u32* count, FS_MediaType mediatype, u64 titleID);
/**
* @brief Gets content infos installed under the specified DLC title.
* @param[out] contentInfoRead Pointer to output the number of content infos read to.
* @param mediatype Media type of the title.
* @param titleID Title ID to retrieve the content infos for (high-id is 0x0004008C).
* @param contentInfoCount Number of content infos to retrieve.
* @param offset Offset from the first content index the count starts at.
* @param[out] contentInfos Pointer to output the content infos read to.
*/
Result AMAPP_ListDLCContentInfos(u32* contentInfoRead, FS_MediaType mediatype, u64 titleID, u32 contentInfoCount, u32 offset, AM_ContentInfo* contentInfos);

View file

@ -0,0 +1,35 @@
/**
* @file ampxi.h
* @brief AMPXI service. This is normally not accessible to userland apps. https://3dbrew.org/wiki/Application_Manager_Services_PXI
*/
#pragma once
/**
* @brief Initializes AMPXI.
* @param servhandle Optional service session handle to use for AMPXI, if zero srvGetServiceHandle() will be used.
*/
Result ampxiInit(Handle servhandle);
/// Exits AMPXI.
void ampxiExit(void);
/**
* @brief Writes a TWL save-file to NAND. https://www.3dbrew.org/wiki/AMPXI:WriteTWLSavedata
* @param titleid ID of the TWL title.
* @param buffer Savedata buffer ptr.
* @param size Size of the savedata buffer.
* @param image_filepos Filepos to use for writing the data to the NAND savedata file.
* @param section_type https://www.3dbrew.org/wiki/AMPXI:WriteTWLSavedata
* @param operation https://3dbrew.org/wiki/AM:ImportDSiWare
*/
Result AMPXI_WriteTWLSavedata(u64 titleid, u8 *buffer, u32 size, u32 image_filepos, u8 section_type, u8 operation);
/**
* @brief Finalizes title installation. https://3dbrew.org/wiki/AMPXI:InstallTitlesFinish
* @param mediaType Mediatype of the titles to finalize.
* @param db Which title database to use.
* @param size Size of the savedata buffer.
* @param titlecount Total titles.
* @param tidlist List of titleIDs.
*/
Result AMPXI_InstallTitlesFinish(FS_MediaType mediaType, u8 db, u32 titlecount, u64 *tidlist);

581
.vscode/dummyinclude/3ds/services/apt.h vendored Normal file
View file

@ -0,0 +1,581 @@
/**
* @file apt.h
* @brief APT (Applet) service.
*/
#pragma once
/**
* @brief NS Application IDs.
*
* Retrieved from http://3dbrew.org/wiki/NS_and_APT_Services#AppIDs
*/
typedef enum {
APPID_NONE = 0,
APPID_HOMEMENU = 0x101, ///< Home Menu
APPID_CAMERA = 0x110, ///< Camera applet
APPID_FRIENDS_LIST = 0x112, ///< Friends List applet
APPID_GAME_NOTES = 0x113, ///< Game Notes applet
APPID_WEB = 0x114, ///< Internet Browser
APPID_INSTRUCTION_MANUAL = 0x115, ///< Instruction Manual applet
APPID_NOTIFICATIONS = 0x116, ///< Notifications applet
APPID_MIIVERSE = 0x117, ///< Miiverse applet (olv)
APPID_MIIVERSE_POSTING = 0x118, ///< Miiverse posting applet (solv3)
APPID_AMIIBO_SETTINGS = 0x119, ///< Amiibo settings applet (cabinet)
APPID_APPLICATION = 0x300, ///< Application
APPID_ESHOP = 0x301, ///< eShop (tiger)
APPID_SOFTWARE_KEYBOARD = 0x401, ///< Software Keyboard
APPID_APPLETED = 0x402, ///< appletEd
APPID_PNOTE_AP = 0x404, ///< PNOTE_AP
APPID_SNOTE_AP = 0x405, ///< SNOTE_AP
APPID_ERROR = 0x406, ///< error
APPID_MINT = 0x407, ///< mint
APPID_EXTRAPAD = 0x408, ///< extrapad
APPID_MEMOLIB = 0x409, ///< memolib
} NS_APPID;
/// APT applet position.
typedef enum {
APTPOS_NONE = -1, ///< No position specified.
APTPOS_APP = 0, ///< Application.
APTPOS_APPLIB = 1, ///< Application library (?).
APTPOS_SYS = 2, ///< System applet.
APTPOS_SYSLIB = 3, ///< System library (?).
APTPOS_RESIDENT = 4, ///< Resident applet.
} APT_AppletPos;
typedef u8 APT_AppletAttr;
struct PtmWakeEvents;
/// Create an APT_AppletAttr bitfield from its components.
static inline APT_AppletAttr aptMakeAppletAttr(APT_AppletPos pos, bool manualGpuRights, bool manualDspRights)
{
return (pos&7) | (manualGpuRights ? BIT(3) : 0) | (manualDspRights ? BIT(4) : 0);
}
/// APT query reply.
typedef enum {
APTREPLY_REJECT = 0,
APTREPLY_ACCEPT = 1,
APTREPLY_LATER = 2,
} APT_QueryReply;
/// APT signals.
typedef enum {
APTSIGNAL_NONE = 0, ///< No signal received.
APTSIGNAL_HOMEBUTTON = 1, ///< HOME button pressed.
APTSIGNAL_HOMEBUTTON2 = 2, ///< HOME button pressed (again?).
APTSIGNAL_SLEEP_QUERY = 3, ///< Prepare to enter sleep mode.
APTSIGNAL_SLEEP_CANCEL = 4, ///< Triggered when ptm:s GetShellStatus() returns 5.
APTSIGNAL_SLEEP_ENTER = 5, ///< Enter sleep mode.
APTSIGNAL_SLEEP_WAKEUP = 6, ///< Wake from sleep mode.
APTSIGNAL_SHUTDOWN = 7, ///< Shutdown.
APTSIGNAL_POWERBUTTON = 8, ///< POWER button pressed.
APTSIGNAL_POWERBUTTON2 = 9, ///< POWER button cleared (?).
APTSIGNAL_TRY_SLEEP = 10, ///< System sleeping (?).
APTSIGNAL_ORDERTOCLOSE = 11, ///< Order to close (such as when an error happens?).
} APT_Signal;
/// APT commands.
typedef enum {
APTCMD_NONE = 0, ///< No command received.
APTCMD_WAKEUP = 1, ///< Applet should wake up.
APTCMD_REQUEST = 2, ///< Source applet sent us a parameter.
APTCMD_RESPONSE = 3, ///< Target applet replied to our parameter.
APTCMD_EXIT = 4, ///< Exit (??)
APTCMD_MESSAGE = 5, ///< Message (??)
APTCMD_HOMEBUTTON_ONCE = 6, ///< HOME button pressed once.
APTCMD_HOMEBUTTON_TWICE = 7, ///< HOME button pressed twice (double-pressed).
APTCMD_DSP_SLEEP = 8, ///< DSP should sleep (manual DSP rights related?).
APTCMD_DSP_WAKEUP = 9, ///< DSP should wake up (manual DSP rights related?).
APTCMD_WAKEUP_EXIT = 10, ///< Applet wakes up due to a different applet exiting.
APTCMD_WAKEUP_PAUSE = 11, ///< Applet wakes up after being paused through HOME menu.
APTCMD_WAKEUP_CANCEL = 12, ///< Applet wakes up due to being cancelled.
APTCMD_WAKEUP_CANCELALL = 13, ///< Applet wakes up due to all applets being cancelled.
APTCMD_WAKEUP_POWERBUTTON = 14, ///< Applet wakes up due to POWER button being pressed (?).
APTCMD_WAKEUP_JUMPTOHOME = 15, ///< Applet wakes up and is instructed to jump to HOME menu (?).
APTCMD_SYSAPPLET_REQUEST = 16, ///< Request for sysapplet (?).
APTCMD_WAKEUP_LAUNCHAPP = 17, ///< Applet wakes up and is instructed to launch another applet (?).
} APT_Command;
/// APT capture buffer information.
typedef struct
{
u32 size;
u32 is3D;
struct
{
u32 leftOffset;
u32 rightOffset;
u32 format;
} top, bottom;
} aptCaptureBufInfo;
/// APT hook types.
typedef enum {
APTHOOK_ONSUSPEND = 0, ///< App suspended.
APTHOOK_ONRESTORE, ///< App restored.
APTHOOK_ONSLEEP, ///< App sleeping.
APTHOOK_ONWAKEUP, ///< App waking up.
APTHOOK_ONEXIT, ///< App exiting.
APTHOOK_COUNT, ///< Number of APT hook types.
} APT_HookType;
/// APT hook function.
typedef void (*aptHookFn)(APT_HookType hook, void* param);
/// APT hook cookie.
typedef struct tag_aptHookCookie
{
struct tag_aptHookCookie* next; ///< Next cookie.
aptHookFn callback; ///< Hook callback.
void* param; ///< Callback parameter.
} aptHookCookie;
/// APT message callback.
typedef void (*aptMessageCb)(void* user, NS_APPID sender, void* msg, size_t msgsize);
/// Initializes APT.
Result aptInit(void);
/// Exits APT.
void aptExit(void);
/**
* @brief Sends an APT command through IPC, taking care of locking, opening and closing an APT session.
* @param aptcmdbuf Pointer to command buffer (should have capacity for at least 16 words).
*/
Result aptSendCommand(u32* aptcmdbuf);
/// Returns true if the application is currently in the foreground.
bool aptIsActive(void);
/// Returns true if the system has told the application to close.
bool aptShouldClose(void);
/// Returns true if the system can enter sleep mode while the application is active.
bool aptIsSleepAllowed(void);
/// Configures whether the system can enter sleep mode while the application is active.
void aptSetSleepAllowed(bool allowed);
/// Handles incoming sleep mode requests.
void aptHandleSleep(void);
/// Returns true if the user can press the HOME button to jump back to the HOME menu while the application is active.
bool aptIsHomeAllowed(void);
/// Configures whether the user can press the HOME button to jump back to the HOME menu while the application is active.
void aptSetHomeAllowed(bool allowed);
/// Returns true if the system requires the application to jump back to the HOME menu.
bool aptShouldJumpToHome(void);
/// Returns true if there is an incoming HOME button press rejected by the policy set by \ref aptSetHomeAllowed (use this to show a "no HOME allowed" icon).
bool aptCheckHomePressRejected(void);
/// \deprecated Alias for \ref aptCheckHomePressRejected.
static inline CTR_DEPRECATED bool aptIsHomePressed(void)
{
return aptCheckHomePressRejected();
}
/// Jumps back to the HOME menu.
void aptJumpToHomeMenu(void);
/// Handles incoming jump-to-HOME requests.
static inline void aptHandleJumpToHome(void)
{
if (aptShouldJumpToHome())
aptJumpToHomeMenu();
}
/**
* @brief Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every frame.
* @return true if the application should keep running, false otherwise (see \ref aptShouldClose).
*/
bool aptMainLoop(void);
/**
* @brief Sets up an APT status hook.
* @param cookie Hook cookie to use.
* @param callback Function to call when APT's status changes.
* @param param User-defined parameter to pass to the callback.
*/
void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param);
/**
* @brief Removes an APT status hook.
* @param cookie Hook cookie to remove.
*/
void aptUnhook(aptHookCookie* cookie);
/**
* @brief Sets the function to be called when an APT message from another applet is received.
* @param callback Callback function.
* @param user User-defined data to be passed to the callback.
*/
void aptSetMessageCallback(aptMessageCb callback, void* user);
/**
* @brief Launches a library applet.
* @param appId ID of the applet to launch.
* @param buf Input/output buffer that contains launch parameters on entry and result data on exit.
* @param bufsize Size of the buffer.
* @param handle Handle to pass to the library applet.
*/
void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);
/// Clears the chainloader state.
void aptClearChainloader(void);
/**
* @brief Configures the chainloader to launch a specific application.
* @param programID ID of the program to chainload to.
* @param mediatype Media type of the program to chainload to.
*/
void aptSetChainloader(u64 programID, u8 mediatype);
/// Configures the chainloader to launch the previous application.
void aptSetChainloaderToCaller(void);
/// Configures the chainloader to relaunch the current application (i.e. soft-reset)
void aptSetChainloaderToSelf(void);
/**
* @brief Sets the "deliver arg" and HMAC for the chainloader, which will
* be passed to the target 3DS/DS(i) application. The meaning of each
* parameter varies on a per-application basis.
* @param deliverArg Deliver arg to pass to the target application.
* @param deliverArgSize Size of the deliver arg, maximum 0x300 bytes.
* @param hmac HMAC buffer, 32 bytes. Use NULL to pass an all-zero dummy HMAC.
*/
void aptSetChainloaderArgs(const void *deliverArg, size_t deliverArgSize, const void *hmac);
/**
* @brief Gets an APT lock handle.
* @param flags Flags to use.
* @param lockHandle Pointer to output the lock handle to.
*/
Result APT_GetLockHandle(u16 flags, Handle* lockHandle);
/**
* @brief Initializes an application's registration with APT.
* @param appId ID of the application.
* @param attr Attributes of the application.
* @param signalEvent Pointer to output the signal event handle to.
* @param resumeEvent Pointer to output the resume event handle to.
*/
Result APT_Initialize(NS_APPID appId, APT_AppletAttr attr, Handle* signalEvent, Handle* resumeEvent);
/**
* @brief Terminates an application's registration with APT.
* @param appID ID of the application.
*/
Result APT_Finalize(NS_APPID appId);
/// Asynchronously resets the hardware.
Result APT_HardwareResetAsync(void);
/**
* @brief Enables APT.
* @param attr Attributes of the application.
*/
Result APT_Enable(APT_AppletAttr attr);
/**
* @brief Gets applet management info.
* @param inpos Requested applet position.
* @param outpos Pointer to output the position of the current applet to.
* @param req_appid Pointer to output the AppID of the applet at the requested position to.
* @param menu_appid Pointer to output the HOME menu AppID to.
* @param active_appid Pointer to output the AppID of the currently active applet to.
*/
Result APT_GetAppletManInfo(APT_AppletPos inpos, APT_AppletPos* outpos, NS_APPID* req_appid, NS_APPID* menu_appid, NS_APPID* active_appid);
/**
* @brief Gets the menu's app ID.
* @return The menu's app ID.
*/
static inline NS_APPID aptGetMenuAppID(void)
{
NS_APPID menu_appid = APPID_NONE;
APT_GetAppletManInfo(APTPOS_NONE, NULL, NULL, &menu_appid, NULL);
return menu_appid;
}
/**
* @brief Gets an applet's information.
* @param appID AppID of the applet.
* @param pProgramID Pointer to output the program ID to.
* @param pMediaType Pointer to output the media type to.
* @param pRegistered Pointer to output the registration status to.
* @param pLoadState Pointer to output the load state to.
* @param pAttributes Pointer to output the applet atrributes to.
*/
Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, bool* pRegistered, bool* pLoadState, APT_AppletAttr* pAttributes);
/**
* @brief Gets an applet's program information.
* @param id ID of the applet.
* @param flags Flags to use when retreiving the information.
* @param titleversion Pointer to output the applet's title version to.
*
* Flags:
* - 0x01: Use AM_ListTitles with NAND media type.
* - 0x02: Use AM_ListTitles with SDMC media type.
* - 0x04: Use AM_ListTitles with GAMECARD media type.
* - 0x10: Input ID is an app ID. Must be set if 0x20 is not.
* - 0x20: Input ID is a program ID. Must be set if 0x10 is not.
* - 0x100: Sets program ID high to 0x00040000, else it is 0x00040010. Only used when 0x20 is set.
*/
Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion);
/**
* @brief Gets the current application's program ID.
* @param pProgramID Pointer to output the program ID to.
*/
Result APT_GetProgramID(u64* pProgramID);
/// Prepares to jump to the home menu.
Result APT_PrepareToJumpToHomeMenu(void);
/**
* @brief Jumps to the home menu.
* @param param Parameters to jump with.
* @param Size of the parameter buffer.
* @param handle Handle to pass.
*/
Result APT_JumpToHomeMenu(const void* param, size_t paramSize, Handle handle);
/**
* @brief Prepares to jump to an application.
* @param exiting Specifies whether the applet is exiting.
*/
Result APT_PrepareToJumpToApplication(bool exiting);
/**
* @brief Jumps to an application.
* @param param Parameters to jump with.
* @param Size of the parameter buffer.
* @param handle Handle to pass.
*/
Result APT_JumpToApplication(const void* param, size_t paramSize, Handle handle);
/**
* @brief Gets whether an application is registered.
* @param appID ID of the application.
* @param out Pointer to output the registration state to.
*/
Result APT_IsRegistered(NS_APPID appID, bool* out);
/**
* @brief Inquires as to whether a signal has been received.
* @param appID ID of the application.
* @param signalType Pointer to output the signal type to.
*/
Result APT_InquireNotification(u32 appID, APT_Signal* signalType);
/**
* @brief Requests to enter sleep mode, and later sets wake events if allowed to.
* @param wakeEvents The wake events. Limited to "shell" (bit 1) for the PDN wake events part
* and "shell opened", "shell closed" and "HOME button pressed" for the MCU interrupts part.
*/
Result APT_SleepSystem(const struct PtmWakeEvents *wakeEvents);
/**
* @brief Notifies an application to wait.
* @param appID ID of the application.
*/
Result APT_NotifyToWait(NS_APPID appID);
/**
* @brief Calls an applet utility function.
* @param id Utility function to call.
* @param out Pointer to write output data to.
* @param outSize Size of the output buffer.
* @param in Pointer to the input data.
* @param inSize Size of the input buffer.
*/
Result APT_AppletUtility(int id, void* out, size_t outSize, const void* in, size_t inSize);
/// Sleeps if shell is closed (?).
Result APT_SleepIfShellClosed(void);
/**
* @brief Locks a transition (?).
* @param transition Transition ID.
* @param flag Flag (?)
*/
Result APT_LockTransition(u32 transition, bool flag);
/**
* @brief Tries to lock a transition (?).
* @param transition Transition ID.
* @param succeeded Pointer to output whether the lock was successfully applied.
*/
Result APT_TryLockTransition(u32 transition, bool* succeeded);
/**
* @brief Unlocks a transition (?).
* @param transition Transition ID.
*/
Result APT_UnlockTransition(u32 transition);
/**
* @brief Glances at a receieved parameter without removing it from the queue.
* @param appID AppID of the application.
* @param buffer Buffer to receive to.
* @param bufferSize Size of the buffer.
* @param sender Pointer to output the sender's AppID to.
* @param command Pointer to output the command ID to.
* @param actualSize Pointer to output the actual received data size to.
* @param parameter Pointer to output the parameter handle to.
*/
Result APT_GlanceParameter(NS_APPID appID, void* buffer, size_t bufferSize, NS_APPID* sender, APT_Command* command, size_t* actualSize, Handle* parameter);
/**
* @brief Receives a parameter.
* @param appID AppID of the application.
* @param buffer Buffer to receive to.
* @param bufferSize Size of the buffer.
* @param sender Pointer to output the sender's AppID to.
* @param command Pointer to output the command ID to.
* @param actualSize Pointer to output the actual received data size to.
* @param parameter Pointer to output the parameter handle to.
*/
Result APT_ReceiveParameter(NS_APPID appID, void* buffer, size_t bufferSize, NS_APPID* sender, APT_Command* command, size_t* actualSize, Handle* parameter);
/**
* @brief Sends a parameter.
* @param source AppID of the source application.
* @param dest AppID of the destination application.
* @param command Command to send.
* @param buffer Buffer to send.
* @param bufferSize Size of the buffer.
* @param parameter Parameter handle to pass.
*/
Result APT_SendParameter(NS_APPID source, NS_APPID dest, APT_Command command, const void* buffer, u32 bufferSize, Handle parameter);
/**
* @brief Cancels a parameter which matches the specified source and dest AppIDs.
* @param source AppID of the source application (use APPID_NONE to disable the check).
* @param dest AppID of the destination application (use APPID_NONE to disable the check).
* @param success Pointer to output true if a parameter was cancelled, or false otherwise.
*/
Result APT_CancelParameter(NS_APPID source, NS_APPID dest, bool* success);
/**
* @brief Sends capture buffer information.
* @param captureBuf Capture buffer information to send.
*/
Result APT_SendCaptureBufferInfo(const aptCaptureBufInfo* captureBuf);
/**
* @brief Replies to a sleep query.
* @param appID ID of the application.
* @param reply Query reply value.
*/
Result APT_ReplySleepQuery(NS_APPID appID, APT_QueryReply reply);
/**
* @brief Replies that a sleep notification has been completed.
* @param appID ID of the application.
*/
Result APT_ReplySleepNotificationComplete(NS_APPID appID);
/**
* @brief Prepares to close the application.
* @param cancelPreload Whether applet preloads should be cancelled.
*/
Result APT_PrepareToCloseApplication(bool cancelPreload);
/**
* @brief Closes the application.
* @param param Parameters to close with.
* @param paramSize Size of param.
* @param handle Handle to pass.
*/
Result APT_CloseApplication(const void* param, size_t paramSize, Handle handle);
/**
* @brief Sets the application's CPU time limit.
* @param percent CPU time limit percentage to set.
*/
Result APT_SetAppCpuTimeLimit(u32 percent);
/**
* @brief Gets the application's CPU time limit.
* @param percent Pointer to output the CPU time limit percentage to.
*/
Result APT_GetAppCpuTimeLimit(u32 *percent);
/**
* @brief Checks whether the system is a New 3DS.
* @param out Pointer to write the New 3DS flag to.
*/
Result APT_CheckNew3DS(bool* out);
/**
* @brief Prepares for an applicaton jump.
* @param flags Flags to use.
* @param programID ID of the program to jump to.
* @param mediatype Media type of the program to jump to.
*/
Result APT_PrepareToDoApplicationJump(u8 flags, u64 programID, u8 mediatype);
/**
* @brief Performs an application jump.
* @param param Parameter buffer.
* @param paramSize Size of parameter buffer.
* @param hmac HMAC buffer (should be 0x20 bytes long).
*/
Result APT_DoApplicationJump(const void* param, size_t paramSize, const void* hmac);
/**
* @brief Prepares to start a library applet.
* @param appID AppID of the applet to start.
*/
Result APT_PrepareToStartLibraryApplet(NS_APPID appID);
/**
* @brief Starts a library applet.
* @param appID AppID of the applet to launch.
* @param param Buffer containing applet parameters.
* @param paramsize Size of the buffer.
* @param handle Handle to pass to the applet.
*/
Result APT_StartLibraryApplet(NS_APPID appID, const void* param, size_t paramSize, Handle handle);
/**
* @brief Prepares to start a system applet.
* @param appID AppID of the applet to start.
*/
Result APT_PrepareToStartSystemApplet(NS_APPID appID);
/**
* @brief Starts a system applet.
* @param appID AppID of the applet to launch.
* @param param Buffer containing applet parameters.
* @param paramSize Size of the parameter buffer.
* @param handle Handle to pass to the applet.
*/
Result APT_StartSystemApplet(NS_APPID appID, const void* param, size_t paramSize, Handle handle);
/**
* @brief Retrieves the shared system font.
* @brief fontHandle Pointer to write the handle of the system font memory block to.
* @brief mapAddr Pointer to write the mapping address of the system font memory block to.
*/
Result APT_GetSharedFont(Handle* fontHandle, u32* mapAddr);
/**
* @brief Receives the deliver (launch) argument
* @param param Parameter buffer.
* @param paramSize Size of parameter buffer.
* @param hmac HMAC buffer (should be 0x20 bytes long).
* @param sender Pointer to output the sender's AppID to.
* @param received Pointer to output whether an argument was received to.
*/
Result APT_ReceiveDeliverArg(void* param, size_t paramSize, void* hmac, u64* sender, bool* received);

180
.vscode/dummyinclude/3ds/services/boss.h vendored Normal file
View file

@ -0,0 +1,180 @@
/**
* @file boss.h
* @brief BOSS service, see also: https://www.3dbrew.org/wiki/BOSS_Services
*/
#pragma once
/// BOSS context.
typedef struct
{
u32 property[0x7];
char url[0x200];
u32 property_x8;
u8 property_x9;
u8 property_xa[0x100];
u8 property_xb[0x200];
char property_xd[0x360];//Additonal optional HTTP request headers.
u32 property_xe;
u32 property_xf[0xc>>2];
u8 property_x10;
u8 property_x11;
u8 property_x12;
u32 property_x13;
u32 property_x14;
u8 property_x15[0x40];
u32 property_x16;
u32 property_x3b;
u8 property_x3e[0x200];
} bossContext;
/// BOSS task status.
typedef enum {
BOSSTASKSTATUS_STARTED = 0x2,
BOSSTASKSTATUS_ERROR = 0x7,
} bossTaskStatus;
/// Type values for bossGetNsDataHeaderInfo().
typedef enum {
bossNsDataHeaderInfoType_ContentSize = 0x3 /// Size of the content.
} bossNsDataHeaderInfoTypes;
/// Size of the output data for bossGetNsDataHeaderInfo().
typedef enum {
bossNsDataHeaderInfoTypeSize_ContentSize = 0x4 ///Type2
} bossNsDataHeaderInfoTypeSizes;
/**
* @brief Initializes BOSS.
* @param programID programID to use, 0 for the current process. Only used when BOSSP is available without *hax payload.
* @param force_user When true, just use bossU instead of trying to initialize with bossP first.
*/
Result bossInit(u64 programID, bool force_user);
/**
* @brief Run the InitializeSession service cmd. This is mainly for changing the programID associated with the current BOSS session.
* @param programID programID to use, 0 for the current process.
*/
Result bossReinit(u64 programID);
/// Exits BOSS.
void bossExit(void);
/// Returns the BOSS session handle.
Handle bossGetSessionHandle(void);
/**
* @brief Set the content data storage location.
* @param extdataID u64 extdataID, must have the high word set to the shared-extdata value when it's for NAND.
* @param boss_size Probably the max size in the extdata which BOSS can use.
* @param mediaType Roughly the same as FS mediatype.
*/
Result bossSetStorageInfo(u64 extdataID, u32 boss_size, u8 mediaType);
/**
* @brief Unregister the content data storage location, which includes unregistering the BOSS-session programID with BOSS.
*/
Result bossUnregisterStorage(void);
/**
* @brief Register a task.
* @param taskID BOSS taskID.
* @param unk0 Unknown, usually zero.
* @param unk1 Unknown, usually zero.
*/
Result bossRegisterTask(const char *taskID, u8 unk0, u8 unk1);
/**
* @brief Send a property.
* @param PropertyID PropertyID
* @param buf Input buffer data.
* @param size Buffer size.
*/
Result bossSendProperty(u16 PropertyID, const void* buf, u32 size);
/**
* @brief Deletes the content file for the specified NsDataId.
* @param NsDataId NsDataId
*/
Result bossDeleteNsData(u32 NsDataId);
/**
* @brief Gets header info for the specified NsDataId.
* @param NsDataId NsDataId
* @param type Type of data to load.
* @param buffer Output buffer.
* @param size Output buffer size.
*/
Result bossGetNsDataHeaderInfo(u32 NsDataId, u8 type, void* buffer, u32 size);
/**
* @brief Reads data from the content for the specified NsDataId.
* @param NsDataId NsDataId
* @param offset Offset in the content.
* @param buffer Output buffer.
* @param size Output buffer size.
* @param transfer_total Optional output actual read size, can be NULL.
* @param unk_out Optional unknown output, can be NULL.
*/
Result bossReadNsData(u32 NsDataId, u64 offset, void* buffer, u32 size, u32 *transfer_total, u32 *unk_out);
/**
* @brief Starts a task soon after running this command.
* @param taskID BOSS taskID.
*/
Result bossStartTaskImmediate(const char *taskID);
/**
* @brief Similar to bossStartTaskImmediate?
* @param taskID BOSS taskID.
*/
Result bossStartBgImmediate(const char *taskID);
/**
* @brief Deletes a task by using CancelTask and UnregisterTask internally.
* @param taskID BOSS taskID.
* @param unk Unknown, usually zero?
*/
Result bossDeleteTask(const char *taskID, u32 unk);
/**
* @brief Returns task state.
* @param taskID BOSS taskID.
* @param inval Unknown, normally 0?
* @param status Output status, see bossTaskStatus.
* @param out1 Output field.
* @param out2 Output field.
*/
Result bossGetTaskState(const char *taskID, s8 inval, u8 *status, u32 *out1, u8 *out2);
/**
* @brief This loads the current state of PropertyID 0x0 for the specified task.
* @param taskID BOSS taskID.
*/
Result bossGetTaskProperty0(const char *taskID, u8 *out);
/**
* @brief Setup a BOSS context with the default config.
* @param bossContext BOSS context.
* @param seconds_interval Interval in seconds for running the task automatically.
* @param url Task URL.
*/
void bossSetupContextDefault(bossContext *ctx, u32 seconds_interval, const char *url);
/**
* @brief Sends the config stored in the context. Used before registering a task.
* @param bossContext BOSS context.
*/
Result bossSendContextConfig(bossContext *ctx);

703
.vscode/dummyinclude/3ds/services/cam.h vendored Normal file
View file

@ -0,0 +1,703 @@
/**
* @file cam.h
* @brief CAM service for using the 3DS's front and back cameras.
*/
#pragma once
#include <3ds/services/y2r.h>
#include <3ds/types.h>
/// Camera connection target ports.
enum {
PORT_NONE = 0x0, ///< No port.
PORT_CAM1 = BIT(0), ///< CAM1 port.
PORT_CAM2 = BIT(1), ///< CAM2 port.
// Port combinations.
PORT_BOTH = PORT_CAM1 | PORT_CAM2, ///< Both ports.
};
/// Camera combinations.
enum {
SELECT_NONE = 0x0, ///< No camera.
SELECT_OUT1 = BIT(0), ///< Outer camera 1.
SELECT_IN1 = BIT(1), ///< Inner camera 1.
SELECT_OUT2 = BIT(2), ///< Outer camera 2.
// Camera combinations.
SELECT_IN1_OUT1 = SELECT_OUT1 | SELECT_IN1, ///< Outer camera 1 and inner camera 1.
SELECT_OUT1_OUT2 = SELECT_OUT1 | SELECT_OUT2, ///< Both outer cameras.
SELECT_IN1_OUT2 = SELECT_IN1 | SELECT_OUT2, ///< Inner camera 1 and outer camera 2.
SELECT_ALL = SELECT_OUT1 | SELECT_IN1 | SELECT_OUT2, ///< All cameras.
};
/// Camera contexts.
typedef enum {
CONTEXT_NONE = 0x0, ///< No context.
CONTEXT_A = BIT(0), ///< Context A.
CONTEXT_B = BIT(1), ///< Context B.
// Context combinations.
CONTEXT_BOTH = CONTEXT_A | CONTEXT_B, ///< Both contexts.
} CAMU_Context;
/// Ways to flip the camera image.
typedef enum {
FLIP_NONE = 0x0, ///< No flip.
FLIP_HORIZONTAL = 0x1, ///< Horizontal flip.
FLIP_VERTICAL = 0x2, ///< Vertical flip.
FLIP_REVERSE = 0x3, ///< Reverse flip.
} CAMU_Flip;
/// Camera image resolutions.
typedef enum {
SIZE_VGA = 0x0, ///< VGA size. (640x480)
SIZE_QVGA = 0x1, ///< QVGA size. (320x240)
SIZE_QQVGA = 0x2, ///< QQVGA size. (160x120)
SIZE_CIF = 0x3, ///< CIF size. (352x288)
SIZE_QCIF = 0x4, ///< QCIF size. (176x144)
SIZE_DS_LCD = 0x5, ///< DS LCD size. (256x192)
SIZE_DS_LCDx4 = 0x6, ///< DS LCD x4 size. (512x384)
SIZE_CTR_TOP_LCD = 0x7, ///< CTR Top LCD size. (400x240)
// Alias for bottom screen to match top screen naming.
SIZE_CTR_BOTTOM_LCD = SIZE_QVGA, ///< CTR Bottom LCD size. (320x240)
} CAMU_Size;
/// Camera capture frame rates.
typedef enum {
FRAME_RATE_15 = 0x0, ///< 15 FPS.
FRAME_RATE_15_TO_5 = 0x1, ///< 15-5 FPS.
FRAME_RATE_15_TO_2 = 0x2, ///< 15-2 FPS.
FRAME_RATE_10 = 0x3, ///< 10 FPS.
FRAME_RATE_8_5 = 0x4, ///< 8.5 FPS.
FRAME_RATE_5 = 0x5, ///< 5 FPS.
FRAME_RATE_20 = 0x6, ///< 20 FPS.
FRAME_RATE_20_TO_5 = 0x7, ///< 20-5 FPS.
FRAME_RATE_30 = 0x8, ///< 30 FPS.
FRAME_RATE_30_TO_5 = 0x9, ///< 30-5 FPS.
FRAME_RATE_15_TO_10 = 0xA, ///< 15-10 FPS.
FRAME_RATE_20_TO_10 = 0xB, ///< 20-10 FPS.
FRAME_RATE_30_TO_10 = 0xC, ///< 30-10 FPS.
} CAMU_FrameRate;
/// Camera white balance modes.
typedef enum {
WHITE_BALANCE_AUTO = 0x0, ///< Auto white balance.
WHITE_BALANCE_3200K = 0x1, ///< 3200K white balance.
WHITE_BALANCE_4150K = 0x2, ///< 4150K white balance.
WHITE_BALANCE_5200K = 0x3, ///< 5200K white balance.
WHITE_BALANCE_6000K = 0x4, ///< 6000K white balance.
WHITE_BALANCE_7000K = 0x5, ///< 7000K white balance.
// White balance aliases.
WHITE_BALANCE_NORMAL = WHITE_BALANCE_AUTO, // Normal white balance. (AUTO)
WHITE_BALANCE_TUNGSTEN = WHITE_BALANCE_3200K, // Tungsten white balance. (3200K)
WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT = WHITE_BALANCE_4150K, // Fluorescent white balance. (4150K)
WHITE_BALANCE_DAYLIGHT = WHITE_BALANCE_5200K, // Daylight white balance. (5200K)
WHITE_BALANCE_CLOUDY = WHITE_BALANCE_6000K, // Cloudy white balance. (6000K)
WHITE_BALANCE_HORIZON = WHITE_BALANCE_6000K, // Horizon white balance. (6000K)
WHITE_BALANCE_SHADE = WHITE_BALANCE_7000K, // Shade white balance. (7000K)
} CAMU_WhiteBalance;
/// Camera photo modes.
typedef enum {
PHOTO_MODE_NORMAL = 0x0, ///< Normal mode.
PHOTO_MODE_PORTRAIT = 0x1, ///< Portrait mode.
PHOTO_MODE_LANDSCAPE = 0x2, ///< Landscape mode.
PHOTO_MODE_NIGHTVIEW = 0x3, ///< Night mode.
PHOTO_MODE_LETTER = 0x4, ///< Letter mode.
} CAMU_PhotoMode;
/// Camera special effects.
typedef enum {
EFFECT_NONE = 0x0, ///< No effects.
EFFECT_MONO = 0x1, ///< Mono effect.
EFFECT_SEPIA = 0x2, ///< Sepia effect.
EFFECT_NEGATIVE = 0x3, ///< Negative effect.
EFFECT_NEGAFILM = 0x4, ///< Negative film effect.
EFFECT_SEPIA01 = 0x5, ///< Sepia effect.
} CAMU_Effect;
/// Camera contrast patterns.
typedef enum {
CONTRAST_PATTERN_01 = 0x0, ///< Pattern 1.
CONTRAST_PATTERN_02 = 0x1, ///< Pattern 2.
CONTRAST_PATTERN_03 = 0x2, ///< Pattern 3.
CONTRAST_PATTERN_04 = 0x3, ///< Pattern 4.
CONTRAST_PATTERN_05 = 0x4, ///< Pattern 5.
CONTRAST_PATTERN_06 = 0x5, ///< Pattern 6.
CONTRAST_PATTERN_07 = 0x6, ///< Pattern 7.
CONTRAST_PATTERN_08 = 0x7, ///< Pattern 8.
CONTRAST_PATTERN_09 = 0x8, ///< Pattern 9.
CONTRAST_PATTERN_10 = 0x9, ///< Pattern 10.
CONTRAST_PATTERN_11 = 0xA, ///< Pattern 11.
// Contrast aliases.
CONTRAST_LOW = CONTRAST_PATTERN_05, ///< Low contrast. (5)
CONTRAST_NORMAL = CONTRAST_PATTERN_06, ///< Normal contrast. (6)
CONTRAST_HIGH = CONTRAST_PATTERN_07, ///< High contrast. (7)
} CAMU_Contrast;
/// Camera lens correction modes.
typedef enum {
LENS_CORRECTION_OFF = 0x0, ///< No lens correction.
LENS_CORRECTION_ON_70 = 0x1, ///< Edge-to-center brightness ratio of 70.
LENS_CORRECTION_ON_90 = 0x2, ///< Edge-to-center brightness ratio of 90.
// Lens correction aliases.
LENS_CORRECTION_DARK = LENS_CORRECTION_OFF, ///< Dark lens correction. (OFF)
LENS_CORRECTION_NORMAL = LENS_CORRECTION_ON_70, ///< Normal lens correction. (70)
LENS_CORRECTION_BRIGHT = LENS_CORRECTION_ON_90, ///< Bright lens correction. (90)
} CAMU_LensCorrection;
/// Camera image output formats.
typedef enum {
OUTPUT_YUV_422 = 0x0, ///< YUV422
OUTPUT_RGB_565 = 0x1, ///< RGB565
} CAMU_OutputFormat;
/// Camera shutter sounds.
typedef enum {
SHUTTER_SOUND_TYPE_NORMAL = 0x0, ///< Normal shutter sound.
SHUTTER_SOUND_TYPE_MOVIE = 0x1, ///< Shutter sound to begin a movie.
SHUTTER_SOUND_TYPE_MOVIE_END = 0x2, ///< Shutter sound to end a movie.
} CAMU_ShutterSoundType;
/// Image quality calibration data.
typedef struct {
s16 aeBaseTarget; ///< Auto exposure base target brightness.
s16 kRL; ///< Left color correction matrix red normalization coefficient.
s16 kGL; ///< Left color correction matrix green normalization coefficient.
s16 kBL; ///< Left color correction matrix blue normalization coefficient.
s16 ccmPosition; ///< Color correction matrix position.
u16 awbCcmL9Right; ///< Right camera, left color correction matrix red/green gain.
u16 awbCcmL9Left; ///< Left camera, left color correction matrix red/green gain.
u16 awbCcmL10Right; ///< Right camera, left color correction matrix blue/green gain.
u16 awbCcmL10Left; ///< Left camera, left color correction matrix blue/green gain.
u16 awbX0Right; ///< Right camera, color correction matrix position threshold.
u16 awbX0Left; ///< Left camera, color correction matrix position threshold.
} CAMU_ImageQualityCalibrationData;
/// Stereo camera calibration data.
typedef struct {
u8 isValidRotationXY; ///< #bool Whether the X and Y rotation data is valid.
u8 padding[3]; ///< Padding. (Aligns isValidRotationXY to 4 bytes)
float scale; ///< Scale to match the left camera image with the right.
float rotationZ; ///< Z axis rotation to match the left camera image with the right.
float translationX; ///< X axis translation to match the left camera image with the right.
float translationY; ///< Y axis translation to match the left camera image with the right.
float rotationX; ///< X axis rotation to match the left camera image with the right.
float rotationY; ///< Y axis rotation to match the left camera image with the right.
float angleOfViewRight; ///< Right camera angle of view.
float angleOfViewLeft; ///< Left camera angle of view.
float distanceToChart; ///< Distance between cameras and measurement chart.
float distanceCameras; ///< Distance between left and right cameras.
s16 imageWidth; ///< Image width.
s16 imageHeight; ///< Image height.
u8 reserved[16]; ///< Reserved for future use. (unused)
} CAMU_StereoCameraCalibrationData;
/// Batch camera configuration for use without a context.
typedef struct {
u8 camera; ///< Selected camera.
s8 exposure; ///< Camera exposure.
u8 whiteBalance; ///< #CAMU_WhiteBalance Camera white balance.
s8 sharpness; ///< Camera sharpness.
u8 autoExposureOn; ///< #bool Whether to automatically determine the proper exposure.
u8 autoWhiteBalanceOn; ///< #bool Whether to automatically determine the white balance mode.
u8 frameRate; ///< #CAMU_FrameRate Camera frame rate.
u8 photoMode; ///< #CAMU_PhotoMode Camera photo mode.
u8 contrast; ///< #CAMU_Contrast Camera contrast.
u8 lensCorrection; ///< #CAMU_LensCorrection Camera lens correction.
u8 noiseFilterOn; ///< #bool Whether to enable the camera's noise filter.
u8 padding; ///< Padding. (Aligns last 3 fields to 4 bytes)
s16 autoExposureWindowX; ///< X of the region to use for auto exposure.
s16 autoExposureWindowY; ///< Y of the region to use for auto exposure.
s16 autoExposureWindowWidth; ///< Width of the region to use for auto exposure.
s16 autoExposureWindowHeight; ///< Height of the region to use for auto exposure.
s16 autoWhiteBalanceWindowX; ///< X of the region to use for auto white balance.
s16 autoWhiteBalanceWindowY; ///< Y of the region to use for auto white balance.
s16 autoWhiteBalanceWindowWidth; ///< Width of the region to use for auto white balance.
s16 autoWhiteBalanceWindowHeight; ///< Height of the region to use for auto white balance.
} CAMU_PackageParameterCameraSelect;
/// Batch camera configuration for use with a context.
typedef struct {
u8 camera; ///< Selected camera.
u8 context; ///< #CAMU_Context Selected context.
u8 flip; ///< #CAMU_Flip Camera image flip mode.
u8 effect; ///< #CAMU_Effect Camera image special effects.
u8 size; ///< #CAMU_Size Camera image resolution.
} CAMU_PackageParameterContext;
/// Batch camera configuration for use with a context and with detailed size information.
typedef struct {
u8 camera; ///< Selected camera.
u8 context; ///< #CAMU_Context Selected context.
u8 flip; ///< #CAMU_Flip Camera image flip mode.
u8 effect; ///< #CAMU_Effect Camera image special effects.
s16 width; ///< Image width.
s16 height; ///< Image height.
s16 cropX0; ///< First crop point X.
s16 cropY0; ///< First crop point Y.
s16 cropX1; ///< Second crop point X.
s16 cropY1; ///< Second crop point Y.
} CAMU_PackageParameterContextDetail;
/**
* @brief Initializes the cam service.
*
* This will internally get the handle of the service, and on success call CAMU_DriverInitialize.
*/
Result camInit(void);
/**
* @brief Closes the cam service.
*
* This will internally call CAMU_DriverFinalize and close the handle of the service.
*/
void camExit(void);
/**
* Begins capture on the specified camera port.
* @param port Port to begin capture on.
*/
Result CAMU_StartCapture(u32 port);
/**
* Terminates capture on the specified camera port.
* @param port Port to terminate capture on.
*/
Result CAMU_StopCapture(u32 port);
/**
* @brief Gets whether the specified camera port is busy.
* @param busy Pointer to output the busy state to.
* @param port Port to check.
*/
Result CAMU_IsBusy(bool* busy, u32 port);
/**
* @brief Clears the buffer and error flags of the specified camera port.
* @param port Port to clear.
*/
Result CAMU_ClearBuffer(u32 port);
/**
* @brief Gets a handle to the event signaled on vsync interrupts.
* @param event Pointer to output the event handle to.
* @param port Port to use.
*/
Result CAMU_GetVsyncInterruptEvent(Handle* event, u32 port);
/**
* @brief Gets a handle to the event signaled on camera buffer errors.
* @param event Pointer to output the event handle to.
* @param port Port to use.
*/
Result CAMU_GetBufferErrorInterruptEvent(Handle* event, u32 port);
/**
* @brief Initiates the process of receiving a camera frame.
* @param event Pointer to output the completion event handle to.
* @param dst Buffer to write data to.
* @param port Port to receive from.
* @param imageSize Size of the image to receive.
* @param transferUnit Transfer unit to use when receiving.
*/
Result CAMU_SetReceiving(Handle* event, void* dst, u32 port, u32 imageSize, s16 transferUnit);
/**
* @brief Gets whether the specified camera port has finished receiving image data.
* @param finishedReceiving Pointer to output the receiving status to.
* @param port Port to check.
*/
Result CAMU_IsFinishedReceiving(bool* finishedReceiving, u32 port);
/**
* @brief Sets the number of lines to transfer into an image buffer.
* @param port Port to use.
* @param lines Lines to transfer.
* @param width Width of the image.
* @param height Height of the image.
*/
Result CAMU_SetTransferLines(u32 port, s16 lines, s16 width, s16 height);
/**
* @brief Gets the maximum number of lines that can be saved to an image buffer.
* @param maxLines Pointer to write the maximum number of lines to.
* @param width Width of the image.
* @param height Height of the image.
*/
Result CAMU_GetMaxLines(s16* maxLines, s16 width, s16 height);
/**
* @brief Sets the number of bytes to transfer into an image buffer.
* @param port Port to use.
* @param bytes Bytes to transfer.
* @param width Width of the image.
* @param height Height of the image.
*/
Result CAMU_SetTransferBytes(u32 port, u32 bytes, s16 width, s16 height);
/**
* @brief Gets the number of bytes to transfer into an image buffer.
* @param transferBytes Pointer to write the number of bytes to.
* @param port Port to use.
*/
Result CAMU_GetTransferBytes(u32* transferBytes, u32 port);
/**
* @brief Gets the maximum number of bytes that can be saved to an image buffer.
* @param maxBytes Pointer to write the maximum number of bytes to.
* @param width Width of the image.
* @param height Height of the image.
*/
Result CAMU_GetMaxBytes(u32* maxBytes, s16 width, s16 height);
/**
* @brief Sets whether image trimming is enabled.
* @param port Port to use.
* @param trimming Whether image trimming is enabled.
*/
Result CAMU_SetTrimming(u32 port, bool trimming);
/**
* @brief Gets whether image trimming is enabled.
* @param trimming Pointer to output the trim state to.
* @param port Port to use.
*/
Result CAMU_IsTrimming(bool* trimming, u32 port);
/**
* @brief Sets the parameters used for trimming images.
* @param port Port to use.
* @param xStart Start X coordinate.
* @param yStart Start Y coordinate.
* @param xEnd End X coordinate.
* @param yEnd End Y coordinate.
*/
Result CAMU_SetTrimmingParams(u32 port, s16 xStart, s16 yStart, s16 xEnd, s16 yEnd);
/**
* @brief Gets the parameters used for trimming images.
* @param xStart Pointer to write the start X coordinate to.
* @param yStart Pointer to write the start Y coordinate to.
* @param xEnd Pointer to write the end X coordinate to.
* @param yEnd Pointer to write the end Y coordinate to.
* @param port Port to use.
*/
Result CAMU_GetTrimmingParams(s16* xStart, s16* yStart, s16* xEnd, s16* yEnd, u32 port);
/**
* @brief Sets the parameters used for trimming images, relative to the center of the image.
* @param port Port to use.
* @param trimWidth Trim width.
* @param trimHeight Trim height.
* @param camWidth Camera width.
* @param camHeight Camera height.
*/
Result CAMU_SetTrimmingParamsCenter(u32 port, s16 trimWidth, s16 trimHeight, s16 camWidth, s16 camHeight);
/**
* @brief Activates the specified camera.
* @param select Camera to use.
*/
Result CAMU_Activate(u32 select);
/**
* @brief Switches the specified camera's active context.
* @param select Camera to use.
* @param context Context to use.
*/
Result CAMU_SwitchContext(u32 select, CAMU_Context context);
/**
* @brief Sets the exposure value of the specified camera.
* @param select Camera to use.
* @param exposure Exposure value to use.
*/
Result CAMU_SetExposure(u32 select, s8 exposure);
/**
* @brief Sets the white balance mode of the specified camera.
* @param select Camera to use.
* @param whiteBalance White balance mode to use.
*/
Result CAMU_SetWhiteBalance(u32 select, CAMU_WhiteBalance whiteBalance);
/**
* @brief Sets the white balance mode of the specified camera.
* TODO: Explain "without base up"?
* @param select Camera to use.
* @param whiteBalance White balance mode to use.
*/
Result CAMU_SetWhiteBalanceWithoutBaseUp(u32 select, CAMU_WhiteBalance whiteBalance);
/**
* @brief Sets the sharpness of the specified camera.
* @param select Camera to use.
* @param sharpness Sharpness to use.
*/
Result CAMU_SetSharpness(u32 select, s8 sharpness);
/**
* @brief Sets whether auto exposure is enabled on the specified camera.
* @param select Camera to use.
* @param autoWhiteBalance Whether auto exposure is enabled.
*/
Result CAMU_SetAutoExposure(u32 select, bool autoExposure);
/**
* @brief Gets whether auto exposure is enabled on the specified camera.
* @param autoExposure Pointer to output the auto exposure state to.
* @param select Camera to use.
*/
Result CAMU_IsAutoExposure(bool* autoExposure, u32 select);
/**
* @brief Sets whether auto white balance is enabled on the specified camera.
* @param select Camera to use.
* @param autoWhiteBalance Whether auto white balance is enabled.
*/
Result CAMU_SetAutoWhiteBalance(u32 select, bool autoWhiteBalance);
/**
* @brief Gets whether auto white balance is enabled on the specified camera.
* @param autoWhiteBalance Pointer to output the auto white balance state to.
* @param select Camera to use.
*/
Result CAMU_IsAutoWhiteBalance(bool* autoWhiteBalance, u32 select);
/**
* @brief Flips the image of the specified camera in the specified context.
* @param select Camera to use.
* @param flip Flip mode to use.
* @param context Context to use.
*/
Result CAMU_FlipImage(u32 select, CAMU_Flip flip, CAMU_Context context);
/**
* @brief Sets the image resolution of the given camera in the given context, in detail.
* @param select Camera to use.
* @param width Width to use.
* @param height Height to use.
* @param cropX0 First crop point X.
* @param cropY0 First crop point Y.
* @param cropX1 Second crop point X.
* @param cropY1 Second crop point Y.
* @param context Context to use.
*/
Result CAMU_SetDetailSize(u32 select, s16 width, s16 height, s16 cropX0, s16 cropY0, s16 cropX1, s16 cropY1, CAMU_Context context);
/**
* @brief Sets the image resolution of the given camera in the given context.
* @param select Camera to use.
* @param size Size to use.
* @param context Context to use.
*/
Result CAMU_SetSize(u32 select, CAMU_Size size, CAMU_Context context);
/**
* @brief Sets the frame rate of the given camera.
* @param select Camera to use.
* @param frameRate Frame rate to use.
*/
Result CAMU_SetFrameRate(u32 select, CAMU_FrameRate frameRate);
/**
* @brief Sets the photo mode of the given camera.
* @param select Camera to use.
* @param photoMode Photo mode to use.
*/
Result CAMU_SetPhotoMode(u32 select, CAMU_PhotoMode photoMode);
/**
* @brief Sets the special effects of the given camera in the given context.
* @param select Camera to use.
* @param effect Effect to use.
* @param context Context to use.
*/
Result CAMU_SetEffect(u32 select, CAMU_Effect effect, CAMU_Context context);
/**
* @brief Sets the contrast mode of the given camera.
* @param select Camera to use.
* @param contrast Contrast mode to use.
*/
Result CAMU_SetContrast(u32 select, CAMU_Contrast contrast);
/**
* @brief Sets the lens correction mode of the given camera.
* @param select Camera to use.
* @param lensCorrection Lens correction mode to use.
*/
Result CAMU_SetLensCorrection(u32 select, CAMU_LensCorrection lensCorrection);
/**
* @brief Sets the output format of the given camera in the given context.
* @param select Camera to use.
* @param format Format to output.
* @param context Context to use.
*/
Result CAMU_SetOutputFormat(u32 select, CAMU_OutputFormat format, CAMU_Context context);
/**
* @brief Sets the region to base auto exposure off of for the specified camera.
* @param select Camera to use.
* @param x X of the region.
* @param y Y of the region.
* @param width Width of the region.
* @param height Height of the region.
*/
Result CAMU_SetAutoExposureWindow(u32 select, s16 x, s16 y, s16 width, s16 height);
/**
* @brief Sets the region to base auto white balance off of for the specified camera.
* @param select Camera to use.
* @param x X of the region.
* @param y Y of the region.
* @param width Width of the region.
* @param height Height of the region.
*/
Result CAMU_SetAutoWhiteBalanceWindow(u32 select, s16 x, s16 y, s16 width, s16 height);
/**
* @brief Sets whether the specified camera's noise filter is enabled.
* @param select Camera to use.
* @param noiseFilter Whether the noise filter is enabled.
*/
Result CAMU_SetNoiseFilter(u32 select, bool noiseFilter);
/**
* @brief Synchronizes the specified cameras' vsync timing.
* @param select1 First camera.
* @param select2 Second camera.
*/
Result CAMU_SynchronizeVsyncTiming(u32 select1, u32 select2);
/**
* @brief Gets the vsync timing record of the specified camera for the specified number of signals.
* @param timing Pointer to write timing data to. (size "past * sizeof(s64)")
* @param port Port to use.
* @param past Number of past timings to retrieve.
*/
Result CAMU_GetLatestVsyncTiming(s64* timing, u32 port, u32 past);
/**
* @brief Gets the specified camera's stereo camera calibration data.
* @param data Pointer to output the stereo camera data to.
*/
Result CAMU_GetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData* data);
/**
* @brief Sets the specified camera's stereo camera calibration data.
* @param data Data to set.
*/
Result CAMU_SetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData data);
/**
* @brief Writes to the specified I2C register of the specified camera.
* @param select Camera to write to.
* @param addr Address to write to.
* @param data Data to write.
*/
Result CAMU_WriteRegisterI2c(u32 select, u16 addr, u16 data);
/**
* @brief Writes to the specified MCU variable of the specified camera.
* @param select Camera to write to.
* @param addr Address to write to.
* @param data Data to write.
*/
Result CAMU_WriteMcuVariableI2c(u32 select, u16 addr, u16 data);
/**
* @brief Reads the specified I2C register of the specified camera.
* @param data Pointer to read data to.
* @param select Camera to read from.
* @param addr Address to read.
*/
Result CAMU_ReadRegisterI2cExclusive(u16* data, u32 select, u16 addr);
/**
* @brief Reads the specified MCU variable of the specified camera.
* @param data Pointer to read data to.
* @param select Camera to read from.
* @param addr Address to read.
*/
Result CAMU_ReadMcuVariableI2cExclusive(u16* data, u32 select, u16 addr);
/**
* @brief Sets the specified camera's image quality calibration data.
* @param data Data to set.
*/
Result CAMU_SetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData data);
/**
* @brief Gets the specified camera's image quality calibration data.
* @param data Pointer to write the quality data to.
*/
Result CAMU_GetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData* data);
/**
* @brief Configures a camera with pre-packaged configuration data without a context.
* @param Parameter to use.
*/
Result CAMU_SetPackageParameterWithoutContext(CAMU_PackageParameterCameraSelect param);
/**
* @brief Configures a camera with pre-packaged configuration data with a context.
* @param Parameter to use.
*/
Result CAMU_SetPackageParameterWithContext(CAMU_PackageParameterContext param);
/**
* @brief Configures a camera with pre-packaged configuration data without a context and extra resolution details.
* @param Parameter to use.
*/
Result CAMU_SetPackageParameterWithContextDetail(CAMU_PackageParameterContextDetail param);
/**
* @brief Gets the Y2R coefficient applied to image data by the camera.
* @param coefficient Pointer to output the Y2R coefficient to.
*/
Result CAMU_GetSuitableY2rStandardCoefficient(Y2RU_StandardCoefficient* coefficient);
/**
* @brief Plays the specified shutter sound.
* @param sound Shutter sound to play.
*/
Result CAMU_PlayShutterSound(CAMU_ShutterSoundType sound);
/// Initializes the camera driver.
Result CAMU_DriverInitialize(void);
/// Finalizes the camera driver.
Result CAMU_DriverFinalize(void);
/**
* @brief Gets the current activated camera.
* @param select Pointer to output the current activated camera to.
*/
Result CAMU_GetActivatedCamera(u32* select);
/**
* @brief Gets the current sleep camera.
* @param select Pointer to output the current sleep camera to.
*/
Result CAMU_GetSleepCamera(u32* select);
/**
* @brief Sets the current sleep camera.
* @param select Camera to set.
*/
Result CAMU_SetSleepCamera(u32 select);
/**
* @brief Sets whether to enable synchronization of left and right camera brightnesses.
* @param brightnessSynchronization Whether to enable brightness synchronization.
*/
Result CAMU_SetBrightnessSynchronization(bool brightnessSynchronization);

View file

@ -0,0 +1,90 @@
/**
* @file cdcchk.h
* @brief CODEC Hardware Check service.
*/
#pragma once
#include <3ds/types.h>
/// I2S line enumeration
typedef enum {
CODEC_I2S_LINE_1, ///< Primary I2S line, used by DSP/Mic (configurable)/GBA sound controller.
CODEC_I2S_LINE_2, ///< Secondary I2S line, used by CSND hardware.
} CodecI2sLine;
/// Initializes CDCCHK.
Result cdcChkInit(void);
/// Exits CDCCHK.
void cdcChkExit(void);
/**
* @brief Gets a pointer to the current cdc:CHK session handle.
* @return A pointer to the current cdc:CHK session handle.
*/
Handle *cdcChkGetSessionHandle(void);
/**
* @brief Reads multiple registers from the CODEC, using the old
* SPI hardware interface and a 4MHz baudrate.
* @param pageId CODEC Page ID.
* @param initialRegAddr Address of the CODEC register to start with.
* @param[out] outData Where to write the read data to.
* @param size Number of registers to read (bytes to read, max. 64).
*/
Result CDCCHK_ReadRegisters1(u8 pageId, u8 initialRegAddr, void *outData, size_t size);
/**
* @brief Reads multiple registers from the CODEC, using the new
* SPI hardware interface and a 16MHz baudrate.
* @param pageId CODEC Page ID.
* @param initialRegAddr Address of the CODEC register to start with.
* @param[out] outData Where to read the data to.
* @param size Number of registers to read (bytes to read, max. 64).
*/
Result CDCCHK_ReadRegisters2(u8 pageId, u8 initialRegAddr, void *outData, size_t size);
/**
* @brief Writes multiple registers to the CODEC, using the old
* SPI hardware interface and a 4MHz baudrate.
* @param pageId CODEC Page ID.
* @param initialRegAddr Address of the CODEC register to start with.
* @param data Where to read the data to write from.
* @param size Number of registers to write (bytes to read, max. 64).
*/
Result CDCCHK_WriteRegisters1(u8 pageId, u8 initialRegAddr, const void *data, size_t size);
/**
* @brief Writes multiple registers to the CODEC, using the new
* SPI hardware interface and a 16MHz baudrate.
* @param pageId CODEC Page ID.
* @param initialRegAddr Address of the CODEC register to start with.
* @param data Where to read the data to write from.
* @param size Number of registers to write (bytes to read, max. 64).
*/
Result CDCCHK_WriteRegisters2(u8 pageId, u8 initialRegAddr, const void *data, size_t size);
/**
* @brief Reads a single register from the NTR PMIC.
* @param[out] outData Where to read the data to (1 byte).
* @param regAddr Register address.
* @note The NTR PMIC is emulated by the CODEC hardware and sends
* IRQs to the MCU when relevant.
*/
Result CDCCHK_ReadNtrPmicRegister(u8 *outData, u8 regAddr);
/**
* @brief Writes a single register from the NTR PMIC.
* @param regAddr Register address.
* @param data Data to write (1 byte).
* @note The NTR PMIC is emulated by the CODEC hardware and sends
* IRQs to the MCU when relevant.
*/
Result CDCCHK_WriteNtrPmicRegister(u8 regAddr, u8 data);
/**
* @brief Sets the DAC volume level for the specified I2S line.
* @param i2sLine I2S line to set the volume for.
* @param volume Volume level (-128 to 0).
*/
Result CDCCHK_SetI2sVolume(CodecI2sLine i2sLine, s8 volume);

View file

@ -0,0 +1,53 @@
/**
* @file cfgnor.h
* @brief CFGNOR service.
*/
#pragma once
/**
* @brief Initializes CFGNOR.
* @param value Unknown, usually 1.
*/
Result cfgnorInit(u8 value);
/// Exits CFGNOR
void cfgnorExit(void);
/**
* @brief Dumps the NOR flash.
* @param buf Buffer to dump to.
* @param size Size of the buffer.
*/
Result cfgnorDumpFlash(u32 *buf, u32 size);
/**
* @brief Writes the NOR flash.
* @param buf Buffer to write from.
* @param size Size of the buffer.
*/
Result cfgnorWriteFlash(u32 *buf, u32 size);
/**
* @brief Initializes the CFGNOR session.
* @param value Unknown, usually 1.
*/
Result CFGNOR_Initialize(u8 value);
/// Shuts down the CFGNOR session.
Result CFGNOR_Shutdown(void);
/**
* @brief Reads data from NOR.
* @param offset Offset to read from.
* @param buf Buffer to read data to.
* @param size Size of the buffer.
*/
Result CFGNOR_ReadData(u32 offset, u32 *buf, u32 size);
/**
* @brief Writes data to NOR.
* @param offset Offset to write to.
* @param buf Buffer to write data from.
* @param size Size of the buffer.
*/
Result CFGNOR_WriteData(u32 offset, u32 *buf, u32 size);

220
.vscode/dummyinclude/3ds/services/cfgu.h vendored Normal file
View file

@ -0,0 +1,220 @@
/**
* @file cfgu.h
* @brief CFGU (Configuration) Service
*/
#pragma once
#include <3ds/types.h>
/// Configuration region values.
typedef enum
{
CFG_REGION_JPN = 0, ///< Japan
CFG_REGION_USA = 1, ///< USA
CFG_REGION_EUR = 2, ///< Europe
CFG_REGION_AUS = 3, ///< Australia
CFG_REGION_CHN = 4, ///< China
CFG_REGION_KOR = 5, ///< Korea
CFG_REGION_TWN = 6, ///< Taiwan
} CFG_Region;
/// Configuration language values.
typedef enum
{
CFG_LANGUAGE_JP = 0, ///< Japanese
CFG_LANGUAGE_EN = 1, ///< English
CFG_LANGUAGE_FR = 2, ///< French
CFG_LANGUAGE_DE = 3, ///< German
CFG_LANGUAGE_IT = 4, ///< Italian
CFG_LANGUAGE_ES = 5, ///< Spanish
CFG_LANGUAGE_ZH = 6, ///< Simplified Chinese
CFG_LANGUAGE_KO = 7, ///< Korean
CFG_LANGUAGE_NL = 8, ///< Dutch
CFG_LANGUAGE_PT = 9, ///< Portugese
CFG_LANGUAGE_RU = 10, ///< Russian
CFG_LANGUAGE_TW = 11, ///< Traditional Chinese
} CFG_Language;
// Configuration system model values.
typedef enum
{
CFG_MODEL_3DS = 0, ///< Old 3DS (CTR)
CFG_MODEL_3DSXL = 1, ///< Old 3DS XL (SPR)
CFG_MODEL_N3DS = 2, ///< New 3DS (KTR)
CFG_MODEL_2DS = 3, ///< Old 2DS (FTR)
CFG_MODEL_N3DSXL = 4, ///< New 3DS XL (RED)
CFG_MODEL_N2DSXL = 5, ///< New 2DS XL (JAN)
} CFG_SystemModel;
/// Initializes CFGU.
Result cfguInit(void);
/// Exits CFGU.
void cfguExit(void);
/**
* @brief Gets the system's region from secure info.
* @param region Pointer to output the region to. (see @ref CFG_Region)
*/
Result CFGU_SecureInfoGetRegion(u8* region);
/**
* @brief Generates a console-unique hash.
* @param appIDSalt Salt to use.
* @param hash Pointer to output the hash to.
*/
Result CFGU_GenHashConsoleUnique(u32 appIDSalt, u64* hash);
/**
* @brief Gets whether the system's region is Canada or USA.
* @param value Pointer to output the result to. (0 = no, 1 = yes)
*/
Result CFGU_GetRegionCanadaUSA(u8* value);
/**
* @brief Gets the system's model.
* @param model Pointer to output the model to. (see @ref CFG_SystemModel)
*/
Result CFGU_GetSystemModel(u8* model);
/**
* @brief Gets whether the system is a 2DS.
* @param value Pointer to output the result to. (0 = yes, 1 = no)
*/
Result CFGU_GetModelNintendo2DS(u8* value);
/**
* @brief Gets a string representing a country code.
* @param code Country code to use.
* @param string Pointer to output the string to.
*/
Result CFGU_GetCountryCodeString(u16 code, u16* string);
/**
* @brief Gets a country code ID from its string.
* @param string String to use.
* @param code Pointer to output the country code to.
*/
Result CFGU_GetCountryCodeID(u16 string, u16* code);
/**
* @brief Checks if NFC (code name: fangate) is supported.
* @param isSupported pointer to the output the result to.
*/
Result CFGU_IsNFCSupported(bool* isSupported);
/**
* @brief Gets a config info block with flags = 2.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param outData Pointer to write the block data to.
*/
Result CFGU_GetConfigInfoBlk2(u32 size, u32 blkID, void* outData);
/**
* @brief Gets a config info block with flags = 4.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param outData Pointer to write the block data to.
*/
Result CFG_GetConfigInfoBlk4(u32 size, u32 blkID, void* outData);
/**
* @brief Gets a config info block with flags = 8.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param outData Pointer to write the block data to.
*/
Result CFG_GetConfigInfoBlk8(u32 size, u32 blkID, void* outData);
/**
* @brief Sets a config info block with flags = 4.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param inData Pointer to block data to write.
*/
Result CFG_SetConfigInfoBlk4(u32 size, u32 blkID, const void* inData);
/**
* @brief Sets a config info block with flags = 8.
* @param size Size of the data to retrieve.
* @param blkID ID of the block to retrieve.
* @param inData Pointer to block data to write.
*/
Result CFG_SetConfigInfoBlk8(u32 size, u32 blkID, const void* inData);
/**
* @brief Writes the CFG buffer in memory to the savegame in NAND.
*/
Result CFG_UpdateConfigSavegame(void);
/**
* @brief Gets the system's language.
* @param language Pointer to write the language to. (see @ref CFG_Language)
*/
Result CFGU_GetSystemLanguage(u8* language);
/**
* @brief Deletes the NAND LocalFriendCodeSeed file, then recreates it using the LocalFriendCodeSeed data stored in memory.
*/
Result CFGI_RestoreLocalFriendCodeSeed(void);
/**
* @brief Deletes the NAND SecureInfo file, then recreates it using the SecureInfo data stored in memory.
*/
Result CFGI_RestoreSecureInfo(void);
/**
* @brief Deletes the "config" file stored in the NAND Config_Savegame.
*/
Result CFGI_DeleteConfigSavefile(void);
/**
* @brief Formats Config_Savegame.
*/
Result CFGI_FormatConfig(void);
/**
* @brief Clears parental controls
*/
Result CFGI_ClearParentalControls(void);
/**
* @brief Verifies the RSA signature for the LocalFriendCodeSeed data already stored in memory.
*/
Result CFGI_VerifySigLocalFriendCodeSeed(void);
/**
* @brief Verifies the RSA signature for the SecureInfo data already stored in memory.
*/
Result CFGI_VerifySigSecureInfo(void);
/**
* @brief Gets the system's serial number.
* @param serial Pointer to output the serial to. (This is normally 0xF)
*/
Result CFGI_SecureInfoGetSerialNumber(u8 *serial);
/**
* @brief Gets the 0x110-byte buffer containing the data for the LocalFriendCodeSeed.
* @param data Pointer to output the buffer. (The size must be at least 0x110-bytes)
*/
Result CFGI_GetLocalFriendCodeSeedData(u8 *data);
/**
* @brief Gets the 64-bit local friend code seed.
* @param seed Pointer to write the friend code seed to.
*/
Result CFGI_GetLocalFriendCodeSeed(u64* seed);
/**
* @brief Gets the 0x11-byte data following the SecureInfo signature.
* @param data Pointer to output the buffer. (The size must be at least 0x11-bytes)
*/
Result CFGI_GetSecureInfoData(u8 *data);
/**
* @brief Gets the 0x100-byte RSA-2048 SecureInfo signature.
* @param data Pointer to output the buffer. (The size must be at least 0x100-bytes)
*/
Result CFGI_GetSecureInfoSignature(u8 *data);

433
.vscode/dummyinclude/3ds/services/csnd.h vendored Normal file
View file

@ -0,0 +1,433 @@
/**
* @file csnd.h
* @brief CSND service. Usage of this service is deprecated in favor of NDSP.
*/
#pragma once
#include <3ds/types.h>
/// Maximum number of CSND channels.
#define CSND_NUM_CHANNELS 32
/// Creates a CSND timer value from a sample rate.
#define CSND_TIMER(n) (0x3FEC3FC / ((u32)(n)))
/**
* @brief Converts a vol-pan pair into a left/right volume pair used by the hardware.
* @param vol Volume to use.
* @param pan Pan to use.
* @return A left/right volume pair for use by hardware.
*/
static inline u32 CSND_VOL(float vol, float pan)
{
float rpan;
u32 lvol, rvol;
if (vol < 0.0f) vol = 0.0f;
else if (vol > 1.0f) vol = 1.0f;
rpan = (pan+1) / 2;
if (rpan < 0.0f) rpan = 0.0f;
else if (rpan > 1.0f) rpan = 1.0f;
lvol = vol*(1-rpan) * 0x8000;
rvol = vol*rpan * 0x8000;
return lvol | (rvol << 16);
}
/// CSND encodings.
enum
{
CSND_ENCODING_PCM8 = 0, ///< PCM8
CSND_ENCODING_PCM16, ///< PCM16
CSND_ENCODING_ADPCM, ///< IMA-ADPCM
CSND_ENCODING_PSG, ///< PSG (Similar to DS?)
};
/// CSND loop modes.
enum
{
CSND_LOOPMODE_MANUAL = 0, ///< Manual loop.
CSND_LOOPMODE_NORMAL, ///< Normal loop.
CSND_LOOPMODE_ONESHOT, ///< Do not loop.
CSND_LOOPMODE_NORELOAD, ///< Don't reload.
};
/// Creates a sound channel value from a channel number.
#define SOUND_CHANNEL(n) ((u32)(n) & 0x1F)
/// Creates a sound format value from an encoding.
#define SOUND_FORMAT(n) ((u32)(n) << 12)
/// Creates a sound loop mode value from a loop mode.
#define SOUND_LOOPMODE(n) ((u32)(n) << 10)
/// Sound flags.
enum
{
SOUND_LINEAR_INTERP = BIT(6), ///< Linear interpolation.
SOUND_REPEAT = SOUND_LOOPMODE(CSND_LOOPMODE_NORMAL), ///< Repeat the sound.
SOUND_ONE_SHOT = SOUND_LOOPMODE(CSND_LOOPMODE_ONESHOT), ///< Play the sound once.
SOUND_FORMAT_8BIT = SOUND_FORMAT(CSND_ENCODING_PCM8), ///< PCM8
SOUND_FORMAT_16BIT = SOUND_FORMAT(CSND_ENCODING_PCM16), ///< PCM16
SOUND_FORMAT_ADPCM = SOUND_FORMAT(CSND_ENCODING_ADPCM), ///< ADPCM
SOUND_FORMAT_PSG = SOUND_FORMAT(CSND_ENCODING_PSG), ///< PSG
SOUND_ENABLE = BIT(14), ///< Enable sound.
};
/// Capture modes.
enum
{
CAPTURE_REPEAT = 0, ///< Repeat capture.
CAPTURE_ONE_SHOT = BIT(0), ///< Capture once.
CAPTURE_FORMAT_16BIT = 0, ///< PCM16
CAPTURE_FORMAT_8BIT = BIT(1), ///< PCM8
CAPTURE_ENABLE = BIT(15), ///< Enable capture.
};
/// Duty cycles for a PSG channel.
typedef enum
{
DutyCycle_0 = 7, ///< 0.0% duty cycle
DutyCycle_12 = 0, ///< 12.5% duty cycle
DutyCycle_25 = 1, ///< 25.0% duty cycle
DutyCycle_37 = 2, ///< 37.5% duty cycle
DutyCycle_50 = 3, ///< 50.0% duty cycle
DutyCycle_62 = 4, ///< 62.5% duty cycle
DutyCycle_75 = 5, ///< 75.0% duty cycle
DutyCycle_87 = 6 ///< 87.5% duty cycle
} CSND_DutyCycle;
/// Channel info.
typedef union
{
u32 value[3]; ///< Raw values.
struct
{
u8 active; ///< Channel active.
u8 _pad1; ///< Padding.
u16 _pad2; ///< Padding.
s16 adpcmSample; ///< Current ADPCM sample.
u8 adpcmIndex; ///< Current ADPCM index.
u8 _pad3; ///< Padding.
u32 unknownZero; ///< Unknown.
};
} CSND_ChnInfo;
/// Capture info.
typedef union
{
u32 value[2]; ///< Raw values.
struct
{
u8 active; ///< Capture active.
u8 _pad1; ///< Padding.
u16 _pad2; ///< Padding.
u32 unknownZero; ///< Unknown.
};
} CSND_CapInfo;
// See here regarding CSND shared-mem commands, etc: http://3dbrew.org/wiki/CSND_Shared_Memory
extern vu32* csndSharedMem; ///< CSND shared memory.
extern u32 csndSharedMemSize; ///< CSND shared memory size.
extern u32 csndChannels; ///< Bitmask of channels that are allowed for usage.
/**
* @brief Acquires a capture unit.
* @param capUnit Pointer to output the capture unit to.
*/
Result CSND_AcquireCapUnit(u32* capUnit);
/**
* @brief Releases a capture unit.
* @param capUnit Capture unit to release.
*/
Result CSND_ReleaseCapUnit(u32 capUnit);
/**
* @brief Flushes the data cache of a memory region.
* @param adr Address of the memory region.
* @param size Size of the memory region.
*/
Result CSND_FlushDataCache(const void* adr, u32 size);
/**
* @brief Stores the data cache of a memory region.
* @param adr Address of the memory region.
* @param size Size of the memory region.
*/
Result CSND_StoreDataCache(const void* adr, u32 size);
/**
* @brief Invalidates the data cache of a memory region.
* @param adr Address of the memory region.
* @param size Size of the memory region.
*/
Result CSND_InvalidateDataCache(const void* adr, u32 size);
/**
* @brief Resets CSND.
* Note: Currently breaks sound, don't use for now!
*/
Result CSND_Reset(void);
/// Initializes CSND.
Result csndInit(void);
/// Exits CSND.
void csndExit(void);
/**
* @brief Adds a command to the list, returning a buffer to write arguments to.
* @param cmdid ID of the command to add.
* @return A buffer to write command arguments to.
*/
u32* csndAddCmd(int cmdid);
/**
* @brief Adds a command to the list, copying its arguments from a buffer.
* @param cmdid ID of the command to add.
* @param cmdparams Buffer containing the command's parameters.
*/
void csndWriteCmd(int cmdid, u8* cmdparams);
/**
* @brief Executes pending CSND commands.
* @param waitDone Whether to wait until the commands have finished executing.
*/
Result csndExecCmds(bool waitDone);
/**
* @brief Sets a channel's play state, resetting registers on stop.
* @param channel Channel to use.
* @param value Play state to set.
*/
void CSND_SetPlayStateR(u32 channel, u32 value);
/**
* @brief Sets a channel's play state.
* @param channel Channel to use.
* @param value Play state to set.
*/
void CSND_SetPlayState(u32 channel, u32 value);
/**
* @brief Sets a channel's encoding.
* @param channel Channel to use.
* @param value Encoding to set.
*/
void CSND_SetEncoding(u32 channel, u32 value);
/**
* @brief Sets the data of a channel's block.
* @param channel Channel to use.
* @param block Block to set.
* @param physaddr Physical address to set the block to.
* @param size Size of the block.
*/
void CSND_SetBlock(u32 channel, int block, u32 physaddr, u32 size);
/**
* @brief Sets whether to loop a channel.
* @param channel Channel to use.
* @param value Whether to loop the channel.
*/
void CSND_SetLooping(u32 channel, u32 value);
/**
* @brief Sets bit 7 of a channel.
* @param channel Channel to use.
* @param set Value to set.
*/
void CSND_SetBit7(u32 channel, bool set);
/**
* @brief Sets whether a channel should use interpolation.
* @param channel Channel to use.
* @param interp Whether to use interpolation.
*/
void CSND_SetInterp(u32 channel, bool interp);
/**
* @brief Sets a channel's duty.
* @param channel Channel to use.
* @param duty Duty to set.
*/
void CSND_SetDuty(u32 channel, CSND_DutyCycle duty);
/**
* @brief Sets a channel's timer.
* @param channel Channel to use.
* @param timer Timer to set.
*/
void CSND_SetTimer(u32 channel, u32 timer);
/**
* @brief Sets a channel's volume.
* @param channel Channel to use.
* @param chnVolumes Channel volume data to set.
* @param capVolumes Capture volume data to set.
*/
void CSND_SetVol(u32 channel, u32 chnVolumes, u32 capVolumes);
/**
* @brief Sets a channel's ADPCM state.
* @param channel Channel to use.
* @param block Current block.
* @param sample Current sample.
* @param index Current index.
*/
void CSND_SetAdpcmState(u32 channel, int block, int sample, int index);
/**
* @brief Sets a whether channel's ADPCM data should be reloaded when the second block is played.
* @param channel Channel to use.
* @param reload Whether to reload ADPCM data.
*/
void CSND_SetAdpcmReload(u32 channel, bool reload);
/**
* @brief Sets CSND's channel registers.
* @param flags Flags to set.
* @param physaddr0 Physical address of the first buffer to play.
* @param physaddr1 Physical address of the second buffer to play.
* @param totalbytesize Total size of the data to play.
* @param chnVolumes Channel volume data.
* @param capVolumes Capture volume data.
*/
void CSND_SetChnRegs(u32 flags, u32 physaddr0, u32 physaddr1, u32 totalbytesize, u32 chnVolumes, u32 capVolumes);
/**
* @brief Sets CSND's PSG channel registers.
* @param flags Flags to set.
* @param chnVolumes Channel volume data.
* @param capVolumes Capture volume data.
* @param duty Duty value to set.
*/
void CSND_SetChnRegsPSG(u32 flags, u32 chnVolumes, u32 capVolumes, CSND_DutyCycle duty);
/**
* @brief Sets CSND's noise channel registers.
* @param flags Flags to set.
* @param chnVolumes Channel volume data.
* @param capVolumes Capture volume data.
*/
void CSND_SetChnRegsNoise(u32 flags, u32 chnVolumes, u32 capVolumes);
/**
* @brief Sets whether a capture unit is enabled.
* @param capUnit Capture unit to use.
* @param enable Whether to enable the capture unit.
*/
void CSND_CapEnable(u32 capUnit, bool enable);
/**
* @brief Sets whether a capture unit should repeat.
* @param capUnit Capture unit to use.
* @param repeat Whether the capture unit should repeat.
*/
void CSND_CapSetRepeat(u32 capUnit, bool repeat);
/**
* @brief Sets a capture unit's format.
* @param capUnit Capture unit to use.
* @param eightbit Format to use.
*/
void CSND_CapSetFormat(u32 capUnit, bool eightbit);
/**
* @brief Sets a capture unit's second bit.
* @param capUnit Capture unit to use.
* @param set Value to set.
*/
void CSND_CapSetBit2(u32 capUnit, bool set);
/**
* @brief Sets a capture unit's timer.
* @param capUnit Capture unit to use.
* @param timer Timer to set.
*/
void CSND_CapSetTimer(u32 capUnit, u32 timer);
/**
* @brief Sets a capture unit's buffer.
* @param capUnit Capture unit to use.
* @param addr Buffer address to use.
* @param size Size of the buffer.
*/
void CSND_CapSetBuffer(u32 capUnit, u32 addr, u32 size);
/**
* @brief Sets a capture unit's capture registers.
* @param capUnit Capture unit to use.
* @param flags Capture unit flags.
* @param addr Capture unit buffer address.
* @param size Buffer size.
*/
void CSND_SetCapRegs(u32 capUnit, u32 flags, u32 addr, u32 size);
/**
* @brief Sets up DSP flags.
* @param waitDone Whether to wait for completion.
*/
Result CSND_SetDspFlags(bool waitDone);
/**
* @brief Updates CSND information.
* @param waitDone Whether to wait for completion.
*/
Result CSND_UpdateInfo(bool waitDone);
/**
* @brief Plays a sound.
* @param chn Channel to play the sound on.
* @param flags Flags containing information about the sound.
* @param sampleRate Sample rate of the sound.
* @param vol The volume, ranges from 0.0 to 1.0 included.
* @param pan The pan, ranges from -1.0 to 1.0 included.
* @param data0 First block of sound data.
* @param data1 Second block of sound data. This is the block that will be looped over.
* @param size Size of the sound data.
*
* In this implementation if the loop mode is used, data1 must be in the range [data0 ; data0 + size]. Sound will be played once from data0 to data0 + size and then loop between data1 and data0+size.
*/
Result csndPlaySound(int chn, u32 flags, u32 sampleRate, float vol, float pan, void* data0, void* data1, u32 size);
/**
* @brief Gets CSND's DSP flags.
* Note: Requires previous CSND_UpdateInfo()
* @param outSemFlags Pointer to write semaphore flags to.
* @param outIrqFlags Pointer to write interrupt flags to.
*/
void csndGetDspFlags(u32* outSemFlags, u32* outIrqFlags);
/**
* @brief Gets a channel's information.
* Note: Requires previous CSND_UpdateInfo()
* @param channel Channel to get information for.
* @return The channel's information.
*/
CSND_ChnInfo* csndGetChnInfo(u32 channel);
/**
* @brief Gets a capture unit's information.
* Note: Requires previous CSND_UpdateInfo()
* @param capUnit Capture unit to get information for.
* @return The capture unit's information.
*/
CSND_CapInfo* csndGetCapInfo(u32 capUnit);
/**
* @brief Gets a channel's state.
* @param channel Channel to get the state of.
* @param out Pointer to output channel information to.
*/
Result csndGetState(u32 channel, CSND_ChnInfo* out);
/**
* @brief Gets whether a channel is playing.
* @param channel Channel to check.
* @param status Pointer to output the channel status to.
*/
Result csndIsPlaying(u32 channel, u8* status);

188
.vscode/dummyinclude/3ds/services/dsp.h vendored Normal file
View file

@ -0,0 +1,188 @@
/**
* @file dsp.h
* @brief DSP Service to access the DSP processor commands (sound)
*
* The DSP has access to the Linear memory region, and to the DSP memory region if allowed in the exheader.
*/
#pragma once
#include <3ds/types.h>
/// DSP interrupt types.
typedef enum
{
DSP_INTERRUPT_PIPE = 2 ///< Pipe interrupt.
} DSP_InterruptType;
/// DSP hook types.
typedef enum
{
DSPHOOK_ONSLEEP = 0, ///< DSP is going to sleep.
DSPHOOK_ONWAKEUP = 1, ///< DSP is waking up.
DSPHOOK_ONCANCEL = 2, ///< DSP was sleeping and the app was cancelled.
} DSP_HookType;
/// DSP hook function.
typedef void (* dspHookFn)(DSP_HookType hook);
/// DSP hook cookie.
typedef struct tag_dspHookCookie
{
struct tag_dspHookCookie* next; ///< Next cookie.
dspHookFn callback; ///< Hook callback.
} dspHookCookie;
/**
* @brief Initializes the dsp service.
*
* Call this before calling any DSP_* function.
* @note This will also unload any previously loaded DSP binary.
* It is done this way since you have to provide your binary when the 3DS leaves sleep mode anyway.
*/
Result dspInit(void);
/**
* @brief Closes the dsp service.
* @note This will also unload the DSP binary.
*/
void dspExit(void);
/// Returns true if a component is loaded, false otherwise.
bool dspIsComponentLoaded(void);
/**
* @brief Sets up a DSP status hook.
* @param cookie Hook cookie to use.
* @param callback Function to call when DSP's status changes.
*/
void dspHook(dspHookCookie* cookie, dspHookFn callback);
/**
* @brief Removes a DSP status hook.
* @param cookie Hook cookie to remove.
*/
void dspUnhook(dspHookCookie* cookie);
/**
* @brief Checks if a headphone is inserted.
* @param is_inserted Pointer to output the insertion status to.
*/
Result DSP_GetHeadphoneStatus(bool* is_inserted);
/**
* @brief Flushes the cache
* @param address Beginning of the memory range to flush, inside the Linear or DSP memory regions
* @param size Size of the memory range to flush
*
* Flushes the cache for the specified memory range and invalidates the cache
*/
Result DSP_FlushDataCache(const void* address, u32 size);
/**
* @brief Invalidates the cache
* @param address Beginning of the memory range to invalidate, inside the Linear or DSP memory regions
* @param size Size of the memory range to flush
*
* Invalidates the cache for the specified memory range
*/
Result DSP_InvalidateDataCache(const void* address, u32 size);
/**
* @brief Retrieves the handle of the DSP semaphore.
* @param semaphore Pointer to output the semaphore to.
*/
Result DSP_GetSemaphoreHandle(Handle* semaphore);
/**
* @brief Sets the DSP hardware semaphore value.
* @param value Value to set.
*/
Result DSP_SetSemaphore(u16 value);
/**
* @brief Masks the DSP hardware semaphore value.
* @param mask Mask to apply.
*/
Result DSP_SetSemaphoreMask(u16 mask);
/**
* @brief Loads a DSP binary and starts the DSP
* @param component The program file address in memory
* @param size The size of the program
* @param prog_mask DSP memory block related ? Default is 0xff.
* @param data_mask DSP memory block related ? Default is 0xff.
* @param is_loaded Indicates if the DSP was succesfully loaded.
*
* @note The binary must be signed (http://3dbrew.org/wiki/DSP_Binary)
* @note Seems to be called when the 3ds leaves the Sleep mode
*/
Result DSP_LoadComponent(const void* component, u32 size, u16 prog_mask, u16 data_mask, bool* is_loaded);
///Stops the DSP by unloading the binary.
Result DSP_UnloadComponent(void);
/**
* @brief Registers an event handle with the DSP through IPC
* @param handle Event handle to register.
* @param interrupt The type of interrupt that will trigger the event. Usual value is DSP_INTERRUPT_PIPE.
* @param channel The pipe channel. Usual value is 2
*
* @note It is possible that interrupt are inverted
*/
Result DSP_RegisterInterruptEvents(Handle handle, u32 interrupt, u32 channel);
/**
* @brief Reads a pipe if possible.
* @param channel unknown. Usually 2
* @param peer unknown. Usually 0
* @param buffer The buffer that will store the values read from the pipe
* @param length Length of the buffer
* @param length_read Number of bytes read by the command
*/
Result DSP_ReadPipeIfPossible(u32 channel, u32 peer, void* buffer, u16 length, u16* length_read);
/**
* @brief Writes to a pipe.
* @param channel unknown. Usually 2
* @param buffer The message to send to the DSP process
* @param length Length of the message
*/
Result DSP_WriteProcessPipe(u32 channel, const void* buffer, u32 length);
/**
* @brief Converts a DSP memory address to a virtual address usable by the process.
* @param dsp_address Address to convert.
* @param arm_address Pointer to output the converted address to.
*/
Result DSP_ConvertProcessAddressFromDspDram(u32 dsp_address, u32* arm_address);
/**
* @brief Reads a DSP register
* @param regNo Offset of the hardware register, base address is 0x1EC40000
* @param value Pointer to read the register value to.
*/
Result DSP_RecvData(u16 regNo, u16* value);
/**
* @brief Checks if you can read a DSP register
* @param regNo Offset of the hardware register, base address is 0x1EC40000
* @param is_ready Pointer to write the ready status to.
*
* @warning This call might hang if the data is not ready. See @ref DSP_SendDataIsEmpty.
*/
Result DSP_RecvDataIsReady(u16 regNo, bool* is_ready);
/**
* @brief Writes to a DSP register
* @param regNo Offset of the hardware register, base address is 0x1EC40000
* @param value Value to write.
*
* @warning This call might hang if the SendData is not empty. See @ref DSP_SendDataIsEmpty.
*/
Result DSP_SendData(u16 regNo, u16 value);
/**
* @brief Checks if you can write to a DSP register ?
* @param regNo Offset of the hardware register, base address is 0x1EC40000
* @param is_empty Pointer to write the empty status to.
*/
Result DSP_SendDataIsEmpty(u16 regNo, bool* is_empty);

261
.vscode/dummyinclude/3ds/services/frd.h vendored Normal file
View file

@ -0,0 +1,261 @@
/**
* @file frd.h
* @brief Friend Services
*/
#pragma once
#include <3ds/mii.h>
#define FRIEND_SCREEN_NAME_SIZE 0xB ///< 11-byte UTF-16 screen name
#define FRIEND_COMMENT_SIZE 0x21 ///< 33-byte UTF-16 comment
#define FRIEND_LIST_SIZE 0x64 ///< 100 (Max number of friends)
#pragma pack(push, 1)
/// Friend key data
typedef struct
{
u32 principalId;
u32 padding;
u64 localFriendCode;
} FriendKey;
/// Friend Title data
typedef struct
{
u64 tid;
u32 version;
u32 unk;
} TitleData;
/// Friend profile data
typedef struct
{
u8 region; ///< The region code for the hardware.
u8 country; ///< Country code.
u8 area; ///< Area code.
u8 language; ///< Language code.
u8 platform; ///< Platform code.
u32 padding;
} FriendProfile;
/// Game Description structure
typedef struct
{
TitleData data;
u16 desc[128];
} GameDescription;
/// Friend Notification Event structure
typedef struct
{
u8 type;
u8 padding3[3];
u32 padding;
FriendKey key;
} NotificationEvent;
#pragma pack(pop)
/// Enum to use with FRD_GetNotificationEvent
typedef enum
{
USER_WENT_ONLINE = 1, ///< Self went online
USER_WENT_OFFLINE, ///< Self went offline
FRIEND_WENT_ONLINE, ///< Friend Went Online
FRIEND_UPDATED_PRESENCE, ///< Friend Presence changed
FRIEND_UPDATED_MII, ///< Friend Mii changed
FRIEND_UPDATED_PROFILE, ///< Friend Profile changed
FRIEND_WENT_OFFLINE, ///< Friend went offline
FRIEND_REGISTERED_USER, ///< Friend registered self as friend
FRIEND_SENT_INVITATION ///< Friend Sent invitation
} NotificationTypes;
/// Initializes FRD service.
Result frdInit(void);
/// Exists FRD.
void frdExit(void);
/// Get FRD handle.
Handle *frdGetSessionHandle(void);
/**
* @brief Gets the login status of the current user.
* @param state Pointer to write the current user's login status to.
*/
Result FRDU_HasLoggedIn(bool *state);
/**
* @brief Gets the online status of the current user.
* @param state Pointer to write the current user's online status to.
*/
Result FRDU_IsOnline(bool *state);
/// Logs out of Nintendo's friend server.
Result FRD_Logout(void);
/**
* @brief Log in to Nintendo's friend server.
* @param event Event to signal when Login is done.
*/
Result FRD_Login(Handle event);
/**
* @brief Gets the current user's friend key.
* @param key Pointer to write the current user's friend key to.
*/
Result FRD_GetMyFriendKey(FriendKey *key);
/**
* @brief Gets the current user's privacy information.
* @param isPublicMode Determines whether friends are notified of the current user's online status.
* @param isShowGameName Determines whether friends are notified of the application that the current user is running.
* @param isShowPlayedGame Determiens whether to display the current user's game history.
*/
Result FRD_GetMyPreference(bool *isPublicMode, bool *isShowGameName, bool *isShowPlayedGame);
/**
* @brief Gets the current user's profile information.
* @param profile Pointer to write the current user's profile information to.
*/
Result FRD_GetMyProfile(FriendProfile *profile);
/**
* @brief Gets the current user's screen name.
* @param name Pointer to write the current user's screen name to.
* @param max_size Max size of the screen name.
*/
Result FRD_GetMyScreenName(char *name, size_t max_size);
/**
* @brief Gets the current user's Mii data.
* @param mii Pointer to write the current user's mii data to.
*/
Result FRD_GetMyMii(MiiData *mii);
/**
* @brief Gets the current user's playing game.
* @param titleId Pointer to write the current user's playing game to.
*/
Result FRD_GetMyPlayingGame(u64 *titleId);
/**
* @brief Gets the current user's favourite game.
* @param titleId Pointer to write the title ID of current user's favourite game to.
*/
Result FRD_GetMyFavoriteGame(u64 *titleId);
/**
* @brief Gets the current user's comment on their friend profile.
* @param comment Pointer to write the current user's comment to.
* @param max_size Max size of the comment.
*/
Result FRD_GetMyComment(char *comment, size_t max_size);
/**
* @brief Gets the current user's friend key list.
* @param friendKeyList Pointer to write the friend key list to.
* @param num Stores the number of friend keys obtained.
* @param offset The index of the friend key to start with.
* @param size Size of the friend key list. (FRIEND_LIST_SIZE)
*/
Result FRD_GetFriendKeyList(FriendKey *friendKeyList, u32 *num, u32 offset, u32 size);
/**
* @brief Gets the current user's friends' Mii data.
* @param miiDataList Pointer to write Mii data to.
* @param friendKeyList Pointer to FriendKeys.
* @param size Number of Friendkeys.
*/
Result FRD_GetFriendMii(MiiData *miiDataList, const FriendKey *friendKeyList, size_t size);
/**
* @brief Get the current user's friends' profile data.
* @param profile Pointer to write profile data to.
* @param friendKeyList Pointer to FriendKeys.
* @param size Number of FriendKeys.
*/
Result FRD_GetFriendProfile(FriendProfile *profile, const FriendKey *friendKeyList, size_t size);
/**
* @brief Get the current user's friends' playing game.
* @param desc Pointer to write Game Description data to.
* @param friendKeyList Pointer to FriendKeys,
* @param size Number Of FriendKeys.
*/
Result FRD_GetFriendPlayingGame(GameDescription *desc, const FriendKey *friendKeyList, size_t size);
/**
* @brief Get the current user's friends' favourite game.
* @param desc Pointer to write Game Description data to.
* @param friendKeyList Pointer to FriendKeys,
* @param count Number Of FriendKeys.
*/
Result FRD_GetFriendFavouriteGame(GameDescription *desc, const FriendKey *friendKeyList, u32 count);
/**
* @brief Gets whether a friend key is included in the current user's friend list.
* @param friendKeyList Pointer to a list of friend keys.
* @param isFromList Pointer to a write the friendship status to.
*/
Result FRD_IsInFriendList(FriendKey *friendKeyList, bool *isFromList);
/**
* @brief Updates the game mode description string.
* @param desc Pointer to write the game mode description to.
*/
Result FRD_UpdateGameModeDescription(const char *desc);
/**
* @brief Event which is signaled when friend login states change.
* @param event event which will be signaled.
*/
Result FRD_AttachToEventNotification(Handle event);
/**
* @brief Get Latest Event Notification
* @param event Pointer to write recieved notification event struct to.
* @param count Number of events
* @param recievedNotifCount Number of notification reccieved.
*/
Result FRD_GetEventNotification(NotificationEvent *event, u32 count, u32 *recievedNotifCount);
/**
* @brief Returns the friend code using the given principal ID.
* @param principalId The principal ID being used.
* @param friendCode Pointer to write the friend code to.
*/
Result FRD_PrincipalIdToFriendCode(u32 principalId, u64 *friendCode);
/**
* @brief Returns the principal ID using the given friend code.
* @param friendCode The friend code being used.
* @param principalId Pointer to write the principal ID to.
*/
Result FRD_FriendCodeToPrincipalId(u64 friendCode, u32 *principalId);
/**
* @brief Checks if the friend code is valid.
* @param friendCode The friend code being used.
* @param isValid Pointer to write the validity of the friend code to.
*/
Result FRD_IsValidFriendCode(u64 friendCode, bool *isValid);
/**
* @brief Sets the Friend API to use a specific SDK version.
* @param sdkVer The SDK version needed to be used.
*/
Result FRD_SetClientSdkVersion(u32 sdkVer);
/**
* @brief Add a Friend online.
* @param event Event signaled when friend is registered.
* @param principalId PrincipalId of the friend to add.
*/
Result FRD_AddFriendOnline(Handle event, u32 principalId);
/**
* @brief Remove a Friend.
* @param principalId PrinipalId of the friend code to remove.
* @param localFriendCode LocalFriendCode of the friend code to remove.
*/
Result FRD_RemoveFriend(u32 principalId, u64 localFriendCode);

1089
.vscode/dummyinclude/3ds/services/fs.h vendored Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,613 @@
/**
* @file fspxi.h
* @brief Service interface for PxiFS services. This is normally not accessible to userland apps. https://3dbrew.org/wiki/Filesystem_services_PXI
*/
#pragma once
#include <3ds/services/fs.h>
#include <3ds/types.h>
typedef u64 FSPXI_Archive;
typedef u64 FSPXI_File;
typedef u64 FSPXI_Directory;
/**
* @brief Opens a file.
* @param out Pointer to output the file handle to.
* @param archive Archive containing the file.
* @param path Path of the file.
* @param flags Flags to open the file with.
* @param attributes Attributes of the file.
*/
Result FSPXI_OpenFile(Handle serviceHandle, FSPXI_File* out, FSPXI_Archive archive, FS_Path path, u32 flags, u32 attributes);
/**
* @brief Deletes a file.
* @param archive Archive containing the file.
* @param path Path of the file.
*/
Result FSPXI_DeleteFile(Handle serviceHandle, FSPXI_Archive archive, FS_Path path);
/**
* @brief Renames a file.
* @param srcArchive Archive containing the source file.
* @param srcPath Path of the source file.
* @param dstArchive Archive containing the destination file.
* @param dstPath Path of the destination file.
*/
Result FSPXI_RenameFile(Handle serviceHandle, FSPXI_Archive srcArchive, FS_Path srcPath, FSPXI_Archive dstArchive, FS_Path dstPath);
/**
* @brief Deletes a directory.
* @param archive Archive containing the directory.
* @param path Path of the directory.
*/
Result FSPXI_DeleteDirectory(Handle serviceHandle, FSPXI_Archive archive, FS_Path path);
/**
* @brief Creates a file.
* @param archive Archive to create the file in.
* @param path Path of the file.
* @param attributes Attributes of the file.
* @param size Size of the file.
*/
Result FSPXI_CreateFile(Handle serviceHandle, FSPXI_Archive archive, FS_Path path, u32 attributes, u64 fileSize);
/**
* @brief Creates a directory.
* @param archive Archive to create the directory in.
* @param path Path of the directory.
* @param attributes Attributes of the directory.
*/
Result FSPXI_CreateDirectory(Handle serviceHandle, FSPXI_Archive archive, FS_Path path, u32 attributes);
/**
* @brief Renames a directory.
* @param srcArchive Archive containing the source directory.
* @param srcPath Path of the source directory.
* @param dstArchive Archive containing the destination directory.
* @param dstPath Path of the destination directory.
*/
Result FSPXI_RenameDirectory(Handle serviceHandle, FSPXI_Archive srcArchive, FS_Path srcPath, FSPXI_Archive dstArchive, FS_Path dstPath);
/**
* @brief Opens a directory.
* @param out Pointer to output the directory handle to.
* @param archive Archive containing the directory.
* @param path Path of the directory.
*/
Result FSPXI_OpenDirectory(Handle serviceHandle, FSPXI_Directory* out, FSPXI_Archive archive, FS_Path path);
/**
* @brief Reads from a file.
* @param file File to read from.
* @param bytesRead Pointer to output the number of read bytes to.
* @param offset Offset to read from.
* @param buffer Buffer to read to.
* @param size Size of the buffer.
*/
Result FSPXI_ReadFile(Handle serviceHandle, FSPXI_File file, u32* bytesRead, u64 offset, void* buffer, u32 size);
/**
* @brief Calculate SHA256 of a file.
* @param file File to calculate the hash of.
* @param buffer Buffer to output the hash to.
* @param size Size of the buffer.
*/
Result FSPXI_CalculateFileHashSHA256(Handle serviceHandle, FSPXI_File file, void* buffer, u32 size);
/**
* @brief Writes to a file.
* @param file File to write to.
* @param bytesWritten Pointer to output the number of bytes written to.
* @param offset Offset to write to.
* @param buffer Buffer to write from.
* @param size Size of the buffer.
* @param flags Flags to use when writing.
*/
Result FSPXI_WriteFile(Handle serviceHandle, FSPXI_File file, u32* bytesWritten, u64 offset, const void* buffer, u32 size, u32 flags);
/**
* @brief Calculates the MAC used in a DISA/DIFF header?
* @param file Unsure
* @param inBuffer 0x100-byte DISA/DIFF input buffer.
* @param inSize Size of inBuffer.
* @param outBuffer Buffer to write MAC to.
* @param outSize Size of outBuffer.
*/
Result FSPXI_CalcSavegameMAC(Handle serviceHandle, FSPXI_File file, const void* inBuffer, u32 inSize, void* outBuffer, u32 outSize);
/**
* @brief Get size of a file
* @param file File to get the size of.
* @param size Pointer to output size to.
*/
Result FSPXI_GetFileSize(Handle serviceHandle, FSPXI_File file, u64* size);
/**
* @brief Set size of a file
* @param file File to set the size of
* @param size Size to set the file to
*/
Result FSPXI_SetFileSize(Handle serviceHandle, FSPXI_File file, u64 size);
/**
* @brief Close a file
* @param file File to close
*/
Result FSPXI_CloseFile(Handle serviceHandle, FSPXI_File file);
/**
* @brief Reads one or more directory entries.
* @param directory Directory to read from.
* @param entriesRead Pointer to output the number of entries read to.
* @param entryCount Number of entries to read.
* @param entryOut Pointer to output directory entries to.
*/
Result FSPXI_ReadDirectory(Handle serviceHandle, FSPXI_Directory directory, u32* entriesRead, u32 entryCount, FS_DirectoryEntry* entries);
/**
* @brief Close a directory
* @param directory Directory to close.
*/
Result FSPXI_CloseDirectory(Handle serviceHandle, FSPXI_Directory directory);
/**
* @brief Opens an archive.
* @param archive Pointer to output the opened archive to.
* @param id ID of the archive.
* @param path Path of the archive.
*/
Result FSPXI_OpenArchive(Handle serviceHandle, FSPXI_Archive* archive, FS_ArchiveID archiveID, FS_Path path);
/**
* @brief Checks if the archive contains a file at path.
* @param archive Archive to check.
* @param out Pointer to output existence to.
* @param path Path to check for file
*/
Result FSPXI_HasFile(Handle serviceHandle, FSPXI_Archive archive, bool* out, FS_Path path);
/**
* @brief Checks if the archive contains a directory at path.
* @param archive Archive to check.
* @param out Pointer to output existence to.
* @param path Path to check for directory
*/
Result FSPXI_HasDirectory(Handle serviceHandle, FSPXI_Archive archive, bool* out, FS_Path path);
/**
* @brief Commits an archive's save data.
* @param archive Archive to commit.
* @param id Archive action sent by FSUSER_ControlArchive. Must not be 0 or 0x789D
* @remark Unsure why id is sent. This appears to be the default action for FSUSER_ControlArchive, with every action other than 0 and 0x789D being sent to this command.
*/
Result FSPXI_CommitSaveData(Handle serviceHandle, FSPXI_Archive archive, u32 id);
/**
* @brief Close an archive
* @param archive Archive to close.
*/
Result FSPXI_CloseArchive(Handle serviceHandle, FSPXI_Archive archive);
/**
* @brief Unknown 0x17. Appears to be an "is archive handle valid" command?
* @param archive Archive handle to check validity of.
* @param out Pointer to output validity to.
*/
Result FSPXI_Unknown0x17(Handle serviceHandle, FSPXI_Archive archive, bool* out);
/**
* @brief Gets the inserted card type.
* @param out Pointer to output the card type to.
*/
Result FSPXI_GetCardType(Handle serviceHandle, FS_CardType* out);
/**
* @brief Gets the SDMC archive resource information.
* @param out Pointer to output the archive resource information to.
*/
Result FSPXI_GetSdmcArchiveResource(Handle serviceHandle, FS_ArchiveResource* out);
/**
* @brief Gets the NAND archive resource information.
* @param out Pointer to output the archive resource information to.
*/
Result FSPXI_GetNandArchiveResource(Handle serviceHandle, FS_ArchiveResource* out);
/**
* @brief Gets the error code from the SDMC FatFS driver
* @param out Pointer to output the error code to
*/
Result FSPXI_GetSdmcFatFsError(Handle serviceHandle, u32* out);
/**
* @brief Gets whether PXIFS0 detects the SD
* @param out Pointer to output the detection status to
*/
Result FSPXI_IsSdmcDetected(Handle serviceHandle, bool* out);
/**
* @brief Gets whether PXIFS0 can write to the SD
* @param out Pointer to output the writable status to
*/
Result FSPXI_IsSdmcWritable(Handle serviceHandle, bool* out);
/**
* @brief Gets the SDMC CID
* @param out Buffer to output the CID to.
* @param size Size of buffer.
*/
Result FSPXI_GetSdmcCid(Handle serviceHandle, void* out, u32 size);
/**
* @brief Gets the NAND CID
* @param out Buffer to output the CID to.
* @param size Size of buffer.
*/
Result FSPXI_GetNandCid(Handle serviceHandle, void* out, u32 size);
/**
* @brief Gets the SDMC speed info
* @param out Buffer to output the speed info to.
*/
Result FSPXI_GetSdmcSpeedInfo(Handle serviceHandle, FS_SdMmcSpeedInfo* out);
/**
* @brief Gets the NAND speed info
* @param out Buffer to output the speed info to.
*/
Result FSPXI_GetNandSpeedInfo(Handle serviceHandle, FS_SdMmcSpeedInfo* out);
/**
* @brief Gets the SDMC log
* @param out Buffer to output the log to.
* @param size Size of buffer.
*/
Result FSPXI_GetSdmcLog(Handle serviceHandle, void* out, u32 size);
/**
* @brief Gets the NAND log
* @param out Buffer to output the log to.
* @param size Size of buffer.
*/
Result FSPXI_GetNandLog(Handle serviceHandle, void* out, u32 size);
/// Clears the SDMC log
Result FSPXI_ClearSdmcLog(Handle serviceHandle);
/// Clears the NAND log
Result FSPXI_ClearNandLog(Handle serviceHandle);
/**
* @brief Gets whether a card is inserted.
* @param inserted Pointer to output the insertion status to.
*/
Result FSPXI_CardSlotIsInserted(Handle serviceHandle, bool* inserted);
/**
* @brief Powers on the card slot.
* @param status Pointer to output the power status to.
*/
Result FSPXI_CardSlotPowerOn(Handle serviceHandle, bool* status);
/**
* @brief Powers off the card slot.
* @param status Pointer to output the power status to.
*/
Result FSPXI_CardSlotPowerOff(Handle serviceHandle, bool* status);
/**
* @brief Gets the card's power status.
* @param status Pointer to output the power status to.
*/
Result FSPXI_CardSlotGetCardIFPowerStatus(Handle serviceHandle, bool* status);
/**
* @brief Executes a CARDNOR direct command.
* @param commandId ID of the command.
*/
Result FSPXI_CardNorDirectCommand(Handle serviceHandle, u8 commandId);
/**
* @brief Executes a CARDNOR direct command with an address.
* @param commandId ID of the command.
* @param address Address to provide.
*/
Result FSPXI_CardNorDirectCommandWithAddress(Handle serviceHandle, u8 commandId, u32 address);
/**
* @brief Executes a CARDNOR direct read.
* @param commandId ID of the command.
* @param size Size of the output buffer.
* @param output Output buffer.
*/
Result FSPXI_CardNorDirectRead(Handle serviceHandle, u8 commandId, u32 size, void* output);
/**
* @brief Executes a CARDNOR direct read with an address.
* @param commandId ID of the command.
* @param address Address to provide.
* @param size Size of the output buffer.
* @param output Output buffer.
*/
Result FSPXI_CardNorDirectReadWithAddress(Handle serviceHandle, u8 commandId, u32 address, u32 size, void* output);
/**
* @brief Executes a CARDNOR direct write.
* @param commandId ID of the command.
* @param size Size of the input buffer.
* @param output Input buffer.
* @remark Stubbed in latest firmware, since ?.?.?
*/
Result FSPXI_CardNorDirectWrite(Handle serviceHandle, u8 commandId, u32 size, const void* input);
/**
* @brief Executes a CARDNOR direct write with an address.
* @param commandId ID of the command.
* @param address Address to provide.
* @param size Size of the input buffer.
* @param input Input buffer.
*/
Result FSPXI_CardNorDirectWriteWithAddress(Handle serviceHandle, u8 commandId, u32 address, u32 size, const void* input);
/**
* @brief Executes a CARDNOR 4xIO direct read.
* @param commandId ID of the command.
* @param address Address to provide.
* @param size Size of the output buffer.
* @param output Output buffer.
*/
Result FSPXI_CardNorDirectRead_4xIO(Handle serviceHandle, u8 commandId, u32 address, u32 size, void* output);
/**
* @brief Executes a CARDNOR direct CPU write without verify.
* @param address Address to provide.
* @param size Size of the input buffer.
* @param output Input buffer.
*/
Result FSPXI_CardNorDirectCpuWriteWithoutVerify(Handle serviceHandle, u32 address, u32 size, const void* input);
/**
* @brief Executes a CARDNOR direct sector erase without verify.
* @param address Address to provide.
*/
Result FSPXI_CardNorDirectSectorEraseWithoutVerify(Handle serviceHandle, u32 address);
/**
* @brief Gets an NCCH's product info
* @param info Pointer to output the product info to.
* @param archive Open NCCH content archive
*/
Result FSPXI_GetProductInfo(Handle serviceHandle, FS_ProductInfo* info, FSPXI_Archive archive);
/**
* @brief Sets the CARDSPI baud rate.
* @param baudRate Baud rate to set.
*/
Result FSPXI_SetCardSpiBaudrate(Handle serviceHandle, FS_CardSpiBaudRate baudRate);
/**
* @brief Sets the CARDSPI bus mode.
* @param busMode Bus mode to set.
*/
Result FSPXI_SetCardSpiBusMode(Handle serviceHandle, FS_CardSpiBusMode busMode);
/**
* @brief Sends initialization info to ARM9
* @param unk FS sends *(0x1FF81086)
*/
Result FSPXI_SendInitializeInfoTo9(Handle serviceHandle, u8 unk);
/**
* @brief Creates ext save data.
* @param info Info of the save data.
*/
Result FSPXI_CreateExtSaveData(Handle serviceHandle, FS_ExtSaveDataInfo info);
/**
* @brief Deletes ext save data.
* @param info Info of the save data.
*/
Result FSPXI_DeleteExtSaveData(Handle serviceHandle, FS_ExtSaveDataInfo info);
/**
* @brief Enumerates ext save data.
* @param idsWritten Pointer to output the number of IDs written to.
* @param idsSize Size of the IDs buffer.
* @param mediaType Media type to enumerate over.
* @param idSize Size of each ID element.
* @param shared Whether to enumerate shared ext save data.
* @param ids Pointer to output IDs to.
*/
Result FSPXI_EnumerateExtSaveData(Handle serviceHandle, u32* idsWritten, u32 idsSize, FS_MediaType mediaType, u32 idSize, bool shared, u8* ids);
/**
* @brief Gets a special content's index.
* @param index Pointer to output the index to.
* @param mediaType Media type of the special content.
* @param programId Program ID owning the special content.
* @param type Type of special content.
*/
Result FSPXI_GetSpecialContentIndex(Handle serviceHandle, u16* index, FS_MediaType mediaType, u64 programId, FS_SpecialContentType type);
/**
* @brief Gets the legacy ROM header of a program.
* @param mediaType Media type of the program.
* @param programId ID of the program.
* @param header Pointer to output the legacy ROM header to. (size = 0x3B4)
*/
Result FSPXI_GetLegacyRomHeader(Handle serviceHandle, FS_MediaType mediaType, u64 programId, void* header);
/**
* @brief Gets the legacy banner data of a program.
* @param mediaType Media type of the program.
* @param programId ID of the program.
* @param banner Pointer to output the legacy banner data to. (size = 0x23C0)
* @param unk Unknown. Always 1?
*/
Result FSPXI_GetLegacyBannerData(Handle serviceHandle, FS_MediaType mediaType, u64 programId, void* banner, u8 unk);
/**
* @brief Formats the CARDNOR device.
* @param unk Unknown. Transaction?
*/
Result FSPXI_FormatCardNorDevice(Handle serviceHandle, u32 unk);
/// Deletes the 3DS SDMC root.
Result FSPXI_DeleteSdmcRoot(Handle serviceHandle);
/// Deletes all ext save data on the NAND.
Result FSPXI_DeleteAllExtSaveDataOnNand(Handle serviceHandle);
/// Initializes the CTR file system.
Result FSPXI_InitializeCtrFilesystem(Handle serviceHandle);
/// Creates the FS seed.
Result FSPXI_CreateSeed(Handle serviceHandle);
/**
* @brief Gets the CTR SDMC root path.
* @param out Pointer to output the root path to.
* @param length Length of the output buffer in bytes.
*/
Result FSPXI_GetSdmcCtrRootPath(Handle serviceHandle, u16* out, u32 length);
/**
* @brief Gets an archive's resource information.
* @param archiveResource Pointer to output the archive resource information to.
* @param mediaType System media type to check.
*/
Result FSPXI_GetArchiveResource(Handle serviceHandle, FS_ArchiveResource* archiveResource, FS_SystemMediaType mediaType);
/**
* @brief Exports the integrity verification seed.
* @param seed Pointer to output the seed to.
*/
Result FSPXI_ExportIntegrityVerificationSeed(Handle serviceHandle, FS_IntegrityVerificationSeed* seed);
/**
* @brief Imports an integrity verification seed.
* @param seed Seed to import.
*/
Result FSPXI_ImportIntegrityVerificationSeed(Handle serviceHandle, const FS_IntegrityVerificationSeed* seed);
/**
* @brief Gets the legacy sub banner data of a program.
* @param bannerSize Size of the banner.
* @param mediaType Media type of the program.
* @param programId ID of the program.
* @param header Pointer to output the legacy sub banner data to.
*/
Result FSPXI_GetLegacySubBannerData(Handle serviceHandle, u32 bannerSize, FS_MediaType mediaType, u64 programId, void* banner);
/**
* @brief Generates random bytes. Uses same code as PSPXI_GenerateRandomBytes
* @param buf Buffer to output random bytes to.
* @param size Size of buffer.
*/
Result FSPXI_GenerateRandomBytes(Handle serviceHandle, void* buffer, u32 size);
/**
* @brief Gets the last modified time of a file in an archive.
* @param archive The archive that contains the file.
* @param out The pointer to write the timestamp to.
* @param path The UTF-16 path of the file.
* @param size The size of the path.
*/
Result FSPXI_GetFileLastModified(Handle serviceHandle, FSPXI_Archive archive, u64* out, const u16* path, u32 size);
/**
* @brief Reads from a special file.
* @param bytesRead Pointer to output the number of bytes read to.
* @param fileOffset Offset of the file.
* @param size Size of the buffer.
* @param data Buffer to read to.
*/
Result FSPXI_ReadSpecialFile(Handle serviceHandle, u32* bytesRead, u64 fileOffset, u32 size, void* data);
/**
* @brief Gets the size of a special file.
* @param fileSize Pointer to output the size to.
*/
Result FSPXI_GetSpecialFileSize(Handle serviceHandle, u64* fileSize);
/**
* @brief Initiates a device move as the source device.
* @param context Pointer to output the context to.
*/
Result FSPXI_StartDeviceMoveAsSource(Handle serviceHandle, FS_DeviceMoveContext* context);
/**
* @brief Initiates a device move as the destination device.
* @param context Context to use.
* @param clear Whether to clear the device's data first.
*/
Result FSPXI_StartDeviceMoveAsDestination(Handle serviceHandle, FS_DeviceMoveContext context, bool clear);
/**
* @brief Reads data and stores SHA256 hashes of blocks
* @param file File to read from.
* @param bytesRead Pointer to output the number of read bytes to.
* @param offset Offset to read from.
* @param readBuffer Pointer to store read data in.
* @param readBufferSize Size of readBuffer.
* @param hashtable Pointer to store SHA256 hashes in.
* @param hashtableSize Size of hashtable.
* @param unk Unknown. Always 0x00001000? Possibly block size?
*/
Result FSPXI_ReadFileSHA256(Handle serviceHandle, FSPXI_File file, u32* bytesRead, u64 offset, void* readBuffer, u32 readBufferSize, void* hashtable, u32 hashtableSize, u32 unk);
/**
* @brief Assumedly writes data and stores SHA256 hashes of blocks
* @param file File to write to.
* @param bytesWritten Pointer to output the number of written bytes to.
* @param offset Offset to write to.
* @param writeBuffer Buffer to write from.
* @param writeBufferSize Size of writeBuffer.
* @param hashtable Pointer to store SHA256 hashes in.
* @param hashtableSize Size of hashtable
* @param unk1 Unknown. Might match with ReadFileSHA256's unknown?
* @param unk2 Unknown. Might match with ReadFileSHA256's unknown?
*/
Result FSPXI_WriteFileSHA256(Handle serviceHandle, FSPXI_File file, u32* bytesWritten, u64 offset, const void* writeBuffer, u32 writeBufferSize, void* hashtable, u32 hashtableSize, u32 unk1, u32 unk2);
/**
* @brief Configures CTRCARD latency emulation.
* @param latency Latency to apply.
*/
Result FSPXI_SetCtrCardLatencyParameter(Handle serviceHandle, u64 latency);
/**
* @brief Sets the file system priority.
* @param priority Priority to set.
*/
Result FSPXI_SetPriority(Handle serviceHandle, u32 priority);
/**
* @brief Toggles cleaning up invalid save data.
* @param enable Whether to enable cleaning up invalid save data.
*/
Result FSPXI_SwitchCleanupInvalidSaveData(Handle serviceHandle, bool enable);
/**
* @brief Enumerates system save data.
* @param idsWritten Pointer to output the number of IDs written to.
* @param idsSize Size of the IDs buffer.
* @param ids Pointer to output IDs to.
*/
Result FSPXI_EnumerateSystemSaveData(Handle serviceHandle, u32* idsWritten, u32 idsSize, u32* ids);
/**
* @brief Reads the NAND report.
* @param unk Unknown
* @param buffer Buffer to write the report to.
* @param size Size of buffer
*/
Result FSPXI_ReadNandReport(Handle serviceHandle, void* buffer, u32 size, u32 unk);
/**
* @brief Unknown command 0x56
* @remark Called by FSUSER_ControlArchive with ArchiveAction 0x789D
*/
Result FSPXI_Unknown0x56(Handle serviceHandle, u32 out[4], FS_Archive archive, FS_Path path);

View file

@ -0,0 +1,63 @@
/**
* @file fsReg.h
* @brief Filesystem registry service
*/
#pragma once
#include <3ds/exheader.h>
#include <3ds/services/fs.h>
/// Initializes fs:REG.
Result fsRegInit(void);
/// Exits fs:REG.
void fsRegExit(void);
/**
* @brief Gets the current fs:REG session handle.
* @return The current fs:REG session handle.
*/
Handle *fsRegGetSessionHandle(void);
/**
* @brief Registers a program's storage information.
* @param pid The Process ID of the program.
* @param programHandle The program handle.
* @param programInfo Information about the program.
* @param storageInfo Storage information to register.
*/
Result FSREG_Register(u32 pid, u64 programHandle, const FS_ProgramInfo *programInfo, const ExHeader_Arm11StorageInfo *storageInfo);
/**
* @brief Unregisters a program's storage information.
* @param pid The Process ID of the program.
*/
Result FSREG_Unregister(u32 pid);
/**
* @brief Retrives the exheader information set(s) (SCI+ACI) about a program.
* @param exheaderInfos[out] Pointer to the output exheader information set(s).
* @param maxNumEntries The maximum number of entries.
* @param programHandle The program handle.
*/
Result FSREG_GetProgramInfo(ExHeader_Info *exheaderInfos, u32 maxNumEntries, u64 programHandle);
/**
* @brief Loads a program.
* @param programHandle[out] Pointer to the output the program handle to.
* @param programInfo Information about the program to load.
*/
Result FSREG_LoadProgram(u64 *programHandle, const FS_ProgramInfo *programInfo);
/**
* @brief Unloads a program.
* @param programHandle The program handle.
*/
Result FSREG_UnloadProgram(u64 programHandle);
/**
* @brief Checks if a program has been loaded by fs:REG.
* @param programHandle The program handle.
*/
Result FSREG_CheckHostLoadId(u64 programHandle);

View file

@ -0,0 +1,270 @@
/**
* @file gspgpu.h
* @brief GSPGPU service.
*/
#pragma once
#define GSP_SCREEN_TOP 0 ///< ID of the top screen.
#define GSP_SCREEN_BOTTOM 1 ///< ID of the bottom screen.
#define GSP_SCREEN_WIDTH 240 ///< Width of the top/bottom screens.
#define GSP_SCREEN_HEIGHT_TOP 400 ///< Height of the top screen.
#define GSP_SCREEN_HEIGHT_TOP_2X 800 ///< Height of the top screen (2x).
#define GSP_SCREEN_HEIGHT_BOTTOM 320 ///< Height of the bottom screen.
/// Framebuffer information.
typedef struct
{
u32 active_framebuf; ///< Active framebuffer. (0 = first, 1 = second)
u32 *framebuf0_vaddr; ///< Framebuffer virtual address, for the main screen this is the 3D left framebuffer.
u32 *framebuf1_vaddr; ///< For the main screen: 3D right framebuffer address.
u32 framebuf_widthbytesize; ///< Value for 0x1EF00X90, controls framebuffer width.
u32 format; ///< Framebuffer format, this u16 is written to the low u16 for LCD register 0x1EF00X70.
u32 framebuf_dispselect; ///< Value for 0x1EF00X78, controls which framebuffer is displayed.
u32 unk; ///< Unknown.
} GSPGPU_FramebufferInfo;
/// Framebuffer format.
typedef enum
{
GSP_RGBA8_OES=0, ///< RGBA8. (4 bytes)
GSP_BGR8_OES=1, ///< BGR8. (3 bytes)
GSP_RGB565_OES=2, ///< RGB565. (2 bytes)
GSP_RGB5_A1_OES=3, ///< RGB5A1. (2 bytes)
GSP_RGBA4_OES=4 ///< RGBA4. (2 bytes)
} GSPGPU_FramebufferFormat;
/// Capture info entry.
typedef struct
{
u32 *framebuf0_vaddr; ///< Left framebuffer.
u32 *framebuf1_vaddr; ///< Right framebuffer.
u32 format; ///< Framebuffer format.
u32 framebuf_widthbytesize; ///< Framebuffer pitch.
} GSPGPU_CaptureInfoEntry;
/// Capture info.
typedef struct
{
GSPGPU_CaptureInfoEntry screencapture[2]; ///< Capture info entries, one for each screen.
} GSPGPU_CaptureInfo;
/// GSPGPU events.
typedef enum
{
GSPGPU_EVENT_PSC0 = 0, ///< Memory fill completed.
GSPGPU_EVENT_PSC1, ///< TODO
GSPGPU_EVENT_VBlank0, ///< TODO
GSPGPU_EVENT_VBlank1, ///< TODO
GSPGPU_EVENT_PPF, ///< Display transfer finished.
GSPGPU_EVENT_P3D, ///< Command list processing finished.
GSPGPU_EVENT_DMA, ///< TODO
GSPGPU_EVENT_MAX, ///< Used to know how many events there are.
} GSPGPU_Event;
/**
* @brief Gets the number of bytes per pixel for the specified format.
* @param format See \ref GSPGPU_FramebufferFormat.
* @return Bytes per pixel.
*/
static inline unsigned gspGetBytesPerPixel(GSPGPU_FramebufferFormat format)
{
switch (format)
{
case GSP_RGBA8_OES:
return 4;
default:
case GSP_BGR8_OES:
return 3;
case GSP_RGB565_OES:
case GSP_RGB5_A1_OES:
case GSP_RGBA4_OES:
return 2;
}
}
/// Initializes GSPGPU.
Result gspInit(void);
/// Exits GSPGPU.
void gspExit(void);
/**
* @brief Gets a pointer to the current gsp::Gpu session handle.
* @return A pointer to the current gsp::Gpu session handle.
*/
Handle *gspGetSessionHandle(void);
/// Returns true if the application currently has GPU rights.
bool gspHasGpuRight(void);
/**
* @brief Presents a buffer to the specified screen.
* @param screen Screen ID (see \ref GSP_SCREEN_TOP and \ref GSP_SCREEN_BOTTOM)
* @param swap Specifies which set of framebuffer registers to configure and activate (0 or 1)
* @param fb_a Pointer to the framebuffer (in stereo mode: left eye)
* @param fb_b Pointer to the secondary framebuffer (only used in stereo mode for the right eye, otherwise pass the same as fb_a)
* @param stride Stride in bytes between scanlines
* @param mode Mode configuration to be written to LCD register
* @return true if a buffer had already been presented to the screen but not processed yet by GSP, false otherwise.
* @note The most recently presented buffer is processed and configured during the specified screen's next VBlank event.
*/
bool gspPresentBuffer(unsigned screen, unsigned swap, const void* fb_a, const void* fb_b, u32 stride, u32 mode);
/**
* @brief Returns true if a prior \ref gspPresentBuffer command is still pending to be processed by GSP.
* @param screen Screen ID (see \ref GSP_SCREEN_TOP and \ref GSP_SCREEN_BOTTOM)
*/
bool gspIsPresentPending(unsigned screen);
/**
* @brief Configures a callback to run when a GSPGPU event occurs.
* @param id ID of the event.
* @param cb Callback to run.
* @param data Data to be passed to the callback.
* @param oneShot When true, the callback is only executed once. When false, the callback is executed every time the event occurs.
*/
void gspSetEventCallback(GSPGPU_Event id, ThreadFunc cb, void* data, bool oneShot);
/**
* @brief Waits for a GSPGPU event to occur.
* @param id ID of the event.
* @param nextEvent Whether to discard the current event and wait for the next event.
*/
void gspWaitForEvent(GSPGPU_Event id, bool nextEvent);
/**
* @brief Waits for any GSPGPU event to occur.
* @return The ID of the event that occurred.
*
* The function returns immediately if there are unprocessed events at the time of call.
*/
GSPGPU_Event gspWaitForAnyEvent(void);
/// Waits for PSC0
#define gspWaitForPSC0() gspWaitForEvent(GSPGPU_EVENT_PSC0, false)
/// Waits for PSC1
#define gspWaitForPSC1() gspWaitForEvent(GSPGPU_EVENT_PSC1, false)
/// Waits for VBlank.
#define gspWaitForVBlank() gspWaitForVBlank0()
/// Waits for VBlank0.
#define gspWaitForVBlank0() gspWaitForEvent(GSPGPU_EVENT_VBlank0, true)
/// Waits for VBlank1.
#define gspWaitForVBlank1() gspWaitForEvent(GSPGPU_EVENT_VBlank1, true)
/// Waits for PPF.
#define gspWaitForPPF() gspWaitForEvent(GSPGPU_EVENT_PPF, false)
/// Waits for P3D.
#define gspWaitForP3D() gspWaitForEvent(GSPGPU_EVENT_P3D, false)
/// Waits for DMA.
#define gspWaitForDMA() gspWaitForEvent(GSPGPU_EVENT_DMA, false)
/**
* @brief Submits a GX command.
* @param gxCommand GX command to execute.
*/
Result gspSubmitGxCommand(const u32 gxCommand[0x8]);
/**
* @brief Acquires GPU rights.
* @param flags Flags to acquire with.
*/
Result GSPGPU_AcquireRight(u8 flags);
/// Releases GPU rights.
Result GSPGPU_ReleaseRight(void);
/**
* @brief Retrieves display capture info.
* @param captureinfo Pointer to output capture info to.
*/
Result GSPGPU_ImportDisplayCaptureInfo(GSPGPU_CaptureInfo* captureinfo);
/// Saves the VRAM sys area.
Result GSPGPU_SaveVramSysArea(void);
/// Resets the GPU
Result GSPGPU_ResetGpuCore(void);
/// Restores the VRAM sys area.
Result GSPGPU_RestoreVramSysArea(void);
/**
* @brief Sets whether to force the LCD to black.
* @param flags Whether to force the LCD to black. (0 = no, non-zero = yes)
*/
Result GSPGPU_SetLcdForceBlack(u8 flags);
/**
* @brief Updates a screen's framebuffer state.
* @param screenid ID of the screen to update.
* @param framebufinfo Framebuffer information to update with.
*/
Result GSPGPU_SetBufferSwap(u32 screenid, const GSPGPU_FramebufferInfo* framebufinfo);
/**
* @brief Flushes memory from the data cache.
* @param adr Address to flush.
* @param size Size of the memory to flush.
*/
Result GSPGPU_FlushDataCache(const void* adr, u32 size);
/**
* @brief Invalidates memory in the data cache.
* @param adr Address to invalidate.
* @param size Size of the memory to invalidate.
*/
Result GSPGPU_InvalidateDataCache(const void* adr, u32 size);
/**
* @brief Writes to GPU hardware registers.
* @param regAddr Register address to write to.
* @param data Data to write.
* @param size Size of the data to write.
*/
Result GSPGPU_WriteHWRegs(u32 regAddr, const u32* data, u8 size);
/**
* @brief Writes to GPU hardware registers with a mask.
* @param regAddr Register address to write to.
* @param data Data to write.
* @param datasize Size of the data to write.
* @param maskdata Data of the mask.
* @param masksize Size of the mask.
*/
Result GSPGPU_WriteHWRegsWithMask(u32 regAddr, const u32* data, u8 datasize, const u32* maskdata, u8 masksize);
/**
* @brief Reads from GPU hardware registers.
* @param regAddr Register address to read from.
* @param data Buffer to read data to.
* @param size Size of the buffer.
*/
Result GSPGPU_ReadHWRegs(u32 regAddr, u32* data, u8 size);
/**
* @brief Registers the interrupt relay queue.
* @param eventHandle Handle of the GX command event.
* @param flags Flags to register with.
* @param outMemHandle Pointer to output the shared memory handle to.
* @param threadID Pointer to output the GSP thread ID to.
*/
Result GSPGPU_RegisterInterruptRelayQueue(Handle eventHandle, u32 flags, Handle* outMemHandle, u8* threadID);
/// Unregisters the interrupt relay queue.
Result GSPGPU_UnregisterInterruptRelayQueue(void);
/// Triggers a handling of commands written to shared memory.
Result GSPGPU_TriggerCmdReqQueue(void);
/**
* @brief Sets 3D_LEDSTATE to the input state value.
* @param disable False = 3D LED enable, true = 3D LED disable.
*/
Result GSPGPU_SetLedForceOff(bool disable);

View file

@ -0,0 +1,78 @@
/**
* @file gsplcd.h
* @brief GSPLCD service.
*/
#pragma once
#include <3ds/types.h>
#include <3ds/services/gspgpu.h>
/// LCD screens.
enum
{
GSPLCD_SCREEN_TOP = BIT(GSP_SCREEN_TOP), ///< Top screen.
GSPLCD_SCREEN_BOTTOM = BIT(GSP_SCREEN_BOTTOM), ///< Bottom screen.
GSPLCD_SCREEN_BOTH = GSPLCD_SCREEN_TOP | GSPLCD_SCREEN_BOTTOM, ///< Both screens.
};
/// Initializes GSPLCD.
Result gspLcdInit(void);
/// Exits GSPLCD.
void gspLcdExit(void);
/**
* @brief Gets a pointer to the current gsp::Lcd session handle.
* @return A pointer to the current gsp::Lcd session handle.
*/
Handle *gspLcdGetSessionHandle(void);
/// Powers on both backlights.
Result GSPLCD_PowerOnAllBacklights(void);
/// Powers off both backlights.
Result GSPLCD_PowerOffAllBacklights(void);
/**
* @brief Powers on the backlight.
* @param screen Screen to power on.
*/
Result GSPLCD_PowerOnBacklight(u32 screen);
/**
* @brief Powers off the backlight.
* @param screen Screen to power off.
*/
Result GSPLCD_PowerOffBacklight(u32 screen);
/**
* @brief Sets 3D_LEDSTATE to the input state value.
* @param disable False = 3D LED enable, true = 3D LED disable.
*/
Result GSPLCD_SetLedForceOff(bool disable);
/**
* @brief Gets the LCD screens' vendors. Stubbed on old 3ds.
* @param vendor Pointer to output the screen vendors to.
*/
Result GSPLCD_GetVendors(u8 *vendors);
/**
* @brief Gets the LCD screens' brightness. Stubbed on old 3ds.
* @param screen Screen to get the brightness value of.
* @param brightness Brightness value returned.
*/
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness);
/**
* @brief Sets the LCD screens' brightness.
* @param screen Screen to set the brightness value of.
* @param brightness Brightness value set.
*/
Result GSPLCD_SetBrightness(u32 screen, u32 brightness);
/**
* @brief Sets the LCD screens' raw brightness.
* @param screen Screen to set the brightness value of.
* @param brightness Brightness value set.
*/
Result GSPLCD_SetBrightnessRaw(u32 screen, u32 brightness);

217
.vscode/dummyinclude/3ds/services/hid.h vendored Normal file
View file

@ -0,0 +1,217 @@
/**
* @file hid.h
* @brief HID service.
*/
#pragma once
//See also: http://3dbrew.org/wiki/HID_Services http://3dbrew.org/wiki/HID_Shared_Memory
/// Key values.
enum
{
KEY_A = BIT(0), ///< A
KEY_B = BIT(1), ///< B
KEY_SELECT = BIT(2), ///< Select
KEY_START = BIT(3), ///< Start
KEY_DRIGHT = BIT(4), ///< D-Pad Right
KEY_DLEFT = BIT(5), ///< D-Pad Left
KEY_DUP = BIT(6), ///< D-Pad Up
KEY_DDOWN = BIT(7), ///< D-Pad Down
KEY_R = BIT(8), ///< R
KEY_L = BIT(9), ///< L
KEY_X = BIT(10), ///< X
KEY_Y = BIT(11), ///< Y
KEY_ZL = BIT(14), ///< ZL (New 3DS only)
KEY_ZR = BIT(15), ///< ZR (New 3DS only)
KEY_TOUCH = BIT(20), ///< Touch (Not actually provided by HID)
KEY_CSTICK_RIGHT = BIT(24), ///< C-Stick Right (New 3DS only)
KEY_CSTICK_LEFT = BIT(25), ///< C-Stick Left (New 3DS only)
KEY_CSTICK_UP = BIT(26), ///< C-Stick Up (New 3DS only)
KEY_CSTICK_DOWN = BIT(27), ///< C-Stick Down (New 3DS only)
KEY_CPAD_RIGHT = BIT(28), ///< Circle Pad Right
KEY_CPAD_LEFT = BIT(29), ///< Circle Pad Left
KEY_CPAD_UP = BIT(30), ///< Circle Pad Up
KEY_CPAD_DOWN = BIT(31), ///< Circle Pad Down
// Generic catch-all directions
KEY_UP = KEY_DUP | KEY_CPAD_UP, ///< D-Pad Up or Circle Pad Up
KEY_DOWN = KEY_DDOWN | KEY_CPAD_DOWN, ///< D-Pad Down or Circle Pad Down
KEY_LEFT = KEY_DLEFT | KEY_CPAD_LEFT, ///< D-Pad Left or Circle Pad Left
KEY_RIGHT = KEY_DRIGHT | KEY_CPAD_RIGHT, ///< D-Pad Right or Circle Pad Right
};
/// Touch position.
typedef struct
{
u16 px; ///< Touch X
u16 py; ///< Touch Y
} touchPosition;
/// Circle Pad position.
typedef struct
{
s16 dx; ///< Pad X
s16 dy; ///< Pad Y
} circlePosition;
/// Accelerometer vector.
typedef struct
{
s16 x; ///< Accelerometer X
s16 y; ///< Accelerometer Y
s16 z; ///< Accelerometer Z
} accelVector;
/// Gyroscope angular rate.
typedef struct
{
s16 x; ///< Roll
s16 z; ///< Yaw
s16 y; ///< Pitch
} angularRate;
/// HID events.
typedef enum
{
HIDEVENT_PAD0 = 0, ///< Event signaled by HID-module, when the sharedmem+0(PAD/circle-pad)/+0xA8(touch-screen) region was updated.
HIDEVENT_PAD1, ///< Event signaled by HID-module, when the sharedmem+0(PAD/circle-pad)/+0xA8(touch-screen) region was updated.
HIDEVENT_Accel, ///< Event signaled by HID-module, when the sharedmem accelerometer state was updated.
HIDEVENT_Gyro, ///< Event signaled by HID-module, when the sharedmem gyroscope state was updated.
HIDEVENT_DebugPad, ///< Event signaled by HID-module, when the sharedmem DebugPad state was updated.
HIDEVENT_MAX, ///< Used to know how many events there are.
} HID_Event;
extern Handle hidMemHandle; ///< HID shared memory handle.
extern vu32* hidSharedMem; ///< HID shared memory.
/// Initializes HID.
Result hidInit(void);
/// Exits HID.
void hidExit(void);
/**
* @brief Sets the key repeat parameters for @ref hidKeysRepeat.
* @param delay Initial delay.
* @param interval Repeat interval.
*/
void hidSetRepeatParameters(u32 delay, u32 interval);
/// Scans HID for input data.
void hidScanInput(void);
/**
* @brief Returns a bitmask of held buttons.
* Individual buttons can be extracted using binary AND.
* @return 32-bit bitmask of held buttons (1+ frames).
*/
u32 hidKeysHeld(void);
/**
* @brief Returns a bitmask of newly pressed buttons, this frame.
* Individual buttons can be extracted using binary AND.
* @return 32-bit bitmask of newly pressed buttons.
*/
u32 hidKeysDown(void);
/**
* @brief Returns a bitmask of newly pressed or repeated buttons, this frame.
* Individual buttons can be extracted using binary AND.
* @return 32-bit bitmask of newly pressed or repeated buttons.
*/
u32 hidKeysDownRepeat(void);
/**
* @brief Returns a bitmask of newly released buttons, this frame.
* Individual buttons can be extracted using binary AND.
* @return 32-bit bitmask of newly released buttons.
*/
u32 hidKeysUp(void);
/**
* @brief Reads the current touch position.
* @param pos Pointer to output the touch position to.
*/
void hidTouchRead(touchPosition* pos);
/**
* @brief Reads the current circle pad position.
* @param pos Pointer to output the circle pad position to.
*/
void hidCircleRead(circlePosition* pos);
/**
* @brief Reads the current accelerometer data.
* @param vector Pointer to output the accelerometer data to.
*/
void hidAccelRead(accelVector* vector);
/**
* @brief Reads the current gyroscope data.
* @param rate Pointer to output the gyroscope data to.
*/
void hidGyroRead(angularRate* rate);
/**
* @brief Waits for an HID event.
* @param id ID of the event.
* @param nextEvent Whether to discard the current event and wait for the next event.
*/
void hidWaitForEvent(HID_Event id, bool nextEvent);
/**
* @brief Waits for any HID or IRRST event.
* @param nextEvents Whether to discard the current events and wait for the next events.
* @param cancelEvent Optional additional handle to wait on, otherwise 0.
* @param timeout Timeout.
*/
Result hidWaitForAnyEvent(bool nextEvents, Handle cancelEvent, s64 timeout);
/// Compatibility macro for hidScanInput.
#define scanKeys hidScanInput
/// Compatibility macro for hidKeysHeld.
#define keysHeld hidKeysHeld
/// Compatibility macro for hidKeysDown.
#define keysDown hidKeysDown
/// Compatibility macro for hidKeysUp.
#define keysUp hidKeysUp
/// Compatibility macro for hidTouchRead.
#define touchRead hidTouchRead
/// Compatibility macro for hidCircleRead.
#define circleRead hidCircleRead
/**
* @brief Gets the handles for HID operation.
* @param outMemHandle Pointer to output the shared memory handle to.
* @param eventpad0 Pointer to output the pad 0 event handle to.
* @param eventpad1 Pointer to output the pad 1 event handle to.
* @param eventaccel Pointer to output the accelerometer event handle to.
* @param eventgyro Pointer to output the gyroscope event handle to.
* @param eventdebugpad Pointer to output the debug pad event handle to.
*/
Result HIDUSER_GetHandles(Handle* outMemHandle, Handle *eventpad0, Handle *eventpad1, Handle *eventaccel, Handle *eventgyro, Handle *eventdebugpad);
/// Enables the accelerometer.
Result HIDUSER_EnableAccelerometer(void);
/// Disables the accelerometer.
Result HIDUSER_DisableAccelerometer(void);
/// Enables the gyroscope.
Result HIDUSER_EnableGyroscope(void);
/// Disables the gyroscope.
Result HIDUSER_DisableGyroscope(void);
/**
* @brief Gets the gyroscope raw to dps coefficient.
* @param coeff Pointer to output the coefficient to.
*/
Result HIDUSER_GetGyroscopeRawToDpsCoefficient(float *coeff);
/**
* @brief Gets the current volume slider value. (0-63)
* @param volume Pointer to write the volume slider value to.
*/
Result HIDUSER_GetSoundVolume(u8 *volume);

View file

@ -0,0 +1,301 @@
/**
* @file httpc.h
* @brief HTTP service.
*/
#pragma once
/// HTTP context.
typedef struct {
Handle servhandle; ///< Service handle.
u32 httphandle; ///< HTTP handle.
} httpcContext;
/// HTTP request method.
typedef enum {
HTTPC_METHOD_GET = 0x1,
HTTPC_METHOD_POST = 0x2,
HTTPC_METHOD_HEAD = 0x3,
HTTPC_METHOD_PUT = 0x4,
HTTPC_METHOD_DELETE = 0x5
} HTTPC_RequestMethod;
/// HTTP request status.
typedef enum {
HTTPC_STATUS_REQUEST_IN_PROGRESS = 0x5, ///< Request in progress.
HTTPC_STATUS_DOWNLOAD_READY = 0x7 ///< Download ready.
} HTTPC_RequestStatus;
/// HTTP KeepAlive option.
typedef enum {
HTTPC_KEEPALIVE_DISABLED = 0x0,
HTTPC_KEEPALIVE_ENABLED = 0x1
} HTTPC_KeepAlive;
/// Result code returned when a download is pending.
#define HTTPC_RESULTCODE_DOWNLOADPENDING 0xd840a02b
// Result code returned when asked about a non-existing header.
#define HTTPC_RESULTCODE_NOTFOUND 0xd840a028
// Result code returned when any timeout function times out.
#define HTTPC_RESULTCODE_TIMEDOUT 0xd820a069
/// Initializes HTTPC. For HTTP GET the sharedmem_size can be zero. The sharedmem contains data which will be later uploaded for HTTP POST. sharedmem_size should be aligned to 0x1000-bytes.
Result httpcInit(u32 sharedmem_size);
/// Exits HTTPC.
void httpcExit(void);
/**
* @brief Opens a HTTP context.
* @param context Context to open.
* @param url URL to connect to.
* @param use_defaultproxy Whether the default proxy should be used (0 for default)
*/
Result httpcOpenContext(httpcContext *context, HTTPC_RequestMethod method, const char* url, u32 use_defaultproxy);
/**
* @brief Closes a HTTP context.
* @param context Context to close.
*/
Result httpcCloseContext(httpcContext *context);
/**
* @brief Cancels a HTTP connection.
* @param context Context to close.
*/
Result httpcCancelConnection(httpcContext *context);
/**
* @brief Adds a request header field to a HTTP context.
* @param context Context to use.
* @param name Name of the field.
* @param value Value of the field.
*/
Result httpcAddRequestHeaderField(httpcContext *context, const char* name, const char* value);
/**
* @brief Adds a POST form field to a HTTP context.
* @param context Context to use.
* @param name Name of the field.
* @param value Value of the field.
*/
Result httpcAddPostDataAscii(httpcContext *context, const char* name, const char* value);
/**
* @brief Adds a POST form field with binary data to a HTTP context.
* @param context Context to use.
* @param name Name of the field.
* @param value The binary data to pass as a value.
* @param len Length of the binary data which has been passed.
*/
Result httpcAddPostDataBinary(httpcContext *context, const char* name, const u8* value, u32 len);
/**
* @brief Adds a POST body to a HTTP context.
* @param context Context to use.
* @param data The data to be passed as raw into the body of the post request.
* @param len Length of data passed by data param.
*/
Result httpcAddPostDataRaw(httpcContext *context, const u32* data, u32 len);
/**
* @brief Begins a HTTP request.
* @param context Context to use.
*/
Result httpcBeginRequest(httpcContext *context);
/**
* @brief Receives data from a HTTP context.
* @param context Context to use.
* @param buffer Buffer to receive data to.
* @param size Size of the buffer.
*/
Result httpcReceiveData(httpcContext *context, u8* buffer, u32 size);
/**
* @brief Receives data from a HTTP context with a timeout value.
* @param context Context to use.
* @param buffer Buffer to receive data to.
* @param size Size of the buffer.
* @param timeout Maximum time in nanoseconds to wait for a reply.
*/
Result httpcReceiveDataTimeout(httpcContext *context, u8* buffer, u32 size, u64 timeout);
/**
* @brief Gets the request state of a HTTP context.
* @param context Context to use.
* @param out Pointer to output the HTTP request state to.
*/
Result httpcGetRequestState(httpcContext *context, HTTPC_RequestStatus* out);
/**
* @brief Gets the download size state of a HTTP context.
* @param context Context to use.
* @param downloadedsize Pointer to output the downloaded size to.
* @param contentsize Pointer to output the total content size to.
*/
Result httpcGetDownloadSizeState(httpcContext *context, u32* downloadedsize, u32* contentsize);
/**
* @brief Gets the response code of the HTTP context.
* @param context Context to get the response code of.
* @param out Pointer to write the response code to.
*/
Result httpcGetResponseStatusCode(httpcContext *context, u32* out);
/**
* @brief Gets the response code of the HTTP context with a timeout value.
* @param context Context to get the response code of.
* @param out Pointer to write the response code to.
* @param timeout Maximum time in nanoseconds to wait for a reply.
*/
Result httpcGetResponseStatusCodeTimeout(httpcContext *context, u32* out, u64 timeout);
/**
* @brief Gets a response header field from a HTTP context.
* @param context Context to use.
* @param name Name of the field.
* @param value Pointer to output the value of the field to.
* @param valuebuf_maxsize Maximum size of the value buffer.
*/
Result httpcGetResponseHeader(httpcContext *context, const char* name, char* value, u32 valuebuf_maxsize);
/**
* @brief Adds a trusted RootCA cert to a HTTP context.
* @param context Context to use.
* @param cert Pointer to DER cert.
* @param certsize Size of the DER cert.
*/
Result httpcAddTrustedRootCA(httpcContext *context, const u8 *cert, u32 certsize);
/**
* @brief Adds a default RootCA cert to a HTTP context.
* @param context Context to use.
* @param certID ID of the cert to add, see sslc.h.
*/
Result httpcAddDefaultCert(httpcContext *context, SSLC_DefaultRootCert certID);
/**
* @brief Sets the RootCertChain for a HTTP context.
* @param context Context to use.
* @param RootCertChain_contexthandle Contexthandle for the RootCertChain.
*/
Result httpcSelectRootCertChain(httpcContext *context, u32 RootCertChain_contexthandle);
/**
* @brief Sets the ClientCert for a HTTP context.
* @param context Context to use.
* @param cert Pointer to DER cert.
* @param certsize Size of the DER cert.
* @param privk Pointer to the DER private key.
* @param privk_size Size of the privk.
*/
Result httpcSetClientCert(httpcContext *context, const u8 *cert, u32 certsize, const u8 *privk, u32 privk_size);
/**
* @brief Sets the default clientcert for a HTTP context.
* @param context Context to use.
* @param certID ID of the cert to add, see sslc.h.
*/
Result httpcSetClientCertDefault(httpcContext *context, SSLC_DefaultClientCert certID);
/**
* @brief Sets the ClientCert contexthandle for a HTTP context.
* @param context Context to use.
* @param ClientCert_contexthandle Contexthandle for the ClientCert.
*/
Result httpcSetClientCertContext(httpcContext *context, u32 ClientCert_contexthandle);
/**
* @brief Sets SSL options for the context.
* The HTTPC SSL option bits are the same as those defined in sslc.h
* @param context Context to set flags on.
* @param options SSL option flags.
*/
Result httpcSetSSLOpt(httpcContext *context, u32 options);
/**
* @brief Sets the SSL options which will be cleared for the context.
* The HTTPC SSL option bits are the same as those defined in sslc.h
* @param context Context to clear flags on.
* @param options SSL option flags.
*/
Result httpcSetSSLClearOpt(httpcContext *context, u32 options);
/**
* @brief Creates a RootCertChain. Up to 2 RootCertChains can be created under this user-process.
* @param RootCertChain_contexthandle Output RootCertChain contexthandle.
*/
Result httpcCreateRootCertChain(u32 *RootCertChain_contexthandle);
/**
* @brief Destroy a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
*/
Result httpcDestroyRootCertChain(u32 RootCertChain_contexthandle);
/**
* @brief Adds a RootCA cert to a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
* @param cert Pointer to DER cert.
* @param certsize Size of the DER cert.
* @param cert_contexthandle Optional output ptr for the cert contexthandle(this can be NULL).
*/
Result httpcRootCertChainAddCert(u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle);
/**
* @brief Adds a default RootCA cert to a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
* @param certID ID of the cert to add, see sslc.h.
* @param cert_contexthandle Optional output ptr for the cert contexthandle(this can be NULL).
*/
Result httpcRootCertChainAddDefaultCert(u32 RootCertChain_contexthandle, SSLC_DefaultRootCert certID, u32 *cert_contexthandle);
/**
* @brief Removes a cert from a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
* @param cert_contexthandle Contexthandle of the cert to remove.
*/
Result httpcRootCertChainRemoveCert(u32 RootCertChain_contexthandle, u32 cert_contexthandle);
/**
* @brief Opens a ClientCert-context. Up to 2 ClientCert-contexts can be open under this user-process.
* @param cert Pointer to DER cert.
* @param certsize Size of the DER cert.
* @param privk Pointer to the DER private key.
* @param privk_size Size of the privk.
* @param ClientCert_contexthandle Output ClientCert context handle.
*/
Result httpcOpenClientCertContext(const u8 *cert, u32 certsize, const u8 *privk, u32 privk_size, u32 *ClientCert_contexthandle);
/**
* @brief Opens a ClientCert-context with a default clientclient. Up to 2 ClientCert-contexts can be open under this user-process.
* @param certID ID of the cert to add, see sslc.h.
* @param ClientCert_contexthandle Output ClientCert context handle.
*/
Result httpcOpenDefaultClientCertContext(SSLC_DefaultClientCert certID, u32 *ClientCert_contexthandle);
/**
* @brief Closes a ClientCert context.
* @param ClientCert_contexthandle ClientCert context to use.
*/
Result httpcCloseClientCertContext(u32 ClientCert_contexthandle);
/**
* @brief Downloads data from the HTTP context into a buffer.
* The *entire* content must be downloaded before using httpcCloseContext(), otherwise httpcCloseContext() will hang.
* @param context Context to download data from.
* @param buffer Buffer to write data to.
* @param size Size of the buffer.
* @param downloadedsize Pointer to write the size of the downloaded data to.
*/
Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downloadedsize);
/**
* @brief Sets Keep-Alive for the context.
* @param context Context to set the KeepAlive flag on.
* @param option HTTPC_KeepAlive option.
*/
Result httpcSetKeepAlive(httpcContext *context, HTTPC_KeepAlive option);

105
.vscode/dummyinclude/3ds/services/ir.h vendored Normal file
View file

@ -0,0 +1,105 @@
/**
* @file ir.h
* @brief IR service.
*/
#pragma once
/**
* @brief Initializes IRU.
* The permissions for the specified memory is set to RO. This memory must be already mapped.
* @param sharedmem_addr Address of the shared memory block to use.
* @param sharedmem_size Size of the shared memory block.
*/
Result iruInit(u32 *sharedmem_addr, u32 sharedmem_size);
/// Shuts down IRU.
void iruExit(void);
/**
* @brief Gets the IRU service handle.
* @return The IRU service handle.
*/
Handle iruGetServHandle(void);
/**
* @brief Sends IR data.
* @param buf Buffer to send data from.
* @param size Size of the buffer.
* @param wait Whether to wait for the data to be sent.
*/
Result iruSendData(u8 *buf, u32 size, bool wait);
/**
* @brief Receives IR data.
* @param buf Buffer to receive data to.
* @param size Size of the buffer.
* @param flag Flags to receive data with.
* @param transfercount Pointer to output the number of bytes read to.
* @param wait Whether to wait for the data to be received.
*/
Result iruRecvData(u8 *buf, u32 size, u8 flag, u32 *transfercount, bool wait);
/// Initializes the IR session.
Result IRU_Initialize(void);
/// Shuts down the IR session.
Result IRU_Shutdown(void);
/**
* @brief Begins sending data.
* @param buf Buffer to send.
* @param size Size of the buffer.
*/
Result IRU_StartSendTransfer(u8 *buf, u32 size);
/// Waits for a send operation to complete.
Result IRU_WaitSendTransfer(void);
/**
* @brief Begins receiving data.
* @param size Size of the data to receive.
* @param flag Flags to use when receiving.
*/
Result IRU_StartRecvTransfer(u32 size, u8 flag);
/**
* @brief Waits for a receive operation to complete.
* @param transfercount Pointer to output the number of bytes read to.
*/
Result IRU_WaitRecvTransfer(u32 *transfercount);
/**
* @brief Sets the IR bit rate.
* @param value Bit rate to set.
*/
Result IRU_SetBitRate(u8 value);
/**
* @brief Gets the IR bit rate.
* @param out Pointer to write the bit rate to.
*/
Result IRU_GetBitRate(u8 *out);
/**
* @brief Sets the IR LED state.
* @param value IR LED state to set.
*/
Result IRU_SetIRLEDState(u32 value);
/**
* @brief Gets the IR LED state.
* @param out Pointer to write the IR LED state to.
*/
Result IRU_GetIRLEDRecvState(u32 *out);
/**
* @brief Gets an event which is signaled once a send finishes.
* @param out Pointer to write the event handle to.
*/
Result IRU_GetSendFinishedEvent(Handle *out);
/**
* @brief Gets an event which is signaled once a receive finishes.
* @param out Pointer to write the event handle to.
*/
Result IRU_GetRecvFinishedEvent(Handle *out);

View file

@ -0,0 +1,65 @@
/**
* @file irrst.h
* @brief IRRST service.
*/
#pragma once
//See also: http://3dbrew.org/wiki/IR_Services http://3dbrew.org/wiki/IRRST_Shared_Memory
#include "3ds/services/hid.h" // for circlePosition definition
/// IRRST's shared memory handle.
extern Handle irrstMemHandle;
/// IRRST's shared memory.
extern vu32* irrstSharedMem;
/// IRRST's state update event
extern Handle irrstEvent;
/// Initializes IRRST.
Result irrstInit(void);
/// Exits IRRST.
void irrstExit(void);
/// Scans IRRST for input.
void irrstScanInput(void);
/**
* @brief Gets IRRST's held keys.
* @return IRRST's held keys.
*/
u32 irrstKeysHeld(void);
/**
* @brief Reads the current c-stick position.
* @param pos Pointer to output the current c-stick position to.
*/
void irrstCstickRead(circlePosition* pos);
/**
* @brief Waits for the IRRST input event to trigger.
* @param nextEvent Whether to discard the current event and wait until the next event.
*/
void irrstWaitForEvent(bool nextEvent);
/// Macro for irrstCstickRead.
#define hidCstickRead irrstCstickRead
/**
* @brief Gets the shared memory and event handles for IRRST.
* @param outMemHandle Pointer to write the shared memory handle to.
* @param outEventHandle Pointer to write the event handle to.
*/
Result IRRST_GetHandles(Handle* outMemHandle, Handle* outEventHandle);
/**
* @brief Initializes IRRST.
* @param unk1 Unknown.
* @param unk2 Unknown.
*/
Result IRRST_Initialize(u32 unk1, u8 unk2);
/// Shuts down IRRST.
Result IRRST_Shutdown(void);

View file

@ -0,0 +1,43 @@
/**
* @file loader.h
* @brief LOADER Service
*/
#pragma once
#include <3ds/exheader.h>
#include <3ds/services/fs.h>
/// Initializes LOADER.
Result loaderInit(void);
/// Exits LOADER.
void loaderExit(void);
/**
* @brief Loads a program and returns a process handle to the newly created process.
* @param[out] process Pointer to output the process handle to.
* @param programHandle The handle of the program to load.
*/
Result LOADER_LoadProcess(Handle* process, u64 programHandle);
/**
* @brief Registers a program (along with its update).
* @param[out] programHandle Pointer to output the program handle to.
* @param programInfo The program info.
* @param programInfo The program update info.
*/
Result LOADER_RegisterProgram(u64* programHandle, const FS_ProgramInfo *programInfo, const FS_ProgramInfo *programInfoUpdate);
/**
* @brief Unregisters a program (along with its update).
* @param programHandle The handle of the program to unregister.
*/
Result LOADER_UnregisterProgram(u64 programHandle);
/**
* @brief Retrives a program's main NCCH extended header info (SCI + ACI, see @ref ExHeader_Info).
* @param[out] exheaderInfo Pointer to output the main NCCH extended header info.
* @param programHandle The handle of the program to unregister
*/
Result LOADER_GetProgramInfo(ExHeader_Info* exheaderInfo, u64 programHandle);

View file

@ -0,0 +1,107 @@
/**
* @file mcuhwc.h
* @brief mcuHwc service.
*/
#pragma once
typedef enum {
LED_NORMAL = 1, ///< The normal mode of the led
LED_SLEEP_MODE, ///< The led pulses slowly as it does in the sleep mode
LED_OFF, ///< Switch off power led
LED_RED, ///< Red state of the led
LED_BLUE, ///< Blue state of the led
LED_BLINK_RED, ///< Blinking red state of power led and notification led
} powerLedState;
typedef struct InfoLedPattern
{
u8 delay; ///< Delay between pattern values, 1/16th of a second (1 second = 0x10)
u8 smoothing; ///< Smoothing between pattern values (higher = smoother)
u8 loopDelay; ///< Delay between pattern loops, 1/16th of a second (1 second = 0x10, 0xFF = pattern is played only once)
u8 blinkSpeed; ///< Blink speed, when smoothing == 0x00
u8 redPattern[32]; ///< Pattern for red component
u8 greenPattern[32]; ///< Pattern for green component
u8 bluePattern[32]; ///< Pattern for blue component
} InfoLedPattern;
/// Initializes mcuHwc.
Result mcuHwcInit(void);
/// Exits mcuHwc.
void mcuHwcExit(void);
/**
* @brief Gets the current mcuHwc session handle.
* @return A pointer to the current mcuHwc session handle.
*/
Handle* mcuHwcGetSessionHandle(void);
/**
* @brief Reads data from an i2c device3 register
* @param reg Register number. See https://www.3dbrew.org/wiki/I2C_Registers#Device_3 for more info
* @param data Pointer to write the data to.
* @param size Size of data to be read
*/
Result MCUHWC_ReadRegister(u8 reg, void *data, u32 size);
/**
* @brief Writes data to a i2c device3 register
* @param reg Register number. See https://www.3dbrew.org/wiki/I2C_Registers#Device_3 for more info
* @param data Pointer to write the data to.
* @param size Size of data to be written
*/
Result MCUHWC_WriteRegister(u8 reg, const void *data, u32 size);
/**
* @brief Gets the battery voltage
* @param voltage Pointer to write the battery voltage to.
*/
Result MCUHWC_GetBatteryVoltage(u8 *voltage);
/**
* @brief Gets the battery level
* @param level Pointer to write the current battery level to.
*/
Result MCUHWC_GetBatteryLevel(u8 *level);
/**
* @brief Gets the sound slider level
* @param level Pointer to write the slider level to.
*/
Result MCUHWC_GetSoundSliderLevel(u8 *level);
/**
* @brief Sets Wifi LED state
* @param state State of Wifi LED. (True/False)
*/
Result MCUHWC_SetWifiLedState(bool state);
/**
* @brief Sets the notification LED pattern
* @param pattern Pattern for the notification LED.
*/
Result MCUHWC_SetInfoLedPattern(const InfoLedPattern* pattern);
/**
* @brief Sets Power LED state
* @param state powerLedState State of power LED.
*/
Result MCUHWC_SetPowerLedState(powerLedState state);
/**
* @brief Gets 3d slider level
* @param level Pointer to write 3D slider level to.
*/
Result MCUHWC_Get3dSliderLevel(u8 *level);
/**
* @brief Gets the major MCU firmware version
* @param out Pointer to write the major firmware version to.
*/
Result MCUHWC_GetFwVerHigh(u8 *out);
/**
* @brief Gets the minor MCU firmware version
* @param out Pointer to write the minor firmware version to.
*/
Result MCUHWC_GetFwVerLow(u8 *out);

128
.vscode/dummyinclude/3ds/services/mic.h vendored Normal file
View file

@ -0,0 +1,128 @@
/**
* @file mic.h
* @brief MIC (Microphone) service.
*/
#pragma once
/// Microphone audio encodings.
typedef enum
{
MICU_ENCODING_PCM8 = 0, ///< Unsigned 8-bit PCM.
MICU_ENCODING_PCM16 = 1, ///< Unsigned 16-bit PCM.
MICU_ENCODING_PCM8_SIGNED = 2, ///< Signed 8-bit PCM.
MICU_ENCODING_PCM16_SIGNED = 3, ///< Signed 16-bit PCM.
} MICU_Encoding;
/// Microphone audio sampling rates.
typedef enum
{
MICU_SAMPLE_RATE_32730 = 0, ///< 32728.498 Hz
MICU_SAMPLE_RATE_16360 = 1, ///< 16364.479 Hz
MICU_SAMPLE_RATE_10910 = 2, ///< 10909.499 Hz
MICU_SAMPLE_RATE_8180 = 3, ///< 8182.1245 Hz
} MICU_SampleRate;
/**
* @brief Initializes MIC.
* @param size Shared memory buffer to write audio data to. Must be aligned to 0x1000 bytes.
* @param handle Size of the shared memory buffer.
*/
Result micInit(u8* buffer, u32 bufferSize);
/// Exits MIC.
void micExit(void);
/**
* @brief Gets the size of the sample data area within the shared memory buffer.
* @return The sample data's size.
*/
u32 micGetSampleDataSize(void);
/**
* @brief Gets the offset within the shared memory buffer of the last sample written.
* @return The last sample's offset.
*/
u32 micGetLastSampleOffset(void);
/**
* @brief Maps MIC shared memory.
* @param size Size of the shared memory.
* @param handle Handle of the shared memory.
*/
Result MICU_MapSharedMem(u32 size, Handle handle);
/// Unmaps MIC shared memory.
Result MICU_UnmapSharedMem(void);
/**
* @brief Begins sampling microphone input.
* @param encoding Encoding of outputted audio.
* @param sampleRate Sample rate of outputted audio.
* @param sharedMemAudioOffset Offset to write audio data to in the shared memory buffer.
* @param sharedMemAudioSize Size of audio data to write to the shared memory buffer. This should be at most "bufferSize - 4".
* @param loop Whether to loop back to the beginning of the buffer when the end is reached.
*/
Result MICU_StartSampling(MICU_Encoding encoding, MICU_SampleRate sampleRate, u32 offset, u32 size, bool loop);
/**
* @brief Adjusts the configuration of the current sampling session.
* @param sampleRate Sample rate of outputted audio.
*/
Result MICU_AdjustSampling(MICU_SampleRate sampleRate);
/// Stops sampling microphone input.
Result MICU_StopSampling(void);
/**
* @brief Gets whether microphone input is currently being sampled.
* @param sampling Pointer to output the sampling state to.
*/
Result MICU_IsSampling(bool* sampling);
/**
* @brief Gets an event handle triggered when the shared memory buffer is full.
* @param handle Pointer to output the event handle to.
*/
Result MICU_GetEventHandle(Handle* handle);
/**
* @brief Sets the microphone's gain.
* @param gain Gain to set.
*/
Result MICU_SetGain(u8 gain);
/**
* @brief Gets the microphone's gain.
* @param gain Pointer to output the current gain to.
*/
Result MICU_GetGain(u8* gain);
/**
* @brief Sets whether the microphone is powered on.
* @param power Whether the microphone is powered on.
*/
Result MICU_SetPower(bool power);
/**
* @brief Gets whether the microphone is powered on.
* @param power Pointer to output the power state to.
*/
Result MICU_GetPower(bool* power);
/**
* @brief Sets whether to clamp microphone input.
* @param clamp Whether to clamp microphone input.
*/
Result MICU_SetClamp(bool clamp);
/**
* @brief Gets whether to clamp microphone input.
* @param clamp Pointer to output the clamp state to.
*/
Result MICU_GetClamp(bool* clamp);
/**
* @brief Sets whether to allow sampling when the shell is closed.
* @param allowShellClosed Whether to allow sampling when the shell is closed.
*/
Result MICU_SetAllowShellClosed(bool allowShellClosed);

168
.vscode/dummyinclude/3ds/services/mvd.h vendored Normal file
View file

@ -0,0 +1,168 @@
/**
* @file mvd.h
* @brief MVD service.
*/
#pragma once
//New3DS-only, see also: http://3dbrew.org/wiki/MVD_Services
///These values are the data returned as "result-codes" by MVDSTD.
#define MVD_STATUS_OK 0x17000
#define MVD_STATUS_PARAMSET 0x17001 ///"Returned after processing NAL-unit parameter-sets."
#define MVD_STATUS_BUSY 0x17002
#define MVD_STATUS_FRAMEREADY 0x17003
#define MVD_STATUS_INCOMPLETEPROCESSING 0x17004 ///"Returned when not all of the input NAL-unit buffer was processed."
#define MVD_STATUS_NALUPROCFLAG 0x17007 ///See here: https://www.3dbrew.org/wiki/MVDSTD:ProcessNALUnit
///This can be used to check whether mvdstdProcessVideoFrame() was successful.
#define MVD_CHECKNALUPROC_SUCCESS(x) (x==MVD_STATUS_OK || x==MVD_STATUS_PARAMSET || x==MVD_STATUS_FRAMEREADY || x==MVD_STATUS_INCOMPLETEPROCESSING || x==MVD_STATUS_NALUPROCFLAG)
/// Default input size for mvdstdInit(). This is what the New3DS Internet Browser uses, from the MVDSTD:CalculateWorkBufSize output.
#define MVD_DEFAULT_WORKBUF_SIZE 0x9006C8
/// Processing mode.
typedef enum {
MVDMODE_COLORFORMATCONV, ///< Converting color formats.
MVDMODE_VIDEOPROCESSING ///< Processing video.
} MVDSTD_Mode;
/// Input format.
typedef enum {
MVD_INPUT_YUYV422 = 0x00010001, ///< YUYV422
MVD_INPUT_H264 = 0x00020001 ///< H264
} MVDSTD_InputFormat;
/// Output format.
typedef enum {
MVD_OUTPUT_YUYV422 = 0x00010001, ///< YUYV422
MVD_OUTPUT_BGR565 = 0x00040002, ///< BGR565
MVD_OUTPUT_RGB565 = 0x00040004 ///< RGB565
} MVDSTD_OutputFormat;
/// Processing configuration.
typedef struct {
MVDSTD_InputFormat input_type; ///< Input type.
u32 unk_x04; ///< Unknown.
u32 unk_x08; ///< Unknown. Referred to as "H264 range" in SKATER.
u32 inwidth; ///< Input width.
u32 inheight; ///< Input height.
u32 physaddr_colorconv_indata; ///< Physical address of color conversion input data.
u32 physaddr_colorconv_unk0; ///< Physical address used with color conversion.
u32 physaddr_colorconv_unk1; ///< Physical address used with color conversion.
u32 physaddr_colorconv_unk2; ///< Physical address used with color conversion.
u32 physaddr_colorconv_unk3; ///< Physical address used with color conversion.
u32 unk_x28[0x18>>2]; ///< Unknown.
u32 enable_cropping; ///< Enables cropping with the input image when non-zero via the following 4 words.
u32 input_crop_x_pos;
u32 input_crop_y_pos;
u32 input_crop_height;
u32 input_crop_width;
u32 unk_x54; ///< Unknown.
MVDSTD_OutputFormat output_type; ///< Output type.
u32 outwidth; ///< Output width.
u32 outheight; ///< Output height.
u32 physaddr_outdata0; ///< Physical address of output data.
u32 physaddr_outdata1; ///< Additional physical address for output data, only used when the output format type is value 0x00020001.
u32 unk_x6c[0x98>>2]; ///< Unknown.
u32 flag_x104; ///< This enables using the following 4 words when non-zero.
u32 output_x_pos; ///< Output X position in the output buffer.
u32 output_y_pos; ///< Same as above except for the Y pos.
u32 output_width_override; ///< Used for aligning the output width when larger than the output width. Overrides the output width when smaller than the output width.
u32 output_height_override; ///< Same as output_width_override except for the output height.
u32 unk_x118;
} MVDSTD_Config;
typedef struct {
u32 end_vaddr;//"End-address of the processed NAL-unit(internal MVD heap vaddr)."
u32 end_physaddr;//"End-address of the processed NAL-unit(physaddr following the input physaddr)."
u32 remaining_size;//"Total remaining unprocessed input data. Buffer_end_pos=bufsize-<this value>."
} MVDSTD_ProcessNALUnitOut;
typedef struct {
void* outdata0;//Linearmem vaddr equivalent to config *_outdata0.
void* outdata1;//Linearmem vaddr equivalent to config *_outdata1.
} MVDSTD_OutputBuffersEntry;
typedef struct {
u32 total_entries;//Total actual used entries below.
MVDSTD_OutputBuffersEntry entries[17];
} MVDSTD_OutputBuffersEntryList;
/// This can be used to override the default input values for MVDSTD commands during initialization with video-processing. The default for these fields are all-zero, except for cmd1b_inval which is 1. See also here: https://www.3dbrew.org/wiki/MVD_Services
typedef struct {
s8 cmd5_inval0, cmd5_inval1, cmd5_inval2;
u32 cmd5_inval3;
u8 cmd1b_inval;
} MVDSTD_InitStruct;
/**
* @brief Initializes MVDSTD.
* @param mode Mode to initialize MVDSTD to.
* @param input_type Type of input to process.
* @param output_type Type of output to produce.
* @param size Size of the work buffer, MVD_DEFAULT_WORKBUF_SIZE can be used for this. Only used when type == MVDMODE_VIDEOPROCESSING.
* @param initstruct Optional MVDSTD_InitStruct, this should be NULL normally.
*/
Result mvdstdInit(MVDSTD_Mode mode, MVDSTD_InputFormat input_type, MVDSTD_OutputFormat output_type, u32 size, MVDSTD_InitStruct *initstruct);
/// Shuts down MVDSTD.
void mvdstdExit(void);
/**
* @brief Generates a default MVDSTD configuration.
* @param config Pointer to output the generated config to.
* @param input_width Input width.
* @param input_height Input height.
* @param output_width Output width.
* @param output_height Output height.
* @param vaddr_colorconv_indata Virtual address of the color conversion input data.
* @param vaddr_outdata0 Virtual address of the output data.
* @param vaddr_outdata1 Additional virtual address for output data, only used when the output format type is value 0x00020001.
*/
void mvdstdGenerateDefaultConfig(MVDSTD_Config*config, u32 input_width, u32 input_height, u32 output_width, u32 output_height, u32 *vaddr_colorconv_indata, u32 *vaddr_outdata0, u32 *vaddr_outdata1);
/**
* @brief Run color-format-conversion.
* @param config Pointer to the configuration to use.
*/
Result mvdstdConvertImage(MVDSTD_Config* config);
/**
* @brief Processes a video frame(specifically a NAL-unit).
* @param inbuf_vaddr Input NAL-unit starting with the 3-byte "00 00 01" prefix. Must be located in linearmem.
* @param size Size of the input buffer.
* @param flag See here regarding this input flag: https://www.3dbrew.org/wiki/MVDSTD:ProcessNALUnit
* @param out Optional output MVDSTD_ProcessNALUnitOut structure.
*/
Result mvdstdProcessVideoFrame(void* inbuf_vaddr, size_t size, u32 flag, MVDSTD_ProcessNALUnitOut *out);
/**
* @brief Renders the video frame.
* @param config Optional pointer to the configuration to use. When NULL, MVDSTD_SetConfig() should have been used previously for this video.
* @param wait When true, wait for rendering to finish. When false, you can manually call this function repeatedly until it stops returning MVD_STATUS_BUSY.
*/
Result mvdstdRenderVideoFrame(MVDSTD_Config* config, bool wait);
/**
* @brief Sets the current configuration of MVDSTD.
* @param config Pointer to the configuration to set.
*/
Result MVDSTD_SetConfig(MVDSTD_Config* config);
/**
* @brief New3DS Internet Browser doesn't use this. Once done, rendered frames will be written to the output buffers specified by the entrylist instead of the output specified by configuration. See here: https://www.3dbrew.org/wiki/MVDSTD:SetupOutputBuffers
* @param entrylist Input entrylist.
* @param bufsize Size of each buffer from the entrylist.
*/
Result mvdstdSetupOutputBuffers(MVDSTD_OutputBuffersEntryList *entrylist, u32 bufsize);
/**
* @brief New3DS Internet Browser doesn't use this. This overrides the entry0 output buffers originally setup by mvdstdSetupOutputBuffers(). See also here: https://www.3dbrew.org/wiki/MVDSTD:OverrideOutputBuffers
* @param cur_outdata0 Linearmem vaddr. The current outdata0 for this entry must match this value.
* @param cur_outdata1 Linearmem vaddr. The current outdata1 for this entry must match this value.
* @param new_outdata0 Linearmem vaddr. This is the new address to use for outaddr0.
* @param new_outdata1 Linearmem vaddr. This is the new address to use for outaddr1.
*/
Result mvdstdOverrideOutputBuffers(void* cur_outdata0, void* cur_outdata1, void* new_outdata0, void* new_outdata1);

149
.vscode/dummyinclude/3ds/services/ndm.h vendored Normal file
View file

@ -0,0 +1,149 @@
/**
* @file ndm.h
* @brief NDMU service. https://3dbrew.org/wiki/NDM_Services
*/
#pragma once
/// Exclusive states.
typedef enum {
NDM_EXCLUSIVE_STATE_NONE = 0,
NDM_EXCLUSIVE_STATE_INFRASTRUCTURE = 1,
NDM_EXCLUSIVE_STATE_LOCAL_COMMUNICATIONS = 2,
NDM_EXCLUSIVE_STATE_STREETPASS = 3,
NDM_EXCLUSIVE_STATE_STREETPASS_DATA = 4,
} ndmExclusiveState;
/// Current states.
typedef enum {
NDM_STATE_INITIAL = 0,
NDM_STATE_SUSPENDED = 1,
NDM_STATE_INFRASTRUCTURE_CONNECTING = 2,
NDM_STATE_INFRASTRUCTURE_CONNECTED = 3,
NDM_STATE_INFRASTRUCTURE_WORKING = 4,
NDM_STATE_INFRASTRUCTURE_SUSPENDING = 5,
NDM_STATE_INFRASTRUCTURE_FORCE_SUSPENDING = 6,
NDM_STATE_INFRASTRUCTURE_DISCONNECTING = 7,
NDM_STATE_INFRASTRUCTURE_FORCE_DISCONNECTING = 8,
NDM_STATE_CEC_WORKING = 9,
NDM_STATE_CEC_FORCE_SUSPENDING = 10,
NDM_STATE_CEC_SUSPENDING = 11,
} ndmState;
// Daemons.
typedef enum {
NDM_DAEMON_CEC = 0,
NDM_DAEMON_BOSS = 1,
NDM_DAEMON_NIM = 2,
NDM_DAEMON_FRIENDS = 3,
} ndmDaemon;
/// Used to specify multiple daemons.
typedef enum {
NDM_DAEMON_MASK_CEC = BIT(NDM_DAEMON_CEC),
NDM_DAEMON_MASK_BOSS = BIT(NDM_DAEMON_BOSS),
NDM_DAEMON_MASK_NIM = BIT(NDM_DAEMON_NIM),
NDM_DAEMON_MASK_FRIENDS = BIT(NDM_DAEMON_FRIENDS),
NDM_DAEMON_MASK_BACKGROUOND = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_BOSS | NDM_DAEMON_MASK_NIM,
NDM_DAEMON_MASK_ALL = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_BOSS | NDM_DAEMON_MASK_NIM | NDM_DAEMON_MASK_FRIENDS,
NDM_DAEMON_MASK_DEFAULT = NDM_DAEMON_MASK_CEC | NDM_DAEMON_MASK_FRIENDS,
} ndmDaemonMask;
// Daemon status.
typedef enum {
NDM_DAEMON_STATUS_BUSY = 0,
NDM_DAEMON_STATUS_IDLE = 1,
NDM_DAEMON_STATUS_SUSPENDING = 2,
NDM_DAEMON_STATUS_SUSPENDED = 3,
} ndmDaemonStatus;
/// Initializes ndmu.
Result ndmuInit(void);
/// Exits ndmu.
void ndmuExit(void);
/**
* @brief Sets the network daemon to an exclusive state.
* @param state State specified in the ndmExclusiveState enumerator.
*/
Result NDMU_EnterExclusiveState(ndmExclusiveState state);
/// Cancels an exclusive state for the network daemon.
Result NDMU_LeaveExclusiveState(void);
/**
* @brief Returns the exclusive state for the network daemon.
* @param state Pointer to write the exclsuive state to.
*/
Result NDMU_GetExclusiveState(ndmExclusiveState *state);
/// Locks the exclusive state.
Result NDMU_LockState(void);
/// Unlocks the exclusive state.
Result NDMU_UnlockState(void);
/**
* @brief Suspends network daemon.
* @param mask The specified daemon.
*/
Result NDMU_SuspendDaemons(ndmDaemonMask mask);
/**
* @brief Resumes network daemon.
* @param mask The specified daemon.
*/
Result NDMU_ResumeDaemons(ndmDaemonMask mask);
/**
* @brief Suspends scheduling for all network daemons.
* @param flag 0 = Wait for completion, 1 = Perform in background.
*/
Result NDMU_SuspendScheduler(u32 flag);
/// Resumes daemon scheduling.
Result NDMU_ResumeScheduler(void);
/**
* @brief Returns the current state for the network daemon.
* @param state Pointer to write the current state to.
*/
Result NDMU_GetCurrentState(ndmState *state);
/**
* @brief Returns a daemon state.
* @param daemon The specified daemon.
* @param state Pointer to write the daemon state to.
*/
Result NDMU_QueryStatus(ndmDaemon daemon, ndmDaemonStatus *status);
/**
* @brief Sets the scan interval.
* @param interval Value to set the scan interval to.
*/
Result NDMU_SetScanInterval(u32 interval);
/**
* @brief Returns the scan interval.
* @param interval Pointer to write the interval value to.
*/
Result NDMU_GetScanInterval(u32 *interval);
/**
* @brief Returns the retry interval.
* @param interval Pointer to write the interval value to.
*/
Result NDMU_GetRetryInterval(u32 *interval);
/// Reverts network daemon to defaults.
Result NDMU_ResetDaemons(void);
/**
* @brief Gets the current default daemon bit mask.
* @param interval Pointer to write the default daemon mask value to. The default value is (DAEMONMASK_CEC | DAEMONMASK_FRIENDS)
*/
Result NDMU_GetDefaultDaemons(ndmDaemonMask *mask);
/// Clears half awake mac filter.
Result NDMU_ClearMacFilter(void);

View file

@ -0,0 +1,91 @@
/**
* @file news.h
* @brief NEWS (Notification) service.
*/
#pragma once
/// Notification header data.
typedef struct {
bool dataSet;
bool unread;
bool enableJPEG;
bool isSpotPass;
bool isOptedOut;
u8 unkData[3];
u64 processID;
u8 unkData2[8];
u64 jumpParam;
u8 unkData3[8];
u64 time;
u16 title[32];
} NotificationHeader;
/// Initializes NEWS.
Result newsInit(void);
/// Exits NEWS.
void newsExit(void);
/**
* @brief Adds a notification to the home menu Notifications applet.
* @param title UTF-16 title of the notification.
* @param titleLength Number of characters in the title, not including the null-terminator.
* @param message UTF-16 message of the notification, or NULL for no message.
* @param messageLength Number of characters in the message, not including the null-terminator.
* @param image Data of the image to show in the notification, or NULL for no image.
* @param imageSize Size of the image data in bytes.
* @param jpeg Whether the image is a JPEG or not.
*/
Result NEWS_AddNotification(const u16* title, u32 titleLength, const u16* message, u32 messageLength, const void* imageData, u32 imageSize, bool jpeg);
/**
* @brief Gets current total notifications number.
* @param num Pointer where total number will be saved.
*/
Result NEWS_GetTotalNotifications(u32* num);
/**
* @brief Sets a custom header for a specific notification.
* @param news_id Identification number of the notification.
* @param header Pointer to notification header to set.
*/
Result NEWS_SetNotificationHeader(u32 news_id, const NotificationHeader* header);
/**
* @brief Gets the header of a specific notification.
* @param news_id Identification number of the notification.
* @param header Pointer where header of the notification will be saved.
*/
Result NEWS_GetNotificationHeader(u32 news_id, NotificationHeader* header);
/**
* @brief Sets a custom message for a specific notification.
* @param news_id Identification number of the notification.
* @param message Pointer to UTF-16 message to set.
* @param size Size of message to set.
*/
Result NEWS_SetNotificationMessage(u32 news_id, const u16* message, u32 size);
/**
* @brief Gets the message of a specific notification.
* @param news_id Identification number of the notification.
* @param message Pointer where UTF-16 message of the notification will be saved.
* @param size Pointer where size of the message data will be saved in bytes.
*/
Result NEWS_GetNotificationMessage(u32 news_id, u16* message, u32* size);
/**
* @brief Sets a custom image for a specific notification.
* @param news_id Identification number of the notification.
* @param buffer Pointer to MPO image to set.
* @param size Size of the MPO image to set.
*/
Result NEWS_SetNotificationImage(u32 news_id, const void* buffer, u32 size);
/**
* @brief Gets the image of a specific notification.
* @param news_id Identification number of the notification.
* @param buffer Pointer where MPO image of the notification will be saved.
* @param size Pointer where size of the image data will be saved in bytes.
*/
Result NEWS_GetNotificationImage(u32 news_id, void* buffer, u32* size);

220
.vscode/dummyinclude/3ds/services/nfc.h vendored Normal file
View file

@ -0,0 +1,220 @@
/**
* @file nfc.h
* @brief NFC service. This can only be used with system-version >=9.3.0-X.
*/
#pragma once
/// This is returned when the current state is invalid for this command.
#define NFC_ERR_INVALID_STATE 0xC8A17600
/// This is returned by nfcOpenAppData() when the appdata is uninitialized since nfcInitializeWriteAppData() wasn't used previously.
#define NFC_ERR_APPDATA_UNINITIALIZED 0xC8A17620
/// This is returned by nfcGetAmiiboSettings() when the amiibo wasn't setup by the amiibo Settings applet.
#define NFC_ERR_AMIIBO_NOTSETUP 0xC8A17628
/// This is returned by nfcOpenAppData() when the input AppID doesn't match the actual amiibo AppID.
#define NFC_ERR_APPID_MISMATCH 0xC8A17638
/// "Returned for HMAC-hash mismatch(data corruption), with HMAC-calculation input_buffer_size=0x34."
#define NFC_ERR_DATACORRUPTION0 0xC8C1760C
/// HMAC-hash mismatch with input_buffer_size=0x1DF, see here: https://www.3dbrew.org/wiki/Amiibo
#define NFC_ERR_DATACORRUPTION1 0xC8A17618
/// This can be used for nfcStartScanning().
#define NFC_STARTSCAN_DEFAULTINPUT 0
/// NFC operation type.
typedef enum {
NFC_OpType_1 = 1, /// Unknown.
NFC_OpType_NFCTag = 2, /// This is the default.
NFC_OpType_RawNFC = 3 /// Use Raw NFC tag commands. Only available with >=10.0.0-X.
} NFC_OpType;
typedef enum {
NFC_TagState_Uninitialized = 0, /// nfcInit() was not used yet.
NFC_TagState_ScanningStopped = 1, /// Not currently scanning for NFC tags. Set by nfcStopScanning() and nfcInit(), when successful.
NFC_TagState_Scanning = 2, /// Currently scanning for NFC tags. Set by nfcStartScanning() when successful.
NFC_TagState_InRange = 3, /// NFC tag is in range. The state automatically changes to this when the state was previously value 2, without using any NFC service commands.
NFC_TagState_OutOfRange = 4, /// NFC tag is now out of range, where the NFC tag was previously in range. This occurs automatically without using any NFC service commands. Once this state is entered, it won't automatically change to anything else when the tag is moved in range again. Hence, if you want to keep doing tag scanning after this, you must stop+start scanning.
NFC_TagState_DataReady = 5 /// NFC tag data was successfully loaded. This is set by nfcLoadAmiiboData() when successful.
} NFC_TagState;
/// Bit4-7 are always clear with nfcGetAmiiboSettings() due to "& 0xF".
enum {
NFC_amiiboFlag_Setup = BIT(4), /// This indicates that the amiibo was setup with amiibo Settings. nfcGetAmiiboSettings() will return an all-zero struct when this is not set.
NFC_amiiboFlag_AppDataSetup = BIT(5) /// This indicates that the AppData was previously initialized via nfcInitializeWriteAppData(), that function can't be used again with this flag already set.
};
typedef struct {
u16 id_offset_size;/// "u16 size/offset of the below ID data. Normally this is 0x7. When this is <=10, this field is the size of the below ID data. When this is >10, this is the offset of the 10-byte ID data, relative to structstart+4+<offsetfield-10>. It's unknown in what cases this 10-byte ID data is used."
u8 unk_x2;//"Unknown u8, normally 0x0."
u8 unk_x3;//"Unknown u8, normally 0x2."
u8 id[0x28];//"ID data. When the above size field is 0x7, this is the 7-byte NFC tag UID, followed by all-zeros."
} NFC_TagInfo;
/// AmiiboSettings structure, see also here: https://3dbrew.org/wiki/NFC:GetAmiiboSettings
typedef struct {
u8 mii[0x60];/// "Owner Mii."
u16 nickname[11];/// "UTF-16BE Amiibo nickname."
u8 flags;/// "This is plaintext_amiibosettingsdata[0] & 0xF." See also the NFC_amiiboFlag enums.
u8 countrycodeid;/// "This is plaintext_amiibosettingsdata[1]." "Country Code ID, from the system which setup this amiibo."
u16 setupdate_year;
u8 setupdate_month;
u8 setupdate_day;
u8 unk_x7c[0x2c];//Normally all-zero?
} NFC_AmiiboSettings;
/// AmiiboConfig structure, see also here: https://3dbrew.org/wiki/NFC:GetAmiiboConfig
typedef struct {
u16 lastwritedate_year;
u8 lastwritedate_month;
u8 lastwritedate_day;
u16 write_counter;
u8 characterID[3];/// the first element is the collection ID, the second the character in this collection, the third the variant
u8 series;/// ID of the series
u16 amiiboID;/// ID shared by all exact same amiibo. Some amiibo are only distinguished by this one like regular SMB Series Mario and the gold one
u8 type;/// Type of amiibo 0 = figure, 1 = card, 2 = plush
u8 pagex4_byte3;
u16 appdata_size;/// "NFC module writes hard-coded u8 value 0xD8 here. This is the size of the Amiibo AppData, apps can use this with the AppData R/W commands. ..."
u8 zeros[0x30];/// "Unused / reserved: this is cleared by NFC module but never written after that."
} NFC_AmiiboConfig;
/// Used by nfcInitializeWriteAppData() internally, see also here: https://3dbrew.org/wiki/NFC:GetAppDataInitStruct
typedef struct {
u8 data_x0[0xC];
u8 data_xc[0x30];/// "The data starting at struct offset 0xC is the 0x30-byte struct used by NFC:InitializeWriteAppData, sent by the user-process."
} NFC_AppDataInitStruct;
/// Used by nfcWriteAppData() internally, see also: https://3dbrew.org/wiki/NFC:WriteAppData
typedef struct {
u8 id[10];//7-byte UID normally.
u8 id_size;
u8 unused_xb[0x15];
} NFC_AppDataWriteStruct;
/**
* @brief Initializes NFC.
* @param type See the NFC_OpType enum.
*/
Result nfcInit(NFC_OpType type);
/**
* @brief Shuts down NFC.
*/
void nfcExit(void);
/**
* @brief Gets the NFC service handle.
* @return The NFC service handle.
*/
Handle nfcGetSessionHandle(void);
/**
* @brief Starts scanning for NFC tags.
* @param inval Unknown. See NFC_STARTSCAN_DEFAULTINPUT.
*/
Result nfcStartScanning(u16 inval);
/**
* @brief Stops scanning for NFC tags.
*/
void nfcStopScanning(void);
/**
* @brief Read amiibo NFC data and load in memory.
*/
Result nfcLoadAmiiboData(void);
/**
* @brief If the tagstate is valid(NFC_TagState_DataReady or 6), it then sets the current tagstate to NFC_TagState_InRange.
*/
Result nfcResetTagScanState(void);
/**
* @brief This writes the amiibo data stored in memory to the actual amiibo data storage(which is normally the NFC data pages). This can only be used if NFC_LoadAmiiboData() was used previously.
*/
Result nfcUpdateStoredAmiiboData(void);
/**
* @brief Returns the current NFC tag state.
* @param state Pointer to write NFC tag state.
*/
Result nfcGetTagState(NFC_TagState *state);
/**
* @brief Returns the current TagInfo.
* @param out Pointer to write the output TagInfo.
*/
Result nfcGetTagInfo(NFC_TagInfo *out);
/**
* @brief Opens the appdata, when the amiibo appdata was previously initialized. This must be used before reading/writing the appdata. See also: https://3dbrew.org/wiki/NFC:OpenAppData
* @param amiibo_appid Amiibo AppID. See here: https://www.3dbrew.org/wiki/Amiibo
*/
Result nfcOpenAppData(u32 amiibo_appid);
/**
* @brief This initializes the appdata using the specified input, when the appdata previously wasn't initialized. If the appdata is already initialized, you must first use the amiibo Settings applet menu option labeled "Delete amiibo Game Data". This automatically writes the amiibo data into the actual data storage(normally NFC data pages). See also nfcWriteAppData().
* @param amiibo_appid amiibo AppID. See also nfcOpenAppData().
* @param buf Input buffer.
* @param size Buffer size.
*/
Result nfcInitializeWriteAppData(u32 amiibo_appid, const void *buf, size_t size);
/**
* @brief Reads the appdata. The size must be >=0xD8-bytes, but the actual used size is hard-coded to 0xD8. Note that areas of appdata which were never written to by applications are uninitialized in this output buffer.
* @param buf Output buffer.
* @param size Buffer size.
*/
Result nfcReadAppData(void *buf, size_t size);
/**
* @brief Writes the appdata, after nfcOpenAppData() was used successfully. The size should be <=0xD8-bytes. See also: https://3dbrew.org/wiki/NFC:WriteAppData
* @param buf Input buffer.
* @param size Buffer size.
* @param taginfo TagInfo from nfcGetTagInfo().
*/
Result nfcWriteAppData(const void *buf, size_t size, NFC_TagInfo *taginfo);
/**
* @brief Returns the current AmiiboSettings.
* @param out Pointer to write the output AmiiboSettings.
*/
Result nfcGetAmiiboSettings(NFC_AmiiboSettings *out);
/**
* @brief Returns the current AmiiboConfig.
* @param out Pointer to write the output AmiiboConfig.
*/
Result nfcGetAmiiboConfig(NFC_AmiiboConfig *out);
/**
* @brief Starts scanning for NFC tags when initialized with NFC_OpType_RawNFC. See also: https://www.3dbrew.org/wiki/NFC:StartOtherTagScanning
* @param unk0 Same as nfcStartScanning() input.
* @param unk1 Unknown.
*/
Result nfcStartOtherTagScanning(u16 unk0, u32 unk1);
/**
* @brief This sends a raw NFC command to the tag. This can only be used when initialized with NFC_OpType_RawNFC, and when the TagState is NFC_TagState_InRange. See also: https://www.3dbrew.org/wiki/NFC:SendTagCommand
* @param inbuf Input buffer.
* @param insize Size of the input buffer.
* @param outbuf Output buffer.
* @param outsize Size of the output buffer.
* @param actual_transfer_size Optional output ptr to write the actual output-size to, can be NULL.
* @param microseconds Timing-related field in microseconds.
*/
Result nfcSendTagCommand(const void *inbuf, size_t insize, void *outbuf, size_t outsize, size_t *actual_transfer_size, u64 microseconds);
/**
* @brief Unknown. This can only be used when initialized with NFC_OpType_RawNFC, and when the TagState is NFC_TagState_InRange.
*/
Result nfcCmd21(void);
/**
* @brief Unknown. This can only be used when initialized with NFC_OpType_RawNFC, and when the TagState is NFC_TagState_InRange.
*/
Result nfcCmd22(void);

151
.vscode/dummyinclude/3ds/services/nim.h vendored Normal file
View file

@ -0,0 +1,151 @@
/**
* @file nim.h
* @brief NIM (network installation management) service.
*
* This service is used to download and install titles from Nintendo's CDN.
*
* We differentiate between two different kinds of downloads:
*
* - "active" downloads, which are downloads started with @ref NIMS_StartDownload or @ref NIMS_StartDownloadSimple. The process must keep polling the current status using @ref NIMS_GetProgress.
* - "tasks", which are downloads started with @ref NIMS_RegisterTask. These are only processed in sleep mode.
*/
#pragma once
// FS_MediaType
#include <3ds/services/fs.h>
/// Mode that NIM downloads/installs a title with.
typedef enum
{
IM_DEFAULT = 0, ///< Initial installation
IM_UNKNOWN1, ///< Unknown
IM_UNKNOWN2, ///< Unknown
IM_REINSTALL, ///< Reinstall currently installed title; use this if the title is already installed (including updates)
} NIM_InstallationMode;
/// Current state of a NIM download/installation.
typedef enum
{
DS_NOT_INITIALIZED = 0, ///< Download not yet initialized
DS_INITIALIZED, ///< Download initialized
DS_DOWNLOAD_TMD, ///< Downloading and installing TMD
DS_PREPARE_SAVE_DATA, ///< Initializing save data
DS_DOWNLOAD_CONTENTS, ///< Downloading and installing contents
DS_WAIT_COMMIT, ///< Waiting before calling AM_CommitImportTitles
DS_COMMITTING, ///< Running AM_CommitImportTitles
DS_FINISHED, ///< Title installation finished
DS_VERSION_ERROR, ///< (unknown error regarding title version)
DS_CREATE_CONTEXT, ///< Creating the .ctx file?
DS_CANNOT_RECOVER, ///< Irrecoverable error encountered (e.g. out of space)
DS_INVALID, ///< Invalid state
} NIM_DownloadState;
/// Input configuration for NIM download/installation tasks.
typedef struct
{
u64 titleId; ///< Title ID
u32 version; ///< Title version
u32 unknown_0; ///< Always 0
u8 ratingAge; ///< Age for the HOME Menu parental controls
u8 mediaType; ///< Media type, see @ref FS_MediaType enum
u8 padding[2]; ///< Padding
u32 unknown_1; ///< Unknown input, seems to be always 0
} NIM_TitleConfig;
/// Output struct for NIM downloads/installations in progress.
typedef struct
{
u32 state; ///< State, see NIM_DownloadState enum
Result lastResult; ///< Last result code in NIM
u64 downloadedSize; ///< Amount of bytes that have been downloaded
u64 totalSize; ///< Amount of bytes that need to be downloaded in total
} NIM_TitleProgress;
/**
* @brief Initializes nim:s. This uses networking and is blocking.
* @param buffer A buffer for internal use. It must be at least 0x20000 bytes long.
* @param buffer_len Length of the passed buffer.
*/
Result nimsInit(void *buffer, size_t buffer_len);
/**
* @brief Initializes nim:s with the given TIN. This uses networking and is blocking.
* @param buffer A buffer for internal use. It must be at least 0x20000 bytes long.
* @param buffer_len Length of the passed buffer.
* @param TIN The TIN to initialize nim:s with. If you do not know what a TIN is or why you would want to change it, use @ref nimsInit instead.
*/
Result nimsInitWithTIN(void *buffer, size_t buffer_len, const char *TIN);
/// Exits nim:s.
void nimsExit(void);
/// Gets the current nim:s session handle.
Handle *nimsGetSessionHandle(void);
/**
* @brief Sets an attribute.
* @param attr Name of the attribute.
* @param val Value of the attribute.
*/
Result NIMS_SetAttribute(const char *attr, const char *val);
/**
* @brief Checks if nim wants a system update.
* @param want_update Set to true if a system update is required. Can be NULL.
*/
Result NIMS_WantUpdate(bool *want_update);
/**
* @brief Makes a TitleConfig struct for use with @ref NIMS_RegisterTask, @ref NIMS_StartDownload or @ref NIMS_StartDownloadSimple.
* @param cfg Struct to initialize.
* @param titleId Title ID to download and install.
* @param version Version of the title to download and install.
* @param ratingAge Age for which the title is aged; used by parental controls in HOME Menu.
* @param mediaType Media type of the title to download and install.
*/
void NIMS_MakeTitleConfig(NIM_TitleConfig *cfg, u64 titleId, u32 version, u8 ratingAge, FS_MediaType mediaType);
/**
* @brief Registers a background download task with NIM. These are processed in sleep mode only.
* @param cfg Title config to use. See @ref NIMS_MakeTitleConfig.
* @param name Name of the title in UTF-8. Will be displayed on the HOME Menu. Maximum 73 characters.
* @param maker Name of the maker/publisher in UTF-8. Will be displayed on the HOME Menu. Maximum 37 characters.
*/
Result NIMS_RegisterTask(const NIM_TitleConfig *cfg, const char *name, const char *maker);
/**
* @brief Checks whether a background download task for the given title is registered with NIM.
* @param titleId Title ID to check for.
* @param registered Whether there is a background download task registered.
*/
Result NIMS_IsTaskRegistered(u64 titleId, bool *registered);
/**
* @brief Unregisters a background download task.
* @param titleId Title ID whose background download task to cancel.
*/
Result NIMS_UnregisterTask(u64 titleId);
/**
* @brief Starts an active download with NIM. Progress can be checked with @ref NIMS_GetProcess. Do not exit the process while a download is in progress without calling @ref NIMS_CancelDownload.
* @param cfg Title config to use. See @ref NIMS_MakeTitleConfig.
* @param mode The installation mode to use. See @ref NIM_InstallationMode.
*/
Result NIMS_StartDownload(const NIM_TitleConfig *cfg, NIM_InstallationMode mode);
/**
* @brief Starts an active download with NIM with default installation mode; cannot reinstall titles. Progress can be checked with @ref NIMS_GetProcess. Do not exit the process while a download is in progress without calling @ref NIMS_CancelDownload.
* @param cfg Title config to use. See @ref NIMS_MakeTitleConfig.
*/
Result NIMS_StartDownloadSimple(const NIM_TitleConfig *cfg);
/**
* @brief Checks the status of the current active download.
* @param tp Title progress struct to write to. See @ref NIM_TitleProgress.
*/
Result NIMS_GetProgress(NIM_TitleProgress *tp);
/**
* @brief Cancels the current active download with NIM.
*/
Result NIMS_CancelDownload(void);

51
.vscode/dummyinclude/3ds/services/ns.h vendored Normal file
View file

@ -0,0 +1,51 @@
/**
* @file ns.h
* @brief NS (Nintendo Shell) service.
*/
#pragma once
/// Initializes NS.
Result nsInit(void);
/// Exits NS.
void nsExit(void);
/**
* @brief Launches a title and the required firmware (only if necessary).
* @param titleid ID of the title to launch, 0 for gamecard, JPN System Settings' titleID for System Settings.
*/
Result NS_LaunchFIRM(u64 titleid);
/**
* @brief Launches a title.
* @param titleid ID of the title to launch, or 0 for gamecard.
* @param launch_flags Flags used when launching the title.
* @param procid Pointer to write the process ID of the launched title to.
*/
Result NS_LaunchTitle(u64 titleid, u32 launch_flags, u32 *procid);
/// Terminates the application from which this function is called
Result NS_TerminateTitle(void);
/**
* @brief Launches a title and the required firmware.
* @param titleid ID of the title to launch, 0 for gamecard.
* @param flags Flags for firm-launch. bit0: require an application title-info structure in FIRM paramters to be specified via FIRM parameters. bit1: if clear, NS will check certain Configuration Memory fields.
*/
Result NS_LaunchApplicationFIRM(u64 titleid, u32 flags);
/**
* @brief Reboots to a title.
* @param mediatype Mediatype of the title.
* @param titleid ID of the title to launch.
*/
Result NS_RebootToTitle(u8 mediatype, u64 titleid);
/**
* @brief Terminates the process with the specified titleid.
* @param titleid ID of the title to terminate.
* @param timeout Timeout in nanoseconds. Pass 0 if not required.
*/
Result NS_TerminateProcessTID(u64 titleid, u64 timeout);
/// Reboots the system
Result NS_RebootSystem(void);

View file

@ -0,0 +1,13 @@
#pragma once
// Initializes NWMEXT.
Result nwmExtInit(void);
// Exits NWMEXT.
void nwmExtExit(void);
/**
* @brief Turns wireless on or off.
* @param enableWifi True enables it, false disables it.
*/
Result NWMEXT_ControlWirelessEnabled(bool enableWifi);

View file

@ -0,0 +1,123 @@
/**
* @file pmapp.h
* @brief PM (Process Manager) application service.
*/
#pragma once
#include <3ds/services/fs.h>
#include <3ds/exheader.h>
/// Launch flags for PM launch commands.
enum {
PMLAUNCHFLAG_NORMAL_APPLICATION = BIT(0),
PMLAUNCHFLAG_LOAD_DEPENDENCIES = BIT(1),
PMLAUNCHFLAG_NOTIFY_TERMINATION = BIT(2),
PMLAUNCHFLAG_QUEUE_DEBUG_APPLICATION = BIT(3),
PMLAUNCHFLAG_TERMINATION_NOTIFICATION_MASK = 0xF0,
PMLAUNCHFLAG_FORCE_USE_O3DS_APP_MEM = BIT(8), ///< Forces the usage of the O3DS system mode app memory setting even if N3DS system mode is not "Legacy". Dev4 and Dev5 not supported. N3DS only.
PMLAUNCHFLAG_FORCE_USE_O3DS_MAX_APP_MEM = BIT(9), ///< In conjunction with the above, forces the 96MB app memory setting. N3DS only.
PMLAUNCHFLAG_USE_UPDATE_TITLE = BIT(16),
};
/// Initializes pm:app.
Result pmAppInit(void);
/// Exits pm:app.
void pmAppExit(void);
/**
* @brief Gets the current pm:app session handle.
* @return The current pm:app session handle.
*/
Handle *pmAppGetSessionHandle(void);
/**
* @brief Launches a title.
* @param programInfo Program information of the title.
* @param launchFlags Flags to launch the title with.
*/
Result PMAPP_LaunchTitle(const FS_ProgramInfo *programInfo, u32 launchFlags);
/**
* @brief Launches a title, applying patches.
* @param programInfo Program information of the title.
* @param programInfoUpdate Program information of the update title.
* @param launchFlags Flags to launch the title with.
*/
Result PMAPP_LaunchTitleUpdate(const FS_ProgramInfo *programInfo, const FS_ProgramInfo *programInfoUpdate, u32 launchFlags);
/**
* @brief Gets a title's ExHeader Arm11CoreInfo and SystemInfo flags.
* @param[out] outCoreInfo Pointer to write the ExHeader Arm11CoreInfo to.
* @param[out] outSiFlags Pointer to write the ExHeader SystemInfo flags to.
* @param programInfo Program information of the title.
*/
Result PMAPP_GetTitleExheaderFlags(ExHeader_Arm11CoreInfo* outCoreInfo, ExHeader_SystemInfoFlags* outSiFlags, const FS_ProgramInfo *programInfo);
/**
* @brief Sets the current FIRM launch parameters.
* @param size Size of the FIRM launch parameter buffer.
* @param in Buffer to retrieve the launch parameters from.
*/
Result PMAPP_SetFIRMLaunchParams(u32 size, const void* in);
/**
* @brief Gets the current FIRM launch parameters.
* @param size Size of the FIRM launch parameter buffer.
* @param[out] out Buffer to write the launch parameters to.
*/
Result PMAPP_GetFIRMLaunchParams(void *out, u32 size);
/**
* @brief Sets the current FIRM launch parameters.
* @param firmTidLow Low Title ID of the FIRM title to launch.
* @param size Size of the FIRM launch parameter buffer.
* @param in Buffer to retrieve the launch parameters from.
*/
Result PMAPP_LaunchFIRMSetParams(u32 firmTidLow, u32 size, const void* in);
/**
* @brief Terminate most processes, to prepare for a reboot or a shutdown.
* @param timeout Time limit in ns for process termination, after which the remaining processes are killed.
*/
Result PMAPP_PrepareForReboot(s64 timeout);
/**
* @brief Terminates the current Application
* @param timeout Timeout in nanoseconds
*/
Result PMAPP_TerminateCurrentApplication(s64 timeout);
/**
* @brief Terminates the processes having the specified titleId.
* @param titleId Title ID of the processes to terminate
* @param timeout Timeout in nanoseconds
*/
Result PMAPP_TerminateTitle(u64 titleId, s64 timeout);
/**
* @brief Terminates the specified process
* @param pid Process-ID of the process to terminate
* @param timeout Timeout in nanoseconds
*/
Result PMAPP_TerminateProcess(u32 pid, s64 timeout);
/**
* @brief Unregisters a process
* @param tid TitleID of the process to unregister
*/
Result PMAPP_UnregisterProcess(u64 tid);
/**
* @brief Sets the APPLICATION cputime reslimit.
* @param cpuTime Reslimit value.
* @note cpuTime can be no higher than reslimitdesc[0] & 0x7F in exheader (or 80 if the latter is 0).
*/
Result PMAPP_SetAppResourceLimit(s64 cpuTime);
/**
* @brief Gets the APPLICATION cputime reslimit.
* @param[out] cpuTime Pointer to write the reslimit value to.
*/
Result PMAPP_GetAppResourceLimit(s64 *outCpuTime);

View file

@ -0,0 +1,41 @@
/**
* @file pmdbg.h
* @brief PM (Process Manager) debug service.
*/
#pragma once
#include <3ds/services/pmapp.h>
/// Initializes pm:dbg.
Result pmDbgInit(void);
/// Exits pm:dbg.
void pmDbgExit(void);
/**
* @brief Gets the current pm:dbg session handle.
* @return The current pm:dbg session handle.
*/
Handle *pmDbgGetSessionHandle(void);
/**
* @brief Enqueues an application for debug after setting cpuTime to 0, and returns a debug handle to it.
* If another process was enqueued, this just calls @ref RunQueuedProcess instead.
* @param[out] Pointer to output the debug handle to.
* @param programInfo Program information of the title.
* @param launchFlags Flags to launch the title with.
*/
Result PMDBG_LaunchAppDebug(Handle *outDebug, const FS_ProgramInfo *programInfo, u32 launchFlags);
/**
* @brief Launches an application for debug after setting cpuTime to 0.
* @param programInfo Program information of the title.
* @param launchFlags Flags to launch the title with.
*/
Result PMDBG_LaunchApp(const FS_ProgramInfo *programInfo, u32 launchFlags);
/**
* @brief Runs the queued process and returns a debug handle to it.
* @param[out] Pointer to output the debug handle to.
*/
Result PMDBG_RunQueuedProcess(Handle *outDebug);

116
.vscode/dummyinclude/3ds/services/ps.h vendored Normal file
View file

@ -0,0 +1,116 @@
/**
* @file ps.h
* @brief PS service.
*/
#pragma once
/// PS AES algorithms.
typedef enum
{
PS_ALGORITHM_CBC_ENC, ///< CBC encryption.
PS_ALGORITHM_CBC_DEC, ///< CBC decryption.
PS_ALGORITHM_CTR_ENC, ///< CTR encryption.
PS_ALGORITHM_CTR_DEC, ///< CTR decryption(same as PS_ALGORITHM_CTR_ENC).
PS_ALGORITHM_CCM_ENC, ///< CCM encryption.
PS_ALGORITHM_CCM_DEC, ///< CCM decryption.
} PS_AESAlgorithm;
/// PS key slots.
typedef enum
{
PS_KEYSLOT_0D, ///< Key slot 0x0D.
PS_KEYSLOT_2D, ///< Key slot 0x2D.
PS_KEYSLOT_31, ///< Key slot 0x31.
PS_KEYSLOT_38, ///< Key slot 0x38.
PS_KEYSLOT_32, ///< Key slot 0x32.
PS_KEYSLOT_39_DLP, ///< Key slot 0x39. (DLP)
PS_KEYSLOT_2E, ///< Key slot 0x2E.
PS_KEYSLOT_INVALID, ///< Invalid key slot.
PS_KEYSLOT_36, ///< Key slot 0x36.
PS_KEYSLOT_39_NFC ///< Key slot 0x39. (NFC)
} PS_AESKeyType;
/// RSA context.
typedef struct {
u8 modulo[0x100];
u8 exponent[0x100];
u32 rsa_bitsize;//The signature byte size is rsa_bitsize>>3.
u32 unk;//Normally zero?
} psRSAContext;
/// Initializes PS.
Result psInit(void);
/**
* @brief Initializes PS with the specified session handle.
* @param handle Session handle.
*/
Result psInitHandle(Handle handle);
/// Exits PS.
void psExit(void);
/// Returns the PS session handle.
Handle psGetSessionHandle(void);
/**
* @brief Signs a RSA signature.
* @param hash SHA256 hash to sign.
* @param ctx RSA context.
* @param signature RSA signature.
*/
Result PS_SignRsaSha256(u8 *hash, psRSAContext *ctx, u8 *signature);
/**
* @brief Verifies a RSA signature.
* @param hash SHA256 hash to compare with.
* @param ctx RSA context.
* @param signature RSA signature.
*/
Result PS_VerifyRsaSha256(u8 *hash, psRSAContext *ctx, u8 *signature);
/**
* @brief Encrypts/Decrypts AES data. Does not support AES CCM.
* @param size Size of the data.
* @param in Input buffer.
* @param out Output buffer.
* @param aes_algo AES algorithm to use.
* @param key_type Key type to use.
* @param iv Pointer to the CTR/IV. The output CTR/IV is also written here.
*/
Result PS_EncryptDecryptAes(u32 size, u8* in, u8* out, PS_AESAlgorithm aes_algo, PS_AESKeyType key_type, u8* iv);
/**
* @brief Encrypts/Decrypts signed AES CCM data.
* When decrypting, if the MAC is invalid, 0xC9010401 is returned. After encrypting the MAC is located at inputbufptr.
* @param in Input buffer.
* @param in_size Size of the input buffer. Must include MAC size when decrypting.
* @param out Output buffer.
* @param out_size Size of the output buffer. Must include MAC size when encrypting.
* @param data_len Length of the data to be encrypted/decrypted.
* @param mac_data_len Length of the MAC data.
* @param mac_len Length of the MAC.
* @param aes_algo AES algorithm to use.
* @param key_type Key type to use.
* @param nonce Pointer to the nonce.
*/
Result PS_EncryptSignDecryptVerifyAesCcm(u8* in, u32 in_size, u8* out, u32 out_size, u32 data_len, u32 mac_data_len, u32 mac_len, PS_AESAlgorithm aes_algo, PS_AESKeyType key_type, u8* nonce);
/**
* @brief Gets the 64-bit console friend code seed.
* @param seed Pointer to write the friend code seed to.
*/
Result PS_GetLocalFriendCodeSeed(u64* seed);
/**
* @brief Gets the 32-bit device ID.
* @param device_id Pointer to write the device ID to.
*/
Result PS_GetDeviceId(u32* device_id);
/**
* @brief Generates cryptographically secure random bytes.
* @param out Pointer to the buffer to write the bytes to.
* @param len Number of bytes to write.
*/
Result PS_GenerateRandomBytes(void* out, size_t len);

View file

@ -0,0 +1,25 @@
/**
* @file ptmgets.h
* @brief PTMGETS service.
*/
#pragma once
#include <3ds/types.h>
/// Initializes PTMGETS.
Result ptmGetsInit(void);
/// Exits PTMGETS.
void ptmGetsExit(void);
/**
* @brief Gets a pointer to the current ptm:gets session handle.
* @return A pointer to the current ptm:gets session handle.
*/
Handle *ptmGetsGetSessionHandle(void);
/**
* @brief Gets the system time.
* @param[out] outMsY2k The pointer to write the number of milliseconds since 01/01/2000 to.
*/
Result PTMGETS_GetSystemTime(s64 *outMsY2k);

View file

@ -0,0 +1,25 @@
/**
* @file ptmsets.h
* @brief PTMSETS service.
*/
#pragma once
#include <3ds/types.h>
/// Initializes PTMSETS.
Result ptmSetsInit(void);
/// Exits PTMSETS.
void ptmSetsExit(void);
/**
* @brief Gets a pointer to the current ptm:sets session handle.
* @return A pointer to the current ptm:sets session handle.
*/
Handle *ptmSetsGetSessionHandle(void);
/**
* @brief Sets the system time.
* @param msY2k The number of milliseconds since 01/01/2000.
*/
Result PTMSETS_SetSystemTime(s64 msY2k);

View file

@ -0,0 +1,133 @@
/**
* @file ptmsysm.h
* @brief PTMSYSM service.
*/
#pragma once
#include <3ds/types.h>
/// PDN wake events and MCU interrupts to select, combined with those of other processes
typedef struct PtmWakeEvents {
u32 pdn_wake_events; ///< Written to PDN_WAKE_EVENTS. Don't select bit26 (MCU), PTM will do it automatically.
u32 mcu_interupt_mask; ///< MCU interrupts to check when a MCU wake event happens.
} PtmWakeEvents;
typedef struct {
PtmWakeEvents exit_sleep_events; ///< Wake events for which the system should fully wake up.
PtmWakeEvents continue_sleep_events; ///< Wake events for which the system should return to sleep.
} PtmSleepConfig;
enum {
// Sleep FSM notification IDs
PTMNOTIFID_SLEEP_REQUESTED = 0x101, ///< @ref PTMSYSM_RequestSleep has been called (ack = 3)
PTMNOTIFID_SLEEP_DENIED = 0x102, ///< The sleep request has been denied by @ref PTMSYSM_ReplyToSleepQuery(true) (no ack required).
PTMNOTIFID_SLEEP_ALLOWED = 0x103, ///< The sleep request has been allowed by @ref PTMSYSM_ReplyToSleepQuery(false) (ack = 1).
PTMNOTIFID_GOING_TO_SLEEP = 0x104, ///< All processes not having "RunnableOnSleep" have been paused & the system is about to go to sleep (ack = 0).
PTMNOTIFID_FULLY_WAKING_UP = 0x105, ///< The system has been woken up, and the paused processes are about to be unpaused (ack = 1).
PTMNOTIFID_FULLY_AWAKE = 0x106, ///< The system is fully awake (no ack required).
PTMNOTIFID_HALF_AWAKE = 0x107, ///< The system has been woken up but is about to go to sleep again (ack = 2).
PTMNOTIFID_SHUTDOWN = 0x108, ///< The system is about to power off or reboot.
PTMNOTIFID_BATTERY_VERY_LOW = 0x211, ///< The battery level has reached 5% or below.
PTMNOTIFID_BATTERY_LOW = 0x212, ///< The battery level has reached 10% or below.
};
/// See @ref PTMSYSM_NotifySleepPreparationComplete. Corresponds to the number of potentially remaning notifs. until sleep/wakeup.
static inline s32 ptmSysmGetNotificationAckValue(u32 id)
{
static const s32 values[] = { 3, -1, 1, 0, 0, -1, 2 };
if (id < PTMNOTIFID_SLEEP_REQUESTED || id > PTMNOTIFID_HALF_AWAKE)
return -1;
return values[id - PTMNOTIFID_SLEEP_REQUESTED];
}
/// Initializes ptm:sysm.
Result ptmSysmInit(void);
/// Exits ptm:sysm.
void ptmSysmExit(void);
/**
* @brief Gets a pointer to the current ptm:sysm session handle.
* @return A pointer to the current ptm:sysm session handle.
*/
Handle *ptmSysmGetSessionHandle(void);
/// Requests to enter sleep mode.
Result PTMSYSM_RequestSleep(void);
/**
* @brief Accepts or denies the incoming sleep mode request.
* @param deny Whether or not to deny the sleep request.
* @note If deny = false, this is equivalent to calling @ref PTMSYSM_NotifySleepPreparationComplete(3)
*/
Result PTMSYSM_ReplyToSleepQuery(bool deny);
/**
* @brief Acknowledges the current sleep notification and advance the internal sleep mode FSM. All subscribers must reply.
* @param ackValue Use @ref ptmSysmGetNotificationAckValue
* @note @ref PTMNOTIFID_SLEEP_DENIED and @ref PTMNOTIFID_FULLY_AWAKE don't require this.
*/
Result PTMSYSM_NotifySleepPreparationComplete(s32 ackValue);
/**
* @brief Sets the wake events (two sets: when to fully wake up and when to return to sleep).
* @param sleepConfig Pointer to the two sets of wake events.
* @note Can only be called just before acknowledging @ref PTMNOTIFID_GOING_TO_SLEEP or @ref PTMNOTIFID_HALF_AWAKE.
*/
Result PTMSYSM_SetWakeEvents(const PtmSleepConfig *sleepConfig);
/**
* @brief Gets the wake reason (only the first applicable wake event is taken into account).
* @param sleepConfig Pointer to the two sets of wake events. Only the relevant set will be filled.
*/
Result PTMSYSM_GetWakeReason(PtmSleepConfig *outSleepConfig);
/// Cancels the "half-awake" state and fully wakes up the 3DS after some delay.
Result PTMSYSM_Awaken(void);
/**
* @brief Sets the user time by updating the user time offset.
* @param msY2k The number of milliseconds since 01/01/2000.
*/
Result PTMSYSM_SetUserTime(s64 msY2k);
/// Invalidates the "system time" (cfg block 0x30002)
Result PTMSYSM_InvalidateSystemTime(void);
/**
* @brief Reads the time and date coming from the RTC and converts the result.
* @param[out] outMsY2k The pointer to write the number of milliseconds since 01/01/2000 to.
*/
Result PTMSYSM_GetRtcTime(s64 *outMsY2k);
/**
* @brief Writes the time and date coming to the RTC, after conversion.
* @param msY2k The number of milliseconds since 01/01/2000.
*/
Result PTMSYSM_SetRtcTime(s64 msY2k);
/**
* @brief Checks whether the system is a New 3DS.
* @param[out] out Pointer to write the New 3DS flag to.
*/
Result PTMSYSM_CheckNew3DS(bool *out);
/**
* @brief Configures the New 3DS' CPU clock speed and L2 cache.
* @param value Bit0: enable higher clock, Bit1: enable L2 cache.
*/
Result PTMSYSM_ConfigureNew3DSCPU(u8 value);
/**
* @brief Trigger a hardware system shutdown via the MCU.
* @param timeout: timeout passed to PMApp:ShutdownAsync (PrepareForReboot).
*/
Result PTMSYSM_ShutdownAsync(u64 timeout);
/**
* @brief Trigger a hardware system reboot via the MCU.
* @param timeout: timeout passed to PMApp:ShutdownAsync (PrepareForReboot).
*/
Result PTMSYSM_RebootAsync(u64 timeout);

View file

@ -0,0 +1,53 @@
/**
* @file ptmu.h
* @brief PTMU service.
*/
#pragma once
/// Initializes PTMU.
Result ptmuInit(void);
/// Exits PTMU.
void ptmuExit(void);
/**
* @brief Gets a pointer to the current ptm:u session handle.
* @return A pointer to the current ptm:u session handle.
*/
Handle *ptmuGetSessionHandle(void);
/**
* @brief Gets the system's current shell state.
* @param out Pointer to write the current shell state to. (0 = closed, 1 = open)
*/
Result PTMU_GetShellState(u8 *out);
/**
* @brief Gets the system's current battery level.
* @param out Pointer to write the current battery level to. (0-5)
*/
Result PTMU_GetBatteryLevel(u8 *out);
/**
* @brief Gets the system's current battery charge state.
* @param out Pointer to write the current battery charge state to. (0 = not charging, 1 = charging)
*/
Result PTMU_GetBatteryChargeState(u8 *out);
/**
* @brief Gets the system's current pedometer state.
* @param out Pointer to write the current pedometer state to. (0 = not counting, 1 = counting)
*/
Result PTMU_GetPedometerState(u8 *out);
/**
* @brief Gets the pedometer's total step count.
* @param steps Pointer to write the total step count to.
*/
Result PTMU_GetTotalStepCount(u32 *steps);
/**
* @brief Gets whether the adapter is plugged in or not
* @param out Pointer to write the adapter state to.
*/
Result PTMU_GetAdapterState(bool *out);

View file

@ -0,0 +1,79 @@
/**
* @file pxidev.h
* @brief Gamecard PXI service.
*/
#pragma once
#include <3ds/services/fs.h>
/// Card SPI wait operation type.
typedef enum {
WAIT_NONE = 0, ///< Do not wait.
WAIT_SLEEP = 1, ///< Sleep for the specified number of nanoseconds.
WAIT_IREQ_RETURN = 2, ///< Wait for IREQ, return if timeout.
WAIT_IREQ_CONTINUE = 3 ///< Wait for IREQ, continue if timeout.
} PXIDEV_WaitType;
/// Card SPI register deassertion type.
typedef enum {
DEASSERT_NONE = 0, ///< Do not deassert.
DEASSERT_BEFORE_WAIT = 1, ///< Deassert before waiting.
DEASSERT_AFTER_WAIT = 2 ///< Deassert after waiting.
} PXIDEV_DeassertType;
/// Card SPI transfer buffer.
typedef struct {
void* ptr; ///< Data pointer.
u32 size; ///< Data size.
u8 transferOption; ///< Transfer options. See @ref pxiDevMakeTransferOption
u64 waitOperation; ///< Wait operation. See @ref pxiDevMakeWaitOperation
} PXIDEV_SPIBuffer;
/// Initializes pxi:dev.
Result pxiDevInit(void);
/// Shuts down pxi:dev.
void pxiDevExit(void);
/**
* @brief Creates a packed card SPI transfer option value.
* @param baudRate Baud rate to use when transferring.
* @param busMode Bus mode to use when transferring.
* @return A packed card SPI transfer option value.
*/
static inline u8 pxiDevMakeTransferOption(FS_CardSpiBaudRate baudRate, FS_CardSpiBusMode busMode)
{
return (baudRate & 0x3F) | ((busMode & 0x3) << 6);
}
/**
* @brief Creates a packed card SPI wait operation value.
* @param waitType Type of wait to perform.
* @param deassertType Type of register deassertion to perform.
* @param timeout Timeout, in nanoseconds, to wait, if applicable.
* @return A packed card SPI wait operation value.
*/
static inline u64 pxiDevMakeWaitOperation(PXIDEV_WaitType waitType, PXIDEV_DeassertType deassertType, u64 timeout)
{
return (waitType & 0xF) | ((deassertType & 0xF) << 4) | ((timeout & 0xFFFFFFFFFFFFFF) << 8);
}
/**
* @brief Performs multiple card SPI writes and reads.
* @param header Header to lead the transfers with. Must be, at most, 8 bytes in size.
* @param writeBuffer1 Buffer to make first transfer from.
* @param readBuffer1 Buffer to receive first response to.
* @param writeBuffer2 Buffer to make second transfer from.
* @param readBuffer2 Buffer to receive second response to.
* @param footer Footer to follow the transfers with. Must be, at most, 8 bytes in size. Wait operation is unused.
*/
Result PXIDEV_SPIMultiWriteRead(PXIDEV_SPIBuffer* header, PXIDEV_SPIBuffer* writeBuffer1, PXIDEV_SPIBuffer* readBuffer1, PXIDEV_SPIBuffer* writeBuffer2, PXIDEV_SPIBuffer* readBuffer2, PXIDEV_SPIBuffer* footer);
/**
* @brief Performs a single card SPI write and read.
* @param bytesRead Pointer to output the number of bytes received to.
* @param initialWaitOperation Wait operation to perform before transferring data.
* @param writeBuffer Buffer to transfer data from.
* @param readBuffer Buffer to receive data to.
*/
Result PXIDEV_SPIWriteRead(u32* bytesRead, u64 initialWaitOperation, PXIDEV_SPIBuffer* writeBuffer, PXIDEV_SPIBuffer* readBuffer);

View file

@ -0,0 +1,42 @@
/**
* @file pxipm.h
* @brief Process Manager PXI service
*/
#pragma once
#include <3ds/exheader.h>
#include <3ds/services/fs.h>
/// Initializes PxiPM.
Result pxiPmInit(void);
/// Exits PxiPM.
void pxiPmExit(void);
/**
* @brief Gets the current PxiPM session handle.
* @return The current PxiPM session handle.
*/
Handle *pxiPmGetSessionHandle(void);
/**
* @brief Retrives the exheader information set(s) (SCI+ACI) about a program.
* @param exheaderInfos[out] Pointer to the output exheader information set.
* @param programHandle The program handle.
*/
Result PXIPM_GetProgramInfo(ExHeader_Info *exheaderInfo, u64 programHandle);
/**
* @brief Loads a program and registers it to Process9.
* @param programHandle[out] Pointer to the output the program handle to.
* @param programInfo Information about the program to load.
* @param updateInfo Information about the program update to load.
*/
Result PXIPM_RegisterProgram(u64 *programHandle, const FS_ProgramInfo *programInfo, const FS_ProgramInfo *updateInfo);
/**
* @brief Unloads a program and unregisters it from Process9.
* @param programHandle The program handle.
*/
Result PXIPM_UnregisterProgram(u64 programHandle);

559
.vscode/dummyinclude/3ds/services/qtm.h vendored Normal file
View file

@ -0,0 +1,559 @@
/**
* @file qtm.h
* @brief QTM services.
*
* QTM is responsible for the following:
* - tracking and predicting the position of the user's eyes. This is done by using the inner
* camera sampling at 320x240px at 30 FPS, and by using the gyroscope to predict the position
* of the eyes between two camera samples (effectively doubling the tracking rate).
* The API reporting eye tracking data is actually *console-agnostic*. This concept is most
* likely covered by patent US9098112B2
* - automatically managing the IR LED emitter used for eye tracking in low-light conditions
* - managing the state of the parallax barrier by controlling the positions of the barrier's
* mask (opaque/transparent state by repeating pattern of 12 units, plus polarity). This is
* done via a TI TCA6416A I2C->Parallel expander (highlighted in yellow in this teardown photo:
* https://guide-images.cdn.ifixit.com/igi/IKlW6WTZKKmapYkt.full, with the expected 12 traces
* being clearly visible near the ribbon cable slot)
* - updating the barrier position according to eye tracking data relative to an optimal setting
* stored in calibration data: this is what Nintendo calls "Super Stable 3D" (SS3D); not done
* when in 2D mode
*
* Head-tracking can be used even if SS3D is disabled.
*
* SS3D works as follows:
* - compute the raw X and Y pixel coordinates for the eye midpoint:
* `rawX = (leftEyeRawPxCoords.x + rightEyeRawPxCoords.x) / 2`
* `rawY = (leftEyeRawPxCoords.y + rightEyeRawPxCoords.y) / 2`
* - rotate the value around the optical Z-axis using the optimal eye-to-camera angle from
* calibration data, with a rotation matrix
* - normalize the X value:
* `xC = (rawX / 320) - 0.5`
* - transform into world space coordinate, using fovX from calibration (convert to radians first).
* Note that this fovX doesn't take lens distortion into account and is slightly different from
* the hardcoded angle used in \ref QTMU_GetTrackingData
* `x = xC * tan(fovX/2)`
* - multiply by length of adjacent side (eye-to-camera distance) to get the length of the opposite
* side. This is the eye horizontal deviation to camera lens in mm, which is then converted to
* number of iod/12 units:
* `delta = x * optimalDistance / (iod/12)`
* - we then obtain the new target position of the parallax barrier (expressed in iod/12 units,
* mod iod/12):
* `pos = centerPos + delta`
* - the value is then rounded to nearest integer. To avoid artifacts, if the rounded value is
* going to increase, then 0.01 is subtracted, and if it is going to decrease, then 0.01 is added.
* The value is rounded again to compute the final discrete value written to the expander (barrier
* position).
* - note: all calculation in QTM and otherwise assume interocular distance to be 62mm (the average).
* Assumedly, if the user's IOD is different, then "optimal distance to screen" effectively changes
* for that user.
*
* QTM services are not present on O3DS, thus caller must call \ref qtmCheckServicesRegistered to check
* if the services are registered. Moreover, since QTM functionality might not always be available (due
* to blacklist or console being N2DSXL), `qtm:u` users should check Result return values, and `qtm:s`
* users can call \ref QTMS_SetQtmStatus to check the actual availability status.
*
* Considering that the eye tracking data reporting API is hardware-agnostic, it is advisable to
* hardcode neither camera aspect ratio (even if it is 4/3 on real hardware) and resolution nor
* field-of-view angle.
*
* There is a separate QTM service, `qtm:c` ("hardware check"), that lets you manipulate parallax barrier
* pattern directly. It is covered in \ref qtmc.h instead.
*/
#pragma once
#include <3ds/types.h>
/// ID of QTM status data (fully enabled/SS3D disabled) in `cfg`
#define QTM_STATUS_CFG_BLK_ID 0x180000u
/// ID of QTM calibration data in `cfg`
#define QTM_CAL_CFG_BLK_ID 0x180001u
/**
* @brief QTM enablement status (when cameras not in use by user), set by `qtm:s`.
* @note Manual IR LED control, camera lux, and `qtm:c` commands remain available
* for use on N3DS and N3DSXL regardless.
*/
typedef enum QtmStatus {
QTM_STATUS_ENABLED = 0, ///< QTM is fully enabled.
QTM_STATUS_SS3D_DISABLED = 1, ///< QTM "super stable 3D" feature is disabled. Parallax barrier hardware state is configured to match O3DS.
/**
* @brief QTM is unavailable: either "blacklisted" (usually by NS) for the current title, **or console is a N2DSXL**.
*
* In this state, all QTM functionality is disabled. This includes "super-stable 3D"
* (ie. auto barrier adjustment) including `qtm:s` manual barrier position setting functions,
* head tracking, IR LED control and camera luminance reporting (400.0 is returned instead).
*
* @note `qtm:c` barrier hardware state setting function (\ref blah) bypasses this state.
* @note Due to an oversight, \ref QTMS_SetQtmStatus allows changing QTM state on N2DSXL. This is not intended
* to be done, and is in fact never done by official software.
*/
QTM_STATUS_UNAVAILABLE = 2,
} QtmStatus;
/// QTM status data (fully enabled/SS3D disabled) in `cfg`. Usually all-zero on N2DSXL.
typedef struct QtmStatusCfgData {
QtmStatus defaultStats; ///< QTM status at boot (fully enabled or SS3D disabled).
/**
* @brief "Global variable" (.data) section load mode? Unused.
* From CTRAging:
* - 0: "normal"
* - 1: "single reacq"
* - 2: "double reacq"
- 3/4/5: "w2w copy 1/10/100"
*/
u8 gvLoadMode;
u8 _padding[2]; ///< Padding.
} QtmStatusCfgData;
/// QTM calibration data (fully enabled/SS3D disabled) in `cfg`. Usually all-zero on N2DSXL.
typedef struct QtmCalibrationData {
/**
* @brief Neutral (center) barrier position/offset (with slit width of 6 units), when the user is
* facing directly facing the camera, that is to say, their eye midpoint normalized X coord
* in the camera's plane is 0, assuming the user's head is located at the expected viewing distance
* and at the expected eye-to-camera angle (as per the rest of this structure).
* This is expressed in terms of iod/12 units modulo iod/12 (thus, range is 0 to 11 included),
* with IOD (interocular distance) assumed to be 62mm.
* @note This field is floating-point for QTM auto-adjustment purposes, however the actual barrier
* position in hardware is an integer.
* @note This is the field that System Settings lets you add -1.0 to +1.0 to.
* @note Moreover, this field can be directly changed through \ref QTMS_SetCenterBarrierPosition.
*/
float centerBarrierPosition;
float translationX; ///< Lens X coord in inner camera space? Very low value and seems to be unused.
float translationY; ///< Lens Y coord in inner camera space? Very low value and seems to be unused.
float rotationZ; ///< Optimal eye-to-camera angle, in radians, without accounting for lens distortion.
float fovX; ///< Camera's horizontal FoV in degrees, without accounting for lens distortion.
float viewingDistance; ///< Optimal viewing distance between user and top screen, assuming iod to be 62mm.
} QtmCalibrationData;
/// Left eye or right eye, for \ref QtmTrackingData and \ref QtmRawTrackingData
typedef enum QtmEyeSide {
QTM_EYE_LEFT = 0, ///< Left eye.
QTM_EYE_RIGHT = 1, ///< Right eye.
QTM_EYE_NUM, ///< Number of eyes.
} QtmEyeSide;
/// QTM raw eye tracking data
typedef struct QtmRawTrackingData {
/**
* @brief Eye position detected or predicted, equals (confidenceLevel > 0).
* If false, QTM will attempt to make a guess based on gyro data.
* If the console isn't moving either, then QTM will assume the user's eyes are progressively
* moving back to face the screen.
*/
bool eyesTracked; ///< Eye position detected or predicted, equals (confidenceLevel > 0).
u8 _padding[3]; ///< Padding.
u32 singletonQtmPtr; ///< Pointer to eye-tracking singleton pointer, in QTM's .bss, located in N3DS extra memory.
float confidenceLevel; ///< Eye tracking confidence level (0 to 1).
/**
* @brief Raw predicted or detected eye coordinates. Each eye is represented as one point.
* Fractional part is *not* necessarily zero.
* @note X coord is within 0 to 320.
* @note Y coord is within 0 to 240.
*/
float rawEyeCameraCoordinates[QTM_EYE_NUM][2];
float dPitch; ///< Difference in gyro pitch from position at console boot.
float dYaw; ///< Difference in gyro yaw from position at console boot.
float dRoll; ///< Difference in gyro roll from position at console boot.
s64 samplingTick; ///< Time point the current measurements were made.
} QtmRawTrackingData;
/// QTM processed eye tracking data, suitable for 3D programming
typedef struct QtmTrackingData {
bool eyesTracked; ///< Eye position detected or tracked with some confidence, equals (confidenceLevel > 0). Even if false, QTM may make a guess
bool faceDetected; ///< Whether or not the entirety of the user's face has been detected with good confidence.
bool eyesDetected; ///< Whether or not the user's eyes have actually been detected with full confidence.
u8 _unused; ///< Unused.
bool clamped; ///< Whether or not the normalized eye coordinates have been clamped after accounting for lens distortion.
u8 _padding[3]; ///< Padding.
float confidenceLevel; ///< Eye tracking confidence level (0 to 1).
/**
* @brief Normalized eye coordinates, for each eye, after accounting for lens distortion, centered around camera.
* X coord is in the -1 to 1 range, and Y coord range depends on inverse aspect ratio (-0.75 to 0.75 on real hardware).
* @note On real hardware, X coord equals `((rawX / 160.0) - 1.00) * 1.0639` before clamping.
* @note On real hardware, Y coord equals `((rawY / 160.0) - 0.75) * 1.0637` before clamping.
*/
float eyeCameraCoordinates[QTM_EYE_NUM][2];
/**
* @brief Normalized eye coordinates, for each eye, in world space.
* Corresponds to \ref eyeCameraCoordinates multiplied by tangent of field of view.
* @note On real hardware, X coord equals `eyeCameraCoordinates.x * tan(64.9 deg / 2)`.
* @note On real hardware, Y coord equals `eyeCameraCoordinates.x * tan(51.0 deg / 2)`.
*/
float eyeWorldCoordinates[QTM_EYE_NUM][2];
float dPitch; ///< Difference in gyro pitch from position at console boot.
float dYaw; ///< Difference in gyro yaw from position at console boot.
float dRoll; ///< Difference in gyro roll from position at console boot.
s64 samplingTick; ///< Time point the current measurements were made.
} QtmTrackingData;
/// QTM service name enum, excluding `qtm:c`
typedef enum QtmServiceName {
/**
* @brief `qtm:u`: has eye-tracking commands and IR LED control commands, but for some
* reason cannot fetch ambiant lux data from the camera's luminosity sensor.
*/
QTM_SERVICE_USER = 0,
/**
* @brief `qtm:s`: has access to all `qtm:u` commands, plus luminosity sensor, plus
* manual barrier position setting and calibration adjustment commands.
* Automatic barrier control is reenabled on session exit.
*/
QTM_SERVICE_SYSTEM = 1,
/**
* @brief `qtm:sp`: has access to all `qtm:s` (and `qtm:u`) commands, and merely has a
* few more commands that GSP uses to notify QTM of 2D<>3D mode switches and
* power events. Automatic barrier control is reenabled on session exit.
* GSP always keeps a `qtm:sp` sessions open (at least on latest system version),
* whereas NS opens then immediately closes a `qtm:sp` sessions only when dealing
* with a "blacklisted" application (that is, almost never).
*/
QTM_SERVICE_SYSTEM_PROCESS = 2,
} QtmServiceName;
/**
* @brief Check whether or not QTM services are registered.
* @return True on O3DS systems, false on N3DS systems.
*/
bool qtmCheckServicesRegistered(void);
/**
* @brief Initializes QTM (except `qtm:c`).
* Excluding `qtm:c`, QTM has three main services.
* Only 3 sessions (2 until 9.3.0 sysupdate) for ALL services COMBINED, including `qtm:c`,
* can be open at a time.
* Refer to \ref QtmServiceName enum value descriptions to see which service to choose.
*
* @param serviceName QTM service name enum value (corresponding to `qtm:u`, `qtm:s` and `qtm:sp`
* respectively).
* @note Result of \ref qtmCheckServicesRegistered should be checked before calling this function.
*/
Result qtmInit(QtmServiceName serviceName);
/// Exits QTM.
void qtmExit(void);
/// Checks whether or not a `qtm:u`, `qtm:s` or `qtm:sp` session is active.
bool qtmIsInitialized(void);
/// Returns a pointer to the current `qtm:u` / `qtm:s` / `qtm:sp` session handle.
Handle *qtmGetSessionHandle(void);
/**
* @brief Gets the current raw eye tracking data, with an optional prediction made for predictionTimePointOrZero = t+dt,
* or for the current time point (QTM makes predictions based on gyro data since inner camera runs at 30 FPS).
*
* @param[out] outData Where to write the raw tracking data to. Cleared to all-zero on failure (instead of being left uninitialized).
* @param predictionTimePointOrZero Either zero, or the time point (in system ticks) for which to make a prediction for.
* Maximum 1 frame (at 30 FPS) in the past, and up to 5 frames in the future.
* @return `0xC8A18008` if camera is in use by user, or `0xC8A183EF` if QTM is unavailable (in particular, QTM is always
* unavailable on N2DSXL), Otherwise, 0 (success). Return value should be checked by caller.
* @note Consider using \ref QTMU_GetTrackingDataEx instead.
*/
Result QTMU_GetRawTrackingDataEx(QtmRawTrackingData *outData, s64 predictionTimePointOrZero);
/**
* @brief Gets the current raw eye tracking data.
*
* @param[out] outData Where to write the raw tracking data to. Cleared to all-zero on failure (instead of being left uninitialized).
* @return `0xC8A18008` if camera is in use by user, or `0xC8A183EF` if QTM is unavailable (in particular, QTM is always
* unavailable on N2DSXL), Otherwise, 0 (success). Return value should be checked by caller.
* @note Consider using \ref QTMU_GetTrackingData instead.
*/
static inline Result QTMU_GetRawTrackingData(QtmRawTrackingData *outData)
{
return QTMU_GetRawTrackingDataEx(outData, 0LL);
}
/**
* @brief Gets the current normalized eye tracking data, made suitable for 3D programming with an optional prediction made
* for predictionTimePointOrZero = t+dt, or for the current time point (QTM makes predictions based on gyro data since
* inner camera runs at 30 FPS).
*
* @param[out] outData Where to write the raw tracking data to. Cleared to all-zero on failure (instead of being left uninitialized).
* @param predictionTimePointOrZero Either zero, or the time point (in system ticks) for which to make a prediction for.
* Maximum 1 frame (at 30 FPS) in the past, and up to 5 frames in the future.
* @return `0xC8A18008` if camera is in use by user, or `0xC8A183EF` if QTM is unavailable (in particular, QTM is always
* unavailable on N2DSXL). Otherwise, 0 (success). Return value should be checked by caller.
* @note This can, for example, be used in games to allow the user to control the scene's camera with their own face.
*/
Result QTMU_GetTrackingDataEx(QtmTrackingData *outData, s64 predictionTimePointOrZero);
/**
* @brief Gets the current normalized eye tracking data, made suitable for 3D programming.
*
* @param[out] outData Where to write the raw tracking data to. Cleared to all-zero on failure (instead of being left uninitialized).
* @return `0xC8A18008` if camera is in use by user, or `0xC8A183EF` if QTM is unavailable (in particular, QTM is always
* unavailable on N2DSXL). Otherwise, 0 (success). Return value should be checked by caller.
* @note This can, for example, be used in games to allow the user to control the scene's camera with their own face.
*/
static inline Result QTMU_GetTrackingData(QtmTrackingData *outData)
{
return QTMU_GetTrackingDataEx(outData, 0LL);
}
/**
* @brief Computes an approximation of the horizontal angular field of view of the camera based on eye tracking data.
*
* @param data Eye tracking data, obtained from \ref QTMU_GetTrackingData or \ref QTMU_GetTrackingDataEx.
* @return Horizontal angular field of view in radians. Corresponds to 64.9 degrees on real hardware.
*/
float qtmComputeFovX(const QtmTrackingData *data);
/**
* @brief Computes an approximation of the vertical angular field of view of the camera based on eye tracking data.
*
* @param data Eye tracking data, obtained from \ref QTMU_GetTrackingData or \ref QTMU_GetTrackingDataEx.
* @return Vertical angular field of view in radians. Corresponds to 51.0 degrees on real hardware.
*/
float qtmComputeFovY(const QtmTrackingData *data);
/**
* @brief Computes a rough approximation of the inverse of the aspect ration of the camera based on eye tracking data.
*
* @param data Eye tracking data, obtained from \ref QTMU_GetTrackingData or \ref QTMU_GetTrackingDataEx.
* @return Rough approximation of the inverse of the aspect ratio of the camera. Aspect ratio is exactly 0.75 on real hardware.
*/
float qtmComputeInverseAspectRatio(const QtmTrackingData *data);
/**
* @brief Computes the user's head tilt angle, that is, the angle between the line through both eyes and the camera's
* horizontal axis in camera space.
*
* @param data Eye tracking data, obtained from \ref QTMU_GetTrackingData or \ref QTMU_GetTrackingDataEx.
* @return Horizontal head angle relative to camera, in radians.
*/
float qtmComputeHeadTiltAngle(const QtmTrackingData *data);
/**
* @brief Estimates the distance between the user's eyes and the camera, based on
* eye tracking data. This may be a little bit inaccurate, as this assumes
* interocular distance of 62mm (like all 3DS software does), and that both
* eyes are at the same distance from the screen.
*
* @param data Eye tracking data, obtained from \ref QTMU_GetTrackingData or \ref QTMU_GetTrackingDataEx.
* @return Eye-to-camera distance in millimeters.
*/
float qtmEstimateEyeToCameraDistance(const QtmTrackingData *data);
/**
* @brief Temporarily enables manual control of the IR LED by user, disabling its automatic control.
* If not already done, this also turns off the IR LED. This setting is cleared when user closes the console's shell.
* @return Always 0 (success).
*/
Result QTMU_EnableManualIrLedControl(void);
/**
* @brief Temporarily disables manual control of the IR LED by user, re-enabling its automatic control.
* If not already done, this also turns off the IR LED.
* @return Always 0 (success).
*/
Result QTMU_DisableManualIrLedControl(void);
/**
* @brief Turns the IR LED on or off during manual control. \ref QTMU_EnableManualIrLedControl must have been called.
*
* @param on Whether to turn the IR LED on or off.
* @return `0xC8A18005` if manual control was not enabled or if the operation failed, `0xC8A18008` if camera is in use
* by user, or `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL).
* Otherwise, 0 (success).
*/
Result QTMU_SetIrLedStatus(bool on);
/**
* @brief Attempts to clear IR LED overrides from any of the relevant commands in `qtm:u`, `qtm:s` (and `qtm:c`) commands
* by calling \ref QTMU_EnableManualIrLedControl followed by \ref QTMU_DisableManualIrLedControl, so that auto IR LED
* management takes place again.
* @return The value returned by \ref QTMU_DisableManualIrLedControl.
*/
Result qtmClearIrLedOverrides(void);
/**
* @brief Checks whether or not QTM has been blacklisted, ie. that it has been made unavailable.
* In detail, this means that the last call to \ref QTMS_SetQtmStatus was made with argument \ref QTM_STATUS_UNAVAILABLE,
* usually by NS. This feature seems to only be used for some internal test titles.
*
* @param[out] outBlacklisted Whether or not QTM is unavailable. Always true on N2DSXL.
* @return Always 0 (success).
* @note On N2DSXL, even though status is always supposed to be \ref QTM_STATUS_UNAVAILABLE, this function often returns true
* (because NS doesn't change QTM's status if title isn't blacklisted). Do not rely on this for N2DSXL detection.
* @note Refer to https://www.3dbrew.org/wiki/NS_CFA for a list of title UIDs this is used for.
*/
Result QTMU_IsCurrentAppBlacklisted(bool *outBlacklisted);
/**
* @brief Sets the neutral (center) barrier position/offset in calibration, _without_ saving it to `cfg`.
* Takes effect immediately. SS3D works by calculating the position of the eye midpoint, rotated
* by the ideal eye-to-camera angle, expressed in (iod/12 units, iod assumed to be 62mm).
*
* @param position Center barrier position, in terms of iod/12 units modulo iod/12.
* @note This field is floating-point for QTM auto-adjustment purposes, however the actual barrier position
* in hardware is an integer.
* @note This is the field that System Settings lets you add -1.0 to +1.0 to.
* @note There is no "get" counterpart for this.
* @return `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), otherwise
0 (success).
*/
Result QTMS_SetCenterBarrierPosition(float position);
/**
* @brief Gets the average ambient luminance as perceived by the inner camera (in lux).
* If QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), returns 400.0 instead
* of the actual luminance.
*
* @param[out] outLuminanceLux Where to write the luminance to. Always 400.0 on N2DSXL.
* @note Camera exposure, and in particular auto-exposure affects the returned luminance value. This must be
* taken into consideration, because this value can thus surge when user covers the inner camera.
* @return Always 0 (success).
*/
Result QTMS_GetCameraLuminance(float *outLuminanceLux);
/**
* @brief Enables automatic barrier control when in 3D mode with "super stable 3D" enabled.
*
* @note This is automatically called upon `qtm:s` and `qtm:sp` session exit.
* @return `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), otherwise
0 (success).
* @note Due to an oversight, \ref QTMS_SetQtmStatus allows changing QTM state on N2DSXL. This is not intended
* to be done, and is in fact never done by official software. If that is regardless the case,
* this function here does nothing.
*/
Result QTMS_EnableAutoBarrierControl(void);
/**
* @brief Temporarily disables automatic barrier control (when in 3D mode with "super stable 3D" enabled).
*
* @note This is automatically called upon `qtm:s` and `qtm:sp` session exit.
* @return `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), otherwise
0 (success).
* @note Due to an oversight, \ref QTMS_SetQtmStatus allows changing QTM state on N2DSXL. This is not intended
* to be done, and is in fact never done by official software. If that is regardless the case,
* this function here does nothing.
*/
Result QTMS_DisableAutoBarrierControl(void);
/**
* @brief Temporarily sets the parallax barrier's position (offset in iod/12 units, assuming slit width of 6 units).
* Does nothing in 2D mode and/or if "super stable 3D" is disabled.
*
* @param position Parallax barrier position (offset in units), must be between 0 and 11 (both included)
* @return `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), 0xE0E18002
* if \p position is not in range, otherwise 0 (success).
* @note Due to an oversight, \ref QTMS_SetQtmStatus allows changing QTM state on N2DSXL. This is not intended
* to be done, and is in fact never done by official software. If that is regardless the case,
* this function here does nothing.
* @note No effect when the screen is in 2D mode.
* @see QTMC_SetBarrierPattern
*/
Result QTMS_SetBarrierPosition(u8 position);
/**
* @brief Gets the current position of the parallax barrier (offset in iod/12 units, slit width of 6 units).
* When "super stable 3D" is disabled, returns 13 instead.
*
* @param[out] outPosition Where to write the barrier's position to.
* @return `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), otherwise
0 (success).
* @note When SS3D is disabled, this returns 13 to \p outPosition . When in 2D mode, the returned position is not
updated.
* @note Due to an oversight, \ref QTMS_SetQtmStatus allows changing QTM state on N2DSXL. This is not intended
* to be done, and is in fact never done by official software. If that is regardless the case,
* this function here returns 13 to \p outPosition .
* @see QTMC_SetBarrierPattern
*/
Result QTMS_GetCurrentBarrierPosition(u8 *outPosition);
/**
* @brief Temporarily overrides IR LED state. Requires "manual control" from `qtm:u` to be disabled, and has
* lower priority than it.
*
* @param on Whether to turn the IR LED on or off.
* @return `0xC8A18005` if manual control was enabled or if the operation failed, `0xC8A18008` if camera is in use
* by user (unless "hardware check" API enabled), or `0xC8A18009` if QTM is unavailable (in particular,
* QTM is always unavailable on N2DSXL). Otherwise, 0 (success).
*/
Result QTMS_SetIrLedStatusOverride(bool on);
/**
* @brief Sets calibration data, taking effect immediately, and optionally saves it to `cfg`.
*
* @param cal Pointer to calibration data.
* @param saveCalToCfg Whether or not to persist the calibration data in `cfg`.
* @return `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL), otherwise
whatever `cfg:s` commands return (if used), or 0 (success).
* @note There is no "get" counterpart for this function, and there is no way to see the current calibration data
in use unless it has been saved to `cfg`.
* @note Due to an oversight, \ref QTMS_SetQtmStatus allows changing QTM state on N2DSXL. This is not intended
* to be done, and is in fact never done by official software. If that is regardless the case,
* this function here doesn't apply calibrations parameters (they may still be saved, however,
* even though QTM calibration blocks are always normally 0 on N2DSXL).
*/
Result QTMS_SetCalibrationData(const QtmCalibrationData *cal, bool saveCalToCfg);
/**
* @brief Gets the current QTM status (enabled/ss3d disabled/unavailable).
*
* @param[out] outQtmStatus Where to write the QTM status to.
* @return Always 0.
*/
Result QTMS_GetQtmStatus(QtmStatus *outQtmStatus);
/**
* @brief Gets the current QTM status (enabled/ss3d disabled/unavailable). Also sets or clear the
* "blacklisted" flag returned by \ref QTMU_IsCurrentAppBlacklisted.
*
* @param qtmStatus QTM status to set. If equal to \ref QTM_STATUS_UNAVAILABLE, sets the "blacklisted" flag,
* otherwise clears it.
* @return `0xE0E18002` if enum value is invalid, otherwise 0 (success).
* @note System settings uses this to disable super-stable 3D, and NS to "blacklist" (make QTM unavailable)
* specific applications.
*/
Result QTMS_SetQtmStatus(QtmStatus qtmStatus);
/**
* @brief Called by GSP's LCD driver to signal 2D<>3D mode change
* @param newMode 0 for 2D, 1 for 800px 2D (unused for this function, same as 0), 2 for 3D
* @return Always 0 (success).
*/
Result QTMSP_NotifyTopLcdModeChange(u8 newMode);
/**
* @brief Called by GSP's LCD driver during top LCD power-on to signal to QTM that it may power on
* and/or reconfigure then use the TI TCA6416A expander. In the process, QTM re-creates its
* expander thread.
* @return Always 0 (success).
*/
Result QTMSP_NotifyTopLcdPowerOn(void);
/**
* @brief Called by GSP's LCD driver to know whether or not QTM's expander thread is using
* the TI TCA6416A expander; it is waiting for this to become true/false during LCD
* power on/power off to proceed. Always false on N2DSXL.
* @param[out] outActive Where to write the "in use" status to.
* @return Always 0 (success).
*/
Result QTMSP_IsExpanderInUse(bool *outActive);
/**
* @brief Called by GSP's LCD driver during top LCD power-on to signal to QTM that it needs to
* switch the parallax barrier state to a 2D state (all-transparent mask). Causes QTM's
* expander thread to exit, relinquishing its `i2c::QTM` session with it.
* @return Always 0 (success).
*/
Result QTMSP_NotifyTopLcdPowerOff(void);

117
.vscode/dummyinclude/3ds/services/qtmc.h vendored Normal file
View file

@ -0,0 +1,117 @@
/**
* @file qtmc.h
* @brief QTM Hardware Check service.
*
* Allows direct control over the parallax barrier's pattern and polarity phase through the
* TI TCA6416A I2C->Parallel expander, as well as control over IR LED state even when camera
* is used by user.
*
* TI TCA6416A I2C->Parallel expander is located on bus I2C1 (PA 0x10161000) device ID 0x40.
*
* The top screen parallax barrier was covered by patent US20030234980A1.
*/
#pragma once
#include <3ds/types.h>
/**
* @brief Initializes `qtm:c`.
* Only 3 sessions (2 until 9.3.0 sysupdate) for ALL services COMBINED, including the main
* services, can be open at a time.
*/
Result qtmcInit(void);
/// Exits `qtm:c`.
void qtmcExit(void);
/// Returns a pointer to the current `qtm:c` session handle.
Handle *qtmcGetSessionHandle(void);
/**
* @brief Starts the QTM Hardware Check API. This must be called before using any other `qtm:c` command,
* and causes barrier pattern to be overriden by what was last set in \ref QTMC_SetBarrierPattern,
* **even in 2D mode**. Also allows IR LED state to be overridden even if user uses the inner camera.
* @return `0xD82183F9` if already started, otherwise 0 (success).
*/
Result QTMC_StartHardwareCheck(void);
/**
* @brief Stops the QTM Hardware Check API. Restore normal barrier and IR LED management behavior.
* @return `0xD82183F8` if API not started, otherwise 0 (success).
*/
Result QTMC_StopHardwareCheck(void);
/**
* @brief Sets the parallax barrier's mask pattern and polarity phase (12+1 bits).
*
* Bit11 to 0 correspond to a repeating barrier mask pattern, 0 meaning the corresponding mask unit is
* transparent and 1 that it is opaque. The direction is: left->right corresponds to MSB->LSB.
*
* Bit12 is the polarity bit.
*
* QTM's expander management thread repeatedly writes (on every loop iteration) the current mask pattern
* plus polarity bit, whether it is normally set or overridden by `qtm:c`, then on the following set,
* negates both (it writes pattern ^ 0x1FFF). This is done at all times, even it 2D mode.
*
* The register being written to are regId 0x02 and 0x03 (output ports).
* TI TCA6416A I2C->Parallel expander is located on bus I2C1 (PA 0x10161000) device ID 0x40.
*
* This function has no effect on N2DSXL.
*
* @param pattern Barrier mask pattern (bit12: polarity, bit11-0: 12-bit mask pattern)
* @return `0xD82183F8` if API not started, otherwise 0 (success).
* @see Patent US20030234980A1 for a description of parallax barriers.
* @example The mask pattern used for super-stable 3D are as follows (position 0 to 11):
*
* 000011111100
* 000001111110
* 000000111111
* 100000011111
* 110000001111
* 111000000111
* 111100000011
* 111110000001
* 111111000000
* 011111100000
* 001111110000
* 000111111000
*
* When SS3D is disabled (ie. it tries to match O3DS behavior), then pattern becomes:
* 111100000111
* Notice that the slit width is reduced from 6 to 5 units there.
*
* For 2D it is all-zero:
* 000000000000
*
* 2D pattern is automatically set on QTM process init and exit.
*/
Result QTMC_SetBarrierPattern(u32 pattern);
/**
* @brief Waits for the expander management thread to (re)initalize the TI TCA6416A I2C->Parallel expander,
* then checks if that expander is behaving as expected (responds with the port direction config
* it has been configured with): it checks whether all ports have been configured as outputs.
*
* On N2DSXL, this function waits forever and never returns.
*
* In detail, the hardware init procedure for the expander is as follows (as done by the expander mgmt. thread):
* - configure enable expander pin on SoC: set GPIO3.bit11 to OUTPUT, then set to 1
* - on the expander (I2C1 deviceId 0x40), set all ports to OUTPUT (regId 0x06, 0x07)
* - on the expander, write 0 (all-transparent mask/2D) to the data registers (regId 0x02, 0x03)
*
* @param[out] outWorking Where to write the working status to. If true, expander is present working.
* If false, the expander is present but is misbehaving. If the function does not
* return, then expander is missing (e.g. on N2DSXL).
* @return `0xD82183F8` if API not started, otherwise 0 (success).
*/
Result QTMC_WaitAndCheckExpanderWorking(bool *outWorking);
/**
* @brief Temporarily overrides IR LED state. Requires "manual control" from `qtm:u` to be disabled, and has
* lower priority than it. Same implementation as \ref QTMS_SetIrLedStatusOverride.
*
* @param on Whether to turn the IR LED on or off.
* @return `0xD82183F8` if API not started, `0xC8A18005` if manual control was enabled or if the operation failed,
* or `0xC8A18009` if QTM is unavailable (in particular, QTM is always unavailable on N2DSXL). Otherwise, 0 (success).
*/
Result QTMC_SetIrLedStatusOverride(bool on);

148
.vscode/dummyinclude/3ds/services/soc.h vendored Normal file
View file

@ -0,0 +1,148 @@
/**
* @file soc.h
* @brief SOC service for sockets communications
*
* After initializing this service you will be able to use system calls from netdb.h, sys/socket.h etc.
*/
#pragma once
#include <netinet/in.h>
#include <sys/socket.h>
/// The config level to be used with @ref SOCU_GetNetworkOpt
#define SOL_CONFIG 0xfffe
/// Options to be used with @ref SOCU_GetNetworkOpt
typedef enum
{
NETOPT_MAC_ADDRESS = 0x1004, ///< The mac address of the interface (u32 mac[6])
NETOPT_ARP_TABLE = 0x3002, ///< The ARP table @see SOCU_ARPTableEntry
NETOPT_IP_INFO = 0x4003, ///< The current IP setup @see SOCU_IPInfo
NETOPT_IP_MTU = 0x4004, ///< The value of the IP MTU (u32)
NETOPT_ROUTING_TABLE = 0x4006, ///< The routing table @see SOCU_RoutingTableEntry
NETOPT_UDP_NUMBER = 0x8002, ///< The number of sockets in the UDP table (u32)
NETOPT_UDP_TABLE = 0x8003, ///< The table of opened UDP sockets @see SOCU_UDPTableEntry
NETOPT_TCP_NUMBER = 0x9002, ///< The number of sockets in the TCP table (u32)
NETOPT_TCP_TABLE = 0x9003, ///< The table of opened TCP sockets @see SOCU_TCPTableEntry
NETOPT_DNS_TABLE = 0xB003, ///< The table of the DNS servers @see SOCU_DNSTableEntry -- Returns a buffer of size 336 but only 2 entries are set ?
NETOPT_DHCP_LEASE_TIME = 0xC001, ///< The DHCP lease time remaining, in seconds
} NetworkOpt;
/// One entry of the ARP table retrieved by using @ref SOCU_GetNetworkOpt and @ref NETOPT_ARP_TABLE
typedef struct
{
u32 unk0; // often 2 ? state ?
struct in_addr ip; ///< The IPv4 address associated to the entry
u8 mac[6]; ///< The MAC address of associated to the entry
u8 padding[2];
} SOCU_ARPTableEntry;
/// Structure returned by @ref SOCU_GetNetworkOpt when using @ref NETOPT_IP_INFO
typedef struct
{
struct in_addr ip; ///< Current IPv4 address
struct in_addr netmask; ///< Current network mask
struct in_addr broadcast; ///< Current network broadcast address
} SOCU_IPInfo;
// Linux netstat flags
// NOTE : there are probably other flags supported, if you can forge ICMP requests please check for D and M flags
/** The route uses a gateway */
#define ROUTING_FLAG_G 0x01
/// One entry of the routing table retrieved by using @ref SOCU_GetNetworkOpt and @ref NETOPT_ROUTING_TABLE
typedef struct
{
struct in_addr dest_ip; ///< Destination IP address of the route
struct in_addr netmask; ///< Mask used for this route
struct in_addr gateway; ///< Gateway address to reach the network
u32 flags; ///< Linux netstat flags @see ROUTING_FLAG_G
u64 time; ///< number of milliseconds since 1st Jan 1900 00:00.
} SOCU_RoutingTableEntry;
/// One entry of the UDP sockets table retrieved by using @ref SOCU_GetNetworkOpt and @ref NETOPT_UDP_TABLE
typedef struct
{
struct sockaddr_storage local; ///< Local address information
struct sockaddr_storage remote; ///< Remote address information
} SOCU_UDPTableEntry;
///@name TCP states
///@{
#define TCP_STATE_CLOSED 1
#define TCP_STATE_LISTEN 2
#define TCP_STATE_ESTABLISHED 5
#define TCP_STATE_FINWAIT1 6
#define TCP_STATE_FINWAIT2 7
#define TCP_STATE_CLOSE_WAIT 8
#define TCP_STATE_LAST_ACK 9
#define TCP_STATE_TIME_WAIT 11
///@}
/// One entry of the TCP sockets table retrieved by using @ref SOCU_GetNetworkOpt and @ref NETOPT_TCP_TABLE
typedef struct
{
u32 state; ///< @see TCP states defines
struct sockaddr_storage local; ///< Local address information
struct sockaddr_storage remote; ///< Remote address information
} SOCU_TCPTableEntry;
/// One entry of the DNS servers table retrieved by using @ref SOCU_GetNetworkOpt and @ref NETOPT_DNS_TABLE
typedef struct
{
u32 family; /// Family of the address of the DNS server
struct in_addr ip; /// IP of the DNS server
u8 padding[12]; // matches the length required for IPv6 addresses
} SOCU_DNSTableEntry;
/**
* @brief Initializes the SOC service.
* @param context_addr Address of a page-aligned (0x1000) buffer to be used.
* @param context_size Size of the buffer, a multiple of 0x1000.
* @note The specified context buffer can no longer be accessed by the process which called this function, since the userland permissions for this block are set to no-access.
*/
Result socInit(u32 *context_addr, u32 context_size);
/**
* @brief Closes the soc service.
* @note You need to call this in order to be able to use the buffer again.
*/
Result socExit(void);
// this is supposed to be in unistd.h but newlib only puts it for cygwin, waiting for newlib patch from dkA
/**
* @brief Gets the system's host ID.
* @return The system's host ID.
*/
long gethostid(void);
// this is supposed to be in unistd.h but newlib only puts it for cygwin, waiting for newlib patch from dkA
int gethostname(char *name, size_t namelen);
int SOCU_ShutdownSockets(void);
int SOCU_CloseSockets(void);
/**
* @brief Retrieves information from the network configuration. Similar to getsockopt().
* @param level Only value allowed seems to be @ref SOL_CONFIG
* @param optname The option to be retrieved
* @param optval Will contain the output of the command
* @param optlen Size of the optval buffer, will be updated to hold the size of the output
* @return 0 if successful. -1 if failed, and errno will be set accordingly. Can also return a system error code.
*/
int SOCU_GetNetworkOpt(int level, NetworkOpt optname, void * optval, socklen_t * optlen);
/**
* @brief Gets the system's IP address, netmask, and subnet broadcast
* @return error
*/
int SOCU_GetIPInfo(struct in_addr *ip, struct in_addr *netmask, struct in_addr *broadcast);
/**
* @brief Adds a global socket.
* @param sockfd The socket fd.
* @return error
*/
int SOCU_AddGlobalSocket(int sockfd);

View file

@ -0,0 +1,45 @@
/**
* @file srvpm.h
* @brief srv:pm service.
*/
#pragma once
/// Initializes srv:pm and the service API.
Result srvPmInit(void);
/// Exits srv:pm and the service API.
void srvPmExit(void);
/**
* @brief Gets the current srv:pm session handle.
* @return The current srv:pm session handle.
*/
Handle *srvPmGetSessionHandle(void);
/**
* @brief Publishes a notification to a process.
* @param notificationId ID of the notification.
* @param process Process to publish to.
*/
Result SRVPM_PublishToProcess(u32 notificationId, Handle process);
/**
* @brief Publishes a notification to all processes.
* @param notificationId ID of the notification.
*/
Result SRVPM_PublishToAll(u32 notificationId);
/**
* @brief Registers a process with SRV.
* @param pid ID of the process.
* @param count Number of services within the service access control data.
* @param serviceAccessControlList Service Access Control list.
*/
Result SRVPM_RegisterProcess(u32 pid, u32 count, const char (*serviceAccessControlList)[8]);
/**
* @brief Unregisters a process with SRV.
* @param pid ID of the process.
*/
Result SRVPM_UnregisterProcess(u32 pid);

251
.vscode/dummyinclude/3ds/services/sslc.h vendored Normal file
View file

@ -0,0 +1,251 @@
/**
* @file sslc.h
* @brief SSLC(TLS) service. https://3dbrew.org/wiki/SSL_Services
*/
#pragma once
/// sslc context.
typedef struct {
Handle servhandle; ///< Service handle.
u32 sslchandle; ///< SSLC handle.
Handle sharedmem_handle;
} sslcContext;
typedef enum {
SSLC_DefaultRootCert_Nintendo_CA = 0x1, //"Nintendo CA"
SSLC_DefaultRootCert_Nintendo_CA_G2 = 0x2, //"Nintendo CA - G2"
SSLC_DefaultRootCert_Nintendo_CA_G3 = 0x3, //"Nintendo CA - G3"
SSLC_DefaultRootCert_Nintendo_Class2_CA = 0x4, //"Nintendo Class 2 CA"
SSLC_DefaultRootCert_Nintendo_Class2_CA_G2 = 0x5, //"Nintendo Class 2 CA - G2"
SSLC_DefaultRootCert_Nintendo_Class2_CA_G3 = 0x6, //"Nintendo Class 2 CA - G3"
SSLC_DefaultRootCert_CyberTrust = 0x7, //"GTE CyberTrust Global Root"
SSLC_DefaultRootCert_AddTrust_External_CA = 0x8, //"AddTrust External CA Root"
SSLC_DefaultRootCert_COMODO = 0x9, //"COMODO RSA Certification Authority"
SSLC_DefaultRootCert_USERTrust = 0xA, //"USERTrust RSA Certification Authority"
SSLC_DefaultRootCert_DigiCert_EV = 0xB //"DigiCert High Assurance EV Root CA"
} SSLC_DefaultRootCert;
typedef enum {
SSLC_DefaultClientCert_ClCertA = 0x40
} SSLC_DefaultClientCert;
/// sslc options. https://www.3dbrew.org/wiki/SSL_Services#SSLOpt
enum {
SSLCOPT_Default = 0,
SSLCOPT_DisableVerify = BIT(9), // "Disables server cert verification when set."
SSLCOPT_TLSv10 = BIT(11) // "Use TLSv1.0."
};
/// Initializes SSLC. Normally session_handle should be 0. When non-zero this will use the specified handle for the main-service-session without using the Initialize command, instead of using srvGetServiceHandle.
Result sslcInit(Handle session_handle);
/// Exits SSLC.
void sslcExit(void);
/**
* @brief Creates a RootCertChain.
* @param RootCertChain_contexthandle Output contexthandle.
*/
Result sslcCreateRootCertChain(u32 *RootCertChain_contexthandle);
/**
* @brief Destroys a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain contexthandle.
*/
Result sslcDestroyRootCertChain(u32 RootCertChain_contexthandle);
/**
* @brief Adds a trusted RootCA cert to a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
* @param cert Pointer to the DER cert.
* @param certsize Size of the DER cert.
*/
Result sslcAddTrustedRootCA(u32 RootCertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle);
/**
* @brief Adds a default RootCA cert to a RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
* @param certID ID of the cert to add.
* @param cert_contexthandle Optional, the cert contexthandle can be written here.
*/
Result sslcRootCertChainAddDefaultCert(u32 RootCertChain_contexthandle, SSLC_DefaultRootCert certID, u32 *cert_contexthandle);
/**
* @brief Removes the specified cert from the RootCertChain.
* @param RootCertChain_contexthandle RootCertChain to use.
* @param cert_contexthandle Cert contexthandle to remove from the RootCertChain.
*/
Result sslcRootCertChainRemoveCert(u32 RootCertChain_contexthandle, u32 cert_contexthandle);
/**
* @brief Creates an unknown CertChain.
* @param CertChain_contexthandle Output contexthandle.
*/
Result sslcCreate8CertChain(u32 *CertChain_contexthandle);
/**
* @brief Destroys a CertChain from sslcCreate8CertChain().
* @param CertChain_contexthandle CertChain contexthandle.
*/
Result sslcDestroy8CertChain(u32 CertChain_contexthandle);
/**
* @brief Adds a cert to a CertChain from sslcCreate8CertChain().
* @param CertChain_contexthandle CertChain to use.
* @param cert Pointer to the cert.
* @param certsize Size of the cert.
*/
Result sslc8CertChainAddCert(u32 CertChain_contexthandle, const u8 *cert, u32 certsize, u32 *cert_contexthandle);
/**
* @brief Adds a default cert to a CertChain from sslcCreate8CertChain(). Not actually usable since no certIDs are implemented in SSL-module for this.
* @param CertChain_contexthandle CertChain to use.
* @param certID ID of the cert to add.
* @param cert_contexthandle Optional, the cert contexthandle can be written here.
*/
Result sslc8CertChainAddDefaultCert(u32 CertChain_contexthandle, u8 certID, u32 *cert_contexthandle);
/**
* @brief Removes the specified cert from the CertChain from sslcCreate8CertChain().
* @param CertChain_contexthandle CertChain to use.
* @param cert_contexthandle Cert contexthandle to remove from the CertChain.
*/
Result sslc8CertChainRemoveCert(u32 CertChain_contexthandle, u32 cert_contexthandle);
/**
* @brief Opens a new ClientCert-context.
* @param cert Pointer to the DER cert.
* @param certsize Size of the DER cert.
* @param key Pointer to the DER key.
* @param keysize Size of the DER key.
* @param ClientCert_contexthandle Output contexthandle.
*/
Result sslcOpenClientCertContext(const u8 *cert, u32 certsize, const u8 *key, u32 keysize, u32 *ClientCert_contexthandle);
/**
* @brief Opens a ClientCert-context with a default certID.
* @param certID ID of the ClientCert to use.
* @param ClientCert_contexthandle Output contexthandle.
*/
Result sslcOpenDefaultClientCertContext(SSLC_DefaultClientCert certID, u32 *ClientCert_contexthandle);
/**
* @brief Closes the specified ClientCert-context.
* @param ClientCert_contexthandle ClientCert-context to use.
*/
Result sslcCloseClientCertContext(u32 ClientCert_contexthandle);
/**
* @brief This uses ps:ps SeedRNG internally.
*/
Result sslcSeedRNG(void);
/**
* @brief This uses ps:ps GenerateRandomData internally.
* @param buf Output buffer.
* @param size Output size.
*/
Result sslcGenerateRandomData(u8 *buf, u32 size);
/**
* @brief Creates a sslc context.
* @param context sslc context.
* @param sockfd Socket fd, this code automatically uses the required SOC command before using the actual sslc command.
* @param input_opt Input sslc options bitmask.
* @param hostname Server hostname.
*/
Result sslcCreateContext(sslcContext *context, int sockfd, u32 input_opt, const char *hostname);
/*
* @brief Destroys a sslc context. The associated sockfd must be closed manually.
* @param context sslc context.
*/
Result sslcDestroyContext(sslcContext *context);
/*
* @brief Starts the TLS connection. If successful, this will not return until the connection is ready for data-transfer via sslcRead/sslcWrite.
* @param context sslc context.
* @param internal_retval Optional ptr where the internal_retval will be written. The value is only copied to here by this function when no error occurred.
* @param out Optional ptr where an output u32 will be written. The value is only copied to here by this function when no error occurred.
*/
Result sslcStartConnection(sslcContext *context, int *internal_retval, u32 *out);
/*
* @brief Receive data over the network connection.
* @param context sslc context.
* @param buf Output buffer.
* @param len Size to receive.
* @param peek When true, this is equivalent to setting the recv() MSG_PEEK flag.
* @return When this isn't an error-code, this is the total transferred data size.
*/
Result sslcRead(sslcContext *context, void *buf, size_t len, bool peek);
/*
* @brief Send data over the network connection.
* @param context sslc context.
* @param buf Input buffer.
* @param len Size to send.
* @return When this isn't an error-code, this is the total transferred data size.
*/
Result sslcWrite(sslcContext *context, const void *buf, size_t len);
/*
* @brief Set the RootCertChain for the specified sslc context.
* @param context sslc context.
* @param handle RootCertChain contexthandle.
*/
Result sslcContextSetRootCertChain(sslcContext *context, u32 handle);
/*
* @brief Set the ClientCert-context for the specified sslc context.
* @param context sslc context.
* @param handle ClientCert contexthandle.
*/
Result sslcContextSetClientCert(sslcContext *context, u32 handle);
/*
* @brief Set the context for a CertChain from sslcCreate8CertChain(), for the specified sslc context. This needs updated once it's known what this context is for.
* @param context sslc context.
* @param handle contexthandle.
*/
Result sslcContextSetHandle8(sslcContext *context, u32 handle);
/*
* @brief Clears the options field bits for the context using the specified bitmask.
* @param context sslc context.
* @param bitmask opt bitmask.
*/
Result sslcContextClearOpt(sslcContext *context, u32 bitmask);
/*
* @brief This copies two strings from context state to the specified output buffers. Each string is only copied if it was successfully loaded. The maxsizes include the nul-terminator. This can only be used if sslcStartConnection() was already used successfully.
* @param context sslc context.
* @param outprotocols Output buffer for a string containing all protocol versions supported by SSL-module.
* @param outprotocols_maxsize Max size of the above output buffer.
* @param outcipher Output buffer for a string containing the cipher suite currently being used.
* @param outcipher_maxsize Max size of the above output buffer.
*/
Result sslcContextGetProtocolCipher(sslcContext *context, char *outprotocols, u32 outprotocols_maxsize, char *outcipher, u32 outcipher_maxsize);
/*
* @brief This loads an u32 from the specified context state. This needs updated once it's known what this field is for.
* @param context sslc context.
* @param out Output ptr to write the value to.
*/
Result sslcContextGetState(sslcContext *context, u32 *out);
/*
* @brief This initializes sharedmem for the specified context.
* @param context sslc context.
* @param buf Sharedmem buffer with address aligned to 0x1000-bytes.
* @param size Sharedmem size aligned to 0x1000-bytes.
*/
Result sslcContextInitSharedmem(sslcContext *context, u8 *buf, u32 size);
/*
* @brief This loads the specified cert. This needs updated once it's known what the cert format is and what the cert is used for later.
* @param buf Input cert.
* @param size Cert size.
*/
Result sslcAddCert(sslcContext *context, const u8 *buf, u32 size);

368
.vscode/dummyinclude/3ds/services/uds.h vendored Normal file
View file

@ -0,0 +1,368 @@
/**
* @file uds.h
* @brief UDS(NWMUDS) local-WLAN service. https://3dbrew.org/wiki/NWM_Services
*/
#pragma once
/// Maximum number of nodes(devices) that can be connected to the network.
#define UDS_MAXNODES 16
/// Broadcast value for NetworkNodeID / alias for all NetworkNodeIDs.
#define UDS_BROADCAST_NETWORKNODEID 0xFFFF
/// NetworkNodeID for the host(the first node).
#define UDS_HOST_NETWORKNODEID 0x1
/// Default recv_buffer_size that can be used for udsBind() input / code which uses udsBind() internally.
#define UDS_DEFAULT_RECVBUFSIZE 0x2E30
/// Max size of user data-frames.
#define UDS_DATAFRAME_MAXSIZE 0x5C6
/// Check whether a fatal udsSendTo error occured(some error(s) from udsSendTo() can be ignored, but the frame won't be sent when that happens).
#define UDS_CHECK_SENDTO_FATALERROR(x) (R_FAILED(x) && x!=0xC86113F0)
/// Node info struct.
typedef struct {
u64 uds_friendcodeseed;//UDS version of the FriendCodeSeed.
union {
u8 usercfg[0x18];//This is the first 0x18-bytes from this config block: https://www.3dbrew.org/wiki/Config_Savegame#0x000A0000_Block
struct {
u16 username[10];
u16 unk_x1c;//Unknown, normally zero. Set to 0x0 with the output from udsScanBeacons().
u8 flag;//"u8 flag, unknown. Originates from the u16 bitmask in the beacon node-list header. This flag is normally 0 since that bitmask is normally 0?"
u8 pad_x1f;//Unknown, normally zero.
};
};
//The rest of this is initialized by NWM-module.
u16 NetworkNodeID;
u16 pad_x22;//Unknown, normally zero?
u32 word_x24;//Normally zero?
} udsNodeInfo;
/// Connection status struct.
typedef struct {
u32 status;
u32 unk_x4;
u16 cur_NetworkNodeID;//"u16 NetworkNodeID for this device."
u16 unk_xa;
u32 unk_xc[0x20>>2];
u8 total_nodes;
u8 max_nodes;
u16 node_bitmask;//"This is a bitmask of NetworkNodeIDs: bit0 for NetworkNodeID 0x1(host), bit1 for NetworkNodeID 0x2(first original client), and so on."
} udsConnectionStatus;
/// Network struct stored as big-endian.
typedef struct {
u8 host_macaddress[6];
u8 channel;//Wifi channel for this network. If you want to create a network on a specific channel instead of the system selecting it, you can set this to a non-zero channel value.
u8 pad_x7;
u8 initialized_flag;//Must be non-zero otherwise NWM-module will use zeros internally instead of the actual field data, for most/all(?) of the fields in this struct.
u8 unk_x9[3];
u8 oui_value[3];//"This is the OUI value for use with the beacon tags. Normally this is 001F32."
u8 oui_type;//"OUI type (21/0x15)"
u32 wlancommID;//Unique local-WLAN communications ID for each application.
u8 id8;//Additional ID that can be used by the application for different types of networks.
u8 unk_x15;
u16 attributes;//See the UDSNETATTR enum values below.
u32 networkID;
u8 total_nodes;
u8 max_nodes;
u8 unk_x1e;
u8 unk_x1f;
u8 unk_x20[0x1f];
u8 appdata_size;
u8 appdata[0xc8];
} udsNetworkStruct;
typedef struct {
u32 BindNodeID;
Handle event;
bool spectator;
} udsBindContext;
/// General NWM input structure used for AP scanning.
typedef struct {
u16 unk_x0;
u16 unk_x2;
u16 unk_x4;
u16 unk_x6;
u8 mac_address[6];
u8 unk_xe[0x26];//Not initialized by dlp.
} nwmScanInputStruct;
/// General NWM output structure from AP scanning.
typedef struct {
u32 maxsize;//"Max output size, from the command request."
u32 size;//"Total amount of output data written relative to struct+0. 0xC when there's no entries."
u32 total_entries;//"Total entries, 0 for none. "
//The entries start here.
} nwmBeaconDataReplyHeader;
/// General NWM output structure from AP scanning, for each entry.
typedef struct {
u32 size;//"Size of this entire entry. The next entry starts at curentry_startoffset+curentry_size."
u8 unk_x4;
u8 channel;//Wifi channel for the AP.
u8 unk_x6;
u8 unk_x7;
u8 mac_address[6];//"AP MAC address."
u8 unk_xe[6];
u32 unk_x14;
u32 val_x1c;//"Value 0x1C(size of this header and/or offset to the actual beacon data)."
//The actual beacon data starts here.
} nwmBeaconDataReplyEntry;
/// Output structure generated from host scanning output.
typedef struct {
nwmBeaconDataReplyEntry datareply_entry;
udsNetworkStruct network;
udsNodeInfo nodes[UDS_MAXNODES];
} udsNetworkScanInfo;
enum {
UDSNETATTR_DisableConnectSpectators = BIT(0), //When set new Spectators are not allowed to connect.
UDSNETATTR_DisableConnectClients = BIT(1), //When set new Clients are not allowed to connect.
UDSNETATTR_x4 = BIT(2), //Unknown what this bit is for.
UDSNETATTR_Default = BIT(15), //Unknown what this bit is for.
};
enum {
UDS_SENDFLAG_Default = BIT(0), //Unknown what this bit is for.
UDS_SENDFLAG_Broadcast = BIT(1) //When set, broadcast the data frame via the destination MAC address even when UDS_BROADCAST_NETWORKNODEID isn't used.
};
typedef enum {
UDSCONTYPE_Client = 0x1,
UDSCONTYPE_Spectator = 0x2
} udsConnectionType;
/**
* @brief Initializes UDS.
* @param sharedmem_size This must be 0x1000-byte aligned.
* @param username Optional custom UTF-8 username(converted to UTF-16 internally) that other nodes on the UDS network can use. If not set the username from system-config is used. Max len is 10 characters without NUL-terminator.
*/
Result udsInit(size_t sharedmem_size, const char *username);
/// Exits UDS.
void udsExit(void);
/**
* @brief Generates a NodeInfo struct with data loaded from system-config.
* @param nodeinfo Output NodeInfo struct.
* @param username If set, this is the UTF-8 string to convert for use in the struct. Max len is 10 characters without NUL-terminator.
*/
Result udsGenerateNodeInfo(udsNodeInfo *nodeinfo, const char *username);
/**
* @brief Loads the UTF-16 username stored in the input NodeInfo struct, converted to UTF-8.
* @param nodeinfo Input NodeInfo struct.
* @param username This is the output UTF-8 string. Max len is 10 characters without NUL-terminator.
*/
Result udsGetNodeInfoUsername(const udsNodeInfo *nodeinfo, char *username);
/**
* @brief Checks whether a NodeInfo struct was initialized by NWM-module(not any output from udsGenerateNodeInfo()).
* @param nodeinfo Input NodeInfo struct.
*/
bool udsCheckNodeInfoInitialized(const udsNodeInfo *nodeinfo);
/**
* @brief Generates a default NetworkStruct for creating networks.
* @param network The output struct.
* @param wlancommID Unique local-WLAN communications ID for each application.
* @param id8 Additional ID that can be used by the application for different types of networks.
* @param max_nodes Maximum number of nodes(devices) that can be connected to the network, including the host.
*/
void udsGenerateDefaultNetworkStruct(udsNetworkStruct *network, u32 wlancommID, u8 id8, u8 max_nodes);
/**
* @brief Scans for networks via beacon-scanning.
* @param outbuf Buffer which will be used by the beacon-scanning command and for the data parsing afterwards. Normally there's no need to use the contents of this buffer once this function returns.
* @param maxsize Max size of the buffer.
* @Param networks Ptr where the allocated udsNetworkScanInfo array buffer is written. The allocsize is sizeof(udsNetworkScanInfo)*total_networks.
* @Param total_networks Total number of networks stored under the networks buffer.
* @param wlancommID Unique local-WLAN communications ID for each application.
* @param id8 Additional ID that can be used by the application for different types of networks.
* @param host_macaddress When set, this code will only return network info from the specified host MAC address.
* @connected When not connected to a network this *must* be false. When connected to a network this *must* be true.
*/
Result udsScanBeacons(void *outbuf, size_t maxsize, udsNetworkScanInfo **networks, size_t *total_networks, u32 wlancommID, u8 id8, const u8 *host_macaddress, bool connected);
/**
* @brief This can be used by the host to set the appdata contained in the broadcasted beacons.
* @param buf Appdata buffer.
* @param size Size of the input appdata.
*/
Result udsSetApplicationData(const void *buf, size_t size);
/**
* @brief This can be used while on a network(host/client) to get the appdata from the current beacon.
* @param buf Appdata buffer.
* @param size Max size of the output buffer.
* @param actual_size If set, the actual size of the appdata written into the buffer is stored here.
*/
Result udsGetApplicationData(void *buf, size_t size, size_t *actual_size);
/**
* @brief This can be used with a NetworkStruct, from udsScanBeacons() mainly, for getting the appdata.
* @param buf Appdata buffer.
* @param size Max size of the output buffer.
* @param actual_size If set, the actual size of the appdata written into the buffer is stored here.
*/
Result udsGetNetworkStructApplicationData(const udsNetworkStruct *network, void *buf, size_t size, size_t *actual_size);
/**
* @brief Create a bind.
* @param bindcontext The output bind context.
* @param NetworkNodeID This is the NetworkNodeID which this bind can receive data from.
* @param spectator False for a regular bind, true for a spectator.
* @param data_channel This is an arbitrary value to use for data-frame filtering. This bind will only receive data frames which contain a matching data_channel value, which was specified by udsSendTo(). The data_channel must be non-zero.
* @param recv_buffer_size Size of the buffer under sharedmem used for temporarily storing received data-frames which are then loaded by udsPullPacket(). The system requires this to be >=0x5F4. UDS_DEFAULT_RECVBUFSIZE can be used for this.
*/
Result udsBind(udsBindContext *bindcontext, u16 NetworkNodeID, bool spectator, u8 data_channel, u32 recv_buffer_size);
/**
* @brief Remove a bind.
* @param bindcontext The bind context.
*/
Result udsUnbind(udsBindContext *bindcontext);
/**
* @brief Waits for the bind event to occur, or checks if the event was signaled. This event is signaled every time new data is available via udsPullPacket().
* @return Always true. However if wait=false, this will return false if the event wasn't signaled.
* @param bindcontext The bind context.
* @param nextEvent Whether to discard the current event and wait for the next event.
* @param wait When true this will not return until the event is signaled. When false this checks if the event was signaled without waiting for it.
*/
bool udsWaitDataAvailable(const udsBindContext *bindcontext, bool nextEvent, bool wait);
/**
* @brief Receives data over the network. This data is loaded from the recv_buffer setup by udsBind(). When a node disconnects, this will still return data from that node until there's no more frames from that node in the recv_buffer.
* @param bindcontext Bind context.
* @param buf Output receive buffer.
* @param size Size of the buffer.
* @param actual_size If set, the actual size written into the output buffer is stored here. This is zero when no data was received.
* @param src_NetworkNodeID If set, the source NetworkNodeID is written here. This is zero when no data was received.
*/
Result udsPullPacket(const udsBindContext *bindcontext, void *buf, size_t size, size_t *actual_size, u16 *src_NetworkNodeID);
/**
* @brief Sends data over the network.
* @param dst_NetworkNodeID Destination NetworkNodeID.
* @param data_channel See udsBind().
* @param flags Send flags, see the UDS_SENDFLAG enum values.
* @param buf Input send buffer.
* @param size Size of the buffer.
*/
Result udsSendTo(u16 dst_NetworkNodeID, u8 data_channel, u8 flags, const void *buf, size_t size);
/**
* @brief Gets the wifi channel currently being used.
* @param channel Output channel.
*/
Result udsGetChannel(u8 *channel);
/**
* @brief Starts hosting a new network.
* @param network The NetworkStruct, you can use udsGenerateDefaultNetworkStruct() for generating this.
* @param passphrase Raw input passphrase buffer.
* @param passphrase_size Size of the passphrase buffer.
* @param context Optional output bind context which will be created for this host, with NetworkNodeID=UDS_BROADCAST_NETWORKNODEID.
* @param data_channel This is the data_channel value which will be passed to udsBind() internally.
* @param recv_buffer_size This is the recv_buffer_size value which will be passed to udsBind() internally.
*/
Result udsCreateNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u8 data_channel, u32 recv_buffer_size);
/**
* @brief Connect to a network.
* @param network The NetworkStruct, you can use udsScanBeacons() for this.
* @param passphrase Raw input passphrase buffer.
* @param passphrase_size Size of the passphrase buffer.
* @param context Optional output bind context which will be created for this host.
* @param recv_NetworkNodeID This is the NetworkNodeID passed to udsBind() internally.
* @param connection_type Type of connection, see the udsConnectionType enum values.
* @param data_channel This is the data_channel value which will be passed to udsBind() internally.
* @param recv_buffer_size This is the recv_buffer_size value which will be passed to udsBind() internally.
*/
Result udsConnectNetwork(const udsNetworkStruct *network, const void *passphrase, size_t passphrase_size, udsBindContext *context, u16 recv_NetworkNodeID, udsConnectionType connection_type, u8 data_channel, u32 recv_buffer_size);
/**
* @brief Stop hosting the network.
*/
Result udsDestroyNetwork(void);
/**
* @brief Disconnect this client device from the network.
*/
Result udsDisconnectNetwork(void);
/**
* @brief This can be used by the host to force-disconnect client(s).
* @param NetworkNodeID Target NetworkNodeID. UDS_BROADCAST_NETWORKNODEID can be used to disconnect all clients.
*/
Result udsEjectClient(u16 NetworkNodeID);
/**
* @brief This can be used by the host to force-disconnect the spectators. Afterwards new spectators will not be allowed to connect until udsAllowSpectators() is used.
*/
Result udsEjectSpectator(void);
/**
* @brief This can be used by the host to update the network attributes. If bitmask 0x4 is clear in the input bitmask, this clears that bit in the value before actually writing the value into state. Normally you should use the below wrapper functions.
* @param bitmask Bitmask to clear/set in the attributes. See the UDSNETATTR enum values.
* @param flag When false, bit-clear, otherwise bit-set.
*/
Result udsUpdateNetworkAttribute(u16 bitmask, bool flag);
/**
* @brief This uses udsUpdateNetworkAttribute() for (un)blocking new connections to this host.
* @param block When true, block the specified connection types(bitmask set). Otherwise allow them(bitmask clear).
* @param clients When true, (un)block regular clients.
* @param flag When true, update UDSNETATTR_x4. Normally this should be false.
*/
Result udsSetNewConnectionsBlocked(bool block, bool clients, bool flag);
/**
* @brief This uses udsUpdateNetworkAttribute() for unblocking new spectator connections to this host. See udsEjectSpectator() for blocking new spectators.
*/
Result udsAllowSpectators(void);
/**
* @brief This loads the current ConnectionStatus struct.
* @param output Output ConnectionStatus struct.
*/
Result udsGetConnectionStatus(udsConnectionStatus *output);
/**
* @brief Waits for the ConnectionStatus event to occur, or checks if the event was signaled. This event is signaled when the data from udsGetConnectionStatus() was updated internally.
* @return Always true. However if wait=false, this will return false if the event wasn't signaled.
* @param nextEvent Whether to discard the current event and wait for the next event.
* @param wait When true this will not return until the event is signaled. When false this checks if the event was signaled without waiting for it.
*/
bool udsWaitConnectionStatusEvent(bool nextEvent, bool wait);
/**
* @brief This loads a NodeInfo struct for the specified NetworkNodeID. The broadcast alias can't be used with this.
* @param NetworkNodeID Target NetworkNodeID.
* @param output Output NodeInfo struct.
*/
Result udsGetNodeInformation(u16 NetworkNodeID, udsNodeInfo *output);

500
.vscode/dummyinclude/3ds/services/y2r.h vendored Normal file
View file

@ -0,0 +1,500 @@
/**
* @file y2r.h
* @brief Y2R service for hardware YUV->RGB conversions
*/
#pragma once
#include <3ds/types.h>
/**
* @brief Input color formats
*
* For the 16-bit per component formats, bits 15-8 are padding and 7-0 contains the value.
*/
typedef enum
{
INPUT_YUV422_INDIV_8 = 0x0, ///< 8-bit per component, planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples).\n Usually named YUV422P.
INPUT_YUV420_INDIV_8 = 0x1, ///< 8-bit per component, planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples).\n Usually named YUV420P.
INPUT_YUV422_INDIV_16 = 0x2, ///< 16-bit per component, planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples).\n Usually named YUV422P16.
INPUT_YUV420_INDIV_16 = 0x3, ///< 16-bit per component, planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples).\n Usually named YUV420P16.
INPUT_YUV422_BATCH = 0x4, ///< 8-bit per component, packed YUV 4:2:2, 16bpp, (Y0 Cb Y1 Cr).\n Usually named YUYV422.
} Y2RU_InputFormat;
/**
* @brief Output color formats
*
* Those are the same as the framebuffer and GPU texture formats.
*/
typedef enum
{
OUTPUT_RGB_32 = 0x0, ///< 32-bit RGBA8888. The alpha component is the 8-bit value set by @ref Y2RU_SetAlpha
OUTPUT_RGB_24 = 0x1, ///< 24-bit RGB888.
OUTPUT_RGB_16_555 = 0x2, ///< 16-bit RGBA5551. The alpha bit is the 7th bit of the alpha value set by @ref Y2RU_SetAlpha
OUTPUT_RGB_16_565 = 0x3, ///< 16-bit RGB565.
} Y2RU_OutputFormat;
/// Rotation to be applied to the output.
typedef enum
{
ROTATION_NONE = 0x0, ///< No rotation.
ROTATION_CLOCKWISE_90 = 0x1, ///< Clockwise 90 degrees.
ROTATION_CLOCKWISE_180 = 0x2, ///< Clockwise 180 degrees.
ROTATION_CLOCKWISE_270 = 0x3, ///< Clockwise 270 degrees.
} Y2RU_Rotation;
/**
* @brief Block alignment of output
*
* Defines the way the output will be laid out in memory.
*/
typedef enum
{
BLOCK_LINE = 0x0, ///< The result buffer will be laid out in linear format, the usual way.
BLOCK_8_BY_8 = 0x1, ///< The result will be stored as 8x8 blocks in Z-order.\n Useful for textures since it is the format used by the PICA200.
} Y2RU_BlockAlignment;
/**
* @brief Coefficients of the YUV->RGB conversion formula.
*
* A set of coefficients configuring the RGB to YUV conversion. Coefficients 0-4 are unsigned 2.8
* fixed pointer numbers representing entries on the conversion matrix, while coefficient 5-7 are
* signed 11.5 fixed point numbers added as offsets to the RGB result.
*
* The overall conversion process formula is:
* @code
* R = trunc((rgb_Y * Y + r_V * V) + 0.75 + r_offset)
* G = trunc((rgb_Y * Y - g_U * U - g_V * V) + 0.75 + g_offset)
* B = trunc((rgb_Y * Y + b_U * U ) + 0.75 + b_offset)
* @endcode
*/
typedef struct
{
u16 rgb_Y; ///< RGB per unit Y.
u16 r_V; ///< Red per unit V.
u16 g_V; ///< Green per unit V.
u16 g_U; ///< Green per unit U.
u16 b_U; ///< Blue per unit U.
u16 r_offset; ///< Red offset.
u16 g_offset; ///< Green offset.
u16 b_offset; ///< Blue offset.
} Y2RU_ColorCoefficients;
/**
* @brief Preset conversion coefficients based on ITU standards for the YUV->RGB formula.
*
* For more details refer to @ref Y2RU_ColorCoefficients
*/
typedef enum
{
COEFFICIENT_ITU_R_BT_601 = 0x0, ///< Coefficients from the ITU-R BT.601 standard with PC ranges.
COEFFICIENT_ITU_R_BT_709 = 0x1, ///< Coefficients from the ITU-R BT.709 standard with PC ranges.
COEFFICIENT_ITU_R_BT_601_SCALING = 0x2, ///< Coefficients from the ITU-R BT.601 standard with TV ranges.
COEFFICIENT_ITU_R_BT_709_SCALING = 0x3, ///< Coefficients from the ITU-R BT.709 standard with TV ranges.
} Y2RU_StandardCoefficient;
/**
* @brief Structure used to configure all parameters at once.
*
* You can send a batch of configuration parameters using this structure and @ref Y2RU_SetConversionParams.
*/
typedef struct
{
Y2RU_InputFormat input_format : 8; ///< Value passed to @ref Y2RU_SetInputFormat
Y2RU_OutputFormat output_format : 8; ///< Value passed to @ref Y2RU_SetOutputFormat
Y2RU_Rotation rotation : 8; ///< Value passed to @ref Y2RU_SetRotation
Y2RU_BlockAlignment block_alignment : 8; ///< Value passed to @ref Y2RU_SetBlockAlignment
s16 input_line_width; ///< Value passed to @ref Y2RU_SetInputLineWidth
s16 input_lines; ///< Value passed to @ref Y2RU_SetInputLines
Y2RU_StandardCoefficient standard_coefficient : 8; ///< Value passed to @ref Y2RU_SetStandardCoefficient
u8 unused; ///< Unused.
u16 alpha; ///< Value passed to @ref Y2RU_SetAlpha
} Y2RU_ConversionParams;
/// Dithering weights.
typedef struct
{
u16 w0_xEven_yEven; ///< Weight 0 for even X, even Y.
u16 w0_xOdd_yEven; ///< Weight 0 for odd X, even Y.
u16 w0_xEven_yOdd; ///< Weight 0 for even X, odd Y.
u16 w0_xOdd_yOdd; ///< Weight 0 for odd X, odd Y.
u16 w1_xEven_yEven; ///< Weight 1 for even X, even Y.
u16 w1_xOdd_yEven; ///< Weight 1 for odd X, even Y.
u16 w1_xEven_yOdd; ///< Weight 1 for even X, odd Y.
u16 w1_xOdd_yOdd; ///< Weight 1 for odd X, odd Y.
u16 w2_xEven_yEven; ///< Weight 2 for even X, even Y.
u16 w2_xOdd_yEven; ///< Weight 2 for odd X, even Y.
u16 w2_xEven_yOdd; ///< Weight 2 for even X, odd Y.
u16 w2_xOdd_yOdd; ///< Weight 2 for odd X, odd Y.
u16 w3_xEven_yEven; ///< Weight 3 for even X, even Y.
u16 w3_xOdd_yEven; ///< Weight 3 for odd X, even Y.
u16 w3_xEven_yOdd; ///< Weight 3 for even X, odd Y.
u16 w3_xOdd_yOdd; ///< Weight 3 for odd X, odd Y.
} Y2RU_DitheringWeightParams;
/**
* @brief Initializes the y2r service.
*
* This will internally get the handle of the service, and on success call Y2RU_DriverInitialize.
*/
Result y2rInit(void);
/**
* @brief Closes the y2r service.
*
* This will internally call Y2RU_DriverFinalize and close the handle of the service.
*/
void y2rExit(void);
/**
* @brief Used to configure the input format.
* @param format Input format to use.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetInputFormat(Y2RU_InputFormat format);
/**
* @brief Gets the configured input format.
* @param format Pointer to output the input format to.
*/
Result Y2RU_GetInputFormat(Y2RU_InputFormat* format);
/**
* @brief Used to configure the output format.
* @param format Output format to use.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetOutputFormat(Y2RU_OutputFormat format);
/**
* @brief Gets the configured output format.
* @param format Pointer to output the output format to.
*/
Result Y2RU_GetOutputFormat(Y2RU_OutputFormat* format);
/**
* @brief Used to configure the rotation of the output.
* @param rotation Rotation to use.
*
* It seems to apply the rotation per batch of 8 lines, so the output will be (height/8) images of size 8 x width.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetRotation(Y2RU_Rotation rotation);
/**
* @brief Gets the configured rotation.
* @param rotation Pointer to output the rotation to.
*/
Result Y2RU_GetRotation(Y2RU_Rotation* rotation);
/**
* @brief Used to configure the alignment of the output buffer.
* @param alignment Alignment to use.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetBlockAlignment(Y2RU_BlockAlignment alignment);
/**
* @brief Gets the configured alignment.
* @param alignment Pointer to output the alignment to.
*/
Result Y2RU_GetBlockAlignment(Y2RU_BlockAlignment* alignment);
/**
* @brief Sets whether to use spacial dithering.
* @param enable Whether to use spacial dithering.
*/
Result Y2RU_SetSpacialDithering(bool enable);
/**
* @brief Gets whether to use spacial dithering.
* @param enable Pointer to output the spacial dithering state to.
*/
Result Y2RU_GetSpacialDithering(bool* enabled);
/**
* @brief Sets whether to use temporal dithering.
* @param enable Whether to use temporal dithering.
*/
Result Y2RU_SetTemporalDithering(bool enable);
/**
* @brief Gets whether to use temporal dithering.
* @param enable Pointer to output the temporal dithering state to.
*/
Result Y2RU_GetTemporalDithering(bool* enabled);
/**
* @brief Used to configure the width of the image.
* @param line_width Width of the image in pixels. Must be a multiple of 8, up to 1024.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetInputLineWidth(u16 line_width);
/**
* @brief Gets the configured input line width.
* @param line_width Pointer to output the line width to.
*/
Result Y2RU_GetInputLineWidth(u16* line_width);
/**
* @brief Used to configure the height of the image.
* @param num_lines Number of lines to be converted.
*
* A multiple of 8 seems to be preferred.
* If using the @ref BLOCK_8_BY_8 mode, it must be a multiple of 8.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetInputLines(u16 num_lines);
/**
* @brief Gets the configured number of input lines.
* @param num_lines Pointer to output the input lines to.
*/
Result Y2RU_GetInputLines(u16* num_lines);
/**
* @brief Used to configure the color conversion formula.
* @param coefficients Coefficients to use.
*
* See @ref Y2RU_ColorCoefficients for more information about the coefficients.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetCoefficients(const Y2RU_ColorCoefficients* coefficients);
/**
* @brief Gets the configured color coefficients.
* @param num_lines Pointer to output the coefficients to.
*/
Result Y2RU_GetCoefficients(Y2RU_ColorCoefficients* coefficients);
/**
* @brief Used to configure the color conversion formula with ITU stantards coefficients.
* @param coefficient Standard coefficient to use.
*
* See @ref Y2RU_ColorCoefficients for more information about the coefficients.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetStandardCoefficient(Y2RU_StandardCoefficient coefficient);
/**
* @brief Gets the color coefficient parameters of a standard coefficient.
* @param coefficients Pointer to output the coefficients to.
* @param standardCoeff Standard coefficient to check.
*/
Result Y2RU_GetStandardCoefficient(Y2RU_ColorCoefficients* coefficients, Y2RU_StandardCoefficient standardCoeff);
/**
* @brief Used to configure the alpha value of the output.
* @param alpha 8-bit value to be used for the output when the format requires it.
*
* @note Prefer using @ref Y2RU_SetConversionParams if you have to set multiple parameters.
*/
Result Y2RU_SetAlpha(u16 alpha);
/**
* @brief Gets the configured output alpha value.
* @param alpha Pointer to output the alpha value to.
*/
Result Y2RU_GetAlpha(u16* alpha);
/**
* @brief Used to enable the end of conversion interrupt.
* @param should_interrupt Enables the interrupt if true, disable it if false.
*
* It is possible to fire an interrupt when the conversion is finished, and that the DMA is done copying the data.
* This interrupt will then be used to fire an event. See @ref Y2RU_GetTransferEndEvent.
* By default the interrupt is enabled.
*
* @note It seems that the event can be fired too soon in some cases, depending the transfer_unit size.\n Please see the note at @ref Y2RU_SetReceiving
*/
Result Y2RU_SetTransferEndInterrupt(bool should_interrupt);
/**
* @brief Gets whether the transfer end interrupt is enabled.
* @param should_interrupt Pointer to output the interrupt state to.
*/
Result Y2RU_GetTransferEndInterrupt(bool* should_interrupt);
/**
* @brief Gets an handle to the end of conversion event.
* @param end_event Pointer to the event handle to be set to the end of conversion event. It isn't necessary to create or close this handle.
*
* To enable this event you have to use @code{C} Y2RU_SetTransferEndInterrupt(true);@endcode
* The event will be triggered when the corresponding interrupt is fired.
*
* @note It is recommended to use a timeout when waiting on this event, as it sometimes (but rarely) isn't triggered.
*/
Result Y2RU_GetTransferEndEvent(Handle* end_event);
/**
* @brief Configures the Y plane buffer.
* @param src_buf A pointer to the beginning of your Y data buffer.
* @param image_size The total size of the data buffer.
* @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
* @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
*
* @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
*
* This specifies the Y data buffer for the planar input formats (INPUT_YUV42*_INDIV_*).
* The actual transfer will only happen after calling @ref Y2RU_StartConversion.
*/
Result Y2RU_SetSendingY(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
/**
* @brief Configures the U plane buffer.
* @param src_buf A pointer to the beginning of your Y data buffer.
* @param image_size The total size of the data buffer.
* @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
* @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
*
* @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
*
* This specifies the U data buffer for the planar input formats (INPUT_YUV42*_INDIV_*).
* The actual transfer will only happen after calling @ref Y2RU_StartConversion.
*/
Result Y2RU_SetSendingU(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
/**
* @brief Configures the V plane buffer.
* @param src_buf A pointer to the beginning of your Y data buffer.
* @param image_size The total size of the data buffer.
* @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
* @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
*
* @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
*
* This specifies the V data buffer for the planar input formats (INPUT_YUV42*_INDIV_*).
* The actual transfer will only happen after calling @ref Y2RU_StartConversion.
*/
Result Y2RU_SetSendingV(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
/**
* @brief Configures the YUYV source buffer.
* @param src_buf A pointer to the beginning of your Y data buffer.
* @param image_size The total size of the data buffer.
* @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
* @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
*
* @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
*
* This specifies the YUYV data buffer for the packed input format @ref INPUT_YUV422_BATCH.
* The actual transfer will only happen after calling @ref Y2RU_StartConversion.
*/
Result Y2RU_SetSendingYUYV(const void* src_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
/**
* @brief Configures the destination buffer.
* @param src_buf A pointer to the beginning of your destination buffer in FCRAM
* @param image_size The total size of the data buffer.
* @param transfer_unit Specifies the size of 1 DMA transfer. Usually set to 1 line. This has to be a divisor of image_size.
* @param transfer_gap Specifies the gap (offset) to be added after each transfer. Can be used to convert images with stride or only a part of it.
*
* This specifies the destination buffer of the conversion.
* The actual transfer will only happen after calling @ref Y2RU_StartConversion.
* The buffer does NOT need to be allocated in the linear heap.
*
* @warning transfer_unit+transfer_gap must be less than 32768 (0x8000)
*
* @note
* It seems that depending on the size of the image and of the transfer unit,\n
* it is possible for the end of conversion interrupt to be triggered right after the conversion began.\n
* One line as transfer_unit seems to trigger this issue for 400x240, setting to 2/4/8 lines fixes it.
*
* @note Setting a transfer_unit of 4 or 8 lines seems to bring the best results in terms of speed for a 400x240 image.
*/
Result Y2RU_SetReceiving(void* dst_buf, u32 image_size, s16 transfer_unit, s16 transfer_gap);
/**
* @brief Checks if the DMA has finished sending the Y buffer.
* @param is_done Pointer to the boolean that will hold the result.
*
* True if the DMA has finished transferring the Y plane, false otherwise. To be used with @ref Y2RU_SetSendingY.
*/
Result Y2RU_IsDoneSendingY(bool* is_done);
/**
* @brief Checks if the DMA has finished sending the U buffer.
* @param is_done Pointer to the boolean that will hold the result.
*
* True if the DMA has finished transferring the U plane, false otherwise. To be used with @ref Y2RU_SetSendingU.
*/
Result Y2RU_IsDoneSendingU(bool* is_done);
/**
* @brief Checks if the DMA has finished sending the V buffer.
* @param is_done Pointer to the boolean that will hold the result.
*
* True if the DMA has finished transferring the V plane, false otherwise. To be used with @ref Y2RU_SetSendingV.
*/
Result Y2RU_IsDoneSendingV(bool* is_done);
/**
* @brief Checks if the DMA has finished sending the YUYV buffer.
* @param is_done Pointer to the boolean that will hold the result.
*
* True if the DMA has finished transferring the YUYV buffer, false otherwise. To be used with @ref Y2RU_SetSendingYUYV.
*/
Result Y2RU_IsDoneSendingYUYV(bool* is_done);
/**
* @brief Checks if the DMA has finished sending the converted result.
* @param is_done Pointer to the boolean that will hold the result.
*
* True if the DMA has finished transferring data to your destination buffer, false otherwise.
*/
Result Y2RU_IsDoneReceiving(bool* is_done);
/**
* @brief Configures the dithering weight parameters.
* @param params Dithering weight parameters to use.
*/
Result Y2RU_SetDitheringWeightParams(const Y2RU_DitheringWeightParams* params);
/**
* @brief Gets the configured dithering weight parameters.
* @param params Pointer to output the dithering weight parameters to.
*/
Result Y2RU_GetDitheringWeightParams(Y2RU_DitheringWeightParams* params);
/**
* @brief Sets all of the parameters of Y2RU_ConversionParams at once.
* @param params Conversion parameters to set.
*
* Faster than calling the individual value through Y2R_Set* because only one system call is made.
*/
Result Y2RU_SetConversionParams(const Y2RU_ConversionParams* params);
/// Starts the conversion process
Result Y2RU_StartConversion(void);
/// Cancels the conversion
Result Y2RU_StopConversion(void);
/**
* @brief Checks if the conversion and DMA transfer are finished.
* @param is_busy Pointer to output the busy state to.
*
* This can have the same problems as the event and interrupt. See @ref Y2RU_SetTransferEndInterrupt.
*/
Result Y2RU_IsBusyConversion(bool* is_busy);
/**
* @brief Checks whether Y2R is ready to be used.
* @param ping Pointer to output the ready status to.
*/
Result Y2RU_PingProcess(u8* ping);
/// Initializes the Y2R driver.
Result Y2RU_DriverInitialize(void);
/// Terminates the Y2R driver.
Result Y2RU_DriverFinalize(void);

141
.vscode/dummyinclude/3ds/srv.h vendored Normal file
View file

@ -0,0 +1,141 @@
/**
* @file srv.h
* @brief Service API.
*/
#pragma once
/// Initializes the service API.
Result srvInit(void);
/// Exits the service API.
void srvExit(void);
/**
* @brief Makes srvGetServiceHandle non-blocking for the current thread (or blocking, the default), in case of unavailable (full) requested services.
* @param blocking Whether srvGetServiceHandle should be non-blocking.
* srvGetServiceHandle will always block if the service hasn't been registered yet,
* use srvIsServiceRegistered to check whether that is the case or not.
*/
void srvSetBlockingPolicy(bool nonBlocking);
/**
* @brief Gets the current service API session handle.
* @return The current service API session handle.
*/
Handle *srvGetSessionHandle(void);
/**
* @brief Retrieves a service handle, retrieving from the environment handle list if possible.
* @param out Pointer to write the handle to.
* @param name Name of the service.
* @return 0 if no error occured,
* 0xD8E06406 if the caller has no right to access the service,
* 0xD0401834 if the requested service port is full and srvGetServiceHandle is non-blocking (see @ref srvSetBlockingPolicy).
*/
Result srvGetServiceHandle(Handle* out, const char* name);
/// Registers the current process as a client to the service API.
Result srvRegisterClient(void);
/**
* @brief Enables service notificatios, returning a notification semaphore.
* @param semaphoreOut Pointer to output the notification semaphore to.
*/
Result srvEnableNotification(Handle* semaphoreOut);
/**
* @brief Registers the current process as a service.
* @param out Pointer to write the service handle to.
* @param name Name of the service.
* @param maxSessions Maximum number of sessions the service can handle.
*/
Result srvRegisterService(Handle* out, const char* name, int maxSessions);
/**
* @brief Unregisters the current process as a service.
* @param name Name of the service.
*/
Result srvUnregisterService(const char* name);
/**
* @brief Retrieves a service handle.
* @param out Pointer to output the handle to.
* @param name Name of the service.
* * @return 0 if no error occured,
* 0xD8E06406 if the caller has no right to access the service,
* 0xD0401834 if the requested service port is full and srvGetServiceHandle is non-blocking (see @ref srvSetBlockingPolicy).
*/
Result srvGetServiceHandleDirect(Handle* out, const char* name);
/**
* @brief Registers a port.
* @param name Name of the port.
* @param clientHandle Client handle of the port.
*/
Result srvRegisterPort(const char* name, Handle clientHandle);
/**
* @brief Unregisters a port.
* @param name Name of the port.
*/
Result srvUnregisterPort(const char* name);
/**
* @brief Retrieves a port handle.
* @param out Pointer to output the handle to.
* @param name Name of the port.
*/
Result srvGetPort(Handle* out, const char* name);
/**
* @brief Waits for a port to be registered.
* @param name Name of the port to wait for registration.
*/
Result srvWaitForPortRegistered(const char* name);
/**
* @brief Subscribes to a notification.
* @param notificationId ID of the notification.
*/
Result srvSubscribe(u32 notificationId);
/**
* @brief Unsubscribes from a notification.
* @param notificationId ID of the notification.
*/
Result srvUnsubscribe(u32 notificationId);
/**
* @brief Receives a notification.
* @param notificationIdOut Pointer to output the ID of the received notification to.
*/
Result srvReceiveNotification(u32* notificationIdOut);
/**
* @brief Publishes a notification to subscribers.
* @param notificationId ID of the notification.
* @param flags Flags to publish with. (bit 0 = only fire if not fired, bit 1 = do not report an error if there are more than 16 pending notifications)
*/
Result srvPublishToSubscriber(u32 notificationId, u32 flags);
/**
* @brief Publishes a notification to subscribers and retrieves a list of all processes that were notified.
* @param processIdCountOut Pointer to output the number of process IDs to.
* @param processIdsOut Pointer to output the process IDs to. Should have size "60 * sizeof(u32)".
* @param notificationId ID of the notification.
*/
Result srvPublishAndGetSubscriber(u32* processIdCountOut, u32* processIdsOut, u32 notificationId);
/**
* @brief Checks whether a service is registered.
* @param registeredOut Pointer to output the registration status to.
* @param name Name of the service to check.
*/
Result srvIsServiceRegistered(bool* registeredOut, const char* name);
/**
* @brief Checks whether a port is registered.
* @param registeredOut Pointer to output the registration status to.
* @param name Name of the port to check.
*/
Result srvIsPortRegistered(bool* registeredOut, const char* name);

1440
.vscode/dummyinclude/3ds/svc.h vendored Normal file

File diff suppressed because it is too large Load diff

350
.vscode/dummyinclude/3ds/synchronization.h vendored Executable file
View file

@ -0,0 +1,350 @@
/**
* @file synchronization.h
* @brief Provides synchronization locks.
*/
#pragma once
#include <sys/lock.h>
#include <3ds/svc.h>
/// A light lock.
typedef _LOCK_T LightLock;
/// A recursive lock.
typedef _LOCK_RECURSIVE_T RecursiveLock;
/// A condition variable.
typedef s32 CondVar;
/// A light event.
typedef struct
{
s32 state; ///< State of the event: -2=cleared sticky, -1=cleared oneshot, 0=signaled oneshot, 1=signaled sticky
LightLock lock; ///< Lock used for sticky timer operation
} LightEvent;
/// A light semaphore.
typedef struct
{
s32 current_count; ///< The current release count of the semaphore
s16 num_threads_acq; ///< Number of threads concurrently acquiring the semaphore
s16 max_count; ///< The maximum release count of the semaphore
} LightSemaphore;
/// Performs a Data Synchronization Barrier operation.
static inline void __dsb(void)
{
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 4" :: [val] "r" (0) : "memory");
}
/// Performs a Data Memory Barrier operation.
static inline void __dmb(void)
{
__asm__ __volatile__("mcr p15, 0, %[val], c7, c10, 5" :: [val] "r" (0) : "memory");
}
/// Performs an Instruction Synchronization Barrier (officially "flush prefetch buffer") operation.
static inline void __isb(void)
{
__asm__ __volatile__("mcr p15, 0, %[val], c7, c5, 4" :: [val] "r" (0) : "memory");
}
/// Performs a clrex operation.
static inline void __clrex(void)
{
__asm__ __volatile__("clrex" ::: "memory");
}
/**
* @brief Performs a ldrex operation.
* @param addr Address to perform the operation on.
* @return The resulting value.
*/
static inline s32 __ldrex(s32* addr)
{
s32 val;
__asm__ __volatile__("ldrex %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
return val;
}
/**
* @brief Performs a strex operation.
* @param addr Address to perform the operation on.
* @param val Value to store.
* @return Whether the operation was successful.
*/
static inline bool __strex(s32* addr, s32 val)
{
bool res;
__asm__ __volatile__("strex %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
return res;
}
/**
* @brief Performs a ldrexh operation.
* @param addr Address to perform the operation on.
* @return The resulting value.
*/
static inline u16 __ldrexh(u16* addr)
{
u16 val;
__asm__ __volatile__("ldrexh %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
return val;
}
/**
* @brief Performs a strexh operation.
* @param addr Address to perform the operation on.
* @param val Value to store.
* @return Whether the operation was successful.
*/
static inline bool __strexh(u16* addr, u16 val)
{
bool res;
__asm__ __volatile__("strexh %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
return res;
}
/**
* @brief Performs a ldrexb operation.
* @param addr Address to perform the operation on.
* @return The resulting value.
*/
static inline u8 __ldrexb(u8* addr)
{
u8 val;
__asm__ __volatile__("ldrexb %[val], %[addr]" : [val] "=r" (val) : [addr] "Q" (*addr));
return val;
}
/**
* @brief Performs a strexb operation.
* @param addr Address to perform the operation on.
* @param val Value to store.
* @return Whether the operation was successful.
*/
static inline bool __strexb(u8* addr, u8 val)
{
bool res;
__asm__ __volatile__("strexb %[res], %[val], %[addr]" : [res] "=&r" (res) : [val] "r" (val), [addr] "Q" (*addr));
return res;
}
/// Performs an atomic pre-increment operation.
#define AtomicIncrement(ptr) __atomic_add_fetch((u32*)(ptr), 1, __ATOMIC_SEQ_CST)
/// Performs an atomic pre-decrement operation.
#define AtomicDecrement(ptr) __atomic_sub_fetch((u32*)(ptr), 1, __ATOMIC_SEQ_CST)
/// Performs an atomic post-increment operation.
#define AtomicPostIncrement(ptr) __atomic_fetch_add((u32*)(ptr), 1, __ATOMIC_SEQ_CST)
/// Performs an atomic post-decrement operation.
#define AtomicPostDecrement(ptr) __atomic_fetch_sub((u32*)(ptr), 1, __ATOMIC_SEQ_CST)
/// Performs an atomic swap operation.
#define AtomicSwap(ptr, value) __atomic_exchange_n((u32*)(ptr), (value), __ATOMIC_SEQ_CST)
/**
* @brief Function used to implement user-mode synchronization primitives.
* @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.
* @param type Type of action to be performed by the arbiter
* @param value Number of threads to signal if using @ref ARBITRATION_SIGNAL, or the value used for comparison.
*
* This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.
*
* @code
* s32 val=0;
* // Does *nothing* since val >= 0
* syncArbitrateAddress(&val,ARBITRATION_WAIT_IF_LESS_THAN,0);
* @endcode
*
* @note Usage of this function entails an implicit Data Memory Barrier (dmb).
*/
Result syncArbitrateAddress(s32* addr, ArbitrationType type, s32 value);
/**
* @brief Function used to implement user-mode synchronization primitives (with timeout).
* @param addr Pointer to a signed 32-bit value whose address will be used to identify waiting threads.
* @param type Type of action to be performed by the arbiter (must use \ref ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT or \ref ARBITRATION_DECREMENT_AND_WAIT_IF_LESS_THAN_TIMEOUT)
* @param value Number of threads to signal if using @ref ARBITRATION_SIGNAL, or the value used for comparison.
*
* This will perform an arbitration based on #type. The comparisons are done between #value and the value at the address #addr.
*
* @code
* s32 val=0;
* // Thread will wait for a signal or wake up after 10000000 nanoseconds because val < 1.
* syncArbitrateAddressWithTimeout(&val,ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,1,10000000LL);
* @endcode
*
* @note Usage of this function entails an implicit Data Memory Barrier (dmb).
*/
Result syncArbitrateAddressWithTimeout(s32* addr, ArbitrationType type, s32 value, s64 timeout_ns);
/**
* @brief Initializes a light lock.
* @param lock Pointer to the lock.
*/
void LightLock_Init(LightLock* lock);
/**
* @brief Locks a light lock.
* @param lock Pointer to the lock.
*/
void LightLock_Lock(LightLock* lock);
/**
* @brief Attempts to lock a light lock.
* @param lock Pointer to the lock.
* @return Zero on success, non-zero on failure.
*/
int LightLock_TryLock(LightLock* lock);
/**
* @brief Unlocks a light lock.
* @param lock Pointer to the lock.
*/
void LightLock_Unlock(LightLock* lock);
/**
* @brief Initializes a recursive lock.
* @param lock Pointer to the lock.
*/
void RecursiveLock_Init(RecursiveLock* lock);
/**
* @brief Locks a recursive lock.
* @param lock Pointer to the lock.
*/
void RecursiveLock_Lock(RecursiveLock* lock);
/**
* @brief Attempts to lock a recursive lock.
* @param lock Pointer to the lock.
* @return Zero on success, non-zero on failure.
*/
int RecursiveLock_TryLock(RecursiveLock* lock);
/**
* @brief Unlocks a recursive lock.
* @param lock Pointer to the lock.
*/
void RecursiveLock_Unlock(RecursiveLock* lock);
/**
* @brief Initializes a condition variable.
* @param cv Pointer to the condition variable.
*/
void CondVar_Init(CondVar* cv);
/**
* @brief Waits on a condition variable.
* @param cv Pointer to the condition variable.
* @param lock Pointer to the lock to atomically unlock/relock during the wait.
*/
void CondVar_Wait(CondVar* cv, LightLock* lock);
/**
* @brief Waits on a condition variable with a timeout.
* @param cv Pointer to the condition variable.
* @param lock Pointer to the lock to atomically unlock/relock during the wait.
* @param timeout_ns Timeout in nanoseconds.
* @return Zero on success, non-zero on failure.
*/
int CondVar_WaitTimeout(CondVar* cv, LightLock* lock, s64 timeout_ns);
/**
* @brief Wakes up threads waiting on a condition variable.
* @param cv Pointer to the condition variable.
* @param num_threads Maximum number of threads to wake up (or \ref ARBITRATION_SIGNAL_ALL to wake them all).
*/
void CondVar_WakeUp(CondVar* cv, s32 num_threads);
/**
* @brief Wakes up a single thread waiting on a condition variable.
* @param cv Pointer to the condition variable.
*/
static inline void CondVar_Signal(CondVar* cv)
{
CondVar_WakeUp(cv, 1);
}
/**
* @brief Wakes up all threads waiting on a condition variable.
* @param cv Pointer to the condition variable.
*/
static inline void CondVar_Broadcast(CondVar* cv)
{
CondVar_WakeUp(cv, ARBITRATION_SIGNAL_ALL);
}
/**
* @brief Initializes a light event.
* @param event Pointer to the event.
* @param reset_type Type of reset the event uses (RESET_ONESHOT/RESET_STICKY).
*/
void LightEvent_Init(LightEvent* event, ResetType reset_type);
/**
* @brief Clears a light event.
* @param event Pointer to the event.
*/
void LightEvent_Clear(LightEvent* event);
/**
* @brief Wakes up threads waiting on a sticky light event without signaling it. If the event had been signaled before, it is cleared instead.
* @param event Pointer to the event.
*/
void LightEvent_Pulse(LightEvent* event);
/**
* @brief Signals a light event, waking up threads waiting on it.
* @param event Pointer to the event.
*/
void LightEvent_Signal(LightEvent* event);
/**
* @brief Attempts to wait on a light event.
* @param event Pointer to the event.
* @return Non-zero if the event was signaled, zero otherwise.
*/
int LightEvent_TryWait(LightEvent* event);
/**
* @brief Waits on a light event.
* @param event Pointer to the event.
*/
void LightEvent_Wait(LightEvent* event);
/**
* @brief Waits on a light event until either the event is signaled or the timeout is reached.
* @param event Pointer to the event.
* @param timeout_ns Timeout in nanoseconds.
* @return Non-zero on timeout, zero otherwise.
*/
int LightEvent_WaitTimeout(LightEvent* event, s64 timeout_ns);
/**
* @brief Initializes a light semaphore.
* @param event Pointer to the semaphore.
* @param max_count Initial count of the semaphore.
* @param max_count Maximum count of the semaphore.
*/
void LightSemaphore_Init(LightSemaphore* semaphore, s16 initial_count, s16 max_count);
/**
* @brief Acquires a light semaphore.
* @param semaphore Pointer to the semaphore.
* @param count Acquire count
*/
void LightSemaphore_Acquire(LightSemaphore* semaphore, s32 count);
/**
* @brief Attempts to acquire a light semaphore.
* @param semaphore Pointer to the semaphore.
* @param count Acquire count
* @return Zero on success, non-zero on failure
*/
int LightSemaphore_TryAcquire(LightSemaphore* semaphore, s32 count);
/**
* @brief Releases a light semaphore.
* @param semaphore Pointer to the semaphore.
* @param count Release count
*/
void LightSemaphore_Release(LightSemaphore* semaphore, s32 count);

123
.vscode/dummyinclude/3ds/thread.h vendored Normal file
View file

@ -0,0 +1,123 @@
/**
* @file thread.h
* @brief Provides functions to use threads.
*/
#pragma once
#include <3ds/types.h>
#include <3ds/result.h>
#include <3ds/synchronization.h>
#include <3ds/svc.h>
#include <3ds/errf.h>
/// Makes the exception handler reuse the stack of the faulting thread as-is
#define RUN_HANDLER_ON_FAULTING_STACK ((void*)1)
/// Makes the exception handler push the exception data on its stack
#define WRITE_DATA_TO_HANDLER_STACK NULL
/// Makes the exception handler push the exception data on the stack of the faulting thread
#define WRITE_DATA_TO_FAULTING_STACK ((ERRF_ExceptionData*)1)
/// libctru thread handle type
typedef struct Thread_tag* Thread;
/// Exception handler type, necessarily an ARM function that does not return.
typedef void (*ExceptionHandler)(ERRF_ExceptionInfo* excep, CpuRegisters* regs);
/**
* @brief Creates a new libctru thread.
* @param entrypoint The function that will be called first upon thread creation
* @param arg The argument passed to @p entrypoint
* @param stack_size The size of the stack that will be allocated for the thread (will be rounded to a multiple of 8 bytes)
* @param prio Low values gives the thread higher priority.
* For userland apps, this has to be within the range [0x18;0x3F].
* The main thread usually has a priority of 0x30, but not always. Use svcGetThreadPriority() if you need
* to create a thread with a priority that is explicitly greater or smaller than that of the main thread.
* @param core_id The ID of the processor the thread should be ran on. Processor IDs are labeled starting from 0.
* On Old3DS it must be <2, and on New3DS it must be <4.
* Pass -1 to execute the thread on all CPUs and -2 to execute the thread on the default CPU (read from the Exheader).
* @param detached When set to true, the thread is automatically freed when it finishes.
* @return The libctru thread handle on success, NULL on failure.
*
* - Processor #0 is the application core. It is always possible to create a thread on this core.
* - Processor #1 is the system core. If APT_SetAppCpuTimeLimit is used, it is possible to create a single thread on this core.
* - Processor #2 is New3DS exclusive. Normal applications can create threads on this core if the exheader kernel flags bitmask has 0x2000 set.
* - Processor #3 is New3DS exclusive. Normal applications cannot create threads on this core.
* - Processes in the BASE memory region can always create threads on processors #2 and #3.
*
* @note Default exit code of a thread is 0.
* @warning @ref svcExitThread should never be called from the thread, use @ref threadExit instead.
*/
Thread threadCreate(ThreadFunc entrypoint, void* arg, size_t stack_size, int prio, int core_id, bool detached);
/**
* @brief Retrieves the OS thread handle of a libctru thread.
* @param thread libctru thread handle
* @return OS thread handle
*/
Handle threadGetHandle(Thread thread);
/**
* @brief Retrieves the exit code of a finished libctru thread.
* @param thread libctru thread handle
* @return Exit code
*/
int threadGetExitCode(Thread thread);
/**
* @brief Frees a finished libctru thread.
* @param thread libctru thread handle
* @remarks This function should not be called if the thread is detached, as it is freed automatically when it finishes.
*/
void threadFree(Thread thread);
/**
* @brief Waits for a libctru thread to finish (or returns immediately if it is already finished).
* @param thread libctru thread handle
* @param timeout_ns Timeout in nanoseconds. Pass U64_MAX if a timeout isn't desired
*/
Result threadJoin(Thread thread, u64 timeout_ns);
/**
* @brief Changes a thread's status from attached to detached.
* @param thread libctru thread handle
*/
void threadDetach(Thread thread);
/**
* @brief Retrieves the libctru thread handle of the current thread.
* @return libctru thread handle of the current thread, or NULL for the main thread
*/
Thread threadGetCurrent(void);
/**
* @brief Exits the current libctru thread with an exit code (not usable from the main thread).
* @param rc Exit code
*/
void threadExit(int rc) __attribute__((noreturn));
/**
* @brief Sets the exception handler for the current thread. Called from the main thread, this sets the default handler.
* @param handler The exception handler, necessarily an ARM function that does not return
* @param stack_top A pointer to the top of the stack that will be used by the handler. See also @ref RUN_HANDLER_ON_FAULTING_STACK
* @param exception_data A pointer to the buffer that will contain the exception data.
See also @ref WRITE_DATA_TO_HANDLER_STACK and @ref WRITE_DATA_TO_FAULTING_STACK
*
* To have CPU exceptions reported through this mechanism, it is normally necessary that UNITINFO is set to a non-zero value when Kernel11 starts,
* and this mechanism is also controlled by @ref svcKernelSetState type 6, see 3dbrew.
*
* VFP exceptions are always reported this way even if the process is being debugged using the debug SVCs.
*
* The current thread need not be a libctru thread.
*/
static inline void threadOnException(ExceptionHandler handler, void* stack_top, ERRF_ExceptionData* exception_data)
{
u8* tls = (u8*)getThreadLocalStorage();
*(u32*)(tls + 0x40) = (u32)handler;
*(u32*)(tls + 0x44) = (u32)stack_top;
*(u32*)(tls + 0x48) = (u32)exception_data;
__dsb();
__isb();
}

79
.vscode/dummyinclude/3ds/types.h vendored Normal file
View file

@ -0,0 +1,79 @@
/**
* @file types.h
* @brief Various system types.
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
/// The maximum value of a u64.
#define U64_MAX UINT64_MAX
/// would be nice if newlib had this already
#ifndef SSIZE_MAX
#ifdef SIZE_MAX
#define SSIZE_MAX ((SIZE_MAX) >> 1)
#endif
#endif
typedef uint8_t u8; ///< 8-bit unsigned integer
typedef uint16_t u16; ///< 16-bit unsigned integer
typedef uint32_t u32; ///< 32-bit unsigned integer
typedef uint64_t u64; ///< 64-bit unsigned integer
typedef int8_t s8; ///< 8-bit signed integer
typedef int16_t s16; ///< 16-bit signed integer
typedef int32_t s32; ///< 32-bit signed integer
typedef int64_t s64; ///< 64-bit signed integer
typedef volatile u8 vu8; ///< 8-bit volatile unsigned integer.
typedef volatile u16 vu16; ///< 16-bit volatile unsigned integer.
typedef volatile u32 vu32; ///< 32-bit volatile unsigned integer.
typedef volatile u64 vu64; ///< 64-bit volatile unsigned integer.
typedef volatile s8 vs8; ///< 8-bit volatile signed integer.
typedef volatile s16 vs16; ///< 16-bit volatile signed integer.
typedef volatile s32 vs32; ///< 32-bit volatile signed integer.
typedef volatile s64 vs64; ///< 64-bit volatile signed integer.
typedef u32 Handle; ///< Resource handle.
typedef s32 Result; ///< Function result.
typedef void (*ThreadFunc)(void *); ///< Thread entrypoint function.
typedef void (*voidfn)(void);
/// Creates a bitmask from a bit number.
#define BIT(n) (1U<<(n))
/// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m.
#define CTR_ALIGN(m) __attribute__((aligned(m)))
/// Packs a struct (and other types?) so it won't include padding bytes.
#define CTR_PACKED __attribute__((packed))
#ifndef CTR_NO_DEPRECATION
/// Flags a function as deprecated.
#define CTR_DEPRECATED __attribute__ ((deprecated))
#else
/// Flags a function as deprecated.
#define CTR_DEPRECATED
#endif
/// Structure representing CPU registers
typedef struct {
u32 r[13]; ///< r0-r12.
u32 sp; ///< sp.
u32 lr; ///< lr.
u32 pc; ///< pc. May need to be adjusted.
u32 cpsr; ///< cpsr.
} CpuRegisters;
/// Structure representing FPU registers
typedef struct {
union {
struct CTR_PACKED { double d[16]; }; ///< d0-d15.
float s[32]; ///< s0-s31.
};
u32 fpscr; ///< fpscr.
u32 fpexc; ///< fpexc.
} FpuRegisters;

View file

@ -0,0 +1,238 @@
/**
* @file decompress.h
* @brief Decompression functions.
*/
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <sys/types.h>
/** @brief Compression types */
typedef enum
{
DECOMPRESS_DUMMY = 0x00, ///< Dummy compression
DECOMPRESS_LZSS = 0x10, ///< LZSS/LZ10 compression
DECOMPRESS_LZ10 = 0x10, ///< LZSS/LZ10 compression
DECOMPRESS_LZ11 = 0x11, ///< LZ11 compression
DECOMPRESS_HUFF1 = 0x21, ///< Huffman compression with 1-bit data
DECOMPRESS_HUFF2 = 0x22, ///< Huffman compression with 2-bit data
DECOMPRESS_HUFF3 = 0x23, ///< Huffman compression with 3-bit data
DECOMPRESS_HUFF4 = 0x24, ///< Huffman compression with 4-bit data
DECOMPRESS_HUFF5 = 0x25, ///< Huffman compression with 5-bit data
DECOMPRESS_HUFF6 = 0x26, ///< Huffman compression with 6-bit data
DECOMPRESS_HUFF7 = 0x27, ///< Huffman compression with 7-bit data
DECOMPRESS_HUFF8 = 0x28, ///< Huffman compression with 8-bit data
DECOMPRESS_HUFF = 0x28, ///< Huffman compression with 8-bit data
DECOMPRESS_RLE = 0x30, ///< Run-length encoding compression
} decompressType;
/** @brief I/O vector */
typedef struct
{
void *data; ///< I/O buffer
size_t size; ///< Buffer size
} decompressIOVec;
/** @brief Data callback */
typedef ssize_t (*decompressCallback)(void *userdata, void *buffer,
size_t size);
#ifdef __cplusplus
extern "C"
{
#endif
/** @brief Decompression callback for file descriptors
* @param[in] userdata Address of file descriptor
* @param[in] buffer Buffer to write into
* @param[in] size Size to read from file descriptor
* @returns Number of bytes read
*/
ssize_t decompressCallback_FD(void *userdata, void *buffer, size_t size);
/** @brief Decompression callback for stdio FILE*
* @param[in] userdata FILE*
* @param[in] buffer Buffer to write into
* @param[in] size Size to read from file descriptor
* @returns Number of bytes read
*/
ssize_t decompressCallback_Stdio(void *userdata, void *buffer, size_t size);
/** @brief Decode decompression header
* @param[out] type Decompression type
* @param[out] size Decompressed size
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Bytes consumed
* @retval -1 error
*/
ssize_t decompressHeader(decompressType *type, size_t *size,
decompressCallback callback, void *userdata,
size_t insize);
/** @brief Decompress data
* @param[in] iov Output vector
* @param[in] iovcnt Number of buffers
* @param[in] callback Data callback (see note)
* @param[in] userdata User data passed to callback (see note)
* @param[in] insize Size of userdata (see note)
* @returns Whether succeeded
*
* @note If callback is null, userdata is a pointer to memory to read from,
* and insize is the size of that data. If callback is not null,
* userdata is passed to callback to fetch more data, and insize is
* unused.
*/
bool decompressV(const decompressIOVec *iov, size_t iovcnt,
decompressCallback callback, void *userdata, size_t insize);
/** @brief Decompress data
* @param[in] output Output buffer
* @param[in] size Output size limit
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
static inline bool
decompress(void *output, size_t size, decompressCallback callback,
void *userdata, size_t insize)
{
decompressIOVec iov;
iov.data = output;
iov.size = size;
return decompressV(&iov, 1, callback, userdata, insize);
}
/** @brief Decompress LZSS/LZ10
* @param[in] iov Output vector
* @param[in] iovcnt Number of buffers
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
bool decompressV_LZSS(const decompressIOVec *iov, size_t iovcnt,
decompressCallback callback, void *userdata,
size_t insize);
/** @brief Decompress LZSS/LZ10
* @param[in] output Output buffer
* @param[in] size Output size limit
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
static inline bool
decompress_LZSS(void *output, size_t size, decompressCallback callback,
void *userdata, size_t insize)
{
decompressIOVec iov;
iov.data = output;
iov.size = size;
return decompressV_LZSS(&iov, 1, callback, userdata, insize);
}
/** @brief Decompress LZ11
* @param[in] iov Output vector
* @param[in] iovcnt Number of buffers
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
bool decompressV_LZ11(const decompressIOVec *iov, size_t iovcnt,
decompressCallback callback, void *userdata,
size_t insize);
/** @brief Decompress LZ11
* @param[in] output Output buffer
* @param[in] size Output size limit
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
static inline bool
decompress_LZ11(void *output, size_t size, decompressCallback callback,
void *userdata, size_t insize)
{
decompressIOVec iov;
iov.data = output;
iov.size = size;
return decompressV_LZ11(&iov, 1, callback, userdata, insize);
}
/** @brief Decompress Huffman
* @param[in] bits Data size in bits (usually 4 or 8)
* @param[in] iov Output vector
* @param[in] iovcnt Number of buffers
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
bool decompressV_Huff(size_t bits, const decompressIOVec *iov, size_t iovcnt,
decompressCallback callback, void *userdata,
size_t insize);
/** @brief Decompress Huffman
* @param[in] bits Data size in bits (usually 4 or 8)
* @param[in] output Output buffer
* @param[in] size Output size limit
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
static inline bool
decompress_Huff(size_t bits, void *output, size_t size,
decompressCallback callback, void *userdata, size_t insize)
{
decompressIOVec iov;
iov.data = output;
iov.size = size;
return decompressV_Huff(bits, &iov, 1, callback, userdata, insize);
}
/** @brief Decompress run-length encoding
* @param[in] iov Output vector
* @param[in] iovcnt Number of buffers
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
bool decompressV_RLE(const decompressIOVec *iov, size_t iovcnt,
decompressCallback callback, void *userdata,
size_t insize);
/** @brief Decompress run-length encoding
* @param[in] output Output buffer
* @param[in] size Output size limit
* @param[in] callback Data callback (see decompressV())
* @param[in] userdata User data passed to callback (see decompressV())
* @param[in] insize Size of userdata (see decompressV())
* @returns Whether succeeded
*/
static inline bool
decompress_RLE(void *output, size_t size, decompressCallback callback,
void *userdata, size_t insize)
{
decompressIOVec iov;
iov.data = output;
iov.size = size;
return decompressV_RLE(&iov, 1, callback, userdata, insize);
}
#ifdef __cplusplus
}
#endif

149
.vscode/dummyinclude/3ds/util/rbtree.h vendored Normal file
View file

@ -0,0 +1,149 @@
/**
* @file rbtree.h
* @brief Red-black trees.
*/
#pragma once
#include <stdint.h>
#include <stddef.h>
/// Retrieves an rbtree item.
#define rbtree_item(ptr, type, member) \
((type*)(((char*)ptr) - offsetof(type, member)))
typedef struct rbtree rbtree_t; ///< rbtree type.
typedef struct rbtree_node rbtree_node_t; ///< rbtree node type.
typedef void (*rbtree_node_destructor_t)(rbtree_node_t *Node); ///< rbtree node destructor.
typedef int (*rbtree_node_comparator_t)(const rbtree_node_t *lhs,
const rbtree_node_t *rhs); ///< rbtree node comparator.
/// An rbtree node.
struct rbtree_node
{
uintptr_t parent_color; ///< Parent color.
rbtree_node_t *child[2]; ///< Node children.
};
/// An rbtree.
struct rbtree
{
rbtree_node_t *root; ///< Root node.
rbtree_node_comparator_t comparator; ///< Node comparator.
size_t size; ///< Size.
};
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Initializes an rbtree.
* @param tree Pointer to the tree.
* @param comparator Comparator to use.
*/
void
rbtree_init(rbtree_t *tree,
rbtree_node_comparator_t comparator);
/**
* @brief Gets whether an rbtree is empty
* @param tree Pointer to the tree.
* @return A non-zero value if the tree is not empty.
*/
int
rbtree_empty(const rbtree_t *tree);
/**
* @brief Gets the size of an rbtree.
* @param tree Pointer to the tree.
*/
size_t
rbtree_size(const rbtree_t *tree);
/**
* @brief Inserts a node into an rbtree.
* @param tree Pointer to the tree.
* @param node Pointer to the node.
* @return The inserted node.
*/
__attribute__((warn_unused_result))
rbtree_node_t*
rbtree_insert(rbtree_t *tree,
rbtree_node_t *node);
/**
* @brief Inserts multiple nodes into an rbtree.
* @param tree Pointer to the tree.
* @param node Pointer to the nodes.
*/
void
rbtree_insert_multi(rbtree_t *tree,
rbtree_node_t *node);
/**
* @brief Finds a node within an rbtree.
* @param tree Pointer to the tree.
* @param node Pointer to the node.
* @return The located node.
*/
rbtree_node_t*
rbtree_find(const rbtree_t *tree,
const rbtree_node_t *node);
/**
* @brief Gets the minimum node of an rbtree.
* @param tree Pointer to the tree.
* @return The minimum node.
*/
rbtree_node_t*
rbtree_min(const rbtree_t *tree);
/**
* @brief Gets the maximum node of an rbtree.
* @param tree Pointer to the tree.
* @return The maximum node.
*/
rbtree_node_t*
rbtree_max(const rbtree_t *tree);
/**
* @brief Gets the next node from an rbtree node.
* @param node Pointer to the node.
* @return The next node.
*/
rbtree_node_t*
rbtree_node_next(const rbtree_node_t *node);
/**
* @brief Gets the previous node from an rbtree node.
* @param node Pointer to the node.
* @return The previous node.
*/
rbtree_node_t*
rbtree_node_prev(const rbtree_node_t *node);
/**
* @brief Removes a node from an rbtree.
* @param tree Pointer to the tree.
* @param node Pointer to the node.
* @param destructor Destructor to use when removing the node.
* @return The removed node.
*/
rbtree_node_t*
rbtree_remove(rbtree_t *tree,
rbtree_node_t *node,
rbtree_node_destructor_t destructor);
/**
* @brief Clears an rbtree.
* @param tree Pointer to the tree.
* @param destructor Destructor to use when clearing the tree's nodes.
*/
void
rbtree_clear(rbtree_t *tree,
rbtree_node_destructor_t destructor);
#ifdef __cplusplus
}
#endif

155
.vscode/dummyinclude/3ds/util/utf.h vendored Normal file
View file

@ -0,0 +1,155 @@
/**
* @file utf.h
* @brief UTF conversion functions.
*/
#pragma once
#include <stdint.h>
#include <sys/types.h>
/** Convert a UTF-8 sequence into a UTF-32 codepoint
*
* @param[out] out Output codepoint
* @param[in] in Input sequence
*
* @returns number of input code units consumed
* @returns -1 for error
*/
ssize_t decode_utf8 (uint32_t *out, const uint8_t *in);
/** Convert a UTF-16 sequence into a UTF-32 codepoint
*
* @param[out] out Output codepoint
* @param[in] in Input sequence
*
* @returns number of input code units consumed
* @returns -1 for error
*/
ssize_t decode_utf16(uint32_t *out, const uint16_t *in);
/** Convert a UTF-32 codepoint into a UTF-8 sequence
*
* @param[out] out Output sequence
* @param[in] in Input codepoint
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out must be able to store 4 code units
*/
ssize_t encode_utf8 (uint8_t *out, uint32_t in);
/** Convert a UTF-32 codepoint into a UTF-16 sequence
*
* @param[out] out Output sequence
* @param[in] in Input codepoint
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out must be able to store 2 code units
*/
ssize_t encode_utf16(uint16_t *out, uint32_t in);
/** Convert a UTF-8 sequence into a UTF-16 sequence
*
* Fills the output buffer up to \a len code units.
* Returns the number of code units that the input would produce;
* if it returns greater than \a len, the output has been
* truncated.
*
* @param[out] out Output sequence
* @param[in] in Input sequence (null-terminated)
* @param[in] len Output length
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out is not null-terminated
*/
ssize_t utf8_to_utf16(uint16_t *out, const uint8_t *in, size_t len);
/** Convert a UTF-8 sequence into a UTF-32 sequence
*
* Fills the output buffer up to \a len code units.
* Returns the number of code units that the input would produce;
* if it returns greater than \a len, the output has been
* truncated.
*
* @param[out] out Output sequence
* @param[in] in Input sequence (null-terminated)
* @param[in] len Output length
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out is not null-terminated
*/
ssize_t utf8_to_utf32(uint32_t *out, const uint8_t *in, size_t len);
/** Convert a UTF-16 sequence into a UTF-8 sequence
*
* Fills the output buffer up to \a len code units.
* Returns the number of code units that the input would produce;
* if it returns greater than \a len, the output has been
* truncated.
*
* @param[out] out Output sequence
* @param[in] in Input sequence (null-terminated)
* @param[in] len Output length
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out is not null-terminated
*/
ssize_t utf16_to_utf8(uint8_t *out, const uint16_t *in, size_t len);
/** Convert a UTF-16 sequence into a UTF-32 sequence
*
* Fills the output buffer up to \a len code units.
* Returns the number of code units that the input would produce;
* if it returns greater than \a len, the output has been
* truncated.
*
* @param[out] out Output sequence
* @param[in] in Input sequence (null-terminated)
* @param[in] len Output length
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out is not null-terminated
*/
ssize_t utf16_to_utf32(uint32_t *out, const uint16_t *in, size_t len);
/** Convert a UTF-32 sequence into a UTF-8 sequence
*
* Fills the output buffer up to \a len code units.
* Returns the number of code units that the input would produce;
* if it returns greater than \a len, the output has been
* truncated.
*
* @param[out] out Output sequence
* @param[in] in Input sequence (null-terminated)
* @param[in] len Output length
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out is not null-terminated
*/
ssize_t utf32_to_utf8(uint8_t *out, const uint32_t *in, size_t len);
/** Convert a UTF-32 sequence into a UTF-16 sequence
*
* @param[out] out Output sequence
* @param[in] in Input sequence (null-terminated)
* @param[in] len Output length
*
* @returns number of output code units produced
* @returns -1 for error
*
* @note \a out is not null-terminated
*/
ssize_t utf32_to_utf16(uint16_t *out, const uint32_t *in, size_t len);

1
.vscode/dummyinclude/sys/lock.h vendored Normal file
View file

@ -0,0 +1 @@
// dummy header

View file

@ -24,3 +24,14 @@ Represents each screen.
Represent each image for the 3D screen.
GFX_LEFT: Left eye.
GFX_RIGHT: Right eye.
## `void gfxSet3D(bool enable);`
Enable or disable 3D on the top screen.
## `bool gfxIs3D(void);`
Check whether the 3D is enabled on the top screen.
# TO SEE:
## `bool gspPresentBuffer(???);`
"Presents a buffer to the specified screen."

View file

@ -3,35 +3,19 @@
using namespace std;
// RESULTS
// Top screen has 50 cols
// Bottom screen has 40 cols
// Bith screens have 29 lines
int main(void) {
// gfxInitDefault();
// consoleInit(GFX_TOP, NULL);
// cout << "012345678901234567890123456789012345678901234567890123456789" << endl;
// consoleInit(GFX_BOTTOM, NULL);
// cout << "012345678901234567890123456789012345678901234567890123456789" << endl;
// while (aptMainLoop()) {
// gfxFlushBuffers();
// }
// gfxExit();
int main(void) {;
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
for (int i = 50; aptMainLoop(); i--) {
cout << i << endl;
bool value = false;
while (aptMainLoop()) {
hidScanInput();
if (hidKeysDownRepeat() & KEY_A)
break;
gfxFlushBuffers();
}
gfxFlushBuffers();
}
while (aptMainLoop()) {
if (hidKeysDown() & KEY_A)
value = !value;
gspWaitForVBlank();
GSPGPU_SetLedForceOff(value);
gfxFlushBuffers();
gfxSwapBuffers();
}
gfxExit();
}