lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi All,

gw-libretro [1] is a libretro [2] core that simulates Game & Watch [3] and similar consoles. It is known to run on Windows, Mac OSX, Linux, and Android, but chances are that it runs on all platforms supported by RetroArch, the official libretro frontend.

gw-libretro is written in C and embeds Lua. C is used to implement the libretro API and to write some native functions exported to Lua, and Lua is the language used to write the actual simulators. There are almost 50 simulators available to play [4], all of them translated from Delphi source code kindly provided by MADrigal [5].

pas2lua [6] was used to convert Pascal source code to Lua. It is very hackish and has some notable flaws (i.e. doesn't support the "with" keyword), but does the hard job. The Lua code it generates needs a Delphi compatibility layer which is included in gw-libretro. This layer implements, part in C and part in Lua, the very minimum necessary to allow the simulators to run. pas2lua is partly written in Lua, and my intention is to rewrite it entirely in Lua.

The simulators' Lua code is obfuscated with bstree [7], a Lua utility that creates a Huffman tree from a set of files and generates a Lua obfuscator, a Lua deobfuscation, and a C header file to be used with bsreader.c to implement a C deobfuscation. bstree uses Penlight's [8] Lua lexer. I'm not sure if compression can be considered a kind of obfuscation.

Cheers,

Andre

[1] https://github.com/libretro/gw-libretro
[2] http://www.libretro.com/
[3] https://en.wikipedia.org/wiki/Game_%26_Watch
[4] http://bot.libretro.com/assets/cores/gw/
[5] http://www.madrigaldesign.it/sim/
[6] https://github.com/leiradel/pas2lua
[7] https://github.com/leiradel/bstree
[8] https://github.com/stevedonovan/Penlight