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

video/epic12.cpp: Fix clipping of CV1K games #11227

Merged
merged 1 commit into from
May 13, 2023
Merged

Conversation

buffis
Copy link
Contributor

@buffis buffis commented May 13, 2023

Change clipping for CV1K games to draw 32 pixels surrounding the visible area.

This can be easily seen in Muchi Muchi Pork, which has a VRAM viewer in Special mode (Object Test), which will show 32 px drawn around the visible areas of framebuffers.
See: https://www.arcade-projects.com/threads/research-into-cv1000-blitter-performance-and-behavior.24385/#post-364121

For most gamers, this wont really matter at all... except for in Muchi Muchi Pork, where changing this actually fixes a bug for Rafute (yellow ship).

When Bombing with Rafute (not the other two character), the screen background will go wavy in a sine-like pattern. Currently in mame, the top of screen will show black pixels when this happens.

Like this: http://img.buffis.com/mmppatch/without_patch.png

With this fix for clipping, the background will instead be visible correctly.
Like this: http://img.buffis.com/mmppatch/with_patch.png

Theres still some potential for artifacts though, both at top and on right side of screen... but this happens on PCB too.

Mame with patch, top artifact: http://img.buffis.com/mmppatch/mame_top_artifacts.png
Mame with patch, right artifact: http://img.buffis.com/mmppatch/mame_top_artifacts.png

PCB top artifact: http://img.buffis.com/mmppatch/pcb_top.jpg and http://img.buffis.com/mmppatch/pcb_top2.jpg
PCB right artifact: http://img.buffis.com/mmppatch/pcb_right.png

PCB footage of some bombs for reference: http://img.buffis.com/mmppatch/pcb_footage.mp4

Also renamed the "scroll registers" to have it more clear which one of these are actually used as a "scroll register" (or rather offset for drawing), and which one is strictly used for clipping.

Change clipping for CV1K games to draw 32 pixels surrounding the visible area.

This can be easily seen in Muchi Muchi Pork, which has a VRAM viewer in Special mode (Object Test), which will show 32 px drawn around the visible areas of framebuffers.

For most gamers, this wont really matter at all... except for in Muchi Muchi Pork, where changing this actually fixes a bug for Rafute.

When Bombing with Rafute, the screen background will go wavy in a sine-like pattern. Currently in mame, the top of screen will show black pixels when this happens.

With this fix for clipping, the background will instead be visible correctly.

Also renamed the "scroll registers" to have it more clear which one of these are actually used as a "scroll register" (or rather offset for drawing), and which one is strictly used for clipping.
@ajrhacker ajrhacker merged commit dc7a43d into mamedev:master May 13, 2023
@dinkc64
Copy link

dinkc64 commented May 27, 2023

@buffis Hi, wanted to let you know about an issue with your new blitter timing code and Mushihime-Sama Futari 1.5, this bug discovery is by el_rika

Game settings: Maniac Mode, w/ Reco (Normal)
Issue: the level 3 boss (beetle), should slow-down spastically if you tap shot, but with new blitter timing, it remains full speed.

PCB Proof: https://www.youtube.com/watch?v=gg53yGaRXHQ

Notice slowdown when shot is tapped, starting @
15:39 - 15:42
15:45 - 15:50
16:06 - 16:12

Get there in MAME easily: using Pugsy's cheat.7z, start the game w/above settings then go into cheat menu and select P1 Invincibility & Maximum firepower. hold down ffwd (insert key) and fire until you get to st.3's boss, as the boss starts shooting at you, pulse fire once. .. or play normal if feeling inclined :)
The boss should slow down as long as your bullets remain on the screen. It can be done with like-pcb slowdown using the old blitter in unsafe mode @ 57% blitter delay. Using your new timing (including the clipping fix), there is no slowdown at all. (Adjusting CPU speed doesn't help)

Second Issue:
Same game & settings, level 1: a few seconds before the T-Rex boss there is "way too much" slowdown with the new blitter timing - The game comes to a crawl almost. On the pcb video above, you can see there is no slowdown at this point between 3:11 - 3:19

best regards,

  • dink

@buffis
Copy link
Contributor Author

buffis commented May 27, 2023

@dinkc64 Hi!

I don't think there's any bug here really. See below.

I did some checks on S1 boss, and here's an example. It's probably not lined up frame-by-frame, but it should work ok as a comparison.
https://youtu.be/R6NHQYSd5iE

Looks alright to me.

In this example, left is playing with the new blitter code in MAME. Right is PCB footage that you linked. MAME is faster here, but thats due to the PCB player hitting a big cancel which causes more gem slow down. I have been unable to reproduce anything that seems particularily broken here.

Regarding S3 boss, I can have a look, but in terms of missing slowdown, it's very plausible that it could be due to the lack of SH3 Wait state emulation. For many games, this is a bigger factor than blitter, and there's no way to set it up to match pcb currently.

It should probably be mentioned that the new Blitter code is not perfect (see TODO's and comments in #10849), so if this is in fact blitter related slowdown, it can be due to being right at the edge of it triggering, and the edge cases being sufficient to make a difference. That's not really unexpected. Either way it is significantly better than the previous logic which had very little to do with hardware behavior :)

I do appreciate people looking at it though. I looked up el_rikas videos on youtube, and it does look like he is not using mame, but instead fbneo on some gameboy-looking device, so i cant really say much if that has any impact or not. Might be fine, but i've never tried that.

@dinkc64
Copy link

dinkc64 commented May 30, 2023

Hi Buffi,
Thanks for taking a look! :)
el_rika says to try with Manic, Palm, Abnormal, the slowdown is much more noticible in the same spot near the end of level 1. (starting with the second dinosaur dieing with a roar), he also provides this pcb link: https://youtu.be/XBFxglmkaJM?t=1863
I can tell things are a little sluggish with Palm, Abnormal setting in that area, I have nothing to base it on - I've never played from a pcb. (Though he has)
He seems pretty adamant about something being wrong here. The videos he posted on yt were just to get my attention, he also verified the behavior in MAME on PC.

