This commit is contained in:
RobertoFresca 2016-06-21 00:17:52 -03:00
commit 5ecceb400d
6 changed files with 171 additions and 18 deletions

View File

@ -40,6 +40,15 @@ function cheatfind.startplugin()
return ram
end
-- return table of share regions
function cheat.getshares()
local shares = {}
for tag, share in pairs(manager:machine():memory().shares) do
shares[tag] = share
end
return shares
end
-- save data block
function cheat.save(space, start, size)
local data = { block = "", start = start, size = size, space = space }
@ -274,6 +283,10 @@ function cheatfind.startplugin()
for tag, ram in pairs(space_table) do
devtable[#devtable + 1] = { tag = tag, space = ram.dev, ram = {{ offset = 0, size = ram.size }} }
end
space_table = cheat.getshares()
for tag, share in pairs(space_table) do
devtable[#devtable + 1] = { tag = tag, space = share, ram = {{ offset = 0, size = share.size }} }
end
end
emu.register_start(start)

View File

@ -587,7 +587,25 @@ luabridge::LuaRef lua_engine::l_memory_get_regions(const memory_manager *m)
luabridge::LuaRef table = luabridge::LuaRef::newTable(L);
for (auto &region: mm->regions()) {
table[region.second->name()] = &region;
table[region.second->name()] = region.second.get();
}
return table;
}
//-------------------------------------------------
// memory_shares - return memory_shares
// -> manager:machine():memory().share[":maincpu"]
//-------------------------------------------------
luabridge::LuaRef lua_engine::l_memory_get_shares(const memory_manager *m)
{
memory_manager *mm = const_cast<memory_manager *>(m);
lua_State *L = luaThis->m_lua_state;
luabridge::LuaRef table = luabridge::LuaRef::newTable(L);
for (auto &share: mm->shares()) {
table[share.first] = share.second.get();
}
return table;
@ -1063,7 +1081,7 @@ int lua_engine::lua_addr_space::l_direct_mem_write(lua_State *L)
//-------------------------------------------------
// region_read - templated region readers for <sign>,<size>
// -> manager:machine():memory().region[":maincpu"]:read_i8(0xC000)
// -> manager:machine():memory().regions[":maincpu"]:read_i8(0xC000)
//-------------------------------------------------
template <typename T>
@ -1097,7 +1115,7 @@ int lua_engine::lua_memory_region::l_region_read(lua_State *L)
//-------------------------------------------------
// region_write - templated region writer for <sign>,<size>
// -> manager:machine():memory().region[":maincpu"]:write_u16(0xC000, 0xF00D)
// -> manager:machine():memory().regions[":maincpu"]:write_u16(0xC000, 0xF00D)
//-------------------------------------------------
template <typename T>
@ -1124,6 +1142,71 @@ int lua_engine::lua_memory_region::l_region_write(lua_State *L)
return 0;
}
//-------------------------------------------------
// share_read - templated share readers for <sign>,<size>
// -> manager:machine():memory().shares[":maincpu"]:read_i8(0xC000)
//-------------------------------------------------
template <typename T>
int lua_engine::lua_memory_share::l_share_read(lua_State *L)
{
memory_share &share = luabridge::Stack<memory_share &>::get(L, 1);
luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected");
offs_t address = lua_tounsigned(L, 2);
T mem_content = 0;
offs_t lowmask = share.bytewidth() - 1;
UINT8* ptr = (UINT8*)share.ptr();
for(int i = 0; i < sizeof(T); i++)
{
int addr = share.endianness() == ENDIANNESS_LITTLE ? address + sizeof(T) - 1 - i : address + i;
if(addr >= share.bytes())
continue;
mem_content <<= 8;
if(share.endianness() == ENDIANNESS_BIG)
mem_content |= ptr[(BYTE8_XOR_BE(addr) & lowmask) | (addr & ~lowmask)];
else
mem_content |= ptr[(BYTE8_XOR_LE(addr) & lowmask) | (addr & ~lowmask)];
}
if (std::numeric_limits<T>::is_signed) {
lua_pushinteger(L, mem_content);
} else {
lua_pushunsigned(L, mem_content);
}
return 1;
}
//-------------------------------------------------
// share_write - templated share writer for <sign>,<size>
// -> manager:machine():memory().shares[":maincpu"]:write_u16(0xC000, 0xF00D)
//-------------------------------------------------
template <typename T>
int lua_engine::lua_memory_share::l_share_write(lua_State *L)
{
memory_share &share = luabridge::Stack<memory_share &>::get(L, 1);
luaL_argcheck(L, lua_isnumber(L, 2), 2, "address (integer) expected");
luaL_argcheck(L, lua_isnumber(L, 3), 3, "value (integer) expected");
offs_t address = lua_tounsigned(L, 2);
T val = lua_tounsigned(L, 3);
offs_t lowmask = share.bytewidth() - 1;
UINT8* ptr = (UINT8*)share.ptr();
for(int i = 0; i < sizeof(T); i++)
{
int addr = share.endianness() == ENDIANNESS_BIG ? address + sizeof(T) - 1 - i : address + i;
if(addr >= share.bytes())
continue;
if(share.endianness() == ENDIANNESS_BIG)
ptr[(BYTE8_XOR_BE(addr) & lowmask) | (addr & ~lowmask)] = val & 0xff;
else
ptr[(BYTE8_XOR_BE(addr) & lowmask) | (addr & ~lowmask)] = val & 0xff;
val >>= 8;
}
return 0;
}
luabridge::LuaRef lua_engine::l_addr_space_map(const address_space *space)
{
lua_State *L = luaThis->m_lua_state;
@ -2375,6 +2458,7 @@ void lua_engine::initialize()
.beginClass <memory_manager> ("memory")
.addProperty <luabridge::LuaRef, void> ("banks", &lua_engine::l_memory_get_banks)
.addProperty <luabridge::LuaRef, void> ("regions", &lua_engine::l_memory_get_regions)
.addProperty <luabridge::LuaRef, void> ("shares", &lua_engine::l_memory_get_shares)
.endClass()
.beginClass <lua_memory_region> ("lua_region")
.addCFunction ("read_i8", &lua_memory_region::l_region_read<INT8>)
@ -2394,6 +2478,30 @@ void lua_engine::initialize()
.addCFunction ("write_i64", &lua_memory_region::l_region_write<INT64>)
.addCFunction ("write_u64", &lua_memory_region::l_region_write<UINT64>)
.endClass()
.deriveClass <memory_region, lua_memory_region> ("region")
.addProperty <UINT32> ("size", &memory_region::bytes)
.endClass()
.beginClass <lua_memory_share> ("lua_share")
.addCFunction ("read_i8", &lua_memory_share::l_share_read<INT8>)
.addCFunction ("read_u8", &lua_memory_share::l_share_read<UINT8>)
.addCFunction ("read_i16", &lua_memory_share::l_share_read<INT16>)
.addCFunction ("read_u16", &lua_memory_share::l_share_read<UINT16>)
.addCFunction ("read_i32", &lua_memory_share::l_share_read<INT32>)
.addCFunction ("read_u32", &lua_memory_share::l_share_read<UINT32>)
.addCFunction ("read_i64", &lua_memory_share::l_share_read<INT64>)
.addCFunction ("read_u64", &lua_memory_share::l_share_read<UINT64>)
.addCFunction ("write_i8", &lua_memory_share::l_share_write<INT8>)
.addCFunction ("write_u8", &lua_memory_share::l_share_write<UINT8>)
.addCFunction ("write_i16", &lua_memory_share::l_share_write<INT16>)
.addCFunction ("write_u16", &lua_memory_share::l_share_write<UINT16>)
.addCFunction ("write_i32", &lua_memory_share::l_share_write<INT32>)
.addCFunction ("write_u32", &lua_memory_share::l_share_write<UINT32>)
.addCFunction ("write_i64", &lua_memory_share::l_share_write<INT64>)
.addCFunction ("write_u64", &lua_memory_share::l_share_write<UINT64>)
.endClass()
.deriveClass <memory_share, lua_memory_share> ("region")
.addProperty <size_t> ("size", &memory_share::bytes)
.endClass()
.beginClass <output_manager> ("output")
.addFunction ("set_value", &output_manager::set_value)
.addFunction ("set_indexed_value", &output_manager::set_indexed_value)
@ -2402,9 +2510,6 @@ void lua_engine::initialize()
.addFunction ("name_to_id", &output_manager::name_to_id)
.addFunction ("id_to_name", &output_manager::id_to_name)
.endClass()
.deriveClass <memory_region, lua_memory_region> ("region")
.addProperty <UINT32> ("size", &memory_region::bytes)
.endClass()
.beginClass <device_image_interface> ("image")
.addFunction ("exists", &device_image_interface::exists)
.addFunction ("filename", &device_image_interface::filename)

View File

@ -198,6 +198,11 @@ private:
};
static luabridge::LuaRef l_memory_get_banks(const memory_manager *m);
static luabridge::LuaRef l_memory_get_shares(const memory_manager *m);
struct lua_memory_share {
template<typename T> int l_share_read(lua_State *L);
template<typename T> int l_share_write(lua_State *L);
};
static luabridge::LuaRef l_memory_get_regions(const memory_manager *m);
struct lua_memory_region {
template<typename T> int l_region_read(lua_State *L);

View File

@ -899,19 +899,19 @@ ROM_END
ROM_START( helifire )
ROM_REGION( 0x8000, "maincpu", 0 )
ROM_LOAD( "hf.f1", 0x0000, 0x0400, CRC(032f89ca) SHA1(63b0310875ed78a6385e44eea781ddcc4a63557c) )
ROM_LOAD( "hf.f2", 0x0400, 0x0400, CRC(2774e70f) SHA1(98d845e80db61799493dbebe8db801567277432c) )
ROM_LOAD( "hf.g1", 0x0800, 0x0400, CRC(b5ad6e8a) SHA1(1eb4931e85bd6a559e85a2b978d383216d3988a7) )
ROM_LOAD( "hf.g2", 0x0c00, 0x0400, CRC(5e015bf4) SHA1(60f5a9707c8655e54a8381afd764856fb25c29f1) )
ROM_LOAD( "hf.h1", 0x1000, 0x0400, CRC(23bb4e5a) SHA1(b59bc0adff3635aca1def2b1997f7edc6ca7e8ee) )
ROM_LOAD( "hf.h2", 0x1400, 0x0400, CRC(358227c6) SHA1(d7bd678ef1737edc6aa609e43e3ae96a8d61dc15) )
ROM_LOAD( "hf.i1", 0x1800, 0x0400, CRC(0c679f44) SHA1(cbe31dbe5f2c5f11a637cb3bde4e059c310d0e76) )
ROM_LOAD( "hf.i2", 0x1c00, 0x0400, CRC(d8b7a398) SHA1(3ddfeac39147d5df6096f525f7ef67abef32a28b) )
ROM_LOAD( "hf.j1", 0x2000, 0x0400, CRC(98ef24db) SHA1(70ad8dd6e1e8f4bf4ce431737ca1856eecc03d53) )
ROM_LOAD( "hf.j2", 0x2400, 0x0400, CRC(5e2b5877) SHA1(f7c747e8a1d9fe2dda71ee6304636cf3cdf727a7) )
ROM_LOAD( "tub_f1_b", 0x0000, 0x0400, CRC(032f89ca) SHA1(63b0310875ed78a6385e44eea781ddcc4a63557c) )
ROM_LOAD( "tub_f2_b", 0x0400, 0x0400, CRC(2774e70f) SHA1(98d845e80db61799493dbebe8db801567277432c) )
ROM_LOAD( "tub_g1_b", 0x0800, 0x0400, CRC(b5ad6e8a) SHA1(1eb4931e85bd6a559e85a2b978d383216d3988a7) )
ROM_LOAD( "tub_g2_b", 0x0c00, 0x0400, CRC(5e015bf4) SHA1(60f5a9707c8655e54a8381afd764856fb25c29f1) )
ROM_LOAD( "tub_h1_b", 0x1000, 0x0400, CRC(23bb4e5a) SHA1(b59bc0adff3635aca1def2b1997f7edc6ca7e8ee) )
ROM_LOAD( "tub_h2_b", 0x1400, 0x0400, CRC(358227c6) SHA1(d7bd678ef1737edc6aa609e43e3ae96a8d61dc15) )
ROM_LOAD( "tub_i1_b", 0x1800, 0x0400, CRC(0c679f44) SHA1(cbe31dbe5f2c5f11a637cb3bde4e059c310d0e76) )
ROM_LOAD( "tub_i2_b", 0x1c00, 0x0400, CRC(d8b7a398) SHA1(3ddfeac39147d5df6096f525f7ef67abef32a28b) )
ROM_LOAD( "tub_j1_b", 0x2000, 0x0400, CRC(98ef24db) SHA1(70ad8dd6e1e8f4bf4ce431737ca1856eecc03d53) )
ROM_LOAD( "tub_j2_b", 0x2400, 0x0400, CRC(5e2b5877) SHA1(f7c747e8a1d9fe2dda71ee6304636cf3cdf727a7) )
ROM_REGION( 0x0400, "audiocpu", 0 )
ROM_LOAD( "hf.snd", 0x0000, 0x0400, CRC(9d77a31f) SHA1(36db9b5087b6661de88042854874bc247c92d985) )
ROM_LOAD( "tub-e_ic5-a", 0x0000, 0x0400, CRC(9d77a31f) SHA1(36db9b5087b6661de88042854874bc247c92d985) )
ROM_END
ROM_START( helifirea )

View File

@ -3497,6 +3497,34 @@ ROM_START( tmht22pe )
ROM_LOAD( "tmnt2_eba.nv", 0x0000, 0x080, CRC(c0a3ed50) SHA1(6deec720c7f1c607740076cb8b5b5becd175aed0) )
ROM_END
ROM_START( tmht24pe )
ROM_REGION( 0x100000, "maincpu", 0 ) /* 4*128k for 68000 code */
ROM_LOAD16_BYTE( "063eaa02.8e", 0x000000, 0x20000, CRC(665a68de) SHA1(3cefc2cb0f0a42f1044ef04862669fc7893005da) )
ROM_LOAD16_BYTE( "063eaa03.8g", 0x000001, 0x20000, CRC(7b7fb3af) SHA1(1c96283af8fc81c30136dfe2efbd113cb7dd3d66) )
ROM_LOAD16_BYTE( "063eaa04.10e", 0x040000, 0x20000, CRC(69f38e1d) SHA1(a63aa86a11f803fa3f07c5eb2fdbdb75bb850d55) )
ROM_LOAD16_BYTE( "063eaa05.10g", 0x040001, 0x20000, CRC(818032af) SHA1(60d416a58696add58493c0f2297b3a4af5f46d6d) )
ROM_REGION( 0x10000, "audiocpu", 0 )
ROM_LOAD( "063b01.2f", 0x0000, 0x10000, CRC(364f548a) SHA1(e0636e27d4fc48b2ccb1417b63d2b68d9e272c06) )
ROM_REGION( 0x100000, "k052109", 0 ) /* tiles */
ROM_LOAD32_WORD( "063b12.16k", 0x000000, 0x080000, CRC(d3283d19) SHA1(49e4daa9cbe4d99bf71fcee6237cb434a0d55312) )
ROM_LOAD32_WORD( "063b11.12k", 0x000002, 0x080000, CRC(6ebc0c15) SHA1(e6848405076937fbf8ec6d318293a0ff922725f4) )
ROM_REGION( 0x400000, "k053245", 0 ) /* sprites */
ROM_LOAD32_WORD( "063b09.7l", 0x000000, 0x100000, CRC(2d7a9d2a) SHA1(a26f9c1a07152bc8c7bcd797d4485bf848f5e2a0) )
ROM_LOAD32_WORD( "063b07.3l", 0x000002, 0x100000, CRC(d9bee7bf) SHA1(7bbb65138fbd216b80412783e6f0072742101440) )
ROM_LOAD32_WORD( "063b10.7k", 0x200000, 0x080000, CRC(f2dd296e) SHA1(a2aad10bfb0904dd73c2ee11049648c94de7f4d5) )
ROM_LOAD32_WORD( "063b08.3k", 0x200002, 0x080000, CRC(3b1ae36f) SHA1(9e69cae8b517497ac77c4d148f56f2bb6a23de89) )
/* second half empty */
ROM_REGION( 0x200000, "k053260", 0 ) /* samples for the 053260 */
ROM_LOAD( "063b06.1d", 0x0000, 0x200000, CRC(1e510aa5) SHA1(02b9bd6bb6b098026a620e4d671c40a31ad9e318) )
ROM_REGION( 0x80, "eeprom", 0 ) // default eeprom to prevent game booting with invisible error message
ROM_LOAD( "tmnt2_eaa.nv", 0x0000, 0x080, CRC(124af18f) SHA1(bbd0629663135fc6c08b000b886ea76a96592a9e) )
ROM_END
ROM_START( tmnt2a )
ROM_REGION( 0x100000, "maincpu", 0 ) /* 4*128k for 68000 code */
ROM_LOAD16_BYTE( "063ada02.8e", 0x000000, 0x20000, CRC(4f11b587) SHA1(111051da23ce7035405b4d12c0f18dcc1d6c8ddc) )
@ -4207,6 +4235,7 @@ GAME( 1991, glfgreatj, glfgreat, glfgreat, glfgreatj, driver_device, 0,
GAME( 1991, tmnt2, 0, tmnt2, ssridr4p, driver_device, 0, ROT0, "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (4 Players ver UAA)", MACHINE_SUPPORTS_SAVE )
GAME( 1991, tmnt2a, tmnt2, tmnt2, ssrid4ps, driver_device, 0, ROT0, "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (4 Players ver ADA)", MACHINE_SUPPORTS_SAVE )
GAME( 1991, tmht22pe, tmnt2, tmnt2, ssriders, driver_device, 0, ROT0, "Konami", "Teenage Mutant Hero Turtles - Turtles in Time (2 Players ver EBA)", MACHINE_SUPPORTS_SAVE )
GAME( 1991, tmht24pe, tmnt2, tmnt2, ssriders, driver_device, 0, ROT0, "Konami", "Teenage Mutant Hero Turtles - Turtles in Time (4 Players ver EAA)", MACHINE_SUPPORTS_SAVE )
GAME( 1991, tmnt22pu, tmnt2, tmnt2, ssriders, driver_device, 0, ROT0, "Konami", "Teenage Mutant Ninja Turtles - Turtles in Time (2 Players ver UDA)", MACHINE_SUPPORTS_SAVE )
GAME( 1993, qgakumon, 0, tmnt2, qgakumon, driver_device, 0, ROT0, "Konami", "Quiz Gakumon no Susume (Japan ver. JA2 Type L)", MACHINE_SUPPORTS_SAVE )

View File

@ -35298,7 +35298,6 @@ thndrx2 // GX073 (c) 1991 (World)
thndrx2a // GX073 (c) 1991 (Asia)
thndrx2j // GX073 (c) 1991 (Japan)
tmht // GX963 (c) 1989 (UK)
tmht22pe // GX063 (c) 1991 (UK)
tmht2p // GX963 (c) 1989 (UK)
tmht2pa // GX963 (c) 1989 (UK)
tmhta // GX963 (c) 1989 (UK)
@ -35306,6 +35305,8 @@ tmhtb // GX963 (c) 1989 (UK?)
tmnt // GX963 (c) 1989 (World)
tmnt2 // GX063 (c) 1991 (US)
tmnt22pu // GX063 (c) 1991 (US)
tmht22pe // GX063 (c) 1991 (UK)
tmht24pe // GX063 (c) 1991 (UK)
tmnt2a // GX063 (c) 1991 (Asia)
tmnt2pj // GX963 (c) 1990 (Japan)
tmnt2po // GX963 (c) 1989 (Oceania)