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

New TIA code comments missing #186

Open
thrust26 opened this issue Aug 6, 2017 · 14 comments
Open

New TIA code comments missing #186

thrust26 opened this issue Aug 6, 2017 · 14 comments
Assignees
Milestone

Comments

@thrust26
Copy link
Member

thrust26 commented Aug 6, 2017

While trying to get a grip on the new TIA code, I am really missing code comments.

I know this is tedious work, but IMO classes, members and methods should be commented. Plus additional code comments where necessary. Else code maintenance and collaboration will become really difficulty.

BTW: IMO the other code could use some more comments too. 😉

@sa666666
Copy link
Member

sa666666 commented Aug 6, 2017

@DirtyHairy mentioned coming back to this and commenting, etc. I would prefer to follow his lead on this, since he wrote most of the code.

Also, what 'other' code is it you speak of?

@thrust26
Copy link
Member Author

thrust26 commented Aug 6, 2017

I only looked into emucore and a bit into some other directories. They are definitely much better commented than the tia sub directory.

And meanwhile I realized that the class comments are all in the header files. So you can ignore my BTW from above.

@sa666666
Copy link
Member

sa666666 commented Aug 6, 2017

Commenting in the header files is the way I learned it in school, way back many moons ago. There are several justifications for this:

  • with code that is to be released commercially, you normally only get the header files as source; the actual source code is a black box
  • related to the first one, typically you comment and describe the ADT, not the implementation
  • tools to autogenerate documentation (javadoc, doxygen, etc) only process header files

So at least for the code I wrote, most of the commenting is in the header files. Of course, if there is something complicated in the cxx file, it is commented there too. But the overall 'big picture' commenting happens in the header files mostly.

@thrust26
Copy link
Member Author

thrust26 commented Aug 6, 2017

All valid arguments, looks like I have done too much Java in between.

@DirtyHairy
Copy link
Member

DirtyHairy commented Aug 7, 2017

Full ACK. I usually prefer clear code with sensible names for entities over verbose documentation. However, I wouldn't claim that the TIA implementation necessarily meets these criteria, and even less in its C++ incarnation 😏 I'll try to improve this over time.

Other than that, there are mainly two reasons why documentation is currently so sparse:

  • The TIA code has been in flux alot, and I hate rewriting documentation during refactoring
  • The other Stella code has had more time to get documented 😄

@thrust26
Copy link
Member Author

thrust26 commented Aug 7, 2017

Welcome back from mud!

Sure, take the time you need. I just tried to understand the code and (where it makes sense) to optimize some parts and there I struggled. Maybe you can ask some questions:

  • why is myTimestamp a double?
  • would it be save to move it outside the loop in TIA:cycle? (myTimestamp += colorClocks instead of myTimestamp++)
  • what does DelayQueue do exactly?

Or you could just comment it. 😆

@DirtyHairy
Copy link
Member

DirtyHairy commented Aug 7, 2017

Or I could do my promised git writeup and you could add comments yourself where you find them appropiate 😛 Just kidding, although this might actually improve the quality of any new comments a lot.

As for your questions:

  • myTimestamp counts color clocks and would overflow after some 30 minutes if it were a 32 bit integer. It currently enters the floating point calculation that simulates the paddle readout circuit, that's why I chose to just make it a double.
  • While I think that it technically could be moved from the loop at this point, I am not overly enthusiastic about doing so. The whole TIA simulation is build around a cycle-by-cycle simulation, and the loop you reference interfaces this to the Stella way of counting time. Moving the increment outside would complicate things and introduce an error vector if anything that touches myTimestamp is changed.
  • DelayQueue is a scheduling queue for pokes that do not take effect instantly, but rather are deferred by one or more clocks. The scheduled pokes are executed during DelayQueue::execute after the specified number of clocks has passed --- that's what happens in delayedWrite. As an additional twist, there is a similar delay when the contents of the "old" and "new" GRPx registers are swapped; this is also handled by the queue with "writes" to registers that are unused on a real TIA (those are enumerated in the DummyRegisters enum).

@thrust26
Copy link
Member Author

thrust26 commented Aug 8, 2017

Thanks for the explanations.

What happens if myTimeStamp overflows (several years now 😃 )? I found it only used in paddle code, correct? And why double, why not a 64 bit integer instead?

@DirtyHairy
Copy link
Member

DirtyHairy commented Aug 8, 2017

Long before it actually overflows, the paddle will start getting jumpy as the relative accuracy will become smaller than one clock. Considering the 52 bits of fraction precision in double, this will happen in about 40.8 years (not considering leap years). Depending on the game, I would think there are some more three to four powers of two headroom, so there won't be any epic, 640 year (with hotswapped hardware) breakout highscores with Stella 😄

As for why it is a double:

  • There's hardware support for doubles in more current CPUs as there is support for 64 bit integers
  • It will be cast to double anyway in the paddle code
  • The code is ported from Javascript which only knows 32 (actually more like 31 in all current VMs) bit integers and doubles 😈

@thrust26
Copy link
Member Author

thrust26 commented Aug 8, 2017

Too many valid reasons to disagree. 😄

@thrust26 thrust26 added this to the Prio 1 milestone Aug 18, 2017
@thrust26 thrust26 added the target 6.0 Christmas 2018 Release label Feb 6, 2018
@sa666666 sa666666 added target 6.1 2020-03 Release and removed target 6.0 Christmas 2018 Release labels Aug 6, 2018
@thrust26
Copy link
Member Author

thrust26 commented Aug 6, 2018

@DirtyHairy

Happy birthday to you,
Happy birthday to you,
Happy birthday dear issue 186,
Happy birthday to you.
🎂

😈

@sa666666
Copy link
Member

sa666666 commented Aug 6, 2018

I didn't want to be pushy, so I pushed the deadline to 6.1. Of course, whatever is added from now to the 6.0 release would be appreciated too. (hint-hint)

@thrust26
Copy link
Member Author

Missed the 2nd birthday by a few days. 😈

@DirtyHairy Where are we with this? What is done and what not?

@DirtyHairy
Copy link
Member

About 50% done iirc. More to come anytime soon 😛

@thrust26 thrust26 pinned this issue Aug 20, 2019
@thrust26 thrust26 added target 6.2 2020-07 Release and removed target 6.1 2020-03 Release labels Dec 15, 2019
@sa666666 sa666666 added target 6.3 2020-10 Release and removed target 6.2 2020-07 Release labels May 29, 2020
@sa666666 sa666666 added target 6.4 2020-11 Release and removed target 6.3 2020-10 Release labels Sep 19, 2020
@thrust26 thrust26 removed the target 6.4 2020-11 Release label Nov 1, 2020
@thrust26 thrust26 added the target 6.5 New Year 2021 Release label Nov 1, 2020
@thrust26 thrust26 added target 6.6 2021-11 Release and removed target 6.5 New Year 2021 Release labels Feb 26, 2021
@thrust26 thrust26 added target 6.7 and removed target 6.6 2021-11 Release labels Nov 22, 2021
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