polycounter

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 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 normal integers 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)

As the emulated polycounter is just an integer we can "tick" it along in the obvious way. We should take care to make sure it doesn't run past the end of the polycounter however. The accepted pattern is:

p++
if p >= polycounter.LenTable6Bit {
	p = 0
}

Whenever the polycounter is to be reset set it it polycounter.ResetValue.

The polycounter bit pattern can be retrieved at any time with the ToBinary() function.

Additional Note

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

View Source
const LenTable6Bit = 64

number of entries in 6 bit polycounter table.

View Source
const ResetValue = 0

ResetValue is used to reset the polycounter.

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) String

func (p Polycounter) String() string

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