Cross-platform mruby on Sega Dreamcast and Nintendo Wii

Summarized using AI

Cross-platform mruby on Sega Dreamcast and Nintendo Wii

Yuji Yokoo • May 15, 2024 • Naha, Okinawa, Japan • Talk

In the presentation titled "Cross-platform mruby on Sega Dreamcast and Nintendo Wii," delivered by Yuji Yokoo at RubyKaigi 2024, the speaker explores the application of mruby, a lightweight implementation of Ruby, in developing software for both the Sega Dreamcast and Nintendo Wii. The presentation outlines several key points regarding cross-platform development, the technical specifications of both consoles, and specific challenges faced during the development process.

Key Points Discussed:
- Introduction of Speaker: Yuji Yokoo introduces himself as a software developer at CyberStash, with a background in data protection software, and his passion for video game console development.
- Overview of mruby: Mruby is described as an efficient, lightweight Ruby implementation that facilitates embedding Ruby into C programs. It is noted for its suitability for both Dreamcast and Wii development.
- Sega Dreamcast: Released in 1998, the Dreamcast features a 200MHz processor and 160MB of RAM. The legacy of the Dreamcast includes a vibrant indie community with tools like KallistiOS, which now supports mruby, allowing developers to create custom software easily.
- Nintendo Wii: Launched in 2006, the Wii is distinguished by its innovative control scheme with the Wii Remote. Yuji discusses how many WII consoles remain unused, highlighting the potential for new software development on this platform.
- Development of Dream Present App: Yuji details the application "Dream Present," initially created for the Dreamcast and later ported to the Wii. He discusses its features, which include text, image, and sound support, and the live demo aspect of the presentation.
- Technical Contributions for Cross-Platform Development: The speaker emphasizes the differences in hardware and software between both consoles, such as their processors, libraries, and storage methods (CD for Dreamcast and SD card for Wii). He shares insights into the complexities of managing a unified source code for cross-platform compatibility.
- Challenges and Adaptations: Yuji explains the difficulties encountered when developing for both consoles due to varying APIs and hardware capabilities, showcasing how he adapted the Wii's motion controls for Dreamcast using a fishing controller.

The presentation concludes with a demonstration of the game developed for both platforms, illustrating the successful implementation of cross-platform mruby on the Dreamcast and Wii. Participants are encouraged to explore more about his projects through provided links.

Key Takeaways:
- Cross-platform development requires careful consideration of hardware capabilities, software stacks, and coding practices.
- The Dreamcast and Wii, despite their differences, both support open development which fosters innovation in indie game development.
- Creative solutions to technology differences can lead to effective cross-platform applications.

Cross-platform mruby on Sega Dreamcast and Nintendo Wii
Yuji Yokoo • May 15, 2024 • Naha, Okinawa, Japan • Talk

RubyKaigi 2024

