GRASS programming language
Encyclopedia
GRASS was a programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 created to script 2D
2D computer graphics
2D computer graphics is the computer-based generation of digital images—mostly from two-dimensional models and by techniques specific to them...

 vector graphics
Vector graphics
Vector graphics is the use of geometrical primitives such as points, lines, curves, and shapes or polygon, which are all based on mathematical expressions, to represent images in computer graphics...

 animations. GRASS was similar to BASIC
BASIC
BASIC is a family of general-purpose, high-level programming languages whose design philosophy emphasizes ease of use - the name is an acronym from Beginner's All-purpose Symbolic Instruction Code....

 in syntax, but added numerous instructions for specifying 2D object animation, including scaling, translation, rotation and color changes over time. It quickly became a hit with the artistic community who were experimenting with the new medium of computer graphics
Computer graphics
Computer graphics are graphics created using computers and, more generally, the representation and manipulation of image data by a computer with help from specialized software and hardware....

, and will remain most famous for its use by Larry Cuba to create the original "attacking the death star will not be easy" animation in Star Wars
Star Wars
Star Wars is an American epic space opera film series created by George Lucas. The first film in the series was originally released on May 25, 1977, under the title Star Wars, by 20th Century Fox, and became a worldwide pop culture phenomenon, followed by two sequels, released at three-year...

. A later version that was adapted to support raster graphics was known as ZGrass.

History

The original version of GRASS was developed by Tom DeFanti for his 1974 Ohio State University
Ohio State University
The Ohio State University, commonly referred to as Ohio State, is a public research university located in Columbus, Ohio. It was originally founded in 1870 as a land-grant university and is currently the third largest university campus in the United States...

 Ph.D. thesis. It was developed on a PDP-11
PDP-11
The PDP-11 was a series of 16-bit minicomputers sold by Digital Equipment Corporation from 1970 into the 1990s, one of a succession of products in the PDP series. The PDP-11 replaced the PDP-8 in many real-time applications, although both product lines lived in parallel for more than 10 years...

/45 driving a Vector General 3DR display, and as the name implies, this was a purely vector graphics
Vector graphics
Vector graphics is the use of geometrical primitives such as points, lines, curves, and shapes or polygon, which are all based on mathematical expressions, to represent images in computer graphics...

 machine. GRASS included a number of vector-drawing commands, and could organize collections of them into a hierarchy, applying the various animation effects to whole "trees" of the image at once (stored in arrays). It was this version that was used for the Star Wars animation, if you re-watch this portion of the film you can see object trees popping into the image at various times.

After graduation, DeFanti moved to the University of Illinois, Chicago Circle
University of Illinois at Chicago
The University of Illinois at Chicago, or UIC, is a state-funded public research university located in Chicago, Illinois, United States. Its campus is in the Near West Side community area, near the Chicago Loop...

. There he joined up with Dan Sandin and together they formed the Circle Graphics Habitat (today known as the Electronic Visualization Laboratory
Electronic Visualization Laboratory
The Electronic Visualization Laboratory is a cross-disciplinary research lab at the University of Illinois at Chicago. It brings together faculty and students from the Art and Computer Science departments of UIC...

, or EVL). Sandin had joined the university in 1971 and set about building what he thought of as the video version of a Moog synthesizer
Moog synthesizer
Moog synthesizer may refer to any number of analog synthesizers designed by Dr. Robert Moog or manufactured by Moog Music, and is commonly used as a generic term for older-generation analog music synthesizers. The Moog company pioneered the commercial manufacture of modular voltage-controlled...

, known as the Sandin Image Processor
Sandin Image Processor
The Sandin Image Processor is a video synthesizer, usually introduced as the "video equivalent of a Moog audio synthesizer," invented by Dan Sandin. That is, it accepted basic video signals and mixed and modified them in a fashion similar to what a Moog synthesizer did with audio...

, or IP. The IP was an analog computer
Analog computer
An analog computer is a form of computer that uses the continuously-changeable aspects of physical phenomena such as electrical, mechanical, or hydraulic quantities to model the problem being solved...

 which took two video inputs, mixed them, colored the results, and then re-created TV output.

DeFanti added the existing GRASS system as the input to the IP, creating the GRASS/Image Processor, which was used throughout the mid-1970s. In order to make the system more useful, DeFanti and Sandin added all sorts of "one-off" commands to the existing GRASS system, but these changes also made the language considerably more idiosyncratic. In 1977 another member of the Habitat, Nola Donato, re-designed many of GRASS's control structures into more general forms, resulting in the considerably cleaner GRASS3.

In 1977 DeFanti was introduced to Jeff Frederiksen, a chip designer working at Dave Nutting Associates
Dave Nutting Associates
David Judd Nutting is a graduate of the Pratt Institute with a degree in industrial design. After leaving the Army Corps of Engineers, he joined the design firm of Brooks Stevens Associates. During his time there he was involved in a wide variety of projects, working on everything from Evinrude...

