Oops, my idents disappeared. I'll insert some brackets:$4008 write:LinearCounterLoad = data & 0x7Fif (LinearCounterMode == LOAD){LinearCounter = LinearCounterLoad}$400A write:TimerLoad.low = dataTimer = TimerLoad$400B write:LengthCounter = LengthCounterTable[data >> 3]TimerLoad.high = data & 7Timer = TimerLoadLinearCounterMode = LOADLinearCounter = LinearCounterLoadChangeMode = ($4008.7 == 0)LinearClock:if (LinearCounterMode == COUNT && LinearCounter){LinearCounter--}if (ChangeMode)ChangeMode = 0if ($4008.7 = 0){LinearCounterMode = COUNT}LengthClock:if (LengthCounter && ($4008.7 = 0) && ($4015.2 = 0)){LengthCounter--}TriangleStepGenerator:Timer = TimerLoadif (($4015.2 = 0) && LinearCounter && LengthCounter) /* channel enabled? */{if (Output == 0xF) step--if (Output == 0x0) step++output += step}