chibigb

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// must be power of two
	SAMPLES_PER_SECONDS = 44100
	CLOCKS_PER_SECONDS  = 4194304
	CLOCKS_PER_SAMPLE   = CLOCKS_PER_SECONDS / SAMPLES_PER_SECONDS
)
View Source
const (
	APU_WAVE_FORM_SQUARE APUWaveType = 0
	APU_WAVE_FORM_WAVE               = 1
	APU_WAVE_FORM_NOISE              = 2
)
View Source
const (
	CARTRIDGE_NO_MBC        CartridgeType = 0
	CARTRIDGE_MBC1                        = 1
	CARTRIDGE_MBC2                        = 2
	CARTRIDGE_MBC3                        = 3
	CARTRIDGE_MBC5                        = 4
	CARTRIDGE_MBC1_MULTI                  = 5
	CARTRIDGE_NOT_SUPPORTED               = 6
)
View Source
const (
	KEY_A      GameBoyKeys = 4
	KEY_B                  = 5
	KEY_START              = 7
	KEY_SELECT             = 6
	KEY_RIGHT              = 0
	KEY_LEFT               = 1
	KEY_UP                 = 2
	KEY_DOWN               = 3
)
View Source
const (
	CPUFLAG_NONE  = 0x00
	CPUFLAG_CARRY = 0x10
	CPUFLAG_HALF  = 0x20
	CPUFLAG_SUB   = 0x40
	CPUFLAG_ZERO  = 0x80
)
View Source
const (
	INTERRUPT_NONE    CPUInterrupt = 0x00
	INTERRUPT_VBLANK               = 0x01
	INTERRUPT_LCDSTAT              = 0x02
	INTERRUPT_TIMER                = 0x04
	INTERRUPT_SERIAL               = 0x08
	INTERRUPT_JOYPAD               = 0x10
)
View Source
const (
	GBC_PIXEL_RGB565 GameBoyColorPixelFormat = 0
	GBC_PIXEL_RGB555                         = 1
	GBC_PIXEL_BGR565                         = 2
	GBC_PIXEL_BGR555                         = 3
)
View Source
const APU_RING_BUFFER_SIZE int = 16 * 512 * 4
View Source
const GAMEBOY_HEIGHT = 144
View Source
const GAMEBOY_WIDTH = 160
View Source
const MBC1RAMBanksSize = 0x8000
View Source
const MBC2RAMBanksSize = 0x8000
View Source
const MBC3RAMBanksSize = 0x8000
View Source
const MBC5RAMBanksSize = 0x20000

Variables

View Source
var InitialValuesForFFXX = [256]byte{}/* 256 elements not displayed */

From Gambatte emulator

View Source
var OPCodeAccurate = [256]byte{}/* 256 elements not displayed */
View Source
var OPCodeBranchMachineCycles = [256]byte{}/* 256 elements not displayed */
View Source
var OPCodeCBAccurate = [256]byte{}/* 256 elements not displayed */
View Source
var OPCodeCBMachineCycles = [256]byte{}/* 256 elements not displayed */
View Source
var OPCodeMachineCycles = [256]byte{}/* 256 elements not displayed */

Functions

func CheckBit

func CheckBit(value byte, bit int) bool

func ClearBit

func ClearBit(value byte, bit int) byte

func SetBit

func SetBit(value byte, bit int) byte

Types

type APU

type APU struct {
	// contains filtered or unexported fields
}

func NewAPU

func NewAPU(console *Console) *APU

func (*APU) Read

func (apu *APU) Read(addr uint16) byte

func (*APU) ReadSoundBuffer

func (apu *APU) ReadSoundBuffer(toFill []byte) []byte

func (*APU) Reset

func (apu *APU) Reset()

func (*APU) Step

func (apu *APU) Step(cycleCount byte)

func (*APU) Write

func (apu *APU) Write(addr uint16, value byte)

type APURingBuffer

type APURingBuffer struct {
	// contains filtered or unexported fields
}

func NewAPURingBuffer

func NewAPURingBuffer() *APURingBuffer

func (*APURingBuffer) Read

func (a *APURingBuffer) Read(preSizedBuf []byte) []byte

func (*APURingBuffer) Write

func (a *APURingBuffer) Write(bytes []byte) (writeCount int)

type APUWave

type APUWave struct {
	// contains filtered or unexported fields
}

func (*APUWave) GetSample

