marker _ambulance_ \ ambulance -- version 3 : 2dup over over ; : pillar ( -- addr ) PORTA ; : pillar# ( -- addr ) PORTB ; : pillar! ( n -- ) pillar c! ; : pillar#! ( n -- ) pillar# c! ; \ n in [0..7] : limit-pillar# ( n -- n' ) 07 and ; : initmojo ( -- ) ff pillar pin_output ff pillar# pin_output ff pillar! 00 pillar#! ; : all-blue 55 ; : all-red aa ; variable speed f0 speed ! \ p#o gets only increased every SPEED \ steps of the (multiplexing) loop : limit-counter ( n -- n' ) speed @ mod ; \ reset COUNTER if SPEED is reached : ambulance ( -- ) initmojo 0 0 0 ( cnt:counter p#o:pillar#-offset p#:pillar# ) begin 2dup = if all-blue pillar! then 2dup swap 4 + limit-pillar# = if all-red pillar! then dup pillar#! 1+ limit-pillar# ( cnt p#o p#+1 ) rot 1+ limit-counter ( p#o p#+1 cnt+1 ) \ 0 increase counter dup 0= if rot 1+ limit-pillar# rot else rot rot then \ increase p#o when cnt=0 key3? until drop drop drop ;