![]() ![]() ![]() The game now runs super well on the switch and its fully featured. I also configured the switch power mode into power-saving mode to run at lower clocks. This made the game use very little battery. The game could easily run at 200 fps on the nintendo switch, but the screen can only do 60 fps, so its v-synced and just idling the chips for most of the frame, saving a lot of power. This upgrade made the game run way better on all platforms, and with it, the game now never goes past 5 milliseconds per frame. I began by implementing my own opengl matrix stack, then I implemented my own version of the opengl fixed pipeline calls that instead save the vertex data into an array, and then draw it all at once. This was not quite as simple, as the game was using the matrix stack of OpenGL too to transform the shapes, and most of the shapes were rendered using things like triangle strip, or triangle fan. The next fix was to remove the glBegin(polygon) 6-calls-per-triangle type of rendering, and use vertex buffers like everyone does. This change made the game run at 60 fps in most levels, but the levels with 500+ bullets on them would still drop below 60 fps. This did change the graphics a bit due to the changes to draw order, but the performance increase was very considerable, as it now does 3 pipeline switches when rendering the bullets instead of 1000+. Instead of switching the graphics pipeline 3 times per bullet, I grouped all of the bullets, and drawed them together. To fix them, I started by rearranging the code. Both of the issues became a big hit to performance. This meant that the game could do pipeline switches up to 1000 times a frame. Even bigger of an issue is that it was rendering 1 bullet at a time, with each bullet drawing 3 shapes with different pipeline settings. Nowadays you only see that sort of code in terrible university graphics courses. This was so bad that it got deprecated back around 2004. The game, as old as it is, was using OpenGL fixed pipeline graphics, doing glBegin(triangles) type code and executing multiple gl calls per bullet. After all it’s a wireframe rendered game from 2002. I found that the game logic update was taking sub 1 millisecond, but the graphics side was taking a lot of time on the CPU side. I ran the game through a profiler to see what was going slow. With sound and input now working, the game is actually properly playable on switch, just a bit on the slow side. Do not use headphones when dealing with low level audio code. This took a while as i’m not used to dealing with audio code, but using a implementation i found in the internet as starting point, i got everything running correctly on switch and pc. For audio, I had no other choice but to implement my own version of SDL_Mixer using the native SDL 2 audio Apis. There was a bit of trouble with the specific gamepad assignments as attached joycons aren’t quite the same as detached joycons, but it worked. I implemented support for gamepads using that API on the PC, and it pretty much worked on the switch. Luckily, in SDL 2 there is a multiplatform gamepad api. Now its time to implement actual gamepad support so that the game can be played on the switch. With the SDL 2 upgrade the code was changed, but it was still using keyboard keys. The input system for the game was using keyboard keys using SDL api. The process of porting the game was done in stages, which i mostly follow in all the porting projects i do as its mostly a general workflow. Meanwhile MIT and other similar licenses only require you to give attribution, but they dont require you to post all the source code, so its possible to use in consoles. In short, the GPL license forces the developer to release the source code of the executables if any small part of the project uses GPL code, and this conflicts with the console NDAs. Licenses like MIT and BSD2 are completely fine to port to consoles, but GPL licenses are completely impossible to port. The code license is BSD2, which is mostly like MIT. Here is the link to the game in nintendo e-shop. In here, i write about how I ported it to Nintendo Switch. I sent an email to the original developer and he answered with his full approval, so i started the work. I chose that game to port because I like bullet hells and because this is a easy project to port due to its minimal codebase and dependencies while it has a license that allows porting to consoles. Its a bullet hell game that has been ported to many platforms over the years, such as Android, IOS, and PsP homebrew. The game is rRootage, made by Kenta Cho, a japanese developer who has released tons of open source games. ![]() As my latest side project, ive ported a 2002 open source game to nintendo switch. ![]()
0 Comments
Leave a Reply. |