@Brazos and TheComet
Quote: "the middle one is a binary operator, not, but im not good at explaining those"
You do fine. But DBC is tricky, in other languages ! can be used as a binary NOT where it gives the opposite value of the expression or two expressions compared. In DBC it does a boolean comparison and just returns a true or a false: 1 or 0. True if the values don't match, and false if they do.
Just like That1Smart Guy wrote.
(flag=0), (dr!0), and (flag>10) are all boolean expressions. That means if their condition is met or not met, they return a 1 or a 0 . Then that value is added or multiplied to the other part of the expression.
Since dr = upkey()-downkey() , that means if upkey() is pressed then a 1 is returned by upkey() and if downkey() isn't pressed then 0 is returned by downkey(). So 1-0 is 1. And the opposite if the downkey is pressed : 0-1 = -1 . If both keys are or aren't pressed, then the value of dr is 0.
Multiply and add these values together and you have your results.
If dr is 0, then flag is reset to 0 at the end of each loop. So in the expression
inc t,((flag=0)*dr) + dr*uinc
The ((flag=0)*dr) will result in the value of the upkey()-downkey() expression ONLY when flag=0; since flag is reset if upkey or downkey aren't pressed, then that allows the user to tap the upkey or downkey and only increment t 1 value, either +1 or -1 .
uinc = (flag > 10) + 2*(flag > 30)
(flag > 10) will only be 1 if flag is > 10. Otherwise it's 0. The same with (flag > 30) except when flag > 30. That allows uinc to be 0, 1, or 1+(2*1) which is 3 . Bring uinc back to the previous line
((flag=0)*dr) + dr*uinc
and the expression can be 0,1,3,-1,-3 . Increment t by any of those values, and voila.
Can you figure out what
inc flag,(dr ! 0)
does?
Enjoy your day.