Compare commits

...

584 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
332 changed files with 31310 additions and 21795 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

1
.gitignore vendored
View File

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

View File

@ -1,47 +0,0 @@
language: c
sudo: false
#Cache devkitArm and doxygen
cache:
directories:
- /home/travis/devkitPro
- /home/travis/doxygen/doxygen-1.8.10/bin
before_install:
# Travis has an OLD doxygen build, so we fetch a recent one
- export DOXY_BINPATH=/home/travis/doxygen/doxygen-1.8.10/bin
- if [ ! -e "$DOXY_BINPATH/doxygen" ]; then mkdir -p ~/doxygen && cd ~/doxygen; fi
- if [ ! -e "$DOXY_BINPATH/doxygen" ]; then wget http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.10.linux.bin.tar.gz; fi
- if [ ! -e "$DOXY_BINPATH/doxygen" ]; then tar xzf doxygen-1.8.10.linux.bin.tar.gz; fi
- export PATH=$PATH:$DOXY_BINPATH
# Prepare devkitArm update
- export DEVKITPRO=/home/travis/devkitPro
- export DEVKITARM=${DEVKITPRO}/devkitARM
- mkdir -p $DEVKITPRO
- cd $DEVKITPRO
- wget -N http://sourceforge.net/projects/devkitpro/files/Automated%20Installer/devkitARMupdate.pl
-
install:
- cd $DEVKITPRO
# Install or update devkitArm if it's cached
- perl devkitARMupdate.pl
- cd $TRAVIS_BUILD_DIR
env:
global:
- secure: "BkEGbVRearmBLntY9WSuFkaiO2qAMMN43qocbkCL18dGbIDJA7vlUXXCKkahdsS5TU9j7xdcybCokmPBuvMCNRvQcDVwDcYbuh+ASmqG8Br1hphUScWPZNkcVSgTcHqNHh2k+05NP6d3vm3utOLgGZt/V5p+XcdGHti86KMeY34="
script:
- cd $TRAVIS_BUILD_DIR/libctru
- make
after_success:
- cd $TRAVIS_BUILD_DIR
- #Build the doxygen files and upload to GH pages
- git config --global user.email "travis@travis-ci.org"
- git config --global user.name "TravisCI-DocBuilder"
# Build the doxygen documentation and push it to gh-pages if current branch is great-refactor
- sh exportdoc.sh

View File

@ -1,5 +1,434 @@
# 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:

View File

@ -1,18 +1,26 @@
# libctru - 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)
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.
*(Originally located at github.com/smealum/ctrulib)*
# Setup
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.
The most recent version of devkitARM (r45 at the time of writing) is always recommended. The installers/setup scripts 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.
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.
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

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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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(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(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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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,102 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <3ds.h>
int main()
{
gfxInitDefault();
consoleInit(GFX_BOTTOM, NULL);
bool initialized = true;
u32 micbuf_size = 0x30000;
u32 micbuf_pos = 0;
u8* micbuf = memalign(0x1000, micbuf_size);
printf("Initializing CSND...\n");
if(R_FAILED(csndInit()))
{
initialized = false;
printf("Could not initialize CSND.\n");
} else printf("CSND initialized.\n");
printf("Initializing MIC...\n");
if(R_FAILED(micInit(micbuf, micbuf_size)))
{
initialized = false;
printf("Could not initialize MIC.\n");
} else printf("MIC initialized.\n");
u32 micbuf_datasize = micGetSampleDataSize();
u32 audiobuf_size = 0x100000;
u32 audiobuf_pos = 0;
u8* audiobuf = linearAlloc(audiobuf_size);
if(initialized) printf("Hold A to record, release to play.\n");
printf("Press START to exit.\n");
while(aptMainLoop())
{
hidScanInput();
gspWaitForVBlank();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
if(initialized)
{
if(kDown & KEY_A)
{
audiobuf_pos = 0;
micbuf_pos = 0;
printf("Stopping audio playback...\n");
CSND_SetPlayState(0x8, 0);
if(R_FAILED(CSND_UpdateInfo(0))) printf("Failed to stop audio playback.\n");
printf("Starting sampling...\n");
if(R_SUCCEEDED(MICU_StartSampling(MICU_ENCODING_PCM16_SIGNED, MICU_SAMPLE_RATE_16360, 0, micbuf_datasize, true))) printf("Now recording.\n");
else printf("Failed to start sampling.\n");
}
if((hidKeysHeld() & KEY_A) && audiobuf_pos < audiobuf_size)
{
u32 micbuf_readpos = micbuf_pos;
micbuf_pos = micGetLastSampleOffset();
while(audiobuf_pos < audiobuf_size && micbuf_readpos != micbuf_pos)
{
audiobuf[audiobuf_pos] = micbuf[micbuf_readpos];
audiobuf_pos++;
micbuf_readpos = (micbuf_readpos + 1) % micbuf_datasize;
}
}
if(hidKeysUp() & KEY_A)
{
printf("Stoping sampling...\n");
if(R_FAILED(MICU_StopSampling())) printf("Failed to stop sampling.\n");
printf("Starting audio playback...\n");
if(R_SUCCEEDED(GSPGPU_FlushDataCache(audiobuf, audiobuf_pos)) && R_SUCCEEDED(csndPlaySound(0x8, SOUND_ONE_SHOT | SOUND_FORMAT_16BIT, 16360, 1.0, 0.0, (u32*)audiobuf, NULL, audiobuf_pos))) printf("Now playing.\n");
else printf("Failed to start playback.\n");
}
}
gfxFlushBuffers();
gfxSwapBuffers();
}
linearFree(audiobuf);
micExit();
free(micbuf);
csndExit();
gfxExit();
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
image
=======
Example for using the camera to take 3D pictures with ctrulib. Press the R button to take a picture - it will be displayed on the top screen.
Currently this example does not make use of the 3DS camera's calibration data to get a correct 3D effect.

View File

@ -1,3 +0,0 @@
<targets selectable="false">
<title mediatype="0">0004001000021400</title>
</targets>

View File

@ -1,190 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <setjmp.h>
#include <3ds.h>
#include <sys/dirent.h>
#include <sys/errno.h>
#include <sys/unistd.h>
#include <stdbool.h>
#define CONFIG_3D_SLIDERSTATE (*(volatile float*)0x1FF81080)
#define WAIT_TIMEOUT 300000000ULL
#define WIDTH 400
#define HEIGHT 240
#define SCREEN_SIZE WIDTH * HEIGHT * 2
#define BUF_SIZE SCREEN_SIZE * 2
static jmp_buf exitJmp;
inline void clearScreen(void) {
u8 *frame = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
memset(frame, 0, 320 * 240 * 3);
}
void hang(char *message) {
clearScreen();
printf("%s", message);
printf("Press start to exit");
while (aptMainLoop()) {
hidScanInput();
u32 kHeld = hidKeysHeld();
if (kHeld & KEY_START) longjmp(exitJmp, 1);
}
}
void cleanup() {
camExit();
gfxExit();
acExit();
}
void writePictureToFramebufferRGB565(void *fb, void *img, u16 x, u16 y, u16 width, u16 height) {
u8 *fb_8 = (u8*) fb;
u16 *img_16 = (u16*) img;
int i, j, draw_x, draw_y;
for(j = 0; j < height; j++) {
for(i = 0; i < width; i++) {
draw_y = y + height - j;
draw_x = x + i;
u32 v = (draw_y + draw_x * height) * 3;
u16 data = img_16[j * width + i];
uint8_t b = ((data >> 11) & 0x1F) << 3;
uint8_t g = ((data >> 5) & 0x3F) << 2;
uint8_t r = (data & 0x1F) << 3;
fb_8[v] = r;
fb_8[v+1] = g;
fb_8[v+2] = b;
}
}
}
// TODO: Figure out how to use CAMU_GetStereoCameraCalibrationData
void takePicture3D(u8 *buf) {
u32 bufSize;
printf("CAMU_GetMaxBytes: 0x%08X\n", (unsigned int) CAMU_GetMaxBytes(&bufSize, WIDTH, HEIGHT));
printf("CAMU_SetTransferBytes: 0x%08X\n", (unsigned int) CAMU_SetTransferBytes(PORT_BOTH, bufSize, WIDTH, HEIGHT));
printf("CAMU_Activate: 0x%08X\n", (unsigned int) CAMU_Activate(SELECT_OUT1_OUT2));
Handle camReceiveEvent = 0;
Handle camReceiveEvent2 = 0;
printf("CAMU_ClearBuffer: 0x%08X\n", (unsigned int) CAMU_ClearBuffer(PORT_BOTH));
printf("CAMU_SynchronizeVsyncTiming: 0x%08X\n", (unsigned int) CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2));
printf("CAMU_StartCapture: 0x%08X\n", (unsigned int) CAMU_StartCapture(PORT_BOTH));
printf("CAMU_SetReceiving: 0x%08X\n", (unsigned int) CAMU_SetReceiving(&camReceiveEvent, buf, PORT_CAM1, SCREEN_SIZE, (s16) bufSize));
printf("CAMU_SetReceiving: 0x%08X\n", (unsigned int) CAMU_SetReceiving(&camReceiveEvent2, buf + SCREEN_SIZE, PORT_CAM2, SCREEN_SIZE, (s16) bufSize));
printf("svcWaitSynchronization: 0x%08X\n", (unsigned int) svcWaitSynchronization(camReceiveEvent, WAIT_TIMEOUT));
printf("svcWaitSynchronization: 0x%08X\n", (unsigned int) svcWaitSynchronization(camReceiveEvent2, WAIT_TIMEOUT));
printf("CAMU_PlayShutterSound: 0x%08X\n", (unsigned int) CAMU_PlayShutterSound(SHUTTER_SOUND_TYPE_NORMAL));
printf("CAMU_StopCapture: 0x%08X\n", (unsigned int) CAMU_StopCapture(PORT_BOTH));
svcCloseHandle(camReceiveEvent);
svcCloseHandle(camReceiveEvent2);
printf("CAMU_Activate: 0x%08X\n", (unsigned int) CAMU_Activate(SELECT_NONE));
}
int main() {
// Initializations
acInit();
gfxInitDefault();
consoleInit(GFX_BOTTOM, NULL);
// Enable double buffering to remove screen tearing
gfxSetDoubleBuffering(GFX_TOP, true);
gfxSetDoubleBuffering(GFX_BOTTOM, false);
// Save current stack frame for easy exit
if(setjmp(exitJmp)) {
cleanup();
return 0;
}
u32 kDown;
u32 kHeld;
printf("Initializing camera\n");
printf("camInit: 0x%08X\n", (unsigned int) camInit());
printf("CAMU_SetSize: 0x%08X\n", (unsigned int) CAMU_SetSize(SELECT_OUT1_OUT2, SIZE_CTR_TOP_LCD, CONTEXT_A));
printf("CAMU_SetOutputFormat: 0x%08X\n", (unsigned int) CAMU_SetOutputFormat(SELECT_OUT1_OUT2, OUTPUT_RGB_565, CONTEXT_A));
printf("CAMU_SetNoiseFilter: 0x%08X\n", (unsigned int) CAMU_SetNoiseFilter(SELECT_OUT1_OUT2, true));
printf("CAMU_SetAutoExposure: 0x%08X\n", (unsigned int) CAMU_SetAutoExposure(SELECT_OUT1_OUT2, true));
printf("CAMU_SetAutoWhiteBalance: 0x%08X\n", (unsigned int) CAMU_SetAutoWhiteBalance(SELECT_OUT1_OUT2, true));
//printf("CAMU_SetEffect: 0x%08X\n", (unsigned int) CAMU_SetEffect(SELECT_OUT1_OUT2, EFFECT_MONO, CONTEXT_A));
printf("CAMU_SetTrimming: 0x%08X\n", (unsigned int) CAMU_SetTrimming(PORT_CAM1, false));
printf("CAMU_SetTrimming: 0x%08X\n", (unsigned int) CAMU_SetTrimming(PORT_CAM2, false));
//printf("CAMU_SetTrimmingParamsCenter: 0x%08X\n", (unsigned int) CAMU_SetTrimmingParamsCenter(PORT_CAM1, 512, 240, 512, 384));
u8 *buf = malloc(BUF_SIZE);
if(!buf) {
hang("Failed to allocate memory!");
}
gfxFlushBuffers();
gspWaitForVBlank();
gfxSwapBuffers();
bool held_R = false;
printf("\nPress R to take a new picture\n");
printf("Use slider to enable/disable 3D\n");
printf("Press Start to exit to Homebrew Launcher\n");
// Main loop
while (aptMainLoop()) {
// Read which buttons are currently pressed or not
hidScanInput();
kDown = hidKeysDown();
kHeld = hidKeysHeld();
// If START button is pressed, break loop and quit
if (kDown & KEY_START) {
break;
}
if ((kHeld & KEY_R) && !held_R) {
printf("Capturing new image\n");
gfxFlushBuffers();
gspWaitForVBlank();
gfxSwapBuffers();
held_R = true;
takePicture3D(buf);
} else if (!(kHeld & KEY_R)) {
held_R = false;
}
if(CONFIG_3D_SLIDERSTATE > 0.0f) {
gfxSet3D(true);
writePictureToFramebufferRGB565(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), buf, 0, 0, WIDTH, HEIGHT);
writePictureToFramebufferRGB565(gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), buf + SCREEN_SIZE, 0, 0, WIDTH, HEIGHT);
} else {
gfxSet3D(false);
writePictureToFramebufferRGB565(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), buf, 0, 0, WIDTH, HEIGHT);
}
// Flush and swap framebuffers
gfxFlushBuffers();
gspWaitForVBlank();
gfxSwapBuffers();
}
// Exit
free(buf);
cleanup();
// Return to hbmenu
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,7 +0,0 @@
video
=======
Example for using the camera to capture 3D videos with ctrulib.
Currently this example does not make use of the 3DS camera's calibration data to get a correct 3D effect.

