On MMC1, whether 0F or 1F is swapped into the C000-FFFF slot depends on whether or not pages 0-F or 10-1F are swapped into the 8000-BFFF slot.
One way to imagine this is the 512K PRG is split into two 256K blocks. The $C000-FFFF range is always set to the last page in the current block. So it will either be page $0F or $1F depending on which block is selected.
On MMC1, the game selects the block by writing to $BFFF. If it writes $0x, it wants the first block, if it writes $1x, it wants the second block.
The code I provided assumes the desired block was stored in RAM (based on the code you posted, it looks like address $0501)
LDA $0501 ; bit 4 of this value is the block the game wants
AND #$10 ; isolate that bit
ORA #$0F ; or with #$0F to select the last page IN THAT BLOCK
ASL A ; shift it left because MMC5 expects an 8k page number
ORA #$80 ; turn on the 'we want ROM' bit
STA $5117 ; swap page into $C000-FFFF slot
Although my original code combined both of those ORAs (hence $4F instead of $0F, since the following ASL will change that 4 to an 8 )
I don't think this code is your problem. If the game is crashing, there must be something else going on.
Is the original game writing to BFFF anywhere else? You'll have to capture all of those writes and translate them into MMC5 equivalents.