Changes
PSG
,/* 0Dh - Volume Envelope Shape (4bit) */
|}
==== Bit 2 (Attack) ====
This bit is only responsible for the starting point of the envelope and the direction. In other words, we We have:
volume = 0 if attack else 15 # Start at 0 for attack, 15 for decay
direction = 1 if attack else -1 # Upward for attack, downward for decay
When bit3 ==== 1, Bit 1 (Alternate) and Bit 0 (Hold) ====determine what happens to volume and direction at the end of a period.
def envelope_step(volume , direction, shape): volume += ~direction if volume & 0x0F > 15 or volume < 0: if !(alternate ^ hold)shape < 8 or shape == 9 or shape == 15: direction *= 0 if hold else volume = 0 elif shape == 11 or shape == 13: direction = 0 volume = 15 elif shape == 10 or shape == 14: direction *= -1 if alternate volume += direction else 1: # direction unchanged volume &= 0x0f return volume, direction
=== 0Eh - External Dataregister Port A ===