View File

@ -1,206 +0,0 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <setjmp.h>
#include <3ds.h>
#include <sys/dirent.h>
#include <sys/errno.h>
#include <sys/unistd.h>
#include <stdbool.h>
#define CONFIG_3D_SLIDERSTATE (*(volatile float*)0x1FF81080)
#define WAIT_TIMEOUT 1000000000ULL
#define WIDTH 400
#define HEIGHT 240
#define SCREEN_SIZE WIDTH * HEIGHT * 2
#define BUF_SIZE SCREEN_SIZE * 2
static jmp_buf exitJmp;
inline void clearScreen(void) {
u8 *frame = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
memset(frame, 0, 320 * 240 * 3);
}
void hang(char *message) {
clearScreen();
printf("%s", message);
printf("Press start to exit");
while (aptMainLoop()) {
hidScanInput();
u32 kHeld = hidKeysHeld();
if (kHeld & KEY_START) longjmp(exitJmp, 1);
}
}
void cleanup() {
camExit();
gfxExit();
acExit();
}
void writePictureToFramebufferRGB565(void *fb, void *img, u16 x, u16 y, u16 width, u16 height) {
u8 *fb_8 = (u8*) fb;
u16 *img_16 = (u16*) img;
int i, j, draw_x, draw_y;
for(j = 0; j < height; j++) {
for(i = 0; i < width; i++) {
draw_y = y + height - j;
draw_x = x + i;
u32 v = (draw_y + draw_x * height) * 3;
u16 data = img_16[j * width + i];
uint8_t b = ((data >> 11) & 0x1F) << 3;
uint8_t g = ((data >> 5) & 0x3F) << 2;
uint8_t r = (data & 0x1F) << 3;
fb_8[v] = r;
fb_8[v+1] = g;
fb_8[v+2] = b;
}
}
}
// TODO: Figure out how to use CAMU_GetStereoCameraCalibrationData
void takePicture3D(u8 *buf) {
u32 bufSize;
printf("CAMU_GetMaxBytes: 0x%08X\n", (unsigned int) CAMU_GetMaxBytes(&bufSize, WIDTH, HEIGHT));
printf("CAMU_SetTransferBytes: 0x%08X\n", (unsigned int) CAMU_SetTransferBytes(PORT_BOTH, bufSize, WIDTH, HEIGHT));
printf("CAMU_Activate: 0x%08X\n", (unsigned int) CAMU_Activate(SELECT_OUT1_OUT2));
Handle camReceiveEvent = 0;
Handle camReceiveEvent2 = 0;
printf("CAMU_ClearBuffer: 0x%08X\n", (unsigned int) CAMU_ClearBuffer(PORT_BOTH));
printf("CAMU_SynchronizeVsyncTiming: 0x%08X\n", (unsigned int) CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2));
printf("CAMU_StartCapture: 0x%08X\n", (unsigned int) CAMU_StartCapture(PORT_BOTH));
printf("CAMU_SetReceiving: 0x%08X\n", (unsigned int) CAMU_SetReceiving(&camReceiveEvent, buf, PORT_CAM1, SCREEN_SIZE, (s16) bufSize));
printf("CAMU_SetReceiving: 0x%08X\n", (unsigned int) CAMU_SetReceiving(&camReceiveEvent2, buf + SCREEN_SIZE, PORT_CAM2, SCREEN_SIZE, (s16) bufSize));
printf("svcWaitSynchronization: 0x%08X\n", (unsigned int) svcWaitSynchronization(camReceiveEvent, WAIT_TIMEOUT));
printf("svcWaitSynchronization: 0x%08X\n", (unsigned int) svcWaitSynchronization(camReceiveEvent2, WAIT_TIMEOUT));
printf("CAMU_PlayShutterSound: 0x%08X\n", (unsigned int) CAMU_PlayShutterSound(SHUTTER_SOUND_TYPE_NORMAL));
printf("CAMU_StopCapture: 0x%08X\n", (unsigned int) CAMU_StopCapture(PORT_BOTH));
svcCloseHandle(camReceiveEvent);
svcCloseHandle(camReceiveEvent2);
printf("CAMU_Activate: 0x%08X\n", (unsigned int) CAMU_Activate(SELECT_NONE));
}
int main() {
// Initializations
acInit();
gfxInitDefault();
consoleInit(GFX_BOTTOM, NULL);
// Enable double buffering to remove screen tearing
gfxSetDoubleBuffering(GFX_TOP, true);
gfxSetDoubleBuffering(GFX_BOTTOM, false);
// Save current stack frame for easy exit
if(setjmp(exitJmp)) {
cleanup();
return 0;
}
u32 kDown;
printf("Initializing camera\n");
printf("camInit: 0x%08X\n", (unsigned int) camInit());
printf("CAMU_SetSize: 0x%08X\n", (unsigned int) CAMU_SetSize(SELECT_OUT1_OUT2, SIZE_CTR_TOP_LCD, CONTEXT_A));
printf("CAMU_SetOutputFormat: 0x%08X\n", (unsigned int) CAMU_SetOutputFormat(SELECT_OUT1_OUT2, OUTPUT_RGB_565, CONTEXT_A));
// TODO: For some reason frame grabbing times out above 10fps. Figure out why this is.
printf("CAMU_SetFrameRate: 0x%08X\n", (unsigned int) CAMU_SetFrameRate(SELECT_OUT1_OUT2, FRAME_RATE_10));
printf("CAMU_SetNoiseFilter: 0x%08X\n", (unsigned int) CAMU_SetNoiseFilter(SELECT_OUT1_OUT2, true));
printf("CAMU_SetAutoExposure: 0x%08X\n", (unsigned int) CAMU_SetAutoExposure(SELECT_OUT1_OUT2, true));
printf("CAMU_SetAutoWhiteBalance: 0x%08X\n", (unsigned int) CAMU_SetAutoWhiteBalance(SELECT_OUT1_OUT2, true));
// TODO: Figure out how to use the effects properly.
//printf("CAMU_SetEffect: 0x%08X\n", (unsigned int) CAMU_SetEffect(SELECT_OUT1_OUT2, EFFECT_SEPIA, CONTEXT_A));
printf("CAMU_SetTrimming: 0x%08X\n", (unsigned int) CAMU_SetTrimming(PORT_CAM1, false));
printf("CAMU_SetTrimming: 0x%08X\n", (unsigned int) CAMU_SetTrimming(PORT_CAM2, false));
//printf("CAMU_SetTrimmingParamsCenter: 0x%08X\n", (unsigned int) CAMU_SetTrimmingParamsCenter(PORT_CAM1, 512, 240, 512, 384));
u8 *buf = malloc(BUF_SIZE);
if(!buf) {
hang("Failed to allocate memory!");
}
u32 bufSize;
printf("CAMU_GetMaxBytes: 0x%08X\n", (unsigned int) CAMU_GetMaxBytes(&bufSize, WIDTH, HEIGHT));
printf("CAMU_SetTransferBytes: 0x%08X\n", (unsigned int) CAMU_SetTransferBytes(PORT_BOTH, bufSize, WIDTH, HEIGHT));
printf("CAMU_Activate: 0x%08X\n", (unsigned int) CAMU_Activate(SELECT_OUT1_OUT2));
Handle camReceiveEvent = 0;
Handle camReceiveEvent2 = 0;
printf("CAMU_ClearBuffer: 0x%08X\n", (unsigned int) CAMU_ClearBuffer(PORT_BOTH));
printf("CAMU_SynchronizeVsyncTiming: 0x%08X\n", (unsigned int) CAMU_SynchronizeVsyncTiming(SELECT_OUT1, SELECT_OUT2));
printf("CAMU_StartCapture: 0x%08X\n", (unsigned int) CAMU_StartCapture(PORT_BOTH));
printf("CAMU_PlayShutterSound: 0x%08X\n", (unsigned int) CAMU_PlayShutterSound(SHUTTER_SOUND_TYPE_MOVIE));
gfxFlushBuffers();
gspWaitForVBlank();
gfxSwapBuffers();
printf("\nUse slider to enable/disable 3D\n");
printf("Press Start to exit to Homebrew Launcher\n");
// Main loop
while (aptMainLoop()) {
// Read which buttons are currently pressed or not
hidScanInput();
kDown = hidKeysDown();
// If START button is pressed, break loop and quit
if (kDown & KEY_START) {
break;
}
printf("CAMU_SetReceiving: 0x%08X\n", (unsigned int) CAMU_SetReceiving(&camReceiveEvent, buf, PORT_CAM1, SCREEN_SIZE, (s16) bufSize));
CAMU_SetReceiving(&camReceiveEvent2, buf + SCREEN_SIZE, PORT_CAM2, SCREEN_SIZE, (s16) bufSize);
printf("svcWaitSynchronization: 0x%08X\n", (unsigned int) svcWaitSynchronization(camReceiveEvent, WAIT_TIMEOUT));
svcWaitSynchronization(camReceiveEvent2, WAIT_TIMEOUT);
if(CONFIG_3D_SLIDERSTATE > 0.0f) {
gfxSet3D(true);
writePictureToFramebufferRGB565(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), buf, 0, 0, WIDTH, HEIGHT);
writePictureToFramebufferRGB565(gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), buf + SCREEN_SIZE, 0, 0, WIDTH, HEIGHT);
} else {
gfxSet3D(false);
writePictureToFramebufferRGB565(gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), buf, 0, 0, WIDTH, HEIGHT);
}
printf("svcCloseHandle: 0x%08X\n", (unsigned int) svcCloseHandle(camReceiveEvent));
svcCloseHandle(camReceiveEvent2);
// Flush and swap framebuffers
gfxFlushBuffers();
gspWaitForVBlank();
gfxSwapBuffers();
}
printf("CAMU_StopCapture: 0x%08X\n", (unsigned int) CAMU_StopCapture(PORT_BOTH));
printf("CAMU_Activate: 0x%08X\n", (unsigned int) CAMU_Activate(SELECT_NONE));
// Exit
free(buf);
cleanup();
// Return to hbmenu
return 0;
}

