timer

package
v0.0.0-...-5560990 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TimerRegisterOffset is register offset address
	TimerRegisterOffset types.Word = 0xFF00
	// DIV - Divider Register (R/W)
	// This register is incremented 16384 (~16779 on SGB) times a second.
	// Writing any value sets it to $00.
	DIV = 0x04
	// TIMA - Timer counter (R/W)
	// This timer is incremented by a clock frequency specified by the TAC register ($FF07).
	// The timer generates an interrupt when it overflows.
	TIMA = 0x05
	// TMA - Timer Modulo (R/W)
	// When the TIMA overflows, this data will be loaded.
	TMA = 0x06
	// TAC - Timer Control (R/W)
	// Bit 2 - Timer Stop
	//         0: Stop Timer
	//         1: Start Timer
	// Bits 1+0 - Input Clock Select
	//         00: 4.096 KHz (~4.194 KHz SGB)
	//         01: 262.144 Khz (~268.4 KHz SGB)
	//         10: 65.536 KHz (~67.11 KHz SGB)
	//         11: 16.384 KHz (~16.78 KHz SGB)
	TAC = 0x07
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Timer

type Timer struct {
	TIMA byte
	TAC  byte
	TMA  byte
	// contains filtered or unexported fields
}

Timer has 4 registers.

func NewTimer

func NewTimer() *Timer

NewTimer constructs timer peripheral.

func (*Timer) Read

func (timer *Timer) Read(addr types.Word) byte

func (*Timer) Update

func (timer *Timer) Update(cycles uint) bool

Update timer counter registers If timer is overflowed return true

func (*Timer) Write

func (timer *Timer) Write(addr types.Word, data byte)

Jump to

Keyboard shortcuts

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