Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SF2X/CPS2: launching a core too fast produces visual artifacts #561

Open
SuperKeeks opened this issue Feb 24, 2024 · 21 comments
Open

SF2X/CPS2: launching a core too fast produces visual artifacts #561

SuperKeeks opened this issue Feb 24, 2024 · 21 comments
Labels
core bug Something isn't working

Comments

@SuperKeeks
Copy link

If launching a core very quickly after booting the system, the game shows with visual artifacts. An easy way to repro is to use the bootcore=lastcore option (which launches the game in 10 seconds)

This happens in Street Fighter 2X but it likely affects other CPS2 cores as well.

If waiting 15-20 seconds before launching the core, the issue doesn't happen.

image

image

image

@SuperKeeks SuperKeeks changed the title SF2X/CPS2: launching a core too fast produce visual artifacts SF2X/CPS2: launching a core too fast produces visual artifacts Feb 24, 2024
@jotego jotego added the core bug Something isn't working label Feb 24, 2024
@paulb-nl
Copy link
Contributor

It is not just launching a core too fast. It also happens when loading a certain core before SSF2.

Loading Karnov's revenge in the NeoGeo core will result in massive glitches and flickering in the SSF2 games when loading them afterwards.

Here is a video where SSF2 is working normally and then I start the NeoGeo core:
https://youtu.be/N-a2xj3a_v8

@jotego
Copy link
Owner

jotego commented Feb 25, 2024

The game does not clean up the memories, neither does the hardware. But it should eventually overwrite old values. I wonder if this is related to the game data download being performed through the DDR memory.
CPS2 is the only jtcore that uses the DDR download in order to speed up the ROM download. I think the NeoGeo core does it too. Maybe it is related to that.
I think you can disable it without recompiling the core by taking away the address="0x30000000" text in the mra file.
Could you try that and let me know how it goes, please?

@SuperKeeks
Copy link
Author

