Does anyone know how Mega Man 2 writes to the Pattern Table, exactly? The game has no CHR-ROM, only PRG, and I have been searching for a couple of days, and haven't had any luck.
I didn't look at this game specifically, but most CHR-RAM games I've seen have a sort of table that indicates which tiles to draw where and how much. For example... if a game wanted to write $618 bytes of tile data taken from pointer $8000, and wants to draw them to PPU address $1234, you might see "34 12 00 80 18 06" in the ROM somewhere. Of course this can be harder to find if you don't know exactly what values to look for.
Odds are, MM's graphics are copied in full, so figure out how many tiles make up all of MM and multiply that number by $10 to get the number of bytes.
To find the PPU address, you can use FCEUXD to get the tile number. Just multiply the tile number by $10 for the PPU address -- and also add $1000 if MM is on the right-hand side of the pattern tables
To find the CPU pointer, find the offset of the start of MMs graphics in the ROM with a tile viewer, subtract $10 for the header, AND with $3FFF, then add $8000. Example: if graphics are at offset 0x05780, subtract $10 for 0x5780, AND with $3FFF for 0x1780, and add $8000 to get $9780.
Searching for one of more of those values in the ROM may turn up the table you're looking for.
Of course.... if you know 6502 (which I'm assuming you must, if you coded a new engine!), you can also just do some simple tracing. Set a write breakpoint on the PPU address that has MM's graphics, fire up the trace logger, and get the game to load MM's graphics. Once the debugger snaps, simply follow the tracelogger back to where it loads the pointers from, and you found your table.
I might look into this later if I'm bored and you can't find it on your own.
I need to know how it writes to the Pattern Table, because I want to swap Mega Man's graphics in/out.
Be warned that CHR-RAM writing is SLOW. It's the big disadvantage to using CHR-RAM over CHR-ROM... games can't "swap" per se... rather they have to redraw each tile one byte at a time. These loops suck up lots of CPU time and aren't instantaneous like CHR-ROM swapping. You'll be able to swap out graphics between scenes.. but you probably won't be able to swap many/any out during any in-game action.
EDIT
well... maybe I'm being pessimistic. You should be able to copy a small bit of tiles every VBlank (maybe 4 or 8 or something like that). So you could swap out large chunks if you spread it across several frames.