| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Nes.Memory
Synopsis
- newMemory :: IO MemoryPointer
- memorySize :: Addr
- newtype Byte = Byte {}
- newtype Addr = Addr {}
- byteToAddr :: Byte -> Addr
- bytesToAddr :: Byte -> Byte -> Addr
- negateByte :: Byte -> Byte
- byteToInt :: Byte -> Int
- addrToInt :: Addr -> Int
- unsafeAddrToByte :: Addr -> Byte
- type MemoryPointer = ForeignPtr ()
- class MemoryInterface a (m :: Type -> Type) where
Documentation
newMemory :: IO MemoryPointer Source #
Creates a new memory slot
memorySize :: Addr Source #
The size of RAM, in bytes
Equivalent to 64 KiB
Instances
| Bits Byte Source # | |
Defined in Nes.Memory Methods (.&.) :: Byte -> Byte -> Byte # (.|.) :: Byte -> Byte -> Byte # complement :: Byte -> Byte # shift :: Byte -> Int -> Byte # rotate :: Byte -> Int -> Byte # setBit :: Byte -> Int -> Byte # clearBit :: Byte -> Int -> Byte # complementBit :: Byte -> Int -> Byte # testBit :: Byte -> Int -> Bool # bitSizeMaybe :: Byte -> Maybe Int # shiftL :: Byte -> Int -> Byte # unsafeShiftL :: Byte -> Int -> Byte # shiftR :: Byte -> Int -> Byte # unsafeShiftR :: Byte -> Int -> Byte # rotateL :: Byte -> Int -> Byte # | |
| Num Byte Source # | |
| Show Byte Source # | |
| Eq Byte Source # | |
| Ord Byte Source # | |
Instances
| Bits Addr Source # | |
Defined in Nes.Memory Methods (.&.) :: Addr -> Addr -> Addr # (.|.) :: Addr -> Addr -> Addr # complement :: Addr -> Addr # shift :: Addr -> Int -> Addr # rotate :: Addr -> Int -> Addr # setBit :: Addr -> Int -> Addr # clearBit :: Addr -> Int -> Addr # complementBit :: Addr -> Int -> Addr # testBit :: Addr -> Int -> Bool # bitSizeMaybe :: Addr -> Maybe Int # shiftL :: Addr -> Int -> Addr # unsafeShiftL :: Addr -> Int -> Addr # shiftR :: Addr -> Int -> Addr # unsafeShiftR :: Addr -> Int -> Addr # rotateL :: Addr -> Int -> Addr # | |
| Ix Addr Source # | |
| Num Addr Source # | |
| Show Addr Source # | |
| Eq Addr Source # | |
| Ord Addr Source # | |
byteToAddr :: Byte -> Addr Source #
negateByte :: Byte -> Byte Source #
Safely negates a byte, handles underflow
unsafeAddrToByte :: Addr -> Byte Source #
Unsafe: Casts a Word16 to Word8
type MemoryPointer = ForeignPtr () Source #
The pointer used to interact with memory
class MemoryInterface a (m :: Type -> Type) where Source #
Methods for interfaces that exposes memory
Methods
readByte :: Addr -> a -> m Byte Source #
Reads a single byte
readAddr :: Addr -> a -> m Addr Source #
Reads two bytes packed in little endian
writeByte :: Byte -> Addr -> a -> m () Source #
Writes a single byte
writeAddr :: Addr -> Addr -> a -> m () Source #
Writes two bytes packed in little endian
the first argument is the address to write the second is the destination
Instances
| MemoryInterface () (Bus r) Source # | |
| MemoryInterface () (CPU r) Source # | |
| MonadIO m => MemoryInterface (ForeignPtr a) m Source # | |
Defined in Nes.Memory.Unsafe | |
| MonadIO m => MemoryInterface (Ptr a) m Source # | Highly unsafe instance that uses pointers directly. No bound checks are done. |