sf30ac-extractor icon indicating copy to clipboard operation
sf30ac-extractor copied to clipboard

Question: Are the ROMs usable with any other emulators?

Open petmac opened this issue 6 years ago • 33 comments

Perhaps they're in a format specifically for the Digital Eclipse engine, or maybe they can be renamed or split/joined to work with FB Alpha or MAME.

Has anyone got them to work in another emulator?

petmac avatar Jun 01 '18 16:06 petmac

Never tried but here's some thoughts by the community:

  • https://twitter.com/zerojay/status/1001849683101257728
  • https://twitter.com/Super_Menteur/status/1001708747289452546
  • https://www.reddit.com/r/StreetFighter/comments/8n3pq7/sf30ac_assets_extraction_hq_music_hq_artwork/dztqw8l/

WydD avatar Jun 01 '18 20:06 WydD

Thanks!

petmac avatar Jun 01 '18 23:06 petmac

I've been having a look at this, only for "StreetFighterII" for the moment, which seems to be the "sf2ub" version of the game.

What I've found so far:

  • StreetFighterII.ub.68k does indeed correspond to these files, but where the MAME ROMs have files with only even bytes and files with only odd bytes (why?), the Anniversary Collection has interleaved them back together. Took a bit of head scratching, but I noticed it after a while.
  • StreetFighterII.z80 is sf2_9.12a
  • StreetFighterII.oki is sf2_18.11c and sf2_19.12c

I'm writing a script to convert the ROMs to MAME format, but I can't promise how far I'll get.

petmac avatar Jun 02 '18 23:06 petmac

Not sure if anyone has gotten this working but I've been poking around with split.py and got the code files to split properly (only changed two lines):

def split_code_file(dst_dir, dst_names, src_path, size): with open(src_path, "rb") as src: print(src_path) for (dst_even_name, dst_odd_name) in dst_names: print("\t" + dst_even_name + ", " + dst_odd_name) contents = src.read(size * 2) dst_even_path = os.path.join(dst_dir, dst_even_name) dst_odd_path = os.path.join(dst_dir, dst_odd_name) with open(dst_even_path, "wb") as dst_even: with open(dst_odd_path, "wb") as dst_odd: for i in range(size): even = contents[i * 2].to_bytes(1, byteorder='big') odd = contents[i * 2 + 1].to_bytes(1, byteorder='big') dst_even.write(even) dst_odd.write(odd)

While you can zip the split files and it does run in FB Alpha, the graphics are not split right. It's definitely possible, just need to figure out how to split the bytes correctly.

seanwiththebeard avatar Sep 03 '18 23:09 seanwiththebeard

I'm starting to think that the graphics have some kind of encryption. Looking at the VROM file with a hex editor I do see a pattern of bytes in blocks of four, so I do think they're interleaved one byte at at a time like the 68K code files. I can't say if the files are just out of order, none of the checksums line up.

This has been a fun puzzle but I don't think I'm getting much further myself. I don't know enough about CPS-1 data structures. CPS-2 is supposedly better documented? Maybe I'll poke around with Alpha.

Meanwhile, if I want to play the games in arcade resolution on my CRT cabinet, it looks like this. At least the pallets load from code and not VROM?

sf2ub-09-17-234536

seanwiththebeard avatar Sep 17 '18 23:09 seanwiththebeard

I know it's a year late, but here's some info that may come in handy:

MAME's file formatting is ALWAYS per-chip dumps named to match the socket on the board where labelled. In the case of CPS1 boards, there's interleaving going on. What you're looking for is going to be at http://wiki.pcbotaku.com/wiki/CPS2_rom_layout as it's a bit messy overall.

Firehawke avatar Jul 01 '19 04:07 Firehawke

Did you guys get any further with this? Annoyingly I’ve got as far as @petmac had in his comment before I realised!

ValadAmoleo avatar Sep 15 '19 10:09 ValadAmoleo

To be more specific, it's a four-way interleave not two-way. That's why you're getting garbled graphics.

Firehawke avatar Sep 18 '19 07:09 Firehawke

To be more specific, it's a four-way interleave not two-way. That's why you're getting garbled graphics.

Do you happen to have a modified version of the Python script to split it properly then? With a four-way interleave taken into account instead of a two-way interleave.

TopHatHipster avatar Dec 14 '19 10:12 TopHatHipster

I've been too busy with MAME-related stuff to write one. I'd hoped providing the missing info would inspire someone to finish up the last bit of work needed, but it seems there's not much interest.

