Compare commits

...

982 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
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
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
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
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
316 changed files with 45736 additions and 20523 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" ! -path "./bin/*" -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,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.h %.vsh.o : %.vsh
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@python3 $(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: 51bfeef9e1a0149726dca43b50919bd45917015a )
and update AEMSTRO environment variable with the proper path
You'll also need to install Python 3 and have that in your path.

View File

@ -1,57 +0,0 @@
; setup constants
.const c20, 1.0, 0.0, 0.5, 1.0
; setup outmap
.out o0, result.position, 0xF
.out o1, result.color, 0xF
.out o2, result.texcoord0, 0x3
.out o3, result.texcoord1, 0x3
.out o4, result.texcoord2, 0x3
; setup uniform map (not required)
.uniform c0, c3, projection
.uniform c4, c7, modelview
.uniform c8, c8, lightDirection
.uniform c9, c9, lightAmbient
.vsh vmain, end_vmain
;code
vmain:
mov r1, v0 (0x4)
mov r1, c20 (0x3)
; temp = modvMtx * in.pos
dp4 r0, c4, r1 (0x0)
dp4 r0, c5, r1 (0x1)
dp4 r0, c6, r1 (0x2)
mov r0, c20 (0x3)
; result.pos = projMtx * temp
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 (0x4)
max r0, c20, r0 (0x9)
mul r0, c9, r0 (0x4)
add o1, c9, r0 (0x4)
mov o1, c20 (0x3)
nop
end
end_vmain:
;operand descriptors
.opdesc x___, xyzw, xyzw ; 0x0
.opdesc _y__, xyzw, xyzw ; 0x1
.opdesc __z_, xyzw, xyzw ; 0x2
.opdesc ___w, xyzw, xyzw ; 0x3
.opdesc xyz_, xyzw, xyzw ; 0x4
.opdesc xyzw, xyzw, xyzw ; 0x5
.opdesc x_zw, xyzw, xyzw ; 0x6
.opdesc xyzw, yyyw, xyzw ; 0x7
.opdesc xyz_, wwww, wwww ; 0x8
.opdesc xyz_, yyyy, xyzw ; 0x9

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,432 +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(shaderProgram_s* shader)
{
gsInitMatrixStack();
initBufferMatrixList();
svcCreateMutex(&linearAllocMutex, false);
if(shader)
{
gsMatrixStackRegisters[0]=shaderInstanceGetUniformLocation(shader->vertexShader, "projection");
gsMatrixStackRegisters[1]=shaderInstanceGetUniformLocation(shader->vertexShader, "modelview");
shaderProgramUse(shader);
}
}
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_SetFloatUniform(GPU_VERTEX_SHADER, 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(shaderProgram_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,330 +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* dvlb;
shaderProgram_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_DepthMap(-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_AddMaskedWrite(GPUREG_0062, 0x1, 0);
GPUCMD_AddWrite(GPUREG_0118, 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_SetFloatUniform(GPU_VERTEX_SHADER, shaderInstanceGetUniformLocation(shader.vertexShader, "lightDirection"), (u32*)(float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x}, 1);
GPU_SetFloatUniform(GPU_VERTEX_SHADER, shaderInstanceGetUniformLocation(shader.vertexShader, "lightAmbient"), (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);
//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);
//load our vertex shader binary
dvlb=DVLB_ParseFile((u32*)test_vsh_shbin, test_vsh_shbin_size);
shaderProgramInit(&shader);
shaderProgramSetVsh(&shader, &dvlb->DVLE[0]);
//initialize GS
gsInit(&shader);
// Flush the command buffer so that the shader upload gets executed
GPUCMD_Finalize();
GPUCMD_FlushAndRun(NULL);
gspWaitForP3D();
//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();
shaderProgramFree(&shader);
DVLB_Free(dvlb);
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,193 +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 :=
INCLUDES := include
GRAPHICS := gfx
#---------------------------------------------------------------------------------
# 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)) \
$(foreach dir,$(GRAPHICS),$(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)/*.*)))
PNGFILES := $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.png)))
#---------------------------------------------------------------------------------
# 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)) \
$(PNGFILES:.png=.bgr.o) \
$(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
IMAGEMAGICK := $(shell which convert)
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
.PHONY: $(BUILD) clean all
#---------------------------------------------------------------------------------
ifeq ($(strip $(IMAGEMAGICK)),)
all:
@echo "Image Magick not found!"
@echo
@echo "Please install Image Magick from http://www.imagemagick.org/ to build this example"
else
all: $(BUILD)
endif
#---------------------------------------------------------------------------------
$(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)
#---------------------------------------------------------------------------------
%.bgr.o: %.bgr
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------
%.bgr: %.png
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@convert $< -rotate 90 $@
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,16 +0,0 @@
24bit Bitmap Example
=======
This example shows on bottom screen an upscaled version of the nds examples Drunken Coders logo that can be found in devkitPro.
If you want to try with your own image follow these steps:
1. Download & install: http://www.imagemagick.org/ (If you get an option to add the application to the path make sure to check it!).
2. convert fileIn.png -channel B -separate fileIn.png -channel G -separate fileIn.png -channel R -separate -channel RGB -combine -rotate 90 fileOut.rgb
3. Rename fileOut.rgb in fileOut.bin
4. Copy fileOut.bin in the data folder of your project
5. Replace any reference of drunkenlogo_bin in main.cpp with fileOut_bin (or however you named it)
6. Re-Build the project
As you can see from the previos steps the image is clockwise rotated by 90 degrees and its B and R channels are swapped. The first operation is done because the 3DS screens are actually portrait screens rotated by 90 degrees (in a counter-clockwise direction), while the second one is done because the 3DS screens' framebuffers have a BGR888 color format, by default.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

View File

@ -1,64 +0,0 @@
/*
Hello World example made by Aurelio Mannara for ctrulib
This code was modified for the last time on: 12/13/2014 01: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>
#include <string.h>
//This include a header containing definitions of our image
#include "brew_bgr.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);
printf("Why so sad Smealum? We can haz 3DS homebrew!");
printf("\x1b[20;15HPress Start to exit.");
//We don't need double buffering in this example. In this way we can draw our image only once on screen.
gfxSetDoubleBuffering(GFX_BOTTOM, false);
//Get the bottom screen's frame buffer
u8* fb = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
//Copy our image in the bottom screen's frame buffer
memcpy(fb, brew_bgr, brew_bgr_size);
// 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();
}
// Exit services
gfxExit();
return 0;
}

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,174 +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,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 to 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,174 +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 @@
# 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,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,174 +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,105 +0,0 @@
/*
Circle Pad example made by Aurelio Mannara for ctrulib
Please refer to https://github.com/smealum/ctrulib/blob/master/libctru/include/3ds/services/hid.h for more information
This code was modified for the last time on: 12/13/2014 2:20 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)
{
//Matrix containing the name of each key. Useful for printing when a key is pressed
char keysNames[32][32] = {
"KEY_A", "KEY_B", "KEY_SELECT", "KEY_START",
"KEY_DRIGHT", "KEY_DLEFT", "KEY_DUP", "KEY_DDOWN",
"KEY_R", "KEY_L", "KEY_X", "KEY_Y",
"", "", "KEY_ZL", "KEY_ZR",
"", "", "", "",
"KEY_TOUCH", "", "", "",
"KEY_CSTICK_RIGHT", "KEY_CSTICK_LEFT", "KEY_CSTICK_UP", "KEY_CSTICK_DOWN",
"KEY_CPAD_RIGHT", "KEY_CPAD_LEFT", "KEY_CPAD_UP", "KEY_CPAD_DOWN"
};
// Initialize services
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);
u32 kDownOld = 0, kHeldOld = 0, kUpOld = 0; //In these variables there will be information about keys detected in the previous frame
printf("\x1b[0;0HPress Start to exit.");
printf("\x1b[1;0HCirclePad position:");
// 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();
//hidKeysHeld returns information about which buttons have are held down in this frame
u32 kHeld = hidKeysHeld();
//hidKeysUp returns information about which buttons have been just released
u32 kUp = hidKeysUp();
if (kDown & KEY_START) break; // break in order to return to hbmenu
//Do the keys printing only if keys have changed
if (kDown != kDownOld || kHeld != kHeldOld || kUp != kUpOld)
{
//Clear console
consoleClear();
//These two lines must be rewritten because we cleared the whole console
printf("\x1b[0;0HPress Start to exit.");
printf("\x1b[1;0HCirclePad position:");
printf("\x1b[3;0H"); //Move the cursor to the fourth row because on the third one we'll write the circle pad position
//Check if some of the keys are down, held or up
int i;
for (i = 0; i < 32; i++)
{
if (kDown & BIT(i)) printf("%s down\n", keysNames[i]);
if (kHeld & BIT(i)) printf("%s held\n", keysNames[i]);
if (kUp & BIT(i)) printf("%s up\n", keysNames[i]);
}
}
//Set keys old values for the next frame
kDownOld = kDown;
kHeldOld = kHeld;
kUpOld = kUp;
circlePosition pos;
//Read the CirclePad position
hidCircleRead(&pos);
//Print the CirclePad position
printf("\x1b[2;0H%04d; %04d", pos.dx, pos.dy);
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
//Wait for VBlank
gspWaitForVBlank();
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,174 +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,60 +0,0 @@
/*
Touch Screen example made by Aurelio Mannara for ctrulib
Please refer to https://github.com/smealum/ctrulib/blob/master/libctru/include/3ds/services/hid.h for more information
This code was modified for the last time on: 12/13/2014 2:30 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);
printf("\x1b[0;0HPress Start to exit.");
printf("\x1b[1;0HTouch Screen position:");
// 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
touchPosition touch;
//Read the touch screen coordinates
hidTouchRead(&touch);
//Print the touch screen coordinates
printf("\x1b[2;0H%03d; %03d", touch.px, touch.py);
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
//Wait for VBlank
gspWaitForVBlank();
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,174 +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,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,174 +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 +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,179 +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
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,174 +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,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;
}

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,163 +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)
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,81 +0,0 @@
#include <string.h>
#include <malloc.h>
#include <inttypes.h>
#include <stdio.h>
#include <3ds.h>
Handle threadHandle, threadRequest;
#define STACKSIZE (4 * 1024)
volatile bool threadExit = false;
volatile int threadcount=0;
void threadMain(void *arg) {
while(1) {
svcWaitSynchronization(threadRequest, U64_MAX);
svcClearEvent(threadRequest);
if(threadExit) svcExitThread();
threadcount++;
}
}
int main(int argc, char** argv) {
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
svcCreateEvent(&threadRequest,0);
u32 *threadStack = memalign(32, STACKSIZE);
Result ret = svcCreateThread(&threadHandle, threadMain, 0, &threadStack[STACKSIZE/4], 0x3f, 0);
printf("thread create returned %x\n", ret);
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
printf("\x1b[5;0H");
printf("thread counter = %d\n",threadcount);
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
if (kDown & KEY_A)
svcSignalEvent(threadRequest);
// Flush and swap framebuffers
gfxFlushBuffers();
gfxSwapBuffers();
}
// tell thread to exit
threadExit = true;
// signal the thread
svcSignalEvent(threadRequest);
// give it time to exit
svcSleepThread(10000000ULL);
// close handles and free allocated stack
svcCloseHandle(threadRequest);
svcCloseHandle(threadHandle);
free(threadStack);
gfxExit();
return 0;
}

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,8 +8,8 @@ endif
include $(DEVKITARM)/base_rules
export LIBCTRU_MAJOR := 0
export LIBCTRU_MINOR := 5
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,18 +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 \
-fno-strict-aliasing \
-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
@ -65,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)))
@ -91,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 data 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
@ -141,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,49 +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/ns.h>
#include <3ds/services/pm.h>
#include <3ds/services/pmapp.h>
#include <3ds/services/pmdbg.h>
#include <3ds/services/ps.h>
#include <3ds/services/ptm.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/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,244 +1,119 @@
/**
* @file gpu.h
* @brief Barebones GPU communications driver.
*/
#pragma once
#include "3ds/gpu/registers.h"
#include "registers.h"
#include "enums.h"
//GPU
void GPU_Init(Handle *gsphandle);
void GPU_Reset(u32* gxbuf, u32* gpuBuf, u32 gpuBufSize);
//GPUCMD
/// 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))
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 header, u32* param, u32 paramlength);
void GPUCMD_Finalize();
extern u32* gpuCmdBuf; ///< GPU command buffer.
extern u32 gpuCmdBufSize; ///< GPU command buffer size.
extern u32 gpuCmdBufOffset; ///< GPU command buffer offset.
#define GPUCMD_AddSingleParam(header, param) GPUCMD_Add((header), (u32[]){(u32)(param)}, 1)
/**
* @brief Sets the GPU command buffer to use.
* @param adr Pointer to the command buffer.
* @param size Size of the command buffer.
* @param offset Offset of the command buffer.
*/
static inline void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset)
{
gpuCmdBuf=adr;
gpuCmdBufSize=size;
gpuCmdBufOffset=offset;
}
/**
* @brief Sets the offset of the GPU command buffer.
* @param offset Offset of the command buffer.
*/
static inline void GPUCMD_SetBufferOffset(u32 offset)
{
gpuCmdBufOffset=offset;
}
/**
* @brief Gets the current GPU command buffer.
* @param addr Pointer to output the command buffer to.
* @param size Pointer to output the size (in words) of the command buffer to.
* @param offset Pointer to output the offset of the command buffer to.
*/
static inline void GPUCMD_GetBuffer(u32** addr, u32* size, u32* offset)
{
if(addr)*addr=gpuCmdBuf;
if(size)*size=gpuCmdBufSize;
if(offset)*offset=gpuCmdBufOffset;
}
/**
* @brief Adds raw GPU commands to the current command buffer.
* @param cmd Buffer containing commands to add.
* @param size Size of the buffer.
*/
void GPUCMD_AddRawCommands(const u32* cmd, u32 size);
/**
* @brief Adds a GPU command to the current command buffer.
* @param header Header of the command.
* @param param Parameters of the command.
* @param paramlength Size of the parameter buffer.
*/
void GPUCMD_Add(u32 header, const u32* param, u32 paramlength);
/**
* @brief Splits the current GPU command buffer.
* @param addr Pointer to output the command buffer to.
* @param size Pointer to output the size (in words) of the command buffer to.
*/
void GPUCMD_Split(u32** addr, u32* size);
/**
* @brief Converts a 32-bit float to a 16-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof16(float f);
/**
* @brief Converts a 32-bit float to a 20-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof20(float f);
/**
* @brief Converts a 32-bit float to a 24-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof24(float f);
/**
* @brief Converts a 32-bit float to a 31-bit float.
* @param f Float to convert.
* @return The converted float.
*/
u32 f32tof31(float f);
/// Adds a command with a single parameter to the current command buffer.
static inline void GPUCMD_AddSingleParam(u32 header, u32 param)
{
GPUCMD_Add(header, &param, 1);
}
/// Adds a masked register write to the current command buffer.
#define GPUCMD_AddMaskedWrite(reg, mask, val) GPUCMD_AddSingleParam(GPUCMD_HEADER(0, (mask), (reg)), (val))
/// Adds a register write to the current command buffer.
#define GPUCMD_AddWrite(reg, val) GPUCMD_AddMaskedWrite((reg), 0xF, (val))
/// Adds multiple masked register writes to the current command buffer.
#define GPUCMD_AddMaskedWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(0, (mask), (reg)), (vals), (num))
/// Adds multiple register writes to the current command buffer.
#define GPUCMD_AddWrites(reg, vals, num) GPUCMD_AddMaskedWrites((reg), 0xF, (vals), (num))
/// Adds multiple masked incremental register writes to the current command buffer.
#define GPUCMD_AddMaskedIncrementalWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(1, (mask), (reg)), (vals), (num))
/// Adds multiple incremental register writes to the current command buffer.
#define GPUCMD_AddIncrementalWrites(reg, vals, num) GPUCMD_AddMaskedIncrementalWrites((reg), 0xF, (vals), (num))
//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
typedef enum
{
GPU_NEAREST = 0x0,
GPU_LINEAR = 0x1,
}GPU_TEXTURE_FILTER_PARAM;
typedef enum
{
GPU_CLAMP_TO_EDGE = 0x0,
GPU_REPEAT = 0x2,
}GPU_TEXTURE_WRAP_PARAM;
typedef enum
{
GPU_TEXUNIT0 = 0x1,
GPU_TEXUNIT1 = 0x2,
GPU_TEXUNIT2 = 0x4
} GPU_TEXUNIT;
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;
typedef enum
{
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;
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;
typedef enum{
GPU_VERTEX_SHADER=0x0,
GPU_GEOMETRY_SHADER=0x1
}GPU_SHADER_TYPE;
void GPU_SetFloatUniform(GPU_SHADER_TYPE type, 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_DepthMap(float zScale, float zOffset);
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();
void GPU_SetShaderOutmap(u32 outmapData[8]);
void GPU_SendShaderCode(GPU_SHADER_TYPE type, u32* data, u16 offset, u16 length);
void GPU_SendOperandDescriptors(GPU_SHADER_TYPE type, u32* data, u16 offset, u16 length);

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);

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,120 @@
#pragma once
#include <3ds/types.h>
#include <3ds/gpu/shbin.h>
typedef struct
{
u32 id;
u32 data[3];
}float24Uniform_s;
// this structure describes an instance of either a vertex or geometry shader
typedef struct
{
DVLE_s* dvle;
u16 boolUniforms;
u32 intUniforms[4];
float24Uniform_s* float24Uniforms;
u8 numFloat24Uniforms;
}shaderInstance_s;
// this structure describes an instance of a full shader program
typedef struct
{
shaderInstance_s* vertexShader;
shaderInstance_s* geometryShader;
u8 geometryShaderInputStride;
}shaderProgram_s;
Result shaderInstanceInit(shaderInstance_s* si, DVLE_s* dvle);
Result shaderInstanceFree(shaderInstance_s* si);
Result shaderInstanceSetBool(shaderInstance_s* si, int id, bool value);
Result shaderInstanceGetBool(shaderInstance_s* si, int id, bool* value);
Result shaderInstanceGetUniformLocation(shaderInstance_s* si, const char* name);
Result shaderProgramInit(shaderProgram_s* sp);
Result shaderProgramFree(shaderProgram_s* sp);
Result shaderProgramSetVsh(shaderProgram_s* sp, DVLE_s* dvle);
Result shaderProgramSetGsh(shaderProgram_s* sp, DVLE_s* dvle, u8 stride);
Result shaderProgramUse(shaderProgram_s* sp);
/**
* @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

@ -1,78 +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,
GEOMETRY_SHDR=GPU_GEOMETRY_SHADER
VERTEX_SHDR=GPU_VERTEX_SHADER, ///< Vertex shader.
GEOMETRY_SHDR=GPU_GEOMETRY_SHADER ///< Geometry shader.
}DVLE_type;
/// Constant type.
typedef enum{
DVLE_CONST_BOOL=0x0,
DVLE_CONST_u8=0x1,
DVLE_CONST_FLOAT24=0x2,
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,
RESULT_NORMALQUAT = 0x1,
RESULT_COLOR = 0x2,
RESULT_TEXCOORD0 = 0x3,
RESULT_TEXCOORD0W = 0x4,
RESULT_TEXCOORD1 = 0x5,
RESULT_TEXCOORD2 = 0x6,
RESULT_VIEW = 0x8
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;
u32* codeData;
u32 opdescSize;
u32* opcdescData;
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;
u16 id;
u32 data[4];
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;
u16 regID;
u8 mask;
u8 unk[3];
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;
u16 startReg;
u16 endReg;
u32 symbolOffset; ///< Symbol offset.
u16 startReg; ///< Start register.
u16 endReg; ///< End register.
}DVLE_uniformEntry_s;
/// DVLE data.
typedef struct{
DVLE_type type;
DVLP_s* dvlp;
u32 mainOffset, endmainOffset;
u32 constTableSize;
DVLE_constEntry_s* constTableData;
u32 outTableSize;
DVLE_outEntry_s* outTableData;
u32 uniformTableSize;
DVLE_uniformEntry_s* uniformTableData;
char* symbolTableData;
u8 outmapMask;
u32 outmapData[8];
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;
DVLP_s DVLP;
DVLE_s* DVLE;
u32 numDVLE; ///< DVLE count.
DVLP_s DVLP; ///< Primary DVLP.
DVLE_s* DVLE; ///< Contained DVLE.
}DVLB_s;
/**
* @brief Parses a shader binary.
* @param shbinData Shader binary data.
* @param shbinSize Shader binary size.
* @return The parsed shader binary.
*/
DVLB_s* DVLB_ParseFile(u32* shbinData, u32 shbinSize);
/**
* @brief Frees shader binary data.
* @param dvlb DVLB to free.
*/
void DVLB_Free(DVLB_s* dvlb);
/**
* @brief Gets a uniform register index from a shader.
* @param dvle Shader to get the register from.
* @param name Name of the register.
* @return The uniform register index.
*/
s8 DVLE_GetUniformRegister(DVLE_s* dvle, const char* name);
/**
* @brief Generates a shader output map.
* @param dvle Shader to generate an output map for.
*/
void DVLE_GenerateOutmap(DVLE_s* dvle);

118
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;

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