News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Question about expanding a Mega Drive Rom  (Read 3228 times)

DougRPG

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Question about expanding a Mega Drive Rom
« on: October 10, 2012, 01:11:43 pm »
Hi, I'm translating a Mega Drive game and I already found the compression algorithm (a huffman variant) and I already have the script dumped. I' m using Ida Pro to disassembly the game, but I'm starting now to change the code.

This rom has 2MB, and there is only a few free bytes at the end of the file. My question is: I want to put my new translated script at the end of the file, and I'll change the way the compression works, but this way the rom will have more than 2MB. Is this  ok or I need to do something special when the rom is expanded this way? Aparently all roms need to be multiple of 256k (or something like that), but is there a reason for that?

Is there some documents explaining this stuff? I'm a begginner in romhacking, and I have a lot of basic stuff to learn.

Thanks....

Malias

  • Sr. Member
  • ****
  • Posts: 278
    • View Profile
Re: Question about expanding a Mega Drive Rom
« Reply #1 on: October 10, 2012, 02:53:38 pm »
I'm not sure, but it might be as simple as changing the header on the rom.  According to this document, the address range is stored from $1A0-$1A7.  Try changing the upper range and see what happens.
The great achievement is to lose one's reason for no reason, and to let my lady know that if I can do this without cause, what should I do if there were cause?
     ~Don Quixote~

nightmareci

  • Jr. Member
  • **
  • Posts: 6
    • View Profile
Re: Question about expanding a Mega Drive Rom
« Reply #2 on: October 12, 2012, 05:47:46 pm »
AFAIK you can just make the ROM bigger without changing anything in the file, because Genesis ROM headers aren't actually read by anything but the code in the ROM; new references in the ROM to the expanded area should "just work," as long as you're simply adding extra space onto the end of the ROM and not trying to expand anywhere else. The main thing you need to worry about is the checksum code, as the checksum will change if you start editing the original ROM's contents, and the game may go into a bad checksum state and refuse to boot. There's probably a conditional branch instruction around the checksum code (e.g. "beq.s checksum_good", so it'd branch if the calculated checksum is equal to the one in the header) that you can change to an unconditional branch that will always continue code execution even if the checksum is bad. Alternatively, there are ways to calculate the new checksum of the modified ROM and write it into the header, making the game work as it should.

DougRPG

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Question about expanding a Mega Drive Rom
« Reply #3 on: November 19, 2012, 09:37:13 pm »
Hi.....

This rom expansion isn't working. I expanded the rom from 2MB to 4MB, inserting 0xFF at the end of the file.

The game starts ok and I can see the intro, but before the gameplay starts the game freezes.
I'm using Regen, and when the game freezes the debugger windows appears, and I can see that the A0 and A1 registers has values CEA24EFA and CEA24EF9 (something wrong right?).
When I run the 2MB version, at the same place the values are BDBF7 and BDBF9.

The only difference between the two roms are the 0xFFs at the end.
I tried to change the header, changing the Rom End Address from 0x1FFFFF to 0x3FFFFF but it's the same.

Someone knows why is this happening?

Thanks



November 20, 2012, 12:15:49 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
I changed the 0xFFs to 0x00s and the game worked (no more that crazy values at A0 and A1). But after adding some code after 0x200000 some strange stuff happened, like some strange Save Game appering, and others anomalies.
I did some debugging and I saw that in some points there are a lot of reads to addresses higher than 0x200000, but the original rom only goes to 0x1FFFFF.
Searching the Genesis memory map I found this:

Code: [Select]
Start address End address Description
$000000 $01FFFF MegaCD BIOS ROM
$020000 $03FFFF MegaCD "Program RAM" Bank Access
$200000 $23FFFF MegaCD "WORD RAM"
$A12000 $A120XX MegaCD "Gate Array"
$FFFD00 $FFFDFF MegaCD Interrupt/Exception vectors

(more details in http://en.wikibooks.org/wiki/Genesis_Programming)

So addresses 200000 to 23FFFF are this MegaCD "WORD RAM". Debugging the game I saw that there is no read from 240000 to 3FFFFF.
The reads stays between 200000 and 23FFFF, so the game seems to use this MegaCD "WORD RAM".

I put my code after 240000 and now everything is working fine (I hope).

Someone knows why this MegaCD "WORD RAM" are being used?




November 20, 2012, 01:21:19 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Reading the page

http://cgfm2.emuviews.com/txt/gen-hw.txt

we can see that Phantasy Star 4 has a similar behaviour. Some games seems to map Ram inside Rom space. Phantasy Star 4 also uses addresses from 200000 to 23FFFF.
I'm not sure if this is relate to MegaCD "WORD RAM" anymore.
« Last Edit: November 20, 2012, 01:21:19 pm by Dgdiniz »

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6481
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Question about expanding a Mega Drive Rom
« Reply #4 on: November 21, 2012, 01:21:45 am »
I'm pretty sure the Mega CD memory map only applies if you're actually hacking a Mega/Sega CD game.
Ignore if you're hacking a cart game, and use the regular MD/Gen map.
Quote
Sir Howard Stringer, chief executive of Sony, on Christmas sales of the PS3:
"It's a little fortuitous that the Wii is running out of hardware."

DougRPG

  • Full Member
  • ***
  • Posts: 142
    • View Profile
Re: Question about expanding a Mega Drive Rom
« Reply #5 on: November 21, 2012, 10:52:15 am »
Yes. Seems that some games maps the save state Ram at 0x200000-0x203FFF (16KB).

So, my advice for who wants to expand a Sega Genesis rom is:

1-) Append a lot of 0x00 at the end (not 0xFF)

2-) Do not use 0x200000-0x203FFF region

3-) Be happy

 :woot!:

kingraph

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Question about expanding a Mega Drive Rom
« Reply #6 on: August 19, 2017, 01:13:29 am »
I'm having the same issue, but I can't seem to find a solution that works.  I'd like to expand an NHL'95 ROM from 2MB to 4MB.  The moment I add any FF or 00 to expand the ROM, the picture cards and names on the main menu get messed up/fail.  So if you don't start the game right away, it will crash.

I have not added or changed any of the code (removed checksum), but this happens.  I'm curious if there has been any more information on what could cause this issue?