SCOPE Solution
TRIANGLE
SCOPE ACT 1

sc_a1_04_triangle locked
Par power1921
Par lines17
Par chips1
Objective
Ramp up 0..64 then fall 64..0, period 128.
Board Data
- Window: 256
- Pins: p0 OUT
- Channels: p0 ANALOG label=CH1_p0_DAC
- Peripherals: DAC data=p0 label=DAC_on_p0
Firmware Solution
; TRIANGLE reference: r0 is the level, r1 is the direction flag (1 = up, 0 = down).
; Climb 0..64, flip, fall 64..0, flip, repeat. cmp/jz turns the wave around.
mov r1, 1 ; start climbing
loop:
out p0, r0 ; draw the current level
slp 1 ; one tick per level
cmp r1, 0
jz down ; direction is down
inc r0 ; climbing
cmp r0, 64
jnz loop ; not at the top yet
mov r1, 0 ; hit the top: flip to down
jmp loop
down:
dec r0 ; falling
cmp r0, 0
jnz loop ; not at the bottom yet
mov r1, 1 ; hit the bottom: flip to up
jmp loop
Board Definition
# TRIANGLE. ACT 1, analog. Turn around with a direction flag and cmp/jz (CRACK's
# compare-and-branch in a visual context). The wave climbs 0..64 then falls 64..0,
# period 128. Reference is sc_a1_04_triangle.asm.
# TITLE TRIANGLE
# OBJECTIVE Ramp up 0..64 then fall 64..0, period 128.
ID sc_a1_04_triangle
WINDOW 256
DIR p0 OUT
PERIPH DAC data=p0 label=DAC_on_p0
CHAN p0 ANALOG label=CH1_p0_DAC
PAR power=1921 lines=17 chips=1