Accéder au contenu principal

Retro 0.1 RC

During last GUADEC, I had a chance to briefly present my project of having a powerful yet simple video game manager and player for GNOME. To make it a reality, a lot of work was needed on the backend side.

This article present the release of the first version of this backend, in its release candidate form.

Libretro

Libretro is a C/C++ API used mainly by retro video game console emulators and game engines. Writing an emulator and writing a GUI application require very different skills, using Libretro allows to isolate the backends (often called modules or cores) implementing the API from the frontends using the API to manipulate them, easying the port of the emulators or engines and offering a multiplicity of cores to choose from to application developers.

The main frontend of Libretro is RetroArch and it have been ported across multiple systems.

Retro

Retro (or retro-gobject) is a GObject based Libretro wrapping library written in Vala. It eases the creation of Libretro frontends by using OOP and automatic memory management (thanks to Vala and GObject); it allows the creation of Libretro frontends in other languages than C/C++ via GObject Introspection; and it allows to have multiple Libretro cores loaded at the  same time, through the use of a global variable to store the calling core's identity, and through file copy to avoid global variable collision in already used modules). Retro's API is not to be considered stable yet, but it is very close to be and shouldn't change much. Some objects are marked with a temporary internal visibility until they are tested and polished and can be part of the public API.

But most importantly, what Retro isn't is a fork of Libretro. All it does is to wrap it in a nice object-oriented layer and it is fully compatible with modules implementing Libretro.

Retro's git repository can be found here: https://github.com/Kekun/retro-gobject

Retro version 0.1 RC can be found here: https://github.com/Kekun/retro-gobject/releases/tag/v0.1-rc

Core

Core is the most important class of Retro. It represents the functionalities associated to a Libretro module and allow you to run it. A Core allows you to get information about its module, to set interfaces to handle the module's callbacks, and most importantly, to run it.

Video

The Video interface is use by a Core to ask the frontend to render video and to set details about how the video must be rendered, such as the source video's pixel format.

Audio

The Audio interface is used by a Core to ask the frontend to play audio.

Input

The Input interface is used by a Core to ask the frontend about the state of the input devices, such as gamepads, keyboards and mice.

Other interfaces

Lots of other interfaces can be set by the frontend or by the Core to communicate. Some examples are the Log interface, to let the Core write log messages, to the standard output or a file by example; the DiskControl interface, to let the frontend control a Core's virtual disk drive (for example, to swap disks on a CD based game console emulator); or the Variables interface to allow the frontend to know about the Core's special options and to set them.

RetroGtk

RetroGtk is a library written in Vala which links Retro, in order to run Libretro modules, and Gtk. It offers Gtk widgets implementing various Retro interfaces, allowing to easily display a Core's video, to forward keyboard and mouse events to it, and to mimick gamepads with a keyboard.

RetroGtk also contains non-Gtk related objects, like loops to help running a Core, an interface to forward a Core's log to a FileStream, and an interface to help manage a Core's variables.

You can use Clutter and ClutterGtk or Cairo to render the video, and I hope that the inclusion of a Gl widget in Gtk+ 3.16 will allow to get rid the dependency on Clutter. It currently can also play a Core's audio via PulseAudio, but it may be moved to some "RetroPa" library. Proper joystick support is still to come, certainly in a separate library (RetroJs?). RetroGtk's git repository can be found here: https://github.com/Kekun/retro-gtk

Libretro module collection

Being able to run, control and render Libretro implementations is of no use if you have no such implementation to run, control and render. To help solving this, I started collecting GPL compatible implementation in a git repository, adding a makefile to ease the compiling and installing them. It is still in its infancy but it already helped me quite a lot.

The machines currently emulated by the collection are:

  • Nintendo Entertainment System
  • Super Nintendo Entertainment System
  • Game Boy Advance
  • Saturn 
  • PC Engine
  • DOS

PlayStation support is to come, but an annoying bug in the emulator have to be solved first.

You can find this collection here: https://github.com/Kekun/libretro-free

Applications

Demo

