\ Rolling dice by setting dots on OLED screen

hex  chere

: DOT       ( y x -- )      \ Eight character dot
    6 umin >r  70 umin  graphic
        dup  r@    xy" Q11P"
             r> 1+ xy" O11N" ;

: ONE       3C 3 dot ;      \ Six sides of a dice
: TWO       24 6 dot  54 0 dot ;
: THREE     one  two ;
: FOUR      two  24 0 dot  54 6 dot ;
: FIVE      one  four ;
: SIX       four 24 3 dot  54 3 dot ;

: DICE      ( +n -- )       \ Print dice
    &page
    dup 1 = if  one     then
    dup 2 = if  two     then
    dup 3 = if  three   then
    dup 4 = if  four    then
    dup 5 = if  five    then
        6 = if  six     then ;

: DO-DICE       6 choose 1+ dice ; \ Print dice randomly
: ROLL-DICE     07 0 do  i 1+ 10 * ms  do-dice  loop ;
: SW?           s1? s2? or ;

: PLAY-DICE     ( -- )
    begin
        20 contrast  200 ms
        begin  do-dice  sw? until
        roll-dice  C0 contrast
        begin  sw? until
    s2? until  &page ;

: TESTDICE      ( -- )
    &page  thin
    0C 1 xy" Rolling dice"  fat
    30 4 xy" test"  800 ms  &page
    begin
        20 contrast
        20 choose 1+ 0 do  do-dice  C ms  loop
        roll-dice  C0 contrast  800 ms
    s2? until
    &page ;

chere swap - dm u.

shield DICE\  freeze
