polycounter

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: GPL-3.0, GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package polycounter implements the polynomial counters found in the TIA. Described by Andrew Towers in the "Atari 2600 TIA Hardware Notes" (TIA_HW_Notes.txt), polynomial counters are a predictably performative way of counting in simple electronics - performance of ripple counters can change due to carrying etc.

In our emulation we are of course using ripple counters internally. But for the purposes of debugging the TIA loop (HSYNC counter) we'd still like to know what the equivalent polycounter value is. We use a 6-bit polycounter for this.

hsync := polycounter.New(6)

We advance the counter with the Tick() function. The binary representation of the polycounter value can be retreived with the ToBinary() function.

Polycounter's will loop around on their own when the bit sequence elapses but this never happens in the VCS. Instead a Reset() signal is generated when the polycounter reaches a certain count. For example, for the HSYNC counter this happens on count 57.

In the 2600, polycounter logic is also used to generate the bit sequences required for TIA audio emulation. A real TIA variously uses 4-bit, 5-bit and 9-bit polycounters to generate the sound waves available to the 2600 programmer. As of yet, this package doesn't support this functionality correctly. The bit sequences required are hard-coded into the tia/audio package as discovered by Ron Fries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Polycounter

type Polycounter int

Polycounter counts through the entries of a 6 bit polycounter. For the purposes of the emulation we represent it as an integer and index a pre-calculated table as required.

func (*Polycounter) Count

func (p *Polycounter) Count() int

Count reports the current polycounter value as an integer. For the bit pattern representation, use the ToBinary() function.

func (*Polycounter) Reset

func (p *Polycounter) Reset()

Reset is a convenience function to reset count value to 0.

func (Polycounter) String

func (p Polycounter) String() string

func (*Polycounter) Tick

func (p *Polycounter) Tick() bool

Tick advances the Polycounter and resets when it reaches the limit. Returns true if counter has reset.

func (*Polycounter) ToBinary

func (p *Polycounter) ToBinary() string

ToBinary returns the bit pattern of the current polycounter value.

Jump to

Keyboard shortcuts

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