summaryrefslogtreecommitdiff
path: root/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs
diff options
context:
space:
mode:
Diffstat (limited to 'fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs')
-rw-r--r--fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs14
1 files changed, 8 insertions, 6 deletions
diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs
index 59200f1..0ee529b 100644
--- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs
+++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs
@@ -18,16 +18,18 @@ instance Pretty SerialError where
, b
]
-compSerial :: (MonadIO m, MonadThrow m) => Handle -> Component m
-compSerial h = Component
+compSerial :: (MonadIO m, MonadThrow m) => Maybe Handle -> Component m
+compSerial mh = Component
{ compState = ()
, compMatches = (== 0xff01)
, compUpdate = \s _ -> pure s
, compWrite = \s _ v -> do
- log $ mconcat
- [ "wrote serial byte: ", tshow $ chr $ fromIntegral v
- ]
- liftIO . hPutChar h . chr $ fromIntegral v
+ -- log $ mconcat
+ -- [ "wrote serial byte: ", tshow $ chr $ fromIntegral v
+ -- ]
+ case mh of
+ Nothing -> pure ()
+ Just h -> liftIO . hPutChar h . chr $ fromIntegral v
pure s
, compRead = \_ _ -> pure 0x00
}