From 379e69cfbb82c5cd0f039707d383e748e5fd6dfc Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Fri, 4 Dec 2020 23:43:40 +1100 Subject: -luaengine.cpp: Expose device_t interface on screen_device and cassette_image_device, and some cleanup. -pockchalv2.xml: A couple of Romaji corrections. --- hash/pockchalv2.xml | 8 ++--- src/frontend/mame/luaengine.cpp | 74 ++++++++++++++++++++++------------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/hash/pockchalv2.xml b/hash/pockchalv2.xml index f81d6a31a3a..c10ab7951ab 100644 --- a/hash/pockchalv2.xml +++ b/hash/pockchalv2.xml @@ -106,7 +106,7 @@ The Pocket Challenge V2 appears to be compatible with the Wonderswan from a soft - Shinkenzemi Chuugaku Kouza - Chuugaku Rika (1 Bunya) (2 Bunya) (2PL) + Shinkenzemi Chuugaku Kouza - Chuugaku Rika (1-bun'ya) (2-bun'ya) (2PL) 2002 Benesse Corporation @@ -122,7 +122,7 @@ The Pocket Challenge V2 appears to be compatible with the Wonderswan from a soft - Shinkenzemi Chuugaku Kouza - Chuugaku Rika (1 Bunya) (2 Bunya) (6PL) + Shinkenzemi Chuugaku Kouza - Chuugaku Rika (1-bun'ya) (2-bun'ya) (6PL) 2006 Benesse Corporation @@ -176,7 +176,7 @@ The Pocket Challenge V2 appears to be compatible with the Wonderswan from a soft - Shinkenzemi Chuugaku Kouza - Chuu1 Kokugo-Hyakunin Isshu (2JA) + Shinkenzemi Chuugaku Kouza - Chuuichi Kokugo-Hyakunin Isshu (2JA) 2002 Benesse Corporation @@ -192,7 +192,7 @@ The Pocket Challenge V2 appears to be compatible with the Wonderswan from a soft - Shinkenzemi Chuugaku Kouza - Chuu1 Suugaku (2M1) + Shinkenzemi Chuugaku Kouza - Chuu 1 Suugaku (2M1) 2002 Benesse Corporation diff --git a/src/frontend/mame/luaengine.cpp b/src/frontend/mame/luaengine.cpp index d0fdcedab88..6ff6dc0709c 100644 --- a/src/frontend/mame/luaengine.cpp +++ b/src/frontend/mame/luaengine.cpp @@ -538,6 +538,7 @@ void lua_engine::initialize() { "end", SEEK_END } }; + /* emu library * * emu.app_name() - return application name @@ -978,7 +979,8 @@ void lua_engine::initialize() return table; })); -/* emu_options library + +/* emu_options library * * manager:options() * manager:machine():options() @@ -987,34 +989,37 @@ void lua_engine::initialize() */ auto emu_options_type = sol().registry().new_usertype("emu_options", sol::no_constructor, sol::base_classes, sol::bases()); - emu_options_type.set("slot_option", [](emu_options &opts, const std::string &name) { return opts.find_slot_option(name); }); + emu_options_type["slot_option"] = [] (emu_options &opts, std::string const &name) { return opts.find_slot_option(name); }; -/* slot_option library +/* slot_option library * * manager:options():slot_option("name") * manager:machine():options():slot_option("name") * + * slot_option:specify(card, bios) - specifies the value of the slot, potentially causing a recalculation + * * slot_option.value - the actual value of the option, after being interpreted * slot_option.specified_value - the value of the option, as specified from outside * slot_option.bios - the bios, if any, associated with the slot * slot_option.default_card_software - the software list item that is associated with this option, by default - * slot_option:specify() - specifies the value of the slot, potentially causing a recalculation */ auto slot_option_type = sol().registry().new_usertype("slot_option", sol::no_constructor); + slot_option_type["specify"] = + [] (slot_option &opt, std::string &&text, char const *bios) + { + opt.specify(std::move(text)); + if (bios) + opt.set_bios(bios); + }; slot_option_type["value"] = sol::property(&slot_option::value); slot_option_type["specified_value"] = sol::property(&slot_option::specified_value); slot_option_type["bios"] = sol::property(&slot_option::bios); slot_option_type["default_card_software"] = sol::property(&slot_option::default_card_software); - slot_option_type.set("specify", [](slot_option &opt, std::string &&text, const char *bios) { - opt.specify(std::move(text)); - if (bios) - opt.set_bios(bios); - }); -/* core_options::entry library +/* core_options::entry library * * options.entries[entry_name] * @@ -1075,7 +1080,7 @@ void lua_engine::initialize() core_options_entry_type.set("has_range", &core_options::entry::has_range); -/* running_machine library +/* running_machine library * * manager:machine() * @@ -1511,9 +1516,6 @@ void lua_engine::initialize() * screen:snapshot([opt] filename) - save snap shot * screen:type() - screen drawing type * screen:frame_number() - screen frame count - * screen:name() - screen device full name - * screen:shortname() - screen device short name - * screen:tag() - screen device tag * screen:xscale() - screen x scale factor * screen:yscale() - screen y scale factor * screen:pixel(x, y) - get pixel at (x, y) as packed RGB in a u32 @@ -1521,7 +1523,10 @@ void lua_engine::initialize() * screen:time_until_pos(vpos, hpos) - get the time until this screen pos is reached */ - auto screen_dev_type = sol().registry().new_usertype("screen_dev", "new", sol::no_constructor); + auto screen_dev_type = sol().registry().new_usertype( + "screen_dev", + sol::no_constructor, + sol::base_classes, sol::bases()); screen_dev_type.set("draw_box", [](screen_device &sdev, float x1, float y1, float x2, float y2, uint32_t bgcolor, uint32_t fgcolor) { int sc_width = sdev.visible_area().width(); int sc_height = sdev.visible_area().height(); @@ -1631,9 +1636,6 @@ void lua_engine::initialize() return "unknown"; }); screen_dev_type.set("frame_number", &screen_device::frame_number); - screen_dev_type.set("name", &screen_device::name); - screen_dev_type.set("shortname", &screen_device::shortname); - screen_dev_type.set("tag", &screen_device::tag); screen_dev_type.set("xscale", &screen_device::xscale); screen_dev_type.set("yscale", &screen_device::yscale); screen_dev_type.set("pixel", [](screen_device &sdev, float x, float y) { return sdev.pixel((s32)x, (s32)y); }); @@ -1714,7 +1716,7 @@ void lua_engine::initialize() dev_state_type.set("is_divider", &device_state_entry::divider); -/* rom_entry library +/* rom_entry library * * manager:machine().devices[device_tag].roms[rom] * @@ -1733,7 +1735,7 @@ void lua_engine::initialize() rom_entry_type.set("flags", &rom_entry::get_flags); -/* output_manager library +/* output_manager library * * manager:machine():outputs() * @@ -1758,7 +1760,7 @@ void lua_engine::initialize() output_type.set("id_to_name", &output_manager::id_to_name); -/* device_image_interface library +/* device_image_interface library * * manager:machine().images[image_type] * @@ -1814,7 +1816,8 @@ void lua_engine::initialize() image_type.set("is_reset_on_load", sol::property(&device_image_interface::is_reset_on_load)); image_type.set("must_be_loaded", sol::property(&device_image_interface::must_be_loaded)); -/* device_slot_interface library + +/* device_slot_interface library * * manager:machine().slots[slot_name] * @@ -1824,14 +1827,14 @@ void lua_engine::initialize() * slot.options[] - get options table (k=name, v=device_slot_interface::slot_option) */ - auto slot_type = sol().registry().new_usertype("slot", "new", sol::no_constructor); + auto slot_type = sol().registry().new_usertype("slot", sol::no_constructor); slot_type["fixed"] = sol::property(&device_slot_interface::fixed); slot_type["has_selectable_options"] = sol::property(&device_slot_interface::has_selectable_options); slot_type["default_option"] = sol::property(&device_slot_interface::default_option); - slot_type["options"] = sol::property([](const device_slot_interface &slot) { return standard_tag_object_ptr_map(slot.option_list()); }); + slot_type["options"] = sol::property([] (device_slot_interface const &slot) { return standard_tag_object_ptr_map(slot.option_list()); }); -/* device_slot_interface::slot_option library +/* device_slot_interface::slot_option library * * manager:machine().slots[slot_name].options[option_name] * @@ -1840,15 +1843,15 @@ void lua_engine::initialize() * slot_option.clock - the clock speed associated with this option */ - auto dislot_option_type = sol().registry().new_usertype("dislot_option", "new", sol::no_constructor); + auto dislot_option_type = sol().registry().new_usertype("dislot_option", sol::no_constructor); dislot_option_type["selectable"] = sol::property(&device_slot_interface::slot_option::selectable); - dislot_option_type["default_bios"] = sol::property(static_cast(&device_slot_interface::slot_option::default_bios)); - dislot_option_type["clock"] = sol::property(static_cast(&device_slot_interface::slot_option::clock)); + dislot_option_type["default_bios"] = sol::property(static_cast(&device_slot_interface::slot_option::default_bios)); + dislot_option_type["clock"] = sol::property(static_cast(&device_slot_interface::slot_option::clock)); -/* cassette_image_device +/* cassette_image_device library * - * device.cassette + * manager:machine().cassettes[cass_name] * * cass:play() * cass:stop() @@ -1867,10 +1870,16 @@ void lua_engine::initialize() * cass.image - get the device_image_interface for this cassette device */ - auto cass_type = sol().registry().new_usertype("cassette", sol::no_constructor); + auto cass_type = sol().registry().new_usertype( + "cassette", + sol::no_constructor, + sol::base_classes, sol::bases()); cass_type["stop"] = [] (cassette_image_device &c) { c.change_state(CASSETTE_STOPPED, CASSETTE_MASK_UISTATE); }; cass_type["play"] = [] (cassette_image_device &c) { c.change_state(CASSETTE_PLAY, CASSETTE_MASK_UISTATE); }; cass_type["record"] = [] (cassette_image_device &c) { c.change_state(CASSETTE_RECORD, CASSETTE_MASK_UISTATE); }; + cass_type["forward"] = &cassette_image_device::go_forward; + cass_type["reverse"] = &cassette_image_device::go_reverse; + cass_type["seek"] = [] (cassette_image_device &c, double time, const char* origin) { if (c.exists()) c.seek(time, s_seek_parser(origin)); }; cass_type["is_stopped"] = sol::property(&cassette_image_device::is_stopped); cass_type["is_playing"] = sol::property(&cassette_image_device::is_playing); cass_type["is_recording"] = sol::property(&cassette_image_device::is_recording); @@ -1878,9 +1887,6 @@ void lua_engine::initialize() cass_type["speaker_state"] = sol::property(&cassette_image_device::speaker_on, &cassette_image_device::set_speaker); cass_type["position"] = sol::property(&cassette_image_device::get_position); cass_type["length"] = sol::property([] (cassette_image_device &c) { if (c.exists()) return c.get_length(); return 0.0; }); - cass_type["forward"] = &cassette_image_device::go_forward; - cass_type["reverse"] = &cassette_image_device::go_reverse; - cass_type["seek"] = [] (cassette_image_device &c, double time, const char* origin) { if (c.exists()) c.seek(time, s_seek_parser(origin)); }; cass_type["image"] = sol::property([] (cassette_image_device &c) { return dynamic_cast(&c); }); -- cgit v1.2.3