00:00:09.440 Okay, hello everyone! Thank you for being here. I am really glad to see so many people in this session.
00:00:12.080 This presentation is about cross-platform mruby on Sega Dreamcast and Nintendo Wii. I have my Nintendo Wii right here, and I also have a GameCube controller connected. Let me start the presentation.
00:00:42.239 This program takes a while to start, but this is the output from my Nintendo Wii. Oh wait, this is the boot menu, so there's one more step to go.
00:01:00.100 So, yeah, this is a familiar looking logo on Wii. This presentation is about cross-platform mruby on Sega Dreamcast and Nintendo Wii by me, Yuji Yokoo, at RubyKaigi 2024. Press 'A' to start, so let’s go!
00:01:24.240 As for the table of contents, this is not quite accurate because I kept changing the content. Basically, I am going to talk a little bit about myself, then discuss the Dreamcast and Wii, how I support them, and about this presentation app I’m running right now. I will also cover cross-platform development, its differences, limitations, and conclude with thanks and information, as well as a little demo game if I have time for it.
00:02:01.079 So, let’s go! This is me, I’m Yuji. I’m a software developer working at a Sydney-based startup called CyberStash where we work on software systems that help people protect data. I do things like encryption in use and tracking where the data goes. I should mention that I’m not an expert in game console development or software development in general. I am now based in Tokyo but have spent a lot of time in Australia, and you can reach me at my email, [email protected], or on GitHub and Twitter.
00:02:57.920 Being at RubyKaigi, I’m sure many people know what mruby is, but I don’t want to assume everyone does. Mruby is a lightweight implementation of Ruby and is great for embedding into C programs. It doesn't have to be C, but it’s the most straightforward option.
00:03:08.840 About the Dreamcast, I have a photo of my Dreamcast here. In fact, I have the unit right here, but I'm not going to lift it. The Dreamcast was the best video game console from Sega, released in November 1998. It has a 200 MHz processor and 160 MB of RAM, which is quite limited by today’s standards. However, the great thing about the Dreamcast is the indie community, which is still very strong. There are still commercial software titles being released, and there’s good free and open-source software available for homebrew and indie development. One of the most popular options is called KallistiOS, which comes with tools and libraries, and has a port system allowing additional software to be compiled and added to your environment. KallistiOS now includes mruby, so you can easily use mruby there. The great thing about this is that I did not do anything; someone else did all the work to get mruby into KallistiOS.
00:04:55.080 Dreamcast can run your custom code—your software—without any hardware modifications. You can write a specially formatted CDR, and the Dreamcast will read that. Assuming everyone knows what CDRs are, I won’t dwell on that. Now, regarding the Wii, I have a photo of my Nintendo Wii, which is the exact same unit I’m using right now. This console was released in 2006 and was quite innovative.
00:05:49.160 Can you believe it’s been 18 years? Although it wasn’t very powerful by the standards of the day, what differentiated the Wii from other consoles was the Wii Remote, also known as the Wiimote. I actually have one here, and my presentation software supports it. The Wii was extremely popular, selling over 100 million units worldwide. This means there are lots of people who have a Wii collecting dust at home; I was one of them until I started developing software for it.
00:06:48.360 As for this application, the presentation you are seeing right now is called Dream Present. I started developing it in 2019 for the Dreamcast. Originally, it ran on Dreamcast only, but now, as you can see, it’s running on my Wii. So, it runs on both the Dreamcast and the Wii. However, it is technically the Dream Present version ported to Wii, so it's not the Wii version; it's Dream Present running on the Wii.
00:07:51.840 The main features of this app include text, image, and sound support. It’s a live demo, meaning it’s running my code on the game console. So, if there are glitches or crashes, please forgive me because it’s a live demo. Something’s got to go wrong, right? Regarding my support for the Dreamcast and Wii, the Dreamcast has been officially supported since 2020, which means there’s a build configuration file included in the main distribution.
00:08:34.320 The pull request to add Dreamcast support was done by the person who also contributed significantly to adding UI to KallistiOS. The build configuration for Nintendo Wii was added recently in October 2023 upon my own contribution. You should be able to run specific commands to build mruby for these platforms, although you will need the respective toolchains and libraries installed on your system.
00:09:50.800 You might be wondering why I am doing this or why you might want to do this. That is a great question. As far as comparing the Dreamcast and Wii goes, they are quite different in many ways. The Dreamcast uses an SH4 processor, while the Wii runs on a PPC processor; they come from different generations, even though the Dreamcast was relatively powerful for its time.
00:10:25.760 The Wii has more memory, processing power, and graphical capabilities. Generally speaking, it is easier to port something from Dreamcast to Wii than vice versa. Additionally, the software stacks are different; the libraries and tools must be prepared separately. A positive note is that both consoles have free and open development SDKs and come with GCC, which is great for anyone wanting to work with mruby.
00:11:30.080 When writing code for both Dreamcast and Wii, you need to write some C and compile mruby code using mrbc to create bytecode. You then need to integrate that bytecode with your C code and use the appropriate toolchains for both platforms. After generating object files, you link them with the Dream C library and the mruby library, which includes the mruby runtime.
00:12:50.640 In the case of Dreamcast, after compiling, you write it onto a CD, and for the Wii, you can put it on an SD card. To make things cross-platform, I initially considered using mruby gems, which would allow adding and removing features at compile time. However, due to some unresolved issues, I decided against it.
00:13:40.079 Instead, I opted for manual management with separate source folders. I started this project on the Dreamcast, ported it to Wii, and then brought it back to Dreamcast so that it runs on both platforms. Initially, the source directory had one makefile, but when I ported it to Wii, I had to split the makefile into two separate files. The source files were also split into Wii and Dreamcast directories, each containing relevant C and Ruby extension files.
00:14:31.360 This is an overview of what the source directory looked like. The main function in C includes Dreamcast-specific initialization in the top half and shared loading logic in the bottom half. However, a lot of things have different API calls and constant names, which can make cross-platform development challenging.
00:15:51.760 This is the main entry point of the main presentation application, which is just plain Ruby. Notably, Chaos provides a ROM disk for assets, which acts as a virtual filesystem, allowing you to use it similarly to a regular file system. On the other hand, when using devkitPPC on Wii, it converts assets into an object file and a header file, making them available as constants within your program.
00:16:44.080 Thus, if you're using filenames to identify assets, you need to map those filenames to variables for Wii. Another notable difference is in the graphics API. On Chaos, you can use a simple VRAM-based approach, where each pixel has a memory address, allowing direct RGB value writing. This works well for low-performance requirements. However, for the Wii, I use GRLib, which supports PNG files and requires calling graphics drawing functions before rendering, increasing the complexity of your drawing pipeline.
00:18:44.800 The key difference is that with the VRAM-based approach, you can draw whatever you want at any time. However, in the rendering-based approach, you have to keep track of the existing objects you’ve drawn to properly render new graphics during the render call.
00:19:08.000 Another difference is that the Wii Remote is not available on the Dreamcast. I will show you how I adapted the motion gestures feature for the Dreamcast shortly. You might be wondering how I achieved this adaptation.
00:19:36.000 Interestingly, there was a fishing controller for the Dreamcast that comes with a reel as well as a motion sensor. This allowed me to bring the user interface in line with the Wii version. Thank you very much, everyone. This is a demonstration of cross-platform mruby on Dreamcast and Wii. See how both work in harmony!
00:20:44.760 I have developed a little demo game for you, which can be played with the Wii Remote, although the response is not optimal for gameplay. Let me switch to showing you the Dreamcast version. This is the hardware-modified Dreamcast version of the presentation. While the screen cannot be skipped, it responds to my controller well, working similarly with some visual differences. The Dreamcast version is an adaptation of the cross-platform application!
00:24:49.640 However, without the motion gestures available from the Wii Remote, it cannot be deemed fully cross-platform. I crafted a technique to utilize the controller to emulate motion by swinging and pressing the button simultaneously.
00:25:13.920 Thank you for your attention! If you would like more information about my projects and developments regarding video game consoles, please scan the QR code or visit the links on the screen.
Explore all talks recorded at RubyKaigi 2024
+56