. Nutting had been contracted by Midway, the videogame division of Bally, to create a standardized graphics driver chip
Graphics processing unit
A graphics processing unit or GPU is a specialized circuit designed to rapidly manipulate and alter memory in such a way so as to accelerate the building of images in a frame buffer intended for output to a display...

. They intended to use it in most of their future arcade games, as well as a video game console
Video game console
A video game console is an interactive entertainment computer or customized computer system that produces a video display signal which can be used with a display device to display a video game...

 they were working on which would later turn into the Astrocade. Midway was quite interested in seeing the GRASS language running on their system, and contracted DeFanti to port it to the platform. A number of people at the Habitat, as well as some from Nutting, worked on the project, which they referred to as the Z Box. GRASS3 running on it became Zgrass. The work would never be released by Midway, but the Circle would produce machines based on it as the Datamax UV-1
Datamax UV-1
The Datamax UV-1 was a pioneering computer designed by a group of computer graphics artists working at the University of Illinois at Chicago, known as the Circle Graphics Habitat...

.

The Z-Box was a raster graphics
Raster graphics
In computer graphics, a raster graphics image, or bitmap, is a data structure representing a generally rectangular grid of pixels, or points of color, viewable via a monitor, paper, or other display medium...

 machine, unlike the original GRASS systems, so while most of the GRASS3 style was maintained in Zgrass, it added a number of commands dedicated to raster images. This included an extensive set of bit block transfer
Bit blit
Bit BLIT is a computer graphics operation in which several bitmaps are combined into one using a raster operator....

 commands in order to simulate sprites, something the hardware didn't include.

The last version of GRASS was RT/1, a port of GRASS to other platforms that divorced the language from the display model and allowed it to be ported to other platforms. Versions existed for DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

, Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

, SGI
Silicon Graphics
Silicon Graphics, Inc. was a manufacturer of high-performance computing solutions, including computer hardware and software, founded in 1981 by Jim Clark...

 platform using OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

, HP-UX
HP-UX
HP-UX is Hewlett-Packard's proprietary implementation of the Unix operating system, based on UNIX System V and first released in 1984...