Firehawke avatar Dec 15 '19 08:12 Firehawke

I've been too busy with MAME-related stuff to write one. I'd hoped providing the missing info would inspire someone to finish up the last bit of work needed, but it seems there's not much interest.

Well, I wouldn't mind finishing up said last bit of work necessary, however I fail to see how one would edit the two-way interleave part of the script into a four-way interleave version.

TopHatHipster avatar Dec 25 '19 00:12 TopHatHipster

Rather than the variables even and odd, you need a b c and d. I did try this but I don’t think the order was right, and I probably didn’t have the length to read right either. Is it interleaved bits, or bytes, or blocks of bytes?

seanwiththebeard avatar Dec 25 '19 00:12 seanwiththebeard

Rather than the variables even and odd, you need a b c and d. I did try this but I don’t think the order was right, and I probably didn’t have the length to read right either. Is it interleaved bits, or bytes, or blocks of bytes?

I'm sadly not sure at what interval said interleaving has taken place. What I found however, is a script someone else made (in Bash) to extract SNK 40th Anniversary's ROMs, which uses the same .mbundle formatting (wish someone would make this extractor work with that game for asset extraction, but I can't get it to work with that game myself) and apparently does something to the graphics parts of the games, if you look closely at the code of said script.

TopHatHipster avatar Dec 25 '19 00:12 TopHatHipster

The CPS1 VROMs are encoded, after decoding and splitting the Street Fighter II VROM it will almost match the sf2 MAME ROMs, there are only a couple of bytes that are different. I assume there are some little graphical changes in the collection. Here is my sample code:

def decode_cps1_gfx(data):
    buf = bytearray(data)
    for i in range(0, len(buf), 4):
        dwval = 0
        src = buf[i] + (buf[i + 1] << 8) + (buf[i + 2] << 16) + (buf[i + 3] << 24)

        for j in range(8):
            n = src >> (j * 4) & 0x0f
            if (n & 0x01):
                dwval |= 1 << (     7 - j)
            if (n & 0x02):
                dwval |= 1 << ( 8 + 7 - j)
            if (n & 0x04):
                dwval |= 1 << (16 + 7 - j)
            if (n & 0x08):
                dwval |= 1 << (24 + 7 - j)

        buf[i + 0] = (dwval)       & 0xff
        buf[i + 1] = (dwval >>  8) & 0xff
        buf[i + 2] = (dwval >> 16) & 0xff
        buf[i + 3] = (dwval >> 24) & 0xff
    return buf


def split_gfx_file(dst_dir, dst_names, src_path, size):
    with open(src_path, "rb") as src:
        print(src_path)
        for (dst_name_1, dst_name_2, dst_name_3, dst_name_4) in dst_names:
            print("\t" + dst_name_1 + ", " + dst_name_2 + ", " + dst_name_3 + ", " + dst_name_4)
            dst_path_1 = os.path.join(dst_dir, dst_name_1)
            dst_path_2 = os.path.join(dst_dir, dst_name_2)
            dst_path_3 = os.path.join(dst_dir, dst_name_3)
            dst_path_4 = os.path.join(dst_dir, dst_name_4)
            with open(dst_path_1, "wb") as dst_1:
                with open(dst_path_2, "wb") as dst_2:
                    with open(dst_path_3, "wb") as dst_3:
                        with open(dst_path_4, "wb") as dst_4:
                            for i in range(size // 2):
                                data = decode_cps1_gfx(src.read(8))
                                dst_1.write(data[0:2])
                                dst_2.write(data[2:4])
                                dst_3.write(data[4:6])
                                dst_4.write(data[6:8])

CPS2 games seems to need an additional shuffle of the data. You can find the code that have to be reversed here

CPS3 games just need to be splitted, no deinterleave or decoding needed. Same for Street Fighter I.

ghoost82 avatar Feb 25 '20 01:02 ghoost82

Genius, but now my code files aren't splitting properly, I'm still using an old copy of petmac's split.py with and without the block in my old post. It's been a while since I poked around with this so I'm probably missing something, but I think we have all the pieces now.

seanwiththebeard avatar Feb 25 '20 16:02 seanwiththebeard

Genius, but now my code files aren't splitting properly, I'm still using an old copy of petmac's split.py with and without the block in my old post. It's been a while since I poked around with this so I'm probably missing something, but I think we have all the pieces now.

I've added @ghoost82's code to @petmac's split.py as that was the code I'd also been messing around with.

https://github.com/ValadAmoleo/sf30ac-extractor/tree/mame

This should split Street Fighter II The World Warrior correctly for you.

ValadAmoleo avatar Feb 29 '20 09:02 ValadAmoleo

Genius, but now my code files aren't splitting properly, I'm still using an old copy of petmac's split.py with and without the block in my old post. It's been a while since I poked around with this so I'm probably missing something, but I think we have all the pieces now.

I've added @ghoost82's code to @petmac's split.py as that was the code I'd also been messing around with.

https://github.com/ValadAmoleo/sf30ac-extractor/tree/mame

This should split Street Fighter II The World Warrior correctly for you.

I tested your whole repo with SF30, and there's no MAME compatible SFII TWW files in the output folder, sadly. The original emulator files are only present (with the other assets extracted along with it).

Edit: Correction: I tested split.py and it output the correct files. My bad!

TopHatHipster avatar Feb 29 '20 09:02 TopHatHipster

Should now split all the Street Fighter III games too.

ValadAmoleo avatar Feb 29 '20 10:02 ValadAmoleo

All four now split correctly, but the code files for SF2UA are named as the "b" files. I couldn't run that one in FBA without renaming them all as "a" files. FBA recognizes all three CPS3 games as correct checksums but SF2UA is all different, but does run. SFIII3UR1worked when I renamed it to SFIII3.

seanwiththebeard avatar Mar 01 '20 19:03 seanwiththebeard

All four now split correctly, but the code files for SF2UA are named as the "b" files. I couldn't run that one in FBA without renaming them all as "a" files. FBA recognizes all three CPS3 games as correct checksums but SF2UA is all different, but does run. SFIII3UR1worked when I renamed it to SFIII3.

Just been through and validated SFIII3 again and it should actually be sfiii3nr1. Which is the Japan 990512 version. For some reason it hadn't occurred to me to check the Japanese versions and the closest match was sfIII3ur1.

Street Fighter 2 The World Warrior validates (using FB Neo) against sf2ub with the following errors:

• graphics ROM sf2-13m.4d has a CRC of 00F1835D (correct is 994BFA58). • graphics ROM sf2-15m.6d has a CRC of C1B85E35 (correct is 3E66AD9D). • graphics ROM sf2-9m.3d has a CRC of 4D872721 (correct is C1BEFAA8). • graphics ROM sf2-11m.5d has a CRC of 0EFB4EFC (correct is 0627C831).

while against sf2ua it has:

• essential program ROM sf2u_30a.11e has a CRC of 57BD7051 (correct is 08BEB861). • essential program ROM sf2u_37a.11f has a CRC of 4A54D479 (correct is B7638D69). • essential program ROM sf2u_31a.12e has a CRC of A673143D (correct is 0D5394E0). • essential program ROM sf2u_38a.12f has a CRC of 4C2CCEF7 (correct is 42D6A79E). • essential program ROM sf2u_28a.9e has a CRC of 4009955E (correct is 387A175C). • essential program ROM sf2u_35a.9f has a CRC of 8C1F3994 (correct is A1A5ADCC). • graphics ROM sf2-13m.4d has a CRC of 00F1835D (correct is 994BFA58). • graphics ROM sf2-15m.6d has a CRC of C1B85E35 (correct is 3E66AD9D). • graphics ROM sf2-9m.3d has a CRC of 4D872721 (correct is C1BEFAA8). • graphics ROM sf2-11m.5d has a CRC of 0EFB4EFC (correct is 0627C831).

It should still run either way using FB Neo (or lr-fbalpha2012 on a RetroPie).

ValadAmoleo avatar Mar 07 '20 13:03 ValadAmoleo

So for the layman, will this program give ROMs playable on Fightcade?

tydog98 avatar May 01 '20 14:05 tydog98

Thanks ValadAmoleo and WydD for your hard work so far. I've been able to run the Street Fighter III ROMS (which is great since that's why I bought Anthology two years ago) but there were some snafus I wanted to point out for any future travelers:

  • Remember to run the "mame" branch of ValadAmoleo's fork and run all the scripts (remember his version of tidy.py is different than the one in WydD's repo).
  • Street Fighter III: New Generation didn't work until I renamed "sfiii" to "sfiiina" and renamed "sfiii_euro.29f400.u2" to "sfiii_asia_nocd.29f400.u2"
  • Street Fighter III 2nd Impact - the directory produced is named "sfiii2" but didn't work in Mame until I named it "sfiii2n", and renamed the bios file to "sfiii2_asia_nocd.29f400.u2".
  • Third Strike didn't work until I renamed "sfiii3_usa.29f400.u2" to "sfiii3_japan_nocd.29f400.u2".

