Homebrew Project SDL 2 port ongoing

mudrik

Member
OP
Newcomer
Joined
Nov 18, 2022
Messages
18
Trophies
0
Age
31
XP
165
Country
Turkey
Hi all!
A few weeks ago I started working on a SDL2 port for the Wii and GameCube. The current status is this:

✅ Audio
❌ Send audio to wiimote​
✅ Joysticks
✅ Gamepads​
✅ Rumble support​
❌ Keyboard
👷 Mouse
✅ Wiimote IR as mouse​
✅ Mouse cursors​
❌ USB Mouse​
❌ Power
❌ Sensors
✅ Time
✅ Threads
✅ Video
✅ Framebuffer​
✅ 2D acceleration​

The source code is available at https://github.com/mardy/SDL/tree/ogc-sdl2-2.28 (be sure to checkout the correct branch!), and instructions on how to build it are in docs/README-ogc.md. Once ready, I'll submit it for inclusion in devkitPro (and I wonder, if libSDL itself would accept it, or if they don't support out-of-market devices), but for the time being I'll be happy to get early feedback and bug reports.

UPDATE 2024-01-28: libSDL2 is now available from the devkitPro repository. It's still under works, but most things are working.
 
Last edited by mudrik,

SaulFabre

I like Yoshis and the Wii/Wii U scene.
Member
Joined
Feb 6, 2019
Messages
3,175
Trophies
2
Age
25
Location
Ecuador
Website
saulfabreg-wiivc.blogspot.com
XP
7,794
Country
Ecuador
Hi all!
A few weeks ago I started working on a SDL2 port for the Wii and GameCube. The current status is this:

✅ Audio
✅ Joysticks
✅ Gamepads​
✅ Rumble support​
❌ Keyboard
❌ Mouse
❌ Power
❌ Sensors
✅ Time
✅ Threads
👷 Video
✅ Framebuffer​
❌ 2D acceleration​

The source code is available at https://github.com/mardy/SDL/tree/ogc-sdl2-2.28 (be sure to checkout the correct branch!), and instructions on how to build it are in docs/README-ogc.md. Once ready, I'll submit it for inclusion in devkitPro (and I wonder, if libSDL itself would accept it, or if they don't support out-of-market devices), but for the time being I'll be happy to get early feedback and bug reports.
This sounds VERY, VERY nice, thanks for posting your progress with this! ^_^
 

mudrik

Member
OP
Newcomer
Joined
Nov 18, 2022
Messages
18
Trophies
0
Age
31
XP
165
Country
Turkey
Today I added support the using the Wiimote infrared pointing device as a mouse; it's not something that was implemented in the SDL1 port, but it seems potentially useful, since it would allow us to run some programs that require a mouse.

For the time being I mapped only two buttons (A and B, as right and left respectively), supporting more would not be hard at all, but I'm not sure it would be helpful (reaching the other buttons while pointing the Wiimote at the screen is not very comfortable).
 

mudrik

Member
OP
Newcomer
Joined
Nov 18, 2022
Messages
18
Trophies
0
Age
31
XP
165
Country
Turkey
I updated the first post: SDL2 is now in the devkitPro repositories, we've got 2D acceleration working, support for mouse cursors, and I will be very happy to help if people are trying to use it and encounter some issues. :-)
 

magarcan

New Member
Newbie
Joined
Feb 14, 2022
Messages
4
Trophies
0
Age
38
Location
Madrid
XP
84
Country
Spain
Thank you very much for the effort. I've looking for any framework to start, and this is the only one updated.

Just a question (maybe stupid one). What are the advantages of using SDl2 instead of GRRLIB for example?
 

JeffRuLz

