1 {-# LANGUAGE ScopedTypeVariables #-}
5 import Control.Concurrent
6 import Data.ReactiveValue
9 import RMCA.Auxiliary.Concurrent
10 import RMCA.Auxiliary.RV
11 import RMCA.Auxiliary.RV
12 import RMCA.Global.Clock
13 import RMCA.Layer.Board
14 import RMCA.Layer.Layer
16 import RMCA.Translator.Jack
17 import RMCA.Translator.Message
18 import RMCA.Translator.Translator
23 boardRVIO = newCBMVarRW $
24 makeBoard [((0,0), mkCell (ChDir False na1 N)),
25 ((0,1), mkCell (ChDir True na1 SE)),
26 ((1,1), mkCell (Split na1)),
27 ((1,-1), mkCell (Split na1)),
28 ((-1,0), mkCell (ChDir False na2 NE))]
33 naOrn = Ornaments Nothing [] NoSlide
39 naOrn = Ornaments Nothing [(10, MIDICVRnd)] SlideUp
45 naOrn = Ornaments Nothing [] NoSlide
52 newTempoRV :: IO (ReactiveFieldReadWrite IO Tempo)
53 newTempoRV = newCBMVarRW 96
57 layerRV <- getDefaultLayerRV
58 boardQueue <- newCBMVarRW []
60 layer <- reactiveValueRead layerRV
62 tempo <- reactiveValueRead tempoRV
64 board <- reactiveValueRead boardRV
65 (inBoard, outBoard) <- yampaReactiveDual (board, layer, tempo)
66 (boardSF $ startHeads board)
67 let inRV = liftRW2 (bijection (\(x,y,z) -> (x,(y,z)), \(x,(y,z)) -> (x,y,z)))
68 boardRV $ pairRW layerRV tempoRV
69 clock <- mkClockRV 100
72 --reactiveValueOnCanRead outBoard (reactiveValueRead outBoard >>= print . ("Board out " ++) . show)
73 reactiveValueOnCanRead outBoard $ do
74 bq <- reactiveValueRead boardQueue
75 ob <- reactiveValueRead $ liftR (event [] id) outBoard
76 reactiveValueWrite boardQueue (bq ++ ob)
78 --reactiveValueOnCanRead outBoard (reactiveValueRead outBoard >>= print)
79 putStrLn "Board started."
81 jackSetup tempoRV (constR 0) (boardQueue)
84 {-jackT <- forkChild $ jackSetup (liftR2 (\t n -> (t, 0, n)) tempoRV