dmgo

package module
v0.0.0-...-f8e0dc1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2024 License: MIT Imports: 13 Imported by: 0

README

dmgo - a gameboy emulator in go

My other emulators: famigo, vcsgo, segmago, and a1go.

Features:
  • Audio!
  • Saved game support!
  • Quicksave/Quickload, too!
  • All major MBCs suppported!
  • Glitches are relatively rare but still totally happen!
  • Graphical and auditory cross-platform support!
Dependencies:
  • You can compile on windows with no C dependencies.
  • Other platforms should do whatever the ebiten page says, which is what's currently under the hood.
Compile instructions
  • If you have go version >= 1.18, go build ./cmd/dmgo should be enough.
  • The interested can also see my build script b for profiling and such.
  • Non-windows users will need ebiten's dependencies.
Important Notes:
  • Keybindings are currently hardcoded to WSAD / JK / TY (arrowpad, ab, start/select)
  • Saved games use/expect a slightly different naming convention than usual: romfilename.gb.sav
  • Quicksave/Quickload is done by pressing m or l (make or load quicksave), followed by a number key

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CartInfo

type CartInfo struct {
	// Title is the game title (11 or 16 chars)
	Title string
	// ManufacturerCode is a mysterious optional 4-char code
	ManufacturerCode string
	// CGBFlag describes if it's CGB, DMG, or both-supported
	CGBFlag byte
	// NewLicenseeCode is used to indicate the publisher
	NewLicenseeCode string
	// SGBFlag indicates SGB support
	SGBFlag byte
	// CartridgeType indicates MBC-type, accessories, etc
	CartridgeType byte
	// ROMSizeCode indicates the size of the ROM
	ROMSizeCode byte
	// RAMSizeCode indicates the size of the RAM
	RAMSizeCode byte
	// DestinationCode shows if the game is meant for Japan or not
	DestinationCode byte
	// OldLicenseeCode is the pre-SGB way to indicate the publisher.
	// 0x33 indicates the NewLicenseeCode is used instead.
	// SGB will not function if the old code is not 0x33.
	OldLicenseeCode byte
	// MaskRomVersion is the version of the game cart. Usually 0x00.
	MaskRomVersion byte
	// HeaderChecksum is a checksum of the header which must be correct for the game to run
	HeaderChecksum byte
}

CartInfo represents a dmg cart header

func ParseCartInfo

func ParseCartInfo(cartBytes []byte) *CartInfo

ParseCartInfo parses a dmg cart header

func (*CartInfo) GetRAMSize

func (ci *CartInfo) GetRAMSize() uint

GetRAMSize decodes the ram size code into an actual size

func (*CartInfo) GetROMSize

func (ci *CartInfo) GetROMSize() uint

GetROMSize decodes the ROM size code into an actual size

type Emulator

type Emulator interface {
	Step()

	Framebuffer() []byte
	FlipRequested() bool

	UpdateInput(input Input)
	ReadSoundBuffer([]byte) []byte
	GetSoundBufferInfo() SoundBufferInfo

	GetCartRAM() []byte
	SetCartRAM([]byte) error

	MakeSnapshot() []byte
	LoadSnapshot([]byte) (Emulator, error)

	InDevMode() bool
	SetDevMode(b bool)
	UpdateDbgKeyState([]bool)
	DbgStep()
}

Emulator exposes the public facing fns for an emulation session

func NewEmulator

func NewEmulator(cart []byte, devMode bool) Emulator

NewEmulator creates an emulation session

func NewErrEmu

func NewErrEmu(msg string) Emulator

NewErrEmu returns an emulator that only shows an error message

func NewGbsPlayer

func NewGbsPlayer(gbs []byte, devMode bool) Emulator

NewGbsPlayer creates an gbsPlayer session

type Input

type Input struct {
	Joypad Joypad
}

Input covers all outside info sent to the Emulator

type Joypad

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

Joypad represents the buttons on a gameboy

type SoundBufferInfo

type SoundBufferInfo struct {
	UsedSize int
	IsValid  bool
}

SoundBufferInfo gives info about the sound buffer. IsValid is used to handle Emulator impls that don't have sound, e.g. errEmu

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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