View File

@ -1,3 +0,0 @@
<targets selectable="false">
<title mediatype="0">0004001000021400</title>
</targets>

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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();
cfguInit();
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
cfguExit();
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,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,177 +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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pica)))
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)) $(PICAFILES:.pica=.shbin.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
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)
#---------------------------------------------------------------------------------
# rule for assembling GPU shaders
#---------------------------------------------------------------------------------
%.shbin.o: %.pica
@echo $(notdir $<)
$(eval CURBIN := $(patsubst %.pica,%.shbin,$(notdir $<)))
$(eval CURH := $(patsubst %.pica,%.psh.h,$(notdir $<)))
@picasso -h $(CURH) -o $(CURBIN) $<
@bin2s $(CURBIN) | $(AS) -o $@
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# GPU example
This is a simple GPU example using the `picasso` shader assembler which comes with devkitARM r45 and up.
Users of earlier versions of devkitARM need to install the tool, which can be found in the address below:
https://github.com/fincs/picasso/releases

View File

@ -1,172 +0,0 @@
#include "3dmath.h"
void m4x4_identity(matrix_4x4* out)
{
m4x4_zeros(out);
out->r[0].x = out->r[1].y = out->r[2].z = out->r[3].w = 1.0f;
}
void m4x4_multiply(matrix_4x4* out, const matrix_4x4* a, const matrix_4x4* b)
{
int i, j;
for (i = 0; i < 4; i ++)
for (j = 0; j < 4; j ++)
out->r[j].c[i] = a->r[j].x*b->r[0].c[i] + a->r[j].y*b->r[1].c[i] + a->r[j].z*b->r[2].c[i] + a->r[j].w*b->r[3].c[i];
}
void m4x4_translate(matrix_4x4* mtx, float x, float y, float z)
{
matrix_4x4 tm, om;
m4x4_identity(&tm);
tm.r[0].w = x;
tm.r[1].w = y;
tm.r[2].w = z;
m4x4_multiply(&om, mtx, &tm);
m4x4_copy(mtx, &om);
}
void m4x4_scale(matrix_4x4* mtx, float x, float y, float z)
{
int i;
for (i = 0; i < 4; i ++)
{
mtx->r[i].x *= x;
mtx->r[i].y *= y;
mtx->r[i].z *= z;
}
}
void m4x4_rotate_x(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = 1.0f;
rm.r[1].y = cosAngle;
rm.r[1].z = sinAngle;
rm.r[2].y = -sinAngle;
rm.r[2].z = cosAngle;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_rotate_y(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = cosAngle;
rm.r[0].z = sinAngle;
rm.r[1].y = 1.0f;
rm.r[2].x = -sinAngle;
rm.r[2].z = cosAngle;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_rotate_z(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = cosAngle;
rm.r[0].y = sinAngle;
rm.r[1].x = -sinAngle;
rm.r[1].y = cosAngle;
rm.r[2].z = 1.0f;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_ortho_tilt(matrix_4x4* mtx, float left, float right, float bottom, float top, float near, float far)
{
matrix_4x4 mp;
m4x4_zeros(&mp);
// Build standard orthogonal projection matrix
mp.r[0].x = 2.0f / (right - left);
mp.r[0].w = (left + right) / (left - right);
mp.r[1].y = 2.0f / (top - bottom);
mp.r[1].w = (bottom + top) / (bottom - top);
mp.r[2].z = 2.0f / (near - far);
mp.r[2].w = (far + near) / (far - near);
mp.r[3].w = 1.0f;
// Fix depth range to [-1, 0]
matrix_4x4 mp2, mp3;
m4x4_identity(&mp2);
mp2.r[2].z = 0.5;
mp2.r[2].w = -0.5;
m4x4_multiply(&mp3, &mp2, &mp);
// Fix the 3DS screens' orientation by swapping the X and Y axis
m4x4_identity(&mp2);
mp2.r[0].x = 0.0;
mp2.r[0].y = 1.0;
mp2.r[1].x = -1.0; // flipped
mp2.r[1].y = 0.0;
m4x4_multiply(mtx, &mp2, &mp3);
}
void m4x4_persp_tilt(matrix_4x4* mtx, float fovx, float invaspect, float near, float far)
{
// Notes:
// We are passed "fovy" and the "aspect ratio". However, the 3DS screens are sideways,
// and so are these parameters -- in fact, they are actually the fovx and the inverse
// of the aspect ratio. Therefore the formula for the perspective projection matrix
// had to be modified to be expressed in these terms instead.
// Notes:
// fovx = 2 atan(tan(fovy/2)*w/h)
// fovy = 2 atan(tan(fovx/2)*h/w)
// invaspect = h/w
// a0,0 = h / (w*tan(fovy/2)) =
// = h / (w*tan(2 atan(tan(fovx/2)*h/w) / 2)) =
// = h / (w*tan( atan(tan(fovx/2)*h/w) )) =
// = h / (w * tan(fovx/2)*h/w) =
// = 1 / tan(fovx/2)
// a1,1 = 1 / tan(fovy/2) = (...) = w / (h*tan(fovx/2))
float fovx_tan = tanf(fovx / 2);
matrix_4x4 mp;
m4x4_zeros(&mp);
// Build standard perspective projection matrix
mp.r[0].x = 1.0f / fovx_tan;
mp.r[1].y = 1.0f / (fovx_tan*invaspect);
mp.r[2].z = (near + far) / (near - far);
mp.r[2].w = (2 * near * far) / (near - far);
mp.r[3].z = -1.0f;
// Fix depth range to [-1, 0]
matrix_4x4 mp2;
m4x4_identity(&mp2);
mp2.r[2].z = 0.5;
mp2.r[2].w = -0.5;
m4x4_multiply(mtx, &mp2, &mp);
// Rotate the matrix one quarter of a turn CCW in order to fix the 3DS screens' orientation
m4x4_rotate_z(mtx, M_PI / 2, true);
}

View File

@ -1,56 +0,0 @@
/*
* Bare-bones simplistic 3D math library
* This library is common to all libctru GPU examples
*/
#pragma once
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef union { struct { float w, z, y, x; }; float c[4]; } vector_4f;
typedef struct { vector_4f r[4]; } matrix_4x4;
static inline float v4f_dp4(const vector_4f* a, const vector_4f* b)
{
return a->x*b->x + a->y*b->y + a->z*b->z + a->w*b->w;
}
static inline float v4f_mod4(const vector_4f* a)
{
return sqrtf(v4f_dp4(a,a));
}
static inline void v4f_norm4(vector_4f* vec)
{
float m = v4f_mod4(vec);
if (m == 0.0) return;
vec->x /= m;
vec->y /= m;
vec->z /= m;
vec->w /= m;
}
static inline void m4x4_zeros(matrix_4x4* out)
{
memset(out, 0, sizeof(*out));
}
static inline void m4x4_copy(matrix_4x4* out, const matrix_4x4* in)
{
memcpy(out, in, sizeof(*out));
}
void m4x4_identity(matrix_4x4* out);
void m4x4_multiply(matrix_4x4* out, const matrix_4x4* a, const matrix_4x4* b);
void m4x4_translate(matrix_4x4* mtx, float x, float y, float z);
void m4x4_scale(matrix_4x4* mtx, float x, float y, float z);
void m4x4_rotate_x(matrix_4x4* mtx, float angle, bool bRightSide);
void m4x4_rotate_y(matrix_4x4* mtx, float angle, bool bRightSide);
void m4x4_rotate_z(matrix_4x4* mtx, float angle, bool bRightSide);
// Special versions of the projection matrices that take the 3DS' screen orientation into account
void m4x4_ortho_tilt(matrix_4x4* mtx, float left, float right, float bottom, float top, float near, float far);
void m4x4_persp_tilt(matrix_4x4* mtx, float fovy, float aspect, float near, float far);

View File

@ -1,94 +0,0 @@
#include "gpu.h"
#define DISPLAY_TRANSFER_FLAGS \
(GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
static u32 *colorBuf, *depthBuf;
static u32 *cmdBuf;
void gpuInit(void)
{
colorBuf = vramAlloc(400*240*4);
depthBuf = vramAlloc(400*240*4);
cmdBuf = linearAlloc(0x40000*4);
GPU_Init(NULL);
GPU_Reset(NULL, cmdBuf, 0x40000);
}
void gpuExit(void)
{
linearFree(cmdBuf);
vramFree(depthBuf);
vramFree(colorBuf);
}
void gpuClearBuffers(u32 clearColor)
{
GX_MemoryFill(
colorBuf, clearColor, &colorBuf[240*400], GX_FILL_TRIGGER | GX_FILL_32BIT_DEPTH,
depthBuf, 0, &depthBuf[240*400], GX_FILL_TRIGGER | GX_FILL_32BIT_DEPTH);
gspWaitForPSC0(); // Wait for the fill to complete
}
void gpuFrameBegin(void)
{
// Configure the viewport and the depth linear conversion function
GPU_SetViewport(
(u32*)osConvertVirtToPhys(depthBuf),
(u32*)osConvertVirtToPhys(colorBuf),
0, 0, 240, 400); // The top screen is physically 240x400 pixels
GPU_DepthMap(-1.0f, 0.0f); // calculate the depth value from the Z coordinate in the following way: -1.0*z + 0.0
// Configure some boilerplate
GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP);
GPU_SetBlendingColor(0,0,0,0);
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
// This is unknown
GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0);
GPUCMD_AddWrite(GPUREG_0118, 0);
// Configure alpha blending and test
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);
int i;
for (i = 0; i < 6; i ++)
GPU_SetDummyTexEnv(i);
}
void gpuFrameEnd(void)
{
// Finish rendering
GPU_FinishDrawing();
GPUCMD_Finalize();
GPUCMD_FlushAndRun();
gspWaitForP3D(); // Wait for the rendering to complete
// Transfer the GPU output to the framebuffer
GX_DisplayTransfer(
colorBuf, GX_BUFFER_DIM(240, 400),
(u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), GX_BUFFER_DIM(240, 400),
DISPLAY_TRANSFER_FLAGS);
gspWaitForPPF(); // Wait for the transfer to complete
// Reset the command buffer
GPUCMD_SetBufferOffset(0);
};
void GPU_SetDummyTexEnv(int id)
{
GPU_SetTexEnv(id,
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);
}

View File

@ -1,26 +0,0 @@
/*
* Bare-bones simplistic GPU wrapper
* This library is common to all libctru GPU examples
*/
#pragma once
#include <string.h>
#include <3ds.h>
#include "3dmath.h"
void gpuInit(void);
void gpuExit(void);
void gpuClearBuffers(u32 clearColor);
void gpuFrameBegin(void);
void gpuFrameEnd(void);
// Configures the specified fixed-function fragment shading substage to be a no-operation
void GPU_SetDummyTexEnv(int id);
// Uploads an uniform matrix
static inline void GPU_SetFloatUniformMatrix(GPU_SHADER_TYPE type, int location, matrix_4x4* matrix)
{
GPU_SetFloatUniform(type, location, (u32*)matrix, 4);
}

View File

@ -1,91 +0,0 @@
; Example PICA200 geometry shader
; Uniforms
.fvec projection[4]
; Constants
.constf myconst(0.0, 1.0, -1.0, 0.5)
.alias zeros myconst.xxxx ; Vector full of zeros
.alias ones myconst.yyyy ; Vector full of ones
.alias half myconst.wwww
; Outputs - this time the type *is* used
.out outpos position
.out outclr color
; Inputs: we will receive the following inputs:
; v0-v1: position/color of the first vertex
; v2-v3: position/color of the second vertex
; v4-v5: position/color of the third vertex
.proc main
; Calculate the midpoints of the vertices
mov r4, v0
add r4, v2, r4
mul r4, half, r4
mov r5, v2
add r5, v4, r5
mul r5, half, r5
mov r6, v4
add r6, v0, r6
mul r6, half, r6
; Emit the first triangle
mov r0, v0
mov r1, r4
mov r2, r6
call emit_triangle
; Emit the second triangle
mov r0, r4
mov r1, v2
mov r2, r5
call emit_triangle
; Emit the third triangle
mov r0, r6
mov r1, r5
mov r2, v4
call emit_triangle
; We're finished
end
.end
.proc emit_triangle
; Emit the first vertex
setemit 0
mov r8, r0
mov r9, v1
call process_vertex
emit
; Emit the second vertex
setemit 1
mov r8, r1
mov r9, v3
call process_vertex
emit
; Emit the third vertex and finish the primitive
setemit 2, prim
mov r8, r2
mov r9, v5
call process_vertex
emit
.end
; Subroutine
; Inputs:
; r8: vertex position
; r9: vertex color
.proc process_vertex
; outpos = projectionMatrix * r8
dp4 outpos.x, projection[0], r8
dp4 outpos.y, projection[1], r8
dp4 outpos.z, projection[2], r8
dp4 outpos.w, projection[3], r8
; outclr = r9
mov outclr, r9
.end

View File

@ -1,139 +0,0 @@
/*
* ~~ Simple libctru GPU geometry shader example ~~
* This example demonstrates the basics of using the PICA200 in a 3DS homebrew
* application in order to render a basic scene using a geoshader.
* The example geoshader receives the vertices of a triangle and emits three
* smaller triangles, thus forming a 'triforce' shape.
*/
#include "gpu.h"
#include "vshader_shbin.h"
#include "gshader_shbin.h"
#define CLEAR_COLOR 0x68B0D8FF
typedef struct { float position[3]; float color[4]; } vertex;
static const vertex vertex_list[] =
{
{ {200.0f, 200.0f, 0.5f}, {1.0f, 0.0f, 0.0f, 1.0f} },
{ {100.0f, 40.0f, 0.5f}, {0.0f, 1.0f, 0.0f, 1.0f} },
{ {300.0f, 40.0f, 0.5f}, {0.0f, 0.0f, 1.0f, 1.0f} },
};
#define vertex_list_count (sizeof(vertex_list)/sizeof(vertex_list[0]))
static DVLB_s *vshader_dvlb, *gshader_dvlb;
static shaderProgram_s program;
static int uLoc_projection;
static matrix_4x4 projection;
static void* vbo_data;
static void sceneInit(void)
{
// Load the shaders and create a shader program
// The geoshader stride is set to 6 so that it processes a triangle at a time
vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_size);
gshader_dvlb = DVLB_ParseFile((u32*)gshader_shbin, gshader_shbin_size);
shaderProgramInit(&program);
shaderProgramSetVsh(&program, &vshader_dvlb->DVLE[0]);
shaderProgramSetGsh(&program, &gshader_dvlb->DVLE[0], 6);
// Get the location of the projection matrix uniform
uLoc_projection = shaderInstanceGetUniformLocation(program.geometryShader, "projection");
// Compute the projection matrix
m4x4_ortho_tilt(&projection, 0.0, 400.0, 0.0, 240.0, 0.0, 1.0);
// Create the VBO (vertex buffer object)
vbo_data = linearAlloc(sizeof(vertex_list));
memcpy(vbo_data, vertex_list, sizeof(vertex_list));
}
static void sceneRender(void)
{
// Bind the shader program
shaderProgramUse(&program);
// Configure the first fragment shading substage to just pass through the vertex color
// See https://www.opengl.org/sdk/docs/man2/xhtml/glTexEnv.xml for more insight
GPU_SetTexEnv(0,
GPU_TEVSOURCES(GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), // RGB channels
GPU_TEVSOURCES(GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), // Alpha
GPU_TEVOPERANDS(0, 0, 0), // RGB
GPU_TEVOPERANDS(0, 0, 0), // Alpha
GPU_REPLACE, GPU_REPLACE, // RGB, Alpha
0xFFFFFFFF);
// Configure the "attribute buffers" (that is, the vertex input buffers)
GPU_SetAttributeBuffers(
2, // Number of inputs per vertex
(u32*)osConvertVirtToPhys(vbo_data), // Location of the VBO
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) |
GPU_ATTRIBFMT(1, 4, GPU_FLOAT), // Format of the inputs (in this case the only input is a 3-element float vector)
0xFFC, // Unused attribute mask, in our case bit 0 is cleared since it is used
0x10, // Attribute permutations (here it is the identity)
1, // Number of buffers
(u32[]) { 0x0 }, // Buffer offsets (placeholders)
(u64[]) { 0x10 }, // Attribute permutations for each buffer (identity again)
(u8[]) { 2 }); // Number of attributes for each buffer
// Upload the projection matrix
GPU_SetFloatUniformMatrix(GPU_GEOMETRY_SHADER, uLoc_projection, &projection);
// Draw the VBO - GPU_GEOMETRY_PRIM allows the geoshader to control primitive emission
GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, vertex_list_count);
}
static void sceneExit(void)
{
// Free the VBO
linearFree(vbo_data);
// Free the shader program
shaderProgramFree(&program);
DVLB_Free(vshader_dvlb);
DVLB_Free(gshader_dvlb);
}
int main()
{
// Initialize graphics
gfxInitDefault();
gpuInit();
// Initialize the scene
sceneInit();
gpuClearBuffers(CLEAR_COLOR);
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank(); // Synchronize with the start of VBlank
gfxSwapBuffersGpu(); // Swap the framebuffers so that the frame that we rendered last frame is now visible
hidScanInput(); // Read the user input
// Respond to user input
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
// Render the scene
gpuFrameBegin();
sceneRender();
gpuFrameEnd();
gpuClearBuffers(CLEAR_COLOR);
// Flush the framebuffers out of the data cache (not necessary with pure GPU rendering)
//gfxFlushBuffers();
}
// Deinitialize the scene
sceneExit();
// Deinitialize graphics
gpuExit();
gfxExit();
return 0;
}

