Coder Social home page Coder Social logo

orsinium-labs / gamgee Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 0.0 226 KB

๐Ÿ‘พ Run WebAssembly (WASM-4) games on small devices (like PyBadge)

License: MIT License

Rust 100.00%
adafruit game-console game-emulators pybadge rust wasm wasm4 webassembly

gamgee's Introduction

๐Ÿ‘พ gamgee

Run WebAssembly (WASM-4) games on small devices.

Gamgee is a WASM-4 games emulator written in Rust and designed to be executed on devices with very little memory and space available. Currently, it supports only Adafruit PyBadge but we plan to add more in the future.

Features:

  • ๐Ÿ’พ Small size. The binary is just about 270 Kb, and it includes wasm interpreter, allocator, graphics library, a custom font, etc.
  • ๐Ÿœ Small memory requirements. The runtime itself needs just a few kilobytes of RAM and the rest is fully available to the running game.
  • ๐Ÿ•น WASM-4 compatible. It can run any WASM-4 game (and there are quite a few) as long as it fits into memory.

photo of pybadge running tetris

๐Ÿ”ง Installation and usage

  1. Install Rust.
  2. Install task.
  3. Connect PyBadge and turn it on.
  4. Press the "reset" button twice on PyBadge to put it into the bootloader mode.
  5. Flash a game onto the device: task flash -- $PWD/watris.wasm. The path must be absolute (hence $PWD).
  6. Press the "reset" button on PyBadge once to refresh the screen.

๐Ÿ™… Limitations

  1. PyBadge screen size is 160x138. WASM-4 games expect 160x160. To fit the image, we skip every 5th line.
  2. WASM-4 games expect 60 FPS but the PyBadge screen is limited to 20 FPS and then there is often just not enough CPU to keep up. The solution is to try calling the update callback as many times as possible but draw only every 5th frame. However, the games can still be slower than they should.
  3. PyBadge screen uses 16 bits per pixel for colors. WASM-4 color palette is defined as 24 bits for each color. We translate the color palette to pybadge colors as close as possible but the colors might look a bit different from (not as vibrant as) what you see on your PC screen.
  4. PyBadge has 192KB of RAM, and a few Kb are needed for the runtime itself. WebAssembly memory is allocated in pages of 64 Kb. So, we can allocate only 2 pages (128 Kb) of memory for the game to use before crashing with OOM. It's enough for most of the games but not all of them.
  5. Unsupported: tone (playing sounds). PyBadge doesn't have a speaker by default. You can attach your own but I don't have one yet. PyBadge has a built-in buzzer but that's not enough for WASM-4 games.
  6. Unsupported: diskw and diskr (persistent storage). The unused flash space can be used to store additional data, and we might use it for these two functions. However, I haven't seen a game yet that would use them. WASM-4 provides game save by dumping the whole game state, so games don't neet to implement their own save system.

๐Ÿ™ Acknowledgments

I want to thank:

And thank you for using the project โ™ฅ๏ธ

gamgee's People

Contributors

orsinium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  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.