func (a *APUWave) GetSample() (byte, byte)

type APUWaveType

type APUWaveType int

type CPU

type CPU struct {
	AF *CPURegister
	BC *CPURegister
	DE *CPURegister
	HL *CPURegister

	PC *CPURegister
	SP *CPURegister

	OpCodeTable   [256]CPUOpCodeEntity
	OpCodeCBTable [256]CPUOpCodeEntity

	IME         bool
	Halt        bool
	BranchTaken bool
	SkipPCBug   bool

	CurrentClockCycles   uint64
	DIVCycles            uint32
	TIMACycles           uint32
	SerialBit            int
	SerialCycles         int
	IMECycles            int
	UnhaltCycles         int
	InterruptDelayCycles int
	AccurateOpeCodeState int
	SpeedMultiplier      int
	ReadCache            byte
	// contains filtered or unexported fields
}

func NewCPU

func NewCPU(console *Console) *CPU

func (*CPU) CheckFlag

func (c *CPU) CheckFlag(flag byte) bool

func (*CPU) ClearAllFlags

func (c *CPU) ClearAllFlags()

func (*CPU) ClearFlag

func (c *CPU) ClearFlag(flag byte)

func (*CPU) FlipFlag

func (c *CPU) FlipFlag(flag byte)

func (*CPU) Halted

func (c *CPU) Halted() bool

func (*CPU) InterruptIsAboutToRaise

func (c *CPU) InterruptIsAboutToRaise() bool

func (*CPU) InterruptPending

func (c *CPU) InterruptPending() CPUInterrupt

func (*CPU) KeepCarryFlag

func (c *CPU) KeepCarryFlag()

XXX: naming

func (*CPU) KeepZeroFlag

func (c *CPU) KeepZeroFlag()

XXX: naming

func (*CPU) MemoryLoad

func (c *CPU) MemoryLoad(addr uint16, value byte)

func (*CPU) MemoryRead

func (c *CPU) MemoryRead(addr uint16) byte

func (*CPU) MemoryRetrieve

func (c *CPU) MemoryRetrieve(addr uint16) byte

func (*CPU) MemoryWrite

func (c *CPU) MemoryWrite(addr uint16, value byte)

func (*CPU) RequestInterrupt

func (c *CPU) RequestInterrupt(interrupt CPUInterrupt)

func (*CPU) Reset

func (c *CPU) Reset()

func (*CPU) ResetDIVCycles

func (c *CPU) ResetDIVCycles()

func (*CPU) ResetTIMACycles

func (c *CPU) ResetTIMACycles()

func (*CPU) ServeInterrupt

func (c *CPU) ServeInterrupt(interrupt CPUInterrupt)

func (*CPU) SetFlag

func (c *CPU) SetFlag(flag byte)

func (*CPU) SetZeroFlag

func (c *CPU) SetZeroFlag(result byte)

func (*CPU) Step

func (c *CPU) Step(count byte) byte

func (*CPU) UpdateSerial

func (c *CPU) UpdateSerial(clockCycles byte)

func (*CPU) UpdateTimers

func (c *CPU) UpdateTimers(clockCycles byte)

type CPUInterrupt

type CPUInterrupt int

type CPUOpCodeEntity

type CPUOpCodeEntity struct {
	// contains filtered or unexported fields
}

type CPURegister

type CPURegister struct {
	// contains filtered or unexported fields
}

func NewCPURegister

func NewCPURegister() *CPURegister

func (*CPURegister) Decrement

func (cr *CPURegister) Decrement()

func (*CPURegister) Get

func (cr *CPURegister) Get() uint16

func (*CPURegister) GetHigh

func (cr *CPURegister) GetHigh() byte

func (*CPURegister) GetHighPointer

func (cr *CPURegister) GetHighPointer() *byte

func (*CPURegister) GetLow

func (cr *CPURegister) GetLow() byte

func (*CPURegister) GetLowPointer

func (cr *CPURegister) GetLowPointer() *byte

func (*CPURegister) Increment

func (cr *CPURegister) Increment()

func (*CPURegister) Set

func (cr *CPURegister) Set(value uint16)

func (*CPURegister) SetHigh

func (cr *CPURegister) SetHigh(value byte)

func (*CPURegister) SetLow

func (cr *CPURegister) SetLow(value byte)

type Cartridge

type Cartridge struct {
	ROM []byte

	RTCPresent bool

	RumblePresent bool
	// contains filtered or unexported fields
}

func NewCartridge

func NewCartridge(console *Console) *Cartridge

func (*Cartridge) IsRTCPresent added in v1.2.0

func (c *Cartridge) IsRTCPresent() bool

func (*Cartridge) LoadFromBuffer

func (c *Cartridge) LoadFromBuffer(buffer []byte)

func (*Cartridge) UpdateCurrentRTC added in v1.2.0

func (c *Cartridge) UpdateCurrentRTC()

type CartridgeType

type CartridgeType int

type Console

type Console struct {
	CPU    *CPU
	Memory *Memory
	PPU    *PPU
	APU    *APU

	Cartridge  *Cartridge
	Controller *Controller
	// contains filtered or unexported fields
}

func NewConsole

func NewConsole() *Console

func (*Console) GetLCDColor

func (console *Console) GetLCDColor(index int) color.RGBA

func (*Console) LoadFromBuffer

func (console *Console) LoadFromBuffer(data []byte)

func (*Console) RunToVBlank

func (console *Console) RunToVBlank()

func (*Console) SetButtonState

func (console *Console) SetButtonState(button int, pressed bool)

func (*Console) SetPixels

func (console *Console) SetPixels(pixels []byte)

func (*Console) SetSoundBuffer

func (console *Console) SetSoundBuffer(buffer []byte)

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(console *Console) *Controller

func (*Controller) KeyPressed

func (c *Controller) KeyPressed(key GameBoyKeys)

func (*Controller) KeyReleased

func (c *Controller) KeyReleased(key GameBoyKeys)

func (*Controller) Read

func (c *Controller) Read() byte

func (*Controller) Reset

func (c *Controller) Reset()

func (*Controller) Step

func (c *Controller) Step(clockCycles byte)

func (*Controller) Update

func (c *Controller) Update()

func (*Controller) Write

func (c *Controller) Write(value byte)

type EnvelopeDirection

type EnvelopeDirection bool
const (
	ENVELOPE_UP   EnvelopeDirection = true
	ENVELOPE_DOWN                   = false
)

type GameBoyColorPixelFormat

type GameBoyColorPixelFormat int

type GameBoyKeys

type GameBoyKeys int

type Memory

type Memory struct {
	// contains filtered or unexported fields
}

func NewMemory

func NewMemory(console *Console) *Memory

func (*Memory) CommonPerformRead

func (m *Memory) CommonPerformRead(addr uint16) byte

func (*Memory) CommonPerformWrite

func (m *Memory) CommonPerformWrite(addr uint16, value byte)

func (*Memory) IORegistersPerformRead

func (m *Memory) IORegistersPerformRead(addr uint16) byte

func (*Memory) IORegistersPerformWrite

func (m *Memory) IORegistersPerformWrite(addr uint16, value byte)

func (*Memory) Load

func (m *Memory) Load(addr uint16, value byte)

func (*Memory) PerformDMA

func (m *Memory) PerformDMA(value byte)

func (*Memory) Read

func (m *Memory) Read(addr uint16) byte

func (*Memory) Reset

func (m *Memory) Reset()

func (*Memory) Retrieve

func (m *Memory) Retrieve(addr uint16) byte

func (*Memory) SetMemoryBankController

func (m *Memory) SetMemoryBankController()

func (*Memory) Write

func (m *Memory) Write(addr uint16, value byte)

type MemoryBankController

type MemoryBankController interface {
	PerformRead(addr uint16) byte
	PerformWrite(addr uint16, value byte)
}

func NewMemoryBankControllerMBC1

func NewMemoryBankControllerMBC1(console *Console) MemoryBankController

func NewMemoryBankControllerMBC2

func NewMemoryBankControllerMBC2(console *Console) MemoryBankController

func NewMemoryBankControllerMBC3 added in v1.2.0

func NewMemoryBankControllerMBC3(console *Console) MemoryBankController

func NewMemoryBankControllerMBC5 added in v1.2.0

func NewMemoryBankControllerMBC5(console *Console) MemoryBankController

func NewMemoryBankControllerNoMBC

func NewMemoryBankControllerNoMBC(console *Console) MemoryBankController

type MemoryBankControllerMBC1

type MemoryBankControllerMBC1 struct {
	// contains filtered or unexported fields
}

func (*MemoryBankControllerMBC1) PerformRead

