Compare commits

..

1083 Commits

Author SHA1 Message Date
Andrea Ciliberti
1b1762f872 Return sockaddr_in length from functions that have in/out addrlen
Previously the socket funtions did not write the sockaddr_in struct fully and instead always returned
the "internal" length, which did not account for the zeroed padding.
2025-01-20 20:42:21 +01:00
Andrea Ciliberti
04b9418dd9 Use macro expansion for maximum sockaddr storage length rather than hardcoded value 2025-01-20 20:42:21 +01:00
kynex7510
30dc65121d Init gpu interrupt queue header 2024-11-20 19:12:01 +01:00
Dave Murphy
8cbcce773b
fix error language, closes #552 (#553) 2024-11-03 20:31:53 +00:00
fincs
a88b5af7a8
libctru v2.4.0 2024-09-17 00:11:09 +02:00
TuxSH
8e55cdf05d Add full support for all QTM services.
This commit adds support for all service commands of all 4 QTM services
(`qtm:u`, `qtm:s`, `qtm:sp` (which are built on top of one another) and
`qtm:c` ("hardware check")), with precise documentation about each command's
behaviour and about I/O internals.

The existing `qtm:c` code in libctru had a lot of misconceptions; this commit is
a full rewrite with breaking changes.

In particular: QTM does *not* track the position of 4 points on the user's face.
Instead, it tracks the position of the user's eyes (but not the direction they are
looking at) and reports their coordinates in camera space and in world space.
The data is presented in a console/hardware-agnostic way to the user.

QTM is a service process responsible for:

- eye tracking (see above). Head tracking data is available even when "super-stable 3D"
  is disabled
- parallax barrier management through the TI TCA6416A I2C->Parallel expander.
  The parallax barrier hardware on N3DS requires that software (in this case, QTM process)
  alternates between writing the barrier's mask pattern & polarity followed by the bit-negation
  of that pattern on polarity continuously, at all times