best regards,

  • dink

@buffis
Copy link
Contributor Author

buffis commented May 30, 2023

Thanks, I agree that it seems slightly sluggish in that area.
I'm going to have a look at it and see if I can figure out what's up here.
It's possible that it's related to the recent clipping change actually.

There can be more sprites drawn by the code under "Sprites fully outside of clipping area should not be drawn."

Will test some things and see if I can figure out whats up! :)

Thanks!

@cuavas
Copy link
Member

cuavas commented May 30, 2023

I’ll tell you one thing, it sure feels weird getting slowdown in Muchi Muchi Pork after getting used to playing without it.

@buffis
Copy link
Contributor Author

buffis commented May 30, 2023

Actually, I don't think the clipping change was merged in MAME 254 so that should be unrelated. Will look at it a bit more to see whats up, and dig out my futari pcb

MMP has quite a lot of slowdown on PCB :)

@buffis
Copy link
Contributor Author

buffis commented May 30, 2023

Hooked up Futari to my test-rig and yes, I agree that there should not be any Blitter slowdown prior to S1 boss.

I have a good capture of that sequence with AbPalm on Maniac now, so I should be able to figure out what's up. Very useful bug report, thank you!

http://img.buffis.com/misc/futariblit.jpg

Must be some edge case I'm handling slightly wrong. Will investigate further :)
Need to compile some test builds and play around which I wont have time for today, but hopefully later this week.

@dinkc64
Copy link

dinkc64 commented May 30, 2023

@buffis you're the best :) thanks for listening!

@dinkc64
Copy link

dinkc64 commented May 30, 2023

@cuavas Muchi really benefits from the new blitter timing; stage 4 is actually enjoyable now :)

@buffis
Copy link
Contributor Author

buffis commented May 31, 2023

The clipping is definitely related to this, with the recent clipping change, there's a lot more slowdown than without it. That's awkward.
I'll figure out the proper fix for it :)
Need to look into it a bit more.

buffis added a commit to buffis/mamefork that referenced this pull request May 31, 2023
Fix issue where some games do very large over-draws which when utilized in Blitter calculations will cause more delay than whats seen on hardware. The fog in S1 of Mushi Futari 1.5 is a good example of this.

On Mushi Futari 1.5, in the section before the boss, the Blitter delay seen on PCB is aprox 12 milliseconds at peaks. With this fix, it matches that quite well!

It's not 100% clear to me this is exactly how things behave, but this should be closer to the truth, until I can figure out a more reliable and reproducible test-case.

See discussions on this PR for background : mamedev#11227

For reference, Saleae logic analyzer output is available in:
http://img.buffis.com/misc/futaris.sal
@buffis
Copy link
Contributor Author

buffis commented May 31, 2023

I believe #11295 should fix the issue before the S1 boss in Futari.
Its related to the transparent fog being drawn, see that PR for details

@dinkc64
Copy link

dinkc64 commented Jun 1, 2023

excellent!! so far, so good! :)

best regards,

  • dink

pauldevine pushed a commit to pauldevine/mame that referenced this pull request Jun 21, 2023
Change clipping for CV1K games to draw 32 pixels surrounding the visible area.

This can be easily seen in Muchi Muchi Pork, which has a VRAM viewer in Special mode (Object Test), which will show 32 px drawn around the visible areas of framebuffers.

For most gamers, this wont really matter at all... except for in Muchi Muchi Pork, where changing this actually fixes a bug for Rafute.

When Bombing with Rafute, the screen background will go wavy in a sine-like pattern. Currently in mame, the top of screen will show black pixels when this happens.

With this fix for clipping, the background will instead be visible correctly.

Also renamed the "scroll registers" to have it more clear which one of these are actually used as a "scroll register" (or rather offset for drawing), and which one is strictly used for clipping.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants