luaengine: bugfixes (nw)

This commit is contained in:
cracyc 2016-11-02 12:14:39 -05:00
parent 431f8d3611
commit bfc49b0974
4 changed files with 28 additions and 8 deletions

View File

@ -52,7 +52,7 @@ function cheatfind.startplugin()
-- save data block
function cheat.save(space, start, size)
local data = { block = "", start = start, size = size, space = space }
if space.shortname then
if getmetatable(space).__name:match("device_t") then
if space:shortname() == "ram" then
data.block = emu.item(space.items["0/m_pointer"]):read_block(start, size)
if not data.block then

View File

@ -654,13 +654,15 @@ function dat.check(set, softlist)
local newbytes = {}
if skip == "odd" then
for i = 1, #bytes, 2 do
val = bytes[i]:byte(1)
newbytes[(i+1)/2] = string.char(((val & 0x0f) << 4) | (val & 0x0f))
val1 = bytes[i]:byte(1)
val2 = bytes[i+1]:byte(1)
newbytes[(i+1)/2] = string.char(((val1 & 0x0f) << 4) | (val2 & 0x0f))
end
elseif skip == "even" then
for i = 1, #bytes, 2 do
val = bytes[i]:byte(1)
newbytes[(i+1)/2] = string.char((val & 0xf0) | ((val & 0xf0) >> 4))
val1 = bytes[i]:byte(1)
val2 = bytes[i+1]:byte(1)
newbytes[(i+1)/2] = string.char((val1 & 0xf0) | ((val2 & 0xf0) >> 4))
end
end
return newbytes

View File

@ -56,13 +56,28 @@ namespace sol
class buffer
{
public:
// sol does lua_settop(0), save userdata buffer in registry if necessary
buffer(int size, lua_State *L)
{
ptr = luaL_buffinitsize(L, &buff, size);
len = size;
if(buff.b != buff.initb)
{
lua_pushvalue(L, -1);
lua_setfield(L, LUA_REGISTRYINDEX, "sol::buffer_temp");
}
}
~buffer()
{
lua_State *L = buff.L;
if(lua_getfield(L, LUA_REGISTRYINDEX, "sol::buffer_temp") != LUA_TNIL)
{
lua_pushnil(L);
lua_setfield(L, LUA_REGISTRYINDEX, "sol::buffer_temp");
}
else
lua_pop(L, -1);
luaL_pushresultsize(&buff, len);
}
void set_len(int size) { len = size; }
@ -85,7 +100,7 @@ namespace sol
{
static int push(lua_State *L, osd_file::error error)
{
std::string strerror;
const char *strerror;
switch(error)
{
case osd_file::error::NONE:
@ -152,7 +167,7 @@ namespace sol
{
static int push(lua_State *L, map_handler_type type)
{
std::string typestr;
const char *typestr;
switch(type)
{
case AMH_NONE:
@ -1658,7 +1673,8 @@ void lua_engine::initialize()
"single_step", sol::property(&mame_ui_manager::single_step, &mame_ui_manager::set_single_step),
"get_line_height", &mame_ui_manager::get_line_height,
"get_string_width", &mame_ui_manager::get_string_width,
"get_char_width", &mame_ui_manager::get_char_width);
// sol converts char32_t to a string
"get_char_width", [](mame_ui_manager &m, uint32_t utf8char) { return m.get_char_width(utf8char); });
/* device.state[]
* state:name() - get device state name

View File

@ -396,6 +396,8 @@ void menu_dats_view::get_data()
for (int x = 0; x < lines; ++x)
{
std::string tempbuf(buffer.substr(xstart[x], xend[x] - xstart[x]));
if((tempbuf[0] == '#') && !x)
continue;
item_append(tempbuf, "", (FLAG_UI_DATS | FLAG_DISABLE), (void *)(uintptr_t)(x + 1));
}
}