10-01-2017, 04:23 PM
(This post was last modified: 03-04-2018, 02:42 PM by gocha.
Edit Reason: I stopped updating lua-v1.4.0 branch and I am using master branch instead, so that I updated the URL for repo.
)
I think this topic is more suitable for Developer Discussion, but I'm posting it here since I was unable to create new thread in the developer forum.
Hi. I am a coder who interested in adding TAS capabilities to PCSX2 emulator.
A half year ago, I have implemented the very basic of Lua scripting engine.
https://github.com/gocha/pcsx2/tree/lua-v1.4.0
Edit: See https://github.com/gocha/pcsx2 instead (Mar 4, 2018)
TASVideos / Lua Scripting
http://tasvideos.org/LuaScripting.html
However, my motivation was lost rapidly since I was stuck in a problem.
The problem is thread model between the emulation core and Lua.
TASVideos emulators I know are single-thread, that can be achieved so naturally, but PCSX2 is a multi-thread emulator. Since I am not very familier with PCSX2 and its internal models, I have no idea how I should handle the communication between Lua and the emulation core (or how to integrate the Lua interpreter to the core thread).
Script will run:
I would be happy if someone teaches me an easy and smart idea for this or any hints. Moreover, I will be more happy if someone would code the rest of things. Thank you.
Hi. I am a coder who interested in adding TAS capabilities to PCSX2 emulator.
A half year ago, I have implemented the very basic of Lua scripting engine.
https://github.com/gocha/pcsx2/tree/lua-v1.4.0
Edit: See https://github.com/gocha/pcsx2 instead (Mar 4, 2018)
TASVideos / Lua Scripting
http://tasvideos.org/LuaScripting.html
However, my motivation was lost rapidly since I was stuck in a problem.
The problem is thread model between the emulation core and Lua.
TASVideos emulators I know are single-thread, that can be achieved so naturally, but PCSX2 is a multi-thread emulator. Since I am not very familier with PCSX2 and its internal models, I have no idea how I should handle the communication between Lua and the emulation core (or how to integrate the Lua interpreter to the core thread).
Script will run:
- When UI (or whatever a trigger) requests starting the script, the script will run immediately.
- When a script has registered some callbacks on step #1, they will be called by certain triggers. (e.g. on frame boundary, memory read, etc.)
- Additionally, most of TASVideos emulators have a co-routine style function: emu.frameadvance(). The function will stop the script execution temporary, then emulate the game for only 1 frame, then resume the script after the function call.
I would be happy if someone teaches me an easy and smart idea for this or any hints. Moreover, I will be more happy if someone would code the rest of things. Thank you.