Well-Known Member
Member
Joined
Sep 14, 2018
Messages
163
Trophies
0
XP
2,540
Country
United States
I decided to test it out with l'Abbaye des Morts today.
It took me a while to figure out which library dependencies I needed to add to the makefile. I think this is normal for SDL but it should probably be documented somewhere (maybe it was and I didn't see it?)
The project compiled for me with these libs:
Code:
LIBS    :=    -lSDL2_mixer -lSDL2_image -lSDL2main -lSDL2 \
            -lfat -lpng -lz -lopusfile -lopus -lmodplug -lvorbisidec -logg \
            -laesnd -lwiiuse -lbte -logc -lm -lstdc++

Video and sound seem to work but input did not. If it helps, this game uses joystick events instead of game controller.
 

JeffRuLz

Well-Known Member
Member
Joined
Sep 14, 2018
Messages
163
Trophies
0
XP
2,540
Country
United States
Hi Jeff, I'm sorry that I didn't see your message before. Have you solved the input issues already? If not, could you please link to your source code repo, so that I can try it?
I've uploaded a .zip because apparently I can't fork a repository on github twice?
It's pretty much identical to the original except for the makefile, and some minor tweaks to main.c. At line 29 I changed fullscreen to 1, and at line 67 I added a line that skips the menu and jumps into gameplay.
Also for the game to work you need the "data", "graphics", and "sounds" folders in the same location as the .dol file, or on the root of the virtual SD card if you're using dolphin.

Another thing I noticed: this game calls "SDL_ShowCursor(SDL_DISABLE);" however the wiimote pointer still displays on screen.
 

Attachments

  • abbayedesmorts-sd2-wii.zip
    6 MB · Views: 11

mudrik

Member
OP
Newcomer
Joined
Nov 18, 2022
Messages
18
Trophies
0
Age
31
XP
165
Country
Turkey
Another thing I noticed: this game calls "SDL_ShowCursor(SDL_DISABLE);" however the wiimote pointer still displays on screen.
Thanks, I'll try to fix this next.

As far as the joystick is concerned, this change fixes it, but I'll try to change SDL so that this modification won't be necessary:
Code:
index 8b6b483..9381ae4 100644
--- a/src/startscreen.c
+++ b/src/startscreen.c
@@ -99,6 +99,10 @@ void startscreen(SDL_Window *screen,uint8_t *state,uint8_t *grapset,uint8_t *ful
                                }
                        }
 
+                       if (keyp.type == SDL_JOYDEVICEADDED) {
+                               SDL_JoystickOpen(0);
+                       }
+
                        if (keyp.type == SDL_QUIT) { /* Exit game */
                                exit = 1;
                                *state = 6;
 

mudrik

Member
OP
Newcomer
Joined
Nov 18, 2022
Messages
18
Trophies
0
Age
31
XP
165
Country
Turkey
Cool, it's working now. I'll continue experimenting with it.
Hi Jeff, some updates:
- I've submitted a PR on Abbaye to support the wiimote directional keys: https://github.com/nevat/abbayedesmorts-gpl/pull/19
- Yesterday we merged a change in SDL to translate the directional movements for a Wiimote held sideways: you'll need to call
Code:
setenv("SDL_WII_JOYSTICK_SIDEWAYS", "1", 1);
before calling SDL_Init() for this to work.
- The cursor should now be gone, too :-)
 

JeffRuLz

Well-Known Member
Member
Joined
Sep 14, 2018
Messages
163
Trophies
0
XP
2,540
Country
United States
Hi Jeff, some updates:
- I've submitted a PR on Abbaye to support the wiimote directional keys: https://github.com/nevat/abbayedesmorts-gpl/pull/19
- Yesterday we merged a change in SDL to translate the directional movements for a Wiimote held sideways: you'll need to call
Code:
setenv("SDL_WII_JOYSTICK_SIDEWAYS", "1", 1);
before calling SDL_Init() for this to work.
- The cursor should now be gone, too :-)
That's awesome, excellent work!
Is there a full list of variables that can be changed for SDL on the Wii?

Also I wanted to ask about 240p support. Is there a way to enable it through SDL? I'm not sure if it needs to be SDL's responsibility, maybe there's a way to expose the current display mode and it can be changed externally.
 

GateGuy

Active Member
Newcomer
Joined
Nov 14, 2019
Messages
30
Trophies
0
XP
175
Country
United States
Might as well dig up this old account to sing my praises. I was going to port one of my games, SuDokuL, to SDL1 so I could get it on Wii, but it had some graphical issues. But then I found out about this SDL2 port, and that works like a charm! 60 FPS at 480p while constantly re-rendering everything. The pointer controls work great as well, especially with the built-in pointer graphic. I kinda wish it would rotate as you rotate the remote, but that's definitely a nitpick.
https://github.com/Mode8fx/SuDokuL

I also tried moving Trogdor: Reburninated from SDL1 to SDL2 (it supports both). To put the performance increase into perspective, the original SDL1 version hit 60 FPS at 240p but only went up to 25 FPS on 480p, while the SDL2 version is a constant 60 no matter what. However, changing the screen scaling mid-game, which involves recreating sprites and text at a different size, immediately crashes for the SDL2 version while SDL1 and other consoles' SDL2's handle it fine. It's probably something specific to how this game handles textures, I haven't looked into why it happens.
https://github.com/Mode8fx/Trogdor-Reburninated

