tia

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: GPL-3.0, GPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package TIA implements the custom video/audio chip found in the the VCS. The TIA is an extremely tricky device and great effort has been expended in creating an accurate emulation. There are undoubtedly subtleties not considered by the emulation but none-the-less it seems accurate for a great many of the ROMs that have been tested.

For clarity the emulation is split across six packages, which coordinates the other five. The principle of the TIA emulation is as follows:

Three times for every tick of the CPU, the TIA Step() function is called. The Step() function takes a single argument saying whether TIA memory should be checked for side-effects. The timing of this is handled by the VCS type in the hardware package but generally speaking there is three video cycles (TIA Step()s) for every one CPU cycle.

The best description of how the TIA works is to be found in the document:

Atari 2600 TIA Hardware Notes, v1.0, by Andrew Towers

The file is often named TIA_HW_Notes.txt and that is the label that is used when referring to it, throughout the commentary in this emulation. The remainder of this Overview relates the high level concepts described in that document with the emulation. Sub-package documentation go into further detail, and code commentary into even more.

The two-phase clock generator is implemented in the phaseclock package. Each phase clock is ticked forward whenever the part of the TIA affected is active. For the Horizontal Clock, the phase clock is ticked forward on every call to Step().

Closely related to the phase clock is the polynomial counter or polycounter (and found in the package of that name). A polycounter is ticked forward whenever its controlling phase clock reaches the rising edge of the second phase. In this emulation that means whenever the phase clock's Phi2() function returns true.

The most important use of the polycounter is the HSYNC counter. The HSYNC counter controls the horizontal scanline of the television screen. At key points in the polycounter sequence, signals are sent to the television. and are used to synchronise the VCS and the TV (eg. HBLANK)

Updating of TIA registers happens in carefully orchestrated cascade. I defer to the code and commentary for the fuller description of what is happening, but it is sufficient to say here that some side effects must take place before others. The various Update*() functions in the tia package and sub-packages help achieve this.

At the end of every Step() function (the end of the video cycle) the TV signal is compiled and sent to the attached television.

The audio signal is also calculated at this point and sent along at the same time. The VCS audio implementation can found in the audio sub-package.

A very important concept in the emulation of the TIA is the concept of delays. Delays occur in the TIA as a consequence of the electric circuit design and also because of the presence of digital latches. For the emulation I have not considered the difference causes in too much detail and have implemented delays in the future package. The TIA code is sprinkled with references to future Events throughout all packages and sub-packages; the timing of when these Events are ticked forward is critically important to the accuracy of the emulation. Again, I defer to the code and commentary for detailed explanations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RIOTports added in v0.16.0

type RIOTports interface {
	Update(chipbus.ChangedRegister) bool
}

RIOTports is used to connect the TIA with the RIOT Ports implementation. We need this because the RIOT is affected by one of the bits in the VBLANK signal but because VBLANK is in the TIA address space we need to forward it from here.

type TIA

type TIA struct {

	// for clarity we think of tia video and audio as sub-systems
	Video *video.Video
	Audio *audio.Audio

	// horizontal blank controls whether to send colour information to the
	// television. it is turned on at the end of the visible screen and turned
	// on depending on the HMOVE latch. it is also used to control when sprite
	// counters are ticked.
	Hblank bool

	// Hmove information
	Hmove hmove.Hmove

	PClk phaseclock.PhaseClock
	// contains filtered or unexported fields
}

TIA contains all the sub-components of the VCS TIA sub-system.

func NewTIA

func NewTIA(instance *instance.Instance, tv TV, mem chipbus.Memory, riot RIOTports, cpu *cpu.CPU) (*TIA, error)

NewTIA creates a TIA, to be used in a VCS emulation.

func (*TIA) Label

func (tia *TIA) Label() string

Label returns an identifying label for the TIA.

func (*TIA) Plumb added in v0.7.1

func (tia *TIA) Plumb(tv TV, mem chipbus.Memory, riot RIOTports, cpu *cpu.CPU)

Plumb the a new ChipBus into the TIA.

func (*TIA) RSYNCstate added in v0.10.1

func (tia *TIA) RSYNCstate() (bool, bool)

RSYNCstate returns whether the RSYNC alignment and reset latches are active. Both are scheduled at the same time and align takes less time to complete than the reset.

func (*TIA) Snapshot added in v0.7.1

func (tia *TIA) Snapshot() *TIA

Snapshot creates a copy of the TIA in its current state.

func (*TIA) Step

func (tia *TIA) Step(update bool) error

Step moves the state of the tia forward one video cycle. The update argument should be true if TIA is to be updated by changes in the TIA Chip memory.

func (*TIA) String

func (tia *TIA) String() string

func (*TIA) Update added in v0.16.0

func (tia *TIA) Update(data chipbus.ChangedRegister) bool

Update checks to see if ChipData applies tot he TIA and updates accordingly.

Returns true if ChipData has *not* been serviced.

type TV added in v0.16.0

type TV interface {
	Signal(signal.SignalAttributes) error
	GetCoords() coords.TelevisionCoords
}

TV defines the television functions required by the TIA type.

Directories

Path Synopsis
Package audio implements the audio generation of the TIA.
Package audio implements the audio generation of the TIA.
mix
Package mix is used to combine two distinct sound sources into either a mono or stereo signal.
Package mix is used to combine two distinct sound sources into either a mono or stereo signal.
Package delay is a replacement for the future package, which has now been removed.
Package delay is a replacement for the future package, which has now been removed.
Package hmove represents the TIA HMOVE process.
Package hmove represents the TIA HMOVE process.
Package phaseclock defines the two phase clock generator used to drive the various polynomial counters in the TIA.
Package phaseclock defines the two phase clock generator used to drive the various polynomial counters in the TIA.
Package polycounter implements the polynomial counters found in the TIA.
Package polycounter implements the polynomial counters found in the TIA.
Package revision handles/documents the differences in the TIA across different models of the Atari 2600.
Package revision handles/documents the differences in the TIA across different models of the Atari 2600.
Package video implements pixel generation for the emulated TIA.
Package video implements pixel generation for the emulated TIA.

Jump to

Keyboard shortcuts

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