Author Topic: sf3:3rd strike widescreen  (Read 41248 times)

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
sf3:3rd strike widescreen
« on: October 27, 2021, 11:05:09 AM »
as you may or may not be aware, the sf3 cps3 engine has widescreen capability built in, of which different games take advantage to differing degrees. sf3:2nd impact has an explicit soft DIP switch "WIDE" that can be enabled which changes the game's width from 384 pixels to 496 pixels. this can be enabled easily in FBNeo by going to the input menu->Set dipswitches... and change 'Screen mode' to Wide. you can see a video of widescreen 2i in action here: https://youtu.be/39ggq3T_K_o

sf3 new generation also has this functionality available, but there is no soft DIP switch in the operator's menu. it can be enabled in FBNeo in the same manner from the input menu. it's 16:9 aspect ratio, although unlike 2nd impact there are some visual issues here or there, like for example in Ibuki's stage some foreground graphic will pop in and out depending on the X position of the players.

sf3: 3rd strike also has this functionality available, but there is no soft DIP switch, and also no "Set dipswitches" functionality in FBNeo. Why? it seems for two reasons:
1) unlike with NG and 2I, Capcom did not enable the logic which permits the players to walk beyond the 4:3 X position boundaries. so even when this mode is enabled for 3s, the players are still "stuck" within the boundaries of the vanilla game. for this reason, I think the FBNeo devs decided that it wasn't worth it for players to play this way (which makes total sense!).
2) unlike with NG and 2I, Capcom did not modify the HUD depending on whether the game is running in vanilla or wide mode. so the player's meters and health are all scrunched up on the left side of the screen.

So my idea is to do a hack which will accomplish the following, in order of priority:
*permanently enable the wide mode by modifying the BIOS ROM region (necessary for anything else)
*remove the X position playfield boundaries when the game is running in wide mode
*improve/replace the HUD, either by solely changing the X positions (they would be relatively small looking) or by outright replacing the graphics (and probably modifying the X position as well)

I think that these are fairly modest goals and they are within my capabilities. so let's look at my todo list:

1) because displaying these games requires the emulator to modify the video output properties, I need a custom build of MAME. if we inspect the cps3 driver source here
https://raw.githubusercontent.com/mamedev/mame/master/src/mame/drivers/cps3.cpp
we can see layout info for 2i:
Code: [Select]
GAMEL(1997, sfiii2,      0,        sfiii2,   cps3,      cps3_state, init_sfiii2,   ROT0, "Capcom", "Street Fighter III 2nd Impact: Giant Attack (USA 970930)", MACHINE_SUPPORTS_SAVE, layout_sfiii2 ) // layout is for widescreen support
GAMEL(1997, sfiii2j,     sfiii2,   sfiii2,   cps3,      cps3_state, init_sfiii2,   ROT0, "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Japan 970930)", MACHINE_SUPPORTS_SAVE, layout_sfiii2 )
GAMEL(1997, sfiii2n,     sfiii2,   sfiii2,   cps3,      cps3_state, init_sfiii2,   ROT0, "Capcom", "Street Fighter III 2nd Impact: Giant Attack (Asia 970930, NO CD)", MACHINE_SUPPORTS_SAVE, layout_sfiii2 )

see that "layout_sfiii2" flag? that's not present for NG or 3s. so I need to build MAME with that flag present for the 3s entries, because I need MAME for the SH2 debugger. for compiling FBNeo with these 3s changes, you need to do the following (thanks barbudreamon!):
Code: [Select]
replace euroDIPInfo by sfiiiwideeuroDIPInfo at https://github.com/finalburnneo/FBNeo/blob/master/src/burn/drv/cps3/d_cps3.cpp#L1562
I have only ever compiled FBNeo, so it should be a good learning experience to compile another emulator after making some modifications (I am not an expert in anything, these hacks are a good way to learn).

2) I need to develop some better tools. for example, the NEO*GEO binary I was modifying for the kof98ratio mod was interleaved amongst 2 files. the CPS3 binary, however, is interleaved amongst *4* files. the binman utility I've been using ( https://www.jammarcade.net/binman-utility/ ) has been super handy, but I'm not sure if I'm able to use it to interleave / de-interleave 4 files. I think this should be pretty straightforward to write myself in C, I should learn it. here's some examples I found https://unix.stackexchange.com/questions/140563/how-to-interleave-the-lines-of-two-or-more-files .

3) once I have custom MAME, I need to decrypt the 3s BIOS (using XCOPY) and permanently enable the widescreen mode by modifying the upper nibble of the region from 0 to 9, and then re-encrypting the BIOS. this should be trivial.

