ia: Benvenite! In mi blog io scribe in interlingua, italiano e anglese.

it: Benvenuti! Nel mio blog scrivo in interlingua, italiano e inglese.

en: Welcome! In my blog I write in Interlingua, Italian and English.

Porting OpenGL games to the Nintendo Wii: cho.mono

More than one year has passed since my last blog post, and I'm a bit ashamed to confess that today's post is again about porting games to the Nintendo Wii — I always tell to myself that I'm soon going to move to something else, possibly less geeky than this (by the way, there is something else I could write about, but I'll leave it for another post!), but the problems posed by porting games to an old console are just way too stimulating, and my brain gets attracted to them in a way that I cannot resist.

Anyway, have you ever heard of OpenGX? It's a project aiming to write an OpenGL driver for the Nintendo GameCube and Wii's GX API: while these consoles have good (at the time, at least) 3D capabilities, they were programmed via an API not even remotely close to OpenGL, so back in 2013 one developer by the name of David Guillen Fandos started a project to investigate the possibility of wrapping the GX API in OpenGL. The project was abandoned after reaching a very basic state, but it's author was diligent enough to write a PDF file describing its design and some implementation details. Having bumped into this document, I was inspired by it and felt it was a pity that such a project had died -- especially given the fact that this didn't happen because of some technical infeasibility. So exactly one year ago, in the spring of 2024, I picked it up and tried porting the game BillardGL to the Wii; I had to add quite a few things to OpenGX, and adjusting the lighting pipeline, but after less than one month the port of BillardGL was ready. In the following months, I ported several other OpenGL 1.x games, gradually enhancing and expanding OpenGX, until I got most of OpenGL 1.4 supported.

A 23 year old game was just ported to a 19 year old console.

Should I have stopped there? Probably. Because indeed the Wii's GPU, despite allowing a good degree of complexity in setting up its shading engine (called TEV, Texture Environment), does not support the modern GL shading language, and trying to have the CPU compile the shaders into something that GX could understand is a task doomed to fail, in part because this would eat up all the computing power, but especially because there simply isn't an algorithm that could translate GLSL into GX commands. Is this the end of the journey then?

Well, the fact that OpenGL 2.0+ shaders can not be machine-translated into GX commands does not mean that this task is impossible: we've still got the human brain to use! The idea is the following: let the deveoper who is porting the game write the GX code corresponding to the GLSL code by hand. Saying it like this might feel like this is no better than saying “Just port the whole rendering backend to GX!” but as a matter of facts, there's a big difference: with this approach all the rest of the OpenGL code stays untouched, and the way I have design this shader substitution to work in OpenGX allows one to keep the GX code isolated in its own source file, without having to change a single line of the program, save from adding a line near the beginning (in main(), typically) to install the GX hooks. This means that your program will still call glUniform*(), glVertexAttribPointer() and so on to setup the rendering pipeline, but when the program will get to execute glDrawArrays() OpenGX will pass control to the hooks previously installed, which will receive the uniforms and the attributes, and setup the pipeline using GX commands. It might seem complicated, but it really isn't (well, if you can deal with the GX API), and it's even more efficient than the fixed pipeline of OpenGL 1.x, since here the GX commands are reduced to the bare minimum required by the shader, whereas in the fixed pipeline we have to follow predefined steps.

chro.mono running on a Nintendo Wii.

The first (and for the time being, the last) OpenGL 2.0+ game I've ported to the Wii is chro.mono, a nice puzzle game from 2013 whose source code has been released in 2021. It uses the FBO feature from OpenGL 3.0, so I had to implement it in OpenGX as well. I'm quite satisfied with the result, not only because the game runs at 60 FPS, but because it shows how rather complex shaders (the game has more than a dozen of them) can be realized in GX; to tell the truth, in couple of cases I had to implement the fragment shader by converting its code to C and drawing to a temporary texture, but luckily these shaders are used only during program startup to draw to an FBO and don't negatively affect the game performance. You can download it from here.

Summing up, if you get really bored and would like to engage in something unusual (read: useless), porting games to older consoles would definitely keep you active for some time. Unfortunately there aren't that many OpenGL games which are open source, so the candidates for porting are not that many (by the way, feel free to suggest in the comments — well, not for me, but maybe someone else will do it).

libSDL2 and VVVVVV for the Wii

Just a quick update on something that I've been working on in my free time.

I recently refurbished my old Nintendo Wii, and for some reason I cannot yet explain (not even to myself) I got into homebrew programming and decided to port libSDL (the 2.x version -- a 1.x port already existed) to it. The result of this work is already available via the devkitPro distribution, and although I'm sure there are still many bugs, it's overall quite usable.

