| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Nes.Render.Frame
Synopsis
- data FrameState = MkFrameState {
- sdl2Frame :: !MemoryPointer
- pixelBuffer :: !(Buffer (Color, PixelType))
- spritePixels :: !SpritePixels
- newFrameState :: IO FrameState
- frameWidth :: Int
- frameHeight :: Int
- frameLength :: Int
- frameSetPixel :: (Word8, Word8, Word8) -> (Int, Int) -> MemoryPointer -> IO ()
- newtype Buffer a = MkBuffer {
- unBuffer :: IOVector a
- bufferWidth :: Int
- bufferHeight :: Int
- bufferLength :: Int
- bufferGet :: Coord -> Buffer a -> IO (Maybe a)
- bufferSet :: a -> Coord -> Buffer a -> IO ()
- bufferCoordToOffset :: Coord -> Int
- bufferGetOffset :: Int -> Buffer a -> IO (Maybe a)
- bufferSetOffset :: a -> Int -> Buffer a -> IO ()
- type SpritePixel = (Color, SpritePriority)
- type SpritePixels = Map Int SpritePixel
- addSpritePixel :: Coord -> SpritePixel -> FrameState -> FrameState
- foreachSpritePixel :: Monad m => (Int -> SpritePixel -> m ()) -> FrameState -> m ()
- type Coord = (Int, Int)
- type Color = (Word8, Word8, Word8)
- data PixelType
- data SpritePriority
State
data FrameState Source #
Constructors
| MkFrameState | |
Fields
| |
newFrameState :: IO FrameState Source #
Allocates the buffers and frame
Frame
frameWidth :: Int Source #
Width (in pixels of the frame)
frameHeight :: Int Source #
Height (in pixels of the frame)
frameLength :: Int Source #
Size, in bytes, of the frame
frameSetPixel :: (Word8, Word8, Word8) -> (Int, Int) -> MemoryPointer -> IO () Source #
Buffer
bufferWidth :: Int Source #
Width of the internal buffer
Equals frameWidth
bufferHeight :: Int Source #
Height of the internal buffer
_Warning_ is not equal to frameHeight
See https://www.nesdev.org/wiki/PPU_rendering#Vertical_blanking_lines_(241-260)
bufferLength :: Int Source #
Number of elements in a buffer
bufferCoordToOffset :: Coord -> Int Source #
Sprite Pixel
type SpritePixel = (Color, SpritePriority) Source #
type SpritePixels = Map Int SpritePixel Source #
addSpritePixel :: Coord -> SpritePixel -> FrameState -> FrameState Source #
foreachSpritePixel :: Monad m => (Int -> SpritePixel -> m ()) -> FrameState -> m () Source #
Pixel
Says _where_ the pixel comes from
Constructors
| TransparentBG | An opaque background pixel (e.g. pipe in mario) |
| OpaqueBG | A transparent background pixel (e.g. sky in mario) |
| Sprite | Pixel from a sprite |
Misc
data SpritePriority Source #
Priority of the sprite (from bit 5 of attribute table)
Instances
| Show SpritePriority Source # | |
Defined in Nes.Render.Frame Methods showsPrec :: Int -> SpritePriority -> ShowS # show :: SpritePriority -> String # showList :: [SpritePriority] -> ShowS # | |
| Eq SpritePriority Source # | |
Defined in Nes.Render.Frame Methods (==) :: SpritePriority -> SpritePriority -> Bool # (/=) :: SpritePriority -> SpritePriority -> Bool # | |