func (m *MemoryBankControllerMBC1) PerformRead(addr uint16) byte

func (*MemoryBankControllerMBC1) PerformWrite

func (m *MemoryBankControllerMBC1) PerformWrite(addr uint16, value byte)

type MemoryBankControllerMBC2

type MemoryBankControllerMBC2 struct {
	// contains filtered or unexported fields
}

func (*MemoryBankControllerMBC2) PerformRead

func (m *MemoryBankControllerMBC2) PerformRead(addr uint16) byte

func (*MemoryBankControllerMBC2) PerformWrite

func (m *MemoryBankControllerMBC2) PerformWrite(addr uint16, value byte)

type MemoryBankControllerMBC3 added in v1.2.0

type MemoryBankControllerMBC3 struct {
	// contains filtered or unexported fields
}

func (*MemoryBankControllerMBC3) PerformRead added in v1.2.0

func (m *MemoryBankControllerMBC3) PerformRead(addr uint16) byte

func (*MemoryBankControllerMBC3) PerformWrite added in v1.2.0

func (m *MemoryBankControllerMBC3) PerformWrite(addr uint16, value byte)

func (*MemoryBankControllerMBC3) UpdateRTC added in v1.2.0

func (m *MemoryBankControllerMBC3) UpdateRTC()

type MemoryBankControllerMBC5 added in v1.2.0

type MemoryBankControllerMBC5 struct {
	// contains filtered or unexported fields
}

func (*MemoryBankControllerMBC5) PerformRead added in v1.2.0

func (m *MemoryBankControllerMBC5) PerformRead(addr uint16) byte

func (*MemoryBankControllerMBC5) PerformWrite added in v1.2.0

func (m *MemoryBankControllerMBC5) PerformWrite(addr uint16, value byte)

type MemoryBankControllerNoMBC

type MemoryBankControllerNoMBC struct {
	// contains filtered or unexported fields
}

func (*MemoryBankControllerNoMBC) PerformRead

func (m *MemoryBankControllerNoMBC) PerformRead(addr uint16) byte

func (*MemoryBankControllerNoMBC) PerformWrite

func (m *MemoryBankControllerNoMBC) PerformWrite(addr uint16, value byte)

type PPU

type PPU struct {
	SpriteXCacheBuffer [GAMEBOY_WIDTH * GAMEBOY_HEIGHT]int
	ColorCacheBuffer   [GAMEBOY_WIDTH * GAMEBOY_HEIGHT]byte
	FrameBuffer        [GAMEBOY_WIDTH * GAMEBOY_HEIGHT]byte
	ColorFrameBuffer   [GAMEBOY_WIDTH * GAMEBOY_HEIGHT]uint16

	GameBoyColorSpritePalettes     [8][4][2]uint16
	GameBoyColorBackgroundPalettes [8][4][2]uint16
	// contains filtered or unexported fields
}

func NewPPU

func NewPPU(console *Console) *PPU

func (*PPU) CompareLYToLYC

func (p *PPU) CompareLYToLYC()

func (*PPU) DisableScreen

func (p *PPU) DisableScreen()

func (*PPU) EnableScreen

func (p *PPU) EnableScreen()

func (*PPU) GetCurrentStatusMode

func (p *PPU) GetCurrentStatusMode() int

func (*PPU) GetIRQ48Signal

func (p *PPU) GetIRQ48Signal() byte

func (*PPU) RenderBG

func (p *PPU) RenderBG(line int, pixel int)

func (*PPU) RenderSprites

func (p *PPU) RenderSprites(line int)

func (*PPU) RenderWindow

func (p *PPU) RenderWindow(line int)

func (*PPU) Reset

func (p *PPU) Reset()

func (*PPU) ResetWindowLine

func (p *PPU) ResetWindowLine()

func (*PPU) ScanLine

func (p *PPU) ScanLine(line int)

func (*PPU) SetIRQ48Signal

func (p *PPU) SetIRQ48Signal(signal byte)

func (*PPU) Step

func (p *PPU) Step(clockCycles *byte) bool

func (*PPU) UpdateStatRegister

func (p *PPU) UpdateStatRegister()

type RTCRegisters added in v1.2.0

type RTCRegisters struct {
	// contains filtered or unexported fields
}

type SweepDirection

type SweepDirection bool
const (
	SWEEP_UP   SweepDirection = false
	SWEEP_DOWN                = true
)

Jump to

Keyboard shortcuts

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