Using Ruby for Sega Dreamcast development: Difference between revisions

From dreamcast.wiki
Jump to navigation Jump to search
m (Adding Ruby link)
(Major upgrade as mruby is now officially supported as kos-port.)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
Since 2019, it's now possible to develop in [https://www.ruby-lang.org Ruby] for the Sega Dreamcast system using the [https://mruby.org/ mruby implementation]. The proof-of-concept was made by [[Yuji Yokoo]]. This is experimental and a lot of features are missing, not working and/or not tested (e.g. debugging).
It is possible to develop in [https://www.ruby-lang.org Ruby] for the Sega Dreamcast system using the [https://mruby.org/ mruby implementation]. This support was originally introduced by [[Yuji Yokoo]] in 2019.
 
Like most Sega Dreamcast software, this project uses [[KallistiOS]] (KOS) as its base.
 
'''Note:''' Debugging support has not been tested as of 2025.


As almost all Sega Dreamcast software, this uses [[KallistiOS]] (KOS).
== Prerequisites ==
== Prerequisites ==


* You should have a working [[KallistiOS]] environment and all the dependencies made for compiling KallistiOS installed;
* A working [[KallistiOS]] environment must be set up, including all necessary dependencies for building KallistiOS;
* You need to have [[KallistiOS]] library built;
* You must build the [[KallistiOS]] library;
* the ''/opt/toolchains/dc/kos/kernel/build/newlib_kill.o'' and ''/opt/toolchains/dc/kos/kernel/build/newlib_getpid.o'' object files should be on your disk (they are produced when building KOS).
* You must have both ''ruby'' and ''bison'' installed (see the sections below).
* You need to have ''rake'' and ''bison'' installed (see below).


=== Installing prerequisites on Cygwin ===
=== Installing prerequisites on Cygwin ===


Open the Cygwin setup and search for the ''rake'' and ''bison'' packages and install them.
Launch the Cygwin setup utility, search for the ''ruby'' and ''bison'' packages, and install them.
 
=== Installing prerequisites on DreamSDK ===
 
Depending on the underlying environment installed with [[DreamSDK]], there are 2 possible cases:
 
==== If you are using the modern MinGW-w64/MSYS2 foundation ==== 


=== Installing prerequisites on DreamSDK (MinGW/MSYS) ===
No additional prerequisites are required — both Ruby and Bison are already preinstalled.


If you use the [[DreamSDK]] environment (or your custom [http://mingw.org MinGW/MSYS] environment) you need to install '''Ruby''' for Windows and the additional ''bison'' package.
==== If you are using the legacy MinGW/MSYS foundation ====


* Install [https://rubyinstaller.org/ RubyInstaller] then verify that the ''rake'' command is available in the ''PATH'' environment variable.
Install manually the prerequisites:
* Install ''msys-bison-bin'' package from the '''MinGW Installation Manager''' program.
* Install [https://rubyinstaller.org/ RubyInstaller], and ensure that the ''ruby'' command is available in your system ''PATH'';
* Use the '''MinGW Installation Manager''' to install the ''msys-bison-bin'' package.


'''Note:''' If you are using DreamSDK on Windows XP, then you should install [https://rubyinstaller.org/ RubyInstaller] 2.0.0 as it the last version which supports this system.
'''Note:''' If you are using DreamSDK on Windows XP, you should install Ruby version 2.0.0 from [https://rubyinstaller.org/ RubyInstaller], as it is the last version compatible with that operating system.


=== Installing prerequisites on GNU/Linux ===
=== Installing prerequisites on GNU/Linux ===


Install the ''rake'' and ''bison'' packages with your package manager (e.g. ''apt'' with Debian/Ubuntu).
Use your distribution’s package manager to install the ''ruby'' and ''bison'' packages (e.g., run ''apt install ruby bison'' on Debian/Ubuntu).


=== Installing prerequisites on macOS ===
=== Installing prerequisites on macOS ===


Install the ''rake'' and ''bison'' packages with your package manager (e.g. ''brew'').
Install the ''ruby'' and ''bison'' packages using your preferred package manager (e.g., ''brew'').


=== Installing prerequisites on MinGW-w64/MSYS2 ===
=== Installing prerequisites on MinGW-w64/MSYS2 ===


  pacman -S rake bison
Run the following command in the MSYS2 shell:
 
pacman -S ruby bison


== Setting up mruby ==
== Setting up mruby ==


Open a Terminal and type the following:
The recommended way to use mruby on Dreamcast is to install the '''mruby''' port from the [https://github.com/KallistiOS/kos-ports KallistiOS Ports repository].
 
First of all, make sure to clone the kos-ports repository:
cd /opt/toolchains/dc
git clone https://github.com/KallistiOS/kos-ports.git .
 
Then, run the following commands:
 
cd /opt/toolchains/dc/kos-ports/mruby
make install clean
 
This will build the embedded mruby library (''libmruby.a'') along with the required host tools (mainly ''/opt/toolchains/dc/bin/mrbc'') for the Dreamcast platform.


cd /opt
'''Note:''' The configuration file is stored in ''build_config/dreamcast_shelf.rb'' in the [https://github.com/mruby/mruby mruby] official repository.
git clone https://github.com/mruby/mruby.git
cd /opt/mruby
cp examples/targets/build_config_dreamcast_shelf.rb build_config.rb
make


This will generate all the required files, i.e. the host tools plus the embedded mruby library (''libmruby.a'') for the Sega Dreamcast.
== Using mruby in a Sega Dreamcast project ==


== Using mruby on a Sega Dreamcast project ==
Two example projects are included with [[KallistiOS]] in the ''/examples/dreamcast/mruby'' directory:


Currently, two projects are available as template:
* '''dreampresent''' – A simple presentation tool (this needs the ''libpng'' port as well);
* [https://github.com/yujiyokoo/dreampresent Dreampresent]: A simple presentation tool;
* '''mrbtris''' – A sample game.
* [https://github.com/yujiyokoo/mrbtris-dreamcast Mrbtris]: A sample game.


Clone these repositories then build these projects by using the usual ''make'' command (of course, this requires '''mruby''' installed properly!).
These examples were originally developed by [[Yuji Yokoo]] and correspond to the earlier stand-alone repositories. You can build them using the standard ''make'' command (assuming '''mruby''' and any additional required ports are properly installed via kos-ports).

Latest revision as of 21:09, 7 August 2025

It is possible to develop in Ruby for the Sega Dreamcast system using the mruby implementation. This support was originally introduced by Yuji Yokoo in 2019.

Like most Sega Dreamcast software, this project uses KallistiOS (KOS) as its base.

Note: Debugging support has not been tested as of 2025.

Prerequisites

  • A working KallistiOS environment must be set up, including all necessary dependencies for building KallistiOS;
  • You must build the KallistiOS library;
  • You must have both ruby and bison installed (see the sections below).

Installing prerequisites on Cygwin

Launch the Cygwin setup utility, search for the ruby and bison packages, and install them.

Installing prerequisites on DreamSDK

Depending on the underlying environment installed with DreamSDK, there are 2 possible cases:

If you are using the modern MinGW-w64/MSYS2 foundation

No additional prerequisites are required — both Ruby and Bison are already preinstalled.

If you are using the legacy MinGW/MSYS foundation

Install manually the prerequisites:

  • Install RubyInstaller, and ensure that the ruby command is available in your system PATH;
  • Use the MinGW Installation Manager to install the msys-bison-bin package.

Note: If you are using DreamSDK on Windows XP, you should install Ruby version 2.0.0 from RubyInstaller, as it is the last version compatible with that operating system.

Installing prerequisites on GNU/Linux

Use your distribution’s package manager to install the ruby and bison packages (e.g., run apt install ruby bison on Debian/Ubuntu).

Installing prerequisites on macOS

Install the ruby and bison packages using your preferred package manager (e.g., brew).

Installing prerequisites on MinGW-w64/MSYS2

Run the following command in the MSYS2 shell:

pacman -S ruby bison

Setting up mruby

The recommended way to use mruby on Dreamcast is to install the mruby port from the KallistiOS Ports repository.

First of all, make sure to clone the kos-ports repository:

cd /opt/toolchains/dc
git clone https://github.com/KallistiOS/kos-ports.git .

Then, run the following commands:

cd /opt/toolchains/dc/kos-ports/mruby
make install clean

This will build the embedded mruby library (libmruby.a) along with the required host tools (mainly /opt/toolchains/dc/bin/mrbc) for the Dreamcast platform.

Note: The configuration file is stored in build_config/dreamcast_shelf.rb in the mruby official repository.

Using mruby in a Sega Dreamcast project

Two example projects are included with KallistiOS in the /examples/dreamcast/mruby directory:

  • dreampresent – A simple presentation tool (this needs the libpng port as well);
  • mrbtris – A sample game.

These examples were originally developed by Yuji Yokoo and correspond to the earlier stand-alone repositories. You can build them using the standard make command (assuming mruby and any additional required ports are properly installed via kos-ports).