View File

@ -1,24 +0,0 @@
; Example PICA200 vertex shader
; Constants
.constf myconst(0.0, 1.0, -1.0, -0.5)
.alias zeros myconst.xxxx ; Vector full of zeros
.alias ones myconst.yyyy ; Vector full of ones
; Outputs - since we are also using a geoshader the output type isn't really used
.out outpos position
.out outclr color
; Inputs (defined as aliases for convenience)
.alias inpos v0
.alias inclr v1
.proc main
; Pass through both inputs to the geoshader
mov outpos.xyz, inpos
mov outpos.w, ones
mov outclr, inclr
; We're finished
end
.end

View File

@ -1,177 +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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pica)))
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)) $(PICAFILES:.pica=.shbin.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
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)
#---------------------------------------------------------------------------------
# rule for assembling GPU shaders
#---------------------------------------------------------------------------------
%.shbin.o: %.pica
@echo $(notdir $<)
$(eval CURBIN := $(patsubst %.pica,%.shbin,$(notdir $<)))
$(eval CURH := $(patsubst %.pica,%.psh.h,$(notdir $<)))
@picasso -h $(CURH) -o $(CURBIN) $<
@bin2s $(CURBIN) | $(AS) -o $@
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# GPU example
This is a simple GPU example using the `picasso` shader assembler which comes with devkitARM r45 and up.
Users of earlier versions of devkitARM need to install the tool, which can be found in the address below:
https://github.com/fincs/picasso/releases

View File

