Add Lua 5.1 script engine core

This is for people involved in the developement of Snes9x, or SNES emulators in general.
BUG REPORTS BELONG IN TECH SUPPORT/BUG TRACKING!
Post Reply
User avatar
gocha
Snes9x Yellow Belt
Posts: 64
Joined: Sun Dec 30, 2007 12:14 am
Location: Japan, Nagoya

Add Lua 5.1 script engine core

Post by gocha » Sun Jan 16, 2011 2:34 am

Diff for versioned files
http://pastebin.com/xiwJmC18

New source files and libs
http://gocha.is.land.to/down/private/sn ... s-libs.zip

Oops, I forgot to add drag and drop support for Lua. Here it is.
http://pastebin.com/7ZbjRNdU

Few of Notes

- Windows Lua library should not be linked statically, because of external modules. So that, Snes9x delayloads lua51.dll
BearOso wrote:As for the Lua support, you're not going to get that into mainline Snes9x unless there's a way to disable it at compile-time. Not all ports can or want to use Lua.
I decided to use HAVE_LUA symbol for that.
I think this update won't break non-win builds. If it does, disable unnecessary codes by using #ifdef HAVE_LUA, please.


P.S: Is there any IRC channel for snes9x development, or something like that?
Last edited by gocha on Sun Jan 30, 2011 1:28 pm, edited 1 time in total.

User avatar
Camo_Yoshi
Snes9x Purple belt
Posts: 922
Joined: Thu Nov 08, 2007 7:59 pm
Location: /dev/null

Post by Camo_Yoshi » Sun Jan 16, 2011 3:29 am

AFAIK, there isn't any IRC dev channel, or any IRC channel for snes9x.

We generally try to stick to the forums. :)

All of you modifications to Snes9x are absolutely amazing, gocha. Thank you for devoting a lot of your time and effort to this.
Snes9x FAQs | Forum Rules
What operating system are you using? 32 or 64bit? Version of Snes9x? Is the text at the bottom of the window white when you load the game?
These suggestions are usually the solution to your issue!

User avatar
zones
Official Mac OSX Porter/Dev
Posts: 908
Joined: Sat May 15, 2004 11:58 pm
Location: Japan

Post by zones » Sun Jan 16, 2011 3:52 am

What's the purpose for adding Lua script?
Why "only for windows version?"
And... How is it worth for the average users' good experiences of snes and snes9x?

User avatar
gocha
Snes9x Yellow Belt
Posts: 64
Joined: Sun Dec 30, 2007 12:14 am
Location: Japan, Nagoya

Post by gocha » Sun Jan 16, 2011 4:32 am

zones wrote:Why "only for windows version?"
Because, I use/maintain only windows version, and there are unfortunately no dev members who are interested in Lua.
If you want to run Lua on your platform, pass your script to RunLuaScriptFile() in lua-engine.cpp.
(DeHackEd's first snes9x-lua seems to run fine on both windows and linux, though I have never tried that)
zones wrote:What's the purpose for adding Lua script?
And... How is it worth for the average users' good experiences of snes and snes9x?
Lua scripting is an extremely useful tool when TASing. Although some programming knowledge is required, the user has power over things like game screen display, inputs, and memory. The following are some common applications, though the possibilities are endless.
  • Displaying helpful information on screen.
  • Eliminating tedious repetition.
  • Creating specific circumstances for testing.
  • Brute forcing a solution.
http://tasvideos.org/LuaScripting.html
List of functions example http://gocha.s1.zmx.jp/down/public/gens-lua.html

As mentioned above, it is useful for TASing, ROMhacking (analyzing), advanced-cheating, etc.
Some programming knowledge is required to make a new script. However, if author releases his own script, users can use such existing script just by loading it. Can't that be a good point for average users, huh?

I can introduce some fun/useful use of EmuLua, have fun :)
http://youtu.be/n7sokdDVn10
http://youtu.be/1XNTjVScm_8
http://youtu.be/-jbFjhBYCjg
http://youtu.be/cv4c6Gg8_Q8
http://youtu.be/LT1eiLiMWkk
(no particular order)

Is there any special reason not to have Lua feature for normal release?

????????????????????????????????????????????????????PM??????????????????????????OK?????????????

User avatar
zones
Official Mac OSX Porter/Dev
Posts: 908
Joined: Sat May 15, 2004 11:58 pm
Location: Japan

Post by zones » Mon Jan 17, 2011 2:04 pm

Thanks to explain what Lua script is and how it can be used on emulators.

In my opinion it's better to leave it in your fork.
????????????????????????

User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso » Mon Jan 17, 2011 7:46 pm

zones wrote:In my opinion it's better to leave it in your fork.
I'm of the same opinion. If there were a larger community developing lua scripts I might be more inclined. However, it looks like only a small few are doing anything with it, and it really would only be a gimmick for anyone else.

I don't think we could accept this anyways because:
* It looks like most of lua-engine.cpp is borrowed from the GPL gens-rr. We can't include GPL code.
* It desperately needs to be cleaned up. It's bad enough that there's stale code all over Snes9x--I don't think it's a good idea to add any more to it.
* Binary libraries and Lua headers. I assume you're just including those for convenience, but in case not: we can't put these into the source tree.

User avatar
gocha
Snes9x Yellow Belt
Posts: 64
Joined: Sun Dec 30, 2007 12:14 am
Location: Japan, Nagoya

Post by gocha » Tue Jan 18, 2011 4:00 am

Hmm, first of all, thank you for speaking your opinions. I can understand them.

Although Lua is useful for various things, it currently is used only by small few people. Also, you, developers probably want to prevent making project larger because of such a minor extra codes.

Still, I do not want to make a customized version of Snes9x because of those functions, since it will make merging the official update harder. (situation is much better than before, since I can access snes9xgit nowadays, though)

Also, having many branches is probably inconvenient for users. They probably don't mind having minor features unless it makes normal use harder or slower very much. I know some of "it have had several branches, but they has been merged into one project after all" examples. FCEUX VBA-M
BearOso wrote:* It looks like most of lua-engine.cpp is borrowed from the GPL gens-rr. We can't include GPL code.
The hardest problem to me. If it can be included with author's special permission, I can ask about this in TASVideos forum or #tasemu freenode.
BearOso wrote:* It desperately needs to be cleaned up. It's bad enough that there's stale code all over Snes9x--I don't think it's a good idea to add any more to it.
Yeah, I planned to do additional implementation and cleanups little by little, after this "core" commit has been done. To me, it is too large to finish the whole work at once.
BearOso wrote:* Binary libraries and Lua headers. I assume you're just including those for convenience
You're right.

Anyway, I probably will work on other improvements/fixes for the time being.
Thanks.

P.S. I have never known of git's "fork" feature. (I'm new at distributed revision control) I may create a new "rerecording" branch at snes9xgit later, if possible.

??????????????????

badinsults
Snes9x White Belt
Posts: 29
Joined: Sat Jan 16, 2010 10:09 am

Post by badinsults » Tue Jan 18, 2011 8:09 am

I've created a #snes9x channel on Freenode, if you want to use that as a dev channel. Same network as the zsnes development channel. With the blessing of the devs, we could make it an official channel.

User avatar
Camo_Yoshi
Snes9x Purple belt
Posts: 922
Joined: Thu Nov 08, 2007 7:59 pm
Location: /dev/null

Post by Camo_Yoshi » Tue Jan 18, 2011 6:34 pm

Hey gocha, I'm also willing to host your diff files on my website mirrors:

My Dropbox Account
http://camoyoshi.1.vg/ (ad supported)
http://camoyoshi.antiblog.com/ (My website)

Just send me a PM if you're interested. :wink:
Snes9x FAQs | Forum Rules
What operating system are you using? 32 or 64bit? Version of Snes9x? Is the text at the bottom of the window white when you load the game?
These suggestions are usually the solution to your issue!

Post Reply