MiSTer-devel / NeoGeo_MiSTer

NeoGeo for MiSTer
GNU General Public License v2.0
145 stars 76 forks source link

Metal Slug 5 Plus #170

Closed terminator2k2 closed 12 months ago

terminator2k2 commented 1 year ago

just wandering if the game mapper/rom bank switching could be added for metal slug 5 plus rom to the core?

ajgowans commented 1 year ago

So in order to provide support for Metal Slug 5 Plus I have been informed that there needs to be a custom bankswitch mapper at 0x2FFFFX, here is the relevant Mame code

case NEOGEO_MSLUG5P: space.install_read_handler(0x2ffff0, 0x2fffff, read16m_delegate(m_slots[m_curr_slot], FUNC(neogeo_cart_slot_device::protection_r))); space.install_write_handler(0x2ffff0, 0x2fffff, write16sm_delegate(this, FUNC(neogeo_base_state::write_bankprot_ms5p))); break;

Special function:

void neogeo_base_state::write_bankprot_ms5p(offs_t offset, uint16_t data) { logerror("ms5plus bankswitch - offset: %06x PC %06x: set banking %04x\n", offset, m_maincpu->pc(), data);

if ((offset == 0) && (data == 0xa0)) { m_bank_base = 0xa0; m_bank_cartridge->set_base((uint8_t )m_slots[m_curr_slot]->get_rom_base() + m_bank_base); } else if (offset == 2) { m_bank_base = m_slots[m_curr_slot]->get_bank_base(data); m_bank_cartridge->set_base((uint8_t )m_slots[m_curr_slot]->get_rom_base() + m_bank_base); } }

Discussion on the forum here: https://misterfpga.org/viewtopic.php?t=5202

Image of relevant section for Mappers in Mame Neo-Geo-Mappers

sorgelig commented 1 year ago

according to this discussion: https://www.neo-geo.com/forums/index.php?threads/metal-slug-5-and-5.234216/

5+ is simply bootleg without any difference from original 5. I don't see much point to add a weird mapper (NeoGeo has enough space to fit the ROM without mapper) for variant working identically to original.

terminator2k2 commented 1 year ago

5 plus is a hack of 5 with a few differences more or less the same additions as 4 plus. Making up the rom it doesnt work properly on mister and niether does the metal slug 5 bootleg rom (mslug5b) which gadgetuk was using to do his conversion.

sorgelig commented 12 months ago

i've tried to implement the mapper.. Something weird happens. it still crashes.

In FBNeo they use different bank switcher: https://github.com/finalburnneo/FBNeo/blob/e42009e3303bfdbefddf5ea2334d38d69b619a9c/src/burn/drv/neogeo/d_neogeo.cpp#L9913

but from my observation of P2ROM of this game, at least reading of last bytes is wrong in both emulators. MAME returns A0 for last 16 bytes of P2 ROM address space. FBNeo doesn't map full address space leaving last 8KB from first bank regardless the current bank. In ROM as i see each bank has identifier so it most likely full 1MB should be mapped.

Whatever.. i'm losing patience on this weird hack which basically gives nothing.. May be my rom set is wrong..

Toryalai1 commented 12 months ago

There is a pack in HTGDB on internet archive where you can get ms5plus rom

carmiker commented 12 months ago

https://gitlab.com/jgemu/geolith/-/blob/master/src/geo_m68k.c?ref_type=heads Use my emulator as a reference. I've got a much simpler implementation of all the strange and exotic mappers.

For ms5plus I recall there were some troubles with converting it to .neo. I think the problem may be in how the conversion is done, and I am not sure the publicly available tools can convert this one properly. Try ms5plus from the "LunaGarlic" set and you may have better luck.

protogem2 commented 12 months ago

I tried the .neo from the LunaGarlic set and it does not work correctly either, graphical glitches and missing background layers, then the game crashes.

From what I understand these plus hacks only add minor things to the game like switching to different transformed states in 5, or summoning a thunder cloud to attack enemies in 4. No actual new content.

carmiker commented 12 months ago

@protogem2 yes, it will fail in the MiSTer implementation until the special bankswitching routine is implemented:

// Metal Slug 5 Plus (bootleg)
/* Shift the data left 16 when 16-bit writes to 0x2ffff4 occur to get the new
   switchable bank address offset. Simple. Everything else about the board is
   the typical behaviour.
*/
sorgelig commented 12 months ago

To add more chaos: i've used .neo rom which it seems not touched and it's probably uses 0x2ffff4 address (it has some obfuscation code). Then i found in my archives decrypted set of roms where ms5plus set is patched and uses 0x2ffff0 address for bank switch.

sorgelig commented 12 months ago

lol.. the patched one works with standard bank switching, no special code required at all :)

terminator2k2 commented 12 months ago

any more info on this working rom set?

sorgelig commented 12 months ago

i've added support for non-patched version.

sorgelig commented 12 months ago

need to update Main, Core and romsets.xml (if you use this format)