progress I've made thus far:
I used MAME debugger's SAVE command to get a dump of the binary. I loaded that in ghidra and everything matches up correctly, so that's all good news.

CPS3 ROMs are encrypted. I am using the program "X.C.O.P.Y." to decrypt and re-encrypt, however only two of the four files that I decrypted seemed to match up with the dumped binary, so that's a bit confusing. need to do more research on this one. I think writing a program in C to do the encryption/decryption could be a bit out of my league, although the source is definitely available in FBNeo and MAME so maybe it's just a matter of copying and pasting and adding some file i/o.

my dream workflow would be to execute one .BAT file that could re-interleave and re-encrypt and then run - but since the project is relatively low in scope I could deal with having to manually deal with GUI programs like XCOPY and binman if I needed to.

so anyway, very little sexy progress to report here, this is just the very beginning of things. hopefully I will have something more interesting to report soon. thank you for reading!

Offline barbudreadmon

  • Administrator
  • *****
  • Posts: 1133
  • Karma: +60/-2
  • Helper
Re: sf3:3rd strike widescreen
« Reply #1 on: October 27, 2021, 01:49:19 PM »
1) unlike with NG and 2I, Capcom did not enable the logic which permits the players to walk beyond the 4:3 X position boundaries. so even when this mode is enabled for 3s, the players are still "stuck" within the boundaries of the vanilla game. for this reason, I think the FBNeo devs decided that it wasn't worth it for players to play this way (which makes total sense!).

That's indeed the reason i didn't enable the widescreen dips for sfiii3 :).
Good luck with this new hack, we'll be happy to add it !

Offline dink

  • Administrator
  • *****
  • Posts: 5123
  • Karma: +455/-1
  • pie? I nearly bought one!
Re: sf3:3rd strike widescreen
« Reply #2 on: October 27, 2021, 02:06:55 PM »
Wow, that sounds incredible - best of luck on your project :)

best regards,
- dink

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #3 on: October 28, 2021, 04:18:42 AM »
huge thanks to TVIndustries, we now have python scripts for both the process of decrypting and merging and encrypting and splitting:

https://github.com/Strugglemeat/3stools/

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #4 on: October 28, 2021, 09:35:33 AM »
thanks to yoshin222 for supplying me with a bunch of memory addresses for 2i and 3s. in 2i, the X position max/min for P1 aren't affected by the 4:3/wide setting.

I got MAME compiled with what I think are the necessary changes, now I'm trying to figure out how to properly decrypt the BIOS.
« Last Edit: October 28, 2021, 09:54:14 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #5 on: October 29, 2021, 04:05:49 AM »
I was able to enable widescreen 3S in current FBNeo by going into Map Game Inputs -> change region from 0x03 to 0x93.
so now I'm pretty confused, because I have a decrypted 3S BIOS, I have changed the region byte from 0x03 to 0x93, replace the BIOS file, load it in MAME, and it does not enable widescreen. it seems like there's something else I need to do to get it to take.

at https://github.com/finalburnneo/FBNeo/blob/4f18905a2f7cfe3b40a51454424ad86ddb2adebe/src/burn/drv/cps3/d_cps3.cpp#L1378
we can see
Code: [Select]
cps3_region_address = 0x0001fec8 but I think this is referring to a longword. looking at 1fec8 in MAME memory viewer we can see
Code: [Select]
30 20 20 93 (the 93 is set from my modded BIOS). so I think the byte for BIOS is at 0x1fecb. this is confirmed by inspecting MAME cheat .ini files - they are modifying 0x1fecb.

edit - goodies from barbudreadmon:

https://github.com/finalburnneo/FBNeo/commit/58193128db1d48f62c9740ce5953906892d5a644#diff-b90a4e5bd9895fe57c50572183c6bc44cc4f222750d7519c117c8c0aaaf1ef28

Quote
so actually, it needs to be applied when the game is already running

https://github.com/finalburnneo/FBNeo/commit/1def4f08e8da1a36d5a5b59655d805a9cddd1b6c