Also worth pointing out is you can change the region of the ROMS to USA so that Third Strike plays in English. In RetroArch this is in the emulator specific options menu available after you load the game (just reset it afterwards).

TimSimpson avatar May 27 '20 06:05 TimSimpson

I was able to use @TimSimpson's hints to run with retroarch and FB Neo except I only had to rename the zip names (e.g., sfiii --> sfiiina.zip when creating the zip). I did not have to rename any *.u2 files.

The end result is sfiiina.zip, sfiii2n.zip and sfiii3nr1.zip.

namtsui avatar Jul 09 '20 15:07 namtsui

Thanks all. I've corrected the SF3 names and pushed the changes to my MAME branch. They now all validate with FinalBurn Neo correctly.

ValadAmoleo avatar Jul 09 '20 15:07 ValadAmoleo

Thanks to @reubenajohnston we can now extract the Street Fighter II': Champion Edition, Street Fighter II': Hyper Fighting and the original Street Fighter! sf2ceua and sf2t are compatible with up to MAME 2007. While sf is compatible with FinalBurn Neo.

I've merged their changes into my branch along with only minor changes.

Update: Since then I've done further changes. If you're just interested in extracting the roms you can now extract the files to the Street Fighter 30th Anniversary Collection directory and run ConvertSF30th.py.