- automatic barrier management by adjusting it with the results of eye-tracking ("super-stable 3D")
- automatic (and manual) IR LED emitter management so that eye-tracking can work even in the dark
- fowarding camera brightness information from cam:q. GSP uses this for auto-brightness
2024-09-15 21:53:43 +02:00
Nikki
5f06a037d7
Add MCUHWC_SetInfoLedPattern (#549) 2024-09-15 20:45:49 +02:00
Rambo6Glaz
cc5b884d7d
Fix NDMU_QueryStatus (#543) 2024-09-15 18:13:27 +02:00
TuxSH
c5ecf54d51 Fix cmdbuf->bool conversion
Affected code was previously reading 3 uninitialized bytes, making the
conversion return wrong results.
2024-09-07 19:41:47 +02:00
TuxSH
faf5162b60 Fix PTMSYSM_CheckNew3DS, closes #540 2024-03-13 19:24:54 +01:00
TuxSH
a6a6548348 Fix documentation of two functions in ac.h 2024-02-08 00:25:27 +01:00
Kayden Tran
0da8705527
Added ndspChnGetFormat (#538) 2024-01-29 12:04:08 +00:00
fincs
d0936b879b
shaderInstanceInit: properly initialize structure (fix #535) 2023-12-16 16:25:47 +01:00
Dave Murphy
c579a65655
don't pollute system headers with 3ds headers 2023-11-05 11:39:10 +00:00
Dave Murphy
bf4a24a4e7
Changelog for 2.3.0 2023-10-28 20:08:55 +01:00
Chris Feger
bd69c96b7d
Buffer console control sequences (#522) 2023-10-28 19:48:16 +01:00
Gleb Mazovetskiy
41e31d3921
Add CTR_ prefix to ALIGN,PACKED,DEPRECATED macros (#532)
Co-authored-by: fincs <fincs@devkitpro.org>
2023-10-11 21:57:13 +02:00
Tekito_256
687aaf6cfc
FSUSER_GetLegacyBannerData: Fix documentation typo (#526) 2023-10-11 21:29:38 +02:00
Dave Murphy
4de90c3436
remove extra __libc_fini_array 2023-09-25 18:17:34 +01:00
TuxSH
5b2a9f6136 ac: add SSID-related ac:i functions
ACI_LoadNetworkSetting and ACI_GetNetworkWirelessEssidSecuritySsid, plus acGetSessionHandle.
2023-09-16 21:22:37 +02:00
TuxSH
0f098853f2 Add isb and prevent CPU from postponing threadOnException memory writes 2023-09-15 23:15:58 +02:00
oreo639
a4634c0290 Add GPU_DOT3_RGBA texture combiner function 2023-08-12 16:52:12 +02:00
fincs
e9fa000e94
Implement dkA r60 threading syscalls (pthread, std::thread support) 2023-06-24 16:07:06 +02:00
DeltaF1
0cbae436c8
Fix typo in docs (#525)
s/bufger/buffer
2023-05-15 18:19:35 +01:00
Dave Murphy
a9a9d9ab69
libctru v2.2.2 2023-05-08 00:11:49 +01:00
Dave Murphy
6714c04806
adjust struct hostent for compatibility 2023-05-08 00:09:58 +01:00
oreo639
39a53c4fe5
archive_dev: Ensure path separator for local path (#524)
Fixes issue where fopen("test.txt","r") opens 3dstest.txt instead of test.txt.

Also correct misuse of strncat() as count applies to src not dest.

See:
8136d94657
806a4d34c5
2023-05-07 12:08:13 +01:00
Dave Murphy
8d90551306
add define for curl 2023-04-18 12:03:44 +01:00
Dave Murphy
032f3dad40
libctru v2.2.0 2023-04-03 21:39:43 +01:00
TuxSH
b18f04d887 apt: add deliver arg support to chainloader + minor fixes 2023-02-25 20:39:04 +00:00
fincs
98324d412f
libctru v2.1.2 2023-02-09 20:11:27 +01:00
TuxSH
cd78fb05cb Change arg types of svcCreateCodeSet and improve documentation
Since kernel doesn't directly access the LMA, but just does memory
management on them instead, they should be passed as u32 (uptr) instead
of void *.

Also change CodeSetInfo to CodeSetHeader to avoid confusion with
ExHeader types.
2023-02-08 18:17:59 +00:00
TuxSH
a30628058c Implement cdc:CHK service 2023-02-08 00:26:18 +00:00
TuxSH
cb9d682f65 Fix svcGetDmaState
Kernel and official app stubs are buggy, as they read 4 bytes when the
enum is only one byte (meaning 3 garbage bytes).
2023-02-06 17:44:12 +00:00
TuxSH
1de86ea38a Add mcuHwcGetSessionHandle 2023-01-31 17:11:02 +00:00
TuxSH
e253c2c005 errf: implement ERRF_SetUserString & clarify 2023-01-11 23:49:31 +00:00
TuxSH
08b76e2e17 apt: fix dirty homebrew chainload
Fix chainload method used when HM is not launched.

We now wait for custom PM to change our launch flag and ask us to
terminate. We previously had a few issues:
- a potential race condition where we exit before PM changes our
  runflags (not observed)
- a kernel deadlock between ExitProcess and TerminateProcess (observed,
  this is due to Nintendo's lack of barrier in many of their atomics
  code)
- debuggers reporting that we were terminated, instead of exiting
  gracefully (not desirable)
2023-01-09 23:58:32 +00:00
GaryOderNichts
da323fa50b ir: Add IRU_GetSend/RecvFinishedEvent 2022-12-06 12:45:49 +01:00
TurtleP
af5321c78e spaces to tabs 2022-09-25 18:39:09 +02:00
TurtleP
58719f32ac fix ndspGetMasterVol and ndspChnGetMix 2022-09-14 23:52:19 +02:00
TurtleP
ef806d5bd8
add various ndspChnGet* methods (#506) 2022-09-14 19:35:11 +02:00
TurtleP
e6fcbef36c
add various ndspGet* methods (#505) 2022-09-14 19:34:32 +02:00
Ian Chamberlain
b20ac22ab7
Use __tdata_align to align thread local storage (#504) 2022-09-14 19:26:23 +02:00
csnikki
59cf50c201 Include for size_t 2022-08-12 16:45:58 +02:00
ZeroSkill
607f1d1fb6
Fix FSPXI_CreateFile and FSPXI_WriteFile (#496) 2022-06-29 18:19:50 +02:00
Théo B
10cf9bb95a
Mark svcExitProcess as taking no arguments (#499) 2022-06-29 12:37:10 +01:00
Teodor Spæren
813d28ddc4 Implement clock_gettime syscall
This implements the syscalls for `clock_gettime` and `clock_getres`. We
support two clocks: CLOCK_REALTIME and CLOCK_MONOTONIC. I've opted to
use the existing `osGetTime()` code for the realtime clock, because it's
known to work.

For CLOCK_MONOTONIC I've used `svcGetSystemTick()` directly, as it has a
higher resolution. We can ignore the drift and so on, because it's
supposed to be just the number of ticks since last boot.
2022-06-27 20:50:39 +02:00
Théo B
82f821156a
Minor style consistency fix for svcExitProcess (#498) 2022-06-26 17:57:28 +01:00
TuxSH
59e0d7596f Fix PMAPP_TerminateTitle 2022-05-24 19:51:52 +01:00
fincs
d4e08aa2cc
libctru v2.1.1 2022-05-22 16:35:03 +02:00
Dave Murphy
b76a245b79
disable array bounds checking for __tls_start 2022-05-02 15:10:17 +01:00
TuxSH
11686876ac Make sure FPSCR is properly initialized
This is a potentially breaking change as the register was left with an unpredictable/unspecified value.

Config: default NaN mode enabled, flush-to-zero enabled, and round to nearest.
2022-04-12 22:22:56 +01:00
TuxSH
c36d9cc4a6 Provide gspGetSessionHandle and gspLcdGetSessionHandle 2022-04-11 22:55:53 +01:00
TuxSH
cf538b1fa8 Make sure all data is initialized in srv and errf
Prior to system version 11.0, the kernel filled the resulting handle with junk in case of failure, when calling svcConnectToPort, etc.

In some situations libctru could accidentally close valid handles.
2022-04-11 21:15:08 +01:00
Eli Clark
ebb5305188
Fix a typo (NEOPT_IP_INFO comment) (#492) 2022-02-17 09:14:26 +00:00
fincs
4815537048
Add changelog for v2.1.0 2022-01-28 23:46:47 +01:00
Dave Murphy
4d36c74be4 next release is 2.1.0 2022-01-26 22:45:17 +00:00
Michael Theall
8ad7b5a71a Fix huffman decode 2022-01-26 22:41:22 +00:00
Michael Theall
bb9c49b84d Add support for SGR 38 and 48
This supports the escape sequences used by fmtlib
2022-01-26 22:41:22 +00:00
oreo639
2564d708e6 Add 3dslink stdio redirection 2022-01-26 18:16:03 +00:00
Dave Murphy
c83c12357e rework syscalls for devkitARM r57 2022-01-26 18:11:25 +00:00
Pixel-Pop
982be53414 DSP_WriteProcessPipe: Fix documentation typo 2022-01-21 18:08:04 +01:00
LiquidFenrir
5f13628dac add DLC title content-info count and data accessors
Named specially to indicate they require amAppInit instead of amInit
2021-12-21 23:48:33 +01:00
fincs
6360f4bdb1
VRAM allocator enhancements, see details:
- Added proper handling for VRAM banks (A and B, 3 MiB each)
- Allocations no longer cross VRAM bank boundaries
- Added vramAllocAt, vramMemAlignAt
2021-08-26 23:42:34 +02:00
fincs
48967dc417
Use __3DS__ instead of _3DS 2021-08-07 19:13:15 +02:00
Aly Cerruti
1f4669fa4c
Support replacing files in rename for better compatibility with POSIX (#483) 2021-04-16 23:01:40 +02:00
fincs
2a9f86fcbc
Add return value to gspPresentBuffer 2021-04-02 19:22:20 +02:00
fincs
bf06f27a0e
Add gspIsPresentPending 2021-03-31 14:49:07 +02:00
oreo639
4e25fb1d6c Switch to github actions 2021-03-01 03:20:15 +01:00
oreo639
858ef9408c Generate tagfile for use with c3d documentation 2021-03-01 03:20:15 +01:00
oreo639
1fb16e21c2 Correct malformed documentation in enums.h 2021-03-01 03:20:15 +01:00
TuxSH
75b4d1f563
Add SDMMC speed info types, and more clock rates (#480) 2021-02-01 14:05:04 +00:00
TuxSH
4fdc40228a Add ptm:gets, ptm:sets and more ptm service commands 2021-01-12 00:35:24 +01:00
fincs
e996cef24d
libctru v2.0.1 2020-12-19 17:15:52 +01:00
TuxSH
dcf83900b9 gspgpu: fix const correctness issues 2020-12-19 15:48:32 +01:00
fincs
02f516111f
srvpm: Correct the previous sysver check fix 2020-12-08 23:16:29 +01:00
Juan Antonio Sauceda
3cefb61d91 osGetWifiStrength: Fix typo in os.h 2020-08-03 01:30:13 +02:00
Vicki Pfau
d085de370e
cfgu: Add CFG_SystemModel enum (#472) 2020-08-01 11:51:46 +01:00
fincs
4866df79a5
condvar: fix embarrassing typo that prevented it from actually working 2020-07-23 02:45:39 +02:00
fincs
958e0c74ea
Travis is such a dumpster fire 2020-07-16 16:38:47 +02:00
fincs
e70908afc7
Release v2.0.0 2020-07-16 16:12:40 +02:00
fincs
e7b0b82bf6
osGetSystemVersionData: avoid leaking cfgu service on failure 2020-07-16 16:12:12 +02:00
fincs
5872ad60be
errf: use CUR_PROCESS_HANDLE instead of hardcoded number 2020-07-16 16:11:27 +02:00
Nanquitas
c1c93b0880 LightEvent: remove magic numbers 2020-07-15 00:16:16 +02:00
Nanquitas
bc6c097dbb Add LightEvent_WaitTimeout 2020-07-15 00:16:16 +02:00
fincs
3874788e85
gsplcd: It's 2020 and we still have typos in IPC wrapper code 2020-07-14 00:28:40 +02:00
fincs
846b79e5a6
cfgu: Correct CFG_Get/SetConfigInfoBlk2/4/8 parameter type 2020-07-13 21:56:08 +02:00
fincs
bd9e559309
Add gfxScreenSwapBuffers, see details:
- Added the ability to duplicate the left eye image to the right eye
  (allows apps to skip rendering to the right eye framebuffer when
   the 3d slider is set to 0.0)
- Deprecated gfxConfigScreen
2020-07-07 13:06:28 +02:00
fincs
4a9c547d8b
Add CondVar implementation 2020-07-07 12:44:18 +02:00
TuxSH
ef6289f977 Add svcControlPerformanceCounter 2020-07-07 12:43:41 +02:00
TuxSH
1ba8d40069 Add/update DMA svcs 2020-07-06 13:22:18 +02:00
TuxSH
58b30bad06 Reorder svcs and replace some void* params, see details:
- New category: "device drivers" (svc 0x5x)
- Use u32 instead of void* when process handles are required
2020-07-06 13:22:18 +02:00
fincs
577fe60268
archive_dev: Reduce maximum simultaneous opened archives from 32 to 8 in order to conserve memory 2020-07-03 20:24:11 +02:00
fincs
75a7312e40
Add romfsMountFromTitle and refactor os-versionbin.c to use it 2020-07-03 20:20:26 +02:00
fincs
24dded1c79
Remove long-since obsolete hb:HB code 2020-07-03 18:09:14 +02:00
fincs
33a570b1c3
Refactor default heap allocation code, see details:
- Use reslimit svcs to retrieve free mem (suggested by @TuxSH) - this
  removes the hardcoded assumption that the process is in APPLICATION.
- The algorithm for calculating default app/linear heap sizes has been
  tweaked to ensure 32MB of linear heap are available for normal apps
  running on Old3DS consoles under appmemtype 0 (i.e. the default).
- Misc cleanup and error checking.
2020-07-03 18:07:20 +02:00
fincs
da529aed21
romfs_dev: Backport proper multimount system from libnx with some tweaks 2020-07-03 00:24:32 +02:00
fincs
1c7914e2f4
archive/romfs: Reduce TLS usage by sharing buffers + changed archive_rename to use a VLA 2020-07-03 00:24:32 +02:00
fincs
3e1d03aecd
Fix typo in osKernelConfig_s 2020-07-03 00:23:42 +02:00
fincs
83e1f97b5b
Remove superfluous casts in FS_Path usage 2020-07-02 16:34:37 +02:00
fincs
818931b51c
Remove unmaintained cppcheck files 2020-07-02 16:32:58 +02:00
fincs
976d284f3a
Use MemPerm enum instead of magic numbers in svcMapMemoryBlock calls 2020-07-02 00:13:55 +02:00
fincs
4e387679f7
Add structs for kernel/shared pages + related refactor, see details:
- Added osKernelConfig_s/osSharedConfig_s structs
- Added OS_KernelConfig/OS_SharedConfig macros for accessing the pages
- Replaced 0x1FF8nnnn hardcoded addresses with struct accesses
- Added osIsHeadsetConnected function
- Refactored and rewritten RTC time support with the correct algorithm
  (many thanks to @TuxSH for reverse engineering the PTM sysmodule):
  - Fully added and documented the osTimeRef_s structure
    - This replaces the previous internal datetime_t struct type
  - Added osGetTimeRef function:
    - This replaces the previous internal getSysTime function
    - Added missing barrier to the lock free reading algorithm
  - osGetTime rewritten to implement the drift-correction algorithm
    - **This introduces a dependency to __aeabi_ldivmod**
  - __libctru_gtod rewritten to reuse osGetTime
2020-07-01 21:02:22 +02:00
fincs
53cbfc231f
Replace magic numbers with defines for Arm11 userland memory regions; clean up and enhance osConvertVirtToPhys 2020-07-01 20:48:18 +02:00
fincs
dfbfc1564f
os.h: Move MemRegion to svc.h; move osGetMemRegionUsed to header; correct osGetMemRegionUsed/Free return type 2020-07-01 18:11:31 +02:00
fincs
64f29fa024
Fix osStrError (previously it was completely broken...) 2020-07-01 00:21:40 +02:00
fincs
41d0d615f5
ndm: Add NDM_ prefix to enum members in order to avoid name collisions 2020-07-01 00:20:42 +02:00
fincs
9a707b2269
Improve safety of usermode synchronization primitives, see details:
- Added data memory barriers where required to ensure intercore safety
- Changed LightLock to handle 0 during locking instead of silently failing
  (this means trivially initialized/zerofilled LightLocks are now supported)
2020-07-01 00:17:08 +02:00
fincs
19fd446ac5
Add and use svcArbitrateAddressNoTimeout (minor ABI optimization) 2020-06-30 18:45:03 +02:00
piepie62
9974ed1aa3 Add LightSemaphore_TryAcquire and fix Acquire 2020-06-24 00:03:13 +02:00
fincs
8662687a2a
ndsp: Refactor sleep/wakeup code for maintainability/accuracy reasons 2020-06-23 00:36:21 +02:00
fincs
03c41754e8
ndsp: Make wavebuf handling more robust (and fix glaring omissions...) 2020-06-22 22:47:53 +02:00
fincs
2ff08fbac8
synchronization.h: Add __dmb() intrinsic 2020-06-22 22:08:21 +02:00
fincs
b93e7f19bf
Refactor DSP<->APT interaction, see details:
- DSP wrapper is now in charge of handling sleep/awake/cancel events
  - Added DSP hook mechanism (similar to APT hook)
  - The DSP component now gets automatically unloaded/reloaded as needed
- NDSP now uses DSP hook instead of APT hook to manage lifetime
  - Moved sleep/wakeup component management logic into NDSP
- APT now calls into DSP wrapper in order to arbitrate access to the DSP
  - Launching libapplets no longer relinquishes DSP rights - this means
    music can now be played in the background during libapplet activity
2020-06-22 00:34:38 +02:00
Ezekiel Bethel
b559d93eda
fix return value of romfs_stat for non-existent files/directories (#466) 2020-06-18 10:58:39 +01:00
fincs
bfc6ea48fb
gfx: Avoid graphical glitches after deinitialization 2020-06-14 01:20:46 +02:00
fincs
bf55423903
gspgpu: Add gspHasGpuRight 2020-06-14 01:19:13 +02:00
fincs
5ac710a0a2
console: Adjust for wide mode 2020-06-13 22:49:52 +02:00
fincs
d521c99769
gfx: Add support for the top screen's 800px high resolution mode (!!!) 2020-06-13 22:48:36 +02:00
fincs
09d629aa85
gspPresentBuffer: stride is u32 2020-06-13 21:57:09 +02:00
fincs
6ef91576ae
Overhaul gspgpu/gfx code, see details:
- GSPGPU changes:
  - gspInit now properly initializes the event queue, GSP shared memory
    and first-time initialization - previously this was done in gfxInit.
  - Removed gspInitEventHandler/gspExitEventHandler in line with above.
  - Added gspPresentBuffer for pushing a framebuffer to the internal
    GSP swap queue (previously this was an internal function in gfx.c).
  - Added defines for screen IDs and screen dimensions.
  - Removed sharedGspCmdBuf param from gspSubmitGxCommand (now uses
    the correct GSP shared memory address automatically).
  - Removed gxCmdBuf global variable (no longer needed as per above).
  - Removed GSPGPU_REBASE_REG (leftover from early 3DS homebrew).
- GFX changes:
  - Documentation overhaul and code cleanup.
  - Simplified implementation using the enhanced GSPGPU service wrapper.
  - Top left/right framebuffers now form a single allocation instead of
    being split into two separate allocations.
  - Fixed LCD configuration mode when framebuffers are on VRAM.
  - Removed the ability to forcefully swap the screens: gspPresentBuffer
    is now always used (i.e. GSP shared mem). The 'immediate' parameter
    of gfxConfigScreen now does nothing, and gfxSwapBuffers/Gpu now do
    the same thing.
  - Removed gfx{TopLeft,TopRight,Bottom}Framebuffers global variables
    (please use gfxGetFramebuffer instead as originally intended...)
2020-06-13 20:08:37 +02:00
oreo639
26f5f7eb33 Fix travis 2020-06-13 12:32:24 +02:00
fincs
9c1c847388
Introduce syncArbitrateAddress/WithTimeout (replaces __sync_get_arbiter) 2020-06-12 20:40:47 +02:00
fincs
528f8feb0b
Add gspGetBytesPerPixel (replaces internal function)
Also fixes GSPGPU_FramebufferFormat's name
2020-06-12 19:24:15 +02:00
fincs
6c0f7ac99c
threadCreate: correct misleading parameter name 2020-06-12 14:31:42 +02:00
fincs
f49efc3cc7
Add support for userAppInit/userAppExit (backported from libnx) 2020-06-12 14:16:46 +02:00
fincs
8e3c9f9784
Minor internal cleanup 2020-06-12 14:15:18 +02:00
fincs
1442eef9e4
Update travis config again 2020-06-11 20:01:32 +02:00
fincs
ea57fb8821
apt: Revamp chainload handling, see details:
- Added aptClearChainloader (clears pending chainloads)
- Added aptSetChainloaderToSelf (reboots to self, i.e. "soft-reset")
- Internal refactoring
2020-06-11 16:28:57 +02:00
fincs
80fad02255
Add travis badge 2020-06-11 03:43:39 +02:00
fincs
08bff23736
Attempt to fix travis 2020-06-11 03:38:42 +02:00
fincs
5986713066
apt: Refactor sleep/home state handling to be more intuitive, see details:
- Added functions for checking APT state:
  - aptIsActive
  - aptShouldClose
  - aptShouldJumpToHome
  - aptCheckHomePressRejected (replaces aptIsHomePressed)
- Added functions for handling incoming requests:
  - aptHandleSleep
  - aptHandleJumpToHome
- Added aptJumpToHomeMenu (callable anytime) because why not
- aptMainLoop is now aptHandleSleep/JumpToHome + return !aptShouldClose
- APTHOOK_ONEXIT is now called during aptExit
- Internal refactoring
2020-06-11 03:02:24 +02:00
fincs
b48b5da211
apt: Add APT_LockTransition, use it in aptWaitForWakeUp 2020-06-10 21:46:48 +02:00
fincs
6ce690828c
apt: Remove aptLaunchLibraryApplet's return value/hidden aptMainLoop call 2020-06-10 20:14:01 +02:00
fincs
ac8656f8b2
apt: Implement screen capture for libapplet transitions (+ related cleanup) 2020-06-10 19:47:17 +02:00
fincs
7171a87d53
Miscellaneous APT fixes and cleanup, see details:
- APT parameter handling now follows official sw a bit more closely
  (with the APT thread acting as a filter which then relays the
   status to the main thread using a LightEvent)
- RUNFLAG_APTREINIT (hax 2.x) handling code has been simplified and
  made (hopefully) more robust
- Fixed sleep handling when the app is inactive (i.e. app is suspended)
- APT debug callback now guarded by an #ifdef (LIBCTRU_APT_DEBUG)
- Removed old Citra response cmdheader workaround
- Other miscellaneous fixes I probably forgot to talk about
2020-06-10 02:08:01 +02:00
fincs
59b8fd8283
apt: Simplify event thread exit handling code 2020-06-09 18:01:11 +02:00
fincs
36b618e3bb
ndspChnReset: Bump syncCount in order to force the DSP to reset the channel 2020-06-08 00:24:24 +02:00
fincs
beaebaaf26
Update readme (again) with clarification 2020-06-02 18:01:22 +02:00
fincs
34f690d9d0
Update documentation url 2020-06-02 17:31:47 +02:00
mtheall
80be51e93b
Fix decompress out-of-bounds access (#463) 2020-06-01 09:03:12 +01:00
Dave Murphy
8f06d03ca6 update Changelog and version for next release 2020-05-27 15:41:32 +01:00
Dave Murphy
26e4f20078 increase decompress buffer size
speeds up decompression when user hasn't increased file buffer
2020-05-27 15:41:32 +01:00
Michael Theall
59e12a1b5e Fix stat for romfs:/ 2020-05-27 13:02:35 +02:00
Glazed_Belmont
2e48185aed
Fix the typo for consoleClear() (#460)
Changed screan to screen
2020-05-26 01:48:11 +01:00
Dave Murphy
aefdcf203d implement lstat with stat
fat32 has no symlinks to follow or not follow
2020-05-25 01:37:34 +01:00
TuxSH
0053d8d076 Add ptm rtc time commands 2020-05-17 22:24:15 +02:00
TuxSH
e3be4b8678 Add sleep state FSM handling service commands 2020-05-17 17:45:52 +02:00
TuxSH
1bafb08f34 Add hidKeysDownRepeat 2020-05-14 22:25:16 +02:00
TuxSH
69483a473a Revamp mappableAlloc 2020-05-14 00:30:53 +02:00
TuxSH
c9326f6bce
hid: add hidWaitForAnyEvent, allow user to override irrst usage check (#454) 2020-05-13 23:09:55 +02:00
Dave Murphy
e86e906895 next version is 1.8.0 2020-05-10 00:20:46 +01:00
Dave Murphy
48f330e56a add changelog entry for 1.8.0 2020-05-09 23:49:36 +01:00
Dave Murphy
ed59061172 add changelog entry for 1.7.0 2020-05-09 23:47:43 +01:00
TuxSH
9d27eb80de APT workaround when Home Menu is not launched, etc. 2020-05-10 00:06:50 +02:00
TuxSH
8d64007d70
Weaken more init/env functions (#451) 2020-05-09 18:22:51 +01:00
TuxSH
65ff0a1fcc Change allocateHeaps logic to properly handle appmemtype 5 2020-05-09 17:41:26 +02:00
fincs
1389fcdfcd
gdbhio: Avoid using reserved st_* identifiers for custom types 2020-05-08 03:29:05 +02:00
fincs
b03b64dd09
Add MEMPERM_READWRITE and MEMPERM_READEXECUTE 2020-05-08 03:16:30 +02:00
Chris Feger
750bceebf2
Add FSPXI interfaces (#446) 2020-05-08 02:20:48 +02:00
TuxSH
b161b7e578 Add GSPGPU_ResetGpuCore 2020-05-07 00:14:02 +02:00
TuxSH
51c0bdfc90 Add gpu hw init on (0x2A07) 2020-05-07 00:14:02 +02:00
TuxSH
6f34257b57 Make initSystem and __ctru_exit weak. Use asm macros 2020-05-06 21:50:20 +02:00
fincs
92ddd9e9b3
gfxWriteFramebufferInfo: use correct atomic update code 2020-05-04 21:17:21 +02:00
fincs
98664af53c
Clean up and optimize LightLock_Lock 2020-05-04 18:34:13 +02:00
TuxSH
fddc517a6b Fix srv/srvpm sysver checks:
- Kernel major version is 3 on SAFE_FIRM
- osGetFirmVersion() is not always equal to osGetKernelVersion()
2020-05-02 14:19:48 +02:00
piepie62
1ca796b3a3 Add invalid glyph index protection 2020-04-24 12:36:23 +02:00
Chris Feger
175dd62a90
Add archive STDIO device driver (#443) 2020-04-15 23:06:36 +01:00
zhupengfei
87734ae8d9 cam: Fix CAMU_GetLatestVsyncTiming
The previous implementation was wrong and result in a guaranteed prefetch abort
2020-04-16 00:05:25 +02:00
Lioncash
7956f6ba24 services/mvd: Remove redundant conditional in mvdstdRenderVideoFrame()
This condition is already checked further up in the function.
2020-04-15 09:13:18 +01:00
Lioncash
0e4d8fbd05 servicers/fs: Remove redundant conditional in FSUSER_OpenArchive()
This is already checked against at the beginning of the function.
2020-04-15 09:13:18 +01:00
Patrik Rak
6bca5af849
Make the FIONBIO ioctl actually work. (#441)
The fcntl needs the original `sockfd`, not the remapped one.
2020-04-15 09:09:17 +01:00
Patrik Rak
8566366b02 Fix dspInit() error handling in ndspInit().
The early return after dspInit() failure obviously keeps the refcount increased and the component loaded. This change properly unwinds all state changes.
2019-10-04 14:36:06 +02:00
LiquidFenrir
8acc1871bc Add AC commands that allow forcing a wifi connection (#438) 2019-09-21 02:49:41 +02:00
fincs
751dd3b42d Release 1.6.0 2019-06-28 17:21:14 +02:00
TuxSH
ed7674626e Implement Luma3DS gdb hio (#433) 2019-06-23 18:06:47 +01:00
Dave Murphy
754c334c29
use temp var for misaligned struct member (#437) 2019-06-06 00:08:49 +01:00
WinterMute
e842cfd011 print string when it's not null 2019-06-05 15:30:06 +01:00
Kartik
188d175579 Fix select() 2019-05-16 18:14:54 +02:00
Chris Feger
309c3f1d7b Fix a possible null pointer issue (#434) 2019-05-14 11:03:24 +01:00
Oreo639
d3ea737071 Add miiSelector configuration functions (#429) 2019-05-04 01:40:00 +02:00
Oreo639
c550a22259 Fix macro PACKED being displayed as variable name 2019-05-04 01:38:29 +02:00
Oreo639
67933816ba Improve travis script 2019-04-30 13:56:50 +02:00
Oreo639
59b71196ac Fix blocking and add aptIsHomePressed 2019-04-25 02:52:00 +02:00
Alex Taber
f919af3182 Rename home_allowed to aptHomeAllowed 2019-04-25 02:52:00 +02:00
LiquidFenrir
9b4ac1118d Allow blocking HOME button
Signed-off-by: Alex Taber <alexftaber@gmail.com>
2019-04-25 02:52:00 +02:00
hax0kartik
d0b6343342 Do not include 3ds.h within ctrulib headers 2019-04-01 17:38:14 +02:00
hax0kartik
d4036d97ef Add Mii struct 2019-04-01 17:38:14 +02:00
Oreo639
fd1006b682 Update travis to build Doxygen. 2019-03-28 12:38:40 +01:00
Chris Feger
2750c4a70b Rework font API to support loading fonts other than the shared system font (#416) 2019-03-28 02:32:07 +01:00
TuxSH
09688ea6fc PM services overhaul 2019-03-28 01:04:02 +01:00
TuxSH
8ffc9461ea LOADER_RegisterProgram: use FS_ProgramInfo 2019-03-28 00:44:43 +01:00
TuxSH
0ed1f2beb2 IPC_Desc_CurProcessHandle => IPC_Desc_CurProcessId 2019-03-28 00:44:32 +01:00
TuxSH
7663a701c0 Add undocumented N3DS PM launch flags 2019-03-24 23:26:43 +01:00
TuxSH
0536cc5493 Loader bugfixes 2019-03-22 14:26:51 +01:00
fincs
5fd623da44 Fix typo in svc.s 2019-03-21 23:06:12 +01:00
Dave Murphy
da0af223a2
Update URL for devkitPro installers 2019-03-17 23:38:03 +00:00
TuxSH
ffba52bcd0 Add PM launch flags 2019-03-17 20:46:04 +01:00
TuxSH
79ee260c15 Implement PxiPM 2019-03-11 21:06:34 +01:00
TuxSH
dacacfa403 Implement fs:REG 2019-03-11 21:06:34 +01:00
fincs
550793b262 Minor text fixes 2019-03-10 21:14:25 +01:00
Slattz
67f10f0ba9 Fix frdGetSessionHandle declaration 2019-02-12 12:28:10 +01:00
Dave Murphy
79a77cd862 add SO_BROADCAST 2019-01-18 15:23:53 +00:00
fincs
b9b4d486a3 Fix GPUCMD_Add with more than 256 words (thanks to iMackshun for testing) 2019-01-18 00:38:47 +01:00
fincs
5f3b369a81 Release 1.5.1 2019-01-02 00:36:07 +01:00
Joel
a482822fb8 Fix a few FRD commands and minor consistency changes (#411) 2019-01-02 00:35:12 +01:00
fincs
14fdf2dee4 Update doxygen binary url for Travis 2019-01-02 00:26:28 +01:00
fincs
56d3b0b76e Add gas-related GPU definitions 2019-01-02 00:18:47 +01:00
Sean Purcell
64bdf022a8 Fix missing include <3ds/types.h> (#414) 2018-10-23 16:04:00 +01:00
Lázaro Vieira
3810a5586b FRD update (#409)
Fix Mii struct padding + some changes for consistency
Documentation update
2018-08-09 15:08:41 +02:00
Kartik
c579e745a8 Add more friend functions (#408) 2018-08-05 15:56:26 +02:00
Pirater12
2c1f84406e UTF16-to UTF8 Translation 2018-07-21 17:18:09 +01:00
Joel16
18267ef6fb Initial bring up of the Friend Service 2018-07-21 17:18:09 +01:00
Dave Murphy
d1ca5c4ea6 implement nanosleep for devkitARM r49
(cherry picked from commit fba44c189e568df13573a9e119e63dbd718424c6)
2018-06-13 14:22:50 +01:00
Dave Murphy
510504a853
Use Docker for builds (#405) 2018-05-22 01:35:54 +01:00
Dave Murphy
fcf9ca767b allow parallel build 2018-05-13 00:23:25 +01:00
fincs
5450b2bee5 Release 1.5.0 2018-05-12 21:21:02 +02:00
Michael Theall
cc22550296 Add decompressHeader 2018-05-12 13:56:29 +02:00
Michael Theall
1165b4cb8b Add decompression routines 2018-05-12 13:56:29 +02:00
Dave Murphy
caacf37594 add DESTDIR for packaging 2018-05-11 02:50:58 +01:00
Dave Murphy
f214b2e535 fix for gcc 8.1.0 2018-05-11 02:49:39 +01:00
fincs
74b8aa00cd Const correctness in osTickCounterRead 2018-03-17 18:11:36 +01:00
Sono
c1cee4a115 Added and adjusted clock speed constants 2018-03-17 18:09:14 +01:00
Pirater12
555f31b35e Add more PM:App functions 2018-03-10 17:04:38 +01:00
Joel16
8840ebf813 Add ACU_Proxy* functions as welll as error code functions 2018-03-10 17:03:25 +01:00
Pirater12
a087e33414 Add NS_RebootSystem 2018-03-09 12:22:38 +01:00
fincs
a4210af6c2 Update devkitARMupdate.pl URL for Travis CI 2018-03-02 23:55:31 +01:00
Joel
6dcbee7f4c Add more CFGI SecureInfo functions (#393) 2018-02-16 01:48:31 +01:00
Kartik
29418f4d3d Add NS_TerminateTitle() (#390) 2018-01-22 02:08:36 +01:00
Kartik
2158f71eb2 Add timeout in NS_TerminateProcessTID() (#389) 2018-01-15 12:45:05 +01:00
TuxSH
c598c445cd Implement per-thread non-blocking behavior for srvGetServiceHandle...
implement srvWaitForPortRegistered and srvIsPortRegistered as well.
2018-01-14 21:18:01 +01:00
Joel16
abf8064771 Add missing enums 2018-01-13 18:47:25 +01:00
Joel
52be537b48 Add more ndm:u functions. (#386) 2018-01-12 13:34:56 +01:00
TuxSH
fdf31f7556 Multiple srv:pm bugfixes 2018-01-07 01:35:19 +01:00
Lioncash
4ceebb8b44 gfx: Mark gfxSetFramebufferInfo and gfxWriteFramebufferInfo as static 2018-01-03 17:10:48 +01:00
Joel
3bbd2dca16 MCU service consistency and a couple more functions (#381)
Also added MCUHWC_GetFwVerHigh and MCUHWC_GetFwVerLow
2018-01-01 16:42:46 +01:00
Lioncash
c941b0d2d2 services: Add missing void keyword in parameter lists to signify no arguments 2018-01-01 16:41:45 +01:00
Lioncash
3a1a501867 shaderProgram: correct array index in shaderProgramSetGshInputPermutation() 2017-12-28 21:53:28 +01:00
Joel
6f64dee330 Add a few more ACU functions (#379) 2017-12-01 17:58:08 +01:00
Kartik
65673fd3f3 Added more mcuHwc functions. (#378) 2017-11-16 00:18:07 +01:00
Kartik
8e2d82ae9a Fix page being not built by doxygen 2017-11-16 00:13:41 +01:00
fincs
fc67757066 fontCalcGlyphPos: Correct vertical texture coordinates 2017-11-07 23:06:20 +01:00
Joel
632f9866e6 Add a few more CFGI functions (#380)
* CFGI_SecureInfoGetSerialNumber
* CFGU_IsNFCSupported (IsFangateSupported)
* CFGI_GetLocalFriendCodeSeed
* CFGI_GetLocalFriendCodeSeedData
2017-10-28 12:12:16 +03:00
fincs
53c42003f3 Release 1.4.0 2017-09-23 18:12:36 +02:00
fincs
213f586c7d Update doxygen to 1.8.11 2017-09-23 18:10:46 +02:00
fincs
7c348aa3ad Add missing examples to 3ds.h 2017-09-23 18:10:46 +02:00
Joel
25123ba057 Add more CFGI functions (#376) 2017-09-23 18:07:50 +02:00
Joel
04bde1de19 More AM_Delete functions (#375) 2017-09-23 17:42:37 +02:00
Kartik
d6a628b7d3 Add mcu::HWC service (#373) 2017-09-23 16:03:37 +02:00
phijor
aaa92f619c Add Mii selector applet (appletEd) (#372) 2017-09-23 15:48:08 +02:00
Joel
fa6eb5db9e More GSPLCD and GSPGPU functions. (#371) 2017-09-23 01:59:26 +02:00
LIT
8196e383c3 Typo. 2017-09-13 14:37:17 +01:00
fincs
0d950af680 Remove deprecated GPUCMD functions 2017-08-29 00:39:56 +02:00
fincs
967b0223ad Correct error in GPU_LIGHTPERM (reported by @wwylele) 2017-08-27 12:25:32 +02:00
TuxSH
010dde085b Add Loader service commands (#370) 2017-08-21 15:55:54 +01:00
TuxSH
f132a7a2a9 Implement light semaphores (#369) 2017-08-01 14:35:45 +01:00
TuxSH
4dafd78e26 Fix const-correctness (#368)
make svcWaitSynchronizationN and svcReplyAndReceive const correct
2017-07-31 14:33:20 +01:00
TuxSH
6a6dc3be4a Add and use enum ResourceLimitType (#367) 2017-07-31 14:21:03 +01:00
TuxSH
532fbef44f Fix srv:pm handling for pre-7.x system versions (#365) 2017-07-31 14:12:51 +01:00
TuxSH
e1ddc74c1c Add exheader.h (#366) 2017-07-31 14:12:16 +01:00
Joel
f05c56435d Implement GSPLCD_SetBrightness and GSPLCD_SetBrightnessRaw (#363) 2017-07-29 22:55:52 +01:00
Dave Murphy
57152061b0 remove devkitARM version. Add link to installer 2017-07-28 01:18:03 +01:00
Dave Murphy
46b29af821 fix version title 2017-07-13 21:12:22 +01:00
Dave Murphy
5843fdcc0d release 1.3.0 2017-07-13 21:08:10 +01:00
Dave Murphy
3cea84f315 fix whitespace 2017-07-13 20:59:56 +01:00
Michael Theall
5d245e5cc8 Fix CUP (cursor position) escape code 2017-07-12 23:29:49 -05:00
HiddenRambler
31ca6f5c53 add nfcStartOtherTagScanning Old3DS compatibility. 2017-07-13 18:11:49 +01:00
TuxSH
bc87466400 srv: code bugfixes:
- Fix srvPublishToSubscriber documentation
- Fix handling of service/named port names of length 8
- Fix srvRegisterPort
2017-07-13 16:12:09 +01:00
Michael Theall
41c1fee88e Fix warning when compiling with C89/90 2017-07-10 23:43:10 -05:00
Kartik
8d177742ae Add PTMU_GetAdapterState (#361) 2017-07-10 14:43:24 +02:00
TuxSH
49f99a0650 Implement privileged resource limit SVCs 2017-07-07 13:08:53 +01:00
TuxSH
4d8c2ea9f5 Implement svcSetGpuProt and svcSetWifiEnabled 2017-07-07 13:08:15 +01:00
Thomas Schneider
325dbf02b7 include svc.h for ResetType 2017-07-04 14:02:08 +01:00
fincs
0475b59e12 nfcInit(): wait for NFC sysmodule to initialize 2017-06-29 18:42:08 +02:00
fincs
be79735c31 Update documentation autobuild token, yet again 2017-06-26 17:29:32 +02:00
Yuri Kunde Schlesner
eb062ce0a9 Add svcCreateSessionToPort 2017-06-26 15:51:03 +01:00
Yuri Kunde Schlesner
1e6df47adb Add svcCreateSession 2017-06-26 15:51:03 +01:00
Kartik
ff559d2a90 Fix compilation issue caused due to errorConf. (#355) 2017-05-21 22:07:33 +02:00
fincs
94aabe35f3 Rename debugDevice_3DMOO to debugDevice_SVC 2017-05-14 11:49:21 +02:00
TuxSH
8778d8c5d6 Add support for user-specified exception handlers 2017-05-14 11:41:24 +02:00
Dave Murphy
e43d368fbc PATH_MAX is max length of fixedpath string 2017-05-04 21:33:53 +01:00
fincs
1ed97e8ba2 Implement RUNFLAG_APTCHAINLOAD 2017-04-14 22:01:13 +02:00
fincs
3f7a4d227d Add GPU_FOGMODE, GPU_GASMODE and GPU_GASLUTINPUT 2017-04-08 12:39:37 +02:00
Dave Murphy
e64d859d36 separate release & debug dependencies 2017-04-06 16:23:01 +01:00
fincs
708ece10df Fix makefile dependency rule inclusion 2017-04-05 19:26:27 +02:00
Kartik
8ada484dad Implement HTTPC:AddPostDataBinary (#352) 2017-04-05 15:49:05 +02:00
Kartik
422c3c3272 Implement error applet (#343) 2017-04-04 17:49:37 +02:00
Dave Murphy
82049e7fc2 use debug defines 2017-04-03 19:24:34 +01:00
Dave Murphy
28827803ce build debug and release versions 2017-04-03 16:24:09 +01:00
Dave Murphy
4f98439f86 Merge pull request #350 from TuxSH/patch-cfi
Add call frame information for SVC wrapper, fix build issue in uds.c
2017-04-03 11:16:52 +01:00
Joel
b3742567d4 Implement GSPLCD::GetBrightness (#351)
* Implement GSPLCD::GetBrightness

* Split input and output params
2017-04-02 22:55:37 -05:00
TuxSH
eb681db5af Fix -Werror=maybe-uninitialized in uds.c...
...when building with -Os/-Og
2017-04-02 16:39:54 +02:00
TuxSH
cdababc38d Add call frame information for SVC wrappers 2017-04-02 16:17:10 +02:00
fincs
f4232926c3 Add GX command queue system for batching GX commands 2017-03-26 19:48:34 +02:00
fincs
d9933cb2db Prevent race condition in gfxWriteFramebufferInfo with atomic instructions 2017-03-26 19:39:01 +02:00
fincs
d8374c2883 Refactor gpu.h/gpu.c, see details:
- Added GPUCMD_Split for splitting the command buffer
  (and beginning a new command list within the same buffer)
- Deprecated GPUCMD_Finalize/Run/FlushAndRun:
  - Use GPUCMD_Split + GX_ProcessCommandList instead
- Turned GPUCMD_SetBuffer/SetBufferOffset/GetBuffer into inlines
- GPUCMD_Add: svcBreak on cmdbuf overflow
2017-03-26 19:37:25 +02:00
fincs
929468371a Increase priority of GSP event thread 2017-03-26 19:32:13 +02:00
fincs
c44da0636a Correct GPU_PROCTEX_LUTID definition 2017-03-15 16:40:06 +01:00
TuxSH
10cb9babc9 Fix debug-related definitions in svc.h 2017-03-14 14:07:43 +00:00
TuxSH
064f9fdf9e Implement svc 0x04, 0x06, 0x53 2017-03-14 14:07:43 +00:00
TuxSH
636dfb2f1d Fix typo in definition of struct FpuRegisters 2017-03-06 19:57:04 +01:00
TuxSH
65171be4d8 Fix ThreadContext definition
Its correct size is 0xcc bytes, not the 8-byte aligned 0xd0
2017-03-06 19:57:04 +01:00
TuxSH
e5fc424414 Amend latest PR/commit 2017-03-05 16:48:09 +01:00
TuxSH
cc2928427b Fix svc(Un)mapProcessMemory typo/misconception 2017-03-04 21:55:24 +01:00
FenrirWolf
ec0b9d8033 Return zero when writing zero bytes (#344) 2017-03-02 01:18:58 -06:00
TuxSH
eeacb2faa9 ERRF_ExceptionInfo: fix typo 2017-03-01 20:45:33 +00:00
Fenrir
da97a8802c Add threadDetach function 2017-03-01 20:45:12 +00:00
TuxSH
c6c994ca60 Make ERRF_ExceptionInfo attributes more explicit 2017-03-01 11:33:51 +00:00
TuxSH
2edbc6fe2e Fix typo in errf.h 2017-03-01 10:35:05 +00:00
TuxSH
492fffd445 Fix DebuggerBreakExceptionEvent definition 2017-02-23 21:29:30 +01:00
Dave Murphy
c195a19683 update changelog 2017-02-23 11:49:48 +00:00
Dave Murphy
9b99862696 new version number for next release 2017-02-20 06:47:22 +00:00
Dave Murphy
b3ed60d123 default to "unsafe" file write. Unable to replicate failure conditions. 2017-02-20 06:41:42 +00:00
fincs
112163e580 Clarify threadFree usage in documentation 2017-02-17 16:08:16 +01:00
yellows8
cffb347407 Added support for the NFC functionality implemented with system-version 10.0.0-X. 2017-02-16 20:27:37 -05:00
fincs
991eb2357b Add TickCounter for measuring performance 2017-02-16 14:35:06 +01:00
fincs
97d01a7325 GPUCMD_Add: allow NULL for adding zerofilled parameter data 2017-02-16 13:48:40 +01:00
fincs
093b3441ea Added (linear/vram/mappable)GetSize for retrieving allocated buffer size 2017-02-16 13:44:19 +01:00
TuxSH
95c4a3e6ef Fix ERRF_ExceptionData definition
This "padding" field is not needed (the struct is used within an union when sent to ErrDisp), and is also undesirable as the kernel push an instance of `ERRF_ExceptionData` (which is a struct of size 0x5C, and not 0x60) on the user stack under certain conditions.
2017-02-16 13:39:20 +01:00
FenrirWolf
fb0ef2a459 correct ticks per msec/usec (#336) 2017-02-13 01:02:21 +00:00
fincs
7be0b5b026 Add GPU_TEXFACE enumeration 2017-02-11 23:04:03 +01:00
Michael Theall
97d6149e3e Avoid double promotion 2017-02-08 22:51:57 -06:00
AriA99
e06c8e542f Add nim:s client implementation. 2017-01-27 19:06:28 +01:00
Slimfr01
6eb53df563 update NFC_AmiiboConfig struct
adjust and rename NFC_AmiiboConfig struct members to better reflect their purpose.
2017-01-20 18:14:16 +00:00
fincs
ee2a1d2eba Bump version for release, with changelog 2017-01-16 17:16:42 +01:00
fincs
e50802b90f Renew GitHub token for uploading Doxygen documentation 2017-01-16 17:14:22 +01:00
Dave Murphy
400e85d674 __alloc_handle changes for dkA r46
space for device specific storage in FILE struct is now allocated in __alloc_handle
2017-01-16 15:39:06 +00:00
Dave Murphy
50cafaa700 devkitARM r46 changes 2017-01-16 15:39:06 +00:00
Dave Murphy
396d341a8f re-enable strict-aliasing 2017-01-16 15:39:06 +00:00
motezazer
648ee46742 Add AM_FinishCiaInstallWithoutCommit and AM_CommitImportPrograms (#321)
* Add AM_FinishCiaInstallWithoutCommit and AM_CommitImportPrograms

* Make the tids const

* In the headers also
2017-01-16 12:41:35 +00:00
yellows8
6e107a1aa5 Added bossGetNsDataHeaderInfo() and enums for it + added a comment for bossTaskStatus. 2017-01-10 18:08:15 -05:00
fincs
d42efe636b Simplify application/linear heap size management 2017-01-03 18:36:37 +01:00
Jeffrey Pfau
635d3e6640 Add APT:ReceiveDeliverArg 2016-12-29 19:28:59 +01:00
Dave Murphy
66d1f7c957 re-enable strict-aliasing 2016-12-28 18:24:58 +00:00
thedax
f744a85e5a Add support for nwm::EXT::ControlWirelessEnabled. 2016-12-28 17:41:51 +01:00
yellows8
47d9585624 Added bossReinit() and bossUnregisterStorage(). Updated comments for bossInit(). 2016-12-27 18:04:17 -05:00
yellows8
d14fa59ba5 Added bossSetStorageInfo(). 2016-12-26 01:43:12 -05:00
yellows8
95bcb4d69a Added force_user param to bossInit(). 2016-12-25 19:21:20 -05:00
yellows8
7ccfe71e45 Added bossDeleteNsData() and bossReadNsData(). 2016-12-25 02:15:10 -05:00
yellows8
435fad724b Added enum bossTaskStatus and updated bossGetTaskState. 2016-12-25 01:00:49 -05:00
yellows8
88da2f456b Added BOSS property_xb and property_x3e. 2016-12-25 00:33:32 -05:00
fincs
4abf42f16d Merge pull request #325 from TuxSH/master
Finish implementing the debug SVCs, fix bugs, other changes
2016-12-23 18:05:42 +01:00
TuxSH
ba23d7224b Add svcGetThreadList 2016-12-23 15:30:46 +01:00
TuxSH
84db84c05f Add svcBreakRO 2016-12-23 15:30:46 +01:00
TuxSH
fbdcf91c8b Update svcOutputDebugString 2016-12-23 15:30:46 +01:00
TuxSH
7e8a480b45 Documentation update for svcBackdoor 2016-12-23 15:01:15 +01:00
TuxSH
c23ed61457 Fix the implementation of svcGetProcessList
svcGetProcessList takes only one scalar output parameter, not two.
2016-12-23 14:59:15 +01:00
TuxSH
066a9cc6fd Update svc(Un)bindInterrupt's prototype and documentation 2016-12-23 14:58:02 +01:00
TuxSH
65240d6202 Finish implementing the debug SVCs and associated types 2016-12-23 14:57:32 +01:00
Dave Murphy
bd832dbb25 fix bossSetupContextDefault prototype 2016-12-23 13:01:23 +00:00
yellows8
131e71b5e7 Added bossSetupContextDefault(), bossSendContextConfig(), and bossContext. 2016-12-22 18:00:58 -05:00
yellows8
b04568fd53 Use const with BOSS, use '(void)' for bossGetSessionHandle, and changed bossCmd34 to bossGetTaskProperty0. 2016-12-22 16:02:53 -05:00
yellows8
955ae2af3e Updated bossCmd34 and added bossGetTaskState(). 2016-12-22 02:18:26 -05:00
yellows8
ee23569db8 Added bossRegisterTask, bossSendProperty, bossDeleteTask, and bossCmd34. 2016-12-22 01:32:49 -05:00
yellows8
e8c3a9139e Started implementing BOSS support. 2016-12-19 19:49:51 -05:00
Mrrraou
b5a8183dbd Add svcGetHandleInfo. (#324) 2016-12-19 00:02:43 +01:00
TuxSH
34015acd3f Change svcKernelSetStateSignature
`svcKernelSetState` behaves like a variadic function. This change, in addition of not breaking anything, would allow writing things like:

```c
svcKernelSetState(0, 0x0004013800000002ULL, 0)````

which is more explicit than what was used before
2016-12-18 23:52:12 +01:00
yellows8
e37ebf3ef1 Added psInitHandle and psGetSessionHandle. Updated PS_AESAlgorithm comments and added psRSAContext. Added PS_SignRsaSha256 and PS_VerifyRsaSha256. Fixed PS_EncryptDecryptAes and PS_EncryptSignDecryptVerifyAesCcm, these originally implemented pxips9 commands not psps. 2016-12-17 01:38:37 -05:00
Dave Murphy
3501efd7e5 whitespace fixes 2016-12-04 17:21:44 +00:00
Dave Murphy
664ae583c4 fix buffer overrun 2016-12-03 21:13:14 +00:00
Lázaro Vieira
744ca95390 Add AM_DeleteAllDemoLaunchInfos (#320) 2016-11-11 00:12:51 +01:00
Dave Murphy
39e54e3634 Merge pull request #319 from esoteric-programmer/suspending_2d_app_fix
Fixed home menu display of suspended 2D mode app
2016-11-10 22:26:00 +00:00
Matthias Lutter
9048408bd3 Fixed buffer overflow after gfxSetScreenFormat (#318) 2016-11-10 23:24:23 +01:00
Matthias Lutter
5e568d78b1 Fixed home menu display of suspended 2D mode app 2016-10-26 15:45:24 +02:00
yellows8
f7eed42835 Implemented AM_ExportTwlBackup/AM_ImportTwlBackup and AM_ReadTwlBackupInfo. 2016-10-19 12:33:04 -04:00
TuxSH
0eb70a4350 Implement NS_LaunchFIRM and NS_LaunchApplicationFIRM (#316) 2016-09-27 23:16:11 +02:00
SciresM
bd34fd59db Add GSPLCD_GetVendors (#311) 2016-09-04 14:41:28 +02:00
fincs
b0768e552b Merge pull request #310 from SciresM/master
Implement some cfg functions.
2016-08-30 21:01:42 +02:00
fincs
1258cfcccb Merge pull request #305 from Thog/ptmsysm
Add PTMSYSM_CheckNew3DS, PTMSYSM_ShutdownAsync and PTMSYSM_RebootAsync
2016-08-30 21:01:29 +02:00
SciresM
0955035671 Implement some cfg:i functions. 2016-08-28 01:03:50 -07:00
Michael Theall
ada9559c11 Fix zero-length Sha256 hash 2016-08-25 06:25:06 -05:00
fincs
277fc287a1 Merge pull request #308 from profi200/master
Added FSUSER_UpdateSha256Context().
2016-08-25 13:22:58 +02:00
profi200
fcbc24a895 Added FSUSER_UpdateSha256Context(). 2016-08-25 08:39:26 +02:00
Thog
3b3c0fabdf Add PTMSYSM_CheckNew3DS, PTMSYSM_ShutdownAsync and PTMSYSM_RebootAsync 2016-07-31 22:42:20 +02:00
fincs
e6ebe9abea Merge pull request #304 from Cruel/httpc
Add httpcCancelConnection and some timeout calls
2016-07-31 11:33:09 +02:00
Thomas Edvalson
3474ac5121 Add httpcCancelConnection and some timeout calls 2016-07-31 00:16:22 -04:00
fincs
7090fbd02d Merge pull request #302 from Lectem/fixoutputbools
fix incorrect values for bool outputs in services
2016-07-28 01:07:54 +02:00
Lectem
c741d7d5cc fix incorrect values for bool outputs in services 2016-07-28 00:40:50 +02:00
fincs
71cdc3cdbc Merge pull request #301 from ksanislo/master
Add httpcSetKeepAlive() to turn HTTP Keep-Alive on and off
2016-07-27 20:27:46 +02:00
fincs
ae6be1cf97 Minor fix in APT_CheckNew3DS_System 2016-07-27 19:06:16 +02:00
Ken Sanislo
9efe374dc1 Define the known KeepAlive on/off flag 2016-07-26 12:39:16 -07:00
Ken Sanislo
6a94d99dc2 Add httpcSetKeepAlive() to turn HTTP Keep-Alive on and off 2016-07-26 10:47:33 -07:00
fincs
d149355fb7 Merge pull request #300 from infinicore/master
Add support for ps:ps#GenerateRandomBytes.
2016-07-22 11:12:56 +02:00
infinicore
5310f1a900 Add support for ps:ps#GenerateRandomBytes. 2016-07-22 06:24:18 +00:00
fincs
9e53a7cd61 Merge pull request #299 from jakcron/master
Fixed cmd word index fail in pm.c
2016-07-21 14:23:10 +02:00
jakcron
4dc8493d77 Fixed cmd word index fail in pm.c 2016-07-21 20:20:13 +08:00
fincs
7aad0b4968 Enhanced and corrected shader code to fully support geometry shaders 2016-07-20 17:35:26 +02:00
fincs
88a9c58bec Remove old deprecated GPU API 2016-07-20 17:31:30 +02:00
fincs
5725ec2ded Const correctness in GPUCMD_Add(RawCommands) 2016-07-20 17:30:19 +02:00
fincs
24b9341c99 Fix lingering parameter bug with APTREINIT (aka hax 2.x) 2016-07-18 00:26:52 +02:00
fincs
343d53f540 Merge pull request #298 from chaoskagami/master
More err:f changes
2016-07-16 11:51:08 +02:00
chaoskagami
afa261eecd Improve err:f documentation and add wrappers to construct errors automatically 2016-07-15 19:39:38 -04:00
fincs
baf7dee858 Merge pull request #296 from linkmauve/camu
Fix CAMU_SetOutputFormat’s header
2016-07-15 00:26:21 +02:00
fincs
ea0a96c29b Merge pull request #297 from chaoskagami/master
Expose err:f global port
2016-07-15 00:16:48 +02:00
chaoskagami
cfdb8d1b58 Expose err:f global port 2016-07-14 18:07:30 -04:00
Emmanuel Gil Peyrot
3bed534f87 Fix CAMU_SetOutputFormat’s header. 2016-07-13 00:09:27 +01:00
fincs
da7ecc255b Take advantage of light events in NDSP and GSPGPU code 2016-07-05 22:38:44 +02:00
fincs
bbd0fe92d3 Add software keyboard (swkbd) library applet support (finally!) 2016-07-04 01:08:12 +02:00
fincs
15e24d19a5 Major APT rewrite, see details:
- Internal logic changes in order to follow official behavior
  more closely - the APT state machine has been removed.
- The following functions were removed:
  * aptSetStatus/aptGetStatus along with the APT_AppStatus enum
  * aptGetStatusPower/aptSetStatusPower
  * aptReturnToMenu
  * aptWaitStatusEvent, aptSignalReadyForSleep
- Library applet launching is now fully supported on both official
  environments (ncch/cia) and homebrew environments (3dsx).
  APT_LaunchLibraryApplet has been replaced with aptLaunchLibraryApplet.
- Added aptSetMessageCallback (intended for use with libapplet code)
- Added APT_CancelParameter
- Some other misc changes
2016-07-02 00:57:06 +02:00
fincs
bac12e19bb Add light events 2016-07-01 18:28:00 +02:00
fincs
2f6a28f1e3 Add ResetType enum (and fixed many wrong ResetType usages) 2016-07-01 18:27:39 +02:00
fincs
02a087b588 Merge pull request #294 from TuxSH/master
Implement svcBindInterrupt and svcUnbindInterrupt
2016-06-25 00:12:16 +02:00
TuxSH
e863d2a4cf Implement svcBindInterrupt and svcUnbindInterrupt 2016-06-25 00:07:03 +02:00
fincs
1cef3e5d2f Merge pull request #291 from Lectem/patch-1
Add NETOPT_DHCP_LEASE_TIME
2016-06-11 19:48:44 +02:00
fincs
14cdb5a9d3 Begin refactoring APT code, many changes to make code a bit more manageable 2016-06-11 19:48:05 +02:00
Lectem
8c9a32747c Add NETOPT_DHCP_LEASE_TIME 2016-06-11 13:20:12 -04:00
fincs
3a10698964 Fix misc FSUSER & PS fail 2016-06-10 18:15:41 +02:00
fincs
56a11197c7 () -> (void) 2016-06-10 18:14:30 +02:00
fincs
6d65d537b3 Merge pull request #290 from Steveice10/master
Add pxidev.h to 3ds.h.
2016-06-03 11:04:02 +02:00
Steven Smith
1ba7894c8d Add pxidev.h to 3ds.h. 2016-06-02 18:43:57 -07:00
yellows8
12f0f638ff Moved amapp init into a seperate function. 2016-06-02 20:49:01 -04:00
fincs
94b3748870 Merge pull request #289 from Steveice10/master
Add pxi:dev service.
2016-06-01 00:57:08 +02:00
Steven Smith
7fa3adc716 Add pxi:dev service. 2016-05-31 15:29:09 -07:00
fincs
8876b1eb5f Merge pull request #288 from Ryuzaki-MrL/master
Add 2 more missing news:s functions
2016-05-21 22:05:02 +02:00
Lázaro Vieira
c36bdb9013 Add 2 more missing news:s functions
-Add NEWS_SetNotificationMessage
-Add NEWS_SetNotificationImage
-NULL reference handling for NEWS_GetNotificationImage
2016-05-21 16:51:31 -03:00
Michael Theall
191e286283 Remove romfs limitation note from osGetSystemVersionData 2016-05-20 00:04:48 -05:00
Michael Theall
d72842f898 Allow multiple romfs mounts 2016-05-19 23:58:55 -05:00
fincs
9489aadb5a Merge pull request #287 from Cruel/const-lyfe
Some const correctness in sslc/httpc inputs
2016-05-20 01:46:53 +02:00
Thomas Edvalson
53e3b35466 Some const correctness in sslc/httpc inputs 2016-05-19 19:21:11 -04:00
fincs
7ce124e744 Add svcSetProcessAffinityMask, svcSetProcessIdealProcessor and svcRun 2016-05-17 00:14:32 +02:00
fincs
3ed89e6bd9 Minor pedantic fix in hb.c 2016-05-17 00:14:00 +02:00
fincs
2810c4d3a8 Merge pull request #285 from Steveice10/togglesleep
Allow toggling sleep mode.
2016-05-08 22:11:54 +02:00
fincs
f22b8f7d9a Merge pull request #282 from Steveice10/master
Separate information required to open an archive from the actual opened handle.
2016-05-08 22:11:48 +02:00
Steven Smith
c81239a407 Allow toggling sleep mode. 2016-05-08 12:45:18 -07:00
Steven Smith
cf91be5041 Separate information required to open an archive from the actual opened handle. 2016-05-06 15:25:20 -07:00
smea
863ea8ef68 Merge pull request #283 from Cruel/etc1-enums
Fix ETC1 texture format enums and add A4
2016-05-02 20:30:08 -07:00
Thomas Edvalson
3129c35e71 Fix ETC1 texture format enums and add A4 2016-05-02 22:46:37 -04:00
yellows8
98adfa0536 Implemented proper NFC support, see also the NFC example. 2016-04-30 17:59:12 -04:00
yellows8
25aae300b2 Implemented httpc support for the remaining documented sslc-related commands. 2016-04-29 00:54:51 -04:00
yellows8
102adfe872 Added UDS_CHECK_SENDTO_FATALERROR and updated comments for udsPullPacket(). 2016-04-27 15:55:49 -04:00
yellows8
a65a2e0def Added flag and out params to MVDSTD_ProcessNALUnit(). Added mvdstdSetupOutputBuffers() and mvdstdOverrideOutputBuffers(). Updated mvdstdInit() to use an initstruct, and clear the workbuf. In mvdstdInit(), use a seperate retval for MVDSTD_ControlFrameRendering() so that the actual retval is returned correctly. Updated mvdstdGenerateDefaultConfig(). Updated mvdstdProcessVideoFrame(). Updated mvd.h. 2016-04-25 12:21:16 -04:00
yellows8
030393a753 Updated the MVDSTD_Config struct. Removed config setup in mvdstdGenerateDefaultConfig() which is actually optional. 2016-04-22 12:38:44 -04:00
yellows8
570f46f281 Moved rendering code from mvdstdProcessVideoFrame() into a seperate function. 2016-04-22 12:12:32 -04:00
fincs
19175f7de3 Merge pull request #281 from Steveice10/master
Minor am:net corrections and additions.
2016-04-22 11:35:42 +02:00
Steven Smith
b1f4f431e8 Minor am:net corrections and additions. 2016-04-21 23:05:49 -07:00
yellows8
1578cd7e82 Updated the MVD implementation to support video processing. Fixed some issues, etc. 2016-04-21 19:22:14 -04:00
Michael Theall
6f378c8297 Reset romFS_offset on romfsExit() 2016-04-20 17:37:34 -05:00
yellows8
f9f7eccc33 Implemented recv_buffer_size for UDS bind handling, this was added to the udsCreateNetwork()/udsConnectNetwork() params too. Run udsBind() before creating/joining a network. Added udsAllowSpectators() and updated the UDSNETATTR enums. Added more defines. Minor other changes. Removed the 'WARNING' from the .h. 2016-04-19 13:36:18 -04:00
fincs
ed5516ba20 Merge pull request #280 from Steveice10/master
Fix FSUSER_GetArchiveResource, add more AM commands.
2016-04-16 11:59:53 +02:00
fincs
2dbed49262 Merge pull request #279 from Lectem/fixnewss
fixes NEWS_AddNotification for news:s #278
2016-04-16 11:59:40 +02:00
Steven Smith
88cffe7703 Fix FSUSER_GetArchiveResource, add more AM commands. 2016-04-16 01:09:07 -07:00
Michael Theall
2f03d17a68 Initialize dir->size 2016-04-15 16:55:33 -05:00
Lectem
18b44e3780 fixes NEWS_AddNotification for news:s #278 2016-04-15 16:47:54 -04:00
fincs
dcf7449a93 Merge pull request #277 from Steveice10/master
Add some resource limit SVCs.
2016-04-14 11:49:13 +02:00
Steven Smith
fd566668d3 Add some resource limit SVCs. 2016-04-14 01:19:11 -07:00
yellows8
6606a77719 Updated udsConnectNetwork() to handle failure from the network-connection command properly, and removed the commented prints. 2016-04-13 00:36:47 -04:00
yellows8
a653c49aaa Updated udsSetNewConnectionsBlocked() and UDSNETATTR for bitmask 0x4. 2016-04-12 22:28:42 -04:00
yellows8
e61e45abdc Added httpcAddDefaultCert, and some header include changes to support this. 2016-04-11 21:27:34 -04:00
yellows8
47155d75b6 Merged the HTTPC_* functions with httpc* and removed HTTPC_* from the .h, etc(this is similar to how sslc is already handled). 2016-04-11 16:19:23 -04:00
fincs
c4d2110ab9 Merge pull request #276 from Steveice10/master
Add ARCHIVE_TWL_SOUND.
2016-04-11 18:18:00 +02:00
Steven Smith
3a84c7237e Add ARCHIVE_TWL_SOUND. 2016-04-11 09:16:02 -07:00
fincs
c29438af03 Merge pull request #275 from Steveice10/master
Add result module codes.
2016-04-11 00:00:41 +02:00
Steven Smith
e266fa8362 Add result module codes. 2016-04-10 12:52:59 -07:00
fincs
3d243ce567 Merge pull request #274 from Steveice10/master
Fix buffer type in FSUSER_EnumerateSystemSaveData.
2016-04-10 11:35:46 +02:00
Steven Smith
001623c43d Fix buffer type in FSUSER_EnumerateSystemSaveData. 2016-04-09 23:53:45 -07:00
fincs
2f7515a814 Merge pull request #273 from ksanislo/master
fix typo from pull #272
2016-04-10 01:26:26 +02:00
Ken Sanislo
d1aaf68665 fix typo from #272 2016-04-09 15:08:52 -07:00
fincs
2706026ff4 Merge pull request #261 from Steveice10/master
Clean up and update AM service functions.
2016-04-09 23:17:32 +02:00
yellows8
b6e0555b1a Implemented UDS data_channel handling. Added the data_channel param to udsBind(), udsConnectNetwork(), and udsCreateNetwork(). Removed UDS_SEND_NETFLAGS_DEFAULT. The output bind context for network creation/connecting is now optional. 2016-04-08 19:09:15 -04:00
Ken Sanislo
353f7af759 httpcSetSSLOpt support (#272)
httpcSetSSLOpt support
2016-04-08 17:37:07 -04:00
yellows8
0c1e656a2b Switched 'input8' for udsSendTo() to 'netflags'. Minor other changes. 2016-04-08 01:20:21 -04:00
yellows8
f6bf7e7b1f Updated comments for udsNodeInfo. 2016-04-07 16:51:03 -04:00
yellows8
daba63af69 Updated udsNodeInfo and udsConnectionStatus. Updated the related code for udsNodeInfo. 2016-04-07 16:31:26 -04:00
yellows8
570c834679 Updated udsConnectionStatus and networkstruct. Removed total_nodes from udsNetworkScanInfo since that's stored in the networkstruct. 2016-04-07 13:06:23 -04:00
Michael Theall
72b6b3e48b Const-correctness and some size_t parameters for UDS 2016-04-07 10:38:44 -05:00
yellows8
d7500b3608 Properly load the UDS network wifi channel, apparently it was hard-coded to channel 1 previously. This fixed the udsConnectNetwork() failures with the example app(not yet available under the 3ds-examples repo). 2016-04-07 10:04:48 -04:00
yellows8
6f6926921e Added a new param to udsScanBeacons() for using ScanOnConnection internally. 2016-04-06 19:38:56 -04:00
yellows8
bdb2835b62 Added udsEjectSpectator(). 2016-04-06 16:32:25 -04:00
yellows8
1671aeb7c2 Implemented full support for connecting as an UDS spectator. 2016-04-06 16:26:06 -04:00
yellows8
3b1673b673 Updated the udsConnectionStatus struct. 2016-04-06 13:41:37 -04:00
yellows8
688b2649c5 Added udsWaitConnectionStatusEvent(). Updated the udsConnectionStatus struct. 2016-04-06 13:02:26 -04:00
yellows8
72cb548cb0 Added udsGetConnectionStatus(). 2016-04-06 12:46:08 -04:00
yellows8
9b5c1a3a6a Added udsGetNodeInformation(). 2016-04-06 12:24:43 -04:00
yellows8
b11004f221 Implemented udsUpdateNetworkAttribute() and udsSetNewConnectionsBlocked(). 2016-04-06 01:56:02 -04:00
yellows8
6570ade097 Disabled the debug prints for network-connecting and implemented udsEjectClient(). 2016-04-06 00:48:08 -04:00
Michael Theall
4393593e48 Add readdir batching to sdmc 2016-04-05 17:36:09 -05:00
Michael Theall
41ea040420 Add opendir/readdir/rewinddir/closedir/stat support to romfs 2016-04-05 17:35:45 -05:00
yellows8
db6432ce0a Added udsGetNetworkStructApplicationData(). 2016-04-05 17:37:07 -04:00
yellows8
9ad6e0945c Fixed udsGetChannel() output. Implemented udsSetApplicationData() and udsGetApplicationData(). Added a comment regarding why there's debug prints in udsConnectNetwork(). 2016-04-05 16:57:16 -04:00
yellows8
d2f9655d8a Added udsWaitDataAvailable(), based on gspWaitForEvent(). 2016-04-05 12:07:24 -04:00
yellows8
4123baba50 Added UDS_HOST_NETWORKNODEID. Updated UDS_SENDFLAG_Broadcast. 2016-04-05 11:26:48 -04:00
yellows8
fa70037055 Added host_macaddress parameter to udsScanBeacons(). 2016-04-05 11:01:16 -04:00
yellows8
d654cf1b88 Switched UDS_SEND_INPUT8_DEFAULT to 0xF3, udsPullPacket() returns actual output data which was sent via udsSendTo() now. 2016-04-05 10:26:16 -04:00
yellows8
a896bf772c Implemented udsCheckNodeInfoInitialized() and udsGetChannel(). Implemented network (dis)connect and scanning code. Implemented udsPullPacket(). Fixed some issues. Updated uds.h for beacon scanning etc. 2016-04-05 10:07:04 -04:00
yellows8
9aa9d32e11 Added varioues UDS structs and enums+defines. Implemented udsGenerateDefaultNetworkStruct(). Implemented code for creating+destroying networks. Implemented code for binds. Implemented udsSendTo(). 2016-04-04 14:26:49 -04:00
yellows8
ed53bcf4a8 Load the UDS connection-status event handle, and a minor uds.c change. 2016-04-04 00:22:32 -04:00
yellows8
c9d2f74815 Implemented some support for ndmu. Started implementing support for UDS. 2016-04-04 00:11:37 -04:00
yellows8
b9c0ca992d Implemented support for sslc cmd8..cmdc CertChain commands. Clear the serv handle in sslcExit. 2016-03-31 12:37:20 -04:00
yellows8
2964d87ed4 Implemented sslcAddCert. 2016-03-31 11:28:32 -04:00
yellows8
3bb7451c3d Implemented sslcContextInitSharedmem. 2016-03-30 16:51:42 -04:00
yellows8
1346fae04f Switched sslcContextGetStrings to sslcContextGetProtocolCipher since it's documented now. 2016-03-30 16:04:17 -04:00
yellows8
44b601d7b8 Switched the sslopt enum to anonymous, and updated sslcRead(), as requested. Implemented sslcContextGetStrings. 2016-03-30 15:02:18 -04:00
yellows8
1e5c91989f Switched to using an enum for sslopt. Updated the type handling for sslcRead. 2016-03-30 14:24:24 -04:00
yellows8
3d90087481 Implemented actual support for sslc, homebrew can now actually use sslc(see also the sslc example). 2016-03-30 13:57:20 -04:00
yellows8
b7b78414da Implemented SOCU_AddGlobalSocket. 2016-03-30 13:52:15 -04:00
Steven Smith
932630764f Clean up and update AM service functions. 2016-03-29 16:16:15 -07:00
fincs
7adab4d940 Merge pull request #271 from MerryMage/channel-filter
ndsp: Monopole and biquad channel filter params
2016-03-25 20:33:57 +01:00
MerryMage
d431a67f31 ndsp: Monopole and biquad channel filter params 2016-03-25 19:30:46 +00:00
fincs
98fa2f7983 Merge pull request #269 from wwylele/master
fix hid:GetGyroscopeRawToDpsCoefficient
2016-03-18 22:47:31 +01:00
wwylele
a5b7c58c69 fix hid:GetGyroscopeRawToDpsCoefficient 2016-03-18 22:52:16 +02:00
yellows8
5b7468e5cf Added initial sslc support. Minus init/exit this only has sslcAddTrustedRootCA implemented. 2016-03-08 19:29:48 -05:00
yellows8
d769879933 Added httpc AddTrustedRootCA. 2016-03-08 18:19:51 -05:00
yellows8
049d2e2373 Finally added code to exit httpc properly via HTTPC_Finalize. 2016-03-08 15:00:57 -05:00
yellows8
e2852d14f1 Merge pull request #267 from Bownairo/master
Adds function addPostDataRaw
2016-03-06 15:24:04 -05:00
Eero Kelly
12a5fa297a Adds function addPostDataRaw 2016-03-06 15:21:01 -05:00
Dave Murphy
2beafaa27f Merge pull request #266 from ObsidianX/nit-pick-hid-comments
Update hid.h comments
2016-03-06 13:13:49 +00:00
yellows8
b0c5a3c87d Clear the httpc sharedmem before using svcCreateMemoryBlock. 2016-02-29 00:45:42 -05:00
Ryan Loebs
1c55370cee Update hid.h comments
Nit-picky update to accurately describe the `hidKeys*()` functions, and how to extract individual bits from them.
2016-02-24 04:32:57 -08:00
fincs
bb9853798b Merge pull request #265 from Lectem/patch-1
add a note for svcExitThread and the thread API
2016-02-16 19:27:02 +01:00
Lectem
6d5a06227b add a note for svcExitThread and the thread API
Calling svcExitThread will make it so that threadCreate detached parameter won't work.
2016-02-16 13:15:31 -05:00
yellows8
e4e51e758b Implemented actual httpc sharedmem handling. Implemented httpc AddPostDataAscii. 2016-02-12 18:38:39 -05:00
Dave Murphy
5e84447219 Merge pull request #263 from smealum/libctru-cleanup
httpc fixes and extensions
2016-02-12 17:16:50 +00:00
Ken Sanislo
e1a9d2ef9c httpc fixes and extensions
Signed-off-by: Dave Murphy <davem@devkitpro.org>
2016-02-12 16:38:43 +00:00
fincs
42ce1d8792 Merge pull request #260 from javimadgit/master
Add basic NFC service support
2016-02-04 17:53:31 +01:00
Javi
c3b22e3922 Fix nfcInit error 2016-02-04 17:20:40 +01:00
Javi
14005eee52 Fixed prefix and parameters declaration 2016-02-04 17:18:26 +01:00
Javi
0c11529000 Add basic NFC service support 2016-02-04 12:51:06 +01:00
mtheall
f700005701 Merge pull request #259 from yuriks/patch-1
Fix crash when getting or setting struct params in CAM:U
2016-02-03 02:45:00 -06:00
Yuri Kunde Schlesner
09611e0284 Fix crash when getting or setting struct params in CAM:U 2016-02-03 00:37:13 -08:00
fincs
8cd37c627c Add ndspChnIsPaused/ndspChnSetPaused (untested) 2016-01-28 23:46:03 +01:00
fincs
27b6134bf2 Adapt AMPXI to use libctru naming conventions for plain service calls. 2016-01-28 23:44:51 +01:00
yellows8
173d258e30 Added ampxiInstallTitlesFinish. 2016-01-26 01:09:21 -05:00
mtheall
c818410973 Merge pull request #256 from Lectem/more_soc
added SOCU_GetNetworkOpt
2016-01-25 19:46:28 -06:00
Lectem
2b9dc3c82a added SOCU_GetNetworkOpt 2016-01-25 01:14:09 -05:00
Dave Murphy
3a3ee64b64 Merge pull request #254 from Rinnegatamante/master
Added some missing news:s funcs and updated header.
2016-01-24 18:05:17 +00:00
Dave Murphy
92700f4f73 Merge pull request #253 from yifanlu/master
Added svc calls for svcCreateCodeSet and svcCreateProcess
2016-01-23 22:42:26 +00:00
Yifan Lu
cd054cbadf Added svc calls for svcCreateCodeSet and svcCreateProcess 2016-01-23 14:32:36 -08:00
Rinnegatamante
62c05ea73b Added some missing news:s funcs and updated header.
Added some missing news:s funcs and updated header.
2016-01-23 12:47:14 +01:00
fincs
b364790a9a Add fallback RomFS path for when argv isn't available (e.g. boot.3dsx) 2016-01-23 00:59:39 +01:00
Michael Theall
818254c55e Add sdmc_getmtime 2016-01-22 16:40:28 -06:00
Michael Theall
07faf3d40c fix spacing 2016-01-21 19:22:43 -06:00
Michael Theall
5af3dd73de Add SOCU_GetIPInfo 2016-01-21 19:21:43 -06:00
Michael Theall
de0a39089c replace 6, 17 with IPPROTO_TCP, IPPROTO_UDP respectively 2016-01-21 17:12:58 -06:00
Dave Murphy
98165a1164 Merge pull request #251 from ss23/250_socket_protocol
Change protocol in socket() to 0 if appropriate - Fix #250
2016-01-21 09:35:46 +00:00
Stephen Shkardoon
248c02cf8e Change protocol in socket() to 0 if appropriate - Fix #250
When the user is specifying TCP or UDP and it is the only option,
change the protocol parameter to 0, which is the only value the
underlying 3DS system will accept as valid. This compatibility layer
ensures that code will work transparently whether on a host system
or the 3DS.
2016-01-20 23:56:48 -05:00
Dave Murphy
b8741b35e8 Merge pull request #247 from Lectem/more_soc
added gethostname
2016-01-21 00:16:26 +00:00
Michael Theall
a7a7231085 Tested all the send/recv flags and the SOL_SOCKET options 2016-01-20 18:10:48 -06:00
Dave Murphy
88c1798c12 Merge pull request #249 from Lectem/patch-2
remove restrict keyword in arpa/inet.h fixes #248
2016-01-20 23:20:48 +00:00
Lectem
097095b557 remove restrict keyword in arpa/inet.h fixes #248
This causes problems for non-c99 and c++ projects.
2016-01-20 16:15:48 -05:00
fincs
70f84f4950 Fix Doxygen oversight 2016-01-19 23:45:31 +01:00
Lectem
6beee4f9fe added gethostname 2016-01-19 14:20:34 -05:00
fincs
8b5e753235 Add shared system font parsing code. 2016-01-19 19:23:58 +01:00
Michael Theall
07f0fe7e65 Fix use of RemoveDevice() 2016-01-18 19:34:12 -06:00
mtheall
722d91b73e Merge pull request #245 from Lectem/more_soc
fix getaddrinfo
2016-01-17 21:53:47 -06:00
Lectem
abbef70e61 fix getaddrinfo 2016-01-17 22:50:40 -05:00
Dave Murphy
28b3775118 Merge pull request #244 from Lectem/more_soc
SOC:u added close/shutdown sockets and inet_pton/ntop
2016-01-17 18:36:06 +00:00
Lectem
45ff5c4ee6 added inet_pton and inet_ntop 2016-01-17 12:58:21 -05:00
Lectem
389807c6a3 fix alignment in arpa/inet.h 2016-01-17 12:25:41 -05:00
Lectem
464d6c6363 SOC:u added close/shutdown sockets 2016-01-16 21:14:09 -05:00
Michael Theall
ac7af47956 Merge branch 'master' of github.com:smealum/ctrulib 2016-01-16 16:32:27 -06:00
Michael Theall
3df00537cd proper EEXIST error for mkdir 2016-01-16 16:32:21 -06:00
Michael Theall
0b40e7aa2f Move sdmc_dir_t into 3ds/sdmc.h 2016-01-16 16:30:11 -06:00
Dave Murphy
557fbedb9b ensure svcSleepThread gets u64 2016-01-16 21:06:33 +00:00
mtheall
15cb718913 Merge pull request #242 from Lectem/more_soc
More soc
2016-01-14 18:18:44 -06:00
Lectem
e9a476cfe2 Added gai_strerror 2016-01-14 18:31:45 -05:00
Lectem
6eb23d3fbd added SOC:u getaddrinfo 2016-01-14 18:30:55 -05:00
Lectem
517b1c9503 added SOC:u getnameinfo 2016-01-14 18:24:50 -05:00
Lectem
b34ff22dc7 fix sockaddr_storage to match the one used by SOC 2016-01-13 12:23:05 -05:00
Lectem
531f8f29a1 fix PF_INET6 value 2016-01-13 12:23:05 -05:00
Michael Theall
c5674b3126 Add sdmcWriteSafe 2016-01-12 16:22:30 -06:00
Dave Murphy
15897d0eab add void function typedef 2016-01-12 21:12:11 +00:00
Dave Murphy
eba67d69ca add macros for color codes 2016-01-12 21:12:11 +00:00
fincs
a75c01c302 Merge pull request #241 from Lectem/TLSfix
fix thread static buffers usage (save+restore)
2016-01-12 20:36:05 +01:00
Lectem
e05f841a58 fix thread static buffers usage (save+restore) 2016-01-10 13:41:28 -05:00
yellows8
d5931ee336 Added AMPXI for using ampxiWriteTWLSavedata. 2016-01-07 17:28:48 -05:00
yellows8
afae9ad607 Added NS_TerminateProcessTID. 2016-01-06 23:31:10 -05:00
fincs
57ec5db247 Bump version to v1.1.0 2016-01-06 19:53:09 +01:00
Dave Murphy
850646ea31 add usleep 2016-01-05 16:37:05 +00:00
fincs
9f98cefa3e Revise/enhance GSPGPU/GFX code, see below:
- Screens can be buffer-swapped independently (gfxConfigScreen)
- Added gspSetEventCallback for running event code directly on the GSP thread
- Added gspWaitForAnyEvent for waiting for any GSP event
- Added gfxIs3D for retrieving 3D-enable status
2016-01-05 00:25:40 +01:00
fincs
43940facdc Fix redundant/hazardous code in svcArbitrateAddress 2016-01-05 00:23:10 +01:00
Dave Murphy
feb0b095e0 increase ndsp thread priority 2016-01-04 19:43:28 +00:00
fincs
59c62c4596 Merge pull request #238 from TuxSH/master
Implementing AM_InstallFirm
2016-01-03 20:29:34 +01:00
TuxSH
29176f39ae Implementing AM_InstallFirm 2016-01-03 19:38:41 +01:00
Dave Murphy
2741615b85 elaborate GX_BUFFER_DIM 2016-01-03 14:08:58 +00:00
Dave Murphy
cf0a0dc8a0 Merge pull request #236 from Steveice10/master
Fix svcSetTimer.
2015-12-30 03:02:51 +00:00
Steven Smith
df1d39b060 Fix svcSetTimer. 2015-12-29 18:46:38 -08:00
fincs
2feb368dd1 Do not make RomFS the default device 2015-12-29 14:22:04 +01:00
fincs
9fee423e8a Merge pull request #235 from Steveice10/master
Add __sync_get_arbiter.
2015-12-29 12:02:11 +01:00
Steven Smith
74a58330e8 Add __sync_get_arbiter. 2015-12-28 20:46:04 -08:00
fincs
aca183a47b Merge pull request #233 from Subv/patch-1
Fixed the timeout parameter in svcArbitrateAddress
2015-12-28 00:45:52 +01:00
Sebastian Valle
85223098c6 Fixed the timeout parameter in svcArbitrateAddress
the r4 and r5 registers were switched
2015-12-27 18:23:26 -05:00
fincs
20e542c2c8 Examples have been moved to https://github.com/devkitPro/3ds-examples 2015-12-24 12:39:26 +01:00
fincs
7defc9053f Merge pull request #230 from Lectem/patch-1
Added documentation link in the readme
2015-12-13 21:34:56 +01:00
Lectem
2d2cafcd86 Added documentation link in the readme 2015-12-13 14:50:41 -05:00
fincs
d4a24169c5 Bump version to 1.0.0 - with changelog 2015-12-07 11:44:36 +01:00
fincs
1951d3b793 Update Makefiles for devkitARM r45 2015-12-07 11:44:36 +01:00
fincs
a7a0613f38 Fix thread stack alignment 2015-12-07 11:44:36 +01:00
fincs
51709c69e2 Document thread API 2015-12-07 11:44:36 +01:00
fincs
9410a6db2b sdmc_dev.c: make string buffers thread local 2015-12-07 11:44:36 +01:00
fincs
3f9513e62c Add TLS (thread local storage) support 2015-12-07 11:44:36 +01:00
fincs
33d05f0fd0 Add basic multithreading example 2015-12-07 11:44:36 +01:00
fincs
12555d77a4 Revise APT/GSP/NDSP to use the new thread API 2015-12-07 11:44:36 +01:00
fincs
b1e97f2ca4 Add WIP thread wrapper API 2015-12-07 11:43:54 +01:00
fincs
05b8ce5b5d Implement devkitARM/newlib lock support & dynamic reent 2015-12-07 11:43:54 +01:00
fincs
1c18b0bffe Merge branch 'master' into great-refactor 2015-12-07 11:43:44 +01:00
Dave Murphy
46ebd3e1d8 fix warning 2015-12-07 08:44:50 +00:00
Dave Murphy
02f145b9e2 remove more greetz 2015-12-07 08:43:08 +00:00
Dave Murphy
02beea3ed7 remove greetz 2015-12-07 08:30:22 +00:00
fincs
e2037f5795 Merge pull request #227 from Cruel/great-refactor
Make ndspWaveBuf's vaddr const
2015-12-06 11:40:38 +01:00
Thomas Edvalson
4eff425593 Make ndspWaveBuf's vaddr const 2015-12-05 18:39:46 -05:00
fincs
c048221f86 Add shaderProgramSetGshMode() for configuring geoshader mode 2015-12-05 13:28:41 +01:00
fincs
c14634f323 Synchronize GPU register names with the 3dbrew Wiki, again 2015-12-05 13:27:02 +01:00
fincs
bd36f283fd Correct error in FSUSER_OpenArchive/FSUSER_CloseArchive 2015-12-04 18:36:09 +01:00
fincs
3657571591 Add proctex GPU register names and enumerations from the 3dbrew Wiki 2015-12-02 12:04:13 +01:00
fincs
33ba77db4d Revert "Revert "Dynamically determine heap sizes.""
This reverts commit cc8e0c29b6.
The bug was fixed in Citra.
2015-12-01 13:25:09 +01:00
fincs
f052d22ceb shaderProgram: manage GPUREG_SH_OUTATTR_MODE/CLOCK 2015-12-01 13:22:34 +01:00
fincs
f7798302ea Add new GPU register names and enumerations from the 3dbrew Wiki 2015-12-01 12:58:57 +01:00
fincs
50e804d4d2 Merge pull request #225 from Dazzozo/am-title-database
AM: implement external title database IPC functions
2015-12-01 11:33:49 +01:00
Daz Jones
5daecd8d24 AM: implement external title database IPC functions
Correct use of these functions allows applications that require
the external (SD) title database (e.g. title installers) to check
if it exists, and if not, have it created.
2015-12-01 02:09:50 +00:00
fincs
416cc38797 Add a few additional GPU enumerations 2015-11-25 21:49:26 +01:00
fincs
cc8e0c29b6 Revert "Dynamically determine heap sizes."
This reverts commit b96dd51d33.
The change completely broke homebrew on the Citra emulator.
2015-11-22 01:13:41 +01:00
fincs
19bca8177a Merge pull request #207 from Steveice10/great-refactor
Dynamically determine heap sizes.
2015-11-21 21:13:09 +01:00
Steven Smith
b96dd51d33 Dynamically determine heap sizes. 2015-11-21 10:43:50 -08:00
fincs
5ece63029a Merge pull request #222 from Steveice10/y2r-docs
Add to and clean up Y2R documentation.
2015-11-21 18:59:20 +01:00
fincs
58b0b9db4d Revise algorithm used by LightLock_Lock/Unlock to fix potential issues 2015-11-21 18:57:16 +01:00
Steven Smith
827bbba993 Add to and clean up Y2R documentation. 2015-11-21 09:26:50 -08:00
fincs
9b57720cee Add LightLock_TryLock and RecursiveLock_TryLock 2015-11-21 11:48:20 +01:00
fincs
e554f11999 Update template Makefile with the following changes:
- Add RomFS embedding support
- Add proper rules for assembling GPU shaders
- Use -ffunction-sections and --gc-sections by default
- Remove -ffast-math
2015-11-21 01:12:33 +01:00
fincs
5923112082 Several improvements to shaderProgram, see details:
- shaderProgramSetGshInputPermutation() was added
- shaderInstanceGetUniformLocation() return type corrected
- shaderInstanceSetBool bug fixed (true/false were incorrectly mapped)
- shaderInstance now has bitmasks indicating which int/bool uniforms are
  used by int/bool constants in the DVLE
- shaderProgramUse() was revamped:
  - Shader unit setup/code/opdesc upload code was separated into a new
    function called shaderProgramConfigure()
  - shaderProgramUse() calls shaderProgramConfigure() and afterwards
    uploads DVLE constants
  - GPU wrappers that perform uniform management will want to use
    shaderProgramConfigure() instead of shaderProgramUse() and later
    read the shaderInstance uniform usage bitmasks to set the constants.
2015-11-21 00:49:33 +01:00
fincs
10c7711ce5 Correct osConvertVirtToPhys/osConvertOldLINEARMemToNew parameter type 2015-11-20 17:24:02 +01:00
Michael Theall
699748da98 Merge branch 'great-refactor' of github.com:smealum/ctrulib into great-refactor 2015-11-20 09:45:26 -06:00
Michael Theall
a1157f7b8b Fix comparator for overflow check 2015-11-20 09:44:58 -06:00
fincs
f8dec9ec5c Fix FS_ATTRIBUTE bitmask values 2015-11-20 16:43:32 +01:00
fincs
b21fa8a57f Fix typo in documentation that broke generation for FS and CFGU 2015-11-19 23:08:18 +01:00
Michael Theall
c0f75ae42b Robustify UTF translation 2015-11-19 13:49:31 -06:00
fincs
3714fa3810 Merge branch 'master' into great-refactor
# Conflicts:
#	libctru/include/3ds/services/fs.h
#	libctru/source/os.c
#	libctru/source/romfs_dev.c
#	libctru/source/services/fs.c
2015-11-19 11:44:59 +01:00
fincs
3fbea733c6 Add fsUseSession/fsEndUseSession 2015-11-19 11:35:02 +01:00
fincs
f6ebc7f285 Merge pull request #221 from Steveice10/mic-fix
Fix order of memalign parameters in MIC example.
2015-11-19 01:12:50 +01:00
Steven Smith
d6dc1d52c5 Fix order of memalign parameters in MIC example. 2015-11-18 15:45:01 -08:00
fincs
6e3b2a4cd7 Merge pull request #219 from Steveice10/launcher
Reference count srv, cleanup launcher code.
2015-11-15 23:18:52 +01:00
Steven Smith
13a5a225b3 Reference count srv, cleanup launcher code. 2015-11-15 13:02:06 -08:00
fincs
651013d3d0 Fix PATH_UTF16 size miscalculation, yet again 2015-11-15 19:21:00 +01:00
fincs
b96697f7a4 Bring back fsMakePath 2015-11-15 13:51:01 +01:00
fincs
083e89628e Merge pull request #218 from Steveice10/fs
Bring FS up to date.
2015-11-15 13:27:17 +01:00
Steven Smith
324fcff1dc Bring FS up to date. 2015-11-14 17:36:07 -08:00
fincs
c49480f5d5 Fix examples after service refactor 2015-11-11 21:13:31 +01:00
fincs
9083a97014 Fix a typo that wreaked havoc 2015-11-11 19:43:27 +01:00
fincs
5d41effb6e Merge pull request #216 from Steveice10/service-cleanup
Service cleanup.
2015-11-11 19:32:20 +01:00
Steven Smith
375fbce98a Service cleanup. 2015-11-11 08:57:54 -08:00
fincs
6a7f13654d Fix #204 2015-11-09 17:32:17 -05:00
smea
9c98fe54b1 Merge pull request #214 from thedax/great-refactor-fix
Pretty sure it's not a good idea to decrement a handle.
2015-11-09 13:37:19 -08:00
thedax
67a1384564 Pretty sure it's not a good idea to decrement a handle. 2015-11-09 16:31:31 -05:00
yellows8
e87ad0ad6c Implemented code for getting the system-version from NAND NVer/CVer. 2015-11-08 21:28:39 -05:00
fincs
c12c0aace3 Merge pull request #212 from Steveice10/newss
Add news:s support.
2015-11-08 22:53:12 +01:00
Steven Smith
65eaba5b2d Add news:s support. 2015-11-08 13:26:29 -08:00
fincs
3d66e29a5d Merge pull request #211 from Steveice10/fix-139
Fix #139
2015-11-08 21:13:32 +01:00
Steven Smith
891df76804 Fix #139 2015-11-08 12:00:33 -08:00
fincs
c3da3c3057 Merge pull request #210 from Steveice10/mic-fix
Fix MIC cutting off a second of audio.
2015-11-08 20:29:31 +01:00
Steven Smith
abdfec701f Fix MIC cutting off a second of audio. 2015-11-08 11:24:04 -08:00
fincs
7440ca7901 Merge pull request #205 from Steveice10/great-refactor
Rewrite MIC service code, clean up microphone example.
2015-11-08 00:22:47 +01:00
yellows8
fcb370a8c1 Implemented FSUSER_GetProductInfo. 2015-11-07 17:35:54 -05:00
Steven Smith
d2f772c960 Rewrite MIC service code, clean up microphone example. 2015-11-07 08:57:48 -08:00
fincs
3aa4bdf6e9 Fix #206 2015-11-07 12:46:24 +01:00
fincs
24a84a874f Fix some mistakes in 2797540a 2015-11-07 01:52:35 +01:00
fincs
2797540a3d Revise most services to follow these guidelines:
- Each service must have xyzInit/xyzExit (with that name)
- xyzInit/xyzExit use reference counting
- xyzExit returns void
- The utilities in <3ds/result.h> are used instead of manual error checking
- The intrinsics in <3ds/synchronization.h> are used instead of inline asm
- Other miscellaneous changes
  - APT now uses a lightweight lock instead of a mutex
  - Initial handle parameters in PTMU were killed
  - Explicit init'ion to 0 or NULL has been removed for global variables
    since they end up on .bss anyway
  - MIC hasn't been touched because it must be rewritten first
  - CFGNOR needs a slight touch before converting
  - SOC is still to be cleaned up
2015-11-07 01:25:31 +01:00
fincs
e01dfbc392 synchronization.h: Add DSB & several atomic operations 2015-11-07 01:07:11 +01:00
fincs
7b25a0d4d4 Add <3ds/result.h> header - 3DS result codes 2015-11-07 01:04:31 +01:00
fincs
2686b57c88 Fix #204 2015-11-06 20:39:41 +01:00
fincs
b33b4eb2d0 Minor cleanup in os.h/os.c + add osGet3DSliderState() 2015-11-05 12:33:43 +01:00
fincs
2ce51cf3d8 Add more (void) and remove more service handle parameters 2015-11-05 11:48:23 +01:00
fincs
e4775572c2 Merge branch 'master' into great-refactor
# Conflicts:
#	libctru/include/3ds/services/httpc.h
2015-11-01 14:14:01 +01:00
fincs
6b40ea9d8e Roll out a new libctru build 2015-11-01 13:59:34 +01:00
yellows8
facb701ae9 Fixed the use_defaultproxy value used by the http example. 2015-10-29 15:27:39 -04:00
yellows8
27469de3c1 Removed an unused debug line in httpc.c. Set the httpc servhandle to zero in httpcExit(), this fixes using httpcInit() after httpcExit(). Fixed the use_defaultproxy comment in httpc.h. 2015-10-29 15:21:08 -04:00
fincs
7914b41107 Merge branch 'master' into great-refactor 2015-10-28 13:34:17 +01:00
fincs
9360cd6a7d Merge pull request #158 from Lectem/patch-1
Protocol numbers and sockopt IP level
2015-10-28 13:18:37 +01:00
yellows8
76e47c02c8 Changed gfxSwapBuffers() to gfxSwapBuffersGpu() in consoleInit(). This fixes the black-screen issue with the text-console on certain systems(such as old3ds v9.0-v9.2). 2015-10-27 19:34:07 -04:00
smea
ca356af42c Merge branch 'master' of github.com:smealum/ctrulib 2015-10-27 10:59:56 -07:00
smea
af34e85ab2 added support for other cfg service names 2015-10-27 10:59:52 -07:00
fincs
6bdfa1a005 aptInit(): Wait for APT_RUNNING (solves certain timing problems) 2015-10-26 21:19:00 +01:00
fincs
f362ae62a0 More NDSP wavebuf queue fixes 2015-10-24 21:56:40 +02:00
fincs
a35abcb901 APT: fix status event issue that breaks things under certain circumstances 2015-10-24 13:48:15 +02:00
fincs
8cc5dec1b2 NDSP: some more safety checks and fixes 2015-10-24 13:47:31 +02:00
fincs
b3e6a64596 Really really fix NDSP wavebuf scheduling, this time for real 2015-10-24 01:47:23 +02:00
fincs
28f73801cc Really fix NDSP wavebuf scheduling 2015-10-24 01:05:23 +02:00
fincs
ebad126fc0 Fix NDSP wavebuf synchronization issue (thanks to Lectem) 2015-10-24 00:54:57 +02:00
fincs
f06d37659c Merge branch 'master' into great-refactor 2015-10-22 22:56:14 +02:00
fincs
25d177f5d0 Merge pull request #198 from wchill/camera-example
Fix camera example bug and add video capture example
2015-10-22 22:49:44 +02:00
Eric Ahn
dc40c55285 Fix freezing on camera image example, add camera video example 2015-10-22 12:37:12 -05:00
fincs
31382e6a34 Merge branch 'master' into great-refactor 2015-10-22 11:34:33 +02:00
fincs
d4ba60aff9 Merge pull request #196 from wchill/camera-example
Add camera example
2015-10-22 11:33:55 +02:00
Eric Ahn
f39862a3ea Add camera example 2015-10-22 04:31:51 -05:00
fincs
9435477699 Merge pull request #197 from Lectem/y2r_finished
Y2R : Added the missing struct and functions
2015-10-22 11:26:08 +02:00
Lectem
15bca44322 Added the missing struct and functions 2015-10-21 22:12:38 -04:00
smea
89fc70f076 fixed bug which caused gsp shared mem to never be unmapped when using gfx 2015-10-20 23:03:49 -07:00
smea
bba6b90ba0 fixed bug which caused gsp shared mem to never be unmapped when using gfx 2015-10-20 23:03:03 -07:00
fincs
07d5367ed4 Some additions to NDSP code (thanks to Lectem) 2015-10-18 23:06:11 +02:00
fincs
807e3db7f2 Merge branch 'master' into great-refactor 2015-10-11 23:49:25 +02:00
fincs
e12c8ff6a6 Add code to manage New 3DS CPU speedup
# Conflicts:
#	libctru/include/3ds/os.h
#	libctru/include/3ds/services/ptm.h
2015-10-11 23:47:23 +02:00
fincs
942ec4af9b Add code to manage New 3DS CPU speedup 2015-10-11 23:44:10 +02:00
fincs
3cb20a965b Do not include the source folder in Doxygen, tidy up README.md 2015-10-10 02:04:16 +02:00
fincs
839289378b Remove Doxygen version tag due to generated files being changed for every single commit 2015-10-10 01:56:39 +02:00
fincs
5e7fe49422 Merge pull request #193 from Lectem/patch-2
Document the loop behaviour of csndPlaySound
2015-10-10 01:44:27 +02:00
Lectem
f14d5721eb Document the loop behaviour of csndPlaySound 2015-10-09 19:41:29 -04:00
fincs
b5009a3430 Merge branch 'great-refactor' of github.com:smealum/ctrulib into great-refactor 2015-10-10 00:13:42 +02:00
fincs
80c76ee8d7 Add encrypted token for Travis CI documentation building 2015-10-10 00:13:05 +02:00
fincs
818cd4ac39 Merge remote-tracking branch 'Lectem/travis_ci' into great-refactor 2015-10-10 00:10:17 +02:00
Lectem
5f648ff9d4 add commit number and readme.md to doc 2015-10-09 17:58:42 -04:00
Lectem
0c2a52a467 travis CI 2015-10-09 17:58:34 -04:00
Lectem
be64a95c74 Added INADDR_LOOPBACK define 2015-10-09 13:37:01 -04:00
fincs
791da049d5 Merge pull request #191 from Steveice10/great-refactor
Fix DSP_SendData writing the value to the wrong index.
2015-10-09 10:18:08 +02:00
Steven Smith
a5ad20cc46 Fix DSP_SendData writing the value to the wrong index. 2015-10-08 23:04:13 -07:00
fincs
5d33682b7a Merge pull request #190 from Sahnvour/great-refactor
Fix NDSP enums for C++.
2015-10-08 00:54:01 +02:00
Antoine Vugliano
b46e0c6a15 Fix NDSP enums for C++. 2015-10-08 00:43:58 +02:00
fincs
c25e04295a Clean up svc.s 2015-10-07 23:32:20 +02:00
fincs
506d9205f3 Merge pull request #189 from Lectem/fix_cpp
fixed enums for c++
2015-10-07 22:03:08 +02:00
Lectem
13adb6a1c2 fixed enums for c++ 2015-10-07 16:00:19 -04:00
fincs
141703b4ee Fix potential race condition in LightLock_Unlock() (spotted by mtheall) 2015-10-07 21:48:26 +02:00
Lectem
70e7fb35bc fix SOL_SOCKET level options 2015-10-07 15:23:24 -04:00
fincs
0e7755af01 Fix GPUCMD_AddSingleParam() C++ compatibility issue 2015-10-07 20:50:57 +02:00
fincs
8f0f83a417 Merge branch 'master' into great-refactor 2015-10-07 20:48:35 +02:00
fincs
b9e5ddb944 Merge pull request #188 from linkmauve/no-executable-makefiles
Remove the executable bit from examples’ Makefiles
2015-10-07 20:48:05 +02:00
Emmanuel Gil Peyrot
b2e01b17a1 Remove the executable bit from examples’ Makefiles
The normal way to invoke a Makefile is to run `make`, not to run the
Makefile directly.  Besides they would be missing a shebang anyway.
2015-10-06 22:58:03 +01:00
Lectem
1a24e0e054 fixed some netinet/in.h formating 2015-10-06 12:53:29 -04:00
Lectem
034a27adaa Protocol numbers and sockopt options
Protocol numbers are based on both RFC 1700 p.7 and the Internet Assigned Numbers Authority (IANA) http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml

Those are to be used with the added sockopt options. The various options have been
tested with wireshark.
2015-10-06 11:13:29 -04:00
fincs
56a2712501 Docufixes 2015-10-06 11:47:28 +02:00
fincs
d9c133d28a Merge pull request #186 from Steveice10/docs
Finish up basic documentation.
2015-10-06 11:26:37 +02:00
fincs
3f9f492ccc Merge pull request #187 from Lectem/documentation
do not include internal structs in documentation
2015-10-06 11:25:52 +02:00
Lectem
e6dd7ac37d do not include internal structs in doc 2015-10-05 23:00:24 -04:00
Steven Smith
fa5f3783ce Finish up basic documentation. 2015-10-05 18:35:15 -07:00
fincs
f4cef43033 Whoops 2015-10-05 11:40:20 +02:00
fincs
66396c5777 Merge branch 'master' into great-refactor 2015-10-05 11:39:11 +02:00
fincs
0c12a709a9 Merge pull request #184 from Steveice10/docs
Document most of services.
2015-10-05 11:38:40 +02:00
fincs
d9f943ab7b Merge pull request #183 from Lectem/patch-2
Allow documentation for static functions
2015-10-05 11:37:18 +02:00
Steven Smith
173d386795 Document most of services. 2015-10-04 22:27:43 -07:00
Lectem
83d78a0f7c Allow documentation for static functions
This will show static functions such as the ones in the ipc.h header in the documentation.
2015-10-04 18:55:07 -04:00
fincs
c0b4a4bae1 Merge pull request #182 from Steveice10/docs
Finish documentation in include/3ds and include/3ds/util.
2015-10-05 00:07:48 +02:00
Steven Smith
d6962f2122 Doc consistency. 2015-10-04 14:08:02 -07:00
Steven Smith
2656225392 Finish documentation in include/3ds and include/3ds/util. 2015-10-04 13:48:26 -07:00
fincs
7fe0cba7e0 Merge pull request #181 from Steveice10/doxygen-format
Rewrite most documentation to be consistent in format.
2015-10-04 19:42:11 +02:00
Steven Smith
9a3baad7ed Rewrite most documentation to be consistent in format. 2015-10-04 10:37:28 -07:00
fincs
b481e6a446 Merge branch 'master' into great-refactor
Conflicts:
	libctru/include/3ds/services/hid.h
	libctru/include/3ds/services/irrst.h
2015-10-04 17:37:19 +02:00
fincs
41c35375f5 Merge pull request #180 from Steveice10/master
Dynamically allocate shared memory.
2015-10-04 17:32:02 +02:00
Steven Smith
9fe9493701 Dynamically allocate shared memory. 2015-10-04 08:03:23 -07:00
fincs
8e052004d5 Merge branch 'master' into great-refactor
Conflicts:
	libctru/include/3ds/services/gsp.h
	libctru/source/services/gsp.c
2015-10-03 18:46:04 +02:00
fincs
5c7273ef3b Merge pull request #176 from thedax/gspLcd
Implement some services from gsp::Lcd.
2015-10-03 18:42:50 +02:00
fincs
167f27cdc4 Merge pull request #179 from profi200/great-refactor
Renamed TitleList to AM_TitleEntry.
2015-10-03 18:41:10 +02:00
profi200
b9f7f74b58 Renamed TitleList to AM_TitleEntry. 2015-10-03 18:37:47 +02:00
fincs
5788134dc5 Fix broken srv code 2015-10-03 13:41:08 +02:00
fincs
7256f74320 Merge pull request #166 from Lectem/IPCrefactor
IPC refactor
2015-10-03 13:26:54 +02:00
Lectem
a117a287fd Use IPC helpers for srv 2015-10-03 07:23:33 -04:00
Lectem
123d8c6d6e Use IPC helpers for y2r 2015-10-03 06:59:19 -04:00
Lectem
deb7518153 Use IPC helpers for soc 2015-10-03 06:59:17 -04:00
Lectem
fa06930406 Use IPC helpers for qtm 2015-10-03 06:59:15 -04:00
Lectem
362a3fce41 Use IPC helpers for ptm 2015-10-03 06:59:13 -04:00
Lectem
64b32816cf Use IPC helpers for ps 2015-10-03 06:59:11 -04:00
Lectem
8dd1bbb0ce Use IPC helpers for pm 2015-10-03 06:59:10 -04:00
Lectem
d97d5f26a4 Use IPC helpers for ns 2015-10-03 06:59:08 -04:00
Lectem
04dd31220c Use IPC helpers for news 2015-10-03 06:59:06 -04:00
Lectem
63f7918868 Use IPC helpers for mvd 2015-10-03 06:59:04 -04:00
Lectem
1863bc2e35 Use IPC helpers for mic 2015-10-03 06:59:02 -04:00
Lectem
a65ae90b36 Use IPC helpers for irrst 2015-10-03 06:59:00 -04:00
Lectem
8f00d34099 Use IPC helpers for ir 2015-10-03 06:58:58 -04:00
Lectem
8975e848d7 Use IPC helpers for httpc 2015-10-03 06:58:56 -04:00
Lectem
44d9f0e940 Use IPC helpers for hid 2015-10-03 06:58:54 -04:00
Lectem
db9d0a69eb Use IPC helpers for hb 2015-10-03 06:58:52 -04:00
Lectem
5e6440b9b7 Use IPC helpers for fs 2015-10-03 06:58:43 -04:00
Lectem
d074d819ff Use IPC helpers for csnd 2015-10-03 06:56:26 -04:00
Lectem
375f5e497d Use IPC helpers for cfgu 2015-10-03 06:56:24 -04:00
Lectem
383acf6575 Use IPC helpers for cfgnor 2015-10-03 06:56:22 -04:00
Lectem
bc3ef580b2 Use IPC helpers for apt, and update some commands 2015-10-03 06:56:11 -04:00
Lectem
b9d51cbd87 Use IPC helpers for am 2015-10-03 06:43:47 -04:00
Lectem
1c002fc034 Use IPC helpers for ac 2015-10-03 06:43:45 -04:00
fincs
8912773f21 Merge branch 'master' into great-refactor
Conflicts:
	libctru/include/3ds/services/apt.h
	libctru/include/3ds/services/fs.h
	libctru/source/services/apt.c
2015-10-03 12:39:09 +02:00
smea
c765e3b559 Update fs.c 2015-10-02 23:10:38 -07:00
smea
8e43355620 Merge branch 'patch-1' of github.com:smealum/ctrulib 2015-10-02 23:07:46 -07:00
smea
87b9d1302a Added FSUSER_GetMediaType 2015-10-02 23:05:30 -07:00
smea
bfbeb7e6ba Merge pull request #177 from suloku/patch-1
Implement APT_GetProgramID
2015-10-02 22:53:48 -07:00
thedax
04ddaff8cd Return the svcSendSyncRquest value if not equal to zero.
Otherwise, return cmdbuf[1].
2015-10-02 21:01:19 -04:00
fincs
89e0bcd8cc NDSP: add mechanism to load the component from an external source 2015-10-02 23:58:02 +02:00
fincs
f1ce480ed9 Add a work-in-progress API for using Nintendo's default DSP component 2015-10-02 21:54:18 +02:00
thedax
861c0a10b5 Change the enum to use BIT and replace u32 with the enum type. 2015-10-01 13:04:21 -04:00
suloku
b6817008ac Update apt.c 2015-10-01 19:01:31 +02:00
suloku
76e3cb0721 Implement APT_GetProgramID 2015-10-01 17:19:13 +02:00
suloku
2dc74a81ab Update apt.h 2015-10-01 17:18:17 +02:00
thedax
5426fba742 Add an enum to make using the gsp::Lcd service a little nicer. 2015-09-30 20:14:10 -04:00
thedax
7bad79e8b4 Implement some services from gsp::Lcd.
http://www.3dbrew.org/wiki/GSP_Services
2015-09-30 18:21:49 -04:00
fincs
9e43411a0e LightLock: avoid the svcArbitrateAddress() call if no thread is waiting 2015-09-30 22:39:57 +02:00
fincs
abd104fae7 Initialize light primitive system if needed 2015-09-30 00:35:01 +02:00
fincs
72ea825b2d Move __clrex/__ldrex/__strex to synchronization.h 2015-09-30 00:20:05 +02:00
fincs
95f63f280d Add lightweight synchronization primitives 2015-09-30 00:07:42 +02:00
fincs
4603b972fa Merge branch 'master' into great-refactor
Conflicts:
	libctru/include/3ds/services/apt.h
	libctru/source/services/apt.c
2015-09-29 23:21:45 +02:00
fincs
6590ed3fad Merge pull request #170 from Lectem/patch-2
document ArbitrateAddress + update ArbitrationType
2015-09-29 23:18:21 +02:00
smea
56b56955c0 Update apt.h 2015-09-27 21:35:55 -07:00
smea
520332e49e Update apt.h 2015-09-27 21:34:47 -07:00
smea
0c21183b7e Merge pull request #174 from Megazig/master
implement APT_GetAppletInfo
2015-09-27 21:32:58 -07:00
megazig
27b5a49c59 implement APT_GetAppletInfo 2015-09-27 23:30:16 -05:00
smea
c6192c331b Merge branch 'master' of github.com:smealum/ctrulib 2015-09-26 17:03:46 -07:00
smea
066d8873d3 added CFG_Region and CFG_Language enums 2015-09-26 17:03:42 -07:00
fincs
c9a75d6a18 DSP code format cleanup 2015-09-25 22:06:51 +02:00
fincs
649e95cd39 Merge branch 'master' into great-refactor
Conflicts:
	libctru/include/3ds/services/apt.h
	libctru/source/services/apt.c
2015-09-25 16:16:10 +02:00
yellows8
2b467b48b8 Implemented http service-cmd code for GetResponseHeader. 2015-09-24 13:04:18 -04:00
yellows8
31b724a431 Added APT_GetAppletProgramInfo. 2015-09-24 04:26:48 -04:00
fincs
04ab998f7a Merge pull request #172 from Steveice10/master
Fix reading accelerometer and gyroscope entries.
2015-09-23 10:14:55 +02:00
Steven Smith
2836b696bd Fix reading accelerometer and gyroscope entries. 2015-09-22 19:12:52 -07:00
Lectem
0a66043e56 document ArbitrateAddress + update ArbitrationType
This has been tested on n3ds 9.9.
2015-09-18 23:04:20 -04:00
fincs
cd05ca0887 Merge branch 'master' into great-refactor 2015-09-18 23:17:28 +02:00
fincs
bf1f162549 Add romfsInitFromFile() 2015-09-18 23:17:12 +02:00
fincs
6892a71eec Restore service session parameter in FSUSER_Initialize() 2015-09-16 23:58:12 +02:00
fincs
e409f1ea1d Add srvGetServiceHandleDirect() 2015-09-16 23:57:28 +02:00
fincs
04ed53659a Merge branch 'master' into great-refactor 2015-09-15 11:47:55 +02:00
smea
43e1137148 Merge pull request #169 from yuriks/gsp-racecond
GSP: Use atomics in interrupt reading loop
2015-09-14 22:52:08 -07:00
Yuri Kunde Schlesner
d08707e3ca GSP: Use atomics in interrupt reading loop 2015-09-15 02:44:40 -03:00
fincs
aa2153700e Merge branch 'great-refactor' of github.com:smealum/ctrulib into great-refactor 2015-09-13 18:41:18 +02:00
fincs
c99707ada4 Add fragment lighting register names, enumerations, etc 2015-09-13 18:40:37 +02:00
fincs
92cad5f971 Merge pull request #167 from Lectem/fixIPCdoc
Fix IPC_MakeHeader documentation
2015-09-09 23:34:10 +02:00
Lectem
0f89778297 Fixed and enhanced IPC_MakeHeader documentation 2015-09-09 17:30:12 -04:00
fincs
730899bee6 Merge pull request #165 from Lectem/dsp
Dsp fixes
2015-09-09 15:56:21 +02:00
Lectem
a68ee14632 Formatting and fixes for DSP 2015-09-09 09:48:40 -04:00
Lectem
77c843f898 Better enum IPC_BufferRights 2015-09-09 09:11:15 -04:00
fincs
9bf546da45 () -> (void), again 2015-09-09 01:47:30 +02:00
fincs
62aa4d8ab0 Merge branch 'master' into great-refactor 2015-09-09 01:46:00 +02:00
fincs
ce59e60193 Merge pull request #161 from Steveice10/master
Add cam:u support and basic documentation.
2015-09-09 01:45:32 +02:00
Steven Smith
9d3b139255 Add cam:u support and basic documentation. 2015-09-08 16:26:56 -07:00
fincs
0ace45a746 Add some more GPU enum values from the 3dbrew wiki 2015-09-08 20:55:43 +02:00
fincs
428a837224 Merge branch 'master' into great-refactor 2015-09-08 20:54:37 +02:00
fincs
eb87524cd4 Merge pull request #163 from Megazig/master
added new NS_APPID values for latest apt module
2015-09-08 20:54:08 +02:00
fincs
c9ad04f70a Merge pull request #164 from Lectem/dsp
IPC stuff and DSP service commands
2015-09-08 20:53:29 +02:00
Lectem
d227918edc Added DSP service commands 2015-09-08 14:25:51 -04:00
Lectem
0d7072ecd2 Added IPC helpers 2015-09-08 14:25:39 -04:00
megazig
6d1f409dfd added new NS_APPID values for latest apt module 2015-09-08 12:02:45 -05:00
fincs
fded98b9ed Sync register names with 3dbrew wiki 2015-09-07 19:31:02 +02:00
fincs
c594170fca Rename GX commands 2015-09-07 12:53:37 +02:00
fincs
530849a4b0 Merge branch 'master' into great-refactor 2015-09-07 12:38:09 +02:00
fincs
e352f3befd Change default linear/VRAM mem alignment to 0x80 (for GPU textures) 2015-09-07 12:37:55 +02:00
fincs
06f7aeb7c4 Fix examples 2015-09-06 18:22:12 +02:00
fincs
0d7a7f4d7d Add missing (void) to functions without arguments 2015-09-06 18:13:31 +02:00
fincs
1817f90c6d Remove service handle parameter from GSPGPU IPC wrappers 2015-09-06 18:04:03 +02:00
fincs
053c71ad08 Remove service handle parameter from FSUSER IPC wrappers 2015-09-06 17:54:36 +02:00
fincs
9b1e6bfc39 Remove service handle parameter from APT IPC wrappers 2015-09-06 17:41:47 +02:00
fincs
15af3eff30 Merge branch 'master' into great-refactor
Conflicts:
	libctru/source/gpu/gpu.c
2015-09-05 22:14:34 +02:00
fincs
57eb921f1a Merge pull request #162 from yuriks/float-conversions
GPU: Clean up float conversion functions
2015-09-05 22:09:33 +02:00
Yuri Kunde Schlesner
407dcd141d GPU: Clean up float conversion functions 2015-09-05 16:55:45 -03:00
fincs
2707bfad93 Remove the broken GPU reset sequence which is never executed 2015-09-05 21:31:16 +02:00
fincs
604b1f4b43 Make some internal shader loading helper functions private/static 2015-09-05 20:30:24 +02:00
fincs
696ac996d1 Remove u32* gxbuf parameter in GX/GPU functions 2015-09-05 20:24:55 +02:00
fincs
5fd4a726ff Start the Great Refactor with some GPU refactoring/deprecating 2015-09-05 20:16:47 +02:00
fincs
11a5001f33 Correct GPU_DrawArray() parameter order, fix GPU examples 2015-09-05 18:02:06 +02:00
fincs
2e43fd1a40 Merge pull request #155 from Subv/vertex_offset
Use register 0x22A (GPUREG_DRAW_VERTEX_OFFSET) when using GPU_DrawArrays
2015-09-05 17:59:37 +02:00
fincs
6b45f5a01c Merge pull request #157 from endrift/master
Fix building on FreeBSD
2015-09-05 17:50:12 +02:00
fincs
e7e21fa9d5 Merge pull request #159 from Lectem/documentation
documentation for the soc service and svcCreateMemoryBlock
2015-09-05 17:46:49 +02:00
fincs
2a0e9655a6 Merge pull request #156 from Dazzozo/yay-svcs
svc: add a few more SVC bindings
2015-09-05 17:45:37 +02:00
fincs
50541234b4 Merge pull request #150 from Megazig/master
PS service key type and socket functionality
2015-09-05 17:44:26 +02:00
Lectem
98d937ebc1 Added getThreadStaticBuffers for IPC 2015-09-01 15:28:52 -04:00
Lectem
d10fc00786 Added pseudo handles for current proc and thread 2015-08-30 23:30:53 -04:00
Lectem
6ca0ab50dd documentation for svcCreateMemoryBlock 2015-08-28 14:55:49 -04:00
Lectem
84d368918e documentation for the soc service 2015-08-28 14:55:40 -04:00
fincs
6b3e38de77 Add RomFS example 2015-08-28 01:19:19 +02:00
fincs
a046b5a19f romfs_dev.c: use correct file closing function 2015-08-27 21:16:27 +02:00
fincs
570ea2ebd2 Add work in progress RomFS driver/devoptab 2015-08-27 20:53:08 +02:00
Jeffrey Pfau
0eac970aa1 Fix building on FreeBSD 2015-08-27 01:04:32 -07:00
Daz Jones
debe7a7553 svc: add a few more SVC bindings
Mostly debug and IPC related.
2015-08-23 20:29:23 +01:00
Subv
ad3dd538dc Use register 0x22A (GPUREG_DRAW_VERTEX_OFFSET) when using GPU_DrawArrays.
It will set the index of the first vertex to draw, akin to the "first" parameter of glDrawArrays.
2015-08-22 22:18:33 -05:00
fincs
24fd71c4ad GPU_KEEP -> GPU_STENCIL_KEEP in GPU examples 2015-08-22 23:14:38 +02:00
fincs
99cbb56491 Merge remote-tracking branch 'pr149/master' 2015-08-22 23:12:32 +02:00
fincs
6f9edd9bbe Merge pull request #154 from Subv/tev_buffer_color
GPU: Added code to manipulate the combiner buffer.
2015-08-22 21:20:37 +02:00
fincs
8ec9b514b0 Merge pull request #152 from Subv/stencil
Added the rest of the stencil operations and corrected their names.
2015-08-22 21:20:31 +02:00
Subv
1738893d05 GPU: Added code to manipulate the combiner buffer.
You can set an initial color value with GPUREG_TEXENV_BUFFER_COLOR, then use GPU_SetCombinerBufferWrite with GPU_TEV_BUFFER_WRITE_CONFIG to allow/disallow the TEV stages to write their color outputs to the buffer.

You can retrieve the previous buffer color using GPU_PREVIOUS_BUFFER as color source in the TEV config.
2015-08-22 11:28:30 -05:00
Subv
f1b641a4ad Added the rest of the stencil operations and corrected their names. 2015-08-21 15:10:13 -05:00
fincs
35a36b1885 Revert g_srv_handle change because srvGetSessionHandle() already existed 2015-08-19 13:29:24 +02:00
megazig
9e597a7af9 update definition of gethostbyaddr 2015-08-18 17:15:21 -05:00
megazig
8e7606692d move h_errno definition to soc_common
add h_addr member to hostent structure
implement gethostbyaddr
2015-08-18 16:55:50 -05:00
megazig
033b353128 add key type 9 (NFC) for ps service 2015-08-18 16:54:22 -05:00
smea
c49d5f49c2 Merge branch 'master' of github.com:smealum/ctrulib 2015-08-17 21:31:04 -07:00
smea
91c98308e2 am:sys stuff, g_serv_handle non static and qtm example label 2015-08-17 21:31:00 -07:00
Luke Street
1a1f3bb932 Fix gpu example Makefiles for latest picasso 2015-08-17 12:01:34 -04:00
fincs
7d63ab5050 Merge pull request #146 from Lectem/fixy2r
Fixed transfer unit and gap type and added a warning
2015-08-10 00:58:54 +02:00
Lectem
8d36f3f03b Fixed transfer unit and gap type and added a warning 2015-08-10 00:44:55 +02:00
fincs
40d972d5ba Revert 73e0267a because it breaks all existing GPU code 2015-08-04 19:31:46 +02:00
smea
9f6f7a57ec Merge pull request #143 from aroulin/fix-gpu-reset
Fix GPU_Reset having wrong GSP command buffer
2015-07-24 13:15:58 -07:00
aroulin
73e0267ae4 Fix GPU_Reset having wrong GSP command buffer 2015-07-24 21:49:49 +02:00
fincs
cc8d6d7427 Merge pull request #142 from Lectem/documentation
Some documentation
2015-07-23 22:55:24 +02:00
Lectem
ea7b0eac5d added gpu examples to doc 2015-07-23 22:41:13 +02:00
Lectem
2d7a53d75f Documented GX TRANSFER_SCALE and FILL_CONTROL 2015-07-23 21:54:48 +02:00
Lectem
894d5342a1 fixed y2r doc and added csnd pan/vol ranges 2015-07-23 21:26:37 +02:00
fincs
bf7d686e88 Add new GPU examples 2015-07-22 19:41:59 +02:00
fincs
10b81077e3 Merge pull request #140 from Lectem/patch-3
Fixed wrap_s and wrap_t
2015-07-20 00:52:10 +02:00
Lectem
4109bf5b66 Fixed wrap_s and wrap_t
Those were swapped.
2015-07-20 00:20:35 +02:00
smea
096bbdf401 added ac:i support 2015-07-15 23:40:11 -07:00
smea
acdb6e5c72 added support for qtm:s and qtm:sp 2015-07-13 23:01:50 -07:00
smea
00eb8c38dc added hid:SPVR support 2015-07-13 23:00:52 -07:00
smea
e539c83d58 Merge branch 'master' of github.com:smealum/ctrulib 2015-07-12 15:31:57 -07:00
smea
ea88f92464 fixed SOC device madness 2015-07-12 15:19:36 -07:00
fincs
d861ec4157 Merge pull request #137 from Lectem/patch-2
Fixed command code for Y2RU_SetConversionParams
2015-07-11 16:00:26 +02:00
Lectem
d0dd07d8f4 Fixed command code for Y2RU_SetConversionParams 2015-07-11 15:51:06 +02:00
smea
9fac0a0ea1 socMemhandle should be closed even if shutdown command fails 2015-07-07 19:52:18 -07:00
fincs
e9651a2869 Merge pull request #136 from Lectem/wrap_modes
added texture border color
2015-07-08 00:48:23 +02:00
Lectem
a204c0def7 added texture border color 2015-07-08 00:17:25 +02:00
Lectem
0774378190 added texture border color 2015-07-08 00:03:01 +02:00
fincs
c46562d54b Clean up libapplet_launch example 2015-07-07 23:46:08 +02:00
fincs
1ff4bb5e92 Merge pull request #135 from Lectem/sound_example_update
updated sound example for new API
2015-07-07 23:26:50 +02:00
Lectem
44db57bd6d updated sound example for new API 2015-07-07 22:48:03 +02:00
fincs
17b0f88dcb Merge pull request #134 from Lectem/wrap_modes
Added GPU_CLAMP_TO_BORDER and GPU_MIRRORED_REPEAT
2015-07-07 22:41:20 +02:00
Lectem
594215e5e5 Added GPU_CLAMP_TO_BORDER and GPU_MIRRORED_REPEAT 2015-07-07 22:25:00 +02:00
yellows8
8e620c269d Fixed socket() error handling when cmdbuf[2] is actually an error-code, not a handle. In socket(), write SYNC_ERROR to errno when an error occurs due to cmdbuf[1]. 2015-07-02 18:53:16 -04:00
fincs
585f84276a Merge pull request #133 from linkmauve/cube-directions
Use more sensible input to move the cube in the gpu example
2015-06-28 19:01:53 +02:00
fincs
a7e9a858dd Merge pull request #132 from Lectem/documentation
Documentation
2015-06-28 19:01:46 +02:00
Emmanuel Gil Peyrot
986f1a7068 Use more sensible input to move the cube in the gpu example. 2015-06-28 17:34:16 +01:00
Lectem
63472635ff added examples to documentation 2015-06-28 14:13:57 +02:00
fincs
ee210d1963 Merge pull request #131 from Lectem/fix_heaps_warning
fix warning types not matching
2015-06-28 13:36:09 +02:00
Lectem
c62d54d831 fix arning types not matching 2015-06-28 13:33:26 +02:00
fincs
68fbd06375 Do not signal APTHOOK_ONRESTORE when the app is being closed 2015-06-28 11:30:57 +02:00
Lectem
2b385581b9 svc.h : updated MemOp enum and documented half of the file 2015-06-28 02:12:25 +02:00
Lectem
0c8c272bf4 updated y2r documentation 2015-06-26 23:00:12 +02:00
Lectem
ac9b5dbb61 os documentation 2015-06-26 22:58:22 +02:00
Lectem
8c053770a2 gfx documentation 2015-06-26 22:27:18 +02:00
plutoo
266ab2fe42 Merge pull request #129 from Lectem/firm_version_fix
fix firm/kernel version and added defines
2015-06-26 22:25:19 +02:00
Lectem
5b6d9b1ad9 fix firm/kernel version and added defines 2015-06-26 22:18:15 +02:00
yellows8
2791ab4850 Merge pull request #127 from infinicore/linklevel
OS: Add function to get wifi strength.
2015-06-23 16:06:38 -04:00
infinicore
ec64beffbd os: add function to get link level 2015-06-23 19:13:30 +00:00
fincs
66b2e4548e Merge pull request #126 from yuriks/y2r
Add y2r:u commands
2015-06-22 00:22:41 +02:00
Lectem
364b9834db Documented y2r
Also aligned enums for readability and changed SetCoefficient to
SetCoefficients
2015-06-22 00:07:18 +02:00
Yuri Kunde Schlesner
8a76010988 Add y2r:u commands 2015-06-21 07:25:28 -03:00
fincs
a7aba7feae (I forgot to update the comment in the header file) 2015-06-20 18:21:06 +02:00
fincs
de18776fac Clean up and simplify APT_CheckNew3DS 2015-06-20 18:17:44 +02:00
fincs
4ebb95cc2f Run initialization/shutdown code in irrstInit/irrstExit when needed 2015-06-20 17:07:06 +02:00
fincs
7706270720 Some minor APT fixes (capture typo, race condition fix, etc) 2015-06-20 17:06:32 +02:00
fincs
e7ea04e532 Merge pull request #124 from Lectem/gx_fill_enum
added GX_SetMemoryFill control enums
2015-06-06 22:52:51 +02:00
Lectem
de687695cf added GX_SetMemoryFill control enums 2015-06-03 21:17:38 +02:00
smea
37ae484338 Merge pull request #58 from Aurelio92/example-BothScreenText
Added BothScreenText example
2015-05-31 09:37:14 -07:00
smea
5bb733455b Merge pull request #59 from Aurelio92/example-MultipleWindowsText
Added MultipleWindowsText
2015-05-31 09:35:39 -07:00
smea
988cf9f905 Merge pull request #60 from Aurelio92/example-ColoredText
Added ColoredText example
2015-05-31 09:33:37 -07:00
smea
31e0f2ee07 Merge pull request #122 from Lectem/thread_svcs
threads svcs
2015-05-30 09:07:41 -07:00
yellows8
0ec23dc90a In APT_CheckNew3DS_*, properly load+check the retval from the cmdbuf when svcSendSyncRequest was successful. In APT_CheckNew3DS(), added code to check for out nullptr, and code to clear out. 2015-05-29 17:15:55 -04:00
Lectem
6ca5285d10 better svcGet*Info 2015-05-28 21:04:52 +02:00
yellows8
f631036063 Added code for getting the session handles for am, fs, and srv. Updated ACU_WaitInternetConnection() so that it waits for outval!=0 instead of outval==1, this fixes new3ds support for this func. 2015-05-26 13:49:37 -04:00
smea
79e2efdc0c Update svc.h
cf PR #123
2015-05-25 23:05:14 -07:00
smea
c03688cfd4 Merge pull request #123 from 173210/master
svc.h: Remove volatile for getThreadLocalStorage
2015-05-25 23:04:20 -07:00
173210
9ad62755b7 svc.h: Remove volatile for getThreadLocalStorage 2015-05-26 14:48:20 +09:00
Aurelio Mannara
4130bb71d0 Updated for latest ctrulib 2015-05-25 22:42:46 +02:00
Aurelio Mannara
f32d31a806 Updated for latest ctrulib 2015-05-25 22:40:31 +02:00
Aurelio Mannara
887a05a765 Updated for latest ctrulib 2015-05-25 22:35:55 +02:00
Lectem
f3bb5339f7 threads svcs 2015-05-25 21:11:16 +02:00
smea
308aa7aaa8 Merge pull request #65 from Aurelio92/example-RTC
Added RTC example
2015-05-25 11:28:35 -07:00
Aurelio Mannara
1f375c0a75 Update for latest ctrulib
Now the example compiles using the latest ctrulib. It also uses
standard C Time library to get date and time
2015-05-25 10:29:06 +02:00
smea
33eb72e071 Merge pull request #112 from xerpi/master
GX_SetDisplayTransfer enums, GPU_SetTexture bug, GPU sample commented
2015-05-24 21:36:25 -07:00
smea
5747dcbd0d Merge pull request #120 from Lectem/texenv_operands
added missing texenv op
2015-05-24 21:34:42 -07:00
smea
9f9139a8d3 Merge pull request #121 from Steveice10/master
Update NS_APPID values.
2015-05-23 11:00:08 -07:00
Steven Smith
40d0739ade Update NS_APPID values. 2015-05-23 10:57:40 -07:00
fincs
8ac3549abf Fix APT applet launch code [regression caused by c75ed65] 2015-05-23 18:46:56 +02:00
fincs
da680e0503 Add APT event hooking mechanism 2015-05-22 21:56:47 +02:00
smea
e2f8011f69 Merge pull request #115 from Steveice10/master
Add news:u commands.
2015-05-19 15:40:35 -07:00
Lectem
53b03ef6c5 use GPU prefix instead of GL 2015-05-16 21:53:10 +02:00
Lectem
7c26d8e68d added missing texenv op 2015-05-16 21:43:34 +02:00
fincs
e2b1da4d80 Minor APT behaviour change 2015-05-13 14:10:25 +02:00
smea
7e10620b7f Merge pull request #119 from archshift/patch-1
Add missing httpcAddRequestHeaderField to httpc.h
2015-05-12 22:55:13 -07:00
archshift
e66e417ce0 Add missing httpcAddRequestHeaderField to httpc.h 2015-05-12 22:29:40 -07:00
smea
d30d14dff4 Merge pull request #116 from profi200/master
Added AM_GetCiaFileInfo() and FSUSER_DeleteDirectoryRecursively().
2015-05-09 13:46:56 -07:00
plutoo
1b1c2a0cea Whitespace fix 2015-05-06 23:12:32 +02:00
plutoo
bf4364af0e Fix svcCreateAddressArbiter 2015-05-06 23:10:44 +02:00
fincs
350cb955b2 Added RUNFLAG_APTREINIT for supporting environments that require APT reinitialization 2015-05-06 22:01:40 +02:00
fincs
004dfff8bd Added some srv commands 2015-05-06 21:59:47 +02:00
profi200
df46a2c7dd Added AM_GetCiaFileInfo() and FSUSER_DeleteDirectoryRecursively(). 2015-05-04 19:29:13 +02:00
fincs
5a28a7398a Merge branch 'master' of github.com:smealum/ctrulib 2015-04-15 22:17:53 +02:00
fincs
c443c34ad0 Major CSND overhaul, see details:
- Missing commands are now added
- Volume and pan are now available in csndPlaySound
- Minor optimization that saves one memcpy per command
- Minor optimization in shared mem channel index computation
2015-04-15 22:17:19 +02:00
Steven Smith
6f37ad03f7 Add news:u commands. 2015-04-14 12:37:20 -07:00
plutoo
71f330aad2 Merge pull request #114 from Steveice10/master
Remove MEMOP_FREE_LINEAR
2015-04-13 22:07:45 +02:00
Steven Smith
3adff173cd Remove MEMOP_FREE_LINEAR 2015-04-13 12:50:02 -07:00
fincs
7b059d9395 svc.h/s cleanup; add svcWriteProcessMemory & svcControlProcessMemory 2015-04-13 17:56:38 +02:00
smea
16732899d5 Merge pull request #113 from archshift/backdoor
Implement svcBackdoor in SVCs
2015-04-04 13:53:21 -07:00
archshift
7bb4fc8547 Implement svcBackdoor in SVCs 2015-04-03 14:37:09 -07:00
Sergi Granell
cf7082ad1b Added GX_SetDisplayTransfer flags enums and define helpers
Solved GPU_SetTexture bug (width and height was swapped)
Comment the GPU sample a bit more (to make it easier to understand)
2015-04-03 18:05:31 +02:00
plutoo
7d940da23a Merge pull request #106 from profi200/master
Replaced AM_installFIRM() with AM_installNativeFirm().
2015-03-28 22:24:53 +01:00
profi200
4ab2b1a363 Replaced AM_installFIRM() with AM_installNativeFirm(). 2015-03-28 22:02:46 +01:00
Dave Murphy
adcea034a5 Merge pull request #109 from Steveice10/master
Reset GPUCMD buffer after running GPU_Reset commands.
2015-03-25 08:09:34 +00:00
Steven Smith
c70fb0feb1 Reset GPUCMD buffer after running GPU_Reset commands. 2015-03-24 20:27:24 -07:00
smea
d22d0a9345 fix bug when alignment value too big 2015-03-19 12:29:47 -07:00
mtheall
b30f553dd0 Stricter checks in MemPool::Allocate(). 2015-03-17 13:49:47 -05:00
Dave Murphy
7a71787670 include data folder in source release, 0.5.0 is next release 2015-03-17 10:48:53 +00:00
Dave Murphy
426258a7f7 exclude 3dsx files in bin directory 2015-03-17 10:43:52 +00:00
Dave Murphy
653f126065 use python3 2015-03-17 10:42:51 +00:00
yellows8
5b5bdb1bd1 Fixed security failure /w alignment in MemPool::Allocate(). 2015-03-16 20:59:59 -04:00
Dave Murphy
2fed2f4241 Merge branch 'gpu_revamp' 2015-03-11 17:06:49 +00:00
Dave Murphy
a6831d177c get rid of strict aliasing 2015-03-11 17:06:34 +00:00
Dave Murphy
5c0a6ceda6 Merge branch 'master' into gpu_revamp 2015-03-11 16:46:49 +00:00
Dave Murphy
85261971db use correct flags 2015-03-11 16:46:24 +00:00
fincs
cd8fa3a26a Merge pull request #104 from patois/master
add SVC 0x61, 0x62, 0x63, 0x64
2015-03-10 13:10:33 +01:00
patois
57f139799c add syscalls 0x61, 0x62, 0x63, 0x64 2015-03-10 12:43:15 +01:00
Dave Murphy
c71637d9ca Merge pull request #101 from profi200/master
Implemented functions to start system applets.
2015-03-08 01:07:34 +00:00
profi200
1a6bdc38a9 Implemented functions to start system applets. 2015-03-07 22:10:18 +01:00
fincs
b085943d4d Correct shaderProgramFree() and DVLB_Free() 2015-03-07 20:39:28 +01:00
fincs
624dc1c1b3 GPU_DepthRange() -> GPU_DepthMap() 2015-03-07 16:59:52 +01:00
fincs
44d2606039 Minor correction in GPU_SendShaderCode/SendOperandDescriptors 2015-03-06 16:32:57 +01:00
fincs
0eed263bba Merge branch 'master' into gpu_revamp 2015-03-06 16:32:13 +01:00
Dave Murphy
b275d5715b add svcGetProcessorID 2015-03-03 11:04:00 +00:00
Dave Murphy
e5edb0fa28 Merge pull request #100 from profi200/master
Added AM_ListTitles(), replace bitwise ands with u32 casts, replaced snprint() ...
2015-03-02 21:56:27 +00:00
fincs
54473e5487 Merge branch 'master' into gpu_revamp 2015-03-02 17:03:58 +01:00
Dave Murphy
1f52ac344d adjust stack before appInit 2015-03-02 10:41:52 +00:00
fincs
386a700673 Fix GPU example 2015-03-02 00:54:29 +01:00
fincs
9abad5bbaf Update GPU example (untested) 2015-03-01 23:20:01 +01:00
fincs
b175fdbca5 Correct error in GPU_SetFloatUniform 2015-03-01 23:19:29 +01:00
fincs
0f4ee280d2 Merge branch 'master' into gpu_revamp 2015-03-01 22:46:24 +01:00
profi200
ed3045ab6a Fixed AM_InstallFIRM(). See 3dbrew. 2015-03-01 21:52:19 +01:00
profi200
02b68eb1ae Change it back to snprintf(). 2015-03-01 20:28:22 +01:00
profi200
a2d2df17f9 Minifix. 2015-03-01 19:57:57 +01:00
profi200
c998b5d035 Added AM_ListTitles(), removed nonsense bitwise ands, replaced sprint() with memcpy() (overflow safe) and made utf.h aveilable for apps. 2015-03-01 19:49:38 +01:00
Dave Murphy
341f10b057 Merge pull request #88 from Steveice10/master
Add AM_GetTitleProductCode, FSUSER_GetNandArchiveResource, and fix missing service imports in 3ds.h.
2015-03-01 18:19:14 +00:00
Dave Murphy
11cd337d36 Merge branch 'master' into gpu_revamp 2015-03-01 16:56:34 +00:00
Dave Murphy
4caa875489 fix smdh building 2015-03-01 16:56:10 +00:00
Dave Murphy
82affd3f77 Merge branch 'master' into gpu_revamp 2015-03-01 16:40:12 +00:00
Dave Murphy
6d25d6d335 add smdh embedding 2015-03-01 16:39:34 +00:00
Steven Smith
20a1a610da Add AM_GetTitleProductCode, FSUSER_GetNandArchiveResource, and fix missing service imports in 3ds.h. 2015-02-28 23:13:21 -08:00
Dave Murphy
ce6fce07a1 Merge pull request #97 from yuriks/more-syscalls
Add a few more SVC call stubs
2015-02-28 00:59:28 +00:00
Yuri Kunde Schlesner
9ee96105f6 Add a few more SVC call stubs 2015-02-27 21:20:55 -03:00
Dave Murphy
8e031b1080 ensure mode changes 2015-02-27 20:50:03 +00:00
Dave Murphy
36f82b8bb8 fix typo 2015-02-26 08:37:23 +00:00
Dave Murphy
02ff590b5a add intermediate Makefile for input examples 2015-02-25 15:36:07 +00:00
Dave Murphy
c5fa04e845 add thread event example 2015-02-25 15:28:30 +00:00
Dave Murphy
aa98a0796b use variable to recurse make 2015-02-23 19:25:59 +00:00
Dave Murphy
6822f89c4c update for latest libctru 2015-02-23 19:25:31 +00:00
Dave Murphy
403c277bf8 switch to hard float 2015-02-23 19:24:59 +00:00
Dave Murphy
d28e3bf1da Merge pull request #64 from Aurelio92/example-TouchScreen
Added TouchScreen example
2015-02-23 19:21:33 +00:00
Dave Murphy
992b23040c implement gettimeofday 2015-02-23 17:41:10 +00:00
Dave Murphy
da57493368 update aemstro reflog 2015-02-22 22:37:17 +00:00
smea
f39571f542 Merge pull request #95 from elhobbs/master
updated shader for current aemstro
2015-02-22 12:04:09 -08:00
Eric Hobbs
fa41041abf fixed lighting in shader for gpu example 2015-02-22 14:55:04 -05:00
Eric Hobbs
dcd1ccf939 updated shader for current aemstro 2015-02-22 13:38:58 -05:00
Dave Murphy
d9552e95dc bump version 2015-02-19 18:51:05 +00:00
Dave Murphy
8ac08bad4e default loop mode is one shot 2015-02-19 18:48:31 +00:00
Dave Murphy
b40d605660 Merge branch 'master' into gpu_revamp 2015-02-19 18:35:10 +00:00
Dave Murphy
a8b20600cf rename example 2015-02-19 10:26:34 +00:00
Dave Murphy
56317483fb Merge pull request #63 from Aurelio92/example-CirclePad
Added example for reading input
2015-02-18 17:50:10 +00:00
Aurelio Mannara
24bceda509 Merged with Pad example
Also updated to make it work with latest ctrulib and devkitARM
2015-02-18 18:34:58 +01:00
Dave Murphy
9a08d26e03 more relevant text 2015-02-18 15:09:15 +00:00
Dave Murphy
257f77a05d simplify imagemagick conversion 2015-02-18 15:06:09 +00:00
Dave Murphy
6be71c218e update for latest libctru 2015-02-18 15:05:29 +00:00
Dave Murphy
131d3380ac use variable to recurse make 2015-02-18 15:04:34 +00:00
Dave Murphy
83c496bcdb use hard float abi 2015-02-18 15:04:04 +00:00
Dave Murphy
64d918a719 Merge pull request #61 from Aurelio92/example-24bit_Bitmap
Added 24bit Bitmap example
2015-02-18 14:58:08 +00:00
Dave Murphy
5a17bfd631 don't need + when using variable 2015-02-18 12:01:03 +00:00
Dave Murphy
71788b4a66 use variable to recurse make 2015-02-18 00:34:55 +00:00
Dave Murphy
0ae00d4fdc Merge pull request #94 from gudenau/master
Fixed a typo
2015-02-17 02:38:35 +00:00
gudenau
bb1ca9e63a Fixed a type-o 2015-02-16 18:47:40 -06:00
smea
8d274afd13 fixed shaderProgramUse so that programs without geoshaders will play nice with those with 2015-01-03 18:06:22 -08:00
smea
100f72c193 fixed linear/vram mem align 2015-01-03 18:00:55 -08:00
smea
b7ab3f9a54 shbin.c cleanup, shaderInstanceGetUniformLocation 2015-01-02 21:22:37 -08:00
smea
5df4902c4e GPU_SetUniform -> GPU_SetFloatUniform 2015-01-02 21:16:17 -08:00
smea
8b84747df3 updated gpu.c to use new convention 2015-01-02 21:14:03 -08:00
smea
d195917ec1 minifix + geoshader stride 2015-01-02 19:39:37 -08:00
smea
a1830973c7 minifix 2015-01-02 19:29:02 -08:00
smea
80e6bcfd34 shaderProgram 2015-01-02 19:16:23 -08:00
smea
cd05cc45ff started work on shaderProgram 2015-01-02 17:15:44 -08:00
smea
28fee06006 minifix 2015-01-02 16:41:07 -08:00
smea
1b80b69e73 Merge branch 'master' into gpu_revamp 2014-12-31 13:35:40 -08:00
smea
3c4c2a6c04 Merge branch 'master' into gpu_revamp 2014-12-31 13:34:25 -08:00
smea
05e886c9fa fixed up DVLE_SendOutmap 2014-12-27 11:22:48 -08:00
Aurelio92
f8c73bdbd6 Merge pull request #3 from WinterMute/example-24bit_Bitmap
Example 24bit bitmap
2014-12-21 13:25:36 +01:00
Dave Murphy
73b76cad57 wrong float abi 2014-12-19 10:07:53 +00:00
Dave Murphy
b3f8a99426 use new image 2014-12-19 10:07:28 +00:00
smea
e3017fa304 made small adjustments to shdr.c 2014-12-18 22:35:13 -08:00
smea
db11dd9bbc GPUCMD_AddMaskedWrite, GPUCMD_AddWrite, GPUCMD_AddMaskedWrites, GPUCMD_AddWrites, GPUCMD_AddMaskedIncrementalWrites, GPUCMD_AddIncrementalWrites 2014-12-18 21:11:53 -08:00
smea
91f01e8280 added registers.h (for real this time) 2014-12-17 22:48:05 -08:00
smea
5f10c8ee74 added registers.h 2014-12-17 22:47:41 -08:00
Dave Murphy
2177ad8619 replace picture with something nicer 2014-12-16 17:13:46 +00:00
Aurelio92
41a9549187 Merge pull request #2 from WinterMute/example-24bit_Bitmap
check for ImageMagick and fail gracefully
2014-12-15 16:47:58 +01:00
Dave Murphy
de38b29ed4 check for ImageMagick and fail gracefully 2014-12-15 15:39:16 +00:00
Aurelio92
83cdef027a Merge pull request #1 from WinterMute/example-24bit_Bitmap
Example 24bit bitmap
2014-12-15 13:52:03 +01:00
Dave Murphy
cbb00e413d Automate graphics conversion
Makefile:

- Don't set DATA, we're no longer embedding files from there directly

- Add folders from GRAPHICS to VPATH. This is how make finds the source files

- Add PNGFILES variable containing all png files from GRAPHICS folders

- Add png files to OFILES with extension changed to rgb.o

- Add rule to create .rgb.o fromn .rgb using normal bin2o macro

- Add rule to create .rgb from .png using imagemagick

source/main.c

- the extension has changed to .rgb so the header is now <filename>_rgb.h and the variables end in _rgb
2014-12-15 12:35:03 +00:00
Dave Murphy
75d62ef1e3 delete generated bin file, move png to gfx folder 2014-12-15 11:59:54 +00:00
Aurelio Mannara
adeffd27ea Fixed a little mess I made with dir-names :D 2014-12-15 09:59:44 +01:00
Aurelio Mannara
eb1d6013cf Fixed a second little mess I made with dir-names 2014-12-15 09:56:03 +01:00
Aurelio Mannara
8533f4d706 Fixed a little mess I made with dir-names :D 2014-12-15 09:55:29 +01:00
Aurelio Mannara
ba6c48caac Fixed a little mess I made with dir-names :D 2014-12-15 09:52:51 +01:00
Aurelio Mannara
4ca16228da Fixed a little mess I made with dir-names :D 2014-12-15 09:51:25 +01:00
Aurelio Mannara
0f3afec935 Used *.c extension and lower case dir name 2014-12-15 09:35:49 +01:00
Aurelio Mannara
9887432e1d Used *.c extension and lower case dir name 2014-12-15 09:35:00 +01:00
Aurelio Mannara
0d47cd1503 Used *.c extension and lower case dir name 2014-12-15 09:34:02 +01:00
Aurelio Mannara
7a8c9c78e7 Used *.c extension and lower case dir name 2014-12-15 09:31:25 +01:00
Aurelio Mannara
5cf80d1690 Used *.c extension and lower case dir name 2014-12-15 09:30:23 +01:00
Aurelio Mannara
31dfb6a92e Used *.c extension and lower case dir name 2014-12-15 09:29:33 +01:00
Aurelio Mannara
6bd1ef0de6 Used *.c extension and lower case dir name 2014-12-15 09:26:11 +01:00
Aurelio Mannara
c58179ef32 Used *.c extension and lower case dir name 2014-12-15 09:24:02 +01:00
Aurelio Mannara
36f36fcea9 Used *.c extension and lower case dir name 2014-12-15 09:19:55 +01:00
Aurelio Mannara
b4cbe825e7 Used *.c extension and lower case dir name 2014-12-15 09:15:32 +01:00
Aurelio Mannara
fd3d64aa16 Used *.c extension and lower case dir name 2014-12-15 09:14:46 +01:00
Aurelio Mannara
d42cabd734 Used *.c extension and lower case dir name 2014-12-15 09:13:59 +01:00
Aurelio Mannara
117738ee5e Added RTC example
This example shows how to get os time and prints it on top screen
2014-12-14 18:11:30 +01:00
Aurelio Mannara
2cf9242785 Added TouchScreen example
This example shows how to get touch coordinates and prints them on top
screen
2014-12-14 18:10:25 +01:00
Aurelio Mannara
e82e9ce975 Added CirclePad example
This example shows how to get Circle Pad position and prints them on
the top screen
2014-12-14 18:09:02 +01:00
Aurelio Mannara
6218327628 Added 24bit Bitmap example
This example shows how to draw a 24bit bitmap on bottom screen
2014-12-14 18:03:27 +01:00
Aurelio Mannara
23c9e4b6da Added ColoredText example
This example shows how to print colored text using ansi escape sequences
2014-12-14 18:00:45 +01:00
Aurelio Mannara
850a6bf5e7 Added MultipleWindowsText
This example shows how to create multiple PrintConsole with custom
windows and print in them
2014-12-14 17:44:33 +01:00
Aurelio Mannara
28f97ad822 Added BothScreenText example
This example shows how to initialize and use a PrintConsole on both
screens
2014-12-14 17:36:19 +01:00
306 changed files with 46098 additions and 18339 deletions

21
.github/workflows/build.yaml vendored Normal file
View File

@ -0,0 +1,21 @@
name: Build libctru
on:
push:
branches: [ master ]
pull_request:
jobs:
build:
name: Test build
runs-on: ubuntu-latest
container:
image: 'devkitpro/devkitarm'
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: build
run: make -C libctru

40
.github/workflows/doxygen.yaml vendored Normal file
View File

@ -0,0 +1,40 @@
name: Build documentation
on:
push:
tags: [ v* ]
jobs:
build:
name: Build documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false
- name: Get current tag
id: vars
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
- name: Set up Doxygen
run: sudo apt-get install -y doxygen
- name: Display Doxygen version
run: echo "Doxygen version $(doxygen -v)"
- name: Build documentation
run: |
git clone --branch=master --single-branch --depth 1 https://github.com/devkitPro/3ds-examples examples
cd libctru
CTRU_VERSION=${{ steps.vars.outputs.tag }} doxygen Doxyfile
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: libctru/docs/html
CLEAN: true
SINGLE_COMMIT: true

4
.gitignore vendored
View File

@ -5,3 +5,7 @@
Thumbs.db
build/
lib/
docs/
examples/
internal_docs
build.sh

481
Changelog.md Normal file
View File

@ -0,0 +1,481 @@
# Changelog
## Version 2.4.0
- **Added full support of all QTM services**, with extensive documentation and technical details in `qtm.h` and `qtmc.h`** (breaking change); examples have been updated for this
- Added MCUHWC_SetInfoLedPattern
- Added ndspChnGetFormat
- Fixed PTMSYSM_CheckNew3DS
- Fixed NDMU_QueryStatus
- Fixed a few service commands improperly deserializing boolean output
- Fixed documentation of ACU_GetWifiStatus and ACU_SetAllowApType
- Fixed shaderInstanceInit to initialize all fields
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 2.3.0
- Fix typo in docs by @DeltaF1 in https://github.com/devkitPro/libctru/pull/525
- Add GPU_DOT3_RGBA texture combiner function by @oreo639 in https://github.com/devkitPro/libctru/pull/528
- FSUSER_GetLegacyBannerData: Fix documentation typo by @Tekito-256 in https://github.com/devkitPro/libctru/pull/526
- Add CTR_ prefix to ALIGN,PACKED,DEPRECATED macros by @glebm in https://github.com/devkitPro/libctru/pull/532
- Buffer console control sequences by @piepie62 in https://github.com/devkitPro/libctru/pull/522
- Prevent CPU from postponing threadOnException memory writes
- Add SSID-related ac:i functions
- ACI_LoadNetworkSetting, ACI_GetNetworkWirelessEssidSecuritySsid and acGetSessionHandle.
- Prevent double call of destructors on exit.
- Added experimental support for standard threading APIs (pthread, C threads, C++ std::thread)
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## New Contributors
- @DeltaF1 made their first contribution in https://github.com/devkitPro/libctru/pull/525
- @Tekito-256 made their first contribution in https://github.com/devkitPro/libctru/pull/526
- @glebm made their first contribution in https://github.com/devkitPro/libctru/pull/532
## Version 2.2.2
- archive_dev: Ensure path separator for local path
- adjust struct hostent for compatibilty
## Version 2.2.1
- add `_SOCKLEN_T_DECLARED`
## Version 2.2.0
- apt: add deliver arg support to chainloader
## Version 2.1.2
- Added cdc:CHK service wrappers
- Added support for `clock_gettime` (#495)
- svc: Fixed svcGetDmaState writing out-of-bounds data
- svc: Changed svcCreateCodeSet address parameters to pointer-sized integers, improve documentation
- fspxi: Fixed FSPXI_CreateFile and FSPXI_WriteFile (#496)
- ndsp: Added various ndspGet\* and ndspChnGet\* methods (#505, #506, #507)
- ir: Added IRU_GetSend/RecvFinishedEvent (#513)
- errf: Added ERRF_SetUserString and clarify documentation
- mcuhwc: Added mcuHwcGetSessionHandle
- apt: Fixed dirty homebrew chainload bug (used when Home Menu hasn't been started)
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 2.1.1
- FPSCR is now initialized with a predictable value in all threads (including the main thread).
- Added gspGetSessionHandle and gspLcdGetSessionHandle.
- Fixed bugs related to uninitialized data in srv/errf service wrappers.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 2.1.0
**The #define for the 3DS platform has been changed to `__3DS__` (previously it was `_3DS`) - please update your Makefiles and your code**
### graphics
- Refactored VRAM allocators:
- Added proper handling for VRAM banks (A and B, 3 MiB each)
- Allocations no longer cross VRAM bank boundaries
- Added vramAllocAt, vramMemAlignAt
- Add gspIsPresentPending.
- Add return value to gspPresentBuffer.
- libctru console now supports SGR 38 and 48 escape sequences (needed by fmtlib).
- Fixed GPU_TEXFACE enum.
### filesystem
- Changed rename to replace existing files, for better compatibility with POSIX (#483)
- Added SDMMC speed info types, and more clock rates (#480).
### miscellaneous
- Added support for 3dslink stdio redirection (#488).
- Added ptm:gets, ptm:sets and more ptm service commands.
- Added AM_ContentInfo, AM_ContentInfoFlags structs.
- Added AMAPP_GetDLCContentInfoCount, AMAPP_ListDLCContentInfos.
- Fixed bug in Huffman decoder.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 2.0.1
- Added CFG_SystemModel enum.
- Fixed bug in condvar code.
- Fixed bug in srvpm code.
- Fixed const correctness issues in gspgpu code.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 2.0.0
**This is a major release. Many essential components have been overhauled, although breaking changes are minimal and only affect rarely used functionality.**
### system
- Added support for userAppInit/userAppExit (backported from libnx).
- Changed default heap allocation logic to be more robust:
- Resource limit SVCs are now used to detect available memory.
- The heap size calculation algorithm was tweaked so that 32MB of linear heap are available for normal apps running under the default appmemtype layout on Old 3DS, as it was the case prior to libctru 1.8.0.
- SVC enhancements:
- Added svcControlPerformanceCounter with corresponding enums.
- Overhauled support for DMA related SVCs:
- Added svcRestartDma.
- Added enums and structures needed for DMA SVCs.
- Added dmaDeviceConfigInitDefault, dmaConfigInitDefault.
- Added svcArbitrateAddressNoTimeout (minor ABI optimization for the svcArbitrateAddress syscall when the timeout parameter is not used).
- Changed process memory SVCs to use u32 parameters instead of void\* for foreign-process addresses.
- Major refactor of OS related functions:
- Added defines for Arm11 userland memory region addresses/sizes.
- Added struct definitions for the kernel/system shared config pages: osKernelConfig_s, osSharedConfig_s.
- Added macros to access the kernel/system shared config pages: OS_KernelConfig, OS_SharedConfig.
- Fixed return type of osGetMemRegionUsed, osGetMemRegionFree (s64 -> u32).
- Refactored osConvertVirtToPhys and added support for the missing linearly mapped memory regions.
- Rewritten RTC time reading support to improve accuracy and match official logic more closely.
- Time drift correction is now implemented.
- Added osGetTimeRef function for reading the current reference timepoint published by the PTM sysmodule.
- Fixed osStrError to actually work properly.
- Cleaned up osGetSystemVersionData implementation.
- Other miscellaneous internal cleanup.
### synchronization
- Improved safety of usermode synchronization primitives when used in intercore contexts.
- Added CondVar synchronization primitive implementation.
- Added syncArbitrateAddress, syncArbitrateAddressWithTimeout.
- These functions replace \_\_sync\_get\_arbiter (which has been removed).
- Added \_\_dmb (Data Memory Barrier) intrinsic.
- Added LightEvent_WaitTimeout.
- Added LightSemaphore_TryAcquire.
- Changed LightLock to support 0 as a valid initial (unlocked) state.
- This effectively adds support for trivially initialized/zerofilled locks.
- Fixed bug in LightSemaphore_Acquire.
### graphics
- Major refactor of the GSP service wrapper. It should now be possible to use GSP directly without the gfx API, if the user so desires.
- Major internal refactor of the gfx wrapper API that increases maintainability.
- Added support for 800px wide mode with non-square pixels on the top screen - usable on every 3DS model except for Old 2DS (but *including* New 2DS XL).
- Added support for 800px wide mode to the libctru console.
- Transferred most of the GSP initialization duties to gspInit/gspExit (previously done by the gfx wrapper).
- Added defines for screen IDs and screen dimensions.
- Added gspPresentBuffer for pushing a framebuffer to the internal GSP swap queue (previously this was an internal function in the gfx wrapper).
- Added gspGetBytesPerPixel, gspHasGpuRight.
- Added gfxScreenSwapBuffers, with support for duplicating left->right eye content during stereoscopic 3D mode.
- Fixed LCD configuration mode when using framebuffers on VRAM with the gfx wrapper.
- Changed gfxExit to set LCD force-black status to true.
- Changed the gfx wrapper to always use gspPresentBuffer during swap. This means the immediate parameter of gfxConfigScreen no longer has any effect, and gfxSwapBuffers/gfxSwapBuffersGpu now do the same thing - that is, present the rendered content during the next VBlank.
- Renamed GSPGPU_FramebufferFormats enum to GSPGPU_FramebufferFormat.
- Deprecated gfxConfigScreen (use gfxScreenSwapBuffers instead).
- Removed gspInitEventHandler, gspExitEventHandler (now handled automatically inside gspInit/gspExit).
- Removed sharedGspCmdBuf param from gspSubmitGxCommand (now uses the proper GSP shared memory address automatically).
- Removed GSPGPU_REBASE_REG define (leftover from early 3DS homebrew).
- Removed numerous internal fields that were previously publicly accessible.
### audio
- DSP access rights are now managed using a hook mechanism, similar to the APT hook.
- This fixes audio playback during libapplet invocations, as they no longer relinquish DSP rights.
- Changed NDSP to use the DSP hook instead of the APT hook.
- Added dspIsComponentLoaded, dspHook, dspUnhook.
- Fixed and improved robustness of wavebuf handling in NDSP code.
- Fixed and refactored NDSP sleep/wakeup code to improve accuracy compared to official logic.
### filesystem
- Reduced TLS footprint of the archive/romfs devices by sharing buffers.
- Reduced the maximum number of concurrently registered archive devices from 32 to 8 in order to save memory.
- Backported multi-mount romfs system from libnx, with additional optimizations (breaking API change).
- Added romfsMountFromTitle.
- Fixed stat for romfs device to return -1 for non-existent files/directories.
### applet
- Major internal refactor of the APT service wrapper that should improve accuracy compared to official logic.
- Fixed sleep handling when the app is inactive (i.e. app is suspended).
- Added support for screen capture during libapplet transitions.
- Added support for proper DSP access right management.
- aptLaunchLibraryApplet no longer calls aptMainLoop internally. Library applet calls no longer return a bool value, users are advised to check APT state manually afterwards.
- Added functions for checking APT state: aptIsActive, aptShouldClose, aptShouldJumpToHome, aptCheckHomePressRejected (replaces aptIsHomePressed).
- Added functions for handling incoming requests: aptHandleSleep, aptHandleJumpToHome.
- Added aptJumpToHomeMenu.
- Changed aptMainLoop to use the new wrapper functions (this means aptMainLoop can now be replaced by custom logic if desired).
- Changed APTHOOK_ONEXIT to be invoked during aptExit instead of during aptMainLoop.
- Added aptClearChainloader, aptSetChainloaderToSelf.
### miscellaneous
- Fix decompress out-of-bounds access.
- Added NDM_ prefix to NDM enum members in order to avoid name collisions.
- Corrected parameter type in several CFGU functions.
- Corrected return value of GSPLCD_GetBrightness.
- Removed obsolete support for ninjhax 1.x's fake hb:HB service.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.9.0
- hid: Added hidKeysDownRepeat, hidWaitForAnyEvent. Allow user override of irsst usage.
- Add ptm rtc time commands
- Add sleep state FSM handling service commands
- Revamp mappableAlloc
- Fixed stat on romfs for directories, implemented lstat via stat (FAT32 has no symlinks)
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.8.0
- Added support for environments where the home menu is not launched (such as running under SAFE_FIRM)
- Added FSPXI service wrappers
- Changed heap allocation logic to be more flexible; this fixes support for certain system memory layouts
- Cleaned up and optimized light lock locking code
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.7.0
- fix FIONBIO ioctl
- Fix CAMU_GetLatestVsyncTiming
- Add archive STDIO device driver
- Add AC commands that allow forcing a wifi connection
- Fix dspInit() error handling in ndspInit()
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.6.0
- Major overhaul to font loading code in order to support loading external fonts.
- Major overhaul to PM service wrappers, now with separate support for pm:app and pm:dbg.
- Added Rosalina GDB host IO (gdbhio) support.
- Added support for the fs:REG service.
- Added support for the PxiPM service.
- Added PM launch flag definitions.
- Added SO_BROADCAST.
- Added new APT helper functions: aptIsHomeAllowed, aptSetHomeAllowed, aptIsHomePressed.
- Added support for the Mii selector libapplet, and other improvements to Mii support.
- Renamed IPC_Desc_CurProcessHandle to IPC_Desc_CurProcessId.
- Changed signature of LOADER_RegisterProgram to use FS_ProgramInfo structs.
- Fixed IPC bugs in the Loader service.
- Fixed svcCreateResourceLimit.
- Fixed corner case bug in GPUCMD_Add.
- Fixed bugs in select and herror.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.5.1
- Added support for the FRD service.
- Added gas-related GPU definitions.
- Implemented nanosleep.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.5.0
- Added new decompression API which supports LZSS/LZ10, LZ11, RLE & Huffman formats, and which can read compressed data from memory or from a file.
- Added srvSetBlockingPolicy, which controls whether srvGetServiceHandle blocks when the service isn't yet registered (or returns an error otherwise).
- Added ACU commands: ACU_GetStatus, ACU_GetSecurityMode, ACU_GetSSIDLength, ACU_GetSecurityMode, ACU_GetProxyEnable, ACU_GetProxyPort, ACU_GetProxyUserName, ACU_GetProxyPassword, ACU_GetLastErrorCode, ACU_GetLastDetailErrorCode.
- Added CFGI commands: CFGI_SecureInfoGetSerialNumber, CFGU_IsNFCSupported, CFGI_GetLocalFriendCodeSeed, CFGI_GetLocalFriendCodeSeedData, CFGI_GetSecureInfoData, CFGI_GetSecureInfoSignature.
- Added MCUHWC commands: MCUHWC_SetWifiLedState, MCUHWC_SetPowerLedState, MCUHWC_Get3dSliderLevel, MCUHWC_GetFwVerHigh, MCUHWC_GetFwVerLow.
- Added NS commands: NS_TerminateTitle, NS_TerminateProcessTID (with timeout), NS_RebootSystem.
- Added PM commands: PM_TerminateCurrentApplication, PM_TerminateProcess, PM_UnregisterProcess.
- Overhauled NDMU service support and added many commands that were previously missing.
- Fixed bugs in srv:pm implementation.
- Fixed calculation of vertical texture coordinates in fontCalcGlyphPos.
- Fixed shaderProgramSetGshInputPermutation.
- Fixed and added clock speed constants (affects system clock and NDSP).
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.4.0
- Added LightSemaphore synchronization primitive.
- Added exheader definitions.
- Added support for the Loader service.
- Added support for the mcu::HWC service.
- Added support for the Mii selector applet.
- Added ResourceLimitType.
- Added AM commands: AM_DeleteAllTemporaryTitles, AM_DeleteAllExpiredTitles, AM_DeleteAllTwlTitles.
- Added CFGI commands: CFGI_RestoreLocalFriendCodeSeed, CFGI_RestoreSecureInfo, CFGI_DeleteConfigSavefile, CFGI_FormatConfig, CFGI_ClearParentalControls, CFGI_VerifySigLocalFriendCodeSeed, CFGI_VerifySigSecureInfo.
- Added GSPGPU commands: GSPGPU_SetLedForceOff.
- Added GSPLCD commands: GSPLCD_SetBrightness, GSPLCD_SetBrightnessRaw, GSPLCD_PowerOnAllBacklights, GSPLCD_PowerOffAllBacklights, GSPLCD_SetLedForceOff.
- Fixed srv:pm handling in pre-7.x system versions.
- Fixed GPU_LIGHTPERM macro definition.
- Removed the remaining deprecated GPUCMD commands.
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
## Version 1.3.0
- Implement more svc calls
- svcCreateResourceLimit
- svcSetResourceLimitValues
- svcSetProcessResourceLimits
- svcCreateSession
- svcCreateSessionToPort
- svcSetGpuProt
- svcSetWifiEnabled
- Additional functions
- implement httpcAddPostDataBinary
- implement PTMU_GetAdapterState
- implement GSPLCD_GetBrightness
- add threadDetach
- srv fixes
- Fix srvPublishToSubscriber documentation
- Fix handling of service/named port names of length 8
- Fix srvRegisterPort
- debugging support
- Add support for user-specified exception handlers
- Rename debugDevice_3DMOO to debugDevice_SVC
- created debug version of library
- Implement error applet
- GPU updates
- Add GX command queue system for batching GX commands
- Correct GPU_PROCTEX_LUTID definition
- Add GPU_FOGMODE, GPU_GASMODE and GPU_GASLUTINPUT
- Other improvements and minor adjustments for overall system stability to enhance the user experience
## Version 1.2.1
- Added NFC support
- Update and renamed NFC_AmiiboConfig members
- Added TickCounter for measuring performance
- Added (linear/vram/mappable)GetSize for retrieving allocated buffer size
- Added nim:s client implementation.
- Correct bus clock used for time calulations
- Default to file write without internal copy buffer
- GPUCMD_Add: allow NULL for adding zerofilled parameter data
- Clarify threadFree usage in documentation
- Add GPU_TEXFACE enumeration
## Version 1.2.0
* New features:
- Added support for the nfc:m/nfc:u service.
- Added support for the ssl:C service.
- Added support for the nwm::UDS service (Local wireless).
- Added support for the boss:P/boss:U service (SpotPass).
- Added support for using the err:f global port.
- Added support for using and parsing the shared system font.
- Added support for using the 3DS' built-in software keyboard applet.
- Added support for using Light Events, a lightweight alternative to normal events that doesn't consume handles.
- Added NDSP commands for setting up per-channel monopole & biquad filters.
* Major breaking changes:
- Major revamp of the APT code; some old deprecated functions were completely removed, homebrew code abiding by recent standards shouldn't be affected though.
- Major revamp of the HTTPC code, including both additions and bugfixes.
- Major revamp of the AM code, with some enhancements.
- Major revamp of FSUSER code, archive handle handling has been refactored. fs(End)UseSession replaced with fsExemptFromSession.
- Major revamp of MVD code to support video processing.
- Major revamp of the GPU shader code to fully support geometry shaders.
- The old deprecated GPU wrapper commands have been removed. Use direct GPU register writes or a separate GPU wrapper library (such as citro3d) instead.
- Major revamp and update of the SVC debugger API.
- Heap size management has been simplified and made more flexible. All applications now default to 32MB of linear heap and all remaining APPLICATION memory is allocated as the application heap, regardless of entrypoint or application format.
* Miscellaneous additions:
- Several enhancements to SOC:u support:
- Added getaddrinfo, getnameinfo, gethostname, gai_strerror.
- Added SOCU_ShutdownSockets, SOCU_CloseSockets, SOCU_GetIPInfo, SOCU_GetNetworkOpt, SOCU_AddGlobalSocket.
- Added several missing flags.
- Minor am:net corrections and additions.
- Added sdmcWriteSafe to disable copying data to temporary RW buffers before calling FSFILE_Write.
- Added sdmc_getmtime to retrieve the modification time for a file.
- Added opendir/readdir/rewinddir/closedir/stat support to romfs.
- Added support for multiple RomFS mounts.
- Added macros for console color codes (ANSI escape sequences).
- Added support for specifying a fallback RomFS path for when argv isn't available.
- Added aptIsSleepAllowed/aptSetSleepAllowed.
- Added ResetType enum for use with svcCreateEvent and svcCreateTimer.
- Added psInitHandle and psGetSessionHandle.
- Added AM commands: AM_ExportTwlBackup, AM_ImportTwlBackup, AM_ReadTwlBackupInfo, AM_DeleteAllDemoLaunchInfos, AM_FinishCiaInstallWithoutCommit, AM_CommitImportPrograms.
- Added AMPXI commands: AMPXI_WriteTWLSavedata, AMPXI_InstallTitlesFinish.
- Added APT commands: APT_ReceiveDeliverArg.
- Added CFG commands: CFG_GetConfigInfoBlk4, CFG_GetConfigInfoBlk8, CFG_SetConfigInfoBlk4, CFG_SetConfigInfoBlk8, CFG_UpdateConfigNANDSavegame.
- Added GSPLCD commands: GSPLCD_GetVendors
- Added FSUSER commands: FSUSER_UpdateSha256Context.
- Added NEWS commands: NEWS_GetTotalNotifications, NEWS_SetNotificationHeader, NEWS_GetNotificationHeader, NEWS_GetNotificationMessage, NEWS_GetNotificationImage, NEWS_SetNotificationMessage, NEWS_SetNotificationImage.
- Added NS commands: NS_TerminateProcessTID, NS_LaunchFIRM, NS_LaunchApplicationFIRM.
- Added PS commands: PS_SignRsaSha256, PS_VerifyRsaSha256.
- Added PTMSYSM commands: PTMSYSM_CheckNew3DS, PTMSYSM_ShutdownAsync, PTMSYSM_RebootAsync.
- Added PXIDEV commands: PXIDEV_SPIMultiWriteRead, PXIDEV_SPIWriteRead.
- Added system calls: svcCreateCodeSet, svcCreateProcess, svcGetResourceLimit, svcGetResourceLimitValues, svcGetResourceLimitCurrentValues, svcSetProcessAffinityMask, svcSetProcessIdealProcessor, svcRun, svcBindInterrupt, svcUnbindInterrupt, svcGetHandleInfo, svcBreakRO, svcGetThreadList.
- Added result module codes.
- Added GPU A4 texture format enum.
* Miscellaneous changes and bug fixes:
- Optimized sdmc's readdir to batch directory entries.
- APT, GSPGPU and NDSP code was tuned to take advantage of Light Events.
- Moved am:app init to a separate function.
- Several issues concerning IPC static buffer saving/restoring were fixed.
- Several issues concerning sdmc/RomFS devoptabs were fixed.
- Several issues concerning SOC:u were fixed.
- An issue concerning cam:u was fixed.
- An issue concerning HID was fixed.
- An issue concerning news:u was fixed.
- The GPU ETC1 texture format enums were fixed.
- usleep was fixed.
- Fixed incorrect bool return values from services.
- Fixed buffer overflow after gfxSetScreenFormat.
- Fixed home menu display of suspended 2D applications.
- Fixed buffer overrun in console code.
- Fixed PS_EncryptDecryptAes and PS_EncryptSignDecryptVerifyAesCcm.
- Fixed the implementation of svcGetProcessList.
- Corrected svcKernelSetState function signature.
## Version 1.1.0
* Additions:
- GSPGPU/GX code was revised and enhanced:
- Screens can be buffer-swapped independently using the new gfxConfigScreen function.
- Added gspSetEventCallback for running event code directly on the GSP thread.
- Added gspWaitForAnyEvent for waiting for any GSP event.
- Added gfxIs3D for retrieving 3D-enable status.
- Added AM_InstallFirm.
- Added __sync_get_arbiter.
- Added support for usleep.
* Changes:
- NDSP thread priority has been increased, therefore mitigating potential sound issues due to high CPU usage on the main thread.
- RomFS initialization no longer makes romfs:/ the default device.
* Bug fixes:
- Fixed the timeout parameter in svcArbitrateAddress.
- Fixed svcSetTimer.
## Version 1.0.0
* New features:
- libctru documentation is now available at http://smealum.github.io/ctrulib/
- Added the NDSP API, which allows the use of the DSP (audio).
- Added Inter Process Communication helpers.
- Added Result code helpers.
- Added support for lightweight synchronization primitives.
- Added support for making the C/C++ standard libraries thread safe.
- Added support for thread-local objects, with the use of standard C and C++ constructs (or GCC extensions).
- Added a new threading API that properly manages internal state. Direct usage of svcCreateThread is deprecated.
- Added a mappable address space allocator. Services which need to map shared memory blocks now use this allocator.
- Added support for embedded RomFS, embedded SMDH and GPU shader building in the template Makefiles.
* Changes and additions to the GPU code:
- Stateless wrapper functions (GPU_*) that merely masked GPU register usage were deprecated, in favour of external GPU wrapper libraries such as citro3d. A future release of libctru may remove them.
- The API set has therefore been simplified down to command list management.
- Synchronized register names with the 3dbrew Wiki.
- Added fragment lighting registers and enums.
- Added procedural texture registers and enums.
- Added shaderProgramSetGshInputPermutation, for configuring the wiring between the vertex shader and the geometry shader.
- Added shaderProgramSetGshMode, for configuring the geometry shader operation mode.
- Added shaderProgramConfigure, intended to be used by GPU wrapper libraries.
- SHBIN/shaderProgram code now correctly computes and sets the values of the GPUREG_SH_OUTATTR_MODE/CLOCK registers.
- GX function naming has been improved, and the initial GX command buffer parameter has been removed.
* Major changes and miscellaneous additions:
- Sweeping changes to make function/structure/enum naming more consistent across the whole library. This affects a lot of code.
- Compiler/linker flags have been tweaked to increase performance and reduce code size, through the garbage collection of unused functions.
- Service initialization is now reference counted in order to properly manage dependencies.
- Initial service handle parameters have been removed, since they were nearly always set to NULL.
- Completed coverage of srv and FSUSER service calls.
- Added fsUseSession and fsEndUseSession for overriding the FSUSER session used in commands in the current thread.
- Added osGet3DSliderState, osSetSpeedupEnable, osGetSystemVersionData and osGetSystemVersionDataString.
- Refactored the MICU service.
- NCCH versions of applications now detect the maximum amount of available memory on startup.
* Miscellaneous changes and bug fixes:
- Commits and pull requests are now built on travis to check that the library compiles, and to generate the documentation.
- General changes and improvements to overall code quality.
- Added the missing struct and functions for Y2R.
- Added srvGetServiceHandleDirect for bypassing the handle override mechanism.
- Usage of the CSND service in new applications is not recommended, however it is not deprecated. The usage of NDSP instead is advised.
- Usage of the HB service in new applications is not recommended due to its necessary removal in hax 2.x, however it is not deprecated.
- Several bugs affecting APT were fixed.
- Several bugs affecting C++ were fixed.
## Version 0 through 0.6.0
No changelog available.

View File

@ -1,24 +1,27 @@
ctrulib
=======
# libctru - CTR User Library
CTR User Library
![Build Status](https://github.com/devkitPro/libctru/actions/workflows/build.yaml/badge.svg)
library for writing user mode arm11 code for the 3DS (CTR)
Library for writing user mode ARM11 code for the 3DS (CTR)
the goal with this is to create a very straightforward interface with the 3DS's OS.
it is not meant to provide higher level functions; to put things in perspective, the purpose of ctrulib would be to sit between the OS and a possible port of SDL rather than replace it.
This library aims to provide the foundations necessary to write 3DS Homebrew, and straightforwardly access the different functionalities provided by the 3DS operating system.
It is not meant to provide higher level functions; to put things in perspective, the purpose of libctru would be to sit between the OS and a possible port of SDL rather than replace it.
setup
=======
*(Originally located at github.com/smealum/ctrulib)*
ctrulib is just a library and needs a toolchain to function. we built ctrulib to be used in conjunction with devkitARM. you may find instructions on how to install devkitARM here : http://devkitpro.org/wiki/Getting_Started
# Setup
The most recent devkitARM (r43) includes 3DS support and a prebuilt libctru.
libctru is just a library and needs a toolchain to function. devkitARM (created by [devkitPro](http://devkitpro.org)) is the officially supported ARM cross compiling toolchain, which provides the framework necessary to supply a usable POSIX-like environment, with working C and C++ standard libraries; as well as the tools required to compile homebrew in the 3DSX format, and assemble GPU shaders. The use of other ARM toolchains is severely discouraged.
To keep up to date with the most recent changes you'll want to checkout ctrulib, build it and install it.
The most recent version of devkitARM is always recommended. The [installers/setup scripts](https://devkitpro.org/wiki/devkitPro_pacman) supplied by devkitPro install a prebuilt copy of the latest stable version of libctru, which is recommended for general use. Please note that devkitPro has a policy of keeping legacy code to a minimum, so a library upgrade may result in older code failing to compile or behave properly. Developers are encouraged to keep their code working with the latest versions of the tools and libraries.
license
=======
You may find instructions on how to install devkitARM on [the devkitPro Wiki](http://devkitpro.org/wiki/Getting_Started).
# Documentation
The documentation is automatically built upon release and can be found at the following url: https://devkitpro.github.io/libctru/
# License
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any

3
examples/.gitignore vendored
View File

@ -1,3 +0,0 @@
build/
*.3dsx
*.elf

View File

@ -1,26 +0,0 @@
SUBDIRS:= $(shell ls | egrep -v '^(CVS)$$')
DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d)
#---------------------------------------------------------------------------------
all: examples
#---------------------------------------------------------------------------------
@rm -fr bin
@mkdir -p bin
@find . -name "*.3dsx" -exec cp -fv {} bin \;
examples:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
#---------------------------------------------------------------------------------
clean:
#---------------------------------------------------------------------------------
@rm -fr bin
@rm -f *.bz2
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
#---------------------------------------------------------------------------------
dist: clean
#---------------------------------------------------------------------------------
@rm -fr bin
@tar --exclude=.svn --exclude=*CVS* -cvjf 3ds-examples-$(DATESTRING).tar.bz2 *

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,9 +0,0 @@
app_launch
=======
Example for launching other apps/applets with ctrulib. Press the A button to launch the app or applet specified in the source.
Note: The title ID of the EUR Nintendo 3DS Camera app is hardcoded and you need to change it if your 3DS is not an european one. See here for title IDs: http://3dbrew.org/wiki/Title_list#00040010_-_System_Applications
This example only works if launched as regular app by the home menu. It will not work with the homebrew menu.

View File

@ -1,49 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <3ds.h>
int main()
{
gfxInitDefault(); // Init graphic stuff
// We need these 2 buffers for APT_DoAppJump() later. They can be smaller too
u8 buf0[0x300];
u8 buf1[0x20];
// Loop as long as the status is not exit
while(aptMainLoop())
{
// Scan hid shared memory for input events
hidScanInput();
if(hidKeysDown() & KEY_A) // If the A button got pressed, start the app launch
{
// Clear both buffers
memset(buf0, 0, 0x300);
memset(buf1, 0, 0x20);
// Open an APT session so we can talk to the APT service
aptOpenSession();
// Prepare for the app launch
APT_PrepareToDoAppJump(NULL, 0, 0x0004001000022400LL, 0); // *EUR* camera app title ID
// Tell APT to trigger the app launch and set the status of this app to exit
APT_DoAppJump(NULL, 0x300 /* size of buf0 */, 0x20 /* size of buf1 */, buf0, buf1);
// Close the APT session because we don't need APT anymore
aptCloseSession();
}
// Flush + swap framebuffers and wait for VBlank. Not really needed in this example
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
gfxExit();
return 0;
}

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,5 +0,0 @@
mic
=======
Example for using the microphone with ctrulib. Hold down the A button to record, the app will then play the recorded audio once the A button is released. Roughly 32 seconds of audio can be recorded with the default audiobuf size in this app.

View File

@ -1,88 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <3ds.h>
int main()
{
u8 *framebuf;
u32 *sharedmem = NULL, sharedmem_size = 0x30000;
u8 *audiobuf;
u32 audiobuf_size = 0x100000, audiobuf_pos = 0;
u8 control=0x40;
u32 audio_initialized = 0;
gfxInitDefault();
if(CSND_initialize(NULL)==0)audio_initialized = 1;
sharedmem = (u32*)memalign(0x1000, sharedmem_size);
audiobuf = linearAlloc(audiobuf_size);
MIC_Initialize(sharedmem, sharedmem_size, control, 0, 3, 1, 1);//See mic.h.
while(aptMainLoop())
{
hidScanInput();
gspWaitForVBlank();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
if(audio_initialized)
{
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
if(kDown & KEY_A)
{
audiobuf_pos = 0;
CSND_setchannel_playbackstate(0x8, 0);//Stop audio playback.
CSND_sharedmemtype0_cmdupdatestate(0);
MIC_SetRecording(1);
memset(framebuf, 0x20, 0x46500);
}
if((hidKeysHeld() & KEY_A) && audiobuf_pos < audiobuf_size)
{
audiobuf_pos+= MIC_ReadAudioData(&audiobuf[audiobuf_pos], audiobuf_size-audiobuf_pos, 1);
if(audiobuf_pos > audiobuf_size)audiobuf_pos = audiobuf_size;
memset(framebuf, 0x60, 0x46500);
}
if(hidKeysUp() & KEY_A)
{
MIC_SetRecording(0);
GSPGPU_FlushDataCache(NULL, audiobuf, audiobuf_pos);
CSND_playsound(0x8, CSND_LOOP_DISABLE, CSND_ENCODING_PCM16, 16000, (u32*)audiobuf, NULL, audiobuf_pos, 2, 0);
memset(framebuf, 0xe0, 0x46500);
gfxFlushBuffers();
gfxSwapBuffers();
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(framebuf, 0xe0, 0x46500);
}
}
gfxFlushBuffers();
gfxSwapBuffers();
}
MIC_Shutdown();
if(audio_initialized)CSND_shutdown();
free(sharedmem);
linearFree(audiobuf);
gfxExit();
return 0;
}

View File

@ -1,175 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,4 +0,0 @@
get_system_language
=======
This is an example on how to get the system language on the 3DS.

View File

@ -1,46 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <3ds.h>
int main(int argc, char** argv)
{
// Initialize services
gfxInitDefault();
initCfgu();
u8 language = 0;
Result res;
// Init console for text output
consoleInit(GFX_BOTTOM, NULL);
// Read the language field from the config savegame.
res = CFGU_GetSystemLanguage(&language);
// Print return value and language code
printf(" Result: 0x%x\n", (int)res);
printf("Language code: %d", (int)language);
// Main loop
while (aptMainLoop())
{
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
// Exit services
exitCfgu();
gfxExit();
return 0;
}

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,11 +0,0 @@
gpu
=======
example of how to use the GPU with libctru
before trying to compile, make sure to download aemstro
( https://github.com/smealum/aemstro reflog: 55bf5056d199e0e9ec3d136dc830ac45a49da074 )
and update Makefile's AEMSTROPATH definition with the proper path
You'll also need to install Python 3 and have that in your path.

View File

@ -1,56 +0,0 @@
; make sure you update aemstro_as for this (15/11/14)
; setup constants
.const 20, 1.0, 0.0, 0.5, 1.0
; setup outmap
.out o0, result.position
.out o1, result.color
.out o2, result.texcoord0
.out o3, result.texcoord1
.out o4, result.texcoord2
; setup uniform map (required to use SHDR_GetUniformRegister)
.uniform 0, 3, projection ; c0-c3 = projection matrix
.uniform 4, 7, modelview ; c4-c7 = modelview matrix
.uniform 8, 8, lightDirection ; c8 = light direction vector
.uniform 9, 9, lightAmbient ; c9 = light ambient color
;code
main:
mov r1, v0 (0x6)
mov r1, c20 (0x3)
; tempreg = mdlvMtx * in.pos
dp4 r0, c4, r1 (0x0)
dp4 r0, c5, r1 (0x1)
dp4 r0, c6, r1 (0x2)
mov r0, c20 (0x3)
; result.pos = projMtx * tempreg
dp4 o0, c0, r0 (0x0)
dp4 o0, c1, r0 (0x1)
dp4 o0, c2, r0 (0x2)
dp4 o0, c3, r0 (0x3)
; result.texcoord = in.texcoord
mov o2, v1 (0x5)
mov o3, c20 (0x7)
mov o4, c20 (0x7)
; result.color = crappy lighting
dp3 r0, c8, v2 (0x6)
max r0, c20, r0 (0x4)
mul r0, c9, r0 (0x8)
add o1, c9, r0 (0x6)
mov o1, c20 (0x3)
flush
end
endmain:
;operand descriptors
.opdesc x___, xyzw, xyzw ; 0x0
.opdesc _y__, xyzw, xyzw ; 0x1
.opdesc __z_, xyzw, xyzw ; 0x2
.opdesc ___w, xyzw, xyzw ; 0x3
.opdesc xyz_, yyyy, xyzw ; 0x4
.opdesc xyzw, xyzw, xyzw ; 0x5
.opdesc xyz_, xyzw, xyzw ; 0x6
.opdesc xyzw, yyyw, xyzw ; 0x7
.opdesc xyz_, wwww, xyzw ; 0x8

Binary file not shown.

View File

@ -1,16 +0,0 @@
.section ".text"
.arm
.align 4
.global _vboMemcpy50
# r0 : dst
# r1 : src
# fixed size 0x50
_vboMemcpy50:
push {r4-r11}
ldmia r1!, {r2-r12}
stmia r0!, {r2-r12}
ldmia r1!, {r2-r12}
stmia r0!, {r2-r12}
pop {r4-r11}
bx lr

View File

@ -1,431 +0,0 @@
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <3ds.h>
#include "gs.h"
#include "math.h"
#define BUFFERMATRIXLIST_SIZE (GS_MATRIXSTACK_SIZE*4)
static void gsInitMatrixStack();
Handle linearAllocMutex;
static u32 gsMatrixStackRegisters[GS_MATRIXTYPES];
typedef struct
{
u32 offset;
mtx44 data;
}bufferMatrix_s;
bufferMatrix_s bufferMatrixList[BUFFERMATRIXLIST_SIZE];
int bufferMatrixListLength;
//----------------------
// GS SYSTEM STUFF
//----------------------
void initBufferMatrixList()
{
bufferMatrixListLength=0;
}
void gsInit(DVLB_s* shader)
{
gsInitMatrixStack();
initBufferMatrixList();
svcCreateMutex(&linearAllocMutex, false);
if(shader)
{
gsMatrixStackRegisters[0]=SHDR_GetUniformRegister(shader, "projection", 0);
gsMatrixStackRegisters[1]=SHDR_GetUniformRegister(shader, "modelview", 0);
}
}
void gsExit(void)
{
svcCloseHandle(linearAllocMutex);
}
void gsStartFrame(void)
{
GPUCMD_SetBufferOffset(0);
initBufferMatrixList();
}
void* gsLinearAlloc(size_t size)
{
void* ret=NULL;
svcWaitSynchronization(linearAllocMutex, U64_MAX);
ret=linearAlloc(size);
svcReleaseMutex(linearAllocMutex);
return ret;
}
void gsLinearFree(void* mem)
{
svcWaitSynchronization(linearAllocMutex, U64_MAX);
linearFree(mem);
svcReleaseMutex(linearAllocMutex);
}
//----------------------
// MATRIX STACK STUFF
//----------------------
static mtx44 gsMatrixStacks[GS_MATRIXTYPES][GS_MATRIXSTACK_SIZE];
static u32 gsMatrixStackRegisters[GS_MATRIXTYPES]={0x00, 0x04};
static u8 gsMatrixStackOffsets[GS_MATRIXTYPES];
static bool gsMatrixStackUpdated[GS_MATRIXTYPES];
static GS_MATRIX gsCurrentMatrixType;
static void gsInitMatrixStack()
{
int i;
for(i=0; i<GS_MATRIXTYPES; i++)
{
gsMatrixStackOffsets[i]=0;
gsMatrixStackUpdated[i]=true;
loadIdentity44((float*)gsMatrixStacks[i][0]);
}
gsCurrentMatrixType=GS_PROJECTION;
}
float* gsGetMatrix(GS_MATRIX m)
{
if(m<0 || m>=GS_MATRIXTYPES)return NULL;
return (float*)gsMatrixStacks[m][gsMatrixStackOffsets[m]];
}
int gsLoadMatrix(GS_MATRIX m, float* data)
{
if(m<0 || m>=GS_MATRIXTYPES || !data)return -1;
memcpy(gsGetMatrix(m), data, sizeof(mtx44));
gsMatrixStackUpdated[m]=true;
return 0;
}
int gsPushMatrix()
{
const GS_MATRIX m=gsCurrentMatrixType;
if(m<0 || m>=GS_MATRIXTYPES)return -1;
if(gsMatrixStackOffsets[m]<0 || gsMatrixStackOffsets[m]>=GS_MATRIXSTACK_SIZE-1)return -1;
float* cur=gsGetMatrix(m);
gsMatrixStackOffsets[m]++;
memcpy(gsGetMatrix(m), cur, sizeof(mtx44));
return 0;
}
int gsPopMatrix()
{
const GS_MATRIX m=gsCurrentMatrixType;
if(m<0 || m>=GS_MATRIXTYPES)return -1;
if(gsMatrixStackOffsets[m]<1 || gsMatrixStackOffsets[m]>=GS_MATRIXSTACK_SIZE)return -1;
gsMatrixStackOffsets[m]--;
gsMatrixStackUpdated[m]=true;
return 0;
}
int gsMatrixMode(GS_MATRIX m)
{
if(m<0 || m>=GS_MATRIXTYPES)return -1;
gsCurrentMatrixType=m;
return 0;
}
//------------------------
// MATRIX TRANSFORM STUFF
//------------------------
int gsMultMatrix(float* data)
{
if(!data)return -1;
mtx44 tmp;
multMatrix44(gsGetMatrix(gsCurrentMatrixType), data, (float*)tmp);
memcpy(gsGetMatrix(gsCurrentMatrixType), (float*)tmp, sizeof(mtx44));
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
return 0;
}
void gsLoadIdentity()
{
loadIdentity44(gsGetMatrix(gsCurrentMatrixType));
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
void gsProjectionMatrix(float fovy, float aspect, float near, float far)
{
initProjectionMatrix(gsGetMatrix(gsCurrentMatrixType), fovy, aspect, near, far);
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
void gsRotateX(float x)
{
rotateMatrixX(gsGetMatrix(gsCurrentMatrixType), x, false);
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
void gsRotateY(float y)
{
rotateMatrixY(gsGetMatrix(gsCurrentMatrixType), y, false);
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
void gsRotateZ(float z)
{
rotateMatrixZ(gsGetMatrix(gsCurrentMatrixType), z, false);
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
void gsScale(float x, float y, float z)
{
scaleMatrix(gsGetMatrix(gsCurrentMatrixType), x, y, z);
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
void gsTranslate(float x, float y, float z)
{
translateMatrix(gsGetMatrix(gsCurrentMatrixType), x, y, z);
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
}
//----------------------
// MATRIX RENDER STUFF
//----------------------
static void gsSetUniformMatrix(u32 startreg, float* m)
{
float param[16];
param[0x0]=m[3]; //w
param[0x1]=m[2]; //z
param[0x2]=m[1]; //y
param[0x3]=m[0]; //x
param[0x4]=m[7];
param[0x5]=m[6];
param[0x6]=m[5];
param[0x7]=m[4];
param[0x8]=m[11];
param[0x9]=m[10];
param[0xa]=m[9];
param[0xb]=m[8];
param[0xc]=m[15];
param[0xd]=m[14];
param[0xe]=m[13];
param[0xf]=m[12];
GPU_SetUniform(startreg, (u32*)param, 4);
}
static int gsUpdateTransformation()
{
GS_MATRIX m;
for(m=0; m<GS_MATRIXTYPES; m++)
{
if(gsMatrixStackUpdated[m])
{
if(m==GS_PROJECTION && bufferMatrixListLength<BUFFERMATRIXLIST_SIZE)
{
GPUCMD_GetBuffer(NULL, NULL, &bufferMatrixList[bufferMatrixListLength].offset);
memcpy(bufferMatrixList[bufferMatrixListLength].data, gsGetMatrix(m), sizeof(mtx44));
bufferMatrixListLength++;
}
gsSetUniformMatrix(gsMatrixStackRegisters[m], gsGetMatrix(m));
gsMatrixStackUpdated[m]=false;
}
}
return 0;
}
void gsAdjustBufferMatrices(mtx44 transformation)
{
int i;
u32* buffer;
u32 offset;
GPUCMD_GetBuffer(&buffer, NULL, &offset);
for(i=0; i<bufferMatrixListLength; i++)
{
u32 o=bufferMatrixList[i].offset;
if(o+2<offset) //TODO : better check, need to account for param size
{
mtx44 newMatrix;
GPUCMD_SetBufferOffset(o);
multMatrix44((float*)bufferMatrixList[i].data, (float*)transformation, (float*)newMatrix);
gsSetUniformMatrix(gsMatrixStackRegisters[GS_PROJECTION], (float*)newMatrix);
}
}
GPUCMD_SetBufferOffset(offset);
}
//----------------------
// VBO STUFF
//----------------------
int gsVboInit(gsVbo_s* vbo)
{
if(!vbo)return -1;
vbo->data=NULL;
vbo->currentSize=0;
vbo->maxSize=0;
vbo->commands=NULL;
vbo->commandsSize=0;
return 0;
}
int gsVboCreate(gsVbo_s* vbo, u32 size)
{
if(!vbo)return -1;
vbo->data=gsLinearAlloc(size);
vbo->numVertices=0;
vbo->currentSize=0;
vbo->maxSize=size;
return 0;
}
void* gsVboGetOffset(gsVbo_s* vbo)
{
if(!vbo)return NULL;
return (void*)(&((u8*)vbo->data)[vbo->currentSize]);
}
int gsVboAddData(gsVbo_s* vbo, void* data, u32 size, u32 units)
{
if(!vbo || !data || !size)return -1;
if(((s32)vbo->maxSize)-((s32)vbo->currentSize) < size)return -1;
memcpy(gsVboGetOffset(vbo), data, size);
vbo->currentSize+=size;
vbo->numVertices+=units;
return 0;
}
int gsVboFlushData(gsVbo_s* vbo)
{
if(!vbo)return -1;
//unnecessary if we use flushAndRun
// GSPGPU_FlushDataCache(NULL, vbo->data, vbo->currentSize);
return 0;
}
int gsVboDestroy(gsVbo_s* vbo)
{
if(!vbo)return -1;
if(vbo->commands)free(vbo->commands);
if(vbo->data)gsLinearFree(vbo->data);
gsVboInit(vbo);
return 0;
}
extern u32 debugValue[];
void GPU_DrawArrayDirectly(GPU_Primitive_t primitive, u8* data, u32 n)
{
//set attribute buffer address
GPUCMD_AddSingleParam(0x000F0200, (osConvertVirtToPhys((u32)data))>>3);
//set primitive type
GPUCMD_AddSingleParam(0x0002025E, primitive);
GPUCMD_AddSingleParam(0x0002025F, 0x00000001);
//index buffer not used for drawArrays but 0x000F0227 still required
GPUCMD_AddSingleParam(0x000F0227, 0x80000000);
//pass number of vertices
GPUCMD_AddSingleParam(0x000F0228, n);
GPUCMD_AddSingleParam(0x00010253, 0x00000001);
GPUCMD_AddSingleParam(0x00010245, 0x00000000);
GPUCMD_AddSingleParam(0x000F022E, 0x00000001);
GPUCMD_AddSingleParam(0x00010245, 0x00000001);
GPUCMD_AddSingleParam(0x000F0231, 0x00000001);
// GPUCMD_AddSingleParam(0x000F0111, 0x00000001); //breaks stuff
}
//not thread safe
int gsVboPrecomputeCommands(gsVbo_s* vbo)
{
if(!vbo || vbo->commands)return -1;
static u32 tmpBuffer[128];
u32* savedAdr; u32 savedSize, savedOffset;
GPUCMD_GetBuffer(&savedAdr, &savedSize, &savedOffset);
GPUCMD_SetBuffer(tmpBuffer, 128, 0);
GPU_DrawArrayDirectly(GPU_TRIANGLES, vbo->data, vbo->numVertices);
GPUCMD_GetBuffer(NULL, NULL, &vbo->commandsSize);
vbo->commands=memalign(0x4, vbo->commandsSize*4);
if(!vbo->commands)return -1;
memcpy(vbo->commands, tmpBuffer, vbo->commandsSize*4);
GPUCMD_SetBuffer(savedAdr, savedSize, savedOffset);
return 0;
}
extern u32* gpuCmdBuf;
extern u32 gpuCmdBufSize;
extern u32 gpuCmdBufOffset;
void _vboMemcpy50(u32* dst, u32* src);
void _GPUCMD_AddRawCommands(u32* cmd, u32 size)
{
if(!cmd || !size)return;
if(size*4==0x50)_vboMemcpy50(&gpuCmdBuf[gpuCmdBufOffset], cmd);
else memcpy(&gpuCmdBuf[gpuCmdBufOffset], cmd, size*4);
gpuCmdBufOffset+=size;
}
int gsVboDraw(gsVbo_s* vbo)
{
if(!vbo || !vbo->data || !vbo->currentSize || !vbo->maxSize)return -1;
gsUpdateTransformation();
gsVboPrecomputeCommands(vbo);
// u64 val=svcGetSystemTick();
if(vbo->commands)
{
_GPUCMD_AddRawCommands(vbo->commands, vbo->commandsSize);
}else{
GPU_DrawArrayDirectly(GPU_TRIANGLES, vbo->data, vbo->numVertices);
}
// debugValue[5]+=(u32)(svcGetSystemTick()-val);
// debugValue[6]++;
return 0;
}

View File

@ -1,59 +0,0 @@
#ifndef GS_H
#define GS_H
#include <3ds.h>
#include "math.h"
#define GS_MATRIXSTACK_SIZE (8)
typedef enum
{
GS_PROJECTION = 0,
GS_MODELVIEW = 1,
GS_MATRIXTYPES
}GS_MATRIX;
typedef struct
{
u8* data;
u32 currentSize; // in bytes
u32 maxSize; // in bytes
u32 numVertices;
u32* commands;
u32 commandsSize;
}gsVbo_s;
void gsInit(DVLB_s* shader);
void gsExit(void);
void gsStartFrame(void);
void gsAdjustBufferMatrices(mtx44 transformation);
void* gsLinearAlloc(size_t size);
void gsLinearFree(void* mem);
float* gsGetMatrix(GS_MATRIX m);
int gsLoadMatrix(GS_MATRIX m, float* data);
int gsPushMatrix();
int gsPopMatrix();
int gsMatrixMode(GS_MATRIX m);
void gsLoadIdentity();
void gsProjectionMatrix(float fovy, float aspect, float near, float far);
void gsRotateX(float x);
void gsRotateY(float y);
void gsRotateZ(float z);
void gsScale(float x, float y, float z);
void gsTranslate(float x, float y, float z);
int gsMultMatrix(float* data);
int gsVboInit(gsVbo_s* vbo);
int gsVboCreate(gsVbo_s* vbo, u32 size);
int gsVboFlushData(gsVbo_s* vbo);
int gsVboDestroy(gsVbo_s* vbo);
int gsVboDraw(gsVbo_s* vbo);
void* gsVboGetOffset(gsVbo_s* vbo);
int gsVboAddData(gsVbo_s* vbo, void* data, u32 size, u32 units);
#endif

View File

@ -1,323 +0,0 @@
///////////////////////////////////////
// GPU example //
///////////////////////////////////////
//this example is meant to show how to use the GPU to render a 3D object
//it also shows how to do stereoscopic 3D
//it uses GS which is a WIP GPU abstraction layer that's currently part of 3DScraft
//keep in mind GPU reverse engineering is an ongoing effort and our understanding of it is still fairly limited.
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <3ds.h>
#include "math.h"
#include "gs.h"
#include "test_vsh_shbin.h"
#include "texture_bin.h"
//will be moved into ctrulib at some point
#define CONFIG_3D_SLIDERSTATE (*(float*)0x1FF81080)
#define RGBA8(r,g,b,a) ((((r)&0xFF)<<24) | (((g)&0xFF)<<16) | (((b)&0xFF)<<8) | (((a)&0xFF)<<0))
//shader structure
DVLB_s* shader;
//texture data pointer
u32* texData;
//vbo structure
gsVbo_s vbo;
//GPU framebuffer address
u32* gpuOut=(u32*)0x1F119400;
//GPU depth buffer address
u32* gpuDOut=(u32*)0x1F370800;
//angle for the vertex lighting (cf test.vsh)
float lightAngle;
//object position and rotation angle
vect3Df_s position, angle;
//vertex structure
typedef struct
{
vect3Df_s position;
float texcoord[2];
vect3Df_s normal;
}vertex_s;
//object data (cube)
//obviously this doesn't have to be defined manually, but we will here for the purposes of the example
//each line is a vertex : {position.x, position.y, position.z}, {texcoord.t, texcoord.s}, {normal.x, normal.y, normal.z}
//we're drawing triangles so three lines = one triangle
const vertex_s modelVboData[]=
{
//first face (PZ)
//first triangle
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
//second triangle
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
//second face (MZ)
//first triangle
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
//second triangle
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
//third face (PX)
//first triangle
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
//second triangle
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
//fourth face (MX)
//first triangle
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
//second triangle
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
//fifth face (PY)
//first triangle
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
//second triangle
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
//sixth face (MY)
//first triangle
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
//second triangle
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
};
//stolen from staplebutt
void GPU_SetDummyTexEnv(u8 num)
{
GPU_SetTexEnv(num,
GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0),
GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0),
GPU_TEVOPERANDS(0,0,0),
GPU_TEVOPERANDS(0,0,0),
GPU_REPLACE,
GPU_REPLACE,
0xFFFFFFFF);
}
// topscreen
void renderFrame()
{
GPU_SetViewport((u32*)osConvertVirtToPhys((u32)gpuDOut),(u32*)osConvertVirtToPhys((u32)gpuOut),0,0,240*2,400);
GPU_DepthRange(-1.0f, 0.0f);
GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP);
GPU_SetBlendingColor(0,0,0,0);
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
GPUCMD_AddSingleParam(0x00010062, 0);
GPUCMD_AddSingleParam(0x000F0118, 0);
//setup shader
SHDR_UseProgram(shader, 0);
GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00);
GPU_SetTextureEnable(GPU_TEXUNIT0);
GPU_SetTexEnv(0,
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
GPU_TEVOPERANDS(0,0,0),
GPU_TEVOPERANDS(0,0,0),
GPU_MODULATE, GPU_MODULATE,
0xFFFFFFFF);
GPU_SetDummyTexEnv(1);
GPU_SetDummyTexEnv(2);
GPU_SetDummyTexEnv(3);
GPU_SetDummyTexEnv(4);
GPU_SetDummyTexEnv(5);
//texturing stuff
GPU_SetTexture(GPU_TEXUNIT0, (u32*)osConvertVirtToPhys((u32)texData),128,128,GPU_TEXTURE_MAG_FILTER(GPU_NEAREST)|GPU_TEXTURE_MIN_FILTER(GPU_NEAREST),GPU_RGBA8);
GPU_SetAttributeBuffers(3, (u32*)osConvertVirtToPhys((u32)texData),
GPU_ATTRIBFMT(0, 3, GPU_FLOAT)|GPU_ATTRIBFMT(1, 2, GPU_FLOAT)|GPU_ATTRIBFMT(2, 3, GPU_FLOAT),
0xFFC, 0x210, 1, (u32[]){0x00000000}, (u64[]){0x210}, (u8[]){3});
//setup lighting (this is specific to our shader)
vect3Df_s lightDir=vnormf(vect3Df(cos(lightAngle), -1.0f, sin(lightAngle)));
GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightDirection", 0), (u32*)(float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x}, 1);
GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightAmbient", 0), (u32*)(float[]){0.7f, 0.4f, 0.4f, 0.4f}, 1);
//initialize projection matrix to standard perspective stuff
gsMatrixMode(GS_PROJECTION);
gsProjectionMatrix(80.0f*M_PI/180.0f, 240.0f/400.0f, 0.01f, 100.0f);
gsRotateZ(M_PI/2); //because framebuffer is sideways...
//draw object
gsMatrixMode(GS_MODELVIEW);
gsPushMatrix();
gsTranslate(position.x, position.y, position.z);
gsRotateX(angle.x);
gsRotateY(angle.y);
gsVboDraw(&vbo);
gsPopMatrix();
GPU_FinishDrawing();
}
int main(int argc, char** argv)
{
gfxInitDefault();
//initialize GPU
GPU_Init(NULL);
//let GFX know we're ok with doing stereoscopic 3D rendering
gfxSet3D(true);
//load our vertex shader binary
shader=SHDR_ParseSHBIN((u32*)test_vsh_shbin, test_vsh_shbin_size);
//initialize GS
gsInit(shader);
//allocate our GPU command buffers
//they *have* to be on the linear heap
u32 gpuCmdSize=0x40000;
u32* gpuCmd=(u32*)linearAlloc(gpuCmdSize*4);
u32* gpuCmdRight=(u32*)linearAlloc(gpuCmdSize*4);
//actually reset the GPU
GPU_Reset(NULL, gpuCmd, gpuCmdSize);
//create texture
texData=(u32*)linearMemAlign(texture_bin_size, 0x80); //textures need to be 0x80-byte aligned
memcpy(texData, texture_bin, texture_bin_size);
//create VBO
gsVboInit(&vbo);
gsVboCreate(&vbo, sizeof(modelVboData));
gsVboAddData(&vbo, (void*)modelVboData, sizeof(modelVboData), sizeof(modelVboData)/sizeof(vertex_s));
gsVboFlushData(&vbo);
//initialize object position and angle
position=vect3Df(0.0f, 0.0f, -2.0f);
angle=vect3Df(M_PI/4, M_PI/4, 0.0f);
//background color (blue)
u32 backgroundColor=RGBA8(0x68, 0xB0, 0xD8, 0xFF);
while(aptMainLoop())
{
//get current 3D slider state
float slider=CONFIG_3D_SLIDERSTATE;
//controls
hidScanInput();
//START to exit to hbmenu
if(keysDown()&KEY_START)break;
//A/B to change vertex lighting angle
if(keysHeld()&KEY_A)lightAngle+=0.1f;
if(keysHeld()&KEY_B)lightAngle-=0.1f;
//D-PAD to rotate object
if(keysHeld()&KEY_RIGHT)angle.x+=0.05f;
if(keysHeld()&KEY_LEFT)angle.x-=0.05f;
if(keysHeld()&KEY_UP)angle.y+=0.05f;
if(keysHeld()&KEY_DOWN)angle.y-=0.05f;
//R/L to bring object closer to or move it further from the camera
if(keysHeld()&KEY_R)position.z+=0.1f;
if(keysHeld()&KEY_L)position.z-=0.1f;
//generate our GPU command buffer for this frame
gsStartFrame();
renderFrame();
GPUCMD_Finalize();
if(slider>0.0f)
{
//new and exciting 3D !
//make a copy of left gpu buffer
u32 offset; GPUCMD_GetBuffer(NULL, NULL, &offset);
memcpy(gpuCmdRight, gpuCmd, offset*4);
//setup interaxial
float interaxial=slider*0.12f;
//adjust left gpu buffer fo 3D !
{mtx44 m; loadIdentity44((float*)m); translateMatrix((float*)m, -interaxial*0.5f, 0.0f, 0.0f); gsAdjustBufferMatrices(m);}
//draw left framebuffer
GPUCMD_FlushAndRun(NULL);
//while GPU starts drawing the left buffer, adjust right one for 3D !
GPUCMD_SetBuffer(gpuCmdRight, gpuCmdSize, offset);
{mtx44 m; loadIdentity44((float*)m); translateMatrix((float*)m, interaxial*0.5f, 0.0f, 0.0f); gsAdjustBufferMatrices(m);}
//we wait for the left buffer to finish drawing
gspWaitForP3D();
GX_SetDisplayTransfer(NULL, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019001E0, 0x01001000);
gspWaitForPPF();
//we draw the right buffer, wait for it to finish and then switch back to left one
//clear the screen
GX_SetMemoryFill(NULL, (u32*)gpuOut, backgroundColor, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201);
gspWaitForPSC0();
//draw the right framebuffer
GPUCMD_FlushAndRun(NULL);
gspWaitForP3D();
//transfer from GPU output buffer to actual framebuffer
GX_SetDisplayTransfer(NULL, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), 0x019001E0, 0x01001000);
gspWaitForPPF();
GPUCMD_SetBuffer(gpuCmd, gpuCmdSize, 0);
}else{
//boring old 2D !
//draw the frame
GPUCMD_FlushAndRun(NULL);
gspWaitForP3D();
//clear the screen
GX_SetDisplayTransfer(NULL, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019001E0, 0x01001000);
gspWaitForPPF();
}
//clear the screen
GX_SetMemoryFill(NULL, (u32*)gpuOut, backgroundColor, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201);
gspWaitForPSC0();
gfxSwapBuffersGpu();
gspWaitForEvent(GSPEVENT_VBlank0, true);
}
gsExit();
gfxExit();
return 0;
}

View File

@ -1,148 +0,0 @@
#include <math.h>
#include <string.h>
#include "math.h"
void loadIdentity44(float* m)
{
if(!m)return;
memset(m, 0x00, 16*4);
m[0]=m[5]=m[10]=m[15]=1.0f;
}
void multMatrix44(float* m1, float* m2, float* m) //4x4
{
int i, j;
for(i=0;i<4;i++)for(j=0;j<4;j++)m[i+j*4]=(m1[0+j*4]*m2[i+0*4])+(m1[1+j*4]*m2[i+1*4])+(m1[2+j*4]*m2[i+2*4])+(m1[3+j*4]*m2[i+3*4]);
}
void translateMatrix(float* tm, float x, float y, float z)
{
float rm[16], m[16];
loadIdentity44(rm);
rm[3]=x;
rm[7]=y;
rm[11]=z;
multMatrix44(tm,rm,m);
memcpy(tm,m,16*sizeof(float));
}
// 00 01 02 03
// 04 05 06 07
// 08 09 10 11
// 12 13 14 15
void rotateMatrixX(float* tm, float x, bool r)
{
float rm[16], m[16];
memset(rm, 0x00, 16*4);
rm[0]=1.0f;
rm[5]=cos(x);
rm[6]=sin(x);
rm[9]=-sin(x);
rm[10]=cos(x);
rm[15]=1.0f;
if(!r)multMatrix44(tm,rm,m);
else multMatrix44(rm,tm,m);
memcpy(tm,m,16*sizeof(float));
}
void rotateMatrixY(float* tm, float x, bool r)
{
float rm[16], m[16];
memset(rm, 0x00, 16*4);
rm[0]=cos(x);
rm[2]=sin(x);
rm[5]=1.0f;
rm[8]=-sin(x);
rm[10]=cos(x);
rm[15]=1.0f;
if(!r)multMatrix44(tm,rm,m);
else multMatrix44(rm,tm,m);
memcpy(tm,m,16*sizeof(float));
}
void rotateMatrixZ(float* tm, float x, bool r)
{
float rm[16], m[16];
memset(rm, 0x00, 16*4);
rm[0]=cos(x);
rm[1]=sin(x);
rm[4]=-sin(x);
rm[5]=cos(x);
rm[10]=1.0f;
rm[15]=1.0f;
if(!r)multMatrix44(tm,rm,m);
else multMatrix44(rm,tm,m);
memcpy(tm,m,16*sizeof(float));
}
void scaleMatrix(float* tm, float x, float y, float z)
{
tm[0]*=x; tm[4]*=x; tm[8]*=x; tm[12]*=x;
tm[1]*=y; tm[5]*=y; tm[9]*=y; tm[13]*=y;
tm[2]*=z; tm[6]*=z; tm[10]*=z; tm[14]*=z;
}
void initProjectionMatrix(float* m, float fovy, float aspect, float near, float far)
{
float top = near*tan(fovy/2);
float right = (top*aspect);
float mp[4*4];
mp[0x0] = near/right;
mp[0x1] = 0.0f;
mp[0x2] = 0.0f;
mp[0x3] = 0.0f;
mp[0x4] = 0.0f;
mp[0x5] = near/top;
mp[0x6] = 0.0f;
mp[0x7] = 0.0f;
mp[0x8] = 0.0f;
mp[0x9] = 0.0f;
mp[0xA] = -(far+near)/(far-near);
mp[0xB] = -2.0f*(far*near)/(far-near);
mp[0xC] = 0.0f;
mp[0xD] = 0.0f;
mp[0xE] = -1.0f;
mp[0xF] = 0.0f;
float mp2[4*4];
loadIdentity44(mp2);
mp2[0xA]=0.5;
mp2[0xB]=-0.5;
multMatrix44(mp2, mp, m);
}
vect3Df_s getMatrixColumn(float* m, u8 i)
{
if(!m || i>=4)return vect3Df(0,0,0);
return vect3Df(m[0+i*4],m[1+i*4],m[2+i*4]);
}
vect3Df_s getMatrixRow(float* m, u8 i)
{
if(!m || i>=4)return vect3Df(0,0,0);
return vect3Df(m[i+0*4],m[i+1*4],m[i+2*4]);
}
vect4Df_s getMatrixColumn4(float* m, u8 i)
{
if(!m || i>=4)return vect4Df(0,0,0,0);
return vect4Df(m[0+i*4],m[1+i*4],m[2+i*4],m[3+i*4]);
}
vect4Df_s getMatrixRow4(float* m, u8 i)
{
if(!m || i>=4)return vect4Df(0,0,0,0);
return vect4Df(m[i+0*4],m[i+1*4],m[i+2*4],m[i+3*4]);
}

View File

@ -1,144 +0,0 @@
#ifndef MATH_H
#define MATH_H
#include <3ds/types.h>
#include <math.h>
typedef float mtx44[4][4];
typedef float mtx33[3][3];
typedef struct
{
s32 x, y, z;
}vect3Di_s;
static inline vect3Di_s vect3Di(s32 x, s32 y, s32 z)
{
return (vect3Di_s){x,y,z};
}
static inline vect3Di_s vaddi(vect3Di_s u, vect3Di_s v)
{
return (vect3Di_s){u.x+v.x,u.y+v.y,u.z+v.z};
}
static inline vect3Di_s vsubi(vect3Di_s u, vect3Di_s v)
{
return (vect3Di_s){u.x-v.x,u.y-v.y,u.z-v.z};
}
static inline vect3Di_s vmuli(vect3Di_s v, s32 f)
{
return (vect3Di_s){v.x*f,v.y*f,v.z*f};
}
typedef struct
{
float x, y, z;
}vect3Df_s;
static inline vect3Df_s vect3Df(float x, float y, float z)
{
return (vect3Df_s){x,y,z};
}
static inline vect3Df_s vaddf(vect3Df_s u, vect3Df_s v)
{
return (vect3Df_s){u.x+v.x,u.y+v.y,u.z+v.z};
}
static inline vect3Df_s vsubf(vect3Df_s u, vect3Df_s v)
{
return (vect3Df_s){u.x-v.x,u.y-v.y,u.z-v.z};
}
static inline vect3Df_s vmulf(vect3Df_s v, float f)
{
return (vect3Df_s){v.x*f,v.y*f,v.z*f};
}
static inline vect3Df_s vscalef(vect3Df_s v1, vect3Df_s v2)
{
return (vect3Df_s){v1.x*v2.x,v1.y*v2.y,v1.z*v2.z};
}
static inline float vmagf(vect3Df_s v)
{
return sqrtf(v.x*v.x+v.y*v.y+v.z*v.z);
}
static inline float vdistf(vect3Df_s v1, vect3Df_s v2)
{
return sqrtf((v1.x-v2.x)*(v1.x-v2.x)+(v1.y-v2.y)*(v1.y-v2.y)+(v1.z-v2.z)*(v1.z-v2.z));
}
static inline vect3Df_s vnormf(vect3Df_s v)
{
const float l=sqrtf(v.x*v.x+v.y*v.y+v.z*v.z);
return (vect3Df_s){v.x/l,v.y/l,v.z/l};
}
typedef struct
{
float x, y, z, w;
}vect4Df_s;
static inline vect4Df_s vect4Df(float x, float y, float z, float w)
{
return (vect4Df_s){x,y,z,w};
}
static inline vect4Df_s vaddf4(vect4Df_s u, vect4Df_s v)
{
return (vect4Df_s){u.x+v.x,u.y+v.y,u.z+v.z,u.w+v.w};
}
static inline vect4Df_s vsubf4(vect4Df_s u, vect4Df_s v)
{
return (vect4Df_s){u.x-v.x,u.y-v.y,u.z-v.z,u.w-v.w};
}
static inline vect4Df_s vmulf4(vect4Df_s v, float f)
{
return (vect4Df_s){v.x*f,v.y*f,v.z*f,v.w*f};
}
static inline float vdotf4(vect4Df_s v1, vect4Df_s v2)
{
return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z+v1.w*v2.w;
}
static inline vect4Df_s vnormf4(vect4Df_s v)
{
const float l=sqrtf(v.x*v.x+v.y*v.y+v.z*v.z+v.w*v.w);
return (vect4Df_s){v.x/l,v.y/l,v.z/l,v.w/l};
}
//interstuff
static inline vect3Di_s vf2i(vect3Df_s v)
{
return (vect3Di_s){floorf(v.x),floorf(v.y),floorf(v.z)};
}
static inline vect3Df_s vi2f(vect3Di_s v)
{
return (vect3Df_s){(float)v.x,(float)v.y,(float)v.z};
}
void loadIdentity44(float* m);
void multMatrix44(float* m1, float* m2, float* m);
void translateMatrix(float* tm, float x, float y, float z);
void rotateMatrixX(float* tm, float x, bool r);
void rotateMatrixY(float* tm, float x, bool r);
void rotateMatrixZ(float* tm, float x, bool r);
void scaleMatrix(float* tm, float x, float y, float z);
void initProjectionMatrix(float* m, float fovy, float aspect, float near, float far);
vect3Df_s getMatrixColumn(float* m, u8 i);
vect3Df_s getMatrixRow(float* m, u8 i);
vect4Df_s getMatrixColumn4(float* m, u8 i);
vect4Df_s getMatrixRow4(float* m, u8 i);
#endif

View File

@ -1,7 +0,0 @@
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
all:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
clean:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
install:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;

View File

@ -1,7 +0,0 @@
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
all:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
clean:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
install:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,55 +0,0 @@
/*
Hello World example made by Aurelio Mannara for ctrulib
This code was modified for the last time on: 12/12/2014 21:00 UTC+1
This wouldn't be possible without the amazing work done by:
-Smealum
-fincs
-WinterMute
-yellows8
-plutoo
-mtheall
-Many others who worked on 3DS and I'm surely forgetting about
*/
#include <3ds.h>
#include <stdio.h>
int main(int argc, char **argv)
{
gfxInitDefault();
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
consoleInit(GFX_TOP, NULL);
//Move the cursor to row 15 and column 19 and then prints "Hello World!"
//To move the cursor you have tu print "\x1b[r;cH", where r and c are respectively
//the row and column where you want your cursor to move
//The top screen has 30 rows and 50 columns
//The bottom screen has 30 rows and 40 columns
printf("\x1b[15;19HHello World!");
printf("\x1b[29;15HPress Start to exit.");
// Main loop
while (aptMainLoop())
{
//Scan all the inputs. This should be done once for each frame
hidScanInput();
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
u32 kDown = hidKeysDown();
if (kDown & KEY_START) break; // break in order to return to hbmenu
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
//Wait for VBlank
gspWaitForVBlank();
}
gfxExit();
return 0;
}

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,4 +0,0 @@
# http
This is an example for using HTTPC. This downloads a raw image for displaying on the top-screen. The URL used here is a LAN-only one, hence this URL must be changed before building+running this example.

View File

@ -1,113 +0,0 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <inttypes.h>
#include <3ds.h>
Result http_download(httpcContext *context)//This error handling needs updated with proper text printing once ctrulib itself supports that.
{
Result ret=0;
u8* framebuf_top;
u32 statuscode=0;
u32 size=0, contentsize=0;
u8 *buf;
ret = httpcBeginRequest(context);
if(ret!=0)return ret;
ret = httpcGetResponseStatusCode(context, &statuscode, 0);
if(ret!=0)return ret;
if(statuscode!=200)return -2;
ret=httpcGetDownloadSizeState(context, NULL, &contentsize);
if(ret!=0)return ret;
printf("size: %"PRId32"\n",contentsize);
gfxFlushBuffers();
buf = (u8*)malloc(contentsize);
if(buf==NULL)return -1;
memset(buf, 0, contentsize);
ret = httpcDownloadData(context, buf, contentsize, NULL);
if(ret!=0)
{
free(buf);
return ret;
}
size = contentsize;
if(size>(240*400*3*2))size = 240*400*3*2;
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memcpy(framebuf_top, buf, size);
gfxFlushBuffers();
gfxSwapBuffers();
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memcpy(framebuf_top, buf, size);
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
free(buf);
return 0;
}
int main()
{
Result ret=0;
httpcContext context;
gfxInitDefault();
httpcInit();
consoleInit(GFX_BOTTOM,NULL);
//Change this to your own URL.
char *url = "http://devkitpro.org/misc/httpexample_rawimg.rgb";
printf("Downloading %s\n",url);
gfxFlushBuffers();
ret = httpcOpenContext(&context, url , 0);
printf("return from httpcOpenContext: %"PRId32"\n",ret);
gfxFlushBuffers();
if(ret==0)
{
ret=http_download(&context);
printf("return from http_download: %"PRId32"\n",ret);
gfxFlushBuffers();
httpcCloseContext(&context);
}
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
// Your code goes here
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
}
// Exit services
httpcExit();
gfxExit();
return 0;
}

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
libapplet_launch
=======
Example for launching library applets. This launches the extrapad library applet(Circle Pad Pro calibration applet) when the B button is pressed.
This is not usable from the homebrew launcher.

View File

@ -1,43 +0,0 @@
#include <3ds.h>
int main()
{
u32 val, i;
gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D
val = 0x22447899;
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
// Your code goes here
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
if (kDown & KEY_B)APT_LaunchLibraryApplet(0x408, 0, NULL, 0);//Launch the extrapad library applet when button B is pressed.
// Example rendering code that displays a white pixel
// Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
u32* fb = (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
for(i=0; i<(0x46500>>2); i++)fb[i] = val;
val+= 0x44;
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1 +0,0 @@
This example is for using New3DS MVD, for hardware color-format conversion + video processing(the latter is not supported by ctrulib/this example yet).

View File

@ -1,6 +0,0 @@
#ifndef COSTABLE_H
#define COSTABLE_H
s32 costable[] = {4096, 4095, 4094, 4093, 4091, 4088, 4084, 4080, 4076, 4071, 4065, 4058, 4051, 4044, 4035, 4026, 4017, 4007, 3996, 3985, 3973, 3960, 3947, 3934, 3919, 3904, 3889, 3873, 3856, 3839, 3821, 3803, 3784, 3765, 3744, 3724, 3703, 3681, 3659, 3636, 3612, 3588, 3564, 3539, 3513, 3487, 3461, 3434, 3406, 3378, 3349, 3320, 3290, 3260, 3229, 3198, 3167, 3135, 3102, 3069, 3035, 3002, 2967, 2932, 2897, 2861, 2825, 2788, 2751, 2714, 2676, 2638, 2599, 2560, 2521, 2481, 2441, 2401, 2360, 2318, 2277, 2235, 2193, 2150, 2107, 2064, 2020, 1976, 1932, 1888, 1843, 1798, 1753, 1707, 1662, 1616, 1569, 1523, 1476, 1429, 1382, 1334, 1287, 1239, 1191, 1143, 1095, 1046, 997, 949, 900, 851, 801, 752, 703, 653, 603, 554, 504, 454, 404, 354, 304, 254, 204, 153, 103, 53, 3, -46, -97, -147, -197, -247, -297, -347, -398, -448, -497, -547, -597, -647, -696, -746, -795, -844, -893, -942, -991, -1040, -1088, -1137, -1185, -1233, -1281, -1328, -1376, -1423, -1470, -1517, -1563, -1610, -1656, -1701, -1747, -1792, -1837, -1882, -1927, -1971, -2015, -2058, -2102, -2144, -2187, -2229, -2271, -2313, -2354, -2395, -2436, -2476, -2516, -2555, -2594, -2633, -2671, -2709, -2747, -2784, -2820, -2857, -2892, -2928, -2963, -2997, -3031, -3065, -3098, -3130, -3163, -3194, -3225, -3256, -3286, -3316, -3345, -3374, -3402, -3430, -3457, -3484, -3510, -3536, -3561, -3585, -3609, -3633, -3656, -3678, -3700, -3721, -3742, -3762, -3782, -3801, -3819, -3837, -3854, -3871, -3887, -3902, -3917, -3932, -3946, -3959, -3971, -3983, -3995, -4005, -4016, -4025, -4034, -4042, -4050, -4057, -4064, -4070, -4075, -4080, -4084, -4087, -4090, -4092, -4094, -4095, -4095, -4095, -4094, -4093, -4091, -4088, -4085, -4081, -4076, -4071, -4066, -4059, -4052, -4045, -4036, -4028, -4018, -4008, -3997, -3986, -3974, -3962, -3949, -3935, -3921, -3906, -3891, -3875, -3858, -3841, -3824, -3805, -3787, -3767, -3747, -3727, -3705, -3684, -3662, -3639, -3615, -3592, -3567, -3542, -3517, -3491, -3464, -3437, -3409, -3381, -3353, -3324, -3294, -3264, -3233, -3202, -3171, -3139, -3106, -3073, -3040, -3006, -2972, -2937, -2902, -2866, -2830, -2793, -2756, -2719, -2681, -2643, -2604, -2565, -2526, -2486, -2446, -2406, -2365, -2324, -2282, -2240, -2198, -2156, -2113, -2069, -2026, -1982, -1938, -1894, -1849, -1804, -1759, -1713, -1668, -1622, -1575, -1529, -1482, -1435, -1388, -1341, -1293, -1245, -1197, -1149, -1101, -1052, -1004, -955, -906, -857, -808, -758, -709, -660, -610, -560, -510, -460, -411, -360, -310, -260, -210, -160, -110, -60, -9, 40, 90, 140, 191, 241, 291, 341, 391, 441, 491, 541, 591, 640, 690, 739, 789, 838, 887, 936, 985, 1033, 1082, 1130, 1179, 1227, 1274, 1322, 1370, 1417, 1464, 1511, 1557, 1604, 1650, 1695, 1741, 1786, 1831, 1876, 1921, 1965, 2009, 2053, 2096, 2139, 2182, 2224, 2266, 2308, 2349, 2390, 2431, 2471, 2511, 2550, 2589, 2628, 2666, 2704, 2742, 2779, 2816, 2852, 2888, 2923, 2958, 2993, 3027, 3060, 3093, 3126, 3158, 3190, 3221, 3252, 3282, 3312, 3342, 3370, 3399, 3426, 3454, 3480, 3507, 3532, 3557, 3582, 3606, 3630, 3653, 3675, 3697, 3718, 3739, 3759, 3779, 3798, 3817, 3835, 3852, 3869, 3885, 3900, 3915, 3930, 3944, 3957, 3970, 3982, 3993, 4004, 4014, 4024, 4033, 4041, 4049, 4056, 4063, 4069, 4074, 4079, 4083, 4087, 4090, 4092, 4094, 4095};
#endif

View File

@ -1,143 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <3ds.h>
#include "costable.h"
u8* inaddr;
u8* outaddr;
char logstring[256];
s32 pcCos(u16 v)
{
return costable[v&0x1FF];
}
void printstring(char *str)//Placeholder until ctrulib itself has proper text drawing.
{
strncat(logstring, str, sizeof(logstring)-1);
}
void draw_startup()
{
Result ret;
FILE *f = NULL;
u8* bufAdr = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
u8* gfxtopadr = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
mvdstdConfig config;
char str[256];
int i, j;
u32 cnt=0;
for(i=0;i<320;i++)
{
for(j=0;j<240;j++)
{
u32 v=(j+i*240)*3;
bufAdr[v]=(pcCos(i+cnt)+4096)/32;
bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
}
}
f = fopen("sdmc:/mvd_indata.bin", "r");
if(f)
{
fread(inaddr, 1, 0x46500, f);
fclose(f);
}
else
{
memcpy(inaddr, bufAdr, 320*240*3);
}
memset(gfxtopadr, 0, 0x46500);
GSPGPU_FlushDataCache(NULL, inaddr, 0x46500);
printstring("mvd example\n");
ret = mvdstdInit(MVDMODE_COLORFORMATCONV, MVDTYPEIN_YUYV422, MVDTYPEOUT_RGB565, 0);
memset(str, 0, 256);
snprintf(str, sizeof(str)-1, "mvdstdInit(): 0x%08x\n", (unsigned int)ret);
printstring(str);
if(ret>=0)
{
mvdstdGenerateDefaultConfig(&config, 320, 240, 320, 240, (u32*)inaddr, (u32*)outaddr, (u32*)&outaddr[0x12c00]);
ret = mvdstdProcessFrame(&config, NULL, 0, 0);
memset(str, 0, 256);
snprintf(str, sizeof(str)-1, "mvdstdProcessFrame(): 0x%08x\n", (unsigned int)ret);
printstring(str);
}
svcSleepThread(1000000000);//Not sure how to determine when frame processing finishes.
GSPGPU_InvalidateDataCache(NULL, outaddr, 0x100000);
f = fopen("sdmc:/mvd_outdata.bin", "w");
if(f)
{
fwrite(outaddr, 1, 0x100000, f);
fclose(f);
}
f = fopen("sdmc:/mvd_log", "w");
if(f)
{
fwrite(logstring, 1, strlen(logstring), f);
fclose(f);
}
memcpy(gfxtopadr, outaddr, 0x46500);
mvdstdShutdown();
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForVBlank();
}
int main()
{
gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D
memset(logstring, 0, 256);
inaddr = linearAlloc(0x100000);
outaddr = linearAlloc(0x100000);
if(inaddr && outaddr)
{
memset(inaddr, 0, 0x100000);
memset(outaddr, 0, 0x100000);
draw_startup();
}
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
// Your code goes here
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
}
if(inaddr)linearFree(inaddr);
if(outaddr)linearFree(outaddr);
gfxExit();
return 0;
}

View File

@ -1,175 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# qtm
This is an example for using New3DS QTM for head-tracking.
This is currently not usable from the homebrew launcher.

View File

@ -1,85 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <3ds.h>
int main()
{
u32 pos;
u32 x, y;
Result ret;
bool qtm_usable;
qtmHeadtrackingInfo qtminfo;
u32 colors[4] = {0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF};
gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D
qtmInit();
consoleInit(GFX_BOTTOM, NULL);
printf("qtm example\n");
qtm_usable = qtmCheckInitialized();
if(!qtm_usable)printf("QTM is not usable, therefore this example won't do anything with QTM.\n");
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
if(qtm_usable)
{
u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(fb, 0, 400*240*3);
ret = qtmGetHeadtrackingInfo(0, &qtminfo);
if(ret==0)
{
consoleClear();
for(pos=0; pos<5; pos++)
{
printf("flags[%x]=0x%x", (unsigned int)pos, qtminfo.flags[pos]);
if(pos<4)printf(", ");
}
printf("\nfloatdata_x08: %f\n", qtminfo.floatdata_x08);
printf("coords0: ");
for(pos=0; pos<4; pos++)
{
printf("[%x].x=%f, y=%f", (unsigned int)pos, qtminfo.coords0[pos].x, qtminfo.coords0[pos].y);
if(pos<3)printf(", ");
}
printf("\n");
if(qtmCheckHeadFullyDetected(&qtminfo))
{
for(pos=0; pos<4; pos++)
{
ret = qtmConvertCoordToScreen(&qtminfo.coords0[pos], NULL, NULL, &x, &y);
if(ret==0)memcpy(&fb[(x*240 + y) * 3], &colors[pos], 3);
}
}
}
}
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
}
// Exit services
qtmExit();
gfxExit();
return 0;
}

View File

@ -1,170 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
.PHONY: all
all : $(OUTPUT).3dsx $(OUTPUT).smdh
endif
$(OUTPUT).3dsx : $(OUTPUT).elf
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,5 +0,0 @@
sdmc
=======
very simple example of how to access SD files with libctru;

View File

@ -1,50 +0,0 @@
#include <3ds/types.h>
s32 costable[] = { 4096, 4095, 4094, 4093, 4091, 4088, 4084, 4080, 4076, 4071, 4065,
4058, 4051, 4044, 4035, 4026, 4017, 4007, 3996, 3985, 3973, 3960,
3947, 3934, 3919, 3904, 3889, 3873, 3856, 3839, 3821, 3803, 3784,
3765, 3744, 3724, 3703, 3681, 3659, 3636, 3612, 3588, 3564, 3539,
3513, 3487, 3461, 3434, 3406, 3378, 3349, 3320, 3290, 3260, 3229,
3198, 3167, 3135, 3102, 3069, 3035, 3002, 2967, 2932, 2897, 2861,
2825, 2788, 2751, 2714, 2676, 2638, 2599, 2560, 2521, 2481, 2441,
2401, 2360, 2318, 2277, 2235, 2193, 2150, 2107, 2064, 2020, 1976,
1932, 1888, 1843, 1798, 1753, 1707, 1662, 1616, 1569, 1523, 1476,
1429, 1382, 1334, 1287, 1239, 1191, 1143, 1095, 1046, 997, 949,
900, 851, 801, 752, 703, 653, 603, 554, 504, 454, 404, 354, 304,
254, 204, 153, 103, 53, 3, -46, -97, -147, -197, -247, -297, -347,
-398, -448, -497, -547, -597, -647, -696, -746, -795, -844, -893,
-942, -991, -1040, -1088, -1137, -1185, -1233, -1281, -1328, -1376,
-1423, -1470, -1517, -1563, -1610, -1656, -1701, -1747, -1792, -1837,
-1882, -1927, -1971, -2015, -2058, -2102, -2144, -2187, -2229, -2271,
-2313, -2354, -2395, -2436, -2476, -2516, -2555, -2594, -2633, -2671,
-2709, -2747, -2784, -2820, -2857, -2892, -2928, -2963, -2997, -3031,
-3065, -3098, -3130, -3163, -3194, -3225, -3256, -3286, -3316, -3345,
-3374, -3402, -3430, -3457, -3484, -3510, -3536, -3561, -3585, -3609,
-3633, -3656, -3678, -3700, -3721, -3742, -3762, -3782, -3801, -3819,
-3837, -3854, -3871, -3887, -3902, -3917, -3932, -3946, -3959, -3971,
-3983, -3995, -4005, -4016, -4025, -4034, -4042, -4050, -4057, -4064,
-4070, -4075, -4080, -4084, -4087, -4090, -4092, -4094, -4095, -4095,
-4095, -4094, -4093, -4091, -4088, -4085, -4081, -4076, -4071, -4066,
-4059, -4052, -4045, -4036, -4028, -4018, -4008, -3997, -3986, -3974,
-3962, -3949, -3935, -3921, -3906, -3891, -3875, -3858, -3841, -3824,
-3805, -3787, -3767, -3747, -3727, -3705, -3684, -3662, -3639, -3615,
-3592, -3567, -3542, -3517, -3491, -3464, -3437, -3409, -3381, -3353,
-3324, -3294, -3264, -3233, -3202, -3171, -3139, -3106, -3073, -3040,
-3006, -2972, -2937, -2902, -2866, -2830, -2793, -2756, -2719, -2681,
-2643, -2604, -2565, -2526, -2486, -2446, -2406, -2365, -2324, -2282,
-2240, -2198, -2156, -2113, -2069, -2026, -1982, -1938, -1894, -1849,
-1804, -1759, -1713, -1668, -1622, -1575, -1529, -1482, -1435, -1388,
-1341, -1293, -1245, -1197, -1149, -1101, -1052, -1004, -955, -906,
-857, -808, -758, -709, -660, -610, -560, -510, -460, -411, -360,
-310, -260, -210, -160, -110, -60, -9, 40, 90, 140, 191, 241, 291,
341, 391, 441, 491, 541, 591, 640, 690, 739, 789, 838, 887, 936,
985, 1033, 1082, 1130, 1179, 1227, 1274, 1322, 1370, 1417, 1464,
1511, 1557, 1604, 1650, 1695, 1741, 1786, 1831, 1876, 1921, 1965,
2009, 2053, 2096, 2139, 2182, 2224, 2266, 2308, 2349, 2390, 2431,
2471, 2511, 2550, 2589, 2628, 2666, 2704, 2742, 2779, 2816, 2852,
2888, 2923, 2958, 2993, 3027, 3060, 3093, 3126, 3158, 3190, 3221,
3252, 3282, 3312, 3342, 3370, 3399, 3426, 3454, 3480, 3507, 3532,
3557, 3582, 3606, 3630, 3653, 3675, 3697, 3718, 3739, 3759, 3779,
3798, 3817, 3835, 3852, 3869, 3885, 3900, 3915, 3930, 3944, 3957,
3970, 3982, 3993, 4004, 4014, 4024, 4033, 4041, 4049, 4056, 4063,
4069, 4074, 4079, 4083, 4087, 4090, 4092, 4094, 4095};

View File

@ -1,6 +0,0 @@
#ifndef COSTABLE_H
#define COSTABLE_H
extern s32 costable[];
#endif

View File

@ -1,98 +0,0 @@
///////////////////////////////////////
// SDMC example //
///////////////////////////////////////
//this example shows you how to load a binary image file from the SD card and display it on the lower screen
//for this to work you should copy test.bin to same folder as your .3dsx
//this file was generated with GIMP by saving a 240x320 image to raw RGB
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <3ds.h>
#include "costable.h"
//this will contain the data read from SDMC
u8* buffer;
//3DS has VFPs so we could just use cos
//but we're old school so LUT4life
s32 pcCos(u16 v)
{
return costable[v&0x1FF];
}
void renderEffect()
{
static int cnt;
u8* bufAdr=gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
int i, j;
for(i=1;i<400;i++)
{
for(j=1;j<240;j++)
{
u32 v=(j+i*240)*3;
bufAdr[v]=(pcCos(i+cnt)+4096)/32;
bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
}
}
cnt++;
}
int main(int argc, char** argv)
{
gfxInitDefault(); //makes displaying to screen easier
FILE *file = fopen("test.bin","rb");
if (file == NULL) goto exit;
// seek to end of file
fseek(file,0,SEEK_END);
// file pointer tells us the size
off_t size = ftell(file);
// seek back to start
fseek(file,0,SEEK_SET);
//allocate a buffer
buffer=malloc(size);
if(!buffer)goto exit;
//read contents !
off_t bytesRead = fread(buffer,1,size,file);
//close the file because we like being nice and tidy
fclose(file);
if(size!=bytesRead)goto exit;
while(aptMainLoop())
{
//exit when user hits B
hidScanInput();
if(keysHeld()&KEY_B)break;
//render rainbow
renderEffect();
//copy buffer to lower screen (don't have to do it every frame)
memcpy(gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL), buffer, size);
//wait & swap
gfxSwapBuffersGpu();
gspWaitForEvent(GSPEVENT_VBlank0, false);
}
//cleanup and return
//returning from main() returns to hbmenu when run under ninjhax
exit:
//closing all services even more so
gfxExit();
return 0;
}

File diff suppressed because one or more lines are too long

View File

@ -1,7 +0,0 @@
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
all:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
clean:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
install:
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;

View File

@ -1,175 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#
# NO_SMDH: if set to anything, no SMDH file is generated.
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
# ICON is the filename of the icon (.png), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.png
# - icon.png
# - <libctru folder>/default_icon.png
#---------------------------------------------------------------------------------
TARGET := $(notdir $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.png)
ifneq (,$(findstring $(TARGET).png,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).png
else
ifneq (,$(findstring icon.png,$(icons)))
export APP_ICON := $(TOPDIR)/icon.png
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
ifeq ($(strip $(NO_SMDH)),)
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
else
$(OUTPUT).3dsx : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
# WARNING: This is not the right way to do this! TODO: Do it right!
#---------------------------------------------------------------------------------
%.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
@rm ../$(notdir $<).shbin
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,3 +0,0 @@
# template
This is a template for starting new 3DS libctru projects.

View File

@ -1,37 +0,0 @@
#include <string.h>
#include <3ds.h>
int main()
{
gfxInitDefault();
//gfxSet3D(true); // uncomment if using stereoscopic 3D
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
// Your code goes here
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
// Example rendering code that displays a white pixel
// Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
memset(fb, 0, 240*400*3);
fb[3*(10+10*240)] = 0xFF;
fb[3*(10+10*240)+1] = 0xFF;
fb[3*(10+10*240)+2] = 0xFF;
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
}
gfxExit();
return 0;
}

View File

@ -1,121 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
include $(DEVKITARM)/3ds_rules
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := $(shell basename $(CURDIR))
BUILD := build
SOURCES := source
DATA := data
INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
CFLAGS := -g -Wall -O2\
$(ARCH)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
ASFLAGS := -g $(ARCH)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(CTRULIB)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
lib:
@[ -d $@ ] || mkdir -p $@
$(BUILD): lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) lib
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
#---------------------------------------------------------------------------------
%.bin.o : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,3 +0,0 @@
# template
This is a template for starting new 3DS library projects.

View File

@ -1,6 +0,0 @@
#ifndef _templatelib_h_
#define _templatelib_h_
int myLibFunction();
#endif // _templatelib_h_

View File

@ -1,6 +0,0 @@
int myLibFunction() {
return 42;
}

7
libctru/.gitignore vendored
View File

@ -1,5 +1,10 @@
debug
release
deps
build
lib
docs
internal_docs
*.bz2
*.bz2
.*/
*.tag

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@ endif
include $(DEVKITARM)/base_rules
export LIBCTRU_MAJOR := 0
export LIBCTRU_MAJOR := 2
export LIBCTRU_MINOR := 4
export LIBCTRU_PATCH := 0
@ -23,12 +23,15 @@ VERSION := $(LIBCTRU_MAJOR).$(LIBCTRU_MINOR).$(LIBCTRU_PATCH)
# INCLUDES is a list of directories containing header files
#---------------------------------------------------------------------------------
TARGET := ctru
BUILD := build
#BUILD := build
SOURCES := source \
source/allocator \
source/gpu \
source/ndsp \
source/services \
source/services/soc \
source/applets \
source/util/decompress \
source/util/rbtree \
source/util/utf \
source/system
@ -39,17 +42,19 @@ INCLUDES := include
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffast-math \
$(ARCH)
CFLAGS := -g -Wall -Werror -mword-relocations \
-ffunction-sections \
-fdata-sections \
$(ARCH) \
$(BUILD_CFLAGS)
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
CFLAGS += $(INCLUDE) -D__3DS__
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
ASFLAGS := -g $(ARCH) $(INCLUDE)
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
@ -64,13 +69,9 @@ LIBDIRS :=
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
@ -90,45 +91,61 @@ else
endif
#---------------------------------------------------------------------------------
export OFILES := $(addsuffix .o,$(BINFILES)) \
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
-I.
.PHONY: $(BUILD) clean all
.PHONY: clean all
#---------------------------------------------------------------------------------
all: $(BUILD)
all: lib/libctru.a lib/libctrud.a
dist-bin: all
@tar -cjf libctru-$(VERSION).tar.bz2 include lib default_icon.png
@tar --exclude=*~ -cjf libctru-$(VERSION).tar.bz2 include lib default_icon.png
dist-src:
@tar -cjf libctru-src-$(VERSION).tar.bz2 include source Makefile Doxyfile Doxyfile.internal default_icon.png
@tar --exclude=*~ -cjf libctru-src-$(VERSION).tar.bz2 include source data Makefile Doxyfile default_icon.png
dist: dist-src dist-bin
install: dist-bin
mkdir -p $(DEVKITPRO)/libctru
bzip2 -cd libctru-$(VERSION).tar.bz2 | tar -x -C $(DEVKITPRO)/libctru
dox:
@doxygen Doxyfile
@doxygen Doxyfile.internal
mkdir -p $(DESTDIR)$(DEVKITPRO)/libctru
bzip2 -cd libctru-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/libctru
lib:
@[ -d $@ ] || mkdir -p $@
$(BUILD): lib
release:
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
debug:
@[ -d $@ ] || mkdir -p $@
lib/libctru.a : lib release $(SOURCES) $(INCLUDES)
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
DEPSDIR=$(CURDIR)/release \
--no-print-directory -C release \
-f $(CURDIR)/Makefile
lib/libctrud.a : lib debug $(SOURCES) $(INCLUDES)
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DDEBUG=1 -Og" \
DEPSDIR=$(CURDIR)/debug \
--no-print-directory -C debug \
-f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) lib docs internal_docs
@rm -fr release debug lib docs libctru.tag
#---------------------------------------------------------------------------------
else
@ -140,8 +157,10 @@ DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
$(OUTPUT) : $(OFILES)
$(OFILES_SRC) : $(HFILES_BIN)
#---------------------------------------------------------------------------------
%.bin.o : %.bin
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

73
libctru/include/3ds/env.h Normal file
View File

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

137
libctru/include/3ds/errf.h Normal file
View File

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

View File

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

236
libctru/include/3ds/font.h Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,222 +1,119 @@
/**
* @file gpu.h
* @brief Barebones GPU communications driver.
*/
#pragma once
void GPU_Init(Handle *gsphandle);
void GPU_Reset(u32* gxbuf, u32* gpuBuf, u32 gpuBufSize);
#include "registers.h"
#include "enums.h"
void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset);
void GPUCMD_SetBufferOffset(u32 offset);
void GPUCMD_GetBuffer(u32** adr, u32* size, u32* offset);
void GPUCMD_AddRawCommands(u32* cmd, u32 size);
void GPUCMD_Run(u32* gxbuf);
void GPUCMD_FlushAndRun(u32* gxbuf);
void GPUCMD_Add(u32 cmd, u32* param, u32 paramlength);
void GPUCMD_AddSingleParam(u32 cmd, u32 param);
void GPUCMD_Finalize();
/// Creates a GPU command header from its write increments, mask, and register.
#define GPUCMD_HEADER(incremental, mask, reg) (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF))
//tex param
#define GPU_TEXTURE_MAG_FILTER(v) (((v)&0x1)<<1) //takes a GPU_TEXTURE_FILTER_PARAM
#define GPU_TEXTURE_MIN_FILTER(v) (((v)&0x1)<<2) //takes a GPU_TEXTURE_FILTER_PARAM
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<8) //takes a GPU_TEXTURE_WRAP_PARAM
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<12) //takes a GPU_TEXTURE_WRAP_PARAM
extern u32* gpuCmdBuf; ///< GPU command buffer.
extern u32 gpuCmdBufSize; ///< GPU command buffer size.
extern u32 gpuCmdBufOffset; ///< GPU command buffer offset.
typedef enum
/**
* @brief Sets the GPU command buffer to use.
* @param adr Pointer to the command buffer.
* @param size Size of the command buffer.
* @param offset Offset of the command buffer.
*/
static inline void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset)
{
GPU_NEAREST = 0x0,
GPU_LINEAR = 0x1,
}GPU_TEXTURE_FILTER_PARAM;
gpuCmdBuf=adr;
gpuCmdBufSize=size;
gpuCmdBufOffset=offset;
}
typedef enum
/**
* @brief Sets the offset of the GPU command buffer.
* @param offset Offset of the command buffer.
*/
static inline void GPUCMD_SetBufferOffset(u32 offset)
{
GPU_CLAMP_TO_EDGE = 0x0,
GPU_REPEAT = 0x2,
}GPU_TEXTURE_WRAP_PARAM;
gpuCmdBufOffset=offset;
}
typedef enum
/**
* @brief Gets the current GPU command buffer.
* @param addr Pointer to output the command buffer to.
* @param size Pointer to output the size (in words) of the command buffer to.
* @param offset Pointer to output the offset of the command buffer to.
*/
static inline void GPUCMD_GetBuffer(u32** addr, u32* size, u32* offset)
{
GPU_TEXUNIT0 = 0x1,
GPU_TEXUNIT1 = 0x2,
GPU_TEXUNIT2 = 0x4
} GPU_TEXUNIT;
if(addr)*addr=gpuCmdBuf;
if(size)*size=gpuCmdBufSize;
if(offset)*offset=gpuCmdBufOffset;
}
typedef enum{
GPU_RGBA8=0x0,
GPU_RGB8=0x1,
GPU_RGBA5551=0x2,
GPU_RGB565=0x3,
GPU_RGBA4=0x4,
GPU_LA8=0x5,
GPU_HILO8=0x6,
GPU_L8=0x7,
GPU_A8=0x8,
GPU_LA4=0x9,
GPU_L4=0xA,
GPU_ETC1=0xB,
GPU_ETC1A4=0xC
}GPU_TEXCOLOR;
/**
* @brief Adds raw GPU commands to the current command buffer.
* @param cmd Buffer containing commands to add.
* @param size Size of the buffer.
*/
void GPUCMD_AddRawCommands(const u32* cmd, u32 size);
typedef enum
/**
* @brief Adds a GPU command to the current command buffer.
* @param header Header of the command.
* @param param Parameters of the command.
* @param paramlength Size of the parameter buffer.
*/
void GPUCMD_Add(u32 header, const u32* param, u32 paramlength);
/**
* @brief Splits the current GPU command buffer.
* @param addr Pointer to output the command buffer to.
* @param size Pointer to output the size (in words) of the command buffer to.
*/
void GPUCMD_Split(u32** addr, u32* size);
/**
* @brief Converts a 32-bit float to a 16-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof16(float f);
/**
* @brief Converts a 32-bit float to a 20-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof20(float f);
/**
* @brief Converts a 32-bit float to a 24-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof24(float f);
/**
* @brief Converts a 32-bit float to a 31-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof31(float f);
/// Adds a command with a single parameter to the current command buffer.
static inline void GPUCMD_AddSingleParam(u32 header, u32 param)
{
GPU_NEVER = 0,
GPU_ALWAYS = 1,
GPU_EQUAL = 2,
GPU_NOTEQUAL = 3,
GPU_LESS = 4,
GPU_LEQUAL = 5,
GPU_GREATER = 6,
GPU_GEQUAL = 7
}GPU_TESTFUNC;
GPUCMD_Add(header, &param, 1);
}
typedef enum
{
GPU_SCISSOR_DISABLE = 0, // disable scissor test
GPU_SCISSOR_INVERT = 1, // exclude pixels inside the scissor box
// 2 is the same as 0
GPU_SCISSOR_NORMAL = 3, // exclude pixels outside of the scissor box
} GPU_SCISSORMODE;
typedef enum
{
GPU_KEEP = 0, // keep destination value
GPU_AND_NOT = 1, // destination & ~source
GPU_XOR = 5, // destination ^ source
// 2 is the same as 1. Other values are too weird to even be usable.
} GPU_STENCILOP;
typedef enum
{
GPU_WRITE_RED = 0x01,
GPU_WRITE_GREEN = 0x02,
GPU_WRITE_BLUE = 0x04,
GPU_WRITE_ALPHA = 0x08,
GPU_WRITE_DEPTH = 0x10,
GPU_WRITE_COLOR = 0x0F,
GPU_WRITE_ALL = 0x1F
} GPU_WRITEMASK;
typedef enum
{
GPU_BLEND_ADD = 0,
GPU_BLEND_SUBTRACT = 1,
GPU_BLEND_REVERSE_SUBTRACT = 2,
GPU_BLEND_MIN = 3,
GPU_BLEND_MAX = 4
} GPU_BLENDEQUATION;
typedef enum
{
GPU_ZERO = 0,
GPU_ONE = 1,
GPU_SRC_COLOR = 2,
GPU_ONE_MINUS_SRC_COLOR = 3,
GPU_DST_COLOR = 4,
GPU_ONE_MINUS_DST_COLOR = 5,
GPU_SRC_ALPHA = 6,
GPU_ONE_MINUS_SRC_ALPHA = 7,
GPU_DST_ALPHA = 8,
GPU_ONE_MINUS_DST_ALPHA = 9,
GPU_CONSTANT_COLOR = 10,
GPU_ONE_MINUS_CONSTANT_COLOR = 11,
GPU_CONSTANT_ALPHA = 12,
GPU_ONE_MINUS_CONSTANT_ALPHA = 13,
GPU_SRC_ALPHA_SATURATE = 14
} GPU_BLENDFACTOR;
typedef enum
{
GPU_LOGICOP_CLEAR = 0,
GPU_LOGICOP_AND = 1,
GPU_LOGICOP_AND_REVERSE = 2,
GPU_LOGICOP_COPY = 3,
GPU_LOGICOP_SET = 4,
GPU_LOGICOP_COPY_INVERTED = 5,
GPU_LOGICOP_NOOP = 6,
GPU_LOGICOP_INVERT = 7,
GPU_LOGICOP_NAND = 8,
GPU_LOGICOP_OR = 9,
GPU_LOGICOP_NOR = 10,
GPU_LOGICOP_XOR = 11,
GPU_LOGICOP_EQUIV = 12,
GPU_LOGICOP_AND_INVERTED = 13,
GPU_LOGICOP_OR_REVERSE = 14,
GPU_LOGICOP_OR_INVERTED = 15
} GPU_LOGICOP;
typedef enum{
GPU_BYTE = 0,
GPU_UNSIGNED_BYTE = 1,
GPU_SHORT = 2,
GPU_FLOAT = 3
}GPU_FORMATS;
//defines for CW ?
typedef enum{
GPU_CULL_NONE = 0,
GPU_CULL_FRONT_CCW = 1,
GPU_CULL_BACK_CCW = 2
}GPU_CULLMODE;
#define GPU_ATTRIBFMT(i, n, f) (((((n)-1)<<2)|((f)&3))<<((i)*4))
typedef enum{
GPU_PRIMARY_COLOR = 0x00,
GPU_TEXTURE0 = 0x03,
GPU_TEXTURE1 = 0x04,
GPU_TEXTURE2 = 0x05,
GPU_TEXTURE3 = 0x06,
GPU_CONSTANT = 0x0E,
GPU_PREVIOUS = 0x0F,
}GPU_TEVSRC;
typedef enum{
GPU_REPLACE = 0x00,
GPU_MODULATE = 0x01,
GPU_ADD = 0x02,
GPU_ADD_SIGNED = 0x03,
GPU_INTERPOLATE = 0x04,
GPU_SUBTRACT = 0x05,
GPU_DOT3_RGB = 0x06 //RGB only
}GPU_COMBINEFUNC;
#define GPU_TEVSOURCES(a,b,c) (((a))|((b)<<4)|((c)<<8))
#define GPU_TEVOPERANDS(a,b,c) (((a))|((b)<<4)|((c)<<8))
typedef enum{
GPU_TRIANGLES = 0x0000,
GPU_TRIANGLE_STRIP = 0x0100,
GPU_TRIANGLE_FAN = 0x0200,
GPU_UNKPRIM = 0x0300 // ?
}GPU_Primitive_t;
void GPU_SetUniform(u32 startreg, u32* data, u32 numreg);
void GPU_SetViewport(u32* depthBuffer, u32* colorBuffer, u32 x, u32 y, u32 w, u32 h);
void GPU_SetScissorTest(GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h);
void GPU_DepthRange(float nearVal, float farVal);
void GPU_SetAlphaTest(bool enable, GPU_TESTFUNC function, u8 ref);
void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask); // GPU_WRITEMASK values can be ORed together
void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 mask, u8 replace);
void GPU_SetStencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass);
void GPU_SetFaceCulling(GPU_CULLMODE mode);
// these two can't be used together
void GPU_SetAlphaBlending(GPU_BLENDEQUATION colorEquation, GPU_BLENDEQUATION alphaEquation,
GPU_BLENDFACTOR colorSrc, GPU_BLENDFACTOR colorDst,
GPU_BLENDFACTOR alphaSrc, GPU_BLENDFACTOR alphaDst);
void GPU_SetColorLogicOp(GPU_LOGICOP op);
void GPU_SetBlendingColor(u8 r, u8 g, u8 b, u8 a);
void GPU_SetAttributeBuffers(u8 totalAttributes, u32* baseAddress, u64 attributeFormats, u16 attributeMask, u64 attributePermutation, u8 numBuffers, u32 bufferOffsets[], u64 bufferPermutations[], u8 bufferNumAttributes[]);
void GPU_SetTextureEnable(GPU_TEXUNIT units); // GPU_TEXUNITx values can be ORed together to enable multiple texture units
void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType);
void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor);
void GPU_DrawArray(GPU_Primitive_t primitive, u32 n);
void GPU_DrawElements(GPU_Primitive_t primitive, u32* indexArray, u32 n);
void GPU_FinishDrawing();
/// Adds a masked register write to the current command buffer.
#define GPUCMD_AddMaskedWrite(reg, mask, val) GPUCMD_AddSingleParam(GPUCMD_HEADER(0, (mask), (reg)), (val))
/// Adds a register write to the current command buffer.
#define GPUCMD_AddWrite(reg, val) GPUCMD_AddMaskedWrite((reg), 0xF, (val))
/// Adds multiple masked register writes to the current command buffer.
#define GPUCMD_AddMaskedWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(0, (mask), (reg)), (vals), (num))
/// Adds multiple register writes to the current command buffer.
#define GPUCMD_AddWrites(reg, vals, num) GPUCMD_AddMaskedWrites((reg), 0xF, (vals), (num))
/// Adds multiple masked incremental register writes to the current command buffer.
#define GPUCMD_AddMaskedIncrementalWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(1, (mask), (reg)), (vals), (num))
/// Adds multiple incremental register writes to the current command buffer.
#define GPUCMD_AddIncrementalWrites(reg, vals, num) GPUCMD_AddMaskedIncrementalWrites((reg), 0xF, (vals), (num))

View File

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

View File

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

View File

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

View File

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

View File

@ -1,68 +0,0 @@
#pragma once
typedef enum{
VERTEX_SHDR=0x0,
GEOMETRY_SHDR=0x1
}SHDR_type;
typedef enum{
RESULT_POSITION = 0x0,
RESULT_COLOR = 0x2,
RESULT_TEXCOORD0 = 0x3,
RESULT_TEXCOORD1 = 0x5,
RESULT_TEXCOORD2 = 0x6
}SHDR_outType;
typedef struct{
u32 codeSize;
u32* codeData;
u32 opdescSize;
u32* opcdescData;
}DVLP_s;
typedef struct{
u32 header;
u32 data[4];
}DVLE_constEntry_s;
typedef struct{
u16 type;
u16 regID;
u32 header;
}DVLE_outEntry_s;
typedef struct{
u32 symbolOffset;
u16 startReg;
u16 endReg;
}DVLE_uniformEntry_s;
typedef struct{
SHDR_type type;
u32 mainOffset, endmainOffset;
u32 constTableSize;
DVLE_constEntry_s* constTableData;
u32 outTableSize;
DVLE_outEntry_s* outTableData;
u32 uniformTableSize;
DVLE_uniformEntry_s* uniformTableData;
char* symbolTableData;
}DVLE_s;
typedef struct{
u32 numDVLE;
DVLP_s DVLP;
DVLE_s* DVLE;
}DVLB_s;
DVLB_s* SHDR_ParseSHBIN(u32* shbinData, u32 shbinSize);
void SHDR_UseProgram(DVLB_s* dvlb, u8 id);
void SHDR_FreeDVLB(DVLB_s* dvlb);
s8 SHDR_GetUniformRegister(DVLB_s* dvlb, const char* name, u8 programID);
void DVLP_SendCode(DVLP_s* dvlp);
void DVLP_SendOpDesc(DVLP_s* dvlp);
void DVLE_SendOutmap(DVLE_s* dvle);
void DVLE_SendConstants(DVLE_s* dvle);

118
libctru/include/3ds/ipc.h Normal file
View File

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

View File

@ -1,8 +0,0 @@
#pragma once
// Functions for allocating/deallocating memory from linear heap
void* linearAlloc(size_t size); // returns a 16-byte aligned address
void* linearMemAlign(size_t size, size_t alignment);
void* linearRealloc(void* mem, size_t size); // not implemented yet
void linearFree(void* mem);
u32 linearSpaceFree(); // get free linear space in bytes

159
libctru/include/3ds/mii.h Normal file
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +0,0 @@
#pragma once
#include <3ds/types.h>
Result sdmcInit(void);
Result sdmcExit(void);

View File

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

View File

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

View File

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

View File

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

View File

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

Some files were not shown because too many files have changed in this diff Show More