Code: [Select]
INT32 cps3Frame()
{
// feels a bit hacky, and sfiii2 can change mode without resetting through its service menu,
// so maybe there is a better way to do this ?
// sfiii3 got that mode too, but it's heavily glitched so let's keep it hidden -barbudreadmon
if ( cps3_region_address ) {
if ((cps3_dip&0x80) == 0x80 && (RomBios[cps3_region_address]&0x80) != 0x80) {
cps3_reset = 1;
RomBios[cps3_region_address] |= 0x80;
}
else if ((cps3_dip&0x80) != 0x80 && (RomBios[cps3_region_address]&0x80) == 0x80) {
cps3_reset = 1;
RomBios[cps3_region_address] &= ~0x80;
}
}
« Last Edit: October 29, 2021, 09:45:21 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #6 on: October 29, 2021, 12:21:50 PM »
I figured out the situation. I ran 2i wide and 2i vanilla and compared the eeprom. then I applied the two bytes that were changed in 2i wide to the 3s eeprom and voila! I was using BIOS which set region to 0x9y but not even sure if that was necessary or not.

so now I have 3s wide in mame and I can do my hacking, oh joy.

Offline KaaMoS

  • Member
  • ***
  • Posts: 136
  • Karma: +1/-0
Re: sf3:3rd strike widescreen
« Reply #7 on: October 29, 2021, 04:06:27 PM »
Pretty cool project, @bankbank. Liked so much :)
Is interesting to see that guard bars/avatars at the top got wider. Have you moved/edited them as well?
« Last Edit: October 29, 2021, 04:08:10 PM by KaaMoS »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #8 on: October 29, 2021, 09:53:52 PM »
Is interesting to see that guard bars/avatars at the top got wider. Have you moved/edited them as well?

hi KaaMoS. the screenshot you are referring to might be 2nd Impact, which has a built-in widescreen mode. I haven't changed anything in 3rd Strike yet. thanks for your enthusiasm!

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #9 on: October 31, 2021, 04:16:25 AM »
bpset 611e016, 1, { r3 = 0xff; g}
this only works for the left side and it affects BOTH players, but making progress
« Last Edit: October 31, 2021, 04:17:30 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #10 on: October 31, 2021, 12:07:25 PM »
I fixed the X position boundaries for the players. next up is the HUD X positions.

https://www.youtube.com/watch?v=FuBcWasuP5k

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #11 on: November 01, 2021, 02:20:03 AM »
gonna write out the issues with each stage here

Yang - no issues
Remy - no issues
Yun - no issues
Urien - no issues
Sean - no issues
Oro - no issues

Dudley
*foreground / background object pop in/out (both sides)

Necro
* background object pop in/out (crane in middle)

Ibuki
* bg obj pop

Makoto
* bg/fg obj pop

Hugo
* bg obj pop

Ken
* bg obj pop

Alex
* bg/fg obj pop

Gouki
*fg obj pop

Q
*foreground / background object pop in/out (right side of stage)

Ryu
*right side background has black area
*background tree object pop in/out

Chun-Li
* left side of stage has black
* bg/fg obj pop

Elena
* left side of stage has black
* bg/fg obj pop

Twelve
* left side of stage has black
* bg obj pop (crane)
« Last Edit: November 02, 2021, 02:30:03 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #12 on: November 01, 2021, 04:35:05 AM »
HUD modding is well underway

bp 60d5cd8, r5>260, {r5+=0x38;g}
bp 60d5e22, r4>20, {r4+=0x38;g}
« Last Edit: November 02, 2021, 02:28:59 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #13 on: November 02, 2021, 06:55:38 AM »
an update - made a lot of progress on tile placement, both dynamic and static. planning on centering the timer and probably enlarging the HP bars.

attached is a handy bit of info for people who want to modify the SS tiles
« Last Edit: November 02, 2021, 06:59:18 AM by bankbank »

Offline bankbank

  • Newbies
  • *
  • Posts: 32
  • Karma: +3/-0
Re: sf3:3rd strike widescreen
« Reply #14 on: May 26, 2022, 10:40:52 AM »
it's been quite a while since I've posted an update here. I'm pleased to share some progress.

regarding the HUD, it is completely fixed! it took an incredible amount of time and effort. I'll attach my latest work spreadsheet for anyone who's curious at taking a peek.

a wonderful tester discovered a couple bugs: Makoto's SA2 (where she jumps up and grabs the wall) and Twelve's airdash wallgrab were both grabbing thin air. these two problems have been fixed.

I just spent a bunch of time looking into the super art kill flash... it seems that the only solution will be to replace/update the existing graphic. as I have never modified any graphics in any game, I've decided to save that one until last.

next up I am going to looking into the object pop in/out in the foreground and background. and then after that I'll tackle the edges of the stages that are missing graphics - that issue should be similar to the super art flash kill image problem.

here's a funny little breakpoint:
Code: [Select]
bp 06124c84,1,{r12=00;g}and here's some screenshots, enjoy!