summaryrefslogtreecommitdiff
path: root/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2024-04-09 22:35:42 -0400
committerLLLL Colonq <llll@colonq>2024-04-09 22:35:42 -0400
commit3a0a7b0a89fd841edd5f25f79cdb877051d0e948 (patch)
treef314021ddd72c3b528c42c154f8aee002a5c0e02 /fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs
parent70d50561b19b4161b85ec1b00c31e5678502688b (diff)
End-of-stream emulator WIP
Diffstat (limited to 'fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs')
-rw-r--r--fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs41
1 files changed, 41 insertions, 0 deletions
diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs
new file mode 100644
index 0000000..00f0e4d
--- /dev/null
+++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs
@@ -0,0 +1,41 @@
+module Fig.Emulator.GB.Component.Video where
+
+import Fig.Prelude
+
+import Fig.Emulator.GB.Bus
+
+newtype VideoError = VideoError Text
+ deriving Show
+instance Exception VideoError
+instance Pretty VideoError where
+ pretty (VideoError b) = mconcat
+ [ "video error: "
+ , b
+ ]
+
+compLCD :: (MonadIO m, MonadThrow m) => Component m
+compLCD = Component
+ { compState = ()
+ , compMatches = \a -> a >= 0xff40 && a <= 0xff4b
+ , compUpdate = pure
+ , compWrite = \s _ _ -> pure s
+ , compRead = \_ (Addr a) -> do
+ let off = a - 0xff40
+ case off of
+ 0x0 -> pure 0x00
+ 0x1 -> pure 0x00
+ 0x2 -> pure 0x00
+ 0x3 -> pure 0x00
+ 0x4 -> pure 0x00
+ 0x5 -> pure 0x00
+ 0x6 -> pure 0x00
+ 0x7 -> pure 0x00
+ 0x8 -> pure 0x00
+ 0x9 -> pure 0x00
+ 0xa -> pure 0x00
+ 0xb -> pure 0x00
+ _ -> throwM $ VideoError $ mconcat
+ [ "address out of bounds for LCD: "
+ , pretty $ Addr a
+ ]
+ }