Chip8.Interpreter.Display (chip8 v0.1.0)

A monochrome display device.

The monochrome display has a resolution of 64x32 pixels (64 pixels wide and 32 pixels high), programs can render graphics on it through the use of sprites (see Chip8.Interpreter.Display.Sprite) and coordinates. The origin point of the display is at the top-left corner, with the coordinates (0, 0).

pixelmap

Pixelmap

In most cases, pixelmaps contain the color information of each pixel in the screen but, since the COSMAC VIP wasn't able to produce colors and there is no way to specify one with the DRW instruction, the only information returned is the pixel "state", which can be, 1 when the pixel is "on" and 0 when is "off".

Link to this section Summary

Link to this section Types

Link to this type

coordinates()

@type coordinates() :: {x :: non_neg_integer(), y :: non_neg_integer()}
@type dimension() :: non_neg_integer()
@type pixel() :: 0 | 1
@type pixelmap() :: [[pixel()]]
@type t() :: %Chip8.Interpreter.Display{
  height: dimension(),
  pixels: [pixel()],
  width: dimension()
}

Link to this section Functions

@spec clear(t()) :: t()
Link to this function

create_sprite(data)

@spec create_sprite([byte()]) :: Chip8.Interpreter.Display.Sprite.t()
Link to this function

draw(display, arg, sprite)

Link to this function

get_coordinates(display, x, y)

@spec get_coordinates(t(), non_neg_integer(), non_neg_integer()) :: coordinates()
Link to this function

has_collision?(display1, display2)

@spec has_collision?(t(), t()) :: boolean()
Link to this function

new(height, width)

@spec new(dimension(), dimension()) :: t()
Link to this function

pixelmap(display)

@spec pixelmap(t()) :: pixelmap()