SONY LUASONY LUAGDCGDC
9 March 20109 March 2010
RJ MicalRJ Mical
OverviewOverview
Lua on the PS3Lua on the PS3
SLEDSLED
Sony use of LuaSony use of Lua
Lua on the PS3Lua on the PS3
Available for the PPU and the SPUAvailable for the PPU and the SPU Several versions available, including 5.1.4Several versions available, including 5.1.4
SLED for editingSLED for editing
SPU LuaSPU Lua
Full Lua implementation, except:Full Lua implementation, except: No parser, code must be precompiledNo parser, code must be precompiled Not much space so only limited usefulnessNot much space so only limited usefulness
70K memory for Lua objects70K memory for Lua objects
Not able to call Lua from CNot able to call Lua from C Though you can share data, call C functions on the Though you can share data, call C functions on the
PPU, signal and synchronize with your C app on PPU, signal and synchronize with your C app on the PPUthe PPU
SPU Lua Details - 1SPU Lua Details - 1
Interface provided to allow shared data to Interface provided to allow shared data to be passed to SPU Lua from the PPUbe passed to SPU Lua from the PPU You have to use struct.unpack before using You have to use struct.unpack before using
the datathe data
Programs must be precompiled oflinePrograms must be precompiled ofline
lua_number is a single-precision floatlua_number is a single-precision float
Memory is a premium, so do garbage Memory is a premium, so do garbage collection often!collection often!
SPU Lua Details - 2SPU Lua Details - 2
It’s possible to call C++ functions from It’s possible to call C++ functions from SPU Lua codeSPU Lua code Register the PPU functions when initializing Register the PPU functions when initializing
the Lua task managerthe Lua task manager In Lua, define a wrapper function that packs In Lua, define a wrapper function that packs
the data, sends it to the PPU function, and the data, sends it to the PPU function, and unpacks the resultsunpacks the results
Synchronization between PPU tasks and Synchronization between PPU tasks and SPU Lua is accomplished with signalsSPU Lua is accomplished with signals
SLEDSLED
Excellent editor (any script language, not just Excellent editor (any script language, not just Lua)Lua)
Full IDE for script editing and debuggingFull IDE for script editing and debugging Syntax highlightingSyntax highlighting BreakpointsBreakpoints Callstack and variable watch listCallstack and variable watch list Edit and continueEdit and continue
libsleddebugger on the PPUlibsleddebugger on the PPU Uses TCP/IP to communicate with the debuggerUses TCP/IP to communicate with the debugger
Lua plug-in supports compilation tooLua plug-in supports compilation too
Sony Use of LuaSony Use of Lua
Lua available for the PS3 and the PSPLua available for the PS3 and the PSP
There are a number of apps that use Lua:There are a number of apps that use Lua: HomeHome PhyreEnginePhyreEngine BuzzBuzz State MachineState Machine