gameboy

package
v0.0.0-...-77df42f Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = ppu.ScreenWidth
	ScreenHeight = ppu.ScreenHeight
)

Variables

View Source
var (
	// FrameRate is the frame rate of the emulator.
	FrameRate = 59.97
	// FrameTime is the time it should take to render a frame.
	FrameTime = time.Second / time.Duration(FrameRate)
)

Functions

func AsModel

func AsModel(m types.Model) func(gb *GameBoy)

func Rotate2DFrame

func Rotate2DFrame(frame [ScreenHeight][ScreenWidth][3]uint8, angleX, angleY, angleZ float64) [ScreenHeight][ScreenWidth][3]uint8

Rotate2DFrame rotates a 2D framebuffer in 3D space with perspective correction.

Types

type GameBoy

type GameBoy struct {
	sync.RWMutex
	CPU *cpu.CPU
	PPU *ppu.PPU

	APU    *apu.APU
	Timer  *timer.Controller
	Serial *serial.Controller

	Bus *io.Bus

	log.Logger

	Printer *accessories.Printer

	Scheduler *scheduler.Scheduler
	// contains filtered or unexported fields
}

GameBoy represents a Game Boy. It contains all the components of the Game Boy. It is the main entry point for the emulator.

func NewGameBoy

func NewGameBoy(rom []byte, opts ...Opt) *GameBoy

NewGameBoy returns a new GameBoy.

func (*GameBoy) AttachAudioListener

func (g *GameBoy) AttachAudioListener(player func([]uint8))

func (*GameBoy) Colourise

func (g *GameBoy) Colourise()

func (*GameBoy) Frame

func (g *GameBoy) Frame() [ppu.ScreenHeight][ppu.ScreenWidth][3]uint8

Frame will step the emulation until the PPU has finished rendering the current frame. It will then prepare the frame for display, and return it.

func (*GameBoy) LinkFrame

LinkFrame will step the emulation until the PPU has finished rendering the current frame. It will then prepare the frame for display, and return it.

func (*GameBoy) SendCommand

func (g *GameBoy) SendCommand(command emulator.CommandPacket) emulator.ResponsePacket

func (*GameBoy) SetModel

func (g *GameBoy) SetModel(m types.Model)

func (*GameBoy) Start

func (g *GameBoy) Start(frames chan<- []byte, events chan<- event.Event, pressed <-chan io.Button, released <-chan io.Button)

func (*GameBoy) StartLinked

func (g *GameBoy) StartLinked(
	frames1 chan<- []byte,
	events1 chan<- event.Event,
	pressed1 <-chan io.Button,
	released1 <-chan io.Button,
	frames2 chan<- []byte,
	events2 chan<- event.Event,
	pressed2 <-chan io.Button,
	released2 <-chan io.Button,
)

func (*GameBoy) State

func (g *GameBoy) State() emulator.State

func (*GameBoy) TogglePause

func (g *GameBoy) TogglePause()

type Opt

type Opt func(gb *GameBoy)

Opt is a function that modifies a GameBoy instance.

func Debug

func Debug() Opt

Debug

func NoAudio

func NoAudio() Opt

func SerialConnection

func SerialConnection(gbFrom *GameBoy) Opt

func SerialDebugger

func SerialDebugger(output *string) Opt

func Speed

func Speed(speed float64) Opt

func WithBootROM

func WithBootROM(rom []byte) Opt

WithBootROM sets the boot ROM for the emulator.

func WithLogger

func WithLogger(log log.Logger) Opt

func WithPrinter

func WithPrinter(printer *accessories.Printer) Opt

type Point

type Point struct {
	X, Y, Z float64
}

Point represents a point in 3D space.

Jump to

Keyboard shortcuts

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