Changes

Jump to: navigation, search

PSG

371 bytes added, 1 April
/* 0Dh - Volume Envelope Shape (4bit) */
|}
==== Bit 3 (Continue) ==== When bit3 = 0, using the volume and direction at envelope generator, the end of a period always are:  volume = 0 direction = 0is always increased from 00h to 0Fh (or vice versa), it is not possible to specify a starting/ending point (like from 00h to 07h).
==== 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 using the volume envelope generator, the volume is always increased from 00h to 0Fh ==== Bit 3 (or vice versaContinue), it is not possible to specify a starting/ending point Bit 1 (like from 00h to 07hAlternate)and Bit 0 (Hold) ==== When bit3 = 0, volume and direction at the end of a period are always 0.
When bit3 ==== 1, Bit 1 (Alternate) and Bit 0 (Hold) ====determine what happens to volume and direction at the end of a period.
When bit3 = 1, these 2 bits determine what happens to volume and direction at the end of a period.=== Algorithm ====
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 ===
11,904
edits