diff --git a/libctru/include/3ds/console.h b/libctru/include/3ds/console.h index 05aef1a..c71aa89 100644 --- a/libctru/include/3ds/console.h +++ b/libctru/include/3ds/console.h @@ -6,10 +6,14 @@ * 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> @@ -28,14 +32,13 @@ 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. + * @brief Console structure used to store the state of a console render context. * * Default values from consoleGetDefault(); - *
+ * @code
  * PrintConsole defaultConsole =
  * {
  * 	//Font:
@@ -57,13 +60,13 @@ typedef struct ConsoleFont
  *	0,  //print callback
  *	false //console initialized
  * };
- * 
+ * @endcode */ typedef struct PrintConsole { - ConsoleFont font; ///< Font of the console. + ConsoleFont font; ///< Font of the console - u16 *frameBuffer; ///< Framebuffer address. + 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) @@ -89,19 +92,19 @@ typedef struct PrintConsole bool consoleInitialised; ///< True if the console is initialized }PrintConsole; -#define CONSOLE_COLOR_BOLD (1<<0) -#define CONSOLE_COLOR_FAINT (1<<1) -#define CONSOLE_ITALIC (1<<2) -#define CONSOLE_UNDERLINE (1<<3) -#define CONSOLE_BLINK_SLOW (1<<4) -#define CONSOLE_BLINK_FAST (1<<5) -#define CONSOLE_COLOR_REVERSE (1<<6) -#define CONSOLE_CONCEAL (1<<7) -#define CONSOLE_CROSSED_OUT (1<<8) +#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 /// Console debug devices supported by libnds. typedef enum { - debugDevice_NULL, ///< swallows prints to stderr + debugDevice_NULL, ///< Swallows prints to stderr debugDevice_3DMOO, ///< Directs stderr debug statements to 3dmoo debugDevice_CONSOLE, ///< Directs stderr debug statements to 3DS console window } debugDevice; @@ -110,7 +113,7 @@ typedef enum { * @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); /** @@ -120,21 +123,21 @@ void consoleSetFont(PrintConsole* console, ConsoleFont* font); * @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); /** @@ -142,13 +145,13 @@ PrintConsole *consoleSelect(PrintConsole* 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 screan by using iprintf("\x1b[2J"); diff --git a/libctru/include/3ds/gfx.h b/libctru/include/3ds/gfx.h index 072ac6c..2d71446 100644 --- a/libctru/include/3ds/gfx.h +++ b/libctru/include/3ds/gfx.h @@ -5,12 +5,15 @@ * This header provides functions to configure and manipulate the two screens, including double buffering and 3D activation. * It is mainly an abstraction over the gsp service. */ - #pragma once + #include <3ds/types.h> #include <3ds/services/gsp.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) /// Available screens. @@ -47,9 +50,10 @@ typedef enum void gfxInitDefault(void); /** - * @brief Initializes the LCD framebuffers - * @brief topFormat The format of the top screen framebuffers - * @brief bottomFormat The format of the bottom screen framebuffers + * @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 will allocate the memory for the framebuffers and open a gsp service session. * It will also bind the newly allocated framebuffers to the LCD screen and setup the VBlank event. @@ -86,12 +90,15 @@ void gfxSetScreenFormat(gfxScreen_t screen, GSP_FramebufferFormats format); /** * @brief Gets a screen pixel format. + * @param screen Screen to get the pixel format of. * @return the pixel format of the chosen screen set by ctrulib. */ GSP_FramebufferFormats gfxGetScreenFormat(gfxScreen_t screen); /** - * @brief Enables the ctrulib double buffering + * @brief Sets whether to use ctrulib's double buffering + * @param screen Screen to toggle double buffering for. + * @param doubleBuffering Whether to use double buffering. * * ctrulib is by default using a double buffering scheme. * If you do not want to swap one of the screen framebuffers when @ref gfxSwapBuffers or @ref gfxSwapBuffers is called, @@ -133,10 +140,12 @@ void gfxSwapBuffersGpu(void); ///@name Helper ///@{ /** - * @brief Retrieves a framebuffer information - * @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 choosen screen + * @brief Retrieves a framebuffer information. + * @param screen Screen to retrieve framebuffer information for. + * @param side Side of the screen to retrieve framebuffer information for. + * @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 choosen screen. * * Please remember that the returned pointer will change after each call to gfxSwapBuffers if double buffering is enabled. */ diff --git a/libctru/include/3ds/ipc.h b/libctru/include/3ds/ipc.h index f13c59f..c26dc16 100644 --- a/libctru/include/3ds/ipc.h +++ b/libctru/include/3ds/ipc.h @@ -2,7 +2,6 @@ * @file ipc.h * @brief Inter Process Communication helpers */ - #pragma once #include <3ds/types.h> @@ -15,11 +14,12 @@ typedef enum IPC_BUFFER_RW = IPC_BUFFER_R | IPC_BUFFER_W ///< Readable and Writable } IPC_BufferRights; - /** - * @brief Command header to be used for IPC + * @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. @@ -31,10 +31,10 @@ static inline u32 IPC_MakeHeader(u16 command_id, unsigned normal_params, unsigne return ((u32) command_id << 16) | (((u32) normal_params & 0x3F) << 6) | (((u32) translate_params & 0x3F) << 0); } - /** - * @brief Creates the header to share handles + * @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. * @@ -48,6 +48,7 @@ static inline u32 IPC_Desc_SharedHandles(unsigned number) /** * @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. * @@ -59,7 +60,8 @@ static inline u32 IPC_Desc_MoveHandles(unsigned number) } /** - * @brief Asks the kernel to fill the handle with the current process handle. + * @brief Returns the code to ask the kernel to fill the handle with the current process handle. + * @return The code to request the current process handle. * * The next value is a placeholder that will be replaced by the current process handle by the kernel. */ @@ -72,6 +74,7 @@ static inline u32 IPC_Desc_CurProcessHandle(void) * @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. */ @@ -85,10 +88,11 @@ static inline u32 IPC_Desc_StaticBuffer(size_t size, unsigned buffer_id) * @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) +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; @@ -98,7 +102,8 @@ static inline u32 IPC_Desc_PXIBuffer(size_t size, unsigned buffer_id,bool is_rea /** * @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 + * @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. */ diff --git a/libctru/include/3ds/os.h b/libctru/include/3ds/os.h index dbf5453..9c433f8 100644 --- a/libctru/include/3ds/os.h +++ b/libctru/include/3ds/os.h @@ -1,33 +1,41 @@ /** * @file os.h - * - * OS related stuff. + * @brief OS related stuff. */ #pragma once +/// 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) /** * @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(u32 vaddr); /** * @brief Converts 0x14* vmem to 0x30*. - * @return The input address when it's already within the new vmem. - * @return 0 when outside of either LINEAR mem areas. + * @param addr Input 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. */ u32 osConvertOldLINEARMemToNew(u32 addr); /** - * @brief Retreives basic information about a service error. - * @return A string of the summary of an error. + * @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. */ @@ -35,7 +43,7 @@ const char* osStrError(u32 error); /** * @brief Gets the system's FIRM version. - * @return The FIRM version. + * @return The system's FIRM version. * * This can be used to compare system versions easily with @ref SYSTEM_VERSION. */ @@ -43,7 +51,7 @@ u32 osGetFirmVersion(void); /** * @brief Gets the system's kernel version. - * @return The kernel version. + * @return The system's kernel version. * * This can be used to compare system versions easily with @ref SYSTEM_VERSION. * @@ -60,7 +68,8 @@ u32 osGetKernelVersion(void); u64 osGetTime(void); /** - * @brief Returns the Wifi signal strength. + * @brief Gets the current Wifi signal strength. + * @return The current Wifi signal strength. * * Valid values are 0-3: * - 0 means the singal strength is terrible or the 3DS is disconnected from @@ -72,7 +81,5 @@ u64 osGetTime(void); * Values outside the range of 0-3 should never be returned. * * These values correspond with the number of wifi bars displayed by Home Menu. - * - * @return the Wifi signal strength */ u8 osGetWifiStrength(void); diff --git a/libctru/include/3ds/services/ac.h b/libctru/include/3ds/services/ac.h index 2ff8d8b..22b3f28 100644 --- a/libctru/include/3ds/services/ac.h +++ b/libctru/include/3ds/services/ac.h @@ -1,7 +1,21 @@ +/** + * @file ac.h + * @brief AC service. + */ #pragma once +/// Initializes AC. Result acInit(void); + +/// Exits AC. Result acExit(void); +/** + * @brief Gets the current Wifi status. + * @param servhandle Optional pointer to the service handle to use. + * @param out Pointer to output the current Wifi status to. (0 = not connected, 1 = O3DS Internet, 2 = N3DS Internet) + */ Result ACU_GetWifiStatus(Handle* servhandle, u32 *out); + +/// Waits for the system to connect to the internet. Result ACU_WaitInternetConnection(void); diff --git a/libctru/include/3ds/services/am.h b/libctru/include/3ds/services/am.h index 2a05a47..f601d78 100644 --- a/libctru/include/3ds/services/am.h +++ b/libctru/include/3ds/services/am.h @@ -15,20 +15,13 @@ typedef struct u8 unk[6]; ///< Unknown title data. } AM_TitleEntry; - -/** - * @brief Initializes AM. - */ +/// Initializes AM. Result amInit(void); -/** - * @brief Exits AM. - */ +/// Exits AM. Result amExit(void); -/** - * @brief Gets the current AM session handle. - */ +/// Gets the current AM session handle. Handle *amGetSessionHandle(void); /** @@ -42,7 +35,7 @@ Result AM_GetTitleCount(u8 mediatype, u32 *count); * @brief Gets a list of title IDs present in a mediatype. * @param mediatype Mediatype to get titles from. * @param count Number of title IDs to get. - * @param titleIDs Buffer to write retreived title IDs to. + * @param titleIDs Buffer to write retrieved title IDs to. */ Result AM_GetTitleIdList(u8 mediatype, u32 count, u64 *titleIDs); @@ -56,7 +49,7 @@ Result AM_GetDeviceId(u32 *deviceID); * @brief Gets a list of details about installed titles. * @param mediatype Mediatype to get titles from. * @param titleCount Number of titles to list. - * @param titleIdList List of title IDs to retreive details for. + * @param titleIdList List of title IDs to retrieve details for. * @param titleList Buffer to write AM_TitleEntry's to. */ Result AM_ListTitles(u8 mediatype, u32 titleCount, u64 *titleIdList, AM_TitleEntry *titleList); @@ -101,9 +94,7 @@ Result AM_DeleteTitle(u8 mediatype, u64 titleID); */ Result AM_DeleteAppTitle(u8 mediatype, u64 titleID); -/** - * @brief Installs the current NATIVE_FIRM title to NAND (firm0:/ & firm1:/) - */ +/// Installs the current NATIVE_FIRM title to NAND (firm0:/ & firm1:/) Result AM_InstallNativeFirm(void); /** diff --git a/libctru/include/3ds/services/apt.h b/libctru/include/3ds/services/apt.h index 4fa4cea..155bb71 100644 --- a/libctru/include/3ds/services/apt.h +++ b/libctru/include/3ds/services/apt.h @@ -11,7 +11,7 @@ /** * @brief NS Application IDs. * - * Retreived from http://3dbrew.org/wiki/NS_and_APT_Services#AppIDs + * Retrieved from http://3dbrew.org/wiki/NS_and_APT_Services#AppIDs */ typedef enum{ APPID_HOMEMENU = 0x101, ///< Home Menu @@ -36,81 +36,133 @@ typedef enum{ APPID_MEMOLIB = 0x409, ///< memolib }NS_APPID; +/// App status values. typedef enum{ - APP_NOTINITIALIZED, - APP_RUNNING, - APP_SUSPENDED, - APP_EXITING, - APP_SUSPENDING, - APP_SLEEPMODE, - APP_PREPARE_SLEEPMODE, - APP_APPLETSTARTED, - APP_APPLETCLOSED + APP_NOTINITIALIZED, ///< App not initialized. + APP_RUNNING, ///< App running. + APP_SUSPENDED, ///< App suspended. + APP_EXITING, ///< App exiting. + APP_SUSPENDING, ///< App suspending. + APP_SLEEPMODE, ///< App in sleep mode. + APP_PREPARE_SLEEPMODE, ///< App preparing to enter sleep mode. + APP_APPLETSTARTED, ///< Applet started. + APP_APPLETCLOSED ///< Applet closed. }APP_STATUS; +/// APT signals. enum { - APTSIGNAL_HOMEBUTTON = 1, + APTSIGNAL_HOMEBUTTON = 1, ///< Home button pressed. // 2: sleep-mode related? - APTSIGNAL_PREPARESLEEP = 3, + APTSIGNAL_PREPARESLEEP = 3, ///< Prepare to enter sleep mode. // 4: triggered when ptm:s GetShellStatus() returns 5. - APTSIGNAL_ENTERSLEEP = 5, - APTSIGNAL_WAKEUP = 6, - APTSIGNAL_ENABLE = 7, - APTSIGNAL_POWERBUTTON = 8, - APTSIGNAL_UTILITY = 9, - APTSIGNAL_SLEEPSYSTEM = 10, - APTSIGNAL_ERROR = 11 -}; + APTSIGNAL_ENTERSLEEP = 5, ///< Enter sleep mode. + APTSIGNAL_WAKEUP = 6, ///< Wake from sleep mode. + APTSIGNAL_ENABLE = 7, ///< Enable. + APTSIGNAL_POWERBUTTON = 8, ///< Power button pressed. + APTSIGNAL_UTILITY = 9, ///< Utility called. + APTSIGNAL_SLEEPSYSTEM = 10, ///< System sleeping. + APTSIGNAL_ERROR = 11 ///< Error occurred. +} APT_Signal; +/// APT hook types. enum { - APTHOOK_ONSUSPEND = 0, - APTHOOK_ONRESTORE, - APTHOOK_ONSLEEP, - APTHOOK_ONWAKEUP, - APTHOOK_ONEXIT, + APTHOOK_ONSUSPEND = 0, ///< App suspended. + APTHOOK_ONRESTORE, ///< App restored. + APTHOOK_ONSLEEP, ///< App sleeping. + APTHOOK_ONWAKEUP, ///< App waking up. + APTHOOK_ONEXIT, ///< App exiting. - APTHOOK_COUNT, -}; + APTHOOK_COUNT, ///< Number of APT hook types. +} APT_HookType; +/// APT hook function. typedef void (*aptHookFn)(int hook, void* param); +/// APT hook cookie. typedef struct tag_aptHookCookie { - struct tag_aptHookCookie* next; - aptHookFn callback; - void* param; + struct tag_aptHookCookie* next; ///< Next cookie. + aptHookFn callback; ///< Hook callback. + void* param; ///< Callback parameter. } aptHookCookie; +/// APT events. extern Handle aptEvents[3]; +/// Initializes APT. Result aptInit(void); + +/// Exits APT. void aptExit(void); + +/// Opens an APT session. void aptOpenSession(void); + +/// Closes an APT session. void aptCloseSession(void); -void aptSetStatus(APP_STATUS status); -APP_STATUS aptGetStatus(void); + /** - * @brief Checks the what triggered a return-to-menu, when the status is APT_SUSPEND. - * @return 0 = home-button, 1 = power-button. + * @brief Sets the app's status. + * @param status Status to set. + */ +void aptSetStatus(APP_STATUS status); + +/** + * @brief Gets the app's status. + * @return The app's status. + */ +APP_STATUS aptGetStatus(void); + +/** + * @brief Gets the app's power status. + * When the status is APT_SUSPEND, this can be used to check what triggered a return-to-menu. + * @return The app's power status. (0 = normal, 1 = power button pressed) */ u32 aptGetStatusPower(void); + +/** + * @brief Sets the app's power status. + * @param status Power status to set. + */ void aptSetStatusPower(u32 status); + /** * @brief Triggers a return to the home menu. * * This should be called by the user application when aptGetStatus() returns APP_SUSPENDING, not calling this will result in return-to-menu being disabled with the status left at APP_SUSPENDING. This function will not return until the system returns to the application, or when the status was changed to APP_EXITING. */ void aptReturnToMenu(void); + +/// Waits for an APT status event. void aptWaitStatusEvent(void); + +/// Signals that the app is ready to sleep. void aptSignalReadyForSleep(void); + +/** + * @brief Gets the menu's app ID. + * @return The menu's app ID. + */ NS_APPID aptGetMenuAppID(void); + /** * @brief Processes the current APT status. Generally used within a main loop. * @return Whether the application is closing. */ 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); Result APT_GetLockHandle(u16 flags, Handle* lockHandle); @@ -136,31 +188,106 @@ Result APT_SendParameter(NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, Result APT_SendCaptureBufferInfo(u32 bufferSize, u32* buffer); Result APT_ReplySleepQuery(NS_APPID appID, u32 a); Result APT_ReplySleepNotificationComplete(NS_APPID appID); + +/** + * @brief Prepares to close the application. + * @param a Whether the jump is to the home menu. + */ Result APT_PrepareToCloseApplication(u8 a); + +/** + * @brief Closes the application. + * @param param Parameter to use. + * @param paramSize Size of param. + * @param handle Handle to use. + */ Result APT_CloseApplication(const u8 *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. * Note: this function is unreliable, see: http://3dbrew.org/wiki/APT:PrepareToStartApplication * @param out Pointer to write the New 3DS flag to. */ Result APT_CheckNew3DS_Application(u8 *out); + +/** + * @brief Checks whether the system is a New 3DS. + * @param out Pointer to write the New 3DS flag to. + */ Result APT_CheckNew3DS_System(u8 *out); + +/** + * @brief Checks whether the system is a New 3DS. + * @param out Pointer to write the New 3DS flag to. + */ Result APT_CheckNew3DS(u8 *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_PrepareToDoAppJump(u8 flags, u64 programID, u8 mediatype); + +/** + * @brief Performs an application jump. + * @param NSbuf0Size Size of NSbuf0Ptr. + * @param NSbuf1Size Size of NSbuf1Ptr. + * @param NSbuf0Ptr Launch buffer 0. + * @param NSbuf1Ptr Launch buffer 1. + */ Result APT_DoAppJump(u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr); + +/** + * @brief Prepares to start a library applet. + * @param appID ID of the applet to start. + */ Result APT_PrepareToStartLibraryApplet(NS_APPID appID); + +/** + * @brief Starts a library applet. + * @param appID ID of the applet to launch. + * @param inhandle Handle to pass to the applet. + * @param parambuf Buffer containing applet parameters. + * @param parambufsize Size of parambuf. + */ Result APT_StartLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize); + /** * @brief Launches a library applet. * Note: This is not usable from the homebrew launcher. This is broken: when the applet does get launched at all, the applet process doesn't actually get terminated when the applet gets closed. * @param appID ID of the applet to launch. * @param inhandle Handle to pass to the applet. - * @param parambuf Buffer containing applet input parameters. + * @param parambuf Buffer containing applet parameters. * @param parambufsize Size of parambuf. */ Result APT_LaunchLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize); + +/** + * @brief Prepares to start a system applet. + * @param appID ID of the applet to start. + */ Result APT_PrepareToStartSystemApplet(NS_APPID appID); + +/** + * @brief Starts a system applet. + * @param appID ID of the applet to launch. + * @param bufSize Size of the parameter buffer. + * @param applHandle Handle to pass to the applet. + * @param buf Buffer containing applet parameters. + */ Result APT_StartSystemApplet(NS_APPID appID, u32 bufSize, Handle applHandle, u8 *buf); diff --git a/libctru/include/3ds/services/cam.h b/libctru/include/3ds/services/cam.h index 1158369..0c77197 100644 --- a/libctru/include/3ds/services/cam.h +++ b/libctru/include/3ds/services/cam.h @@ -3,196 +3,168 @@ * @brief CAM service for using the 3DS's front and back cameras. */ #pragma once + #include <3ds/services/y2r.h> #include <3ds/types.h> -/** - * @brief Camera connection target ports. - */ +/// Camera connection target ports. typedef enum { - PORT_NONE = 0x0, - PORT_CAM1 = BIT(0), - PORT_CAM2 = BIT(1), + 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, + PORT_BOTH = PORT_CAM1 | PORT_CAM2, ///< Both ports. } CAMU_Port; -/** - * @brief Camera combinations. - */ +/// Camera combinations. typedef enum { - SELECT_NONE = 0x0, - SELECT_OUT1 = BIT(0), - SELECT_IN1 = BIT(1), - SELECT_OUT2 = BIT(2), + 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, - SELECT_OUT1_OUT2 = SELECT_OUT1 | SELECT_OUT2, - SELECT_IN1_OUT2 = SELECT_IN1 | SELECT_OUT2, - SELECT_ALL = SELECT_OUT1 | SELECT_IN1 | SELECT_OUT2, + 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. } CAMU_CameraSelect; -/** - * @brief Camera contexts. - */ +/// Camera contexts. typedef enum { - CONTEXT_NONE = 0x0, - CONTEXT_A = BIT(0), - CONTEXT_B = BIT(1), + 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, + CONTEXT_BOTH = CONTEXT_A | CONTEXT_B, ///< Both contexts. } CAMU_Context; -/** - * @brief Ways to flip the camera image. - */ +/// Ways to flip the camera image. typedef enum { - FLIP_NONE = 0x0, - FLIP_HORIZONTAL = 0x1, - FLIP_VERTICAL = 0x2, - FLIP_REVERSE = 0x3, + FLIP_NONE = 0x0, ///< No flip. + FLIP_HORIZONTAL = 0x1, ///< Horizontal flip. + FLIP_VERTICAL = 0x2, ///< Vertical flip. + FLIP_REVERSE = 0x3, ///< Reverse flip. } CAMU_Flip; -/** - * @brief Camera image resolutions. - */ +/// Camera image resolutions. typedef enum { - SIZE_VGA = 0x0, - SIZE_QVGA = 0x1, - SIZE_QQVGA = 0x2, - SIZE_CIF = 0x3, - SIZE_QCIF = 0x4, - SIZE_DS_LCD = 0x5, - SIZE_DS_LCDx4 = 0x6, - SIZE_CTR_TOP_LCD = 0x7, + 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, + SIZE_CTR_BOTTOM_LCD = SIZE_QVGA, ///< CTR Bottom LCD size. (320x240) } CAMU_Size; -/** - * @brief Camera capture frame rates. - */ +/// Camera capture frame rates. typedef enum { - FRAME_RATE_15 = 0x0, - FRAME_RATE_15_TO_5 = 0x1, - FRAME_RATE_15_TO_2 = 0x2, - FRAME_RATE_10 = 0x3, - FRAME_RATE_8_5 = 0x4, - FRAME_RATE_5 = 0x5, - FRAME_RATE_20 = 0x6, - FRAME_RATE_20_TO_5 = 0x7, - FRAME_RATE_30 = 0x8, - FRAME_RATE_30_TO_5 = 0x9, - FRAME_RATE_15_TO_10 = 0xA, - FRAME_RATE_20_TO_10 = 0xB, - FRAME_RATE_30_TO_10 = 0xC, + 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; -/** - * @brief Camera white balance modes. - */ +/// Camera white balance modes. typedef enum { - WHITE_BALANCE_AUTO = 0x0, - WHITE_BALANCE_3200K = 0x1, - WHITE_BALANCE_4150K = 0x2, - WHITE_BALANCE_5200K = 0x3, - WHITE_BALANCE_6000K = 0x4, - WHITE_BALANCE_7000K = 0x5, - WHITE_BALANCE_MAX = 0x6, + 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, - WHITE_BALANCE_TUNGSTEN = WHITE_BALANCE_3200K, - WHITE_BALANCE_WHITE_FLUORESCENT_LIGHT = WHITE_BALANCE_4150K, - WHITE_BALANCE_DAYLIGHT = WHITE_BALANCE_5200K, - WHITE_BALANCE_CLOUDY = WHITE_BALANCE_6000K, - WHITE_BALANCE_HORIZON = WHITE_BALANCE_6000K, - WHITE_BALANCE_SHADE = WHITE_BALANCE_7000K, + 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; -/** - * @brief Camera photo modes. - */ +/// Camera photo modes. typedef enum { - PHOTO_MODE_NORMAL = 0x0, - PHOTO_MODE_PORTRAIT = 0x1, - PHOTO_MODE_LANDSCAPE = 0x2, - PHOTO_MODE_NIGHTVIEW = 0x3, - PHOTO_MODE_LETTER = 0x4, + 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; -/** - * @brief Camera special effects. - */ +/// Camera special effects. typedef enum { - EFFECT_NONE = 0x0, - EFFECT_MONO = 0x1, - EFFECT_SEPIA = 0x2, - EFFECT_NEGATIVE = 0x3, - EFFECT_NEGAFILM = 0x4, - EFFECT_SEPIA01 = 0x5, + 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; -/** - * @brief Camera contrast patterns. - */ +/// Camera contrast patterns. typedef enum { - CONTRAST_PATTERN_01 = 0x0, - CONTRAST_PATTERN_02 = 0x1, - CONTRAST_PATTERN_03 = 0x2, - CONTRAST_PATTERN_04 = 0x3, - CONTRAST_PATTERN_05 = 0x4, - CONTRAST_PATTERN_06 = 0x5, - CONTRAST_PATTERN_07 = 0x6, - CONTRAST_PATTERN_08 = 0x7, - CONTRAST_PATTERN_09 = 0x8, - CONTRAST_PATTERN_10 = 0x9, - CONTRAST_PATTERN_11 = 0xA, + 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, - CONTRAST_NORMAL = CONTRAST_PATTERN_06, - CONTRAST_HIGH = CONTRAST_PATTERN_07, + 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; -/** - * @brief Camera lens correction modes. - */ +/// Camera lens correction modes. typedef enum { - LENS_CORRECTION_OFF = 0x0, - LENS_CORRECTION_ON_70 = 0x1, - LENS_CORRECTION_ON_90 = 0x2, + 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, - LENS_CORRECTION_NORMAL = LENS_CORRECTION_ON_70, - LENS_CORRECTION_BRIGHT = LENS_CORRECTION_ON_90, + 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; -/** - * @brief Camera image output formats. - */ +/// Camera image output formats. typedef enum { - OUTPUT_YUV_422 = 0x0, - OUTPUT_RGB_565 = 0x1, + OUTPUT_YUV_422 = 0x0, ///< YUV422 + OUTPUT_RGB_565 = 0x1, ///< RGB565 } CAMU_OutputFormat; -/** - * @brief Camera shutter sounds. - */ +/// Camera shutter sounds. typedef enum { - SHUTTER_SOUND_TYPE_NORMAL = 0x0, - SHUTTER_SOUND_TYPE_MOVIE = 0x1, - SHUTTER_SOUND_TYPE_MOVIE_END = 0x2, + 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; -/** - * @brief Image quality calibration data. - */ +/// Image quality calibration data. typedef struct { s16 aeBaseTarget; ///< Auto exposure base target brightness. s16 kRL; ///< Left color correction matrix red normalization coefficient. @@ -207,9 +179,7 @@ typedef struct { u16 awbX0Left; ///< Left camera, color correction matrix position threshold. } CAMU_ImageQualityCalibrationData; -/** - * @brief Stereo camera calibration data. - */ +/// 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) @@ -228,9 +198,7 @@ typedef struct { u8 reserved[16]; ///< Reserved for future use. (unused) } CAMU_StereoCameraCalibrationData; -/** - * @brief Batch camera configuration for use without a context. - */ +/// Batch camera configuration for use without a context. typedef struct { u8 camera; ///< #CAMU_CameraSelect Selected camera. s8 exposure; ///< Camera exposure. @@ -254,9 +222,7 @@ typedef struct { s16 autoWhiteBalanceWindowHeight; ///< Height of the region to use for auto white balance. } CAMU_PackageParameterCameraSelect; -/** - * @brief Batch camera configuration for use with a context. - */ +/// Batch camera configuration for use with a context. typedef struct { u8 camera; ///< #CAMU_CameraSelect Selected camera. u8 context; ///< #CAMU_Context Selected context. @@ -265,9 +231,7 @@ typedef struct { u8 size; ///< #CAMU_Size Camera image resolution. } CAMU_PackageParameterContext; -/** - * @brief Batch camera configuration for use with a context and with detailed size information. - */ +/// Batch camera configuration for use with a context and with detailed size information. typedef struct { u8 camera; ///< #CAMU_CameraSelect Selected camera. u8 context; ///< #CAMU_Context Selected context. @@ -295,276 +259,445 @@ Result camInit(void); */ Result camExit(void); -/// Begins capture on the specified camera port. +/** + * Begins capture on the specified camera port. + * @param port Port to begin capture on. + */ Result CAMU_StartCapture(CAMU_Port port); -///Terminates capture on the specified camera port. +/** + * Terminates capture on the specified camera port. + * @param port Port to terminate capture on. + */ Result CAMU_StopCapture(CAMU_Port port); /** * @brief Gets whether the specified camera port is busy. - * - * Writes the result to the provided output pointer. + * @param busy Pointer to output the busy state to. + * @param port Port to check. */ Result CAMU_IsBusy(bool* busy, CAMU_Port port); -///Clears the buffer and error flags of the specified camera port. +/** + * @brief Clears the buffer and error flags of the specified camera port. + * @param port Port to clear. + */ Result CAMU_ClearBuffer(CAMU_Port port); /** * @brief Gets a handle to the event signaled on vsync interrupts. - * - * Writes the event handle to the provided output pointer. + * @param event Pointer to output the event handle to. + * @param port Port to use. */ Result CAMU_GetVsyncInterruptEvent(Handle* event, CAMU_Port port); /** * @brief Gets a handle to the event signaled on camera buffer errors. - * - * Writes the event handle to the provided output pointer. + * @param event Pointer to output the event handle to. + * @param port Port to use. */ Result CAMU_GetBufferErrorInterruptEvent(Handle* event, CAMU_Port port); /** * @brief Initiates the process of receiving a camera frame. - * - * Writes a completion event handle to the provided pointer and writes image data to the provided buffer. + * @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, CAMU_Port port, u32 imageSize, s16 transferUnit); /** * @brief Gets whether the specified camera port has finished receiving image data. - * - * Writes the result to the provided output pointer. + * @param finishedReceiving Pointer to output the receiving status to. + * @param port Port to check. */ Result CAMU_IsFinishedReceiving(bool* finishedReceiving, CAMU_Port port); -///Sets the number of lines to transfer into an image buffer. +/** + * @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(CAMU_Port port, s16 lines, s16 width, s16 height); /** * @brief Gets the maximum number of lines that can be saved to an image buffer. - * - * Writes the result to the provided output pointer. + * @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); -///Sets the number of bytes to transfer into an image buffer. +/** + * @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(CAMU_Port port, u32 bytes, s16 width, s16 height); /** * @brief Gets the number of bytes to transfer into an image buffer. - * - * Writes the result to the provided output pointer. + * @param transferBytes Pointer to write the number of bytes to. + * @param port Port to use. */ Result CAMU_GetTransferBytes(u32* transferBytes, CAMU_Port port); /** * @brief Gets the maximum number of bytes that can be saved to an image buffer. - * - * Writes the result to the provided output pointer. + * @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); -///Sets whether image trimming is enabled. +/** + * @brief Sets whether image trimming is enabled. + * @param port Port to use. + * @param trimming Whether image trimming is enabled. + */ Result CAMU_SetTrimming(CAMU_Port port, bool trimming); /** * @brief Gets whether image trimming is enabled. - * - * Writes the result to the provided output pointer. + * @param trimming Pointer to output the trim state to. + * @param port Port to use. */ Result CAMU_IsTrimming(bool* trimming, CAMU_Port port); -///Sets the parameters used for trimming images. +/** + * @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(CAMU_Port port, s16 xStart, s16 yStart, s16 xEnd, s16 yEnd); /** * @brief Gets the parameters used for trimming images. - * - * Writes the result to the provided output pointer. + * @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, CAMU_Port port); -///Sets the parameters used for trimming images, relative to the center of the image. +/** + * @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(CAMU_Port port, s16 trimWidth, s16 trimHeight, s16 camWidth, s16 camHeight); -///Activates the specified camera. +/** + * @brief Activates the specified camera. + * @param select Camera to use. + */ Result CAMU_Activate(CAMU_CameraSelect select); -///Switches the specified camera's active context. +/** + * @brief Switches the specified camera's active context. + * @param select Camera to use. + * @param context Context to use. + */ Result CAMU_SwitchContext(CAMU_CameraSelect select, CAMU_Context context); -///Sets the exposure value of the specified camera. +/** + * @brief Sets the exposure value of the specified camera. + * @param select Camera to use. + * @param exposure Exposure value to use. + */ Result CAMU_SetExposure(CAMU_CameraSelect select, s8 exposure); -///Sets the white balance mode of the specified camera. +/** + * @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(CAMU_CameraSelect 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(CAMU_CameraSelect select, CAMU_WhiteBalance whiteBalance); -///Sets the sharpness of the specified camera. +/** + * @brief Sets the sharpness of the specified camera. + * @param select Camera to use. + * @param sharpness Sharpness to use. + */ Result CAMU_SetSharpness(CAMU_CameraSelect select, s8 sharpness); -///Sets whether auto exposure is enabled on the specified camera. +/** + * @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(CAMU_CameraSelect select, bool autoExposure); /** * @brief Gets whether auto exposure is enabled on the specified camera. - * - * Writes the result to the provided output pointer. + * @param autoExposure Pointer to output the auto exposure state to. + * @param select Camera to use. */ Result CAMU_IsAutoExposure(bool* autoExposure, CAMU_CameraSelect select); -///Sets whether auto white balance is enabled on the specified camera. +/** + * @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(CAMU_CameraSelect select, bool autoWhiteBalance); /** * @brief Gets whether auto white balance is enabled on the specified camera. - * - * Writes the result to the provided output pointer. + * @param autoWhiteBalance Pointer to output the auto white balance state to. + * @param select Camera to use. */ Result CAMU_IsAutoWhiteBalance(bool* autoWhiteBalance, CAMU_CameraSelect select); -///Flips the image of the specified camera in the specified context. +/** + * @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(CAMU_CameraSelect select, CAMU_Flip flip, CAMU_Context context); -///Sets the image resolution of the given camera in the given context, in detail. +/** + * @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(CAMU_CameraSelect select, s16 width, s16 height, s16 cropX0, s16 cropY0, s16 cropX1, s16 cropY1, CAMU_Context context); -///Sets the image resolution of the given camera in the given 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(CAMU_CameraSelect select, CAMU_Size size, CAMU_Context context); -///Sets the frame rate of the given camera. +/** + * @brief Sets the frame rate of the given camera. + * @param select Camera to use. + * @param frameRate Frame rate to use. + */ Result CAMU_SetFrameRate(CAMU_CameraSelect select, CAMU_FrameRate frameRate); -///Sets the photo mode of the given camera. +/** + * @brief Sets the photo mode of the given camera. + * @param select Camera to use. + * @param photoMode Photo mode to use. + */ Result CAMU_SetPhotoMode(CAMU_CameraSelect select, CAMU_PhotoMode photoMode); -///Sets the special effects of the given camera in the given context. +/** + * @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(CAMU_CameraSelect select, CAMU_Effect effect, CAMU_Context context); -///Sets the contrast mode of the given camera. +/** + * @brief Sets the contrast mode of the given camera. + * @param select Camera to use. + * @param contrast Contrast mode to use. + */ Result CAMU_SetContrast(CAMU_CameraSelect select, CAMU_Contrast contrast); -///Sets the lens correction mode of the given camera. +/** + * @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(CAMU_CameraSelect select, CAMU_LensCorrection lensCorrection); -///Sets the output format of the given camera in the given context. +/** + * @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(CAMU_CameraSelect select, CAMU_OutputFormat format, CAMU_Context context); -///Sets the region to base auto exposure off of for the specified camera. +/** + * @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(CAMU_CameraSelect select, s16 x, s16 y, s16 width, s16 height); -///Sets the region to base auto white balance off of for the specified camera. +/** + * @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(CAMU_CameraSelect select, s16 x, s16 y, s16 width, s16 height); -///Sets whether the specified camera's noise filter is enabled. +/** + * @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(CAMU_CameraSelect select, bool noiseFilter); -///Synchronizes the specified cameras' vsync timing. +/** + * @brief Synchronizes the specified cameras' vsync timing. + * @param select1 First camera. + * @param select2 Second camera. + */ Result CAMU_SynchronizeVsyncTiming(CAMU_CameraSelect select1, CAMU_CameraSelect select2); /** * @brief Gets the vsync timing record of the specified camera for the specified number of signals. - * - * Writes the result to the provided output pointer, which should be of size "past * sizeof(s64)". + * @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, CAMU_Port port, u32 past); /** * @brief Gets the specified camera's stereo camera calibration data. - * - * Writes the result to the provided output pointer. + * @param data Pointer to output the stereo camera data to. */ Result CAMU_GetStereoCameraCalibrationData(CAMU_StereoCameraCalibrationData* data); -///Sets the specified camera's stereo camera calibration 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. - * - * Use with caution. + * @param select Camera to write to. + * @param addr Address to write to. + * @param data Data to write. */ Result CAMU_WriteRegisterI2c(CAMU_CameraSelect select, u16 addr, u16 data); /** * @brief Writes to the specified MCU variable of the specified camera. - * - * Use with caution. + * @param select Camera to write to. + * @param addr Address to write to. + * @param data Data to write. */ Result CAMU_WriteMcuVariableI2c(CAMU_CameraSelect select, u16 addr, u16 data); /** * @brief Reads the specified I2C register of the specified camera. - * - * Writes the result to the provided output pointer. + * @param data Pointer to read data to. + * @param select Camera to read from. + * @param addr Address to read. */ Result CAMU_ReadRegisterI2cExclusive(u16* data, CAMU_CameraSelect select, u16 addr); /** * @brief Reads the specified MCU variable of the specified camera. - * - * Writes the result to the provided output pointer. + * @param data Pointer to read data to. + * @param select Camera to read from. + * @param addr Address to read. */ Result CAMU_ReadMcuVariableI2cExclusive(u16* data, CAMU_CameraSelect 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. - * - * Writes the result to the provided output pointer. + * @param data Pointer to write the quality data to. */ Result CAMU_GetImageQualityCalibrationData(CAMU_ImageQualityCalibrationData* data); -///Configures a camera with pre-packaged configuration data without a context. +/** + * @brief Configures a camera with pre-packaged configuration data without a context. + * @param Parameter to use. + */ Result CAMU_SetPackageParameterWithoutContext(CAMU_PackageParameterCameraSelect param); -///Configures a camera with pre-packaged configuration data with a context. +/** + * @brief Configures a camera with pre-packaged configuration data with a context. + * @param Parameter to use. + */ Result CAMU_SetPackageParameterWithContext(CAMU_PackageParameterContext param); -///Configures a camera with pre-packaged configuration data without a context and extra resolution details. +/** + * @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); -///Gets the Y2R coefficient applied to image data by the camera. +/** + * @brief Gets the Y2R coefficient applied to image data by the camera. + * @param coefficient Pointer to output the Y2R coefficient to. + */ Result CAMU_GetSuitableY2rStandardCoefficient(Y2R_StandardCoefficient* coefficient); -///Plays the specified shutter sound. +/** + * @brief Plays the specified shutter sound. + * @param sound Shutter sound to play. + */ Result CAMU_PlayShutterSound(CAMU_ShutterSoundType sound); -///Initializes the camera driver. +/// Initializes the camera driver. Result CAMU_DriverInitialize(void); -///Finalizes the camera driver. +/// Finalizes the camera driver. Result CAMU_DriverFinalize(void); /** * @brief Gets the current activated camera. - * - * Writes the result to the provided output pointer. + * @param select Pointer to output the current activated camera to. */ Result CAMU_GetActivatedCamera(CAMU_CameraSelect* select); /** * @brief Gets the current sleep camera. - * - * Writes the result to the provided output pointer. + * @param select Pointer to output the current sleep camera to. */ Result CAMU_GetSleepCamera(CAMU_CameraSelect* select); -///Sets the current sleep camera. +/** + * @brief Sets the current sleep camera. + * @param select Camera to set. + */ Result CAMU_SetSleepCamera(CAMU_CameraSelect select); -///Sets whether to enable synchronization of left and right camera brightnesses. +/** + * @brief Sets whether to enable synchronization of left and right camera brightnesses. + * @param brightnessSynchronization Whether to enable brightness synchronization. + */ Result CAMU_SetBrightnessSynchronization(bool brightnessSynchronization); diff --git a/libctru/include/3ds/services/cfgnor.h b/libctru/include/3ds/services/cfgnor.h index 6bcfd71..7132a53 100644 --- a/libctru/include/3ds/services/cfgnor.h +++ b/libctru/include/3ds/services/cfgnor.h @@ -1,8 +1,44 @@ +/** + * @file cfgnor.h + * @brief CFGNOR service. + */ #pragma once +/** + * @brief Initializes CFGNOR. + * @param value Unknown, usually 1. + */ Result CFGNOR_Initialize(u8 value); + +/// Shuts down CFGNOR. Result CFGNOR_Shutdown(); + +/** + * @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); + +/** + * @brief Dumps the NOR flash. + * @param buf Buffer to dump to. + * @param size Size of the buffer. + */ Result CFGNOR_DumpFlash(u32 *buf, u32 size); + +/** + * @brief Writes the NOR flash. + * @param buf Buffer to write from. + * @param size Size of the buffer. + */ Result CFGNOR_WriteFlash(u32 *buf, u32 size); diff --git a/libctru/include/3ds/services/cfgu.h b/libctru/include/3ds/services/cfgu.h index e3ca2ef..322bbd6 100644 --- a/libctru/include/3ds/services/cfgu.h +++ b/libctru/include/3ds/services/cfgu.h @@ -1,41 +1,95 @@ #pragma once +/// Configuration region values. typedef enum { - CFG_REGION_JPN = 0, - CFG_REGION_USA = 1, - CFG_REGION_EUR = 2, - CFG_REGION_AUS = 3, - CFG_REGION_CHN = 4, - CFG_REGION_KOR = 5, - CFG_REGION_TWN = 6, + 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, - CFG_LANGUAGE_EN = 1, - CFG_LANGUAGE_FR = 2, - CFG_LANGUAGE_DE = 3, - CFG_LANGUAGE_IT = 4, - CFG_LANGUAGE_ES = 5, - CFG_LANGUAGE_ZH = 6, - CFG_LANGUAGE_KO = 7, - CFG_LANGUAGE_NL = 8, - CFG_LANGUAGE_PT = 9, - CFG_LANGUAGE_RU = 10, - CFG_LANGUAGE_TW = 11, + 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_Langage; +/// Initializes CFGU. Result initCfgu(void); + +/// Exits CFGU. Result exitCfgu(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. (0 = O3DS, 1 = O3DSXL, 2 = N3DS, 3 = 2DS, 4 = N3DSXL) + */ 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 Gets a config info block. + * @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, u8* outData); + +/** + * @brief Gets the system's language. + * @param language Pointer to write the language to. (see @ref CFG_Langage) + */ Result CFGU_GetSystemLanguage(u8* language); diff --git a/libctru/include/3ds/services/csnd.h b/libctru/include/3ds/services/csnd.h index c957959..c35d650 100644 --- a/libctru/include/3ds/services/csnd.h +++ b/libctru/include/3ds/services/csnd.h @@ -6,12 +6,17 @@ #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) { @@ -27,50 +32,57 @@ static inline u32 CSND_VOL(float vol, float pan) return lvol | (rvol << 16); } +/// CSND encodings. enum { CSND_ENCODING_PCM8 = 0, ///< PCM8 CSND_ENCODING_PCM16, ///< PCM16 CSND_ENCODING_ADPCM, ///< IMA-ADPCM - CSND_ENCODING_PSG, ///< Similar to DS? -}; + CSND_ENCODING_PSG, ///< PSG (Similar to DS?) +} CSND_Encoding; +/// CSND loop modes. enum { - CSND_LOOPMODE_MANUAL = 0, - CSND_LOOPMODE_NORMAL, - CSND_LOOPMODE_ONESHOT, - CSND_LOOPMODE_NORELOAD, -}; + CSND_LOOPMODE_MANUAL = 0, ///< Manual loop. + CSND_LOOPMODE_NORMAL, ///< Normal loop. + CSND_LOOPMODE_ONESHOT, ///< Do not loop. + CSND_LOOPMODE_NORELOAD, ///< Don't reload. +} CSND_LoopMode; +/// 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), - SOUND_REPEAT = SOUND_LOOPMODE(CSND_LOOPMODE_NORMAL), - SOUND_ONE_SHOT = SOUND_LOOPMODE(CSND_LOOPMODE_ONESHOT), - SOUND_FORMAT_8BIT = SOUND_FORMAT(CSND_ENCODING_PCM8), - SOUND_FORMAT_16BIT = SOUND_FORMAT(CSND_ENCODING_PCM16), - SOUND_FORMAT_ADPCM = SOUND_FORMAT(CSND_ENCODING_ADPCM), - SOUND_FORMAT_PSG = SOUND_FORMAT(CSND_ENCODING_PSG), - SOUND_ENABLE = BIT(14), -}; + 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. +} CSND_Flag; +/// Capture modes. enum { - CAPTURE_REPEAT = 0, - CAPTURE_ONE_SHOT = BIT(0), - CAPTURE_FORMAT_16BIT = 0, - CAPTURE_FORMAT_8BIT = BIT(1), - CAPTURE_ENABLE = BIT(15), -}; + 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. +} CSND_CaptureMode; -/** - * @brief Duty cycles for a PSG channel. - */ +/// Duty cycles for a PSG channel. enum { DutyCycle_0 = 7, ///< 0.0% duty cycle @@ -81,42 +93,53 @@ enum DutyCycle_62 = 4, ///< 62.5% duty cycle DutyCycle_75 = 5, ///< 75.0% duty cycle DutyCycle_87 = 6 ///< 87.5% duty cycle -}; +} CSND_PSGDutyCycles; +/// Channel info. typedef union { - u32 value[3]; + u32 value[3]; ///< Raw values. struct { - u8 active; - u8 _pad1; - u16 _pad2; - s16 adpcmSample; - u8 adpcmIndex; - u8 _pad3; - u32 unknownZero; + 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]; + u32 value[2]; ///< Raw values. struct { - u8 active; - u8 _pad1; - u16 _pad2; - u32 unknownZero; + 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; -extern u32 csndSharedMemSize; -extern u32 csndChannels; // Bitmask of channels that are allowed for usage +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); /** @@ -125,47 +148,211 @@ Result CSND_ReleaseCapUnit(u32 capUnit); */ Result CSND_Reset(void); +/// Initializes CSND. Result csndInit(void); + +/// Exits CSND. Result csndExit(void); /** - * @brief Adds a command to the list and returns the buffer to write its arguments to. + * @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 and copies its arguments from a buffer. + * @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, u32 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, u32 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); /** @@ -182,17 +369,39 @@ Result CSND_UpdateInfo(bool waitDone); 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); diff --git a/libctru/include/3ds/services/dsp.h b/libctru/include/3ds/services/dsp.h index 476e7bb..4515e38 100644 --- a/libctru/include/3ds/services/dsp.h +++ b/libctru/include/3ds/services/dsp.h @@ -7,12 +7,13 @@ #pragma once #include <3ds/types.h> +/// DSP interrupt types. typedef enum { - DSP_INTERRUPT_PIPE = 2 + DSP_INTERRUPT_PIPE = 2 ///< Pipe interrupt. } DSP_InterruptType; - +/// DSP pipe directions. typedef enum { DSP_PIPE_INPUT = 0, ///< DSP to ARM @@ -34,7 +35,10 @@ Result dspInit(void); */ Result dspExit(void); -///Checks if a headphone is inserted. +/** + * @brief Checks if a headphone is inserted. + * @param is_inserted Pointer to output the insertion status to. + */ Result DSP_GetHeadphoneStatus(bool* is_inserted); /** @@ -55,13 +59,22 @@ Result DSP_FlushDataCache(const void* address, u32 size); */ Result DSP_InvalidateDataCache(const void* address, u32 size); -///Retrieves the handle of the DSP semaphore +/** + * @brief Retrieves the handle of the DSP semaphore. + * @param semaphore Pointer to output the semaphore to. + */ Result DSP_GetSemaphoreHandle(Handle* semaphore); -///Sets the DSP hardware semaphore value +/** + * @brief Sets the DSP hardware semaphore value. + * @param value Value to set. + */ Result DSP_SetSemaphore(u16 value); -///Masks the DSP hardware semaphore value +/** + * @brief Masks the DSP hardware semaphore value. + * @param mask Mask to apply. + */ Result DSP_SetSemaphoreMask(u16 mask); /** @@ -77,12 +90,13 @@ Result DSP_SetSemaphoreMask(u16 mask); */ Result DSP_LoadComponent(const void* component, u32 size, u16 prog_mask, u16 data_mask, bool* is_loaded); -///Stops the DSP by unloading the binary +///Stops the DSP by unloading the binary. Result DSP_UnloadComponent(void); /** * @brief Registers an event handle with the DSP through IPC - * @param interrut The type of interrupt that will trigger the event. Usual value is DSP_INTERRUPT_PIPE. + * @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 @@ -90,6 +104,7 @@ Result DSP_UnloadComponent(void); 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 @@ -99,24 +114,31 @@ Result DSP_RegisterInterruptEvents(Handle handle, u32 interrupt, u32 channel); Result DSP_ReadPipeIfPossible(u32 channel, u32 peer, void* buffer, u16 length, u16* length_read); /** + * @param 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); -///Converts a DSP memory to a virtual address usable by the process +/** + * @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. */ @@ -125,6 +147,7 @@ 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. */ @@ -133,5 +156,6 @@ 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); diff --git a/libctru/include/3ds/services/fs.h b/libctru/include/3ds/services/fs.h index d31cccc..159c5dd 100644 --- a/libctru/include/3ds/services/fs.h +++ b/libctru/include/3ds/services/fs.h @@ -6,15 +6,8 @@ #include <3ds/types.h> -/** - * @defgroup fs_open_flags FS Open Flags - * - * @sa FSUSER_OpenFile - * @sa FSUSER_OpenFileDirectly - * - * @{ - */ - +///@name FS Open Flags +///@{ /// Open file for read. #define FS_OPEN_READ (1<<0) /// Open file for write. @@ -23,15 +16,8 @@ #define FS_OPEN_CREATE (1<<2) /// @} -/** - * @defgroup fs_create_attributes FS Create Attributes - * - * @sa FSUSER_OpenFile - * @sa FSUSER_OpenFileDirectly - * - * @{ - */ - +///@name FS Create Attributes +///@{ /// No attributes. #define FS_ATTRIBUTE_NONE (0x00000000) /// Create with read-only attribute. @@ -44,22 +30,15 @@ #define FS_ATTRIBUTE_DIRECTORY (0x01000000) /// @} -/** - * @defgroup fs_write_flush_flags FS Flush Flags - * - * @sa FSFILE_Write - * - * @{ - */ - +///@name FS Flush Flags +///@{ /// Don't flush #define FS_WRITE_NOFLUSH (0x00000000) /// Flush #define FS_WRITE_FLUSH (0x00010001) - /// @} -/// FS path type +/// FS path type. typedef enum { PATH_INVALID = 0, ///< Specifies an invalid path. @@ -69,24 +48,24 @@ typedef enum PATH_WCHAR = 4, ///< Specifies a text based path with a 16-bit short per character. } FS_pathType; -/// FS archive ids +/// FS archive IDs. typedef enum { - ARCH_ROMFS = 0x3, - ARCH_SAVEDATA = 0x4, - ARCH_EXTDATA = 0x6, - ARCH_SHARED_EXTDATA = 0x7, - ARCH_SYSTEM_SAVEDATA = 0x8, - ARCH_SDMC = 0x9, - ARCH_SDMC_WRITE_ONLY = 0xA, - ARCH_BOSS_EXTDATA = 0x12345678, - ARCH_CARD_SPIFS = 0x12345679, - ARCH_NAND_RW = 0x1234567D, - ARCH_NAND_RO = 0x1234567E, - ARCH_NAND_RO_WRITE_ACCESS = 0x1234567F, + ARCH_ROMFS = 0x3, ///< RomFS archive. + ARCH_SAVEDATA = 0x4, ///< Save data archive. + ARCH_EXTDATA = 0x6, ///< Ext data archive. + ARCH_SHARED_EXTDATA = 0x7, ///< Shared ext data archive. + ARCH_SYSTEM_SAVEDATA = 0x8, ///< System save data archive. + ARCH_SDMC = 0x9, ///< SDMC archive. + ARCH_SDMC_WRITE_ONLY = 0xA, ///< Write-only SDMC archive. + ARCH_BOSS_EXTDATA = 0x12345678, ///< BOSS ext data archive. + ARCH_CARD_SPIFS = 0x12345679, ///< Card SPIFS archive. + ARCH_NAND_RW = 0x1234567D, ///< Read-write NAND archive. + ARCH_NAND_RO = 0x1234567E, ///< Read-only NAND archive. + ARCH_NAND_RO_WRITE_ACCESS = 0x1234567F, ///< Read-only write access NAND archive. } FS_archiveIds; -/// FS path +/// FS path. typedef struct { FS_pathType type; ///< FS path type. @@ -94,7 +73,7 @@ typedef struct const u8 *data; ///< Pointer to FS path data. } FS_path; -/// FS archive +/// FS archive. typedef struct { u32 id; ///< Archive ID. @@ -103,66 +82,261 @@ typedef struct Handle handleHigh; ///< Low word of handle. } FS_archive; -/// Directory entry +/// Directory entry. typedef struct { // 0x00 u16 name[0x106]; ///< UTF-16 encoded name // 0x20C - u8 shortName[0x09]; ///< 8.3 file name + u8 shortName[0x09]; ///< 8.3 File name // 0x215 u8 unknown1; ///< ??? // 0x216 - u8 shortExt[0x04]; ///< 8.3 file extension (set to spaces for directories) + u8 shortExt[0x04]; ///< 8.3 File extension (set to spaces for directories) // 0x21A u8 unknown2; ///< ??? // 0x21B u8 unknown3; ///< ??? // 0x21C - u8 isDirectory; ///< directory bit + u8 isDirectory; ///< Directory bit // 0x21D - u8 isHidden; ///< hidden bit + u8 isHidden; ///< Hidden bit // 0x21E - u8 isArchive; ///< archive bit + u8 isArchive; ///< Archive bit // 0x21F - u8 isReadOnly; ///< read-only bit + u8 isReadOnly; ///< Read-only bit // 0x220 - u64 fileSize; ///< file size + u64 fileSize; ///< File size } FS_dirent; +/// Initializes FS. Result fsInit(void); + +/// Exits FS. Result fsExit(void); + +/** + * @brief Gets the current FS session handle. + * @return The current FS session handle. + */ Handle *fsGetSessionHandle(void); -FS_path FS_makePath(FS_pathType type, const char *path); +/** + * Creates an FS_path instance. + * @param type Type of path. + * @param path Path to use. + * @return The created FS_path instance. + */ +FS_path FS_makePath(FS_pathType type, const char *path); +/** + * @brief Initializes FSUSER. + * @param handle FS:USER service handle to use. + */ Result FSUSER_Initialize(Handle handle); + +/** + * @brief Opens an archive. + * @param archive Archive to open. + */ Result FSUSER_OpenArchive(FS_archive* archive); + +/** + * @brief Opens a directory. + * @param out Pointer to output the directory handle to. + * @param archive Archive to open the directory from. + * @param dirLowPath Path of the directory. + */ Result FSUSER_OpenDirectory(Handle* out, FS_archive archive, FS_path dirLowPath); + +/** + * @brief Opens a file. + * @param out Pointer to output the file handle to. + * @param archive Archive to open the file from. + * @param fileLowPath Path of the file. + * @param openflags Open flags to use. + * @param attributes Attributes to use. + */ Result FSUSER_OpenFile(Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes); + +/** + * @brief Opens a file directly. + * @param out Pointer to output the file handle to. + * @param archive Archive to open the file from. + * @param fileLowPath Path of the file. + * @param openflags Open flags to use. + * @param attributes Attributes to use. + */ Result FSUSER_OpenFileDirectly(Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes); + +/** + * @brief Closes an archive. + * @param archive Archive to close. + */ Result FSUSER_CloseArchive(FS_archive* archive); + +/** + * @brief Creates a file. + * @param archive Archive to use. + * @param fileLowPath Path of the file. + * @param fileSize Initial size of the file. + */ Result FSUSER_CreateFile(FS_archive archive, FS_path fileLowPath, u32 fileSize); + +/** + * @brief Creates a directory. + * @param archive Archive to use. + * @param dirLowPath Path of the directory. + */ Result FSUSER_CreateDirectory(FS_archive archive, FS_path dirLowPath); + +/** + * @brief Deletes a file. + * @param archive Archive to use. + * @param fileLowPath Path of the file. + */ Result FSUSER_DeleteFile(FS_archive archive, FS_path fileLowPath); + +/** + * @brief Deletes a directory. + * @param archive Archive to use. + * @param dirLowPath Path of the directory. + */ Result FSUSER_DeleteDirectory(FS_archive archive, FS_path dirLowPath); + +/** + * @brief Deletes a directory recursively. + * @param archive Archive to use. + * @param dirLowPath Path of the directory. + */ Result FSUSER_DeleteDirectoryRecursively(FS_archive archive, FS_path dirLowPath); + +/** + * @brief Renames a file. + * @param srcArchive Source archive. + * @param srcFileLowPath Source file. + * @param destArchive Destination archive. + * @param destFileLowPath Destination file. + */ Result FSUSER_RenameFile(FS_archive srcArchive, FS_path srcFileLowPath, FS_archive destArchive, FS_path destFileLowPath); + +/** + * @brief Renames a directory. + * @param srcArchive Source archive. + * @param srcDirLowPath Source directory. + * @param destArchive Destination archive. + * @param destDirLowPath Destination directory. + */ Result FSUSER_RenameDirectory(FS_archive srcArchive, FS_path srcDirLowPath, FS_archive destArchive, FS_path destDirLowPath); + +/** + * @brief Gets the SDMC resource info. + * @param sectorSize Pointer to output the sector size to. + * @param sectorSize Pointer to output the cluster size to. + * @param sectorSize Pointer to output the total number of clusters to. + * @param sectorSize Pointer to output the number of free clusters to. + */ Result FSUSER_GetSdmcArchiveResource(u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters); + +/** + * @brief Gets the NAND resource info. + * @param sectorSize Pointer to output the sector size to. + * @param sectorSize Pointer to output the cluster size to. + * @param sectorSize Pointer to output the total number of clusters to. + * @param sectorSize Pointer to output the number of free clusters to. + */ Result FSUSER_GetNandArchiveResource(u32 *sectorSize, u32 *clusterSize, u32 *numClusters, u32 *freeClusters); + +/** + * @brief Gets whether an SD card is detected. + * @param detected Pointer to output the SD detection state to. + */ Result FSUSER_IsSdmcDetected(u8 *detected); + +/** + * @brief Gets whether the SD card is writable. + * @param detected Pointer to output the SD writable state to. + */ Result FSUSER_IsSdmcWritable(u8 *writable); + +/** + * @brief Gets the media type of the current application. + * @param mediatype Pointer to output the media type to. + */ Result FSUSER_GetMediaType(u8* mediatype); +/** + * @brief Closes a file handle. + * @param handle File handle to close. + */ Result FSFILE_Close(Handle handle); + +/** + * @brief Reads from a file. + * @param handle File handle to use. + * @param bytesRead Pointer to output the number of bytes read to. + * @param offset Offset to read from. + * @param buffer Buffer to read to. + * @param size Size of the buffer. + */ Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size); + +/** + * @brief Writes to a file. + * @param handle File handle to use. + * @param bytesRead 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 flushFlags Flush flags to apply after writing. + */ Result FSFILE_Write(Handle handle, u32 *bytesWritten, u64 offset, const void *buffer, u32 size, u32 flushFlags); + +/** + * @brief Gets a file's size. + * @param handle File handle to use. + * @param size Pointer to output the size to. + */ Result FSFILE_GetSize(Handle handle, u64 *size); + +/** + * @brief Sets a file's size. + * @param handle File handle to use. + * @param size Size to set. + */ Result FSFILE_SetSize(Handle handle, u64 size); + +/** + * @brief Gets a file's attributes. + * @param handle File handle to use. + * @param attributes Pointer to output the attributes to. + */ Result FSFILE_GetAttributes(Handle handle, u32 *attributes); + +/** + * @brief Sets a file's attributes. + * @param handle File handle to use. + * @param attributes Attributes to set. + */ Result FSFILE_SetAttributes(Handle handle, u32 attributes); + +/** + * @brief Flushes a file to disk. + * @param handle File handle to flush. + */ Result FSFILE_Flush(Handle handle); +/** + * @brief Reads one or more directory entries. + * @param handle Directory handle to read from. + * @param entriesRead Pointer to output the current number of read entries to. + * @param entrycount Number of entries to read. + * @param buffer Buffer to output directory entries to. + */ Result FSDIR_Read(Handle handle, u32 *entriesRead, u32 entrycount, FS_dirent *buffer); + +/** + * @brief Closes a directory handle. + * @param handle Directory handle to close. + */ Result FSDIR_Close(Handle handle); diff --git a/libctru/include/3ds/services/gsp.h b/libctru/include/3ds/services/gsp.h index 81cead1..c0c3787 100644 --- a/libctru/include/3ds/services/gsp.h +++ b/libctru/include/3ds/services/gsp.h @@ -6,96 +6,223 @@ #define GSP_REBASE_REG(r) ((r)-0x1EB00000) +/// Framebuffer information. typedef struct { - u32 active_framebuf; ///< "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; ///< "?" + 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. } GSP_FramebufferInfo; +/// Framebuffer format. typedef enum { - GSP_RGBA8_OES=0, ///< pixel_size = 4-bytes - GSP_BGR8_OES=1, ///< pixel_size = 3-bytes - GSP_RGB565_OES=2, ///< pixel_size = 2-bytes - GSP_RGB5_A1_OES=3, ///< pixel_size = 2-bytes - GSP_RGBA4_OES=4 ///< pixel_size = 2-bytes + 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) }GSP_FramebufferFormats; -/** - * See this for GSP_CaptureInfoEntry and GSP_CaptureInfo: http://3dbrew.org/wiki/GSPGPU:ImportDisplayCaptureInfo - */ +/// Capture info entry. typedef struct { - u32 *framebuf0_vaddr; - u32 *framebuf1_vaddr; - u32 format; - u32 framebuf_widthbytesize; + u32 *framebuf0_vaddr; ///< Left framebuffer. + u32 *framebuf1_vaddr; ///< Right framebuffer. + u32 format; ///< Framebuffer format. + u32 framebuf_widthbytesize; ///< Framebuffer pitch. } GSP_CaptureInfoEntry; +/// Capture info. typedef struct { - GSP_CaptureInfoEntry screencapture[2]; + GSP_CaptureInfoEntry screencapture[2]; ///< Capture info entries, one for each screen. } GSP_CaptureInfo; +/// GSP events. typedef enum { - GSPEVENT_PSC0 = 0, ///< memory fill completed - GSPEVENT_PSC1, - GSPEVENT_VBlank0, - GSPEVENT_VBlank1, - GSPEVENT_PPF, ///< display transfer finished - GSPEVENT_P3D, ///< command list processing finished - GSPEVENT_DMA, + GSPEVENT_PSC0 = 0, ///< Memory fill completed. + GSPEVENT_PSC1, ///< TODO + GSPEVENT_VBlank0, ///< TODO + GSPEVENT_VBlank1, ///< TODO + GSPEVENT_PPF, ///< Display transfer finished. + GSPEVENT_P3D, ///< Command list processing finished. + GSPEVENT_DMA, ///< TODO - GSPEVENT_MAX, ///< used to know how many events there are + GSPEVENT_MAX, ///< Used to know how many events there are. } GSP_Event; +/// LCD screens. typedef enum { - GSPLCD_TOP = BIT(0), - GSPLCD_BOTTOM = BIT(1), - GSPLCD_BOTH = GSPLCD_TOP | GSPLCD_BOTTOM, + GSPLCD_TOP = BIT(0), ///< Top screen. + GSPLCD_BOTTOM = BIT(1), ///< Bottom screen. + GSPLCD_BOTH = GSPLCD_TOP | GSPLCD_BOTTOM, ///< Both screens. }GSPLCD_Screens; +/// Initializes GSP. Result gspInit(void); + +/// Exits GSP. void gspExit(void); +/// Initializes GSPLCD. Result gspLcdInit(void); + +/// Exits GSPLCD. void gspLcdExit(void); +/** + * @brief Initializes the GSP event handler. + * @param gspEvent Event handle to use. + * @param gspSharedMem GSP shared memory. + * @param gspThreadId ID of the GSP thread. + */ Result gspInitEventHandler(Handle gspEvent, vu8* gspSharedMem, u8 gspThreadId); + +/// Exits the GSP event handler. void gspExitEventHandler(void); + +/** + * @brief Waits for a GSP event to occur. + * @param id ID of the event. + * @param Whether to discard the current event and wait for the next event. + */ void gspWaitForEvent(GSP_Event id, bool nextEvent); + +/// Waits for PSC0 #define gspWaitForPSC0() gspWaitForEvent(GSPEVENT_PSC0, false) + +/// Waits for PSC1 #define gspWaitForPSC1() gspWaitForEvent(GSPEVENT_PSC1, false) + +/// Waits for VBlank. #define gspWaitForVBlank() gspWaitForVBlank0() + +/// Waits for VBlank0. #define gspWaitForVBlank0() gspWaitForEvent(GSPEVENT_VBlank0, true) + +/// Waits for VBlank1. #define gspWaitForVBlank1() gspWaitForEvent(GSPEVENT_VBlank1, true) + +/// Waits for PPF. #define gspWaitForPPF() gspWaitForEvent(GSPEVENT_PPF, false) + +/// Waits for P3D. #define gspWaitForP3D() gspWaitForEvent(GSPEVENT_P3D, false) + +/// Waits for DMA. #define gspWaitForDMA() gspWaitForEvent(GSPEVENT_DMA, false) +/** + * @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(GSP_CaptureInfo *captureinfo); + +/// Sames the VRAM sys area. Result GSPGPU_SaveVramSysArea(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, GSP_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, 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, u32* data, u8 datasize, 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 Submits a GX command. + * @param sharedGspCmdBuf Command buffer to use. + * @param gxCommand GX command to execute. + */ Result GSPGPU_SubmitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8]); +/** + * @brief Powers off the backlight. + * @param screen Screen to power off. + */ Result GSPLCD_PowerOffBacklight(GSPLCD_Screens screen); + +/** + * @brief Powers on the backlight. + * @param screen Screen to power on. + */ Result GSPLCD_PowerOnBacklight(GSPLCD_Screens screen); diff --git a/libctru/include/3ds/services/hb.h b/libctru/include/3ds/services/hb.h index 00f6d67..db63fd4 100644 --- a/libctru/include/3ds/services/hb.h +++ b/libctru/include/3ds/services/hb.h @@ -6,23 +6,17 @@ // WARNING ! THIS FILE PROVIDES AN INTERFACE TO A NON-OFFICIAL SERVICE PROVIDED BY NINJHAX // BY USING COMMANDS FROM THIS SERVICE YOU WILL LIKELY MAKE YOUR APPLICATION INCOMPATIBLE WITH OTHER HOMEBREW LAUNCHING METHODS -// A GOOD WAY TO COPE WITH THIS IS TO CHECK THE OUTPUT OF initHb FOR ERRORS +// A GOOD WAY TO COPE WITH THIS IS TO CHECK THE OUTPUT OF hbInit FOR ERRORS #include <3ds/types.h> -/** - * @brief Initializes HB. - */ +/// Initializes HB. Result hbInit(); -/** - * @brief Exits HB. - */ +/// Exits HB. void hbExit(); -/** - * @brief Flushes/invalidates the entire data/instruction cache. - */ +/// Flushes/invalidates the entire data/instruction cache. Result HB_FlushInvalidateCache(void); /** diff --git a/libctru/include/3ds/services/hid.h b/libctru/include/3ds/services/hid.h index 1dbee7e..11e619c 100644 --- a/libctru/include/3ds/services/hid.h +++ b/libctru/include/3ds/services/hid.h @@ -6,105 +6,188 @@ //See also: http://3dbrew.org/wiki/HID_Services http://3dbrew.org/wiki/HID_Shared_Memory +/// Key values. typedef enum { - KEY_A = BIT(0), - KEY_B = BIT(1), - KEY_SELECT = BIT(2), - KEY_START = BIT(3), - KEY_DRIGHT = BIT(4), - KEY_DLEFT = BIT(5), - KEY_DUP = BIT(6), - KEY_DDOWN = BIT(7), - KEY_R = BIT(8), - KEY_L = BIT(9), - KEY_X = BIT(10), - KEY_Y = BIT(11), - KEY_ZL = BIT(14), ///< ZL (new 3DS only) - KEY_ZR = BIT(15), ///< ZR (new 3DS only) - KEY_TOUCH = BIT(20), ///< 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 + 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, - KEY_DOWN = KEY_DDOWN | KEY_CPAD_DOWN, - KEY_LEFT = KEY_DLEFT | KEY_CPAD_LEFT, - KEY_RIGHT = KEY_DRIGHT | KEY_CPAD_RIGHT, + 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 } PAD_KEY; +/// Touch position. typedef struct { - u16 px, py; + u16 px; ///< Touch X + u16 py; ///< Touch Y } touchPosition; +/// Circle Pad position. typedef struct { - s16 dx, dy; + s16 dx; ///< Pad X + s16 dy; ///< Pad Y } circlePosition; +/// Accelerometer vector. typedef struct { - s16 x; - s16 y; - s16 z; + 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 + 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_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 + HIDEVENT_MAX, ///< Used to know how many events there are. } HID_Event; -extern Handle hidMemHandle; -extern vu32* hidSharedMem; +extern Handle hidMemHandle; ///< HID shared memory handle. +extern vu32* hidSharedMem; ///< HID shared memory. +/// Initializes HID. Result hidInit(void); + +/// Exits HID. void hidExit(void); +/// Scans HID for input data. void hidScanInput(void); + +/** + * @brief Gets the currently held keys. + * Individual keys can be checked by ORing them with this value. + * @return Keys held. + */ u32 hidKeysHeld(void); + +/** + * @brief Gets keys that were just pressed. + * Individual keys can be checked by ORing them with this value. + * @return Keys down. + */ u32 hidKeysDown(void); + +/** + * @brief Gets keys that were just released. + * Individual keys can be checked by ORing them with this value. + * @return Keys up. + */ 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); -// libnds compatibility defines +/// 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. diff --git a/libctru/include/3ds/services/httpc.h b/libctru/include/3ds/services/httpc.h index 5530141..cd76e35 100644 --- a/libctru/include/3ds/services/httpc.h +++ b/libctru/include/3ds/services/httpc.h @@ -4,34 +4,78 @@ */ #pragma once +/// HTTP context. typedef struct { - Handle servhandle; - u32 httphandle; + Handle servhandle; ///< Service handle. + u32 httphandle; ///< HTTP handle. } httpcContext; -typedef enum{ - HTTPCREQSTAT_INPROGRESS_REQSENT = 0x5, - HTTPCREQSTAT_DLREADY = 0x7 +/// HTTP request status. +typedef enum { + HTTPCREQSTAT_INPROGRESS_REQSENT = 0x5, ///< Request in progress. + HTTPCREQSTAT_DLREADY = 0x7 ///< Download ready. } httpcReqStatus; +/// Result code returned when a download is pending. #define HTTPC_RESULTCODE_DOWNLOADPENDING 0xd840a02b +/// Initializes HTTPC. Result httpcInit(void); + +/// Exits HTTPC. void httpcExit(void); /** - * @brief Opens an HTTP context. + * @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, char* url, u32 use_defaultproxy); + +/** + * @brief Closes a HTTP context. + * @param context Context to close. + */ Result httpcCloseContext(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, char* name, char* value); + +/** + * @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 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, httpcReqStatus* 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. @@ -39,7 +83,16 @@ Result httpcGetDownloadSizeState(httpcContext *context, u32* downloadedsize, u32 * @param delay Delay to wait for the status code. Not used yet. */ Result httpcGetResponseStatusCode(httpcContext *context, u32* out, u64 delay); + +/** + * @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, char* name, char* value, u32 valuebuf_maxsize); + /** * @brief Downloads data from the HTTP context into a buffer. * The *entire* content must be downloaded before using httpcCloseContext(), otherwise httpcCloseContext() will hang. @@ -52,16 +105,98 @@ Result httpcDownloadData(httpcContext *context, u8* buffer, u32 size, u32 *downl //Using the below functions directly is not recommended, use the above functions. See also the http example. +/** + * @brief Initializes HTTPC. + * @param handle HTTPC service handle to use. + */ Result HTTPC_Initialize(Handle handle); + +/** + * @brief Initializes a HTTP connection session. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + */ Result HTTPC_InitializeConnectionSession(Handle handle, Handle contextHandle); + +/** + * @brief Creates a HTTP context. + * @param handle HTTPC service handle to use. + * @param url URL to connect to. + * @param contextHandle Pointer to output the created HTTP context handle to. + */ Result HTTPC_CreateContext(Handle handle, char* url, Handle* contextHandle); + +/** + * @brief Closes a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + */ Result HTTPC_CloseContext(Handle handle, Handle contextHandle); + +/** + * @brief Applies the default proxy to a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + */ Result HTTPC_SetProxyDefault(Handle handle, Handle contextHandle); + +/** + * @brief Adds a request header field to a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + * @param name Name of the field. + * @param value of the field. + */ Result HTTPC_AddRequestHeaderField(Handle handle, Handle contextHandle, char* name, char* value); + +/** + * @brief Begins a HTTP request. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + */ Result HTTPC_BeginRequest(Handle handle, Handle contextHandle); + +/** + * @brief Receives data from a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + * @param buffer Buffer to receive data to. + * @param size Size of the buffer. + */ Result HTTPC_ReceiveData(Handle handle, Handle contextHandle, u8* buffer, u32 size); + +/** + * @brief Gets the request state of a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + * @param out Pointer to output the request state to. + */ Result HTTPC_GetRequestState(Handle handle, Handle contextHandle, httpcReqStatus* out); + +/** + * @brief Gets the download size state of a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + * @param downloadedsize Pointer to output the downloaded size to. + * @param contentsize Pointer to output the total content size to. + */ Result HTTPC_GetDownloadSizeState(Handle handle, Handle contextHandle, u32* downloadedsize, u32* contentsize); + +/** + * @brief Gets a response header field from a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle 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 HTTPC_GetResponseHeader(Handle handle, Handle contextHandle, char* name, char* value, u32 valuebuf_maxsize); + +/** + * @brief Gets the status code of a HTTP context. + * @param handle HTTPC service handle to use. + * @param contextHandle HTTP context handle to use. + * @param out Pointer to output the status code to. + */ Result HTTPC_GetResponseStatusCode(Handle handle, Handle contextHandle, u32* out); diff --git a/libctru/include/3ds/services/ir.h b/libctru/include/3ds/services/ir.h index c711c6f..8e1beb1 100644 --- a/libctru/include/3ds/services/ir.h +++ b/libctru/include/3ds/services/ir.h @@ -11,11 +11,54 @@ * @param sharedmem_size Size of the shared memory block. */ Result IRU_Initialize(u32 *sharedmem_addr, u32 sharedmem_size); + +/// Shuts down IRU. Result IRU_Shutdown(void); + +/** + * @brief Gets the IRU service handle. + * @return The IRU service handle. + */ Handle IRU_GetServHandle(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 IRU_SendData(u8 *buf, u32 size, u32 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 write the bytes read to. + * @param wait Whether to wait for the data to be received. + */ Result IRU_RecvData(u8 *buf, u32 size, u8 flag, u32 *transfercount, u32 wait); + +/** + * @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 KED state. + * @param out Pointer to write the IR LED state to. + */ Result IRU_GetIRLEDRecvState(u32 *out); diff --git a/libctru/include/3ds/services/irrst.h b/libctru/include/3ds/services/irrst.h index c6c7351..5cfb3ba 100644 --- a/libctru/include/3ds/services/irrst.h +++ b/libctru/include/3ds/services/irrst.h @@ -1,23 +1,62 @@ +/** + * @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; +/// 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); -#define hidCstickRead irrstCstickRead // because why not +/// 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); diff --git a/libctru/include/3ds/services/mic.h b/libctru/include/3ds/services/mic.h index 7a7660a..317c058 100644 --- a/libctru/include/3ds/services/mic.h +++ b/libctru/include/3ds/services/mic.h @@ -17,11 +17,13 @@ */ Result MIC_Initialize(u32 *sharedmem, u32 sharedmem_size, u8 control, u8 recording, u8 unk0, u8 unk1, u8 unk2); -/** - * @brief Shuts down MIC. - */ +/// Shuts down MIC. Result MIC_Shutdown(void); +/** + * @brief Gets the current shared memory offset. + * @return The current shared memory offset. + */ u32 MIC_GetSharedMemOffsetValue(void); /** @@ -33,17 +35,62 @@ u32 MIC_GetSharedMemOffsetValue(void); */ u32 MIC_ReadAudioData(u8 *outbuf, u32 readsize, u32 waitforevent); -Result MIC_MapSharedMem(Handle handle, u32 size); -Result MIC_UnmapSharedMem(void); -Result MIC_cmd3_Initialize(u8 unk0, u8 unk1, u32 sharedmem_baseoffset, u32 sharedmem_endoffset, u8 unk2); -Result MIC_cmd5(void); -Result MIC_GetCNTBit15(u8 *out); -Result MIC_GetEventHandle(Handle *handle); /** - * See here: http://3dbrew.org/wiki/MIC_Services + * @brief Maps MIC's shared memory. + * @param handle Handle of the shared memory. + * @param size Size of the shared memory. + */ +Result MIC_MapSharedMem(Handle handle, u32 size); + +/// Unmaps MIC's shardd memory. +Result MIC_UnmapSharedMem(void); + +/** + * @brief Initializes MIC. + * @param unk0 Unknown. + * @param unk1 Unknown. + * @param sharedmem_baseoffset Base offset of shared memory. + * @param sharedmem_endoffset End offset of shared memory. + * @param unk2 Unknown. + */ +Result MIC_cmd3_Initialize(u8 unk0, u8 unk1, u32 sharedmem_baseoffset, u32 sharedmem_endoffset, u8 unk2); + +/// Unknown MIC command. +Result MIC_cmd5(void); + +/** + * @brief Gets CNT bit 15 from MIC. + * @param out Pointer to output the bit to. + */ +Result MIC_GetCNTBit15(u8 *out); + +/** + * @brief Gets the event handle signaled by MIC when data is ready. + * @param handle Pointer to output the event handle to. + */ +Result MIC_GetEventHandle(Handle *handle); + +/** + * Sets the control value. + * @param value Control value to set. */ Result MIC_SetControl(u8 value); + +/** + * Gets the control value. + * @param value Pointer to output the control value to. + */ Result MIC_GetControl(u8 *value); + +/** + * Sets whether the microphone is recording. + * @param value Whether the microphone is recording. + */ Result MIC_SetRecording(u8 value); + +/** + * Gets whether the microphone is recording. + * @param value Pointer to output whether the microphone is recording to. + */ Result MIC_IsRecoding(u8 *value); diff --git a/libctru/include/3ds/services/mvd.h b/libctru/include/3ds/services/mvd.h index 1906e65..5f001d4 100644 --- a/libctru/include/3ds/services/mvd.h +++ b/libctru/include/3ds/services/mvd.h @@ -6,52 +6,83 @@ //New3DS-only, see also: http://3dbrew.org/wiki/MVD_Services +/// Processing mode. typedef enum { - MVDMODE_COLORFORMATCONV, - MVDMODE_VIDEOPROCESSING + MVDMODE_COLORFORMATCONV, ///< Converting color formats. + MVDMODE_VIDEOPROCESSING ///< Processing video. } mvdstdMode; +/// Input format. typedef enum { - MVDTYPEIN_YUYV422 = 0x00010001, - MVDTYPEIN_H264 = 0x00020001 + MVDTYPEIN_YUYV422 = 0x00010001, ///< YUYV422 + MVDTYPEIN_H264 = 0x00020001 ///< H264 } mvdstdTypeInput; +/// Output format. typedef enum { - MVDTYPEOUT_RGB565 = 0x00040002 + MVDTYPEOUT_RGB565 = 0x00040002 ///< RGB565 } mvdstdTypeOutput; +/// Processing configuration. typedef struct { - mvdstdTypeInput input_type; - u32 unk_x04; - u32 unk_x08; - u32 inwidth, inheight; - u32 physaddr_colorconv_indata; - u32 unk_x18[0x28>>2]; - u32 flag_x40;//0x0 for colorconv, 0x1 for H.264 - u32 unk_x44; - u32 unk_x48; - u32 outheight0, outwidth0;//Only set for H.264. - u32 unk_x54; - mvdstdTypeOutput output_type; - u32 outwidth1, outheight1; - u32 physaddr_outdata0; - u32 physaddr_outdata1_colorconv; - u32 unk_x6c[0xb0>>2]; + mvdstdTypeInput input_type; ///< Input type. + u32 unk_x04; ///< Unknown. + u32 unk_x08; ///< Unknown. + u32 inwidth ///< Input width. + u32 inheight; ///< Input height. + u32 physaddr_colorconv_indata; ///< Physical address of color conversion input data. + u32 unk_x18[0x28>>2]; ///< Unknown. + u32 flag_x40; ///< Unknown. 0x0 for colorconv, 0x1 for H.264 + u32 unk_x44; ///< Unknown. + u32 unk_x48; ///< Unknown. + u32 outheight0; ///< First output width. Only set for H.264. + u32 outwidth0; ///< First output height. Only set for H.264. + u32 unk_x54; ///< Unknown. + mvdstdTypeOutput output_type; ///< Output type. + u32 outwidth1; ///< Second output width. + u32 outheight1; ///< Second output height. + u32 physaddr_outdata0; ///< Physical address of output data. + u32 physaddr_outdata1_colorconv; ///< Physical address of color conversion output data. + u32 unk_x6c[0xb0>>2]; ///< Unknown. } mvdstdConfig; +/** + * @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_colorconv Virtual address of the color conversion output data. + */ void mvdstdGenerateDefaultConfig(mvdstdConfig *config, u32 input_width, u32 input_height, u32 output_width, u32 output_height, u32 *vaddr_colorconv_indata, u32 *vaddr_outdata0, u32 *vaddr_outdata1_colorconv); /** - * @brief Initializes MVDSTD. - * Video processing / H.264 isn't supported currently. + * @brief Initializes MVDSTD. Video processing / H.264 currently isn't supported. * @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 data to process. Not used when type == MVDTYPE_COLORFORMATCONV. */ Result mvdstdInit(mvdstdMode mode, mvdstdTypeInput input_type, mvdstdTypeOutput output_type, u32 size); + +/// Shuts down MVDSTD. Result mvdstdShutdown(void); +/** + * @brief Sets the current configuration of MVDSTD. + * @param config Pointer to the configuration to set. + */ Result mvdstdSetConfig(mvdstdConfig *config); + +/** + * @brief Processes a frame. + * @param config Pointer to the configuration to use. + * @param h264_vaddr_inframe Input H264 frame. + * @param h264_inframesize Size of the input frame. + * @param h264_frameid ID of the input frame. + */ Result mvdstdProcessFrame(mvdstdConfig *config, u32 *h264_vaddr_inframe, u32 h264_inframesize, u32 h264_frameid); diff --git a/libctru/include/3ds/services/news.h b/libctru/include/3ds/services/news.h index 1381f59..68c11a5 100644 --- a/libctru/include/3ds/services/news.h +++ b/libctru/include/3ds/services/news.h @@ -4,14 +4,10 @@ */ #pragma once -/** - * @brief Initializes NEWS. - */ +/// Initializes NEWS. Result newsInit(void); -/** - * @brief Exits NEWS. - */ +/// Exits NEWS. Result newsExit(void); /** diff --git a/libctru/include/3ds/services/ns.h b/libctru/include/3ds/services/ns.h index 5423b59..de3c7f3 100644 --- a/libctru/include/3ds/services/ns.h +++ b/libctru/include/3ds/services/ns.h @@ -4,14 +4,10 @@ */ #pragma once -/** - * @brief Initializes NS. - */ +/// Initializes NS. Result nsInit(void); -/** - * @brief Exits NS. - */ +/// Exits NS. Result nsExit(void); /** diff --git a/libctru/include/3ds/services/pm.h b/libctru/include/3ds/services/pm.h index e5bb8e7..b8fd3c4 100644 --- a/libctru/include/3ds/services/pm.h +++ b/libctru/include/3ds/services/pm.h @@ -4,14 +4,10 @@ */ #pragma once -/** - * @brief Initializes PM. - */ +/// Initializes PM. Result pmInit(void); -/** - * @brief Exits PM. - */ +/// Exits PM. Result pmExit(void); /** @@ -33,7 +29,7 @@ Result PM_GetTitleExheaderFlags(u8 mediatype, u64 titleid, u8* out); /** * @brief Sets the current FIRM launch parameters. * @param size Size of the FIRM launch parameter buffer. - * @param in Buffer to retreive the launch parameters from. + * @param in Buffer to retrieve the launch parameters from. */ Result PM_SetFIRMLaunchParams(u32 size, u8* in); @@ -48,6 +44,6 @@ Result PM_GetFIRMLaunchParams(u32 size, u8* out); * @brief Sets the current FIRM launch parameters. * @param firm_titleid_low Low Title ID of the FIRM title to launch. * @param size Size of the FIRM launch parameter buffer. - * @param in Buffer to retreive the launch parameters from. + * @param in Buffer to retrieve the launch parameters from. */ Result PM_LaunchFIRMSetParams(u32 firm_titleid_low, u32 size, u8* in); diff --git a/libctru/include/3ds/services/ps.h b/libctru/include/3ds/services/ps.h index 582dd3d..4667d29 100644 --- a/libctru/include/3ds/services/ps.h +++ b/libctru/include/3ds/services/ps.h @@ -4,9 +4,7 @@ */ #pragma once -/** - * @brief PS AES algorithms. - */ +/// PS AES algorithms. typedef enum { ps_CBC_ENC, ///< CBC encoding. @@ -17,9 +15,7 @@ typedef enum ps_CCM_DEC, ///< CCM decoding. } ps_aes_algo; -/** - * @brief PS key slots. - */ +/// PS key slots. typedef enum { ps_KEYSLOT_0D, ///< Key slot 0x0D. @@ -34,14 +30,10 @@ typedef enum ps_KEYSLOT_39_NFC ///< Key slot 0x39. (NFC) } ps_aes_keytypes; -/** - * @brief Initializes PS. - */ +/// Initializes PS. Result psInit(void); -/** - * @brief Exits PS. - */ +/// Exits PS. Result psExit(void); /** diff --git a/libctru/include/3ds/services/ptm.h b/libctru/include/3ds/services/ptm.h index e830dff..17f3ea8 100644 --- a/libctru/include/3ds/services/ptm.h +++ b/libctru/include/3ds/services/ptm.h @@ -1,10 +1,46 @@ +/** + * @file ptm.h + * @brief PTM service. + */ #pragma once +/// Initializes PTM. Result ptmInit(void); + +/// Exits PTM. Result ptmExit(void); +/** + * @brief Gets the system's current shell state. + * @param servhandle Optional pointer to the handle to use. + * @param out Pointer to write the current shell state to. (0 = closed, 1 = open) + */ Result PTMU_GetShellState(Handle* servhandle, u8 *out); + +/** + * @brief Gets the system's current battery level. + * @param servhandle Optional pointer to the handle to use. + * @param out Pointer to write the current battery level to. (0-5) + */ Result PTMU_GetBatteryLevel(Handle* servhandle, u8 *out); + +/** + * @brief Gets the system's current battery charge state. + * @param servhandle Optional pointer to the handle to use. + * @param out Pointer to write the current battery charge state to. (0 = not charging, 1 = charging) + */ Result PTMU_GetBatteryChargeState(Handle* servhandle, u8 *out); + +/** + * @brief Gets the system's current pedometer state. + * @param servhandle Optional pointer to the handle to use. + * @param out Pointer to write the current pedometer state to. (0 = not counting, 1 = counting) + */ Result PTMU_GetPedometerState(Handle* servhandle, u8 *out); + +/** + * @brief Gets the pedometer's total step count. + * @param servhandle Optional pointer to the handle to use. + * @param steps Pointer to write the total step count to. + */ Result PTMU_GetTotalStepCount(Handle* servhandle, u32 *steps); diff --git a/libctru/include/3ds/services/qtm.h b/libctru/include/3ds/services/qtm.h index ab64b6c..c63c743 100644 --- a/libctru/include/3ds/services/qtm.h +++ b/libctru/include/3ds/services/qtm.h @@ -6,17 +6,13 @@ //See also: http://3dbrew.org/wiki/QTM_Services -/** - * @brief Head tracking coordinate pair. - */ +/// Head tracking coordinate pair. typedef struct { float x; ///< X coordinate. float y; ///< Y coordinate. } qtmHeadtrackingInfoCoord; -/** - * @brief Head tracking info. - */ +/// Head tracking info. typedef struct { u8 flags[5]; ///< Flags. u8 padding[3]; ///< Padding. @@ -25,14 +21,10 @@ typedef struct { u32 unk_x2c[5]; ///< Unknown. Not used by System_Settings. } qtmHeadtrackingInfo; -/** - * @brief Initializes QTM. - */ +/// Initializes QTM. Result qtmInit(void); -/** - * @brief Exits QTM. - */ +/// Exits QTM. void qtmExit(void); /** diff --git a/libctru/include/3ds/services/soc.h b/libctru/include/3ds/services/soc.h index 34a8e49..470cce8 100644 --- a/libctru/include/3ds/services/soc.h +++ b/libctru/include/3ds/services/soc.h @@ -20,6 +20,10 @@ Result SOC_Initialize(u32 *context_addr, u32 context_size); */ Result SOC_Shutdown(void); -/* this is supposed to be in unistd.h but newlib only puts it for cygwin */ +// this is supposed to be in unistd.h but newlib only puts it for cygwin +/** + * @brief Gets the system's host ID. + * @return The system's host ID. + */ long gethostid(void); diff --git a/libctru/include/3ds/services/y2r.h b/libctru/include/3ds/services/y2r.h index bbc859f..40b4616 100644 --- a/libctru/include/3ds/services/y2r.h +++ b/libctru/include/3ds/services/y2r.h @@ -346,6 +346,10 @@ Result Y2RU_IsDoneSendingYUYV(bool* is_done); */ Result Y2RU_IsDoneReceiving(bool* is_done); +/** + * @brief Sets currently unknown parameters. + * @param params Unknown parameters. + */ Result Y2RU_SetUnknownParams(const u16 params[16]); /** @@ -355,14 +359,10 @@ Result Y2RU_SetUnknownParams(const u16 params[16]); */ Result Y2RU_SetConversionParams(const Y2R_ConversionParams* params); -/** - * @brief Starts the conversion process - */ +/// Starts the conversion process Result Y2RU_StartConversion(void); -/** - * @brief Cancels the conversion - */ +/// Cancels the conversion Result Y2RU_StopConversion(void); /** @@ -372,10 +372,15 @@ Result Y2RU_StopConversion(void); */ Result Y2RU_IsBusyConversion(bool* is_busy); - -/* Seems to check whether y2r is ready to be used */ +/** + * @brief Checks whether y2r is ready to be used. + * @param ping Pointer to output y2r's status to. + */ Result Y2RU_PingProcess(u8* ping); +/// Initializes the y2r driver. Result Y2RU_DriverInitialize(void); + +/// Terminates the y2r driver. Result Y2RU_DriverFinalize(void); diff --git a/libctru/include/3ds/svc.h b/libctru/include/3ds/svc.h index fd91721..c5ab683 100644 --- a/libctru/include/3ds/svc.h +++ b/libctru/include/3ds/svc.h @@ -6,7 +6,6 @@ #include "types.h" - /// Pseudo handle for the current process #define CUR_PROCESS_HANDLE 0xFFFF8001 @@ -30,11 +29,11 @@ typedef enum { MEMOP_REGION_SYSTEM = 0x200, ///< SYSTEM memory region. MEMOP_REGION_BASE = 0x300, ///< BASE memory region. - MEMOP_OP_MASK = 0xFF, - MEMOP_REGION_MASK = 0xF00, + MEMOP_OP_MASK = 0xFF, ///< Operation bitmask. + MEMOP_REGION_MASK = 0xF00, ///< Region bitmask. MEMOP_LINEAR_FLAG = 0x10000, ///< Flag for linear memory operations - MEMOP_ALLOC_LINEAR = MEMOP_LINEAR_FLAG | MEMOP_ALLOC, ///< Allocates linear memory. + MEMOP_ALLOC_LINEAR = MEMOP_LINEAR_FLAG | MEMOP_ALLOC, ///< Allocates linear memory. } MemOp; /// The state of a memory block. @@ -283,7 +282,7 @@ static inline u32* getThreadStaticBuffers(void) * @param size The requested size for @ref MEMOP_ALLOC and @ref MEMOP_ALLOC_LINEAR. * @param op Operation flags. See @ref MemOp. * @param perm A combination of @ref MEMPERM_READ and @ref MEMPERM_WRITE. Using MEMPERM_EXECUTE will return an error. - * Value 0 is used when unmapping memory. + * Value 0 is used when unmapping memory. * * If a memory is mapped for two or more addresses, you have to use MEMOP_UNMAP before being able to MEMOP_FREE it. * MEMOP_MAP will fail if @p addr1 was already mapped to another address. @@ -557,7 +556,7 @@ Result svcGetThreadAffinityMask(u8* affinitymask, Handle thread, s32 processorco /** * @brief Sets a thread's affinity mask. * @param thread Handle of the thread. - * @param affinitymask Pointer to retreive the affinity masks from. + * @param affinitymask Pointer to retrieve the affinity masks from. * @param processorcount Number of processors. */ Result svcSetThreadAffinityMask(Handle thread, u8* affinitymask, s32 processorcount); @@ -777,7 +776,7 @@ Result svcDuplicateHandle(Handle* out, Handle original); /** * @brief Gets the system info. * @param[out] out Pointer to output the system info to. - * @param type Type of system info to retreive. + * @param type Type of system info to retrieve. * @param param Parameter clarifying the system info type. */ Result svcGetSystemInfo(s64* out, u32 type, s32 param); diff --git a/libctru/include/3ds/types.h b/libctru/include/3ds/types.h index d7754c0..a2bb20e 100644 --- a/libctru/include/3ds/types.h +++ b/libctru/include/3ds/types.h @@ -46,14 +46,15 @@ typedef void (*ThreadFunc)(void *); ///< Thread entrypoint function. /// 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. +/// Aligns a struct (and other types?) to m, making sure that the size of the struct is a multiple of m. #define ALIGN(m) __attribute__((aligned(m))) -/// packs a struct (and other types?) so it won't include padding bytes. +/// Packs a struct (and other types?) so it won't include padding bytes. #define PACKED __attribute__((packed)) -/// flags a function as deprecated. #ifndef LIBCTRU_NO_DEPRECATION +/// Flags a function as deprecated. #define DEPRECATED __attribute__ ((deprecated)) #else +/// Flags a function as deprecated. #define DEPRECATED #endif diff --git a/libctru/include/3ds/util/rbtree.h b/libctru/include/3ds/util/rbtree.h index 6e1cf34..08778b9 100644 --- a/libctru/include/3ds/util/rbtree.h +++ b/libctru/include/3ds/util/rbtree.h @@ -7,7 +7,7 @@ #include #include -/// brief Retreives an rbtree item. +/// Retrieves an rbtree item. #define rbtree_item(ptr, type, member) \ ((type*)(((char*)ptr) - offsetof(type, member)))