Castle Game Engine supports compiling games to the Nintendo Switch console.
It is a modern, successful, indie-friendly console from Nintendo. Our friend company, Cat-astrophe Games, has already released games using CGE on Nintendo Switch (Escape from the Universe and The Unholy Society).
It is a full integration, really 100% of the engine works on Nintendo Switch. You just write cross-platform Pascal code using CGE units. You can compile the application for Nintendo Switch:
from the GUI editor: Set "Run → Platform" to "Nintendo Switch",
or from the command-line: using the build tool with the --target=nintendo-switch
parameter.
All the existing CGE examples, like eye_of_beholder or platformer just work on Nintendo Switch.
We have released games on Nintendo store using Castle Game Engine:
The integration code with Nintendo Switch is not public and not open-source. It cannot be, as we are covered by Nintendo NDA agreements and we cannot disclose the technological details about how Nintendo Switch works. To develop on Nintendo Switch, you have to:
Become a Nintendo Developer yourself, and sign the necessary NDA agreements between your company and Nintendo. You will most likely want to buy a developer version of the console, as well.
Contact Michalis Kamburelis through the non-public Nintendo developer forum. I can then share with you the necessary code that adds Nintendo Switch integration on top of the open-source CGE core, through the Nintendo forum, so Nintendo can confirm it’s legally OK with them. Of course you get this for free. The integration code cannot be open-source, but I still want to give it to everyone for free.
We already went through this process with an external company, and everything was smooth, Nintendo has zero issues with us sharing code this way — under the roof of a closed forum where all participants are known to have signed NDA agreements.
As stressed in the previous section, the technical details of Nintendo Switch are confidential. Thus, the full documentation describing using the engine on Nintendo Switch is part of the closed-source engine branch, that you get for free once you confirm that you are registered Nintendo Developer — see above.
Some information that is not confidential:
It is public knowledge that Nintendo Switch devices uses Aarch64 CPU (see device CPU on Wikipedia). It is also public knowledge that Nintendo Switch supports OpenGL, OpenGLES and Vulkan APIs. So, yeah, we rely on these.
We are using unmodified FPC.
All the units available on Android / Aarch64 platform are available on Nintendo Switch as well. We use a small trick to utilize FPC for Android / Aarch64 (compiler and standard library) to develop on Nintendo Switch.
Note
|
TODO: FPC 3.3.1 has support for Embedded / Aarch64 target since September 2023. See commit to packages/fpmkunit/src/fpmkunit.pp. We should see can we use Embedded / Aarch64 instead of Android / Aarch64 hack — this would make things cleaner and simpler. |
You cannot access system-specific things using standard library. You have to use CGE. For example, you cannot open files using TFileStream
, you must open files using CGE Download
function. Even a large game can be easily recompiled for Nintendo Switch, but you need to use CGE API consistently for everything (reading and writing files, measuring time etc.)
Aside from syscalls (or things that indirectly do syscalls), everything else just works. The whole CGE API works, and the FPC standard library works as well as long as you avoid system calls. E.g. you can use standard FPC units to process XML, JSON etc. (just be sure to open/save them using CGE API like Download
, UrlSaveStream
).
You can use CASTLE_NINTENDO_SWITCH
conditional to make platform-specific code, if you need to. Like {$ifdef CASTLE_NINTENDO_SWITCH} DoSomethingNintendoSpecific; {$endif}
. But there’s a good chance you won’t need it, as the whole CGE API is available on Nintendo Switch and you can write cross-platform code that just works everywhere for all "normal" game needs.
If you have any questions, please ask.
For confident matters (and most Nintendo Switch questions are confidential, due to Nintendo NDA agreements) you can contact me privately. Send email to [email protected]
and/or write a thread on Nintendo developer forum and ping me about it.
To improve this documentation just edit this page and create a pull request to cge-www repository.