I tried removing the address text. Game loads much slower, but issue still occurs :(

@jotego
Copy link
Owner

jotego commented Feb 26, 2024

I tried removing the address text. Game loads much slower, but issue still occurs :(

Thank you

@paulb-nl
Copy link
Contributor

The game does not clean up the memories, neither does the hardware

At least the games test Object and Work RAM so when those tests are finished the RAM should have the same contents every time.

@jotego
Copy link
Owner

jotego commented Feb 26, 2024

At least the games test Object and Work RAM so when those tests are finished the RAM should have the same contents every time.

That's a good point. But if Ryu's silhouette can be seen in those scenes, there must be some wrong data in memory. It could be a MMR (device register), but I cannot think of something that could produce that silhouette effect

@SuperKeeks
Copy link
Author

I've uploaded the issue in video form in case it's useful https://youtube.com/shorts/sNsjTJykaDI?si=7DmcBiZeseXO3Jkh

@paulb-nl
Copy link
Contributor

After some testing I determined that there are no glitches if the first bank (8MB) of SDRAM is cleared before starting the game.

Only clearing 1MB at 0x500000 removes most of the glitches on the left half of the screen. What does the core use at that offset?

@jotego
Copy link
Owner

jotego commented Feb 27, 2024

Thank you for looking into it. You must be clearing the object RAM, which agrees with the images as what we see is wrong objects (sprites) displayed.

@paulb-nl
Copy link
Contributor

If I interpret your source correctly then Video RAM and Object RAM are at 0x200000 and 0x280000.

VRAM_OFFSET = 23'h20_0000,
ORAM_OFFSET = 23'h28_0000,

Clearing only those offsets has no effect on the glitches.

I don't know what is at 0x500000. Is it the M68K ROM?

@jotego
Copy link
Owner

jotego commented Feb 27, 2024

I think those offsets are referred to 16-bit words, whereas you're probably counting bytes. If you multiply by two, 0x28'0000*2=0x50'0000
How are you clearing it? By adding a part in the MRA?

@paulb-nl
Copy link
Contributor

I cleared it with the Menu core. I modified it so I could select which part of SDRAM can be cleared.

Ok so clearing Object RAM helps a bit but does not remove all glitches.

I have found with Mame that this game only clears 0x0000 - 0x1C4F of both Object RAM banks. For 0x1C50 - 0x1FFF it reads the value then writes 0x00 and then writes the old value back.

@jotego
Copy link
Owner

jotego commented Feb 28, 2024

I cleared it with the Menu core. I modified it so I could select which part of SDRAM can be cleared.

In principle, it is possible to have the MRA overwrite that region on start up. But I am not sure whether it will work with the current core as cores often do address transformations while downloading the MRA data

Ok so clearing Object RAM helps a bit but does not remove all glitches.

Maybe the regular VRAM also has the same problem?

I have found with Mame that this game only clears 0x0000 - 0x1C4F of both Object RAM banks. For 0x1C50 - 0x1FFF it reads the value then writes 0x00 and then writes the old value back.

I would need to check if that part of the object RAM is meant to be special. Maybe the object MMR go there. I do not remember off the top of my head. MMR sometimes cannot be read back and I do not implement the reading. Maybe in this case reading is supported and not implemented (?). I'd need to check it.

@paulb-nl
Copy link
Contributor

Some more testing in Mame:

Filling Video RAM or 0xFF0000 RAM with random values shows no glitches.
Filling Object RAM with random values shows massive glitches in Mame like we see in the core. Filling with 0x00 or 0xFF values shows no glitches.

Hyper SF2 also only clears Object RAM up to 0x1C4F but is not affected because it places the 0x8000 last sprite indicator in Object RAM which SSF2 does not.

X-men vs SF clears Object RAM completely.

So it appears that SSF2 expects uninitialized Object RAM to have certain values.

I think the Menu core that I modified is somehow not clearing Object RAM completely when writing 0x00 to 0x500000-0x5FFFFF.

In principle, it is possible to have the MRA overwrite that region on start up. But I am not sure whether it will work with the current core as cores often do address transformations while downloading the MRA data

Clearing Object RAM in the core itself seems like a better idea.

@jotego
Copy link
Owner

jotego commented Mar 13, 2024

@jotego jotego closed this as completed in 581875c May 12, 2024
@jotego
Copy link
Owner

jotego commented May 12, 2024

I cannot quite reproduce this issue but I have added logic to clear up the object RAM during reset in 581875c, which follows @paulb-nl findings about this.

Let me know if you see it again. The files will be published next JTFRIDAY.

@SuperKeeks
Copy link
Author

Cool, I'll try when I can after it's published and will update this thread with the results. Thanks!!

@paulb-nl
Copy link
Contributor

I wanted to test the updated core but the cores update on friday were built from commit 4f7da4b which is from May 11th, before you committed the fix.

@jotego
Copy link
Owner

jotego commented May 20, 2024

@paulb-nl you can use this one to test it:

jtcps2.rbf.zip

@paulb-nl
Copy link
Contributor

Thank you for the test build. Unfortunately the issue remains.

Looking at your fix, it seems you are clearing a copy of the Object RAM which is in BRAM. BRAM is always cleared to 0 during loading of the FPGA bitstream so that is not needed.

What needs to be cleared is Object RAM in SDRAM:

.SLOT2_AW ( 13 ), // Object RAM - read only access
.SLOT2_DW ( 16 ),
.SLOT2_LATCH ( OBJ_LATCH ),
.SLOT2_DOUBLE( 1 ),
.SLOT2_OFFSET( ORAM_OFFSET ),

Reproducing this is easy. Load Karnov's revenge in the Neo Geo core and then load SSF2.

@jotego jotego reopened this May 21, 2024
@jotego
Copy link
Owner

jotego commented May 21, 2024

I see. Thank you. I will tackle this when executing #511 then as it will be easier to do when full SDRAM framework is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core bug Something isn't working
Projects
Status: 🙋‍♂️ Backlog
Development

No branches or pull requests

3 participants