AlisterT / openjazz

OpenJazz
GNU General Public License v2.0
275 stars 49 forks source link

Revamp the old platform ports and integrate them #27

Closed carstene1ns closed 3 years ago

carstene1ns commented 6 years ago

OJ is known to have run on a lot of different platforms, partly with network support. Also, it has recently been ported to PSVITA and will likely soon receive a Switch port.

I currently do have the source code and auxiliary stuff for the Wii port and have the necessary tools to build it. A PSP port is nowadays already included. PSVITA is available here: https://github.com/usineur/openjazz Further platforms: http://alister.eu/jazz/oj/download.php

carstene1ns commented 5 years ago

Wii port works quite good, tested on Hardware.

carstene1ns commented 3 years ago

For the psvita port there is a branch now: psvita. The others are probably too old, source seems lost.

vaguerant commented 3 years ago

Does the Wii version currently build, or is that one of the too old ports? There are binaries around from ~10 years ago, but a more recent build would be nice, especially if it added more modern features like Wii U GamePad and Pro Controller support which would make it almost as good as a native Wii U port.

carstene1ns commented 3 years ago

The Wii port works quite well and has been tested by myself. It will be part of next release (together with 3DS and PSP). However, for proper WiiU support we would need libwupc or something.

vaguerant commented 3 years ago

Excellent, very glad to hear that. As for Wii U support, the Pro Controller should work just by building with newer libraries--internally, the Pro Controller is just another Wiimote+Extension controller like the Nunchuk, Classic Controller or even the Balance Board, and it was added to the Wii homebrew library (libogc I think?) years ago.

For the Wii U GamePad, you do need the libwiidrc library. I'm not a real programmer, but I actually did add Wii U GamePad support to another homebrew a while back and it was surprisingly simple: https://github.com/JeffRuLz/OpenHCL/commit/ad295de

If you want to give it a shot, you can skip the #include <string.h> from that commit, which I left behind in error from some testing. Otherwise, that commit should have everything you need to add GamePad support.

The only other Wii U-specific feature that would be handy is switching the video to 4:3, which requires a register poke on Wii U, as otherwise the game will display stretched to 16:9 on both TV and GamePad. It's my understanding that the Wii port is 4:3-only, if I'm wrong about that do ignore me.

Here's some code snippets from OpenHCL again where I handled switching to 4:3. This would all go in your video code somewhere.

First off is the include which I think is what gives you access to those low-level read32, write32 and mask32 instructions:

#include <ogc/machine/processor.h>

Then just determining whether you're running on a Wii U.

isWiiVC = read32(0x12FFFFC0);
isWiiU  = ((*(vu16*)0xCD8005A0 == 0xCAFE) || isWiiVC);

Again, not a programmer, but if I'm not mistaken, I think you might also be able to simplify that down to just:

isWiiU  = ((*(vu16*)0xCD8005A0 == 0xCAFE) || read32(0x12FFFFC0));

This next part is poking the register to switch the scaling to 4:3. You can just poke this register on startup every time without causing any issues--if the system is already running in 4:3, it won't do anything, but if it's running at 16:9, this will switch it to 4:3.

if (isWiiU)
    {
        write32(0xd8006a0, 0x30000002);
        mask32(0xd8006a8, 0, 2);
    }

And then upon exit of your graphics, you again check if this is a Wii U, and whether the Wii U is configured to 16:9. If yes to both, the register is poked back to its normal 16:9 stretching behavior. It's necessary to check for 16:9 here because it's possible (if unlikely) that somebody is running their Wii U in 4:3, so you can't just assume you should switch back to 16:9 on exit.

if (isWiiU && CONF_GetAspectRatio() == CONF_ASPECT_16_9)
    {
        write32(0xd8006a0, 0x30000004);
        mask32(0xd8006a8, 0, 2);
    }

I won't be able to give it a shot until after the weekend, but I'll see if I can get OpenJazz building for Wii on my end, and if so I'll make an attempt to add all this Wii U stuff. However, the last time I attempted the same (after OpenHCL) I failed miserably, so I can't promise I'll be able to contribute anything useful.

carstene1ns commented 3 years ago

The controller support is unfortunately not doable without patching the SDL library, otherwise this is a big hack. The widescreen support is way easier and actually on my list for wii as well, so code can be shared.

vaguerant commented 3 years ago

Ah, I hadn't realized this was a feature missing from SDL Wii rather than OpenJazz. It would definitely be nice to see support over there.