mirror of https://github.com/bsnes-emu/bsnes.git
Update to bsnes v025r04? release.
New WIP up. This one's a bit better than last, but I don't want bug reports yet. This one only maps generic LoROM and HiROM games. Took about four or five hours, but I reworked most of the new memory mapper yet again. SRAM should be working now, and I managed to gain back the speed lost by dropping the address masking and forcing Visual C++ to inline (__forceinline). The masking was no good anyway, because the ROM file loaded in is definitely not always a power of two, which means I'd have to use modulus and holy fuck no I'm not adding a division for every memory access. The old memory mapper didn't have this either, as it stored a bunch of pointers into memory chunks. The new one just stores one pointer plus integer offsets into that pointer (a bit slower but cleaner and necessary for abstraction), so it's really mostly the same thing. Man, I was looking at my old generic LoROM / HiROM mapper, and the difference from that and what I have now is astounding ... it would seem I've certainly gotten better at programming since then. /* new */ void sBus::map_generic() { switch(cartridge.info.mapper) { case Cartridge::LOROM: { map(MapLinear, 0x00, 0x3f, 0x8000, 0xffff, memory::rom); map(MapLinear, 0x80, 0xbf, 0x8000, 0xffff, memory::rom); map(MapLinear, 0x40, 0x7f, 0x0000, 0xffff, memory::rom); map(MapLinear, 0xc0, 0xff, 0x0000, 0xffff, memory::rom); } break; case Cartridge::HIROM: { map(MapShadow, 0x00, 0x3f, 0x8000, 0xffff, memory::rom); map(MapShadow, 0x80, 0xbf, 0x8000, 0xffff, memory::rom); map(MapLinear, 0x40, 0x7f, 0x0000, 0xffff, memory::rom); map(MapLinear, 0xc0, 0xff, 0x0000, 0xffff, memory::rom); } break; } if(memory::sram.size() == 0) { return; } map(MapLinear, 0x20, 0x3f, 0x6000, 0x7fff, memory::sram); map(MapLinear, 0xa0, 0xbf, 0x6000, 0x7fff, memory::sram); map(MapLinear, 0x70, 0x7f, 0x0000, 0x7fff, memory::sram); if(cartridge.info.mapper != Cartridge::LOROM) { return; } map(MapLinear, 0xf0, 0xff, 0x0000, 0x7fff, memory::sram); } /* old */ void bMemBus::cart_map_generic(uint type) { uint rom_size = cartridge.info.rom_size; uint ram_size = cartridge.info.ram_size; for(uint page = 0x0000; page <= 0xffff; page++) { if(memory_type(page << 8) != TYPE_CART)continue; uint addr = page << 8; uint bank = page >> 8; //RAM mapping is incorrect in several games, this is the most compatible //layout I can create using only ROM header information. Additional accuracy //requires PCB identification. //Unmapped region //$[00-1f|80-9f]:[6000-7fff] if((bank & 0x7f) >= 0x00 && (bank & 0x7f) <= 0x1f && (addr & 0xe000) == 0x6000) { continue; } //HiROM RAM region //$[20-3f|a0-bf]:[6000-7fff] if((bank & 0x7f) >= 0x20 && (bank & 0x7f) <= 0x3f && (addr & 0xe000) == 0x6000) { if(ram_size == 0)continue; addr = ((bank & 0x7f) - 0x20) * 0x2000 + ((addr & 0xffff) - 0x6000); addr %= ram_size; page_handle[page] = cartridge.ram + addr; page_read [page] = &bMemBus::read_ram; page_write [page] = &bMemBus::write_ram; continue; } //LoROM RAM region //$[70-7f|f0-ff]:[0000-7fff] //Note: WRAM is remapped over $[7e-7f]:[0000-ffff] if((bank & 0x7f) >= 0x70 && (bank & 0x7f) <= 0x7f && (addr & 0x8000) == 0x0000) { if(!(bank & 0x80) || type == Cartridge::LOROM) { //HiROM maps $[f0-ff]:[0000-7fff] to ROM if(ram_size == 0)continue; addr = ((bank & 0x7f) - 0x70) * 0x8000 + (addr & 0x7fff); addr %= ram_size; page_handle[page] = cartridge.ram + addr; page_read [page] = &bMemBus::read_ram; page_write [page] = &bMemBus::write_ram; continue; } } //ROM region switch(type) { case Cartridge::LOROM: { addr = (bank & 0x7f) * 0x8000 + (addr & 0x7fff); addr = mirror(rom_size, addr); } break; case Cartridge::HIROM: { addr = mirror(rom_size, addr); } break; } page_handle[page] = cartridge.rom + addr; page_read [page] = &bMemBus::read_rom; page_write [page] = &bMemBus::write_rom; } } Note that those two certainly aren't identical in function, and I'll no doubt have some memory mapping bugs again (probably with Final Fight, SFII and such), but it should only require minor changes to fix that. > byuu: is it possible there's supposed to be steam appearing there to > create the illusion, but isn't? That's a lot more likely, honestly. Hopefully someone can make it to level 5, heh. I know I sure as hell can't. [No archive available]
This commit is contained in:
parent
42d3f2a37f
commit
476a1c819a