gameboy

package
v0.0.0-...-60bc869 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScreenWidth  = 160 // Game boy screen width
	ScreenHeight = 144 // Game boy screen height
)

Variables

View Source
var GrayPalette = []color.RGBA{
	{
		R: 0x2b,
		G: 0x2b,
		B: 0x26,
		A: 0,
	},
	{
		R: 0x70,
		G: 0x6b,
		B: 0x66,
		A: 0,
	},
	{
		R: 0xa8,
		G: 0x9f,
		B: 0x94,
		A: 0,
	},
	{
		R: 0xe0,
		G: 0xdb,
		B: 0xcd,
		A: 0,
	},
}
View Source
var OriginalPalette = []color.RGBA{
	{
		R: 0x9b,
		G: 0xbc,
		B: 0x0f,
	},
	{
		R: 0x8b,
		G: 0xac,
		B: 0xf,
	},
	{
		R: 0x30,
		G: 0x62,
		B: 0x30,
	},
	{
		R: 0xf,
		G: 0x38,
		B: 0xf,
	},
}

Functions

This section is empty.

Types

type Gameboy

type Gameboy struct {

	// Joypad represents physycal buttons of Gameboy.
	Joypad *Joypad
	// contains filtered or unexported fields
}

Gameboy represents an emulator of Gameboy console.

func New

func New() *Gameboy

New creates and returns a new Gameboy instance.

func (*Gameboy) GetVideoBuffer

func (gb *Gameboy) GetVideoBuffer() []uint8

GetVideoBuffer returns ppu video buffer.

func (*Gameboy) LoadRom

func (gb *Gameboy) LoadRom(rom string) error

LoadRom loads a ROM file into the Gameboy's cartridge and returns an error if the file could not be loaded.

func (*Gameboy) Run

func (gb *Gameboy) Run()

Run runs the main loop of the Gameboy, which repeatedly executes instructions while the console is not paused, and waits for a signal on the stopCh channel to stop the console.

func (*Gameboy) Stop

func (gb *Gameboy) Stop()

Stop sends a signal on the stopCh channel to stop the Gameboy.

type Joypad

type Joypad struct {
	Start  bool
	Select bool
	B      bool
	A      bool
	Down   bool
	Up     bool
	Left   bool
	Right  bool
	// contains filtered or unexported fields
}

Joypad represents Gameboy input controller. It holds which keys are down/up.

func (*Joypad) Get

func (j *Joypad) Get() uint8

Get returns uint8 value indicating which keys are currently pressed.

func (*Joypad) Set

func (j *Joypad) Set(val uint8)

Set indicates whether an action or direction key is pressed.

Jump to

Keyboard shortcuts

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