@ -1,172 +0,0 @@
#include "3dmath.h"
void m4x4_identity(matrix_4x4* out)
{
m4x4_zeros(out);
out->r[0].x = out->r[1].y = out->r[2].z = out->r[3].w = 1.0f;
}
void m4x4_multiply(matrix_4x4* out, const matrix_4x4* a, const matrix_4x4* b)
{
int i, j;
for (i = 0; i < 4; i ++)
for (j = 0; j < 4; j ++)
out->r[j].c[i] = a->r[j].x*b->r[0].c[i] + a->r[j].y*b->r[1].c[i] + a->r[j].z*b->r[2].c[i] + a->r[j].w*b->r[3].c[i];
}
void m4x4_translate(matrix_4x4* mtx, float x, float y, float z)
{
matrix_4x4 tm, om;
m4x4_identity(&tm);
tm.r[0].w = x;
tm.r[1].w = y;
tm.r[2].w = z;
m4x4_multiply(&om, mtx, &tm);
m4x4_copy(mtx, &om);
}
void m4x4_scale(matrix_4x4* mtx, float x, float y, float z)
{
int i;
for (i = 0; i < 4; i ++)
{
mtx->r[i].x *= x;
mtx->r[i].y *= y;
mtx->r[i].z *= z;
}
}
void m4x4_rotate_x(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = 1.0f;
rm.r[1].y = cosAngle;
rm.r[1].z = sinAngle;
rm.r[2].y = -sinAngle;
rm.r[2].z = cosAngle;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_rotate_y(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = cosAngle;
rm.r[0].z = sinAngle;
rm.r[1].y = 1.0f;
rm.r[2].x = -sinAngle;
rm.r[2].z = cosAngle;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_rotate_z(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = cosAngle;
rm.r[0].y = sinAngle;
rm.r[1].x = -sinAngle;
rm.r[1].y = cosAngle;
rm.r[2].z = 1.0f;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_ortho_tilt(matrix_4x4* mtx, float left, float right, float bottom, float top, float near, float far)
{
matrix_4x4 mp;
m4x4_zeros(&mp);
// Build standard orthogonal projection matrix
mp.r[0].x = 2.0f / (right - left);
mp.r[0].w = (left + right) / (left - right);
mp.r[1].y = 2.0f / (top - bottom);
mp.r[1].w = (bottom + top) / (bottom - top);
mp.r[2].z = 2.0f / (near - far);
mp.r[2].w = (far + near) / (far - near);
mp.r[3].w = 1.0f;
// Fix depth range to [-1, 0]
matrix_4x4 mp2, mp3;
m4x4_identity(&mp2);
mp2.r[2].z = 0.5;
mp2.r[2].w = -0.5;
m4x4_multiply(&mp3, &mp2, &mp);
// Fix the 3DS screens' orientation by swapping the X and Y axis
m4x4_identity(&mp2);
mp2.r[0].x = 0.0;
mp2.r[0].y = 1.0;
mp2.r[1].x = -1.0; // flipped
mp2.r[1].y = 0.0;
m4x4_multiply(mtx, &mp2, &mp3);
}
void m4x4_persp_tilt(matrix_4x4* mtx, float fovx, float invaspect, float near, float far)
{
// Notes:
// We are passed "fovy" and the "aspect ratio". However, the 3DS screens are sideways,
// and so are these parameters -- in fact, they are actually the fovx and the inverse
// of the aspect ratio. Therefore the formula for the perspective projection matrix
// had to be modified to be expressed in these terms instead.
// Notes:
// fovx = 2 atan(tan(fovy/2)*w/h)
// fovy = 2 atan(tan(fovx/2)*h/w)
// invaspect = h/w
// a0,0 = h / (w*tan(fovy/2)) =
// = h / (w*tan(2 atan(tan(fovx/2)*h/w) / 2)) =
// = h / (w*tan( atan(tan(fovx/2)*h/w) )) =
// = h / (w * tan(fovx/2)*h/w) =
// = 1 / tan(fovx/2)
// a1,1 = 1 / tan(fovy/2) = (...) = w / (h*tan(fovx/2))
float fovx_tan = tanf(fovx / 2);
matrix_4x4 mp;
m4x4_zeros(&mp);
// Build standard perspective projection matrix
mp.r[0].x = 1.0f / fovx_tan;
mp.r[1].y = 1.0f / (fovx_tan*invaspect);
mp.r[2].z = (near + far) / (near - far);
mp.r[2].w = (2 * near * far) / (near - far);
mp.r[3].z = -1.0f;
// Fix depth range to [-1, 0]
matrix_4x4 mp2;
m4x4_identity(&mp2);
mp2.r[2].z = 0.5;
mp2.r[2].w = -0.5;
m4x4_multiply(mtx, &mp2, &mp);
// Rotate the matrix one quarter of a turn CCW in order to fix the 3DS screens' orientation
m4x4_rotate_z(mtx, M_PI / 2, true);
}

View File

@ -1,56 +0,0 @@
/*
* Bare-bones simplistic 3D math library
* This library is common to all libctru GPU examples
*/
#pragma once
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef union { struct { float w, z, y, x; }; float c[4]; } vector_4f;
typedef struct { vector_4f r[4]; } matrix_4x4;
static inline float v4f_dp4(const vector_4f* a, const vector_4f* b)
{
return a->x*b->x + a->y*b->y + a->z*b->z + a->w*b->w;
}
static inline float v4f_mod4(const vector_4f* a)
{
return sqrtf(v4f_dp4(a,a));
}
static inline void v4f_norm4(vector_4f* vec)
{
float m = v4f_mod4(vec);
if (m == 0.0) return;
vec->x /= m;
vec->y /= m;
vec->z /= m;
vec->w /= m;
}
static inline void m4x4_zeros(matrix_4x4* out)
{
memset(out, 0, sizeof(*out));
}
static inline void m4x4_copy(matrix_4x4* out, const matrix_4x4* in)
{
memcpy(out, in, sizeof(*out));
}
void m4x4_identity(matrix_4x4* out);
void m4x4_multiply(matrix_4x4* out, const matrix_4x4* a, const matrix_4x4* b);
void m4x4_translate(matrix_4x4* mtx, float x, float y, float z);
void m4x4_scale(matrix_4x4* mtx, float x, float y, float z);
void m4x4_rotate_x(matrix_4x4* mtx, float angle, bool bRightSide);
void m4x4_rotate_y(matrix_4x4* mtx, float angle, bool bRightSide);
void m4x4_rotate_z(matrix_4x4* mtx, float angle, bool bRightSide);
// Special versions of the projection matrices that take the 3DS' screen orientation into account
void m4x4_ortho_tilt(matrix_4x4* mtx, float left, float right, float bottom, float top, float near, float far);
void m4x4_persp_tilt(matrix_4x4* mtx, float fovy, float aspect, float near, float far);

View File

@ -1,94 +0,0 @@
#include "gpu.h"
#define DISPLAY_TRANSFER_FLAGS \
(GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
static u32 *colorBuf, *depthBuf;
static u32 *cmdBuf;
void gpuInit(void)
{
colorBuf = vramAlloc(400*240*4);
depthBuf = vramAlloc(400*240*4);
cmdBuf = linearAlloc(0x40000*4);
GPU_Init(NULL);
GPU_Reset(NULL, cmdBuf, 0x40000);
}
void gpuExit(void)
{
linearFree(cmdBuf);
vramFree(depthBuf);
vramFree(colorBuf);
}
void gpuClearBuffers(u32 clearColor)
{
GX_MemoryFill(
colorBuf, clearColor, &colorBuf[240*400], GX_FILL_TRIGGER | GX_FILL_32BIT_DEPTH,
depthBuf, 0, &depthBuf[240*400], GX_FILL_TRIGGER | GX_FILL_32BIT_DEPTH);
gspWaitForPSC0(); // Wait for the fill to complete
}
void gpuFrameBegin(void)
{
// Configure the viewport and the depth linear conversion function
GPU_SetViewport(
(u32*)osConvertVirtToPhys(depthBuf),
(u32*)osConvertVirtToPhys(colorBuf),
0, 0, 240, 400); // The top screen is physically 240x400 pixels
GPU_DepthMap(-1.0f, 0.0f); // calculate the depth value from the Z coordinate in the following way: -1.0*z + 0.0
// Configure some boilerplate
GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP);
GPU_SetBlendingColor(0,0,0,0);
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
// This is unknown
GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0);
GPUCMD_AddWrite(GPUREG_0118, 0);
// Configure alpha blending and test
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);
int i;
for (i = 0; i < 6; i ++)
GPU_SetDummyTexEnv(i);
}
void gpuFrameEnd(void)
{
// Finish rendering
GPU_FinishDrawing();
GPUCMD_Finalize();
GPUCMD_FlushAndRun();
gspWaitForP3D(); // Wait for the rendering to complete
// Transfer the GPU output to the framebuffer
GX_DisplayTransfer(
colorBuf, GX_BUFFER_DIM(240, 400),
(u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), GX_BUFFER_DIM(240, 400),
DISPLAY_TRANSFER_FLAGS);
gspWaitForPPF(); // Wait for the transfer to complete
// Reset the command buffer
GPUCMD_SetBufferOffset(0);
};
void GPU_SetDummyTexEnv(int id)
{
GPU_SetTexEnv(id,
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);
}

View File

@ -1,26 +0,0 @@
/*
* Bare-bones simplistic GPU wrapper
* This library is common to all libctru GPU examples
*/
#pragma once
#include <string.h>
#include <3ds.h>
#include "3dmath.h"
void gpuInit(void);
void gpuExit(void);
void gpuClearBuffers(u32 clearColor);
void gpuFrameBegin(void);
void gpuFrameEnd(void);
// Configures the specified fixed-function fragment shading substage to be a no-operation
void GPU_SetDummyTexEnv(int id);
// Uploads an uniform matrix
static inline void GPU_SetFloatUniformMatrix(GPU_SHADER_TYPE type, int location, matrix_4x4* matrix)
{
GPU_SetFloatUniform(type, location, (u32*)matrix, 4);
}

View File

@ -1,131 +0,0 @@
/*
* ~~ Simple libctru GPU triangle example ~~
* This example demonstrates the basics of using the PICA200 in a 3DS homebrew
* application in order to render a basic scene consisting of a white solid triangle.
*/
#include "gpu.h"
#include "vshader_shbin.h"
#define CLEAR_COLOR 0x68B0D8FF
typedef struct { float x, y, z; } vertex;
static const vertex vertex_list[] =
{
{ 200.0f, 200.0f, 0.5f },
{ 100.0f, 40.0f, 0.5f },
{ 300.0f, 40.0f, 0.5f },
};
#define vertex_list_count (sizeof(vertex_list)/sizeof(vertex_list[0]))
static DVLB_s* vshader_dvlb;
static shaderProgram_s program;
static int uLoc_projection;
static matrix_4x4 projection;
static void* vbo_data;
static void sceneInit(void)
{
// Load the vertex shader and create a shader program
vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_size);
shaderProgramInit(&program);
shaderProgramSetVsh(&program, &vshader_dvlb->DVLE[0]);
// Get the location of the projection matrix uniform
uLoc_projection = shaderInstanceGetUniformLocation(program.vertexShader, "projection");
// Compute the projection matrix
m4x4_ortho_tilt(&projection, 0.0, 400.0, 0.0, 240.0, 0.0, 1.0);
// Create the VBO (vertex buffer object)
vbo_data = linearAlloc(sizeof(vertex_list));
memcpy(vbo_data, vertex_list, sizeof(vertex_list));
}
static void sceneRender(void)
{
// Bind the shader program
shaderProgramUse(&program);
// Configure the first fragment shading substage to just pass through the vertex color
// See https://www.opengl.org/sdk/docs/man2/xhtml/glTexEnv.xml for more insight
GPU_SetTexEnv(0,
GPU_TEVSOURCES(GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), // RGB channels
GPU_TEVSOURCES(GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), // Alpha
GPU_TEVOPERANDS(0, 0, 0), // RGB
GPU_TEVOPERANDS(0, 0, 0), // Alpha
GPU_REPLACE, GPU_REPLACE, // RGB, Alpha
0xFFFFFFFF);
// Configure the "attribute buffers" (that is, the vertex input buffers)
GPU_SetAttributeBuffers(
1, // Number of inputs per vertex
(u32*)osConvertVirtToPhys((u32)vbo_data), // Location of the VBO
GPU_ATTRIBFMT(0, 3, GPU_FLOAT), // Format of the inputs (in this case the only input is a 3-element float vector)
0xFFE, // Unused attribute mask, in our case bit 0 is cleared since it is used
0x0, // Attribute permutations (here it is the identity)
1, // Number of buffers
(u32[]) { 0x0 }, // Buffer offsets (placeholders)
(u64[]) { 0x0 }, // Attribute permutations for each buffer (identity again)
(u8[]) { 1 }); // Number of attributes for each buffer
// Upload the projection matrix
GPU_SetFloatUniformMatrix(GPU_VERTEX_SHADER, uLoc_projection, &projection);
// Draw the VBO
GPU_DrawArray(GPU_TRIANGLES, 0, vertex_list_count);
}
static void sceneExit(void)
{
// Free the VBO
linearFree(vbo_data);
// Free the shader program
shaderProgramFree(&program);
DVLB_Free(vshader_dvlb);
}
int main()
{
// Initialize graphics
gfxInitDefault();
gpuInit();
// Initialize the scene
sceneInit();
gpuClearBuffers(CLEAR_COLOR);
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank(); // Synchronize with the start of VBlank
gfxSwapBuffersGpu(); // Swap the framebuffers so that the frame that we rendered last frame is now visible
hidScanInput(); // Read the user input
// Respond to user input
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
// Render the scene
gpuFrameBegin();
sceneRender();
gpuFrameEnd();
gpuClearBuffers(CLEAR_COLOR);
// Flush the framebuffers out of the data cache (not necessary with pure GPU rendering)
//gfxFlushBuffers();
}
// Deinitialize the scene
sceneExit();
// Deinitialize graphics
gpuExit();
gfxExit();
return 0;
}

View File

@ -1,34 +0,0 @@
; Example PICA200 vertex shader
; Uniforms
.fvec projection[4]
; Constants
.constf myconst(0.0, 1.0, -1.0, -0.5)
.alias zeros myconst.xxxx ; Vector full of zeros
.alias ones myconst.yyyy ; Vector full of ones
; Outputs
.out outpos position
.out outclr color
; Inputs (defined as aliases for convenience)
.alias inpos v0
.proc main
; Force the w component of inpos to be 1.0
mov r0.xyz, inpos
mov r0.w, ones
; outpos = projectionMatrix * inpos
dp4 outpos.x, projection[0], r0
dp4 outpos.y, projection[1], r0
dp4 outpos.z, projection[2], r0
dp4 outpos.w, projection[3], r0
; outclr = solid white color
mov outclr, ones
; We're finished
end
.end

