def envelope_step(volume, direction, shape):
volume += direction if volume > 15 or volume < 0: if shape < 8 or shape == 9 or shape == 15: direction = 0 volume = 0 elif shape == 11 or shape == 13: direction = 0 volume = 15 elif shape == 10 or shape == 14: direction *= -1 volume += direction else: # direction unchanged volume &= 0x0f return volume, direction
=== 0Eh - External Dataregister Port A ===