triangle problems...

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
triangle problems...
by on (#7277)
im having as topics says that problem, my trgnl emulation in some games trough me whistles. its ok for christmas, but not for accuracy.
I want to know if the following is right, can somebody help me?:

Code:

if ((triangleLinearCounter != 0) && (triangleLenCounter != 0))
{

ClockStepGenerator(); //this clock step generator and feeds the trngl DAC
}
else      
   FeedDAC(CHANNEL_TRIANGLE, 0);      //else.. feed dac with "0"



Is that "else" well?

by on (#7278)
No - when the triangle channel is inactive, its position gets "stuck" wherever it was previously.

by on (#7279)
Thanks for the help i fixed it, but im still having problems.
Blarrg mentions 2 steps that takes the linear counter if it is clocked:

1)
Code:
if (haltflag == TRUE) cLinear = CReloadValue;
else if (cLinear != 0) cLinear--;


2)
Code:
if  (controlflag == FALSE) haltflag = FALSE;


These two are executed separetly?
thxs again.

by on (#7282)
Your code above looks correct, based on the following:

Quote:
When clocked by the frame sequencer, the following actions occur in order:

1) If halt flag is set, set counter to reload value, otherwise if counter is non-zero, decrement it.
2) If control flag is clear, clear halt flag.

by on (#7302)
thnxs!!