View File

@ -1,177 +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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.pica)))
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)) $(PICAFILES:.pica=.shbin.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
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)
#---------------------------------------------------------------------------------
# rule for assembling GPU shaders
#---------------------------------------------------------------------------------
%.shbin.o: %.pica
@echo $(notdir $<)
$(eval CURBIN := $(patsubst %.pica,%.shbin,$(notdir $<)))
$(eval CURH := $(patsubst %.pica,%.psh.h,$(notdir $<)))
@picasso -h $(CURH) -o $(CURBIN) $<
@bin2s $(CURBIN) | $(AS) -o $@
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
@echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
# GPU example
This is a simple GPU example using the `picasso` shader assembler which comes with devkitARM r45 and up.
Users of earlier versions of devkitARM need to install the tool, which can be found in the address below:
https://github.com/fincs/picasso/releases

View File

@ -1,172 +0,0 @@
#include "3dmath.h"
void m4x4_identity(matrix_4x4* out)
{
m4x4_zeros(out);
out->r[0].x = out->r[1].y = out->r[2].z = out->r[3].w = 1.0f;
}
void m4x4_multiply(matrix_4x4* out, const matrix_4x4* a, const matrix_4x4* b)
{
int i, j;
for (i = 0; i < 4; i ++)
for (j = 0; j < 4; j ++)
out->r[j].c[i] = a->r[j].x*b->r[0].c[i] + a->r[j].y*b->r[1].c[i] + a->r[j].z*b->r[2].c[i] + a->r[j].w*b->r[3].c[i];
}
void m4x4_translate(matrix_4x4* mtx, float x, float y, float z)
{
matrix_4x4 tm, om;
m4x4_identity(&tm);
tm.r[0].w = x;
tm.r[1].w = y;
tm.r[2].w = z;
m4x4_multiply(&om, mtx, &tm);
m4x4_copy(mtx, &om);
}
void m4x4_scale(matrix_4x4* mtx, float x, float y, float z)
{
int i;
for (i = 0; i < 4; i ++)
{
mtx->r[i].x *= x;
mtx->r[i].y *= y;
mtx->r[i].z *= z;
}
}
void m4x4_rotate_x(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = 1.0f;
rm.r[1].y = cosAngle;
rm.r[1].z = sinAngle;
rm.r[2].y = -sinAngle;
rm.r[2].z = cosAngle;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_rotate_y(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = cosAngle;
rm.r[0].z = sinAngle;
rm.r[1].y = 1.0f;
rm.r[2].x = -sinAngle;
rm.r[2].z = cosAngle;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_rotate_z(matrix_4x4* mtx, float angle, bool bRightSide)
{
matrix_4x4 rm, om;
float cosAngle = cosf(angle);
float sinAngle = sinf(angle);
m4x4_zeros(&rm);
rm.r[0].x = cosAngle;
rm.r[0].y = sinAngle;
rm.r[1].x = -sinAngle;
rm.r[1].y = cosAngle;
rm.r[2].z = 1.0f;
rm.r[3].w = 1.0f;
if (bRightSide) m4x4_multiply(&om, mtx, &rm);
else m4x4_multiply(&om, &rm, mtx);
m4x4_copy(mtx, &om);
}
void m4x4_ortho_tilt(matrix_4x4* mtx, float left, float right, float bottom, float top, float near, float far)
{
matrix_4x4 mp;
m4x4_zeros(&mp);
// Build standard orthogonal projection matrix
mp.r[0].x = 2.0f / (right - left);
mp.r[0].w = (left + right) / (left - right);
mp.r[1].y = 2.0f / (top - bottom);
mp.r[1].w = (bottom + top) / (bottom - top);
mp.r[2].z = 2.0f / (near - far);
mp.r[2].w = (far + near) / (far - near);
mp.r[3].w = 1.0f;
// Fix depth range to [-1, 0]
matrix_4x4 mp2, mp3;
m4x4_identity(&mp2);
mp2.r[2].z = 0.5;
mp2.r[2].w = -0.5;
m4x4_multiply(&mp3, &mp2, &mp);
// Fix the 3DS screens' orientation by swapping the X and Y axis
m4x4_identity(&mp2);
mp2.r[0].x = 0.0;
mp2.r[0].y = 1.0;
mp2.r[1].x = -1.0; // flipped
mp2.r[1].y = 0.0;
m4x4_multiply(mtx, &mp2, &mp3);
}
void m4x4_persp_tilt(matrix_4x4* mtx, float fovx, float invaspect, float near, float far)
{
// Notes:
// We are passed "fovy" and the "aspect ratio". However, the 3DS screens are sideways,
// and so are these parameters -- in fact, they are actually the fovx and the inverse
// of the aspect ratio. Therefore the formula for the perspective projection matrix
// had to be modified to be expressed in these terms instead.
// Notes:
// fovx = 2 atan(tan(fovy/2)*w/h)
// fovy = 2 atan(tan(fovx/2)*h/w)
// invaspect = h/w
// a0,0 = h / (w*tan(fovy/2)) =
// = h / (w*tan(2 atan(tan(fovx/2)*h/w) / 2)) =
// = h / (w*tan( atan(tan(fovx/2)*h/w) )) =
// = h / (w * tan(fovx/2)*h/w) =
// = 1 / tan(fovx/2)
// a1,1 = 1 / tan(fovy/2) = (...) = w / (h*tan(fovx/2))
float fovx_tan = tanf(fovx / 2);
matrix_4x4 mp;
m4x4_zeros(&mp);
// Build standard perspective projection matrix
mp.r[0].x = 1.0f / fovx_tan;
mp.r[1].y = 1.0f / (fovx_tan*invaspect);
mp.r[2].z = (near + far) / (near - far);
mp.r[2].w = (2 * near * far) / (near - far);
mp.r[3].z = -1.0f;
// Fix depth range to [-1, 0]
matrix_4x4 mp2;
m4x4_identity(&mp2);
mp2.r[2].z = 0.5;
mp2.r[2].w = -0.5;
m4x4_multiply(mtx, &mp2, &mp);
// Rotate the matrix one quarter of a turn CCW in order to fix the 3DS screens' orientation
m4x4_rotate_z(mtx, M_PI / 2, true);
}

View File

@ -1,56 +0,0 @@
/*
* Bare-bones simplistic 3D math library
* This library is common to all libctru GPU examples
*/
#pragma once
#include <string.h>
#include <stdbool.h>
#include <math.h>
typedef union { struct { float w, z, y, x; }; float c[4]; } vector_4f;
typedef struct { vector_4f r[4]; } matrix_4x4;
static inline float v4f_dp4(const vector_4f* a, const vector_4f* b)
{
return a->x*b->x + a->y*b->y + a->z*b->z + a->w*b->w;
}
static inline float v4f_mod4(const vector_4f* a)
{
return sqrtf(v4f_dp4(a,a));
}
static inline void v4f_norm4(vector_4f* vec)
{
float m = v4f_mod4(vec);
if (m == 0.0) return;
vec->x /= m;
vec->y /= m;
vec->z /= m;
vec->w /= m;
}
static inline void m4x4_zeros(matrix_4x4* out)
{
memset(out, 0, sizeof(*out));
}
static inline void m4x4_copy(matrix_4x4* out, const matrix_4x4* in)
{
memcpy(out, in, sizeof(*out));
}
void m4x4_identity(matrix_4x4* out);
void m4x4_multiply(matrix_4x4* out, const matrix_4x4* a, const matrix_4x4* b);
void m4x4_translate(matrix_4x4* mtx, float x, float y, float z);
void m4x4_scale(matrix_4x4* mtx, float x, float y, float z);
void m4x4_rotate_x(matrix_4x4* mtx, float angle, bool bRightSide);
void m4x4_rotate_y(matrix_4x4* mtx, float angle, bool bRightSide);
void m4x4_rotate_z(matrix_4x4* mtx, float angle, bool bRightSide);
// Special versions of the projection matrices that take the 3DS' screen orientation into account
void m4x4_ortho_tilt(matrix_4x4* mtx, float left, float right, float bottom, float top, float near, float far);
void m4x4_persp_tilt(matrix_4x4* mtx, float fovy, float aspect, float near, float far);

View File

@ -1,94 +0,0 @@
#include "gpu.h"
#define DISPLAY_TRANSFER_FLAGS \
(GX_TRANSFER_FLIP_VERT(0) | GX_TRANSFER_OUT_TILED(0) | GX_TRANSFER_RAW_COPY(0) | \
GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) | \
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO))
static u32 *colorBuf, *depthBuf;
static u32 *cmdBuf;
void gpuInit(void)
{
colorBuf = vramAlloc(400*240*4);
depthBuf = vramAlloc(400*240*4);
cmdBuf = linearAlloc(0x40000*4);
GPU_Init(NULL);
GPU_Reset(NULL, cmdBuf, 0x40000);
}
void gpuExit(void)
{
linearFree(cmdBuf);
vramFree(depthBuf);
vramFree(colorBuf);
}
void gpuClearBuffers(u32 clearColor)
{
GX_MemoryFill(
colorBuf, clearColor, &colorBuf[240*400], GX_FILL_TRIGGER | GX_FILL_32BIT_DEPTH,
depthBuf, 0, &depthBuf[240*400], GX_FILL_TRIGGER | GX_FILL_32BIT_DEPTH);
gspWaitForPSC0(); // Wait for the fill to complete
}
void gpuFrameBegin(void)
{
// Configure the viewport and the depth linear conversion function
GPU_SetViewport(
(u32*)osConvertVirtToPhys(depthBuf),
(u32*)osConvertVirtToPhys(colorBuf),
0, 0, 240, 400); // The top screen is physically 240x400 pixels
GPU_DepthMap(-1.0f, 0.0f); // calculate the depth value from the Z coordinate in the following way: -1.0*z + 0.0
// Configure some boilerplate
GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
GPU_SetStencilOp(GPU_STENCIL_KEEP, GPU_STENCIL_KEEP, GPU_STENCIL_KEEP);
GPU_SetBlendingColor(0,0,0,0);
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
// This is unknown
GPUCMD_AddMaskedWrite(GPUREG_0062, 0x1, 0);
GPUCMD_AddWrite(GPUREG_0118, 0);
// Configure alpha blending and test
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);
int i;
for (i = 0; i < 6; i ++)
GPU_SetDummyTexEnv(i);
}
void gpuFrameEnd(void)
{
// Finish rendering
GPU_FinishDrawing();
GPUCMD_Finalize();
GPUCMD_FlushAndRun();
gspWaitForP3D(); // Wait for the rendering to complete
// Transfer the GPU output to the framebuffer
GX_DisplayTransfer(
colorBuf, GX_BUFFER_DIM(240, 400),
(u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), GX_BUFFER_DIM(240, 400),
DISPLAY_TRANSFER_FLAGS);
gspWaitForPPF(); // Wait for the transfer to complete
// Reset the command buffer
GPUCMD_SetBufferOffset(0);
};
void GPU_SetDummyTexEnv(int id)
{
GPU_SetTexEnv(id,
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);
}

View File

@ -1,26 +0,0 @@
/*
* Bare-bones simplistic GPU wrapper
* This library is common to all libctru GPU examples
*/
#pragma once
#include <string.h>
#include <3ds.h>
#include "3dmath.h"
void gpuInit(void);
void gpuExit(void);
void gpuClearBuffers(u32 clearColor);
void gpuFrameBegin(void);
void gpuFrameEnd(void);
// Configures the specified fixed-function fragment shading substage to be a no-operation
void GPU_SetDummyTexEnv(int id);
// Uploads an uniform matrix
static inline void GPU_SetFloatUniformMatrix(GPU_SHADER_TYPE type, int location, matrix_4x4* matrix)
{
GPU_SetFloatUniform(type, location, (u32*)matrix, 4);
}

View File

@ -1,244 +0,0 @@
/*
* ~~ Simple libctru GPU textured cube example ~~
* This example demonstrates the basics of using the PICA200 in a 3DS homebrew
* application in order to render a basic scene consisting of a rotating
* textured cube which is also shaded using a simple shading algorithm.
* The shading algorithm is explained in the vertex shader source code.
*/
#include "gpu.h"
#include "vshader_shbin.h"
#include "kitten_bin.h"
#define CLEAR_COLOR 0x68B0D8FF
typedef struct { float position[3]; float texcoord[2]; float normal[3]; } vertex;
static const vertex vertex_list[] =
{
// First face (PZ)
// First triangle
{ {-0.5f, -0.5f, +0.5f}, {0.0f, 0.0f}, {0.0f, 0.0f, +1.0f} },
{ {+0.5f, -0.5f, +0.5f}, {1.0f, 0.0f}, {0.0f, 0.0f, +1.0f} },
{ {+0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {0.0f, 0.0f, +1.0f} },
// Second triangle
{ {+0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {0.0f, 0.0f, +1.0f} },
{ {-0.5f, +0.5f, +0.5f}, {0.0f, 1.0f}, {0.0f, 0.0f, +1.0f} },
{ {-0.5f, -0.5f, +0.5f}, {0.0f, 0.0f}, {0.0f, 0.0f, +1.0f} },
// Second face (MZ)
// First triangle
{ {-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {0.0f, 0.0f, -1.0f} },
{ {-0.5f, +0.5f, -0.5f}, {1.0f, 0.0f}, {0.0f, 0.0f, -1.0f} },
{ {+0.5f, +0.5f, -0.5f}, {1.0f, 1.0f}, {0.0f, 0.0f, -1.0f} },
// Second triangle
{ {+0.5f, +0.5f, -0.5f}, {1.0f, 1.0f}, {0.0f, 0.0f, -1.0f} },
{ {+0.5f, -0.5f, -0.5f}, {0.0f, 1.0f}, {0.0f, 0.0f, -1.0f} },
{ {-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {0.0f, 0.0f, -1.0f} },
// Third face (PX)
// First triangle
{ {+0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {+1.0f, 0.0f, 0.0f} },
{ {+0.5f, +0.5f, -0.5f}, {1.0f, 0.0f}, {+1.0f, 0.0f, 0.0f} },
{ {+0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {+1.0f, 0.0f, 0.0f} },
// Second triangle
{ {+0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {+1.0f, 0.0f, 0.0f} },
{ {+0.5f, -0.5f, +0.5f}, {0.0f, 1.0f}, {+1.0f, 0.0f, 0.0f} },
{ {+0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {+1.0f, 0.0f, 0.0f} },
// Fourth face (MX)
// First triangle
{ {-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f} },
{ {-0.5f, -0.5f, +0.5f}, {1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f} },
{ {-0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {-1.0f, 0.0f, 0.0f} },
// Second triangle
{ {-0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {-1.0f, 0.0f, 0.0f} },
{ {-0.5f, +0.5f, -0.5f}, {0.0f, 1.0f}, {-1.0f, 0.0f, 0.0f} },
{ {-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {-1.0f, 0.0f, 0.0f} },
// Fifth face (PY)
// First triangle
{ {-0.5f, +0.5f, -0.5f}, {0.0f, 0.0f}, {0.0f, +1.0f, 0.0f} },
{ {-0.5f, +0.5f, +0.5f}, {1.0f, 0.0f}, {0.0f, +1.0f, 0.0f} },
{ {+0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {0.0f, +1.0f, 0.0f} },
// Second triangle
{ {+0.5f, +0.5f, +0.5f}, {1.0f, 1.0f}, {0.0f, +1.0f, 0.0f} },
{ {+0.5f, +0.5f, -0.5f}, {0.0f, 1.0f}, {0.0f, +1.0f, 0.0f} },
{ {-0.5f, +0.5f, -0.5f}, {0.0f, 0.0f}, {0.0f, +1.0f, 0.0f} },
// Sixth face (MY)
// First triangle
{ {-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {0.0f, -1.0f, 0.0f} },
{ {+0.5f, -0.5f, -0.5f}, {1.0f, 0.0f}, {0.0f, -1.0f, 0.0f} },
{ {+0.5f, -0.5f, +0.5f}, {1.0f, 1.0f}, {0.0f, -1.0f, 0.0f} },
// Second triangle
{ {+0.5f, -0.5f, +0.5f}, {1.0f, 1.0f}, {0.0f, -1.0f, 0.0f} },
{ {-0.5f, -0.5f, +0.5f}, {0.0f, 1.0f}, {0.0f, -1.0f, 0.0f} },
{ {-0.5f, -0.5f, -0.5f}, {0.0f, 0.0f}, {0.0f, -1.0f, 0.0f} },
};
#define vertex_list_count (sizeof(vertex_list)/sizeof(vertex_list[0]))
static DVLB_s* vshader_dvlb;
static shaderProgram_s program;
static int uLoc_projection, uLoc_modelView;
static int uLoc_lightVec, uLoc_lightHalfVec, uLoc_lightClr, uLoc_material;
static matrix_4x4 projection;
static matrix_4x4 material =
{
{
{ { 0.0f, 0.2f, 0.2f, 0.2f } }, // Ambient
{ { 0.0f, 0.4f, 0.4f, 0.4f } }, // Diffuse
{ { 0.0f, 0.8f, 0.8f, 0.8f } }, // Specular
{ { 1.0f, 0.0f, 0.0f, 0.0f } }, // Emission
}
};
static void* vbo_data;
static void* tex_data;
static float angleX = 0.0, angleY = 0.0;
static void sceneInit(void)
{
// Load the vertex shader and create a shader program
vshader_dvlb = DVLB_ParseFile((u32*)vshader_shbin, vshader_shbin_size);
shaderProgramInit(&program);
shaderProgramSetVsh(&program, &vshader_dvlb->DVLE[0]);
// Get the location of the uniforms
uLoc_projection = shaderInstanceGetUniformLocation(program.vertexShader, "projection");
uLoc_modelView = shaderInstanceGetUniformLocation(program.vertexShader, "modelView");
uLoc_lightVec = shaderInstanceGetUniformLocation(program.vertexShader, "lightVec");
uLoc_lightHalfVec = shaderInstanceGetUniformLocation(program.vertexShader, "lightHalfVec");
uLoc_lightClr = shaderInstanceGetUniformLocation(program.vertexShader, "lightClr");
uLoc_material = shaderInstanceGetUniformLocation(program.vertexShader, "material");
// Compute the projection matrix
m4x4_persp_tilt(&projection, 80.0f*M_PI/180.0f, 400.0f/240.0f, 0.01f, 1000.0f);
// Create the VBO (vertex buffer object)
vbo_data = linearAlloc(sizeof(vertex_list));
memcpy(vbo_data, vertex_list, sizeof(vertex_list));
// Load the texture
tex_data = linearAlloc(kitten_bin_size);
memcpy(tex_data, kitten_bin, kitten_bin_size);
}
static void sceneRender(void)
{
// Bind the shader program
shaderProgramUse(&program);
// Configure the first fragment shading substage to blend the texture color with
// the vertex color (calculated by the vertex shader using a lighting algorithm)
// See https://www.opengl.org/sdk/docs/man2/xhtml/glTexEnv.xml for more insight
GPU_SetTexEnv(0,
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), // RGB channels
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR), // Alpha
GPU_TEVOPERANDS(0, 0, 0), // RGB
GPU_TEVOPERANDS(0, 0, 0), // Alpha
GPU_MODULATE, GPU_MODULATE, // RGB, Alpha
0xFFFFFFFF);
// Configure the first texture unit
GPU_SetTextureEnable(GPU_TEXUNIT0);
GPU_SetTexture(
GPU_TEXUNIT0,
(u32*)osConvertVirtToPhys(tex_data),
64, // Width
64, // Height
GPU_TEXTURE_MAG_FILTER(GPU_LINEAR) | GPU_TEXTURE_WRAP_S(GPU_REPEAT) | GPU_TEXTURE_WRAP_T(GPU_REPEAT), // Flags
GPU_RGBA8 // Pixel format
);
// Configure the "attribute buffers" (that is, the vertex input buffers)
GPU_SetAttributeBuffers(
3, // Number of inputs per vertex
(u32*)osConvertVirtToPhys(vbo_data), // Location of the VBO
GPU_ATTRIBFMT(0, 3, GPU_FLOAT) | // Format of the inputs
GPU_ATTRIBFMT(1, 2, GPU_FLOAT) |
GPU_ATTRIBFMT(2, 3, GPU_FLOAT),
0xFFC, // Unused attribute mask, in our case bits 0~2 are cleared since they are used
0x210, // Attribute permutations (here it is the identity, passing each attribute in order)
1, // Number of buffers
(u32[]) { 0x0 }, // Buffer offsets (placeholders)
(u64[]) { 0x210 }, // Attribute permutations for each buffer (identity again)
(u8[]) { 3 }); // Number of attributes for each buffer
// Calculate the modelView matrix
matrix_4x4 modelView;
m4x4_identity(&modelView);
m4x4_translate(&modelView, 0.0, 0.0, -2.0 + 0.5*sinf(angleX));
m4x4_rotate_x(&modelView, angleX, true);
m4x4_rotate_y(&modelView, angleY, true);
// Rotate the cube each frame
angleX += M_PI / 180;
angleY += M_PI / 360;
// Upload the uniforms
GPU_SetFloatUniformMatrix(GPU_VERTEX_SHADER, uLoc_projection, &projection);
GPU_SetFloatUniformMatrix(GPU_VERTEX_SHADER, uLoc_modelView, &modelView);
GPU_SetFloatUniformMatrix(GPU_VERTEX_SHADER, uLoc_material, &material);
GPU_SetFloatUniform(GPU_VERTEX_SHADER, uLoc_lightVec, (u32*)(float[]){0.0f, -1.0f, 0.0f, 0.0f}, 1);
GPU_SetFloatUniform(GPU_VERTEX_SHADER, uLoc_lightHalfVec, (u32*)(float[]){0.0f, -1.0f, 0.0f, 0.0f}, 1);
GPU_SetFloatUniform(GPU_VERTEX_SHADER, uLoc_lightClr, (u32*)(float[]){1.0f, 1.0f, 1.0f, 1.0f}, 1);
// Draw the VBO
GPU_DrawArray(GPU_TRIANGLES, 0, vertex_list_count);
}
static void sceneExit(void)
{
// Free the texture
linearFree(tex_data);
// Free the VBO
linearFree(vbo_data);
// Free the shader program
shaderProgramFree(&program);
DVLB_Free(vshader_dvlb);
}
int main()
{
// Initialize graphics
gfxInitDefault();
gpuInit();
// Initialize the scene
sceneInit();
gpuClearBuffers(CLEAR_COLOR);
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank(); // Synchronize with the start of VBlank
gfxSwapBuffersGpu(); // Swap the framebuffers so that the frame that we rendered last frame is now visible
hidScanInput(); // Read the user input
// Respond to user input
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
// Render the scene
gpuFrameBegin();
sceneRender();
gpuFrameEnd();
gpuClearBuffers(CLEAR_COLOR);
// Flush the framebuffers out of the data cache (not necessary with pure GPU rendering)
//gfxFlushBuffers();
}
// Deinitialize the scene
sceneExit();
// Deinitialize graphics
gpuExit();
gfxExit();
return 0;
}

View File

@ -1,90 +0,0 @@
; Example PICA200 vertex shader
; Uniforms
.fvec projection[4], modelView[4]
.fvec lightVec, lightHalfVec, lightClr, material[4]
.alias mat_amb material[0]
.alias mat_dif material[1]
.alias mat_spe material[2]
.alias mat_emi material[3]
; Constants
.constf myconst(0.0, 1.0, -1.0, -0.5)
.alias zeros myconst.xxxx ; Vector full of zeros
.alias ones myconst.yyyy ; Vector full of ones
; Outputs
.out outpos position
.out outtc0 texcoord0
.out outclr color
; Inputs (defined as aliases for convenience)
.alias inpos v0
.alias intex v1
.alias innrm v2
.proc main
; Force the w component of inpos to be 1.0
mov r0.xyz, inpos
mov r0.w, ones
; r1 = modelView * inpos
dp4 r1.x, modelView[0], r0
dp4 r1.y, modelView[1], r0
dp4 r1.z, modelView[2], r0
dp4 r1.w, modelView[3], r0
; outpos = projection * r1
dp4 outpos.x, projection[0], r1
dp4 outpos.y, projection[1], r1
dp4 outpos.z, projection[2], r1
dp4 outpos.w, projection[3], r1
; outtex = intex
mov outtc0, intex
; Transform the normal vector with the modelView matrix
; r1 = normalize(modelView * innrm)
mov r0.xyz, innrm
mov r0.w, zeros
dp4 r1.x, modelView[0], r0
dp4 r1.y, modelView[1], r0
dp4 r1.z, modelView[2], r0
mov r1.w, zeros
dp3 r2, r1, r1 ; r2 = x^2+y^2+z^2 for each component
rsq r2, r2 ; r2 = 1/sqrt(r2) ''
mul r1, r2, r1 ; r1 = r1*r2
; Calculate the diffuse level (r0.x) and the shininess level (r0.y)
; r0.x = max(0, -(lightVec * r1))
; r0.y = max(0, (-lightHalfVec[i]) * r1) ^ 2
dp3 r0.x, lightVec, r1
add r0.x, zeros, -r0
dp3 r0.y, -lightHalfVec, r1
max r0, zeros, r0
mul r0.y, r0, r0
; Accumulate the vertex color in r1, initializing it to the emission color
mov r1, mat_emi
; r1 += specularColor * lightClr * shininessLevel
mul r2, lightClr, r0.yyyy
mul r2, mat_spe, r2
add r1, r2, r1
; r1 += diffuseColor * lightClr * diffuseLevel
mul r2, lightClr, r0.xxxx
mul r2, mat_dif, r2
add r1, r2, r1
; r1 += ambientColor * lightClr
mov r2, lightClr
mul r2, mat_amb, r2
add r1, r2, r1
; outclr = clamp r1 to [0,1]
min outclr, ones, r1
; We're finished
end
.end

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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,57 +0,0 @@
/*
Both Screen Text example made by Aurelio Mannara for ctrulib
This code was modified for the last time on: 12/12/2014 23:20 UTC+1
*/
#include <3ds.h>
#include <stdio.h>
int main(int argc, char **argv)
{
// Initialize services
gfxInitDefault();
//In this example we need one PrintConsole for each screen
PrintConsole topScreen, bottomScreen;
//Initialize console for both screen using the two different PrintConsole we have defined
consoleInit(GFX_TOP, &topScreen);
consoleInit(GFX_BOTTOM, &bottomScreen);
//Before doing any text printing we should select the PrintConsole in which we are willing to write, otherwise the library will print on the last selected/initialized one
//Let's start by printing something on the top screen
consoleSelect(&topScreen);
printf("This is the top screen. We have lot of space here!\n");
//Now write something else on the bottom screen
consoleSelect(&bottomScreen);
printf("This is the bottom screen. We don't have much space...\nStill better than DS screens :D");
consoleSelect(&topScreen);
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();
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,69 +0,0 @@
/*
Colored Text example made by Aurelio Mannara for ctrulib
This code was modified for the last time on: 12/12/2014 23:00 UTC+1
*/
#include <3ds.h>
#include <stdio.h>
int main(int argc, char **argv)
{
// 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);
//Move the cursor to row 15 and column 19 and then prints "Hello World!"
//To move the cursor you have tu print "\x1b[r;cH", where r and c are respectively
//the row and column where you want your cursor to move
//The top screen has 30 rows and 50 columns
//The bottom screen has 30 rows and 40 columns
printf("\x1b[15;19HHello World!");
//Move the cursor to the top left corner of the screen
printf("\x1b[0;0H");
//Print a REALLY crappy poeam with colored text
//\x1b[cm set a SGR (Select Graphic Rendition) parameter, where c is the parameter that you want to set
//Please refer to http://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes to see all the possible SGR parameters
//As of now ctrulib support only these parameters:
//Reset (0), Half bright colors (2), Reverse (7), Text color (30-37) and Background color (40-47)
printf("Roses are \x1b[31mred\x1b[0m\n");
printf("Violets are \x1b[34mblue\x1b[0m\n");
printf("Piracy is bad\n");
printf("While homebrews are good\n\n");
//Black text on white background
//In this example we set two parameter in a single escape sequence by separating them by a semicolon
//\x1b[47;30m means that it will set a white background (47) and it will print white characters (30)
//In this we also could have used the
printf("\x1b[47;30mBlack text on white background\x1b[0m");
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();
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,46 +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
*/
#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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,66 +0,0 @@
/*
Multiple Windows Text example made by Aurelio Mannara for ctrulib
This code was modified for the last time on: 12/12/2014 23:50 UTC+1
*/
#include <3ds.h>
#include <stdio.h>
int main(int argc, char **argv)
{
// Initialize services
gfxInitDefault();
//In this example we need three PrintConsole, one for each window and one for the whole top screen
PrintConsole leftWindow, rightWindow, topScreen;
//Initialize console for each window
consoleInit(GFX_TOP, &leftWindow);
consoleInit(GFX_TOP, &rightWindow);
consoleInit(GFX_TOP, &topScreen);
//Now we specify the window position and dimension for each console window using consoleSetWindow(PrintConsole* console, int x, int y, int width, int height);
//x, y, width and height are in terms of cells, not pixel, where each cell is composed by 8x8 pixels.
consoleSetWindow(&leftWindow, 1, 1, 23, 28);
consoleSetWindow(&rightWindow, 26, 1, 23, 28);
//Before doing any text printing we should select the PrintConsole in which we are willing to write, otherwise the library will print on the last selected/initialized one
//Let's start by printing something on the top screen
consoleSelect(&leftWindow);
printf("This text is in the left window!\n");
printf("3DS rocks!!!\n");
//Now write something else on the bottom screen
consoleSelect(&rightWindow);
printf("This text is in the right window!\n");
printf("This thing works pretty well!\n");
consoleSelect(&topScreen);
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();
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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, 1);
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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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,45 +0,0 @@
#include <3ds.h>
#include <stdio.h>
static bool allowed = false;
// If you define this function, you can monitor/debug APT events
void _aptDebug(int a, int b)
{
if (allowed)
printf("_aptDebug(%d,%x)\n", a, b);
}
int main()
{
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
allowed = true;
printf("Press B to launch applet\n");
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
gfxSwapBuffers();
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
gfxFlushBuffers();
// Launch the extrapad library applet when button B is pressed.
if (kDown & KEY_B)
{
Result rc = APT_LaunchLibraryApplet(APPID_EXTRAPAD, 0, NULL, 0);
if (rc) printf("APT_LaunchLibraryApplet: %08lX\n", rc);
}
}
// Exit services
gfxExit();
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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);
MVDSTD_Config 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(inaddr, 0x46500);
printstring("mvd example\n");
ret = mvdstdInit(MVDMODE_COLORFORMATCONV, MVD_INPUT_YUYV422, MVD_OUTPUT_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(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);
mvdstdExit();
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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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;
QTM_HeadTrackingInfo 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 = QTM_GetHeadTrackingInfo(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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,6 +0,0 @@
Hello, this is the libctru romfs example.
This text is being read off a file in romfs.
>>3DS Homebrew is Cool<<
Signed off, fincs

View File

@ -1,2 +0,0 @@
The path to this file contains UTF-16
characters that fall outside ASCII.

View File

@ -1,58 +0,0 @@
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <3ds.h>
void printfile(const char* path)
{
FILE* f = fopen(path, "r");
if (f)
{
char mystring[100];
while (fgets(mystring, sizeof(mystring), f))
{
int a = strlen(mystring);
if (mystring[a-1] == '\n')
{
mystring[a-1] = 0;
if (mystring[a-2] == '\r')
mystring[a-2] = 0;
}
puts(mystring);
}
printf(">>EOF<<\n");
fclose(f);
}
}
int main()
{
gfxInitDefault();
consoleInit(GFX_TOP, NULL);
Result rc = romfsInit();
if (rc)
printf("romfsInit: %08lX\n", rc);
else
{
printf("romfs Init Successful!\n");
printfile("folder/file.txt");
// Test reading a file with non-ASCII characters in the name
printfile("フォルダ/ファイル.txt");
}
// Main loop
while (aptMainLoop())
{
gspWaitForVBlank();
hidScanInput();
u32 kDown = hidKeysDown();
if (kDown & KEY_START)
break; // break in order to return to hbmenu
}
romfsExit();
gfxExit();
return 0;
}

View File

@ -1,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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(GSPGPU_EVENT_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,196 +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.
# ROMFS is the directory which contains the RomFS, relative to the Makefile (Optional)
# 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
#ROMFS := romfs
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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)))
PICAFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.v.pica)))
SHLISTFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.shlist)))
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)) \
$(PICAFILES:.v.pica=.shbin.o) $(SHLISTFILES:.shlist=.shbin.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
ifeq ($(strip $(NO_SMDH)),)
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
endif
ifneq ($(ROMFS),)
export _3DSXFLAGS += --romfs=$(CURDIR)/$(ROMFS)
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)
#---------------------------------------------------------------------------------
# rules for assembling GPU shaders
#---------------------------------------------------------------------------------
define shader-as
$(eval CURBIN := $(patsubst %.shbin.o,%.shbin,$(notdir $@)))
picasso -o $(CURBIN) $1
bin2s $(CURBIN) | $(AS) -o $@
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(CURBIN) | tr . _)`.h
echo "extern const u8" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(CURBIN) | tr . _)`.h
echo "extern const u32" `(echo $(CURBIN) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(CURBIN) | tr . _)`.h
endef
%.shbin.o : %.v.pica %.g.pica
@echo $(notdir $^)
@$(call shader-as,$^)
%.shbin.o : %.v.pica
@echo $(notdir $<)
@$(call shader-as,$<)
%.shbin.o : %.shlist
@echo $(notdir $<)
@$(call shader-as,$(foreach file,$(shell cat $<),$(dir $<)/$(file)))
-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,122 +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 -mtp=soft
CFLAGS := -g -Wall -O2 -mword-relocations \
-fomit-frame-pointer -ffunction-sections \
$(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.

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