From 9167b9ca9e5de8fddda016fb99a7d926625233bb Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 7 May 2024 20:00:17 -0400 Subject: fb-emulator-gb: It's not as slow --- fig-emulator-gb/src/Fig/Emulator/GB/Component/Interrupt.hs | 2 +- fig-emulator-gb/src/Fig/Emulator/GB/Component/Joystick.hs | 2 +- fig-emulator-gb/src/Fig/Emulator/GB/Component/RAM.hs | 2 +- fig-emulator-gb/src/Fig/Emulator/GB/Component/ROM.hs | 2 +- fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs | 2 +- fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) (limited to 'fig-emulator-gb/src/Fig/Emulator/GB/Component') diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Interrupt.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Interrupt.hs index ec5540c..f6ea420 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Interrupt.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Interrupt.hs @@ -14,7 +14,7 @@ instance Pretty InterruptError where , b ] -compInterrupt :: (MonadIO m, MonadThrow m) => Component m +compInterrupt :: Component compInterrupt = Component { compState = () , compMatches = \a -> a == 0xff0f || a == 0xffff diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Joystick.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Joystick.hs index 84785b6..7519ea5 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Joystick.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Joystick.hs @@ -13,7 +13,7 @@ instance Pretty JoystickError where , b ] -compJoystick :: (MonadIO m, MonadThrow m) => Component m +compJoystick :: Component compJoystick = Component { compState = () , compMatches = (== 0xff00) diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/RAM.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/RAM.hs index b17292c..4dc5715 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/RAM.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/RAM.hs @@ -19,7 +19,7 @@ instance Pretty RAMError where , b ] -compWRAM :: (MonadIO m, MonadThrow m) => Addr -> Int -> Component m +compWRAM :: Addr -> Int -> Component compWRAM start size = Component { compState = V.replicate size 0 :: V.Vector Word8 , compMatches = \a -> diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/ROM.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/ROM.hs index bfdc2fb..6aafc46 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/ROM.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/ROM.hs @@ -20,7 +20,7 @@ instance Pretty ROMError where ] -- | Initialize base ROM (no mapper) from a ByteString -compROM :: (MonadIO m, MonadThrow m) => ByteString -> Component m +compROM :: ByteString -> Component compROM bs = Component { compState = V.fromList $ BS.unpack bs , compMatches = \a -> 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 0ee529b..7a4bceb 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Serial.hs @@ -18,7 +18,7 @@ instance Pretty SerialError where , b ] -compSerial :: (MonadIO m, MonadThrow m) => Maybe Handle -> Component m +compSerial :: Maybe Handle -> Component compSerial mh = Component { compState = () , compMatches = (== 0xff01) diff --git a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs index 9326e41..2337a1c 100644 --- a/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs +++ b/fig-emulator-gb/src/Fig/Emulator/GB/Component/Video.hs @@ -36,7 +36,7 @@ newtype Framebuffer = Framebuffer { fbSurface :: SDL.Surface } -initializeFramebuffer :: MonadIO m => m Framebuffer +initializeFramebuffer :: IO Framebuffer initializeFramebuffer = do s <- liftIO $ SDL.createRGBSurface (SDL.V2 (fromIntegral screenWidth) $ fromIntegral screenHeight) @@ -45,7 +45,7 @@ initializeFramebuffer = do { fbSurface = s } -logTilemap :: MonadIO m => V.Vector Word8 -> m () +logTilemap :: V.Vector Word8 -> IO () logTilemap v = do let base = 0x9800 - 0x8000 bytes <- forM ([0..(32 * 32)] :: [Int]) \i -> do @@ -54,7 +54,7 @@ logTilemap v = do Just a -> pure a log $ "tilemap:" <> tshow bytes -blitPixel :: MonadIO m => Word32 -> (Word8, Word8) -> Framebuffer -> m () +blitPixel :: Word32 -> (Word8, Word8) -> Framebuffer -> IO () blitPixel c (x, y) fb = do SDL.lockSurface $ fbSurface fb (base :: Ptr.Ptr Word32) <- Ptr.castPtr <$> SDL.surfacePixels (fbSurface fb) @@ -64,7 +64,7 @@ blitPixel c (x, y) fb = do liftIO $ St.poke p c SDL.unlockSurface $ fbSurface fb -blitTile :: (MonadIO m, MonadThrow m) => V.Vector Word8 -> Addr -> (Word8, Word8) -> Framebuffer -> m () +blitTile :: V.Vector Word8 -> Addr -> (Word8, Word8) -> Framebuffer -> IO () blitTile v (Addr a) (bx, by) fb = do (ps :: [(Word8, Word8, Word8)]) <- mconcat <$> forM [0..7] \y -> do mconcat <$> forM [0..1] \xb -> do @@ -120,7 +120,7 @@ data VideoState = VideoState , vstTick :: Word16 } -compVideo :: (MonadIO m, MonadThrow m) => Framebuffer -> Component m +compVideo :: Framebuffer -> Component compVideo framebuffer = Component { compState = VideoState { vstFb = framebuffer -- cgit v1.2.3