tia

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: GPL-3.0, GPL-3.0 Imports: 11 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 achive 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 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. each sprite object also contains HOMVE information
	// - HmoveLatch indicates whether HMOVE has been triggered this scanline.
	// it is reset when a new scanline begins
	HmoveLatch bool

	// - HmoveCt counts backwards from 15 to -1 (represented by 255). note that
	// unlike how it is described in TIA_HW_Notes.txt, we always send the extra
	// tick to the sprites on Phi1.  however, we also send the HmoveCt value,
	// whether or not the extra should be honoured is up to the sprite.
	// (TIA_HW_Notes.txt says that HmoveCt is checked *before* sending the
	// extra tick)
	HmoveCt uint8

	FutureHmove delay.Event
	// contains filtered or unexported fields
}

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

func NewTIA

func NewTIA(tv television.Television, mem bus.ChipBus, vblankBits *input.VBlankBits) (*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) Step

func (tia *TIA) Step(readMemory bool) (bool, error)

Step moves the state of the tia forward one video cycle returns the state of the CPU's RDY flag.

func (TIA) String

func (tia TIA) String() string

func (*TIA) UpdateTIA

func (tia *TIA) UpdateTIA(data bus.ChipData) bool

UpdateTIA checks for side effects in the TIA sub-system.

Returns true if ChipData has *not* been serviced.

Directories

Path Synopsis
Package audio implements the audio generation of the TIA.
Package audio implements the audio generation of the TIA.
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 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 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