SCOPE Solution
DECAY
SCOPE ACT 1

Prerequisites
Unlocks
sc_a1_09_decay locked
Par power128
Par lines8
Par chips1
Objective
An exponential fall, halving each step, then a snap back to the top.
Board Data
- Window: 64
- Pins: p0 OUT
- Channels: p0 ANALOG label=CH1_p0_DAC
- Peripherals: DAC data=p0 label=DAC_on_p0
Firmware Solution
; DECAY reference: an exponential fall. Start the level at the top, then HALVE it each
; step with shr (255, 127, 63, 31, 15, 7, 3, 1) so the curve drops fast and flattens.
; When the level reaches 0 the loop resets to the top. Teaches shr (halve) and jnz
; (keep looping while the level is nonzero).
top:
mov r0, 255
loop:
out p0, r0 ; draw the current level
slp 2 ; hold each step two ticks
shr r0, 1 ; halve the level (shift right by one)
jnz loop ; nonzero -> keep decaying
jmp top ; reached 0 -> reset to the top
Board Definition
# DECAY. ACT 1, analog. Not a straight ramp: an EXPONENTIAL fall. Start the level high
# and HALVE it each step with shr, so the curve drops fast then flattens toward the
# floor, then resets to the top. The first SCOPE board to use a shift, so it teaches
# shr (halve) and jnz (loop while nonzero). Reference is sc_a1_09_decay.asm.
# TITLE DECAY
# OBJECTIVE An exponential fall, halving each step, then a snap back to the top.
ID sc_a1_09_decay
WINDOW 64
DIR p0 OUT
PERIPH DAC data=p0 label=DAC_on_p0
CHAN p0 ANALOG label=CH1_p0_DAC
PAR power=128 lines=8 chips=1