ZXS: Machine: Add more aux funcs
authorLucian Mogosanu <lucian.mogosanu@gmail.com>
Tue, 23 Dec 2014 17:41:18 +0000 (19:41 +0200)
committerLucian Mogosanu <lucian.mogosanu@gmail.com>
Tue, 23 Dec 2014 17:41:34 +0000 (19:41 +0200)
getMainMemByte retrieves one byte from the main memory.

src/ZXS/Machine.hs

index 3eaeff0..52842c4 100644 (file)
@@ -1,6 +1,8 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 module ZXS.Machine where
 
+import Data.Word
+import Control.Monad.IO.Class (liftIO)
 import Control.Monad.State
 import Control.Applicative (Applicative)
 
@@ -33,6 +35,10 @@ type ZXS a = ZXST IO a
 getsCPU :: (CPU -> a) -> ZXS a
 getsCPU f = gets zxCPU >>= return . f
 
+getMainMemByte :: Word16 -> ZXS Word8
+getMainMemByte addr = gets zxMainMem
+                  >>= \ mem -> liftIO $ ramGetByte mem addr
+
 modifyCPU :: (CPU -> CPU) -> ZXS ()
 modifyCPU f = modify $ \ spc -> spc { zxCPU = f $ zxCPU spc }