don't click here

What's the correct way of extracting games....

Discussion in 'Technical Discussion' started by MarzSyndrome, Feb 12, 2012.

  1. MarzSyndrome

    MarzSyndrome

    Everything is going to the beat. Member
    As in stuff like the 6-Pak and the Mega Games series et al.

    I know drx managed to seperate the Sonic 2 data from Sonic Compilation and made a standalone ROM out of it, but I don't know how complicated it's supposed to be. I thought you could just find the headers, grab a chunk from the start of that header adding up to the game's traditional ROM size and then save it, but the resulting file doesn't load under any emulator. A look through a hex editor reveals many changes to the data indeed (compared to an equivalent standalone ROM), so I guess not.


    Was thinking about this lately after realising that the later "Sega Soccer" - a rebranded version of World Cup Italia '90/World Championship Soccer - is exclusive to a few of the EU compilations it appeared on, and thought a standalone ROM of it might help 'complete' the WCS set somewhat.
     
  2. ICEknight

    ICEknight

    Researcher Researcher
    I can't help with this, but that Sonic 2 from the Sonic Compilation can be extracted by just trimming the whole ROM from the beginning until the point where the second ROM (Sonic 1?) starts, and then editing the header so the startup routine points to the usual place, instead of the game select menu.

    As I understand, games placed anywhere but the very beginning of the compilations will have their pointers shifted, so it won't be such an easy task for those. =\
     
  3. MarzSyndrome

    MarzSyndrome

    Everything is going to the beat. Member
    You're right, it doesn't look easy. I was hoping to just copy-paste the "Sega Soccer" gfx data into a WCI90 rom, but it's dawned on me that the only 68k code-hacking I've been involved in is all related to Amiga stuff, not Mega Drive. I don't know of any MD emulator with a live debugger like what WinUAE has that can allow me to understand better what the startup code is doing.

    Anyone willing to trounce me and set a new record for creating a Sega Soccer rom? :P
     
  4. LocalH

    LocalH

    roxoring your soxors Tech Member
    You could always go the cheap route and $00 out everything that's not part of the game in question. It'll certainly compress better! :specialed:
     
  5. MarzSyndrome

    MarzSyndrome

    Everything is going to the beat. Member
    You've sort of reminded me that there were a few hacks of Sonic Compilation that did straight redirects to each game upon startup. I've looked at these but as it turns out, I'm going to have to learn all about the first $100 bytes of the header and what they're supposed to represent (and I'm not talking about the section with all the names and flags) - I'm having an awfully hard time finding a nice, detailed page on this however.
     
  6. LocalH

    LocalH

    roxoring your soxors Tech Member
    The first $100 bytes of the header are not Sega-specific, they are merely the exception vectors for the 68000 itself (and also are used for this same purpose in nearly all, if not all 68k-based systems).

    Given that you say the game is a rebranded version of WCS, I would recommend starting with the header from that game, and replacing the necessary addresses with that of the rebranded game. This page contains a generic list of the 68k exception vectors. The most important vectors are those at $000000 (initial stack pointer), $000004 (initial program counter), $000070 (level 4 interrupt, used as H-Int) and $000078 (level 6 interrupt, used as V-Int). Most of the other vectors are only used in case of an actual exception that would otherwise cause the processor to halt (address error, illegal instruction, divide-by-zero). Unfortunately, unless "Sega Soccer" in this compilation is analogous to Sonic 2 in Sonic Compilation, the values found in the header won't necessarily be accurate.

    One possibility for an easy hack - does the compilation ROM you are referring to have a header for "Sega Soccer" at a non-$000000 location (similar to S1 and MBM in Compilation)? If so, then take the offset of "SEGA MEGA DRIVE", subtract $100, and take that as the start of your "sub-ROM". Look in that first $100 bytes (starting at the beginning of your "sub-ROM") and see if the values look to be within the range of memory that the desired game occupies. If it looks more like it would be set up for a game starting at $000000, then add to each of those first 32-bit values the start of the "sub-ROM" that you identified earlier (not all 256 are even used by the processor itself, and of the ones that are not "reserved", even fewer of them were used on the MD, I'm pretty sure the vectors between $0C0-$FFF are not used at all anywhere, and the ones between $080-$0BF aren't used at all on the MD). Others may be able to clarify this a little better.

    It may help if you post the contents of that first $100 plus the following MD header so that others could assist you. I've got plans tonight, but I might look into this sometime in the next couple of days, see what I can find out.
     
  7. LocalH

    LocalH

    roxoring your soxors Tech Member
    Ok, did some hacking around. First things first, the ROMs I am using for analysis (and cross-reference to make sure I was looking at the right stuff):

    World Championship Soccer
    JP ("Domestic") name: WORLDCUP SOCCER
    World ("Overseas") name: WORLD CHAMPIONSHIP SOCCER
    Game ID: GM 00004009-03
    MD checksum: AE55
    Region code: JU

    World Cup Italia '90
    JP name: WORLDCUP SOCCER
    World name: WORLD CUP ITALIA'90
    Game ID: GM 00004009-05
    MD checksum: EE69
    Region code: E

    Mega Games 6 vol 1
    JP name: MEGAGAMES Vol. 1
    World name: MEGAGAMES Vol. 1
    Game ID: GM MK-1188
    MD checksum: 3A72
    Region code: F (newer variant of JUE, interesting given that this was an E-only release)

    From looking at the standalone ROMs, I found that there were only two of the vectors that were important - initial PC and V-Int. All the rest of the vectors (except for the initial stack pointer) were pointing at $200, which is an infinite loop. To deduce the initial PC, I looked for text from either WCS or WCI90, and found that the copy of MG6 I have contains WCI90 and not WCS nor "Sega Soccer", and that the game falls from $C0000-$FFFFFF. Looking back and forth between MG6 at $C0000 and WCS around $200, I found that $C0000 was indeed the proper start vector. Looking at the MG6 header, I found that the V-Int vector was being redirected through RAM (the main menu writes the necessary V-Int vector to RAM $FFFC, and along with a JMP instruction at RAM $FFFA this tells me exactly where to look in RAM). I then booted the MG6 ROM in Regen and went into WCI90. Upon seeing the SEGA logo, I went into the debugger and found that the vector was jumping to $C067A. Now we have enough information to make a single ROM that boots the version of WCI90 found within, and contains data for no other games.

    Since this copy of MG6 contains WCI90, I used the header from WCI90 as a base (as well as the bytes from $200-$205). I changed the vector at $04 from $00000206 to $000C0000, the vector at $78 from $000008BC to $000C067A, kept $200-$205 the same (4E714E7160FA, this is two NOPs and a relative BRAnch), inserted garbage data (recommended all set to a single value, not recommended to use actual garbage data) up until $BFFFF, and then the entire contents of the MG6 ROM from $C0000-$FFFFF. At this point, the ROM is finished and working (on a cursory search, it's not likely there's anything else useful for this game outside the $C0000-$FFFFF range). If you don't care about other games being in there (nor emulators displaying the correct game name), you can do this by just truncating the MG6 ROM at $100000 and fix the vectors I listed above.

    If your MG6 ROM is actually branded "Sega Soccer" then we must have a different revision, I'd need your copy of the ROM to redo what I did above.