summaryrefslogtreecommitdiff
path: root/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2024-05-07 14:21:13 -0400
committerLLLL Colonq <llll@colonq>2024-05-07 14:21:13 -0400
commita81c92dc2cdff02c55fdc197d943bc7a35c64be5 (patch)
treec5c4039f1e81d8290859656f3a0d306e6af62053 /fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs
parent82d4f5c55bdb1f160fe558bd9e413b726e36541b (diff)
fig-emulator-gb: Fix space leak
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
}