diff options
| author | LLLL Colonq <llll@colonq> | 2024-04-17 22:45:19 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-04-17 22:45:19 -0400 |
| commit | 9d875ab8fb539246e3aea0aae58d2c9f227c8276 (patch) | |
| tree | ba14b76a69fa39ec5cdb614d76ff6fdd02c81e94 /fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs | |
| parent | 3a0a7b0a89fd841edd5f25f79cdb877051d0e948 (diff) | |
Some basic emulator graphics
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.hs | 31 |
1 files changed, 31 insertions, 0 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 new file mode 100644 index 0000000..68bc477 --- /dev/null +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs @@ -0,0 +1,31 @@ +module Fig.Emulator.GB.Component.Serial where + +import Fig.Prelude +import Prelude (fromIntegral) + +import Data.Char (chr) + +import Fig.Emulator.GB.Utils +import Fig.Emulator.GB.Bus + +newtype SerialError = SerialError Text + deriving Show +instance Exception SerialError +instance Pretty SerialError where + pretty (SerialError b) = mconcat + [ "joystick error: " + , b + ] + +compSerial :: (MonadIO m, MonadThrow m) => Component m +compSerial = Component + { compState = () + , compMatches = (== 0xff01) + , compUpdate = \s _ -> pure s + , compWrite = \s _ v -> do + log $ mconcat + [ "wrote serial byte: ", tshow $ chr $ fromIntegral v + ] + pure s + , compRead = \_ _ -> pure 0x00 + } |
