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

Rondo of blood missing flickering pixels in the water #165

Closed
TruREALigion opened this issue Dec 1, 2021 · 12 comments
Closed

Rondo of blood missing flickering pixels in the water #165

TruREALigion opened this issue Dec 1, 2021 · 12 comments

Comments

@TruREALigion
Copy link

TruREALigion commented Dec 1, 2021

Interesting (minor) issue. The pirate ship stage 5 It doesn’t do the pixel flickering in the water. Videohere

@dshadoff
Copy link
Member

dshadoff commented Dec 1, 2021

I think I understand what that is.

The Hu6260 Video Color Encoder chip has a video interface and a computer-side interface for reading-writing palette entries. But it is not exactly dual-ported memory.

If the computer side accesses the VCE palette during active display, it receives priority; the display interface will display the last-successfully-fetched value, which is still held in a latch. This can create horizontal streaks, where the previous value appears to be extended beyond its normal boundary.

This is basically comparable to "CRAM dots" on Sega hardware. It's a limitation of the original hardware, and is generally considered a bad side effect. I was not aware of an example that it was ever used intentionally.

@TruREALigion
Copy link
Author

TruREALigion commented Dec 2, 2021

Using CRAM “intentionally”. If true, these artists really thought ahead!

So it sounds like the TG16 core is optimally reading/writing compared to what original hardware did, which is why these “CRAM dots” are not appearing from the FPGA?

Nevertheless, I believe the CoreGrafx2 had slight differences in hardware so I’m going to see if my DUO and white PCE exhibit the same thing. But it requires a trip back home to my parents house…. Stay tuned!

@dshadoff
Copy link
Member

dshadoff commented Dec 4, 2021

I'm working with github.com/turboxray to see if we are able to make a test ROM to quantify this VCE/CPU conflict behavior. This may take some time.

The other possibility - since your example seems to shift the whole scanline - is that there may be a raster interrupt, adjusting the X offset for one line only. This is difficult, because the next scanline is not affected, but RCR interrupts are usually a bit too slow to set up for consecutive scanlines. If this is the case, the x_offset is set immediately before being latched on that one scanline, and then reset soon afterward (to take effect on the next scanline). If this is the behaviour, then the x_offset latch point may need to be adjusted slightly.

@TruREALigion
Copy link
Author

Glad I could contribute.

Here is a video of my DUO-R showing the same behaviour. This time (not that it matters) on a consumer CRT. https://twitter.com/lnitial_d/status/1467236409513811971?s=21

@M-Walrus
Copy link
Contributor

M-Walrus commented Dec 4, 2021

it seems behavior on original hardware without the SSDS3 flash cart is even different from what you show in this video @TruREALigion
If you observe here, the large pillar is constantly flashing which is not the behavior in your video either:
https://youtu.be/7o1NuDusUic?t=1652

here is my 100% save file for testing purposes, to be able to access the level directly from the title screen (Stage 5):
Akumajou Dracula X - Chi no Rondo (Japan) (FABT, FACT).zip

@dshadoff
Copy link
Member

It doesn't seem to be related to a raster interrupt.
At the very beginning of that level, BXR is written at lines 0x11, 0x40, and 0xF4 ... but the write at 0xF4 doesn't change the value (before and after are both 0x0000).

However, there are quite a few palette updates occurring between lines 0xE1 to 0xE3 (specific code is in bank $69, address $47E2 through $4814. This seems to be the area in question (initiated by raster counter interrupt).

@dshadoff
Copy link
Member

I made a change and submitted a PR.

The flicker shows up in the correct position, but seems a little smaller on my PR than the real hardware; this may take some fine-tuning or better equipment for test.

sorgelig pushed a commit that referenced this issue Dec 12, 2021
…active scan. (issue #165) (#167)

When CPU accesses the palette memory during active display, the VCE is prevented from accessing the palette memory, and uses the last-latched color value.

This pull request implements the behavioor, but timing may or may not be exactly like original hardware (this looks like slightly less conflict than real hardware).  May need follow-up measurements and adjustment.
@dshadoff
Copy link
Member

Reviewing against actual hardware, the effect is correct but roughly half as much as expected.
This is true even if I simplify the latch criteria from:
elsif (CE_N = '0' and (WR_N = '0' or RD_N = '0') and (A = "010" or A = "011" or A = "100" or A = "101")) then
to
elsif (CE_N = '0') then

I think either:

  1. Maybe 6280's CEK_N is being held low for a shorter period than expected, or
  2. Perhaps the latch needs to be held one cycle beyond CE's removal (i.e. perhaps the 6260 remains sensitive beyond the assertion of CE)

@dshadoff
Copy link
Member

Here is a test build of the core, holding the latch one more cycle (at the output stage, by waiting 1 cycle after release of CE_N):
TurboGrafx16.zip
It is closer to what can be seen on real hardware, but hard to say whether it's exact.

@dshadoff
Copy link
Member

I took videos of:
a) original hardware
b) the implementation I previously checked in
c) the "additional cycle of hold" version described above, and
d) a version with 2 additional cycles of hold.

The results are:

  • b) is too little effect.
  • c) is a similar effect to original hardware, but appears slightly shorter than original, and slightly less volatile
  • d) is approximately the right length (or possibly slightly too long), but it is too deterministic-looking.

The original seems to be between 1 and 2 cycles more than the current CE hold - between c) and d) implementations - and the volatility probably results from a clock-domain-crossing effect between the 7.16MHz CPU and (what seems to be) a 5MHz video clock.

I will check in the 1-additional cycle version as an improvement, but I think it can still be improved more (but may be beyond my current skill to implement).

sorgelig pushed a commit that referenced this issue Dec 24, 2021
Extended the 'hold' time of the latched value by one cycle.
Also changed the names of the latch registers to conform to convention.
@dshadoff
Copy link
Member

The version with the fix is now in the public release.

In terms of how games operate (including simulating real hardware for games under development), I believe that this is now "close enough" that the core displays games as intended, and is a very good representation of real hardware (certainly better than any current software emulator).

In terms of "nth-degree cycle-accuracy" on this issue, there may still be something to learn on this issue, but I would recommend closing this issue until such "nth degree accuracy" is noticeable or can be measured.

@thehughhefner
Copy link
Contributor

This ticket can be closed since @dshadoff solved this.

@sorgelig sorgelig closed this as completed May 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants