The PC Engine handles addresses internally with mappers, since the physical memory space (2MB) is considerably bigger than the logical space (64KB).
The Magic Engine emulator references addresses within the logic space with 3 bytes, using the high byte as the page number, and the remaining two as the logical address. Mednafen references the address within the physical space, using the 21bit address.
To convert between the two is simple. For example, take the address from Bonk III's Invincibility cheat by VisitntX - F829B6.
First, take off the page number - F8.
Then, consider the 3 high bits of the address 0x29B6, which are 001. This is the mapper #, which is not needed for the physical address. So, with this said, we zero those bits.
Lastly, we shift the page number left 13 bits and logical OR with the address.
And now you have a physical address for use in mednafen, and can convert the Magic Engine codes for it.
To Convert back to Magic Engine, for RAM codes the mapper number will always be 1 (001). So, you just slide those bits into the physical address between the page and the address.
____________________________________
As for how to convert physical ROM addresses into logical addresses, I'm not sure how to determine the mapper number used. I would guess that you AND the page# with 0x7, but that doesn't ring true with the known RAM mapper of MRP1, since 0xF8 AND 0x7 is 0.
If anybody knows the answer, please feel free to share.
The Magic Engine emulator references addresses within the logic space with 3 bytes, using the high byte as the page number, and the remaining two as the logical address. Mednafen references the address within the physical space, using the 21bit address.
To convert between the two is simple. For example, take the address from Bonk III's Invincibility cheat by VisitntX - F829B6.
First, take off the page number - F8.
Then, consider the 3 high bits of the address 0x29B6, which are 001. This is the mapper #, which is not needed for the physical address. So, with this said, we zero those bits.
Code:
0x29B6 & 0x1FFF = 0x09B6
Code:
(0xF8 << 13) | 0x09B6 = 0x1F09B6
To Convert back to Magic Engine, for RAM codes the mapper number will always be 1 (001). So, you just slide those bits into the physical address between the page and the address.
Code:
((0x1F09B6 & 0xFFFF) | 0x2000) | (((0x1F09B6 >> 13) & 0xFF) << 16) = 0xF829B6
As for how to convert physical ROM addresses into logical addresses, I'm not sure how to determine the mapper number used. I would guess that you AND the page# with 0x7, but that doesn't ring true with the known RAM mapper of MRP1, since 0xF8 AND 0x7 is 0.
If anybody knows the answer, please feel free to share.
Comment