gw-libretro/gwlua
Vladimir Serbinenko 0505a20683 Remove snprintf
2022-04-08 11:40:09 +02:00
..
lua Commit updated system.h 2017-12-10 15:18:24 +00:00
png Many fixes for the 1.3 release, please see the changelog 2017-11-29 21:38:08 +00:00
bsreader.c Remove declaration-after-statement 2022-04-08 11:39:03 +02:00
bsreader.h decode .bs files 2015-04-13 19:34:27 -03:00
bstree.h use new obfuscator 2015-04-19 14:23:23 -03:00
entries.c Release 1.6.0, added support for mouse and touch screens 2017-12-10 11:12:48 +00:00
entries.gperf Release 1.6.0, added support for mouse and touch screens 2017-12-10 11:12:48 +00:00
functions.c Remove snprintf 2022-04-08 11:40:09 +02:00
gwlua.c Remove declaration-after-statement 2022-04-08 11:39:03 +02:00
gwlua.h Fixed wrong layer for the first sprite 2018-04-15 18:29:22 +01:00
image.c Remove declaration-after-statement 2022-04-08 11:39:03 +02:00
LICENSE copy gwrom and gwlua source instead of using submodules 2015-03-03 16:41:37 -03:00
picture.h changed pictures to use rle 2015-04-21 10:58:07 -03:00
README.md copy gwrom and gwlua source instead of using submodules 2015-03-03 16:41:37 -03:00
ref.c version 2 2015-03-29 23:01:51 -03:00
sound.c Many fixes for the 1.3 release, please see the changelog 2017-11-29 21:38:08 +00:00
stb_image.h version 2 2015-03-29 23:01:51 -03:00
timer.c setting interval to 0 disables the timer 2015-05-25 10:21:58 -03:00

gwlua

A middleware to write Game & Watch-like games in Lua. Provides pictures, sprites, timers and sounds.

gwlua is a middleware, meaning it knows nothing about how sound is actually played and sprites blitted onto the screen. You have to provide functions to do that according to the platform you're targetting.

For an working example of gwlua, see gw-libretro.

Usage

Add gwlua.c and gwlua.h to your project. See gwlua.h for some documentation.

Rationale

When I started porting MADrigal's Game & Watch simulators to libretro, I had to make a decision on how to take advantage of the existing simulators' source code. The simulators are written in Delphi, so I could:

  1. Try to compile the original source code with Free Pascal: This would turn each simulator into its own libretro core, instead of a content able to be played by a core. In addition, I'd have to provide functions to make the Delphi compiled work, like Application and Form classes.
  2. Try to compile the original source code with Free Pascal to some machine code (I was thinking about MIPS) and add a CPU emulator to the libretro core: This would let me package each game into a content, but I'd have to bootstrap high level stuff as machine code, i.e. picture loading and blitting.
  3. Rewrite the original source code in another language: This would free me from Free Pascal, but would mean each simulator is a separate core just like the first option.

So I decided to go with an option that I believe has the best mix: rewrite the Pascal code in Lua, and package the Lua source code along with assets into a libretro content. The libretro core would then be able to read the archive and run the Lua code, which in turn can easily call native functions to deal with IO etc.

Why Lua

I have experience with both the language and on embedding it in C/C++ programs, and it's syntax is similar to that of Pascal. In fact, I wrote a translator that takes Pascal source code and generates Lua source code. The translator is far from perfect, but it does the hard work, leaving me to just tweak a few lines.