Update 2: Noticed there'd been a merge on Master (by ghoost82) from ages ago which allowed it to extract SNK 40th Anniversary. Thought it'd be nice for split.py to work on this too. So I've started implementing it. Currently only extracts Beast Busters (bbusters). Code really needs to be refactored now because it's getting messy.

ValadAmoleo avatar Oct 04 '20 14:10 ValadAmoleo

I've now refactored the code. Python isn't my main language so I've probably made a few faux pas but I'm much happier with it now. Only thing I want to do is split up split.py but I think having more files might make it more difficult for the end user so I will leave it as is for now. End user should only notice that the console output is friendlier now.

ValadAmoleo avatar Oct 05 '20 12:10 ValadAmoleo

Thanks to @reubenajohnston we can now extract the Street Fighter II': Champion Edition, Street Fighter II': Hyper Fighting and the original Street Fighter! sf2ceua and sf2t are compatible with up to MAME 2007. While sf is compatible with FinalBurn Neo.

I had the same results while testing the latest updates to @ValadAmoleo's repo. I was able to play these roms using retroarch with FBNeo and mame2003 cores. All of these were tested to work on OpenBSD with WIP ports of these cores built from their respective repos.

https://github.com/libretro/FBNeo https://github.com/libretro/mame2003-libretro

fbneo: sf, sfiii2n (2nd Impact), sfiii3nr1 (3rd Strike), sfiiina (New Generation) mame2003: sf2ceua (Championship Edition), sf2t (Hyper Fighting), sf2ub (The World Warrior)

namtsui avatar Oct 07 '20 09:10 namtsui

Update 2: Noticed there'd been a merge on Master (by ghoost82) from ages ago which allowed it to extract SNK 40th Anniversary. Thought it'd be nice for split.py to work on this too. So I've started implementing it. Currently only extracts Beast Busters (bbusters). Code really needs to be refactored now because it's getting messy.

Have you all seen this list of the 40th offsets? https://gitlab.com/vaiski/romextract/-/blob/master/scripts/STEAM-865940.sh

reubenajohnston avatar Oct 07 '20 13:10 reubenajohnston

Update 2: Noticed there'd been a merge on Master (by ghoost82) from ages ago which allowed it to extract SNK 40th Anniversary. Thought it'd be nice for split.py to work on this too. So I've started implementing it. Currently only extracts Beast Busters (bbusters). Code really needs to be refactored now because it's getting messy.

Have you all seen this list of the 40th offsets? https://gitlab.com/vaiski/romextract/-/blob/master/scripts/STEAM-865940.sh

I updated my fork with this yesterday, I just forgot to mention I'd done it. Thanks though!

ValadAmoleo avatar Oct 07 '20 13:10 ValadAmoleo

Thanks to the research done by @reubenajohnston, my fork can now convert samsho 1-4 from the Samurai Shodown Collection.

Edit: That's assuming you have a NEO GEO BIOS. I totally forgot to convert that. Ack!

Update: Okay latest commit also extracts the BIOS now.

ValadAmoleo avatar Oct 08 '20 18:10 ValadAmoleo