Object Vectors

Most game involve moving patterns. Most patterns move along a line. The Astrocade system ROM provides the vectoring routines to facilitate programming such pattern motion.

The vectoring routines work with a memory array called a vector. Represented within this vector are the coordinates of the object, the velocities of the object, and the status information necessary to control the object. By periodically invoking the vectoring routine, this data is updated and can be used to direct the motion of a pattern.

Vector Attributes

More formally, a vectored object possesses an x- and y-coordinate. Associated with these coordinates are velocities ΔX and ΔY, which are added to X and Y each time increment. Since the screen is finite, there also exists two upper and two lower limits XLU, XLL, YLU, and YLL. When these limits are reached, a response is triggered.

The HVGSYS vectoring routine allows for two different responses to a limit trigger. Either the sign of the delta is reversed, or vectoring is stopped for that coordinate. This is specified by a flag byte. When a limit is hit, it is indicated in a status byte. Also, the coordinate is set equal to the limit, preventing overshoot.

Utilizing the vectoring routines involves a number of user responsibilities. The user must properly initialize certain fields in the vector block. They must increment the time base byte and periodically call the vectoring routine. Status bits must be checked and writing must be done.

To ensure high accuracy, coordinates and deltas are double-precision. The assumed binary “decimal point” is between the high- and low-order byte.

Vector blocks must be stored in RAM.

The Vector Block

The following diagrams illustrate the vector block's layout and the attendant user responsibilities:

Magic Register (VBMR)

The Magic Register byte provides a number of pattern transformation functions, depending on which bits are set. The key functions are EXPAND, OR, XOR, FLOP, and PLOP.

Examples from Vector Animation Tutorial:

Magic byte (decimal) Magic byte (hex) Result Description
0 0H PLOP Draw image, destroy background
8 08H Expand + PLOP Draw monochrome image, destroy background
16 10H OR Draw image, keep background where image blank (bit 0)
24 18H Expand + OR Draw monochrome image, keep background where image blank
32 20H XOR Draw image, merge with background
40 28H Expand + XOR Draw monochrome image, merge with background
64 40H FLOP + PLOP Draw image horizontally flipped, destroy background
72 48H Expand + FLOP + PLOP Draw monochrome image horizontally flipped, destroy background
80 50H FLOP + OR Draw image horizontally flipped, keep background
88 58H Expand + FLOP + OR Draw monochrome image, horizontally flipped, keep background
96 60H FLOP + XOR Draw image horizontally flipped, merge with background
104 68H Expand + FLOP + XOR Draw monochrome image, horizontally flipped, merge with background

Vector Status (VBSTAT)

Bit Name Label Description
0–5 Not used
6 Active VBSACT Set by user to indicate that vector is active. The vectoring routines will do no processing if reset.
7 Blank VBBLNK Must be initialized by user to reset state. Thereafter, maintained by VWRIT and VBLANK.

Time Base (VBTIMB)

The Time Base byte determines how often the delta values are applied to the coordinates. For example, a value of 4 would increase the coordinate(s) by 4 delta increments per vector call.

VBTIMB decrements to 0 after calling VECT. Therefore, a non-zero value must be stored here before calling VECT.

Delta X/Y (VBDXL, VBDXH, VBDYL, VBDYH)

A delta is a value indicating a direction, or vector. For example, placing 1 in the x-delta and 3 in the y-delta would make the pattern move down 3 pixels and right 1 pixel. Calling VECT will update the coordinates appropriately.

The Arcade allows for fractional deltas, i.e., finer movements, by using a second byte. VBDXH and VBDYH store the whole number values of the deltas, while VBDXL and VBDYL store the fractional halves. For example, to have your pattern move 1 pixel down every four calls, you would enter a y-delta of 0.25, or VBDYH = 0 and VBDYL = 25.

X/Y Coordinate (VBXL, VBXH, VBYL, VBYH)

The x- and y-coordinate of the pattern's screen position.

X/Y Check Mask (VBXCHK, VBYCHK)

The check mask byte determines whether a limit (i.e., boundary) is attained and how to respond. Limit values are defined in the object's limit table and passed to the object vectoring routines (i.e., VECT or VECTC).

Bit Name Label Description
0 Limit Check VBCLMT Set to one (1) to enable limit checking.
1 Reverse Delta VBCREV Changes the sign of the delta when the limit is reached. This can be used to cause objects to 'bounce' off barriers.
3 Limit Attained VBCLAT In contrast to the bounce effect, the system will set the limit attained flag and hold the pattern at the limit position until the user changes the delta.

Old Screen Address (VBOAL, VBOAH)

VBOAL and VBOAH are maintained by the user if VBLANK is being used to erase graphics. If so, you must take the absolute screen address calculated by VWRITR and place it here.

Limit Table

The Limit Table is a four-byte list indicating the boundaries of a vectored pattern:

Byte Name Description
1 X lower limit The leftmost boundary the pattern may reach
2 X upper limit The rightmost boundary the pattern may reach
3 Y lower limit The topmost boundary the pattern may reach
4 Y upper limit The bottommost edge the pattern may reach

Reference: Lance F. Squire, Bally/Astrocade Vector Animation Tutorial [PDF].