Welcome!

Miscellaneous => Projects => Topic started by: bankbank on October 27, 2021, 11:05:09 AM

Title: sf3:3rd strike widescreen
Post by: bankbank 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!
Title: Re: sf3:3rd strike widescreen
Post by: barbudreadmon 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 !
Title: Re: sf3:3rd strike widescreen
Post by: dink on October 27, 2021, 02:06:55 PM
Wow, that sounds incredible - best of luck on your project :)

best regards,
- dink
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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/
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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.
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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;
}
}
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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.
Title: Re: sf3:3rd strike widescreen
Post by: KaaMoS 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?
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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!
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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)
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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}
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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
Title: Re: sf3:3rd strike widescreen
Post by: bankbank 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!
Title: Re: sf3:3rd strike widescreen
Post by: barbudreadmon on May 26, 2022, 01:49:12 PM
nice progress :)
Title: Re: sf3:3rd strike widescreen
Post by: dink on May 26, 2022, 05:45:50 PM
Wow this is great!  Nice work bankbank!!

best regards,
- dink
Title: Re: sf3:3rd strike widescreen
Post by: bankbank on June 17, 2022, 05:49:25 AM
made some lovely progress after a long, long process of trying to figure out the popping in/out of objects in the foreground and background of several stages
bp 60b644e,1,{r6=FF07;g}
bp 60b6452,1,{r3=ee;g}

regarding object pop in/out, I just need to make some small adjustments on Ken, Alex, and Elena's stages and then this aspect of the hack is all done. after that there's really just two more things to change:
A) far edge stage boundaries for some characters have black or incomplete graphics. I'll probably adjust stage boundary coordinates rather than trying to modify the graphics. much cleaner solution
B) as detailed previously, several graphics which take up the entire width of the screen in 4:3 mode need to be adjusted. most pressing is the super KO flash.

progress video here: https://youtu.be/HOElBwfY7eI

I've also attached my working spreadsheet .xls file here for anyone who's interested.

@barbudreadmon I wonder if it will possible to get you to help me to add this 3rd Strike Widescreen hack to FBNeo once it's complete? there's some complications due to FBNeo's implementation of widescreen in CPS3
https://github.com/finalburnneo/FBNeo/commit/1def4f08e8da1a36d5a5b59655d805a9cddd1b6c
https://github.com/finalburnneo/FBNeo/commit/58193128db1d48f62c9740ce5953906892d5a644#diff-b90a4e5bd9895fe57c50572183c6bc44cc4f222750d7519c117c8c0aaaf1ef28

I have hacked the sfiii3nr1 binary so that the game no longer checks the nvram for the widescreen toggle - the hack will always, no matter what launch into widescreen. and, unfortunately, now the hack hangs at the initial boot text (which is around where the nvram loading is). I assume this is due to the way FBNeo works with CPS3 wide, as referenced in the two github links above. If you would be so kind to accommodate my hack (which hopefully lots of people will play but who knows), I would be very greatful. I can provide you with the modified binary on discord or a patch on here.
Title: Re: sf3:3rd strike widescreen
Post by: barbudreadmon on June 17, 2022, 08:28:22 AM
@barbudreadmon I wonder if it will possible to get you to help me to add this 3rd Strike Widescreen hack to FBNeo once it's complete?

Sure :), you can ping me on discord when you are done.
Title: Re: sf3:3rd strike widescreen
Post by: bankbank on July 01, 2022, 08:01:19 AM
Sure :), you can ping me on discord when you are done.

merci! barbudreadmon was so kind as to add the mod to FBNEO:
https://github.com/finalburnneo/FBNeo/commit/6dd253cbe092116e147b68ee20ea9a1c7bb79989
Title: Re: sf3:3rd strike widescreen
Post by: dink on July 01, 2022, 09:01:01 AM
Awesome, nice work bankbank! :D
Title: Re: sf3:3rd strike widescreen
Post by: bankbank on September 08, 2022, 03:45:03 AM
anyone here have insight into how cps3/3s stores data in vram?
I have found the function which loads/decompresses the tile data
and DrewDos found where the tile data resides (compressed) in the ROM
but I can't find where it writes decompressed tile data to / where it can be read from

I have fixed the white part of the super ko flash since I was able to just modify the tilemap and to change the all-black tiles to all-white tiles
but for fixing the super ko flash graphical parts, I need to put new graphics data in the ROM and then in VRAM and reference with more modified tilemap
I just can't figure out where the tiles are in VRAM
anyone?
Title: Re: sf3:3rd strike widescreen
Post by: dink on September 08, 2022, 09:22:12 AM
bankbank, Most stuff makes it into vram via dma, from both the sh2 cpu and the cps3 board also has another dma controller to do palette, sprite and character dma.
To get the addresses from where this stuff is coming from, you'd need to edit the driver and uncomment all of the logging in the dma (chr,pal,sprite) functions, as well as in the sh2 cpu's dma function - as the logging stuff is there but commented out.  One could also watch the dma addresses without recompiling anything.  Look for dma_w in cps3_map in the current mame driver.

best regards,
- dink
Title: Re: sf3:3rd strike widescreen
Post by: Netro on October 17, 2022, 09:57:41 PM
Within all this great work you guys are doing, is it possible to disable the hud elements for 3rd strike, as well as the background?
Title: Re: sf3:3rd strike widescreen
Post by: dink on October 17, 2022, 11:35:34 PM
most likely: you'd have to hack the cps3 code, and have it only draw the sprites.
Title: Re: sf3:3rd strike widescreen
Post by: barbudreadmon on October 18, 2022, 08:51:36 AM
If that result is what you are looking for, you can reach it pretty easily by disabling layer 1 & 2 in our UI
Title: Re: sf3:3rd strike widescreen
Post by: bankbank on December 22, 2022, 08:38:04 AM
minor update here with some good news and some bad news

the good news is that the hack runs on real CPS3 hardware

the bad news is that the right side of the background tiles are not updating (see attached screenshot)

this behavior is different from what we observe when the hack is played in FBNeo, where the background tiles are drawn correctly

when I set widescreen to permanently on through modification of the binary, perhaps I only did it partially. there's also a chance that I need to update a routine to draw to that area.

it's important to me that this thing works on real hardware, so I'm going to tackle the issue eventually
Title: Re: sf3:3rd strike widescreen
Post by: dink on December 22, 2022, 11:50:28 PM
bankbank, love what you're doing - keep it up :)
While I can't be much help with real hw, just wanted to say that the way it stops drawing tiles is a curiosity. 

good luck!
best regards,
- dink