@@ -253,10 +253,6 @@ void LuaContext::SetupContext(sol::state &lua) {
253253 lua.set_function (" bitcast_s32_to_float" , &bitcast_s32_to_float);
254254 lua.set_function (" bitcast_float_to_s32" , &bitcast_float_to_s32);
255255
256- // System control (TODO: Should this be privileged to certain types of script?)
257- lua.set_function (" stop" , &stop);
258- lua.set_function (" reset" , &reset);
259-
260256 // MIPS instruction utilities
261257 lua.set_function (" asm" , [this ](int destAddress, const char *code) -> void {
262258 if (!Memory::IsValid4AlignedAddress (destAddress)) {
@@ -277,9 +273,11 @@ void LuaContext::SetupContext(sol::state &lua) {
277273 lua.set_function (" sys_call" , &sys_call);
278274
279275 // Memory tools
276+ sol::table mem = lua.create_table ();
277+ lua[" mem" ] = mem;
280278
281279 // After modifying code, this needs to be used.
282- lua .set_function (" invalidate_cache" , [this ](int start, int size) -> void {
280+ mem .set_function (" invalidate_cache" , [this ](int start, int size) -> void {
283281 if (!Memory::IsValidRange (start, size)) {
284282 PrintF (LogLineType::Error, " invalidate_cache: bad range %08x + %08x" , start, size);
285283 return ;
@@ -292,34 +290,23 @@ void LuaContext::SetupContext(sol::state &lua) {
292290 }
293291 });
294292
295- lua .set_function (" memcpy " , [this ](int dest, int src, int size) -> void {
293+ mem .set_function (" copy " , [this ](int dest, int src, int size) -> void {
296294 if (!Memory::IsValidRange (dest, size) || !Memory::IsValidRange (src, size)) {
297295 PrintF (LogLineType::Error, " memcpy: bad range dest %08x + %08x or src %08x + %08x" , dest, size, src, size);
298296 return ;
299297 }
300298 Memory::MemcpyUnchecked (dest, src, size);
301299 });
302300
303- lua .set_function (" memset " , [this ](int dest, int byte, int size) -> void {
301+ mem .set_function (" set " , [this ](int dest, int byte, int size) -> void {
304302 if (!Memory::IsValidRange (dest, size)) {
305303 PrintF (LogLineType::Error, " memset(%d): bad range dest %08x + %08x" , (u8 )byte, dest, size);
306304 return ;
307305 }
308306 Memory::MemsetUnchecked (dest, byte, size);
309307 });
310-
311- // UI interactions
312- lua.set_function (" notify_info" , [](const char *str, const char *id) {
313- g_OSD.Show (OSDType::MESSAGE_INFO , str, 0 .0f , strlen (id) == 0 ? nullptr : id);
314- });
315- lua.set_function (" notify_warn" , [](const char *str, const char *id) {
316- g_OSD.Show (OSDType::MESSAGE_WARNING , str, 0 .0f , strlen (id) == 0 ? nullptr : id);
317- });
318- lua.set_function (" notify_error" , [](const char *str, const char *id) {
319- g_OSD.Show (OSDType::MESSAGE_ERROR , str, 0 .0f , strlen (id) == 0 ? nullptr : id);
320- });
321- lua.set_function (" notify_success" , [](const char *str, const char *id) {
322- g_OSD.Show (OSDType::MESSAGE_SUCCESS , str, 0 .0f , strlen (id) == 0 ? nullptr : id);
308+ mem.set_function (" is_valid" , [this ](int address) -> bool {
309+ return Memory::IsValidAddress (address);
323310 });
324311
325312 // Missing functions after studying Thirteen's plugins
@@ -336,11 +323,29 @@ void LuaContext::SetupContext(sol::state &lua) {
336323 // We don't properly support the "Pause" code type, I don't think?
337324 // Icache invalidation will not be automatic, unlike in cwcheats.
338325
339- // Initialize useful constants.
326+ // Game information constants.
340327 lua[" game" ] = lua.create_table_with (
341- " ID" , g_paramSFO.GetDiscID ()
328+ " ID" , g_paramSFO.GetDiscID (),
329+ " TITLE" , g_paramSFO.GetValueString (" TITLE" )
342330 );
343331
332+ // Emulator control
333+ //
334+ // TODO: Add a numeric version number that's easy to check for.
335+ sol::table emu = lua.create_table_with (
336+ " VERSION" , PPSSPP_GIT_VERSION ,
337+ " stop" , &stop,
338+ " reset" , &reset
339+ );
340+ lua[" emu" ] = emu;
341+ // UI interactions
342+ emu.set_function (" notify" , [](const char *str) {
343+ g_OSD.Show (OSDType::MESSAGE_INFO , str, 0 .0f , nullptr );
344+ });
345+ emu.set_function (" warn" , [](const char *str) {
346+ g_OSD.Show (OSDType::MESSAGE_WARNING , str, 0 .0f , nullptr );
347+ });
348+
344349 lua[" btn" ] = lua.create_table_with (
345350 " SELECT" , 0x00000001 ,
346351 " START" , 0x00000008 ,
0 commit comments