Giter VIP home page Giter VIP logo

nikouu / mgba-http Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 0.0 2.96 MB

An HTTP interface for mGBA scripting. Connect to mGBA with your favourite language using an HTTP REST API! Easily create your own cross platform "Twitch Plays", Gameboy playing bot, or more.

License: MIT License

C# 74.76% Lua 22.22% PowerShell 3.01% Smalltalk 0.01%
api api-rest csharp dotnet lua mgba mgba-api twitch-plays twitch-plays-pokemon gameboy

mgba-http's Introduction

mGBA-http

An HTTP interface for mGBA scripting. As long as you make HTTP requests, you'll be able to interact with mGBA.

⭐ I've written about this on my blog! 📝

Features

  • Interact with mGBA with any language that supports HTTP
  • Full Swagger API documentation (swagger.json and SwaggerUI) for fast prototyping and integration
  • Maps 1 to 1 with most of the mGBA scripting API
  • Custom button APIs for easy button interaction
  • Cross platform
  • Easy to setup

This project is great if you want to:

  • Create a "Twitch Plays"
  • Write an AI bot in your preferred programming language
  • Create an information dashboard for the current game (e.g. show your current Pokémon's stats like Pokélink)
  • Edit the memory of the running game

Example

In the example below, we accept inputs from one program and send them to mGBA:

  • (top left) is accepting key inputs from keyboard and sending them to mGBA-http
  • (top right) mGBA-http is forwarding these to mGBA
  • (bottom left) mGBA's built-in scripting API accepting the requests from mGBA-http
  • (bottom right) then the key inputs are read by the ROM

If you want to see more real examples with videos, code, and explanations, check out the examples page.

There are also C# examples I use for testing in the testing folder.

example1-pokemonyellowmovement2.mp4

Quick Start Guide

mGBA-http works with 0.10.2 of mGBA (and probably later version too).

  1. Ensure you have mGBA
  2. Download mGBA-http and mGBASocketServer.lua from the Releases section
  3. Run mGBA-http
  4. In mGBA, go to Tools > Scripting, then File > Load script and load in mGBASocketServer.lua

Once a ROM is loaded, you are now ready to start using mGBA-http.

For a more in-depth guide with pictures, see the Full Guide.

Limitations

  • No frame perfect calls. There is network latency between your application to mGBA-http and again latency between mGBA-http and mGBA. This will not be accurate for frame perfect manipulation and is meant for more general usage such as for "Twitch plays", AI playing bot, or other non frame specific application. For high accuracy manipulation see Bizhawk which is used for TASBots.
  • Not all scripting calls are implemented. See ImplementedApis.md for the list of what is implemented.
  • The OSX and Linux binaries are experimental.

Why?

This project came about because I didn't know lua and wanted to use C# control emulated Pokémon games in a cross platform way. I was there for and loved Twitch Plays Pokémon and looking around, most GitHub projects for "X plays" style emulator controllers use the Windows SendKey API (or similar abstraction) regardless of language.

When investigating how Ironmon-Tracker worked after seeing it on Arex's stream, I noticed mGBA has a scripting API and more specifically a socket API which I could interact with via C# and it went from there[1][2].

mGBA-http builds on the mGBA socket API abstraction and adds an HTTP layer to simplify interaction and development - which is exactly what I want for future projects.

Future projects such as the proof of concept: CPU Plays Pokemon

Contributing

If you know Lua, GameBoy/Advance, or mGBA specifics, I'd love for help.

Development

If you're a .NET developer, the setup simple and familiar opening the solution file. I use Visual Studio (At least VS 17.9) and the latest .NET. However, if you choose to develop C# without Visual Studio, that's fine too.

If you're not a .NET developer, check out the comprehensive C# learning website from Microsoft. You can program in C# on whatever platform whether it's Windows, Mac, or Linux.

In terms of the .NET work, the project uses ASP.NET Core minimal API.

Design Document

The rough design philosphy is outlined in the design document. Please understand and follow this when considering a contribution.

Build

The PowerShell release script ReleaseBuild.ps1 creates the final binaries. PowerShell is cross platform and can be downloaded via the PowerShell download documentation.

The script generates binaries closely aligned with the operating systems and architectures that mGBA provides downloads for.

Cross Platform

To reduce the barrier of entry, mGBA-http also has self-contained builds. These are the larger binaries with "self-contained" in the filename and bring the entirity of .NET needed to run the executable - meaning the user does not need to download the .NET runtime to use mGBA-http.

Contact

If there's a problem feel free to start an issue, otherwise see my about page on how to contact me.

Acknowledgments

References.md has useful links during development.

This project is not associated to the development or development team of mGBA. I'm just a fan ✌

Links

License

MIT

If you end up using mGBA-http, drop me a message and tell me what you're up to!

mgba-http's People

Contributors

nikouu avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.