In order to prove it, I ported the game VVVVVV to the Wii:

During the process I had to fix quite a few bugs in my libSDL port and in a couple of other libraries used by VVVVVV, which will hopefully will make it easier to port more games. There's still an issue that bothers me, where the screen resolution seems to be not totally supported by my TV (or is it the HDMI adaptor's fault?), resulting in a few pixels being cut at the top and at the bottom of the screen. But unless you are a perfectionist, it's a minor issue.

In case you have a Wii to spare, or wouldn't mind playing on the Dolphin emulator, here's the link to the VVVVVV release. Have fun! :-)

Will the internet forget russophobia?

I've often wondering what will happen when this horrific war in Europe will finally be over. I won't be discussing politics here, but what is mostly interesting to me is how (and if) all the companies who made high proclaims about not doing business with Russia will justify their getting back into the Russian market. They will probably count on the fact that the war will be long, and that people will forget what these companies' stance was. After all, the world has forget about all the companies who collaborated with the Nazi regime, so we can expect the same to happen with this war.

But I don't think that's right: if you made a mistake, you should be held accountable for it. You might be wondering what is the “mistake” I'm talking about: that's russophobia, indeed. To put it simply, and make a concrete example: if The Qt Company stops doing business with Russian companies and blocks its downloads page to Russian IP addresses because of the war, without being forced by the government to do so, but does not take similar measures against other countries who wage wars which have caused way more deaths and displacement of individuals, well, that's what I call “russophobia”. Of course, I'm aware that there's way more than that, and that the hatred for all what is Russian (including culture and sport competitions) is an even bigger issue, but in this blog post I'm especially focused on the IT world, so please forgive my semi-intentional narrow-mindness on this topic.

Now, I'm fully aware that we live in a mediatic bubble that directs our decisions in a way that is almost automatic, and I'm sure that most people working for companies who took russophobic decisions are not themselves russophobic at all (and I'm not dismissing the possibility that even the very same people who took these decisions might not be russophobic) and that these decisions were taken on impulse, because “everyone else is doing the same” and due to the media pressure that if you don't do that, you might get accused of supporting the “wrong” side of the war.

But that's not an excuse, especially for “smart” people like IT engineers (and I put the adjective between quotes for a reason), and especially after the initial heat has passed and when, after more than one year of war, we should have been exposed to different point of views and be able to evaluate the situation more rationally. It has been therefore especially stunning for me to learn that the Linux Kernel community, and hence The Linux Foundation, has recently given room to russophobic behaviours, refusing a patch coming from the Russian company Baikal (a CPU maker). For the record, the incriminated patch was not related to supporting hardware produced by this company (not that this would make the deed less serious, but at least one could have argued that there could be some spot of logic in it):

From: Jakub Kicinski <kuba@kernel.org>
To: Serge Semin <Sergey.Semin@baikalelectronics.ru>
[...]

On Tue, 14 Mar 2023 01:42:24 +0300 Serge Semin wrote:
> From: Serge Semin <Sergey.Semin@baikalelectronics.ru>

We don't feel comfortable accepting patches from or relating 
to hardware produced by your organization.

Please withhold networking contributions until further notice.

(here the link to the original discussion). One week later, someone denounced this as a violation to the Code of Conduct committee (unfortunately the only link I could find to this is coming from a Russian IT forum, and any other references seem to have been removed from DuckDuckGo and Google), only to receive a reply that it was all fine.

To me this is not fine. The war will end, sooner or later, but it bothers me that we never learn from the past and repeat the same mistakes over and over. We apparently know a lot about propaganda, yet we fail to recognize it when it influences our own mind and actions. My humble contribution is the creation of a page where I list the companies who have taken russophobic actions, and, on the opposite side, companies (like Flickr and Zorin OS) who have stood out for positive messages and helpful actions. My hope is that some of the listed companies will find the courage to review their actions, and either correct their stance, or at least clarify their reasons. So, I hereby present

Denouncing russophobia

where you'll find some of the good and some of the bad companies. I'm sure I'm missing plenty of them: I just started recollecting my memories and searching online a couple of days ago. I created this as a GitHub project, because indeed I'm looking forward for contributions, to help me make the lists more complete. I need to stress that the fact that a company has announced the suspension of its business in Russia does not automatically make it russophobic: what we need to look at is the reason for that decision: companies like LEGO and Nintendo, for example, have suspended their operations citing logistic and financial reasons; no judgement involved.

Let me repeat it once more, just to make sure there are no misunderstandings: it's perfectly fine for businesses to take a stance on politics, and sometimes it might be even praiseworthy; but if a company is international, and does not apply the same reasoning to other armed conflicts, or seem to care only about certain human rights violations and not others, then it's a case of double standards which we need to be aware of, and make the company think twice about it. And that's also the reason why you won't find any Ukrainian company among the “bad” ones, because in their case the reaction is perfectly understandable and they can hardly be accused of adopting double standards (well, technically speaking, they are adopting double standards, but when you are so directly impacted I think it does not deserve a blame): if it's your house which burns, you should definitely scream about it, even if you previously have been silent about your neighbour house's burning.

I'm especially looking forward for more “good” companies, who have shown empathy towards the people affected by the war (and maybe even collected money to help them) while refraining from taking the judging role and forgetting about all the injustice and suffering that other wars have caused (including on that very same piece of land that suddenly appeared on all newspapers' front pages on February 24th, 2022). I hope that these companies can serve as an example of positive action, humanity, and love.