, AIX
AIX operating system
AIX AIX AIX (Advanced Interactive eXecutive, pronounced "a i ex" is a series of proprietary Unix operating systems developed and sold by IBM for several of its computer platforms...

, Macintosh and Amiga
Amiga
The Amiga is a family of personal computers that was sold by Commodore in the 1980s and 1990s. The first model was launched in 1985 as a high-end home computer and became popular for its graphical, audio and multi-tasking abilities...

. The language remains similar to the earlier versions, so the reason for the change of name is unclear.

Description

Zgrass was based on a standard set of BASIC commands and used most of its syntax. Where Zgrass differed from BASIC was that all commands were in fact functions and returned values, similar to the C programming language
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

. If there was no obvious return value it was expected that a function would return 1 if it succeeded, and 0 if it failed. For instance, the command PRINT PRINT 10 would be illegal in BASIC, but in Zgrass this would print 10 1, the 1 being the value returned by second PRINT, meaning "I successfully output the string '10'".

Programs in Zgrass were referred to as "macros", and stored as strings. Both of these oddities were deliberate, as Zgrass allowed any string to become a program. For instance, MYBOX="BOX 0,0,100,100,2" defines a string (no need for a $ as in BASIC) containing a snippet of Zgrass code. Simply typing MYBOX from that point on would run the command(s) inside. This feature can be used in place of the more traditional GOSUB
GOSUB
GOSUB is a command in many versions of the BASIC computer programming language. A GOSUB statement jumps to a line elsewhere in the program. That line and the following lines up to a RETURN are used as a simple kind of a subroutine without parameters or local variables.The GOSUB command may be used...

command from BASIC, but has the added advantage of having a well defined name as opposed to an opaque line number. In addition the command remains a string, and can be manipulated at runtime with standard string operations.

Most BASIC interpreters of the era converted the input text into a "tokenized" version in which each of the commands was replaced by a single number (typically one byte
Byte
The byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...

 long). This made the program run faster because it didn't have to continually decode the commands from the strings every time. Zgrass's use of string-based macros made this difficult, so they didn't bother with tokenization. Instead they included a compiler
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...

 which could be used on any particular macro, speeding it up many times. Programs would often consist of a mix of compiled and uncompiled macros.

Line numbers were optional in Zgrass, and typically only appeared on lines that were the target of a GOTO. Most BASIC interpreters required line numbers for every line of code, but this was due to their use in the "line editor"–if you needed to edit that line, the only way to refer to it was by number. Zgrass used a more advanced full-screen editor that eliminated this need (as was the case for True BASIC
True BASIC
True BASIC is a variant of the BASIC programming language descended from Dartmouth BASIC — the original BASIC — invented by college professors John G. Kemeny and Thomas E...

). Zgrass allowed any string to act as a "line number", GOTO 10 and GOTO MARKER were both valid. Zgrass also included nameless branches, using the SKIP instruction, which would move forward or back a given number of lines.

In keeping with its original purpose as a graphics language, Zgrass included numerous commands for simple drawing. Zgrass's coordinate system was based on that of the original graphics chip that Nutting had designed, based on a 320×202 grid. The Astrocade, for some reason, used only half the resolution, a 160×101 display. To avoid potential mapping problems, the coordinate space's zero point was placed in the center of the screen. −160 to 160 were valid X locations, and -101 to 101 valid Y locations. For use on the Astrocade you used the positive locations only, whereas on the UV-1 the entire space was available.

Zgrass added a fairly complete set of array functions, as arrays are widely used in graphics. This included the ability to "capture" parts of the display into an array as a bitmap
Bitmap
In computer graphics, a bitmap or pixmap is a type of memory organization or image file format used to store digital images. The term bitmap comes from the computer programming terminology, meaning just a map of bits, a spatially mapped array of bits. Now, along with pixmap, it commonly refers to...

, which could then be manipulated as any other graphic item. This allowed Zgrass to include sprite-like functionality in the language, something the Nutting hardware did not include. Another feature the Astrocade did not include was the ability to process arrays with any reasonable speed, so the UV-1 included the Zilog supplied FPU
Floating point unit
A floating-point unit is a part of a computer system specially designed to carry out operations on floating point numbers. Typical operations are addition, subtraction, multiplication, division, and square root...

 for added performance.

Zgrass included three priorities (called levels) that allowed macros to be run normally, or in "foreground" or "background" levels. This added a simple form of multitasking
Computer multitasking
In computing, multitasking is a method where multiple tasks, also known as processes, share common processing resources such as a CPU. In the case of a computer with a single CPU, only one task is said to be running at any point in time, meaning that the CPU is actively executing instructions for...

 which was tremendously useful in an animation-oriented language. Game authors could place joystick-reading routines in a macro set to run in the background, and then the joystick would be read automatically whenever the current drawing macro completed. Functions placed in the foreground ran before either, and was often used for timers and other "low latency" needs. Zgrass included a TIMEOUT function that would call macros on a timed basis, making the implementation of timers very easy.

Zgrass also included a series of commands that "covered" CP/M, which allowed the disk to be accessed without exiting to the command prompt. You could easily save out macros to named files, and load them in the same way, allowing you to construct programs by loading up various macros from the disk into one large program. The commands also automatically made a backup copy of every save. Similar features were supported for cassette tape storage, but oddly the syntax was marred, disk commands were D-something, like DPUT while tape commands were something-TAPE, like PUTTAPE. (It is not clear why this difference in syntax existed; TPUT seems like a better solution, and PUT D filename even better.)

With programs constructed from randomly selected modules, Zgrass needed to have better control over its variables than BASIC. In BASIC all variables are "global", so if two subroutines both use the variable i (very common) then they could set each other's values leading to hard to debug problems. Under Zgrass a programmer loading up two modules would almost certainly find that both used i as a loop counter, and thus could cause problems. To address this problem, Zgrass allowed one to use lowercase letters for variables, in which case the variable was local only to that macro. Oddly the examples provided with the language do not make widespread use of this feature, potentially confusing new programmers who might not be aware the feature even exists.

Example

SINCURVE=[PROMPT "WHAT IS THE OFFSET?"
INPUT OFFSET
x=-160
angle=0
POINT OFFSET+x,SIN(angle)*80,3
angle=angle+2
IF (x=x+1)<159,SKIP -2]

This text creates a new macro called SINCURVE that can be called simply by typing SINCURVE into the command prompt, or from other macros or programs. SINCURVE uses two local variables, x and angle, as well as a global variable, OFFSET.

The PROMPT/INPUT is a modification of the original BASIC INPUT, which will not ask for the input if the user types it into the command line when calling the macro. In this case typing SINCURVE will result in the prompt appearing and the program waiting for input, whereas typing SINCURVE 30 will skip the prompt and OFFSET will automatically be assigned 30. This allows a single macro to be used both interactively and within a program as a function.

POINT is an example of one of the many graphics commands included in the Zgrass language. POINTrequires an X and Y location, as well as a color. In this example the user supplied OFFSET moves the x position of the curve on the screen, while the Y position is supplied by the trig function
Trigonometry
Trigonometry is a branch of mathematics that studies triangles and the relationships between their sides and the angles between these sides. Trigonometry defines the trigonometric functions, which describe those relationships and have applicability to cyclical phenomena, such as waves...

, suitably enlarged for display (in this case, 80 times). The color is supplied in the last input, and in this case is 3. The UV-1 used color registers, so 3 did not imply a particular color, but a color selected from the current palette.

The IF is likewise interesting. It places an increment, (x=x+1), in front of the test, a feature not normally available in BASIC. In this case the IF is told to call SKIP -2 if true, which will move back two lines and can be used in place of a GOTO.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK