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 struct {
// contains filtered or unexported fields
}
Polycounter counts from 0 to Limit. can be used to index a polycounter table
func New ¶
func New(numBits int) (*Polycounter, error)
New is the preferred method of initialisation for the Polycounter type
func (*Polycounter) Count ¶
func (pcnt *Polycounter) Count() int
Count reports the current polycounter value as an integer For the bit pattern representation, use the ToBinary() function.
func (*Polycounter) Match ¶
func (pcnt *Polycounter) Match(pattern string) (int, error)
Match returns the index of the specified pattern
func (*Polycounter) Reset ¶
func (pcnt *Polycounter) Reset()
Reset is a convenience function to reset count value to 0
func (Polycounter) String ¶
func (pcnt Polycounter) String() string
func (*Polycounter) Tick ¶
func (pcnt *Polycounter) Tick() bool
Tick advances the Polycounter and resets when it reaches the limit. returns true if counter has reset
func (*Polycounter) ToBinary ¶
func (pcnt *Polycounter) ToBinary() string
ToBinary returns the bit pattern of the current polycounter value