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

Properly model NUSIZ during player decode and draw #63

Open
DirtyHairy opened this issue Dec 23, 2016 · 17 comments
Open

Properly model NUSIZ during player decode and draw #63

DirtyHairy opened this issue Dec 23, 2016 · 17 comments

Comments

@DirtyHairy
Copy link
Member

DirtyHairy commented Dec 23, 2016

...as described on AtariAge. As for the players, this will basically boil down to replacing the precomputed player patterns with a proper description of the player scan counters. Looking at Joe Musashi's testcase, I think that there is no delay in NUSIZ (I'll have to recheck, but if I remember correctly, a delay will wreak havok on several ROMs, including Tominv5), but instead the current pixel will finish rendering and, after that, the clock divisor will continue counting at the new ratio.

@DirtyHairy
Copy link
Member Author

By the way, that's a pretty fascinating thread 😏 Several ideas from there are actually implemented in 6502.ts and the new core. A nice case of parallel evolution 🍻

@thrust26
Copy link
Member

Sounds interesting. Which ideas?

@DirtyHairy
Copy link
Member Author

Mainly splitting the individual aspects of the TIA into separate classes and modelling the TIA as interconnected counters. I also stumbled over your branch in Stella when I first started integrating the new core (I didn't know about the corresponding thread); that stuff looks pretty similar to how the new core is structured, too.

@sa666666
Copy link
Member

sa666666 commented Dec 24, 2016

I had partly forgotten about that thread. Looking at it now, it did lay out the framework of where we are now, but (as you say) in a completely parallel evolution. Things were looking up at that point, but you'll notice how the thread just stopped. In the last message, I went to PM to help the guy set up a development environment. After a week or so of working on it, he decided that he was no longer interested. And some of the other help that was anticipated didn't come, so I became disillusioned and (again) moved on to other parts of the codebase.

So @DirtyHairy, you'll understand why I switched to your core so quickly, as we talked about in a PM. I've since learned that once you find reliable help, you latch on immediately :)

@thrust26
Copy link
Member

If the same solution is found multiple times independently, that 's a very good sign.

Sorry for aborting my work on Stella, first SCA had to be done and took much longer than I had expected. And afterwards I simply was not motivated enough to return. But at least I was able to help to forward Christian to Stella.

@sa666666
Copy link
Member

For the record, Thomas, I wasn't referring to you in that last comment.

@DirtyHairy
Copy link
Member Author

DirtyHairy commented Dec 24, 2016

@sa666666 Indeed, this is an interesting bit of history that explains very well why you wanted to get rid of the old core as soon as possible. It is also a peculiar coincidence that the 6502.ts core came around and to fill that particular hole.

I started 6502.ts as a mere research project and tech demo on Typescript and Javascript performance more than two years ago, and after completing CPU emulation, the project went to sleep again in early 2015. It is a mere coincidence that I started work again on 2600 emulation this spring and, after getting the first few ROMs to work, I was kinda sucked in --- I wasn't into retrocomputing in general or the VCS on particular before. The 2600 and the TIA are fascinating pieces of technology, and the more I learn about them, the more I continue to be surprised by what talented people can get out of this seemingly primitive and unwieldly hardware.

Anyway, merry christmas to you both, I'll propably be mostly gone from the web for a few days now 😏 🎄 ❄️

@DirtyHairy
Copy link
Member Author

DirtyHairy commented Feb 5, 2017

I have created a series of testcases that probe the behavior of nusiz during decode and draw: testcases.zip, source here. The testcases work by switching nusiz at a given clock and shifting the player from right to left through this point. The two red lines mark the point where NUSIZ (and the initial RESP) are hit, and the point where a 8px player would start drawing. Color/BW shifts between two player patterns, difficulty p0 switches between target nusiz values, and difficulty p1 switches between PAL and NTSC. The results:

8 -> 16
8-16

8 -> 32
8-32

16 -> 8
16-8

16 -> 32
16-32

32 -> 8
32-8

32 -> 16
32-16

Now all I'll have to do is to determine a rule from those... 🎱

@DirtyHairy
Copy link
Member Author

Implemented in 1a7ac60 . The corresponding patterns now look like this in stella:

8 -> 16
player8

8 -> 32
player8_1

16 -> 8
player16

16 -> 32
player16_1

32 -> 8
player32

32 -> 16
player32_1

@sa666666
Copy link
Member

sa666666 commented Feb 6, 2017

Just wanted to confirm that this fixes the final remaining issue in #68 too (the second-last horizontal bar was too short).

@DirtyHairy DirtyHairy changed the title Properly model NUSIZ during player and missile draw Properly model NUSIZ during player Feb 6, 2017
@DirtyHairy DirtyHairy changed the title Properly model NUSIZ during player Properly model NUSIZ during player decode and draw Feb 6, 2017
@DirtyHairy
Copy link
Member Author

This als renders Joe Musashi's testcase pixel correct.

@DirtyHairy
Copy link
Member Author

DirtyHairy commented Feb 6, 2017

However, @thrust26 's testcase is much closer than any other emulator, but there are still two deviations:

img_20170206_224210

vs.

testsize2copies_a

Specifically, the first sample on the right in the second and third groups shows two lines surplus in the emulation. I'm reopening this ticked and will close it again once I get this fixed 😏

@DirtyHairy DirtyHairy reopened this Feb 6, 2017
@DirtyHairy
Copy link
Member Author

It seems that switching off a copy during the very early stages of decoding will skip it alltogether. fd95231 accounts for this behavior and reproduces @thrust26 's testcase perfectly.

testsize2copies_a

Still, this has made me curious about some other cases I want to test before closing this:

  • Switching from double / quad player to two close copies, inducing an overlap between between the two copies
  • Systematically switching off copies just after hitting the decode
  • Systematically switching on copies just before hitting the decode

@DirtyHairy
Copy link
Member Author

The TIA is one hellish chip. It seems that everything that affects the counters obeys slightly different rules during hblank. I have created a new testcase that is very similar to the testcases above but executes the NUSIZ during hblank (I only 32 pixels -> x) for now: testcase.zip. As before, you can find the source in the 6502.ts repo.

The results on real hardware look like this:

32 -> 8:
img_20170307_225903

32 -> 16
img_20170307_225925

Commit e021660 improves emulation to include this class of edga cases. The emulation now looks like this:

32 -> 8
player32_hblank

32 -> 16
player32_hblank_1

This fixes #82 for good. More to come...

@DirtyHairy
Copy link
Member Author

The very same commit also fixes the cases 16 -> 8 and 16 -> 32. For reference:

16 -> 8 hardware
16_to_8

16 -> 32 hardware
16_to_32

16 -> 8 Stella
player16_hblank

16 -> 32 Stella
player16_hblank_1

@thrust26
Copy link
Member

@DirtyHairy Is this still an issue?

@thrust26 thrust26 added this to the Prio 2 milestone Aug 18, 2017
@DirtyHairy
Copy link
Member Author

DirtyHairy commented Aug 18, 2017

Not so much an issue as an reminder that there are still some edge cases that I didn't investigate and that I want to revisit eventually.

@thrust26 thrust26 added this to the Prio 3 milestone Aug 18, 2017
@thrust26 thrust26 removed this from the Prio 2 milestone Aug 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants