Skip to content

Commit

Permalink
tttool play: improve handling of the J command (entropia#231)
Browse files Browse the repository at this point in the history
The J() command is executed after all other commands in the line have
executed. The 2s pause if no P() follows J() (as documented in
entropia#179 (comment))
is not implemented yet.
  • Loading branch information
Thomas Bleher committed Dec 1, 2020
1 parent 0441235 commit 64904b4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/GMERun.hs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,17 @@ playTTAudio i = do
let bs = ttAudioFiles tt !! fromIntegral i
liftIO $ playSound bs

-- Rules for J(): jumps are executed last; the last J() wins.
-- Effectively this is like a jump register is set, which is consulted after
-- all other commands have executed. Simulate this by moving the last Jump
-- to the end of the list and discarding all others.
moveJumpsLast Nothing [] = []
moveJumpsLast (Just x) [] = [x]
moveJumpsLast _ (Jump v : acts) = moveJumpsLast (Just (Jump v)) acts
moveJumpsLast j (x : acts) = x : (moveJumpsLast j acts)

applyLine :: Line Word16 -> GMEM Word16 ()
applyLine (Line _ _ acts playlist) = go acts
applyLine (Line _ _ acts playlist) = go (moveJumpsLast Nothing acts)
where
go (Neg r : acts) = do
modReg r neg
Expand Down

0 comments on commit 64904b4

Please sign in to comment.