Announcement

Collapse
No announcement yet.

[PCE/TG16] Converting paged addresses to physical addresses (Magic Engine > Mednafen)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [PCE/TG16] Converting paged addresses to physical addresses (Magic Engine > Mednafen)

    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.
    Code:
    0x29B6 & 0x1FFF = 0x09B6
    Lastly, we shift the page number left 13 bits and logical OR with the address.
    Code:
    (0xF8 << 13) | 0x09B6 = 0x1F09B6
    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.
    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.
    Please put all complaints in writing and submit them here.

    Above link not working? Try here.


  • #2
    I can't get this conversion to work with ROM codes.

    VisitntX- You made most of these codes, maybe you could shed some light?
    Please put all complaints in writing and submit them here.

    Above link not working? Try here.

    Comment


    • #3
      I wish there was a cheat code patcher for the TG-16/PC Engine roms...

      Comment


      • #4
        Sorry for bumping such an old topic...

        Any chance of getting this RAM conversion working on the database, when you have some spare time and desire?
        http://OldGameHacking.com/
        http://www.youtube.com/user/DreamcastVideos

        Comment


        • #5
          I forgot all about this. My past self just taught my present self something I didn't think I knew.

          Did I not? I'm at the end of a long day at work and my mind is mush. I might look at this tomorrow or something.
          Please put all complaints in writing and submit them here.

          Above link not working? Try here.

          Comment


          • #6
            The database supports the codes Ootake emulator accepts, that begin with F8 perfectly.
            But when you look at the other format that MESS uses, that begins with 1F; it shows up as unrecognized.

            This game, for example, has both code formats:
            http://gamehacking.org/?game=40287
            http://OldGameHacking.com/
            http://www.youtube.com/user/DreamcastVideos

            Comment


            • #7
              You can add codes in either format now, and they are all recognized.

              All except those that have decimal values. Those values need converted to hex for the site to recognize them.
              Please put all complaints in writing and submit them here.

              Above link not working? Try here.

              Comment


              • #8
                Thank you very much, for always improving the site!
                Now it's easier than ever to use already created RAM codes for making ROM hacks.

                Edit:
                I changed the very few codes RAM codes I have made, to have hex values.
                Also added two new codes: http://gamehacking.org/hackers/Mezmorize/pce
                Last edited by Mezmorize; 03-07-2015, 02:34:46 AM.
                http://OldGameHacking.com/
                http://www.youtube.com/user/DreamcastVideos

                Comment

                Working...
                X