What's new

possible to code an emulator in Lua?

Danny

Programmer | Moderator
Im just wondering if it would be possible to code an emulator in Lua?

Or would it be possible to convert c to lua and port an emulator that way?

And finally, would lua be powerfull enough to handle an emulator? even a basic one like a chip8 emu?
 

gladius

New member
Yes, you can code an emulator in any half decent programming language. The question is whether the language is well suited to the problem or not. Lua would definitely handle a chip8 emu, but if you were trying a complete game system it might not be fast enough.
 

ector

Emulator Developer
lua could probably handle Gameboy without much trouble, it's actually pretty fast. You'd have to change the number representation to integers though, if I remember correctly there's a #define for that (by default, lua does ALL math with double precision floating point numbers, which is not what you want for emulation for many reasons). Also, you'd have to write some well designed wrapper functions in C to allow lua to write to some kind of display, get input etc.
 

Cyberman

Moderator
Moderator
Yet another reply (YAR)

To answer your question yes it is possible.

I've seen LUA used for a ISO image manipulation system so pretty much anything is possible.

You will need to give LUA IO capability to the keyboard and game input devices. In addition to that LUA will need access to the sound and video systems in the API. If you are using window this would be Win API access.
You might be able to use the GDI etc. Essentially you will need to put in direct hooks into the OS in LUA to support such functionality.

For something like a Unix type system things get a bit more interesting. File IO can be used to access many things, audio via "/dev/dsp". PIPEs can be used to access the display. I'm not sure how to advise you in the best route for accessing X resources.


Cyb
 

Top