Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
crsn/examples/purple.csn

67 lines
1.3 KiB

4 years ago
(
; Do you like purple? I like purple
(ld r0 10000)
(call rgb 1 255 0 255)
(:n)
(rng r1 100 160)
(rng r2 170 200)
(call rgb 0 r1 0 r2)
(rng r1 32 126)
(ld @cout r1)
(dec r0)
(j.nz :n)
(call resetcolor)
(ld @cout '\n')
(halt)
(proc rgb fg r g b
(mkbf r7)
(ld @cout 27)
(ld @cout '[')
(tst fg
(z? (ld @cout '4'))
(nz? (ld @cout '3')))
(ld @cout '8')(ld @cout ';')(ld @cout '2')(ld @cout ';')
(call itoa r7 r)
(bfsz r0 @r7)
(ldn @cout @r7 r0)
(ld @cout ';')
(call itoa r7 g)
(bfsz r0 @r7)
(ldn @cout @r7 r0)
(ld @cout ';')
(call itoa r7 b)
(bfsz r0 @r7)
(ldn @cout @r7 r0)
(ld @cout 'm')
(del @r7)
(ret)
)
(proc resetcolor
(ld @cout 27)
(ld @cout '[')
(ld @cout 'm')
(ret)
)
(proc itoa buf num
(bfrsz @buf 0)
(ld r1 num)
(tst r1 (<0? (mul r1 -1)))
(:next)
(mod r0 r1 10)
(add r0 '0')
(bfrpush @buf r0)
(div r1 10 (z?
(tst num (<0? (bfrpush @buf '-')))
(ret)))
(j :next)
)
)