summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/frontend/mame/luaengine.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp
index 587e903416e..9e3af7de31a 100644
--- a/src/frontend/mame/luaengine.cpp
+++ b/src/frontend/mame/luaengine.cpp
@@ -2165,19 +2165,31 @@ void lua_engine::initialize()
"refresh", [](screen_device &sdev) { return ATTOSECONDS_TO_HZ(sdev.refresh_attoseconds()); },
"refresh_attoseconds", [](screen_device &sdev) { return sdev.refresh_attoseconds(); },
"snapshot", [this](screen_device &sdev, sol::object filename) -> sol::object {
- emu_file file(machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
- osd_file::error filerr;
- if(filename.is<const char *>())
+ std::string snapstr;
+ bool is_absolute_path = false;
+ if (filename.is<const char *>())
{
- std::string snapstr(filename.as<const char *>());
- strreplace(snapstr, "/", PATH_SEPARATOR);
- strreplace(snapstr, "%g", machine().basename());
- filerr = file.open(snapstr.c_str());
+ // a filename was specified; if it isn't absolute postprocess it
+ snapstr = filename.as<const char *>();
+ is_absolute_path = osd_is_absolute_path(snapstr);
+ if (!is_absolute_path)
+ {
+ strreplace(snapstr, "/", PATH_SEPARATOR);
+ strreplace(snapstr, "%g", machine().basename());
+ }
}
+
+ // open the file
+ emu_file file(is_absolute_path ? "" : machine().options().snapshot_directory(), OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS);
+ osd_file::error filerr;
+ if (!snapstr.empty())
+ filerr = file.open(snapstr);
else
filerr = machine().video().open_next(file, "png");
- if(filerr != osd_file::error::NONE)
+ if (filerr != osd_file::error::NONE)
return sol::make_object(sol(), filerr);
+
+ // and save the snapshot
machine().video().save_snapshot(&sdev, file);
return sol::make_object(sol(), sol::nil);
},
@@ -2398,7 +2410,9 @@ void lua_engine::initialize()
* image:image_type_name() - floppy/cart/cdrom/tape/hdd etc
* image:load()
* image:unload()
+ * image:create()
* image:crc()
+ * image:display()
*
* image.device - get associated device_t
* image.software_parent
@@ -2406,6 +2420,7 @@ void lua_engine::initialize()
* image.is_writeable
* image.is_creatable
* image.is_reset_on_load
+ * image.must_be_loaded
*/
sol().registry().new_usertype<device_image_interface>("image", "new", sol::no_constructor,
@@ -2419,12 +2434,16 @@ void lua_engine::initialize()
"image_type_name", &device_image_interface::image_type_name,
"load", &device_image_interface::load,
"unload", &device_image_interface::unload,
+ "create", [](device_image_interface &di, const std::string &filename) { return di.create(filename); },
"crc", &device_image_interface::crc,
+ "display", [](device_image_interface &di) { return di.call_display(); },
"device", sol::property(static_cast<const device_t &(device_image_interface::*)() const>(&device_image_interface::device)),
"is_readable", sol::property(&device_image_interface::is_readable),
"is_writeable", sol::property(&device_image_interface::is_writeable),
"is_creatable", sol::property(&device_image_interface::is_creatable),
- "is_reset_on_load", sol::property(&device_image_interface::is_reset_on_load));
+ "is_reset_on_load", sol::property(&device_image_interface::is_reset_on_load),
+ "must_be_loaded", sol::property(&device_image_interface::must_be_loaded)
+ );
/* mame_machine_manager library