Amazing work on this port! Are you also planning to port SDL2_image to Gamecube?

Also I wanted to ask about 240p support. Is there a way to enable it through SDL? I'm not sure if it needs to be SDL's responsibility, maybe there's a way to expose the current display mode and it can be changed externally.
It should work like SDL1's port where setting width to 320 and height to 240 via SDL_SetVideoMode() should automatically set the framebuffer to use 240p. That's what happens with SuDokuL.
 

mudrik

Member
OP
Newcomer
Joined
Nov 18, 2022
Messages
18
Trophies
0
Age
31
XP
165
Country
Turkey
That's awesome, excellent work!
Is there a full list of variables that can be changed for SDL on the Wii?
No, but you can run a "git grep" in the SDL repo to see them. Here are the current ones we support; others might be added tn the future:
- SDL_WII_JOYSTICK_SIDEWAYS: this you know :-)
- SDL_WII_JOYSTICK_SPLIT: The wiimote and its expansion will be reported as separate joysticks

Then there's a standard SDL hint, SDL_HINT_ACCELEROMETER_AS_JOYSTICK, which, if set, makes it so that the wiimote accelerometer is reported as additional axes on the Wiimote joystick.

Also I wanted to ask about 240p support. Is there a way to enable it through SDL? I'm not sure if it needs to be SDL's responsibility, maybe there's a way to expose the current display mode and it can be changed externally.
We don't currently support any window modes other than 640x480, but I think we should. I recently made a small app wii-screen (you can find it in the OpenShop), to study the available video modes. If you are willing to create a branch of Abbaye which calls SDL_SetWindowDisplayMode to set the video mode, then it will be easier for me to add the missing support.
Post automatically merged:

The pointer controls work great as well, especially with the built-in pointer graphic. I kinda wish it would rotate as you rotate the remote, but that's definitely a nitpick.
Please file it as a feature request, I'm not sure if I'll get into that soon (I'm afraid that the amount of work might not be worth the benefit), but it's nice to have it tracked -- maybe someone else will jump in and implement it before I do B-)

Nice! I need to try it B-)

I also tried moving Trogdor: Reburninated from SDL1 to SDL2 (it supports both). To put the performance increase into perspective, the original SDL1 version hit 60 FPS at 240p but only went up to 25 FPS on 480p, while the SDL2 version is a constant 60 no matter what. However, changing the screen scaling mid-game, which involves recreating sprites and text at a different size, immediately crashes for the SDL2 version while SDL1 and other consoles' SDL2's handle it fine. It's probably something specific to how this game handles textures, I haven't looked into why it happens.
https://github.com/Mode8fx/Trogdor-Reburninated
I'll give it a try. It may be that it uses SDL_LockTexture, which I haven't yet implemented. But if it's so, now I have a strong motivation to work on it B-)
https://github.com/Mode8fx/Trogdor-Reburninated
Amazing work on this port! Are you also planning to port SDL2_image to Gamecube?
Oh, I think that it was simply forgotten, there shouldn't be anything hard about it. Can you please file a bug here: https://github.com/devkitPro/pacman-packages/issues

It should work like SDL1's port where setting width to 320 and height to 240 via SDL_SetVideoMode() should automatically set the framebuffer to use 240p. That's what happens with SuDokuL.
There's no such function in SDL2, just SDL_SetWindowDisplayMode. SuDokuL is running at 640x480 with scaling. B-)
 
Last edited by mudrik,
  • Like
Reactions: splaca

GateGuy

Active Member
Newcomer
Joined
Nov 14, 2019
Messages
30
Trophies
0
XP
175
Country
United States
Please file it as a feature request, I'm not sure if I'll get into that soon (I'm afraid that the amount of work might not be worth the benefit), but it's nice to have it tracked -- maybe someone else will jump in and implement it before I do B-)
Like I said, it's a nitpick :)
Where would it be best to leave a feature request, though? I don't see a section for issues on your repo.
Oh, I think that it was simply forgotten, there shouldn't be anything hard about it. Can you please file a bug here: https://github.com/devkitPro/pacman-packages/issues
Done.
There's no such function in SDL2, just SDL_SetWindowDisplayMode. SuDokuL is running at 640x480 with scaling. B-)
Oh yeah, I forgot I'm just scaling everything relative to the display resolution. Never mind!
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    K3Nv2 @ K3Nv2: Lol rappers still promoting crypto