Documentation ¶
Index ¶
- Constants
- type Action
- type GameBoy
- func (g *GameBoy) Home(eventType uint32)
- func (g *GameBoy) JoypadA(eventType uint32)
- func (g *GameBoy) JoypadB(eventType uint32)
- func (g *GameBoy) JoypadDown(eventType uint32)
- func (g *GameBoy) JoypadLeft(eventType uint32)
- func (g *GameBoy) JoypadRight(eventType uint32)
- func (g *GameBoy) JoypadSelect(eventType uint32)
- func (g *GameBoy) JoypadStart(eventType uint32)
- func (g *GameBoy) JoypadUp(eventType uint32)
- func (g *GameBoy) NextPalette(eventType uint32)
- func (g *GameBoy) PreviousPalette(eventType uint32)
- func (g *GameBoy) ProcessEvents()
- func (g *GameBoy) Quit(eventType uint32)
- func (g *GameBoy) Recover()
- func (g *GameBoy) Screenshot(eventType uint32)
- func (g *GameBoy) SetControls(keymap options.Keymap) (err error)
- func (g *GameBoy) StartStopRecord(eventType uint32)
- func (g *GameBoy) Stop()
- func (g *GameBoy) Tick() (res TickResult)
- func (g *GameBoy) ToggleVoice1(eventType uint32)
- func (g *GameBoy) ToggleVoice2(eventType uint32)
- func (g *GameBoy) ToggleVoice3(eventType uint32)
- func (g *GameBoy) ToggleVoice4(eventType uint32)
- type TickResult
Constants ¶
const VBlankRate = apu.GameBoyRate / 60
VBlankRate represents ticks to wait before refreshing the Home screen.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action func(eventType uint32)
Action type for user interactions. This might move to a ui package someday.
type GameBoy ¶
type GameBoy struct { UI *ui.UI APU *apu.APU CPU *cpu.CPU PPU *ppu.PPU Display *screen.Screen DMA *memory.DMA Serial *serial.Serial Timer *timer.Timer JPad *joypad.Joypad Controls map[options.KeyStroke]Action // contains filtered or unexported fields }
GameBoy structure grouping all our state machines to tick them together.
func New ¶
New just instantiates most of the emulator. No biggie. TODO: try cleaning this mess up a little.
func (*GameBoy) Home ¶
Home stops the emulation to display some kind of home menu. Clearing it should be done from the UI itself. Which, in itself, is going to be another whole thing.
Doing this should pave the way for high-level stuff the emulator should do on VBlank like saving or loading states and suchlike.
func (*GameBoy) JoypadDown ¶
JoypadDown updates the Joypad's registers for the Down direction.
func (*GameBoy) JoypadLeft ¶
JoypadLeft updates the Joypad's registers for the Left direction.
func (*GameBoy) JoypadRight ¶
JoypadRight updates the Joypad's registers for the Right direction.
func (*GameBoy) JoypadSelect ¶
JoypadSelect updates the Joypad's registers for the Select button.
func (*GameBoy) JoypadStart ¶
JoypadStart updates the Joypad's registers for the Start button.
func (*GameBoy) NextPalette ¶
NextPalette switches colors to the next defined palette, wrapping around. There should always be at least a default palette in the config object.
func (*GameBoy) PreviousPalette ¶
PreviousPalette switches colors to the previous defined palette, wrapping around. There should always be at least a default palette in the config object.
func (*GameBoy) ProcessEvents ¶
func (g *GameBoy) ProcessEvents()
func (*GameBoy) Recover ¶
func (g *GameBoy) Recover()
Recover should be called at the end of each Tick. If the program panics, it should then display some useful debug info before crashing.
func (*GameBoy) Screenshot ¶
Screenshot saves the current frame to disk as a PNG file. TODO: configurable folder, obviously.
func (*GameBoy) SetControls ¶
SetControls validates and sets the given control map for the emulator.
func (*GameBoy) StartStopRecord ¶
StartStopRecord starts recording video output to GIF and closes the file when done. Defined as a single action to toggle between the two and avoid opening several GIFs at once.
func (*GameBoy) Stop ¶
func (g *GameBoy) Stop()
Stop should be called before quitting the program and will close all needed resources.
func (*GameBoy) Tick ¶
func (g *GameBoy) Tick() (res TickResult)
Tick advances the whole emulator one step at a theoretical 4MHz. Since we're using SDL audio for timing this, we also return the current value of audio samples for each stereo channel as well as whether they should be played now.
func (*GameBoy) ToggleVoice1 ¶
ToggleVoice1 mutes or unmutes the first audio generator (Square 1).
func (*GameBoy) ToggleVoice2 ¶
ToggleVoice2 mutes or unmutes the second audio generator (Square 2).
func (*GameBoy) ToggleVoice3 ¶
ToggleVoice3 mutes or unmutes the third audio generator (Wave).
func (*GameBoy) ToggleVoice4 ¶
ToggleVoice4 mutes or unmutes the fourth audio generator (Noise).
type TickResult ¶
TickResult type to group return values from Tick.