Un editoriale di Marco Travaglio

Nonostante io non legga più Il Fatto Quotidiano (per i motivi spiegati qui, che restano tuttora validi), continuo a imbattermi negli editoriali di Marco Travaglio, che spesso apprezzo. Oggi invece mi sono imbattuto nell'introduzione del suo nuovo libro “Scemi di guerra”, e ve ne riporto un estratto che ho trovato particolarmente incisivo.


Abbiamo abolito la storia. È vietato raccontare ciò che è accaduto in Ucraina prima del 24 febbraio 2022: gli otto anni di guerra civile in Donbass dopo il golpe bianco (anzi, nero) di Euromaidan nel 2014 e le migliaia di morti e feriti causati dai continui attacchi delle truppe di Kiev e delle milizie filo-naziste al seguito contro le popolazioni russofone e russofile che, col sostegno di Mosca, chiedevano l’indipendenza o almeno l’autonomia. Il tutto in barba ai due accordi di Minsk. La versione ufficiale, l’unica autorizzata, è che prima del 2022 non è successo niente: una mattina Putin s’è svegliato più pazzo del solito e ha invaso l’Ucraina. Se la gente scoprisse la verità, capirebbe che il mantra atlantista “Putin aggressore e Zelensky aggredito” vale solo dal 2022: prima, per otto anni, gli aggressori erano i governi di Kiev (l’ultimo, quello di Zelensky) e gli aggrediti i popoli del Donbass. Fra le vittime, c’è il giornalista italiano Andrea Rocchelli, ucciso dall’esercito ucraino… Abbiamo abolito la geografia. Proibito mostrare la cartina dell’allargamento della Nato a Est negli ultimi 25 anni (da 16 a 30 membri)… Eppure, che la Nato si sia allargata a Est, accerchiando e assediando la Russia, minacciandone la sicurezza con installazioni di missili nucleari sempre più vicine al confine, in barba alle promesse fatte a Gorbaciov nel 1990, fino all’ultima provocazione di annunciare l’imminente ingresso nell’Alleanza dei vicini di casa della Russia – Georgia e Ucraina – è un fatto storico indiscutibile…

L’altra cartina proibita è quella dei Paesi che non condannano o non sanzionano la Russia, o se ne restano neutrali: quasi tutta l’Asia, l’Africa e l’America Latina, cioè l’87% della popolazione mondiale. Ma al nostro piccolo mondo antico occidentale piace far credere che Putin è isolato e noi lo stiamo circondando. Sul fatto che Cina, India, Brasile e altri paesucoli stiano con lui o non stiano con noi, meglio sorvolare: altrimenti lo capiscono tutti che le sanzioni non funzionano… Solo abolendo la storia si può credere al presidente Sergio Mattarella quando ripete che “l’Ucraina è la prima guerra nel cuore dell’Europa nel dopoguerra”. E Belgrado bombardata anche dall’Italia nel 1999 dov’è, in Oceania? E chi era il vicepremier del governo D’Alema che bombardava Belgrado? Un certo Mattarella… Abbiamo abolito il rispetto per le altre culture. In una folle ondata di russofobia, abbiamo visto ostracizzare direttori d’orchestra, cantanti liriche, pianiste di fama mondiale, fotografi, atleti (anche paraolimpici), persino gatti e querce, soltanto perché russi. E poi censurare corsi su Dostoevskij, cancellare dai teatri i balletti di Cajkovskij, addirittura estromettere la delegazione russa dalle celebrazioni per la liberazione di Auschwitz. Come se il lager l’avessero liberato gli americani o gli ucraini e non l’Armata Rossa… i trombettieri della Nato propagandano la bufala dell’“euroatlantismo” e gli scemi di guerra se la bevono, senz’accorgersi che mai come oggi gli interessi dell’Europa sono opposti a quelli dell’America.