Code Monkey home page Code Monkey logo

libretro-rs's Introduction

libretro-rs

Design Philosophy

The approach to this crate can best be summarized as wanting to expose all functionality, even if not idiomatically. The libretro API has quite a bit of functionality, and implementing all of that up front would just cause delays. Instead, all of the raw API is made available to you. If you run into something that isn't explicitly supported, you can always use the raw API.

Another design note is to try and include data that would be available to a C implementation. For example, emulators cannot reasonably be expected to be constructed without parameters (à la Default). Therefore, there is a RetroCore::init function that can acccess the RetroEnvironment, so things like asset paths can be used to construct the emulator. With that in mind, care will be taken to hide API functionality where it isn't allowed.

After the above requirements are met, the last goal is to make the bindings logical and ergonomic. If you're feeling pain anywhere in the API then definitely let us know!

Getting started

A reference implementation is available in the example folder, and should be enough to get you started. At a high level, you need to modify your Cargo.toml:

[dependencies]
libretro-rs = "0.1"

[lib]
crate-type = ["cdylib"]

Then implement a trait and call a macro:

use libretro_rs::*;

struct Emulator {
  // ...
}

impl RetroCore for Emulator {
  // ...
}

libretro_core!(Emulator);

et voilà! Running cargo build will produce a shared library (.so, .dll, etc) that you can use with a libretro front-end:

$ retroarch --verbose -L libemulator.so /path/to/game.rom

Example

The example folder contains a working CHIP-8 emulator. You can run it using this command:

$ cargo build -p example
$ retroarch --verbose -L ./target/debug/libexample.so <game path>

Replace .so with .dll if running on Windows.

libretro-rs's People

Contributors

inquisitivecoder avatar im-apbecker avatar goncalopascoal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.