To test all of this, I wrote a demo application, which uses Retro, RetroGtk and the module collection to run games. It allows you to open several game files (see the modules in the collection to know what can be run), to set the Core's options, and it supports inputs such as the keyboard, the mouse, and can use the keyboard as a virtual gamepad. You can set the virtual gamepad's configuration via a button.

Theme Park running in DOSBox
Virtual gamepad configuration when running PC Genjin 2 in Mednafen
Nestopia's options
bSNES running Yoshi's Island, showing the "ungrab the pointer" message

Here is the demo's git repository: https://github.com/Kekun/retro-gtk-demo

GNOME Games

The ultimate goal of this project is to write a video game manager and player for GNOME, with a user interface similar to GNOME Music or GNOME Video. This project is similar to OpenEmu for MacOS X systems.

Commentaires

  1. Great news, congrats! Good to see libretro getting a bit of gtk love, this will surely help me run my favourite games better integrated than I currently do (DosBox - and most emulators - looks a bit alien by default)

    RépondreSupprimer
  2. The libraries just need a little bit of gtk-doc love :)

    RépondreSupprimer
    Réponses
    1. I'll try to add it for the final 0.1 release! Too bad I can't manage to get Valadoc working.

      Supprimer
  3. Nice, maybe you should think about porting these project to autotools, so, for example, they can be easily compiled/run in jhbuild (Ive just added them to gnome-world moduleset but they fail to install as they try to install in a system directory)

    RépondreSupprimer
    Réponses
    1. I spent some time to port the building system from my makefiles to the autotools (via Anjuta, as I don't know how to use the autotools _yet_), here is the result: https://github.com/Kekun/retro-gobject/tree/automake
      I managed to make the autotools build and install most of what is needed, but it still lacks a way to generate documentation (I would love to have C documentation via Gtk-doc and Vala documentation via Valadoc).

      I'm not willing to merge this branch to master and publish the final 0.1 version until I can generate some form of documentation, maybe you could help me to achieve it?

      Supprimer
  4. Réponses
    1. Thanks, at least you now know part of why I didn't work more on the Python app. ;)

      Supprimer

Enregistrer un commentaire

Posts les plus consultés de ce blog

Moving the Blog

I am moving this blog to greener lands: https://fediverse.blog/~/AdrienPlazas . The existing articles will remain here on Blogger, and new articles will land on the fediverse.blog Plume instance.

libhandy 0.0.10

libhandy 0.0.10 just got released, and it comes with a few new adaptive widgets for your GTK app. You can get this new version here . The View Switcher GNOME applications typically use a GtkStackSwitcher to switch between their views. This design works fine on a desktop, but not so well on really narrow devices like mobile phones, so Tobias Bernard designed a more modern and adaptive replacement — now available in libhandy as the HdyViewSwitcher . In many ways, the HdyViewSwitcher functions very similarly to a GtkStackSwitcher : you assign it a GtkStack containing your application's pages, and it will display a row of side-by-side, homogeneously-sized buttons, each representing a page. It differs in that it can display both the title and the icon of your pages, and that the layout of the buttons automatically adapts to a narrower version, depending on the available width. We have also added a view switcher bar, designed to be used at he bottom of the window: HdyView

My Name is Handy, Lib Handy

Libhandy 0.0.7 just got released! I didn't blog about this mobile and adaptive oriented GTK widget library since the release of its 0.0.4 version three months ago , so let's catch up on what has been added since. List Rows A common pattern in GNOME applications is lists , which are typically implemented via GtkListBox . More specific patterns arose, where rows have a title at the start, an optional subtitle below it, actions at the end and an icon or some other widget like a radio button as a prefix. These rows can also be expanded to reveal nested rows or anything else that fits the need. So far every application using these patterns implemented the rows by hand for each and every row. It made using these a bit cumbersome and it led to inconsistencies in sizing, even inside a single application. To make these patterns easier to use, we implemented HdyActionRow , HdyComboRow and HdyExpanderRow . HdyActionRow The action row is a simple and flexible row, it lets