screen

package
v0.0.0-...-657eaca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const FrameDelay = (1 / 59.7) * 100

FrameDelay is the time each GIF frame lasts, given that the Gameboy's screen is refreshed at 59.7Hz. In 100ths of a second (which is about 1.7 but we might add that up before we round it to integer). In any event, browsers seem to ignore any value of 0 or 1 (or more depending on sources) so delay will be initialized at 2 for new frames.

Variables

View Source
var FrameBounds = image.Rectangle{
	Min: image.Point{0, 0},
	Max: image.Point{X: options.ScreenWidth, Y: options.ScreenHeight},
}

FrameBounds holds fixed bounds for each frame.

Functions

This section is empty.

Types

type ColorIndex

type ColorIndex uint8

ColorIndex into a display-defined 4-color palette.

type GIF

type GIF struct {
	gif.GIF

	Filename string
	// contains filtered or unexported fields
}

GIF recorder generating animated images on the fly.

func NewGIF

func NewGIF(config *options.Options) *GIF

NewGIF instantiates a GIF recorder that will buffer frames and then output a GIF file when required.

func (*GIF) Close

func (g *GIF) Close()

Close writes the actual GIF file to disk.

func (*GIF) IsOpen

func (g *GIF) IsOpen() bool

IsOpen returns true if GIF recording is already in progress (i.e. we have a file currently open) or false otherwise.

func (*GIF) New

func (g *GIF) New(file *os.File, palette []color.RGBA)

New starts recording a new GIF file to the provided descriptor and starts recording screen output. This should be called at VBlank time to prevent incomplete frames.

func (*GIF) SaveFrame

func (g *GIF) SaveFrame()

SaveFrame adds the current frame to GIF slice and pre-instantiate next. We detect if the display was disabled. If so, save a "disabled screen" frame instead. TODO: stream saved frames to disk.

func (*GIF) Write

func (g *GIF) Write(colorIndex uint8)

Write adds a new pixel to the current GIF frame.

type Palette

type Palette [4]color.NRGBA

Palette containing 4 indexed colors.

type Screen

type Screen struct {
	Rectangle image.Rectangle
	// contains filtered or unexported fields
}

Screen represents the LCD display for a GameBoy. It works by shifting out individual pixels to a single dedicated texture.

func New

func New(ui *ui.UI, config *options.Options) *Screen

New returns an SDL2 display with a greyish palette and takes a zoom factor to size the window (current default is 2x).

func (*Screen) Close

func (s *Screen) Close()

Close frees allocated resources.

func (*Screen) Disable

func (s *Screen) Disable()

Disable turns off the display. A disabled GB screen will be drawn at VBlank time.

func (*Screen) Dump

func (s *Screen) Dump()

Dump writes the current pixel buffer to file for debugging purposes.

func (*Screen) Enable

func (s *Screen) Enable()

Enable turns on the display. Pixels will be drawn to our texture and showed at VBlank time.

func (*Screen) Enabled

func (s *Screen) Enabled() bool

Enabled returns whether the display is enabled or not (as part of the Display interface).

func (*Screen) Palette

func (s *Screen) Palette(p []color.RGBA)

Palette will set a new palette for the display and GIF.

func (*Screen) Screenshot

func (s *Screen) Screenshot()

Screenshot will make the display dump the next frame to file.

func (*Screen) StartRecord

func (s *Screen) StartRecord()

StartRecord will create a new GIF file and output frames into it until StopRecord is called.

We only just raise a flag here, recording should start and stop in VBlank.

func (*Screen) StopRecord

func (s *Screen) StopRecord()

StopRecord will flush recorded frames to the previously created GIF file. We only just raise a flag here, recording should start and stop in VBlank.

func (*Screen) VBlank

func (s *Screen) VBlank()

VBlank is called when the PPU reaches VBlank state. At this point, our SDL buffer should be ready to display.

func (*Screen) Write

func (s *Screen) Write(colorIndex uint8)

Write adds a new pixel (a mere index into a palette) to the texture buffer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL