The Amiga
The Amiga
The Amiga
THE AMIGA
Images;
Sounds, and
Animation
on the
Commodore"
Amiga
MICROSOFT-
PRESS
Michael Boom
PUBLISHED BY
Microsoft Press
A Division of Microsoft Corporation
16011 N.E. 36th Way, Box97017 Redmond, Washington 98073-9717
2 3456789MLML8909876
Distributed to the book trade in the United States by Harper & Row.
Distributed to the book trade in Canada by General Publishing Company, Ltd.
Distributed to the book trade outside the United States and Canada by Penguin Books Ltd.
Penguin Books Ltd., Harmondsworth, Middlesex, England
Penguin Books Australia Ltd., Ringwood, Victoria, Australia
Penguin Books N.Z. Ltd., 1S2-190 WairauRoad, Auckland 10, New Zealand
Foreword IX
Acknowledgments xi
Introduction xiii
SECTION 2 IMAGES
Chapter Two A Video Graphics Primer 27
Chapter Three Amiga Graphics Tools 53
Chapter Four Amiga BASIC Graphics: Screens, Windows,
and Palettes 85
Chapter Five Amiga BASIC Graphics: Creating Images 113
Chapter Six Amiga BASIC Graphics: Odds and Ends 143
SECTION 3 SOUNDS
Chapter Seven An Electronic Music Primer 173
Chapter Eight Amiga Music Tools 195
Chapter Nine Amiga BASIC Sound: Music and Speech 221
SECTION 4 ANIMATION
Chapter Ten A Computer Animation Primer 251
Chapter Eleven Amiga Animation Tools 269
Chapter Twelve Amiga BASIC Animation: Creating Moving
Objects 295
Chapter Thirteen Amiga BASIC Animation: Controlling Motion 327
Index 363
FOREWORD TO THE AMIGA
IX
tremendous powers, the Amiga is an ideal tool for the software
artist who wants to establish new standards in all of these areas.
Software that brings the best out of the Amiga will boggle minds
and make people squeal with delight.
Can we even imagine the future possibilities for the Amiga?
Western Union could have owned the patent on the telephone, but
turned it down; the company couldn't see the potential. Teievision
was first thought to be suitable only for civil-defense communica
tions. Only time and creative minds will determine the true
potential of the Amiga.
Much has been made recently of "desktop publishing," which,
by improving the quality and control available to the individual,
may revolutionize the process of communicating on paper. Without
discounting the importance of paper, video and sound loom as the
media of choice when you have to get a message across. It stands
to reason, then, that a "desktop video" market may develop around
the Amiga that eventually surpasses desktop publishing.
As the first audiovisual personal computer, the Amiga may be
the innovative product that stimulates an inteUectual revolution,
akin to Gutenberg's printing press. The Amiga: Images, Sounds,
and Animation, thoughtfully written by Michael Boom, can help
you have your own part in that revolution. Viva Amiga!
Trip Hawkins
President. Electronic Arts
ACKNOWLEDGMENTS
If you ask people what their favorite art medium is, chances are
excellent that they won't reply "personal computers." Most people
think personal computers are fine for managing a database,
running a spreadsheet, and processing a few words here and there,
but they usually don't think of them as an expressive medium. If
they do, they rank personal computers somewhere below crayons
and kazoos for creating quality images and sound.
Amiga users know this stereotype is false. With internal
hardware and system software designed specifically for graphics
and music, the Amiga juggles colors and sound as easily as it
calculates spreadsheets and shuffles words. By using the powerful
creative software available for the Amiga, users can draw pictures
with exquisite color and detail, and produce music and sound
effects on a par with professional synthesizers. Amiga users can
combine their artistic and musical masterpieces to create cartoon-
quality animation, an activity that was previously unavailable to all
but professional and student animators with access to expensive
equipment.
Like any other medium, using the Amiga creatively takes
knowledge and practice. This book is written to give you both,
teaching you the concepts you need to understand what you're
doing, and giving you examples so you can experiment with what
you learn. If you're a novice Amiga user, you'll find the fundamental
concepts of computer graphics and sound explained in primers
throughout the book. With these concepts m hand, you can easily
go through the following chapters that show you how to use
application programs like Deluxe Paint, Deluxe Music, and Deluxe
Video. Step-by-step examples give you practical experience using
these applications.
Experienced Amiga users will also find much of interest in this
book. The chapters on application programs explain advanced
features, and show you some tricks that you can use to get unique
results. They also review other software on the market, and explain
how additional hardware can turn your Amiga into an even more
advanced creative tool. If you're a BASIC programmer, you'll find
chapters explaining the intricate details of Amiga BASIC graphics,
sound, and animation commands, and showing you in example
programs how to combine them for useful results.
xui
HOW THIS BOOK IS ORGANIZED
This book is divided into four sections to make it easy for you to
find a specific area of interest. Section 1 introduces you to the
Amiga, taking you on a detailed tour of its hardware and system
software to see what makes it such a powerful computer. Section 2
covers graphics, showing you how to ceate still images on the
monitor screen. In Section 3, you'll find information about sound
how to create music, speech, and sound effects using the Amiga's
internal sound synthesis. Section 4 teaches you about animation,
showing you how to give motion to figures on the screen.
Each of the last three sections is organized the same way: The
first chapter of each section is a primer that introduces you to
important concepts you'll work with in that section. For example,
you learn about how computer monitors create images in Sec
tion 2, how the ear hears sound in Section 3, and how the illusion
of motion is created by changing still pictures in Section 4. The
second chapter of each section shows you how to use a specific
application programDeluxe Paint in Section 2, Deluxe Music
in Section 3, and Deluxe Video in Section 4and discusses
additional software and hardware you can use with your Amiga.
The remaining chapters in each section deal with Amiga BASIC
statements and functions.
xiv
There are two helpful appendices in the book. Appendix A is a
list of all the BASIC statements and functions used in this book,
with the format they use and a short explanation. As you write
your own BASIC programs, you can use this appendix as a
convenient reference if you forget the exact format of a statement,
or if you need to find the right statement to perform a BASIC task.
Appendix B is a list of all the software and hardware companies
mentioned in the book, with addresses you can write to for more
information about their products. Following these appendices is a
full index to help you quickly find any topic discussed in the book.
xv
The
In this section, you Machine
take a close look at the
Amiga to see what it is
and what it does. You'll
learn about the equip
ment the Amiga uses
to run, and to produce
graphics and sound.
I'll also learn about
levels of
with
every
mation and
presented in this sec
tion will take some of
the mystery out of the
Amiga's performance,
and give you the back
ground to tackle other
sections of this book
with ease.
CHAPTER ONE
A CLOSE LOOK AT
THE AMIGA
When you first encounter an Amiga, you see only half of
what makes it work. The half you can see and touchthe
keyboard, the console, the monitor, and the disk driveis
the hardware. The invisible half of the Amiga is its
software.
Software is a set of instructions, stored in the computer
or on a floppy disk, that determines how various compo
nents and functions interacthow the keyboard sends
messages to the computer, for example, and how the
monitor screen displays pictures. The software makes the
computer perform tasks that are helpful to you. Without it,
a computer is an expensive and inactive desk ornament.
A complete Amiga computer system is a working
partnership of both hardware and software. To understand
the entire system, you must learn about both halves of the
computer.
THE HARDWARE
Figure 1-1.
Console
Keyboard
Mouse
4
THE MONITOR
Chances are you pay more attention to the monitor than to any
other part of the Amiga system. The monitor is the Amiga's
channel of communication with you; it gives you visual information
through its screen, and audio information through its speaker.
The Amiga can work with three different kinds of monitors: RGB
monitors, composite video monitors, and standard television sets.
RGB {short for Red, Green, Blue) monitors show the sharpest
picture with the most vivid colors, and can display 80 columns of
readable text. You should use an RGB monitor with the Amiga,
even if you have to save pennies for years, because it's the only
monitor that does full justice to the Amiga's graphic abilities.
A composite video monitor is midway in quality between an
RGB monitor and a TV set. If you have a component television
system, chances are the monitor that displays the picture is a
composite video monitor. Whiie it doesn't display as clear a picture
as the RGB monitor, a composite video monitor attached to the
Amiga still produces a good-looking picture, thanks to the Amiga's
superior composite video signal.
The standard home television set can range in quality from
pretty good to horrible. The advantage to a TV set, of course, is
that you can use your regular TV without having to buy a special
computer monitor. If you do use a color television set for a monitor,
the Amiga gives it an excellent TV signal for color display. On a
good-quality TV set, the Amiga can display 60 columns of readable
text on the screen.
The Amiga has three different connectors (called ports) for
connecting monitors, one port for each kind of monitor. Since the
three ports all send out the same display information (although in
different forms), you can connect all three different kinds of
monitors at the same time and show the Amiga's video display on
three screens at once.
THE KEYBOARD
You use the keyboard to send information to the Amiga, feeding
it words, numbers, or requests for special functions as needed. The
keys are laid out like a standard typewriter, so if you're a touch
typist, you'll feel at home.
You'll also notice some keys not found on a typewriter. On the
left and right sides of the Spacebar you'll find the two Amiga keys,
each marked with a red "A." By holding down an Amiga key and
pressing another key, you can perform special program functions,
such as choosing a menu item. Next to the Amiga keys are the ALT
keys, and above the left SHIFT key you'll find the CTRL key. The ALT
and CTRL keys are special keys that, like the Amiga keys, are used
in combination with other keys to execute various program
functions.
5
To the right of the main keyboard are four cursor keys, marked
with arrows, that let you move the cursor around the monitor
screen in applications such as word-processing programs. Above
the cursor keys is the HELP key, which you can use in some
applications to get helpful information about using that program.
Along the top of the keyboard are ten function keys (F1-F10) that can
perform special program functions with a single keystroke, and on
the far right of the keyboard is a numeric keypad that's laid out like
a calculator to speed number entry. You can see these special keys
in Figure 1-2.
'''''Ti'lrfrr
' ' ' ' '
u. EXJUU
1 ' ' ' I' ' ' '
THE MOUSE
The mouse does away with a lot of typing and is the key to the
simplicity of using the Amiga. As you roll it on a flat surface, the
mouse moves an on-screen pointer. You can use the mouse to move
the cursor quickly in word-processing programs, for example, or to
select menu items or objects on the screen that start activities like
printing or displaying different sections of text. The mouse also
makes an excellent drawing instrument: You can use it with
graphics programs to draw images on the screen.
6
THE CONSOLE
The console is the real workhorse of the system. It contains all
the microchips and other electronic components that actually do
the work of computing and storing information. The console also
contains the internal disk drive, which you use to access and store
data and programs on floppy disks. From the outside, the console
looks simple and innocent. You have to look inside to see what a
hotbed of activity the console really is.
The interior of the console is not the rat's nest of tangled wires
and glowing lights that you might expect if you've watched a lot of
low-budget science fiction movies. Instead, it's an orderly array of
microchips and other small electronic components, all laid out on
two green boards collectively called the motherboard. You can see
the motherboard and other components that are housed in the
console in Figure 1-3.
Disk drive
7
through its circuits, it generates heat. Too much heat can keep the
chips from working correctly, and could possibly damage them. To
help keep the computer cool, there are vent slots on the bottom and
back of the console. You should take care not to block these slots
when you use the Amiga.
The motherboard
Most of the real work of the Amiga is done by just four chips on
the motherboard: the microprocessor and the three custom chips
(see Figure 1-4). The microprocessor is the master chip that does
most of the "brain work" of the Amiga such as adding, dividing,
and sending commands and information to other chips. The
custom chips, which are unique to the Amiga and contribute
significantly to its overall computing power, back up the micro
processor by taking care of details such as creating video displays
and generating sounds. This frees up the microprocessor chip and
allows it to run more efficiently
I
The chips on the
motherboard: The
microprocessor chip, cus
8
The Motorola 68000 microprocessor
The power of a microprocessor is measured by the amount of
data it can handle at a time and the speed at which it operates. As
microprocessors go, the 16/32-bit Motorola 68000 is fast. 16/32 indi
cates the 68000's data-handling capabilities: The 68000 processes
data in chunks of 16 bits and 32 bits. Inside the microprocessor, the
68000 works on 32 bits of data at a time, then sends data out to the
rest of the computer in 16-bit chunks. This makes the 68000 much
faster than a 16-bit microprocessor, such as that used by the
IBM PC, and makes the Amiga a very quick machine.
Other computers, such as the Apple Macintosh and the Atari ST
computers, also use the 68000 microprocessor. What sets the Amiga
apart from these computers is its set of custom chips that give it
even greater speed and enhanced abilities.
9
The memory chips
Memory chips are another important set of chips on the
motherboard. There are two types of memory chips: RAM and ROM.
RAM is short for Random Access Memory, ROM is short for Read
Only Memory. Each type of memory stores data, but in
a completely different manner.
RAM, also called read/write memory, is erasable, so the
microprocessor and custom chips can store data there, retrieve it
later, and erase the data so new data can come in. You should note
that nothing can be kept in RAM permanently, because RAM has
the unfortunate characteristic of losing all of its stored data when
the power is turned off.
ROM isn't erasable; the data stored there (sometimes called
firmware) is always available to the Amiga. The microprocessor
and custom chips can read the data in ROM, but they can't erase it
or store new data there. The Amiga's ROM chips store important
system software (put into them at the factory) that the com
puter uses to run itself (a process called booting) when you first
turn it on.
Other chips and electronic components on the motherboard take
care of details needed to send data and audio-video information out
of the console. Although they're all necessary, the microprocessor,
custom chips, and memory chips are the most important chips on
the board-
10
through the microprocessor. This means that data transfer between
the drive and memory is very fast. It also means that the disk drive
can transfer data to and from RAM without stopping the other
workings of the Amiga. This is very handy when the Amiga is
busy animating a figure on the screen or creating music on the
speaker. It doesn't have to stop while it gets new information from
the disk drive for the next animation sequence or a new song.
Figure 1-5.
11
The controller ports
On the right side of the Amiga, you can see two controller ports.
The Amiga's mouse plugs into the first of these ports. The con
troller ports are not just for mice, though. You can plug in other
controllers as well, such as joysticks, light pens, or touch tablets.
The controller ports pass information from the controllers to the
Paula chip so the Amiga can read the controller's position or
actions. Two controller ports let you use two controllers at once.
Figure 1-6.
12
The keyboard port
If you turn the Amiga console around so you can see its back,
you'll see a row of ports, shown in Figure 1-6. The first port on the
left is the keyboard port, which passes information from the
keyboard to the inside of the console. The keyboard cord plugs in
here. If you run the keyboard cord under the console, you can slide
the keyboard under the console whenever you're not using
the machine.
13
line-level output {the same kind that cassette decks produce),
which means the audio signals produced from these ports must be
amplified in order to be heard. Using standard audio cables, you
can connect these audio ports to a stereo amplifier, using the
inputs for a tape deck, compact disc player, or an auxiliary device.
If you want to record music you create with the Amiga, you can
connect the audio ports to the inputs of a tape recorder to put your
sounds on tape.
COMMON PERIPHERALS
You can expand the minimum Amiga system with peripherals
that add power and make the Amiga more useful. These common
peripherals help save working time, and can transfer the results of
the Amiga's work onto paper or over the phone lines.
14
One of the most useful additions to the Amiga system is a
printer. Printers come in all shapes, sizes, and capabilities, and the
Amiga will work with the majority of them. Most printers are used
just to print text, but many will also print pictures from the Amiga's
screen. These graphics printers are a very useful tool for artists.
Letter-quality printers
Businesses use letter-quality printers to create letters that look
like they were done on a typewriter. The letter-quality printer
puts characters on paper by striking an inked ribbon with fully
formed characters on the ends of spokes, much like a typewriter.
Although their printing is crisp and clear, letter-quality printers are
of little use for graphics, since they can only create characters and
not pictures.
Thermal-transfer printers
Thermal-transfer printers work much like dot-matrix printers, but
use points of heat to create dots directly on special paper, similar to
the dots created by a dot-matrix printer. Thermal printers also print
pictures that look much like an impact dot-matrix picture; some
even use a ribbon containing colored wax to create color pictures.
Thermal-transfer graphics aren't usually as good as dot-matrix
graphicsthe placement of the dots on the paper isn't always as
accurate and the dots are sometimes smeared-but thermal
printers are usually much less expensive than other types.
Ink-jet printers
Ink-jet printers spray small drops of ink on paper to form text
characters and graphics. Most models print only one color, but
more expensive models are available that can print multiple colors
using separate jets for each color. They're worth the cost if you
want high-quality printed graphics, because they print with vivid
and even coloration.
15
Laser printers
The laser printer is a type of printer that's out of the price range
of most personal-computer users. It creates pictures and text using
a photosensitive drum and toner the way a photocopier does, but
creates the images on the drum with a laser instead of exposing
the drum to a printed document through a lens, like a photocopier.
Laser printers are very fast and quiet, and laser graphics are crisp
and clear. Most laser printers print only in one color. You can vary
the colors by using color-toner cartridges, but the text or graphics
on each page will still be printed in one color, unless each page is
sent through the printer again and reprinted using a different color
toner. As laser technology advances, look for laser printers that will
print multiple colors on the same page simultaneously. Prices
should drop as well, until laser printers are more affordable for
Amiga artists.
Figure 1-7.
An external 3V2-inch
Amiga disk drive.
16
When you use just the internal disk drive to copy files from one disk
to another, you have to swap disks back and forth until the copy is
complete. A second disk drive eliminates disk swapping, saving
you time and aggravation.
Real gluttons for disk-storage space can use the expansion
connector to add a hard-disk drive, ,which is capable of storing
megabytes of information. Although this much extra storage space
is generally used to keep a large number of records for database
programs, it is also useful for animators and musicians who want
to store long animation sequences or scores.
A tremendous data-storage capacity isn't the only benefit of a
hard-disk drive: It also transfers information to the Amiga and back
much faster than a floppy-disk drive. This speed can be very useful
when you need to feed long sequences of animation images to the
Amiga quickly.
External RAM
The Amiga can have a maximum of 512 kilobytes of internal
RAM. If you really want to expand the Amiga's memory you can
add up to eight megabytes of external RAM by plugging external
RAM cards into the external connector on the right side of the
Amiga console. Since pictures and sounds require large amounts of
memory, you might want the extra RAM to accommodate involved
animation sequences or long musical scores.
Additional peripherals
There is a multitude of other peripherals designed to help you
with specific tasks. A modem will connect the Amiga to phone
lines so it can communicate with other computers and computer
networks. Touch tablets and light pens help draw figures on the
monitor screen without using the mouse. Synthesizers add to the
Amiga's already powerful musical abilities, and video cameras,
video recorders, and other various video accessories help bring
outside video images to the Amiga, and bring Amiga images to
the outside world. You can read more about additional periph
erals in later chapters.
SOFTWARE
17
But that's a process not unlike reading through old federal income-
tax forms, and isn't really much fun. (My apologies to die-hard
hackers and accountants.) Practically speaking, software is what it
does, so you can use a more enjoyable method of examining
software by examining its results.
SYSTEM SOFTWARE
The software included with the Amiga, called the system
software, runs the Amiga. Some of this software is stored inside
the console on ROM chips. The rest is included on two floppy disks:
the Workbench disk and the Kickstart disk- The system software
has five main programs and many smaller routines that are
structured in layers so they can work with each other.
An analogy helps to see how the system software works. Think
of a factory set up to manufacture kazoos. The factory has
machines for stamping out metal shapes, bending metal, attaching
buzzing membranes, painting metal, and boxing up finished
kazoos. The machines are run by a factory work force, men and
women expert at making sure the machines turn out the finest
kazoo craftsmanship. The individual workers are guided by
supervisors who make sure things are running smoothly. Directing
the supervisors are managers with expertise in each area of kazoo
manufacturing-one manager for metal cutting, another for
creative painting, and so forth- One step above the managers are
directorsone for each different area, like shipping and quality
control. A level above the directors are the vice presidents, who
carry out the orders of the president of the kazoo company.
Whenever the president decides to do something new, like
introduce a new line of Luciano Pavarotti-shaped kazoos, he tells
one of his vice presidents to start production. The VP gives orders
to the directors who need to be involved, who in turn issue their
orders to the managers. The managers tell the work force what
changes have to be made in running the machinery.
Although the Amiga doesn't manufacture kazoos, it runs like the
kazoo factory. The hardware (the factory work force) does the nitty-
gritty work, and the software (the management) runs the hardware.
At the lowest level of the software is a program called Exec (the
supervisors) that directly runs the hardware. Giving orders to Exec
are small subprograms called libraries and devices (the managers)
that specialize in areas like graphics, sound production, and math.
At the level above the libraries and devices are AmigaDOS and
Intuition (the directors), two programs that coordinate the work of
18
the software below to perform such tasks as moving data back and
forth between the disk drive and the motherboard and presenting
data to you in a way that's easy to understand. At the top level of
the system software are two more programs, Workbench and CLI
(the vice presidents). They take orders directly from you (the
president) and pass them down to the rest of the system software.
Figure 1-8 shows you the different layers of the Amiga system
software.
Figure 1-8.
The user
Intuition AmigaDOS
O Exec
Low level
Amiga hardware
Exec
Exec (short for system executive) is the lowest-level program of
the Amiga's system software. It's stored in the ROM chips inside
the console and on the Kickstart disk. When you turn on the com
puter, it's Exec that starts things rolling. It first clears the Amiga's
memory runs a short test of the hardware, and then asks you to
insert the Kickstart disk in the disk drive so it can bring the
19
rest of Exec into the Amiga's memory. When the Kickstart disk is
finished loading, Exec asks for the Workbench disk so it can load
the other system software-
Exec takes care of the fundamental hardware activities. It
provides routines to pass data back and forth from chip to chip and
to transfer data through the ports and connectors. Exec also has
routines to check the keys on the keyboard, to monitor the actions
of the mouse, to create video and audio signals, and to perform
other tasks fundamental to the Amiga's operation.
Exec can run many different activities at once. For example, it
can send characters out to a printer at the same time as it moves
figures on the monitor screen. This ability is called multitasking,
and is one of the features that makes the Amiga a powerful
computer.
To juggle the separate activities of multitasking, Exec has to
make sure that each activity shares the Amiga's chips without
interfering with other activities. Exec is a little like a lawyer
working for clients with conflicting interests: It spends a little time
with each activity so that the activities don't think they're being
ignored, and keeps each activity ignorant of the others.
20
AmigaDOS
On the level above the libraries and devices is AmigaDOS, short
for Amiga Disk Operating System. Like a traffic dispatcher who
keeps track of trucks on a highway, AmigaDOS keeps track of data
and programs in the Amiga's memory and on disks in the disk
drives. These programs and groups of related data are called files.
When AmigaDOS stores files on a disk, it keeps track of each file's
location on the disk, the size of the file, and when it was stored.
When it comes time to bring the file back into RAM, AmigaDOS
knows where to find the file and how to transfer it back to RAM.
AmigaDOS is also in charge of starting different programs. Since
Exec can handle many different tasks at once, AmigaDOS can take
advantage of Exec's multitasking ability to run different programs
at the same time if you ask it to. In case of any conflict between
programs, AmigaDOS knows which program is more important,
and makes sure it gets chip time or storage space from Exec before
the other programs do.
You use AmigaDOS whenever you load a program from disk and
start it running. You can give commands to AmigaDOS using one
of two higher-level programs: Workbench or CLI (discussed soon).
Intuition
Intuition is a program that works just above the libraries and
devices, at the same level as AmigaDOS. It provides user-interface
routines. The user interface, simply put, is the means you use to
control a program. Intuition's routines create the elements of the
Amiga user interface: screens, windows, menus, gadgets, and
requesters. Intuition also provides routines that use libraries and
devices to put text and graphics on the screen and read the mouse
and keyboard to see what the user wants.
Programmers can use Intuitions routines to create an Amiga
user interface for their programs. Instead of making their own
menus, windows, and other features from scratch, programmers
can ask Intuition to do it for them (for example, you'll learn how to
make a window in an Amiga BASIC program in Chapter 4).
Intuition's features encourage all programmers to use a consistent
user interface so users won't have to learn a new set of commands
and rules each time they learn a new program.
Workbench
Workbench is a graphics-based program that sits at the top level
of the Amiga's system software and takes commands directly from
you. It acts as an interpreter between you and AmigaDOS so you
can use AmigaDOS to manage files on disks and in RAM. The
display you see in Figure 1-9 (on the next page) is an example of
Workbench.
21
Figure 1-9.
CLI
CLJ, short for Command Line Interpreter, is a text-based
alternative to the graphics-based Workbench. Unlike Workbench, it
doesn't make use of the Intuition user-interface routines to interpret
your commands to AmigaDOS- Instead, it uses an older user
interface that requires the user to type commands in a command
line. CLJ interprets each of these commands as an AmigaDOS
activity and starts the activity the user typed in. Figure 1-10 shows
an example of a session with AmigaDOS using CU.
Although CLJ is not always as easy to use as Workbench,
it's more powerful. It provides more AmigaDOS activities than
Workbench, and is particularly useful for advanced Amiga users.
Examples of CLI activities not found in Workbench are setting a
program to run immediately when you turn on the computer, and
searching through files to find a particular piece of data. In
addition, you can use CLJ to run a series of AmigaDOS commands
to create AmigaDOS programs to perform long and involved file-
handling tasks.
22
Figure MO.
SOFTWARE TOOLS
The system software is only the beginning of the software you'll
use on the Amiga. For really practical results, you'll use software
tools like Deluxe Paint, Deluxe Music, Deluxe Video, and Amiga
BASIC, featured in the other sections of this book. These programs
apply specifically to jobs you want to get done, and use the Amiga
system software to get the results you want.
PRIMARY COLORS
When you look at an image on a color monitor, you're actually
seeing an illusion of color. In fact, the monitor can display only
three primary colors: red, green, and blue. What the Amiga does is
mix and match these primary colors, and the resulting combina
tions create the rainbow of colors you seem to see. This effect is
directly related to the way your eye sees color.
At the back of the eyeball are two types of light receptors: rods
and cones. The rods see a colorless world in shades of gray, while
the cones see color. Although most people perceive a full range of
SECTION 2: IMAGES
28
colors-red, yellow, green, cyan, blue, violet, and many colors in
betweenthe cones in the eye can actually see only the three
primary colors: red, green, and blue. The brain blends the varying
amounts of red, green, and blue light coming into the eye to create
additional colors.
The proportion of the primary colors blended together
determines the resultant color. For example, you see yellow as
a combination of equal parts of red and green light. If there is
more red light than green light, the yellow takes on an orangish
cast. If there's more green light than red light, the yellow becomes
more of a greenish yellow. By varying the amounts of red, green,
and blue light entering the eye, you can create a vast assortment
of other colors.
Figure 2-1.
29
HIS COLOR CREATION
Although it's easy to set red, green, and blue blends to create
new colors, it's not always easy to describe those colors as
individual amounts of red, green, and blue, or to come up with
exactly the color you wanted to create. People tend to describe
colors using terms like "light purple" or "dark red" rather than
descriptions like "eight parts red, eight parts blue, and three parts
green." There is another way to describe colors using three
attributes: hue, intensity, and saturation (HIS). These attributes
describe colors more like the way we see them.
Hue
Hue is the most apparent color attribute. You usually talk about
hues when you talk about color, using words like red, purple,
orange, and green. Hue is set by the mixture of primary colors in a
color, and is changed by the ratio of these primary colors. For
example, a mixture of blue and green light where the blue light is
twice as strong as the green light will create a hue described as
greenish blue. A mixture of blue and gjeen light where the green
light is twice as strong as the blue light creates a hue described as
bluish green. Since hues are often mixtures of other hues, many
of them have names like reddish orange, purplish pink, and
yellowish brown.
Intensity
The overall strength of light determines the intensity of a color.
Intensity can run the range from black (no light at all) to radiant
(maximum light strength). As an example of different color inten
sities, think of the difference between the colors at the beginning of
a sunrise and the colors when the sunrise is full. Many of the hues
are the same, but their intensity grows stronger as the sunrise
progresses, so the colors become much more radiant.
Hue and intensity are separate attributesone can change
without altering the other. For example, a greenish-blue hue is
created with a mixture of two parts blue light and one part green,
so the ratio is two to one. If the strength of both the blue and green
light is doubled so the new mixture is four parts blue light and two
parts green, the ratio is still two to one, so the hue is still greenish
blue. The intensity changes, thoughthe second color mixture is
much more radiant.
SECTION 2: IMAGES
30
Saturation
The saturation of a color changes as more white is mixed in
with it. Fully saturated colors have no white mixed in, and so look
more vivid. Colors with little saturation are diluted by white and
look pale, like pastel colors.
Since radiant white is actually an equal mixture of red, green,
and blue, when you add white to a color you are actually adding
red, green, and blue in equal parts. Therefore, saturation is tied
together with hue: Both hue and saturation change as white is
added, since the equal parts of red, gieen, and blue used to create
white change the ratio of primary colors in the resultant color.
Whether a color changes hue or saturation is mostly a subjective
judgmentdoes the new color look paler, or does it actually look
like a new hue?
Some Amiga graphics programs use HIS to create new colors.
For example, Deluxe Paint, described in the next chapter, uses
three sliders to control the hue, intensity, and saturation of a color,
just as the Preferences program uses RGB sliders. Deluxe Paint
takes your HIS settings and translates them into RGB settings that
the Amiga needs to create the colors on the monitor screen.
MONOCHROME MONITORS
The heart of a monochrome monitor, or almost any monitor for
that matter, is the cathode-ray tube (CRT for short). The CRT is a
large vacuum tube with a rectangular faceplate for displaying
images, and an elongated stem containing an electron gun
protruding from the rear (see Figure 2-2 on the next page).
31
Figure 2-2
Cutaway view of a
cathode-ray tube.
Electron gun
Faceplate
When you turn on the monitor and let the CRT warm up, the
electron gun fires a stream of electrons at the front of the tube,
which is covered with a layer of phosphor particles. Each phosphor
particle glows briefly when it's hit by an electron, and remains dark
when it's not. A black-and-white television, which is the most
common monochrome monitor, uses phosphor that glows white.
Some monochrome computer monitors use green or amber
phosphor instead of white phosphor.
Deflection area
electron gun.
SECTION 2: IMAGES
32
Raster scanning
To create an image across the entire faceplate, most monitors
use a technique called raster scanning. The area of the screen that
will be struck by the electron beam is called a raster. The computer
or the television circuitry controlling the monitor divides the raster
into several hundred horizontal lines called raster lines. It then
sends signals to the monitor that move the beam of the electron
gun across the CRT's faceplate to draw each raster line.
To cover the entire faceplate, the electron beam starts in the
upper left corner of the screen and scans from left to right across
the top of the screen. The strength of the electron beam determines
how brightly each phosphor particle glows as the beam scans over
it. Where the phosphor should be dark, the electron gun fixes no
electrons. Where the phosphor should be fully lit, the electron gun
fires electrons at full force. For shades in between, the electron gun
fires at partial strength so the phosphor doesn't glow as brightly.
When it reaches the right end of the raster line, the electron
beam sweeps back to the left side of the screen in a motion called
the horizontal retrace. It then starts a new raster line just below the
last raster line. When it finishes this raster line, it sweeps back and
starts yet another raster line, continuing all the way to the bottom
of the screen, displaying raster line after raster line. When it reaches
the bottom it has finished its vertical sweep, and goes back to the
top left corner of the screen in a motion called the vertical retrace.
Figure 2-4 shows the motion of the electron beam in a typical
raster scan.
Figure 2-4.
The electron-beam
pattern used in raster
scanning.
The raster scan has to take place very quickly, because phosphor
particles stop glowing very soon after the electron beam moves
33
away To keep all the phosphors glowing on the screen, the electron
beam sweeps over the entire faceplate sixty times a second. This
raster-scanning rate is called the refresh rate.
COLOR MONITORS
On the faceplate of a color monitor are three different colored
phosphors: red, green, and blue, in clusters of three. If you turn on a
color monitor and look at it under a magnifying glass, you can see
the three different colored phosphor dots glowing, as shown in
Figure 2-5.
Figure 2-5.
At the back of the color CRT are three electron guns, one for red
phosphors, one for green, and one for blue. A color mask located
just behind the phosphor layer of the CRT has a grid of tiny holes,
one for each cluster of colored phosphors. Each hole restricts the
beams from the three electron guns as they sweep across the
screen, so that each beam can strike only the appropriate colored
phosphor in each cluster, as illustrated in Figure 2-6. You can see in
the figure that the blue electron gun can hit only the blue phosphor
in the phosphor cluster; the hole is too small to let the beam strike
the red and green phosphors in the cluster. Likewise, the red gun
can hit only the red phosphor, and the green gun can hit only the
green phosphor.
A color monitor uses a raster scan just as a monochrome
monitor does. The color picture is broken up into raster lines, and
the three electron beams sweep in unison across the screen,
working their way across and down sixty times a second. Instead
SECTION 2: IMAGES
34
Red electron gun Figure 2-6.
35
Transferring video images to other media is not always simple.
Resolution differs from medium to medium, the colors don't always
match the way they should, and the sense of proportion isn't always
the same. Basically, the quality of the image when translated to a
different medium depends on the quality of the software you use to
translate the image, the quality of the equipment you use to
reproduce it, and your skill and knowledge of the medium used.
VIDEOTAPE
Recording the Amiga's video images on videotape is an easy
way to store and reproduce Amiga graphics. The Amiga can send
out a video signal from its composite video port directly to a video
tape recorder instead of to a composite monitor. The Amiga has
the capability of driving more than one monitor at a time, so you
could display the graphics on an RGB monitor connected to the
RGB port, while recording the same image on a VCR connected to
the composite video port. The video recorder stores the images on
videotape, so you can send the tape to other people with the same
type of recorder, or broadcast the tape over a television transmitter
if you're lucky enough to have access to one.
Videotape is an excellent way to store Amiga graphics. It can
capture motion and accompanying sounds, and it plays everything
back on a familiar medium: a monitor. There are some minor
drawbacks. A computer-generated image on videotape usually
doesn't look as good as the original image. Also, if your original
image is a still image, the VCR can only display it until the tape
runs outyou can't keep the image on the monitor indefinitely.
SECTION 2: IMAGES
36
partly finished. For example, a shutter speed of 1/120 of a second
will catch the raster scan with only half the picture drawn on the
monitor screen.
Prints made from your video photographs have an obvious
advantage--they're portable. You can send them through the mail
or mount them on the wall. They're also easy to look atyou don't
need to take time to plug them in, turn them on, or load them. Like
any other kind of photographic print, you can use them in
thousands of different ways.
There are some disadvantages to color prints. They don't always
reproduce the colors on youi monitor with complete accuracy, and
they don't glow the way your monitor does. One way to improve
color reproduction is to shoot photographs using slides. Slides have
the added advantage of looking radiant, like the monitor screen,
when you project them on a projector screen.
Prints and slides have a common distortion problem, because a
monitor screen usually has a curve to it. When you look at it
directly, images don't seem curved because your brain adjusts for
the curvature. When you photograph a video image, you transfer it
to a flat medium, and the curvature becomes noticeable. The
picture bulges a bit in the center, like a picture T-shirt on a man
with a beer belly.
37
Resolution
One of the first problems in translating video to print is that
most printers can print a picture with more detail, or higher
resolution, than the computer can display on the monitor. An
average dot-matrix printer can put over 900 dots of ink across the
width and 1200 dots down the length of an 8M>-by-ll-inch sheet of
paper. The Amiga's most finely detailed display on the monitor has
640 picture elements across the width of the screen and 400 picture
elements down the length, a display of lower resolution than the
900-by-1200 printed picture. To print a picture from the monitor on a
printer, the Amiga has to convert the image.
The simplest way to convert video resolution into print is to use
blocks of ink dots to represent each video picture element {pixel for
short). Each element in a video image that measures 320 by 200
pixels could be printed with a corresponding 3-by-3 block of ink
dots, stretching the 320-by-200 image into 960-by-600 ink "blocks."
The problem with converting video pixels into blocks of ink dots is
that it makes the printed image look jagged. In Figure 2-7, you can
see a diagonal line printed on a dot-matrix printer using blocks,
and the line as it appears on a video monitor. The printed line looks
pretty jagged.
Figure 2-7.
"Jaggies" created by
printing out a video
image
SECTION 2: IMAGES
38
High-quality printer software uses more than one printer dot to
represent a screen pixel, but instead of using blocks, it uses a more
intelligent translation scheme to smooth out the jaggies (computer
jargon for the stairstep effect in curved and diagonal lines) in the
printed translation of the screen image. This uses the printer's
higher resolution to its best advantage, as you can see in Figure
2-8. Smoothing out the jaggies this way is called anti-aliasing. It
can make images look a lot better, but the software has to second-
guess the artist's intentions. If the artist intentionally puts jaggies
in the picture, they might be smoothed out in a print made using
anti-aliasing software.
Figure 2-8.
39
that are darker are printed as solid black. The obvious disad
vantage to strict black-and-white printing is that it loses all the
subtlety of shade in the original image. It can be used to good
advantage, though, to translate a color picture with strong contrast
into a silhouette.
To turn colors into shades of gray, the printer software uses
black dot patterns on the printer to create different shades of gray.
Each shade of gray has a different dot pattern, Figure 2-9 shows
some enlargements of gray dot patterns. To turn the video colors
into gjay, the software interprets bright pixels as lighter shades of
gray and dark pixels as darker shades of gray then prints them
using the corresponding dot patterns.
Figure 2-9.
Shades of gray on a
dot-matrix printout
(enlarged).
Printing in color
Color printers don't have to interpret video colors as shades
of gray but they do have other tricky issues to resolve. Most
important is that color printing uses a set of primary colors that
aren't the same as video primary colors. Color printers use cyan,
yellow, and magenta in different mixtures to create other colors,
and often add black to give the picture more contrast.
Translating red, green, and blue directly into cyan, yellow, and
magenta wouldn't be difficult, except for one important factor; The
primary colors on a monitor screen can change in intensity but a
printer's primary colors can't. The primary colors on a color printer
have just one intensity because a dot of ink, unlike a phosphor,
can't glow at different strengths. When a color printer mixes two
SECTION 2: IMAGES
40
primary colors together, it gets just one resulting color Because
of this, most color printers have just six different solid colors
available to them: cyan, yellow, magenta, green (cyan and yellow
mixed), red (yellow and magenta mixed), and violet (cyan and
magenta mixed).
To approximate the thousands of different colors the video
screen can create, color printers use a process called dithering.
Dithering is an odd-sounding term that means the printer overlays
dots of one color on a solid field of another color. Viewed from a
slight distance, dithering creates a new color. One example is a
field of solid red with dots of black sprinkled throughout, resulting
in dark red.
Dithering gives a color printer a wide variety of colors, but its
color range is still limited compared to that of the monitor screen.
As a result, an Amiga image transferred to a printer won't show
subtle variations in color. The printed colors also have a textured
look as a result of dithering that makes them look different from
their video counterparts.
Now that you've seen how video images are created on the
Amiga's monitor, seen by the human eye, and transferred to other
media, you can look at the Amiga's specific graphics capabilities
with a better understanding of its accomplishments. The Amiga
was designed to be an exceptional graphics computer, and the
power of its hardware, combined with the graphics routines in
the system software, enable it to create video images of power
and subtlety.
The following pages describe the graphics features available in
any Amiga computer system running with its system software
the software on the Kickstart and Workbench disks you use to start
the system. Although you may not be able to use all of these
features directly (unless you're an advanced programmer capable of
using the Exec libraries and devices), most of the features are
available through application programs like Deluxe Paint, and
through programming languages like Amiga BASIC, as we'll see in
later chapters. As more software comes out for the Amiga, you can
expect to see even more of these graphics features available in
application programs.
41
PICTURE DETAIL
Like most other microcomputers, the Amiga creates images on
your monitor screen using pixels, those tiny boxy dots that give
computer images a slightly jagged quality. Creating a picture with
pixels is like building a house with bricks: Everything has square
corners. The trick to rounding off the jaggies in the picture is to use
smaller pixels; at a distance, you can't see all those square corners.
The Amiga has a choice of four different-sized pixels for varying
degrees of detail and smoothness. You can see these in Figure 2-10.
The size of the pixels you use in a screen determines the
resolution of the screen. The smaller the pixels, the higher the
resolution and the finer the detail in the pictures on the screen. The
larger the pixels are, the lower the resolution is and the coarser the
pictures are on the screen.
Figure 2-10.
greatly enlarged.
SECTION 2: IMAGES
42
Figure 2-11.
Figure 2-12.
A 640-by-200 Amiga
screen: the Workbench
display,
duel,
better to be Short thin Knott,
then Shott uas shot, not Knott,
as Shott shot Shott, not Knotd
43
In the Amiga's highest-resolution screen, the pixel is a square
shape just one-fourth the size of a low-resolution pixel. The high-
resolution screen measures 640 pixels across by 400 pixels from top
to bottom. With pixels this small, the detail of the picture is very
fine, and it's hard to see jaggies. In Figure 2-13, you can see a high-
resolution Amiga picture. It has enough detail to show the indi
vidual hairs on the mandrill's face.
Figure 2-13.
SECTION 2: IMAGES
44
different graphic media to get fine or coarse effects, much like a
painter picking different grades of paper for a watercolor. You'll
learn how to specify the resolution you want in later chapters.
Mixing resolutions
If you would like to mix resolutions on the monitor, the Amiga
can accommodate you by allowing you to divide the monitor
display into horizontal areas called screens (not to be confused with
the monitor screen itself), each with its own resolution. Intuition,
the user interface, allows you to display different resolutions on the
monitor simultaneously by layering many screens. You can drag
screens down with the mouse pointer to reveal any screens
underneath, and you can drag screens up to cover any screens that
were underneath. Figure 2-14 shows layered screens of different
resolutions on the monitor screen.
Figure 2-14.
Most Amiga programs, like Workbench for example, use only one
screen with a pre-set resolution. Some programs, like Deluxe Paint,
offer you a single screen in the resolution of your choice. A few
other programs, like Deluxe Video, use two or more screens with
different resolutions that you can move up and down on the
monitor. If you want to create your own screens, you have to use a
programming language like Amiga BASIC or C. (You will learn more
about screens and how to create them in Chapter 4.)
45
THE AMIGA COLOR PALETTE
Resolution is just one aspect of an Amiga picture; the other one
is color. Resolution gives a picture height and breadth, color can
give it depth.
The Amiga can create up to 4096 different colors on the monitor
screen by combining red, green, and blue in varying amounts. It
doesn't usually display all of these colors at once, though. Like
increasing picture resolution, increasing the number of colors in a
picture requires more memory to store the picture. To keep picture
memory requirements down to a reasonable size, the Amiga
usually limits the maximum number of colors on one screen to 32
{except on 320-by-400 and 640-by-4O0 resolution screens, where it
sets a maximum of 16 colors). This provides a wide color range
without using up so much memory that the Amiga can't run any
programs.
SECTION 2: IMAGES
46
from purple to orange using the color-creation sliders on the side of
the palette (you'll see how to do this in the next chapter). Every
purple pixel on the screen turns to orange, and you can see the
results immediately.
The Amiga can put all 4096 colors on the screen at one time
using a special mode called Hold and Modify (known as HAM for
short), which smears the colors horizontally to create very subtle
shading. For example, the Amiga can use HAM to shade a round
red vase to make it look three-dimensional. Where the vase curves
out and catches the light, it would use a bright red. It would then
subtly shade the red, turning it to darker shades where the vase
curves into the shadow. This gives it a smooth, glowing appear
ance. Figure 2-15 shows the full shades of a display using HAM.
Figure 2-15.
47
DRAWING PICTURES
The Amiga has special routines in its graphics library that help
draw pictures on the screen. These graphics routines create the
different components of any video picture: They can draw lines, fill
in areas with a specific color or pattern, copy one section of a
picture to another section, change colors, and perform other
important graphics functions.
The graphics routines make use of a special section of the
Agnus chip (one of the three custom chips) called the blitter. Blitter
is short for "bit-mapped block transfer," a mouthful that means it
quickly shuffles around large blocks of data in memory When that
data happens to be in the graphics-display section of the Amiga's
memory, the blitter can draw figures very quickly so you don't have
to wait a long time for a picture to appear on the monitor screen.
The graphics routines are used frequently in Amiga software.
Any of the graphics commands in Amiga BASIC or the drawing
functions m programs like Deluxe Paint use the graphics routines to
accomplish their tasks. Workbench uses the routines to draw icons
and windows on the screen.
CREATING TEXT
Libraries in the Amiga's system software also create characters
so the Amiga can put text on the screen. They use a flexible
system that resembles color registers, but instead of storing a red-
green-blue color combination in each register, it stores the design
for a character. The full set of character designs stored in
memory-including all the characters in the alphabet, numerals,
punctuation marks, mathematical symbols, and other special
charactersis called a font.
As you type characters in at the keyboard, the Amiga uses the
designs it has in memory for the font to create each character it
puts on the screen. If you change a font, the Amiga changes the
designs in all the registers, and any new characters appearing on
the screen use the style of the new font. One font might be blocky
and straight, another flowing and elegant. For example, in a word-
processing program, you can have the Amiga use one font to
display a headline, and use a second font to print a personal
message. Figure 2-16 shows some of the fonts the Amiga uses.
SECTION 2- IMAGES
48
Figure 2-16.
Different fonts are stored on disk until the Amiga needs them,
when they're transferred to RAM to be used to create the text on
display. As software developers design new fonts, you'll be able to
buy them on a floppy disk, load them into the Amiga, and call them
in by name through the program you're using.
Advanced Amiga programmers programming in C or assembly
language can create their own fonts by drawing the pattern for
each character and storing the data on disk. This is very useful for
creating characters for Russian, Greek, Hebrew, or other languages
that use different alphabets. This ability is also handy for creating
special mathematical or logical symbols. Watch for future commer
cially available software that lets non-programmers create their own
fonts, too.
Once a font is loaded in memory, the Amiga can use its system
software to alter the characters for emphasis. It can, for example,
stretch them out twice as wide, italicize them, underline them,
make them thicker, or invert their colors. It can also color the
characters any one of its possible 4096 colors. You can use some of
these effects in word processors like Textcraft and in graphics
programs with text like Deluxe Paint.
49
The Amiga also controls the background of the characters. It can
use the existing picture on the screen as background, or it can
create a contrasting background. Characters with a contrasting
background look like strips of letters pasted on a telegram.
Characters using the existing background blend in with their
surroundings. In Figure 2-17, you can see the characters with both
types of backgrounds.
Figure 2-17.
SCROLLING PICTURES
The Amiga has several other graphics features currently not
available to anyone but advanced programmers using C or
assembly language. These features let the Amiga store a picture in
memory that is too high and wide to display completely on the
monitor screen at one time. In such a case, the Amiga displays just
one section of the picture at a time, using the monitor screen as a
window on the picture. In Figure 2-18, you can see how this
feature works.
Although you can see only one section of the picture at a time
on the monitor, the Amiga can still bring any section of the picture
into view and so display the entire image in pieces. It can jump
quickly from section to section, or it can smoothly scroll the picture
into view in small increments. This makes the picture look like it's
sliding by under the monitor. The Amiga can scroD a picture at any
speed, fast or slow. It's not limited to up and down or left and right,
but can also scroll diagonally
SECTION 2: IMAGES
50
Figure 2-18.
serves as a window on a
Figure 2-19.
51
Superimposing one picture on top of another makes it easier to
change the images you see on the monitor screen. The background
picture can be used like the backdrop in a theater: It's drawn only
once, and doesn't change on the screen. Any elements of the
monitor display that will change or that move can be drawn in the
foreground picture. Since the Amiga doesn't have to keep changing
the background display as the foreground changes, it has a much
easier task of updating the monitor display, since it only has to re
create the foreground.
Although overlapping pictures is a feature usually available to
advanced programmers using C or assembly language, you can use
overlapping pictures whenever you make a video using the
animation program Deluxe Video (featured in Chapter 11).
SECTION 2: IMAGES
52
CHAPTER THREE
AMIGA GRAPHICS
TOOLS
Creating images with a graphics application program is
one of the most enjoyable activities you can pursue with an
Amiga. Graphics applications are now available for users of
all skill levels. They allow you to produce colorful pictures
with ease and speed, and give you the power to create
images of surprising complexity and subtlety. This chapter
features a graphics application called Deluxe Paint, and
introduces you to two more: Graphicraft and Aegis Images.
Deluxe Paint, developed and sold by Electronic Arts, is
one of the most versatile graphics applications programs
available. In this chapter, you'll see how to use the
advanced features of Deluxe Paint. Since Deluxe Paint
includes a manual that describes its individual features,
this chapter doesn't duplicate what you can read there.
Instead, it shows you how to combine those features to
achieve practical results. It also gives you some hints that
will make working with Deluxe Paint as easy as possible.
Later sections in the chapter show you how to print and
photograph your Deluxe Paint images. At the end of the
chapter, you can read about two of the other graphics
programs created for the Amiga, and about hardware that
can make your Amiga images look clear and colorful.
SECTION 2: IMAGES
54
Once you have the brush you want, you can use it in conjunc
tion with different brush modes to add texture or to affect the
colors on the screen in various subtle and unsubtle ways: shading,
blending, and smearing colors, painting with a single color, and
cycling through all the colors on your palette. Using custom brushes
effectively is very important if you want to get the most out of
Deluxe Paint.
Before you do anything with Deluxe Paint, the first thing you
should do is to create a work disk where you can store your Deluxe
Paint pictures.
2. If you have one disk drive, remove the Workbench disk and
insert a blank disk (or one you don't mind having erased) in
the disk drive. If you have two drives, insert the blank disk
in the external drive.
3. When the icon for the blank disk appears on the Workbench
screen, select it and choose the Initialize command from the
Disk menu, then follow the directions that appear on the
screen to initialize it.
55
from the Workbench menu to duplicate the empty drawer.
Do this twice more to make a total of three copies of the
empty drawer.
7. You should now have four drawer icons in your disk window.
The new icons may be stacked one on top of the other, so
you may have to drag them around to see them all. To name
each drawer, select the icon for the drawer, then choose the
Rename command from the Workbench menu. When the title
strip appears in the middle of the screen, click in the strip to
select it, press the DEL key several times to erase its
contents, then type in a new name and press RETURN when
you're finished- (Use the cursor and BACKSPACE keys to
correct mistakes if you need to.) Name one of the drawers lo
res, another med-res, another hi-res, and the last brush.
8. Select the icon for your disk, choose the Rename command,
and follow the instructions in step 7 to give your disk a
descriptive name.
You now have a Deluxe Paint work disk. When you save pictures
and brushes on this disk from Deluxe Paint, Deluxe Paint will
automatically use the four drawers you just created on the disk. It
stores all your low-resolution pictures in the lo-res drawer, your
medium-resolution pictures in the med-res drawer, and your high-
resolution pictures in the hi-res drawer. It stores your custom
brushes in the brush drawer.
To save you the trouble of having to create another work disk
this way, you can set this one aside as a master empty work disk.
Whenever you want to create a new empty work disk, just copy
your entire work disk master using the directions in the Introduc
tion to Amiga manual.
SECTION 2: IMAGES
56
You can also choose the number of colors available to you in
Deluxe Paint when you load the program by choosing the number
of bit planes you want to use for your painting. You'll learn more
about bit planes in Chapter 4. For now, all you need to know is that
the number of bit planes you use determines the number of colors
available to you, and that the more bit planes you use, the more
RAM you use. Five bit planes give you 32 colors, four bit planes give
you 16 colors, three bit planes give you 8 colors, two bit planes give
you 4 colors, and one bit plane gives you 2 colors. To assign bit
planes, just type the number of bit planes you want after the
dpaint load command. For example, to get a version of Deluxe
Paint with a high-resolution screen three bit planes deep (8 colors),
you'd type the command dpaint hi 3. For a low-resolution screen
two bit planes deep (4 colors), you'd type dpaint lo 2.
Why would you want to be able to use different screen resolu
tions and bit-plane depths'? The most important reason is that
you can save the images you create in Deluxe Paint on disk and
then use them with other programs. Some of those other programs
require the images to use a specific resolution and bit-plane
depth. For example, Deluxe Video (an animation program dis
cussed in Chapter 11) uses low-resolution images that are three bit
planes deep.
Another reason for choosing between low- and high-resolution
screens is that there are distinct advantages to both resolutions. If
you paint low-resolution pictures, you get to work with 32 colors. A
wide range of colors in a low-resolution picture can sometimes
make a picture look much more detailed and realistic than a high-
resolution picture using fewer colors. If you paint high-resolution
pictures, the curves and diagonals in your picture will look much
smoother, and you can create finer textures with the thin lines and
greater resolution available. Although the screen flickers slightly in
high-resolution mode (you'D learn why in the next chapter), if you
print or photograph your picture, the flicker is of no consequence.
57
To change the colors in the palette, open the palette window
by pressing p on the keyboard. The palette window, shown
in Figure 3-1, appears. You can alter any individual color on the
palette by selecting it with the pointer, and then setting the sliders
to the left of the colors. There are two sets of three slidersyou
can use either set to change a color. The first set, labeled RGB, sets
the red, green, and blue components of the selected color; the
second set, labeled HSV, sets the hue, saturation, and value of the
selected color. Value is Deluxe Paint's term for intensitythe value
slider sets the intensity of the selected color.
Figure 3-1.
SPREAD [ lExJCOFYl
RANGE |:iSHDilC2IC3
SPEED
CANCEL UNDO OK
When you change a color using either set of sliders, Deluxe Paint
automatically adjusts the other set of sliders to match the changes
you've made in the color. Which set you use is up to you: RGB is
easier to use if you like to think in terms of mixing primary colors;
HSV is easier to use if you like to choose a hue with the hue slider,
and then lighten and darken it with the saturation and value
sliders. If you aren't familiar with RGB and HSV (frequently called
HIS) color creation, be sure to read Chapter 2.
SECTION 2: IMAGES
58
The five boxes labeled RANGE, SH, C1, C2, and C3 control the four
ranges of colors Deluxe Paint uses when you paint using special
brush modes (more on that later in this chapter). The four different
ranges of colors are the shade range (SH), color-cycle range 1 (C1),
color-cycle range 2 (C2), and color-cycle range 3 (C3). Deluxe Paint
works with the SH range when you use the Blend and Shade brush
modes; it cycles through the colors in the the C1, C2, or C3 ranges
when you use the Cycle brush mode or the Cycle command in the
Picture menu. All these ranges have been presetyou can view any
of them by selecting SH, C1, C2, or C3. A white bracket appears on
the palette to show you what colors are included in the range and
where it begins and ends.
You can change the default range settings to suit your needs. To
change a range of colors, first select which of the four ranges you
want to reset. Next, select any of the colors in the palette as the
starting color in the range, then select RANGE. A TO pointer appears
on the screen. Use it to select any color in the palette as the last
color in the range. The TO pointer will then disappear, and the new
range is set.
The shade range works best when you set it to coincide with a
spread of colors that ranges from dark to light. A good example of
this is the range of grays that are the last 12 colors in Deluxe Paint's
default palette. When you use the Blend and Shade brush modes,
Deluxe Paint can move up and down in this range to darken or
lighten the colors you have on the screen.
When you ask Deluxe Paint to cycle colors, it cycles through the
colors in the selected cycle range, using the speed set for that
range in the SPEED slider located just below the range controls. You
can change the speed of a color cycle by first selecting it and then
setting the SPEED slider.
Since there are three different cycle ranges, you can set one
range inside another range for some very bizarre effects when you
cycle the colors on the screen. If you want to get rid of any range in
the palette, just select the range, select a color, select RANGE, then
use the TO pointer to select the same color againeffectively
creating a one-color range.
When you've set the palette to your taste, you can select the OK
command to apply it, or, if you have second thoughts, you can
select CANCEL to go back to the palette you were using before you
started changing colors or ranges. No matter what changes you've
made, don't worry about losing Deluxe Paint's default palette. You
can always get it back when you need to by choosing Default Palette
from the Picture menu.
59
CREATING PRECISE DRAWINGS
As you use the Deluxe Paint drawing tools, you may find yourself
trying to place line ends, rectangle corners, circle edges, and other
object boundaries in precise locations so they match up with other
objects on the screen. You can always use the magnifier tool to get
a closer look at what you're doing, or you can scrunch up close to
the screen and squint at the individual pixels, but there are easier
ways to click your figures into place.
SECTION 2: IMAGES
60
This method is very useful for drawing straight lines or for
moving a brush in a straight line across the screen. For example,
say you want to draw a straight line from one side of the screen to
the other without moving up or down. Select the line-drawing tool,
then move the mouse pointer to the place where you want the line
to begin. Before you press the left mouse button to begin drawing
the line, hold down the SHIFT key. Then hold down the left mouse
button and start rolling the mouse to the side. As you roll, the SHIFT
key keeps the line on a strict horizontal path, even if your hand
moves the mouse up and down as you roll it.
61
and dragging the mouse, you can change the size of the grid. As
you move the mouse, the coordinates will change to show you how
many pixels wide and high each square of the grid is. Once you've
dragged the grid to the size you want, you can release the left
button. The grid will disappear, and the next time you turn on the
grid tool, the new size will determine where the grid intersections
are located.
By default, the grid is aligned with the top and left boundaries
of the screen, but you can reposition the grid intersections if you
want to. First, select the grid tool with the right mouse button
again. The sizing grid will appear on the screen again, but this
time you will be positioning it on the screen to determine where
the actual grid lines themselves will benot the size of the indi
vidual squares. Place the intersections of the sizing grid where you
want the grid lines to be positioned, then click the left mouse but
ton, and the entire grid is realigned to match the position of the
sizing grid on the screen.
When you use the grid with the text tool, it restricts where you
can place the text cursor with the pointer. Once you start typing,
the letters aren't restricted by the grid, but if you move the text
cursor by clicking elsewhere on the screen, its new position is
restrained by the grid. By stretching the grid to the size you want,
you can use the grid intersections as tab stops and line spacing.
Just type what you want, then relocate the text cursor with the
pointer. The grid makes it easy to line up columns and lines of text.
One of the most useful applications of the grid is in creating
background patterns. You can try it out by first loading the picture
Patterns from the Deluxe Paint disk. In the upper right corner of the
picture are eight patterns in yellow boxes. You can select any one
of those patterns as a custom brush, and then duplicate it all over
the screen using the grid to line up the brushes.
Try it out. Use the brush-selection tool to select the brick pat
tern by selecting all of the pattern inside the yellow box without
including any of the yellow border. If you watch the coordinates as
you set the brush, you'll see that the box is exactly 19 pixels wide
by 11 pixels high. Press j on the keyboard to switch to the other
drawing screen, where you can paint in a blank screen without
covering the other patterns. Now resize the grid so it's one pixel
wider and higher than your brush: Set it to 20 pixels wide by 12
pixels high. Once the grid size is set, turn on the grid, make sure
the brush is set for dotted freehand drawing, and start painting.
Perfectly aligned blocks of the brick pattern will then start to fill
the screen.
SECTION 2: IMAGES
62
Once you fill the entire screen with bricks, try painting other
things on top of the bricks. If you paint something you don't like,
and if clicking UNDO doesn't erase all of it, you won't be able to
erase it using the background color, because the brick background
isn't one single color. Instead, turn on the grid if it isn't already
turned on, then grab any section of brick as a brush and start
painting over what you draw. If you haven't changed the grid since
you laid down the pattern, the brush will erase your figure by filling
it in with new bricks aligned with the old bricks.
63
silhouette, coloring it with a single color: the current foreground
color. If, in our example, the foreground color is set to green, Deluxe
Paint will use the arc shape of the rainbow, but will fill it with only
one color: green.
SECTION 2: IMAGES
64
The Blend mode
The Blend mode works something like the Smear mode: When you
drag the brush in Blend mode over two different colors that are both
in the shade range, the brush drags some of the first color into the
second color. The difference is that in Blend mode, the brush doesn't
just drag pixels of one color into an area of another color: The brush
compares the colors it's dragging to the colors it's passing over, and
lays down a color halfway between the two colors in the shade
range. (If the two colors are adjacent m the shade range, Deluxe
Paint will use the color you started blending from.) When you work
with a shade range that progresses from dark to Sight, this means
that you can use the Blend mode to blur the borders between two
different colors, using all the intermediate shades of color between
them to make a smooth transition from one to the other. This
sounds much more complicated than it really is. If you try the
example later in the chapter, you'll see just how it works.
65
Using the Object and Color modes to outline a figure
When you create an object using colors that don't contrast well
with the background color on the screen, you might want to outline
your object with another color to make it stand out. For example, an
orange object on a white background will stand out better if you
outline the object in black. You can always outline your object by
carefully drawing around the edges, but that takes a lot of time if
the object is at all complicated. By selecting the object as a brush
and using the Object and Color brush modes, you can create an
outline for that object in seconds, no matter how complex its shape.
Follow these instructions to try it out:
2. Choose Load Fonts from the Font menu, then choose a large
font (sapphire-19 works well for this example).
3. Select the text tool, put the text cursor on the screen, and
click to position the text cursor.
5. When you're finished with your message, select the entire set
of characters as a custom brush.
6. Choose Color from the Mode menu, then choose black from the
palette to turn your brush black.
7. Choose Coordinates from the Prefs menu so you can see the
coordinates in the title bar.
9. Move the brush to a blank area of the screen, then hold down
the left button and drag down and right until the coordinates
measure 2 by 2 pixels. The result will be a somewhat illegible
set of black blobs on the screen, similar to what you see in
the right half of Figure 3-2.
SECTION 2 IMAGES
66
10. Choose Object from the Mode menu to turn your brush back to
its original light blue color.
11. Position your brush in the middle of the "rectangle" you just
created so you can see the text with a black outline. Click
the left mouse button to copy the brush there. When you
move the brush away, voila! You have light-blue text outlined
in black, something like what you see in the lower part of
Figure 3-2.
Figure 3-2.
12. Select the outlined text as a new custom brush, then save it
to disk. You can use it in a later example.
In this example, when you used your custom brush in the Object
mode, Deluxe Paint always used the original colors (light blue in
this case) that the brush had when you first selected your custom
brush. Once you change your custom brush to Color mode, you can
choose any color you want. (In this example, in step 6 you could
choose any color you wanted to outline your message.) As soon as
you choose the Object mode again, your brush will return to its
original colors.
67
Creating a sandy background with the Smear mode
Most of the tools in the control panel create objects of a single
color If you want to create patterns that mix a lot of different colors
in a small area, you can spend a lot of time trying to do it with
standard tools. For example, consider trying to draw a picture of
beach balls on a sandy beach. Drawing each grain of sand on the
beachalternating light, dark, and in-betweencan be a very
tedious job. You can use a brush in the Smear mode to perform the
job with much more speed and ease.
In this example, make sure that you're using the default palette
with the default setting for the shade range, so it includes the last
12 colors on the palette, ranging from dark gray to light gray. While
these particular colors aren't necessary for this specific example,
you can use these results in a later example that will use this
shade range.
3. Pick each of the 12 colors in the shade range and put a dab
of it on the screen so the dabs touch to form a circle, as you
can see in the left side of Figure 3-3.
5. Choose Smear from the Mode menu, then move the brush to
the center of the dabs, hold down the left mouse button, and
start smearing. Smear in a circular motion from inside the
cluster of dabs so you get a little bit of each color smeared
in the center. The result should look like the right side of
Figure 3-3.
SECTION 2: IMAGES
68
Figure 3-3.
Figure 3-4.
69
Creating rainclouds with the Blend mode
If you've ever looked at rainclouds, you'll notice that they have a
wide range of graysfrom light gray to very dark gray where rain
is pouring down from them. If you want to create closely shaded
clouds with Deluxe Paint, you can use a brush in Blend mode to
create a wide range of grays from just two original shades.
3. Create a filled box in the upper third of the screen using the
darkest gray in the shade range.
5. Pick the largest circular brush in the control panel (the one to
the far right), then choose Blend from the Mode menu.
6. Move the brush to the dark area in the upper third of the
screen, hold the left mouse button down and slowly move the
brush down and slightly toward the right into the light area
of the screen. The dark area should smear and blend into the
light area. Repeat the stroke many times, working across the
border between the two shades of gray to create a rainy look.
SECTION 2: IMAGES
70
Figure 3-5.
71
3. Put the brush on the screen wherever you want to place
the text.
4. Choose Shade from the Mode menu. The brush shows on the
screen as a lighter shade of sand in the shape of your letters.
6. Choose Object from the Mode menu. The brush will appear as
the original outlined letters. Place them just above and to the
left of the shadow, then click the left mouse button to copy
the letters there. The results should look like Figure 3-6. If you
look closely at the shadow, you can still see the grains of
sand, although they're darkened.
Figure 3-6.
Shade mode
SECTION 2: IMAGES
72
EASY TRICKS
As you use Deluxe Paint, you'll find many shortcuts and neat
tricks to heip you create pictures. To start you off right, here are
three tricks that you may find useful.
73
Copy pictures from magazines onto acetate
If you're not the greatest freehand sketch artist in the world, or if
you are but want to save yourself some work, you can use sheets of
.002 weight clear acetate (available in most art stores), a fine felt-tip
marker, and some magazines to good advantage. If you lay the ace
tate on a magazine picture, you can trace the image on the acetate
with the felt-tip marker. When you're finished, tape the acetate to
your monitor screen, and follow the traced lines with the Deluxe
Paint cursor to copy the image to the screen. As long as you work
alone behind closed doors, no one but you will know your secret.
SECTION 2: IMAGES
74
Figure 3-7.
75
margin at 5 characters (Vz inch from the left side of the paper) and
the right margin at 80 characters (8 inches from the left side of the
paper and/2 inch from the right side of the paper).
When the printer driver sends your picture to the printer, it keeps
the height in proportion to the width you set. If you print a picture
using the above settings, it will look like the picture on the paper in
the left half of Figure 3-8. If you reset the margins to 5 and 40,
halving the width, when you print the picture the height is also
halved, as shown in the right half of Figure 3-8.
Figure 3-8.
SECTION 2: IMAGES
76
Figure 3-9.
Figure 3-10.
The two examples in Figure 3-10 use the same margin settings.
Notice that the margin settings control the width of whichever side
of the picture goes from left to right. This means that a vertical
picture will be larger than a horizontal picture printed with the
same margin settings, as you can see in Figure 3-10.
77
Once you've set the graphics settings as you like them, you can
select OK to return to the Printer Change screen, where you can select
OK to return to the first Preferences screen. Once there, if you want
to use your new printer settings without changing your default
printer settings, you can select Use, which will put them into effect
without saving them to disk. If you want to save your new settings
as the default printer settings, select Save, which will put them into
effect and also save them to disk so that the next time you boot
Deluxe Paint, these settings will automatically go into effect with
out your having to set them again using the Preferences program.
SECTION 2: IMAGES
78
OTHER AVAILABLE GRAPHICS SOFTWARE
GRAPHICRAFT
Graphicraft is a graphics program marketed by Commodore-
Amiga. Although you cannot create multicolored custom brushes
or work on a high-resolution screen with Graphicraft, you can still
use it to create excellent pictures. It just takes a little more time
to do it.
One good reason for buying Graphicraft, or at least looking
at it, are the sample pictures that come with it. They take full
advantage of Graphicraft's ability to cycle colors to create beating
hearts, storming weather maps, and flying hot dogs. If you take the
time to learn how these pictures work, you can then create some
very sophisticated animation using any graphics program that can
cycle colors.
AEGIS IMAGES
Aegis Images is a graphics program that is sold together with
Aegis Animator, a video-animation program. You can use the
pictures you create in Images as objects to animate m Animator.
Although Images does not offer custom multicolored brushes
and different screen resolutions, it has other special features. Where
the power of Deluxe Paint is in selecting multicolored custom
brushes and building pictures with them, Images concentrates on
the versatile use of monochrome brushes.
You can use the Images brushes to paint with single colors
or with multicolored patterns, and you can use them with a wide
variety of object-producing tools, such as parallelogram and tri
angle tools. You can alter the way any tool works to get some very
effective results. For example, you can set any of the tools so the
last point of one object will be the first point in the next object you
create; in this way, the objects you create will be chained together.
Images also has brush effects similar to Smear, Shade, and Blend
in Deluxe Paint. "Transparency" and "glow" are two of these.
Other features are "pantograph" and "under," which allow you to
copy an image with strokes of a brush or to paint one color under
other colors already on the screen.
79
THE IFF GRAPHICS STANDARD
One thing that Deluxe Paint, Graphicraft, and Aegis Images
have in common is that they all save their picture files to disk using
the IFF graphics standard. IFF stands for Interchange File Format.
It's a standard that was developed by Electronic Arts in collabora
tion with Commodore-Amiga, to make sure that files saved by one
program can be used by another program. There are IFF standards
for graphics, for music, for sound, for text, and for a wide range of
other types of data that can be saved to disk or transmitted. IFF
standards are designed to go beyond working with different
programs on the same computerthey're also designed to work
with different computers.
Software developers have to use the IFF standard, or their
programs won't be able to use files from other programs that were
saved using the IFF standard. Fortunately most software developers
for the Amiga are adhering to the standard at Commodore-Amiga's
urging. What this means for you is that you can take a picture
saved by Graphicraft, Deluxe Paint, or Aegis Images and toad it
into any Amiga graphics program that uses the IFF standard. For
example, if you like some features of Deluxe Paint and other fea
tures of Images, you can create a picture on Deluxe Paint, save it,
and then load it into Images for some touch-up work using images'
special features.
MONITORS
The piece of graphics hardware you probably spend the most
time with is the monitor you use with your Amiga. If you're using a
monochrome monitor or a composite video monitor and want to
upgrade your picture by buying an RGB monitor, there are several
things to consider as you shop.
There are two types of RGB monitors: analog and digital. Digital
RGB monitors are the type most commonly used with the IBM PC,
so they're easy to find. Your Amiga can display pictures on a digital
RGB monitor, but a digital RGB monitor can only display 16 different
colors, severely limiting the colors you can use with your Amiga.
An analog RGB monitor can display a full range of colorsit's the
best RGB monitor for working with color graphics.
SECTION 2: IMAGES
80
Many different analog RGB monitors are available. To make sure
you find one that works well with your Amiga, be sure that the
monitor has at least 400 lines of vertical resolution to display the
Amiga's high-resolution pictures with accuracy. You should also
check the dot pitch of the monitor; the smaller the dot pitch, the
clearer the picture on the screen. An average RGB monitor might
have a dot pitch of around .4 mm. An exceptionally clear monitor
might have a dot pitch of around .28 mm.
If your budget precludes spending a good chunk of money on a
monitor just for your computer, you might consider getting a TV set
that will display analog RGB signals from your Amiga. That way
when you're finished with your computer work, you can watch your
favorite TV programs. One example of this type of TV/monitor is the
SonyKV1311.
Another alternative is to buy any of the many video monitors on
the market designed to work with a component video system that
also includes an input for an analog RGB signal. They usually don't
have a tuner built into them, but most will accept a signal from a
VCR, so you can use the tuner built into your VCR to receive
television programs. One advantage to a video monitor like this is
size: Some of them have a screen size as large as 25 or 26 inches, a
real advantage if you're displaying Amiga images in a storefront, or
even if you just like to sit back in a sofa and play larger-than-life
video games.
PRINTERS
A color printer is very important if you want to make copies of
your Amiga images on paper. The Amiga's system software has
printer drivers for three different color printers: the Okimate 20, the
Epson JX-80, and the Diablo C-150. You can use other color printers,
but you must have a printer driver for them before they will work
with the Amiga.
81
The Epson JX-80 printer
The Epson JX-80 is an impact dot-matrix printer that uses a
multicolored inked ribbon to strike against paper to print colors.
The JX-80 is probably the best text printer of the three color
printers, since it can produce near letter-quality text if you add a
special chip to it. It can use almost any kind of paper you can feed
into it, and it will use one ribbon over and over again until it runs
out of ink.
The main disadvantage of a JX-80, like most color impact dot-
matrix printers, is that the color saturation you get from an inked
ribbon on standard paper is poor; the printed images look washed
out, compared to what you see on the screen. The advantage is
that you can use the JX-80 for word processing as well as printing
graphics, and it's affordable.
SECTION 2: IMAGES
82
THE AMIGA LIVE! FRAMEGRABBER
If you want to add some pictures from real life to your collection
of Amiga images, you can use the Amiga LIVE! framegrabber to
turn images from a video camera, TV, VCR, another computer, or
any other video source into a low-resolution Amiga image.
The Amiga LIVE! framegrabber plugs into the expansion bus on
the right side of the Amiga. On the side of the Amiga LIVE! box is
an NTSC jack where you can plug in a standard video cable to
carry a picture from another video source (like a video camera).
When you turn on the Amiga, you boot a disk containing the
Amiga LIVE! driver, the software that reads the images from the
framegrabber. When the driver is loaded, you see the images that
the framegrabber produces on your monitor screen.
Amiga LIVE! is a real-time framegrabber. That means that at
least 12 times a second it can take a video picture and convert it to
a 320-by-200 Amiga picture. If the source is a moving picture, you
see the result as a series of moving Amiga pictures on the screen.
You can at any point freeze the picture on the screen. Amiga LIVE!
can capture pictures from video in color using 32 colors, or in black
and white using 16 levels of gray You can then save those pictures
to disk, and since the software will save them using the IFF
standard, you can load your picture into an IFF graphics program
and alter them later.
Amiga LIVE! can act as more than just a still-picture digitizer.
Since it operates in real time, and since the Amiga simultaneously
puts its images out through the NTSC port on the back of the
Amiga console, you can feed the digitized images from Amiga
LIVE! into a VCR connected to the NTSC port to create your own
special-effects videos. Amiga LIVE! acts as an image processor to
freeze frames, alter colors, and create many of the special effects
you see in other video-based productions such as music videos.
83
CHAPTER FOUR
AMIGA BASIC
GRAPHICS:
SCREENS,
WINDOWS, AND
PALETTES
Microsoft's Amiga BASIC has a full set of graphics
commands that let you design effective pictures with your
BASIC programs. You can use the graphics commands to
create your own screens and windows, then fill those
windows with shapes, colors, and text. You can display
data with colors and shapes instead of numbers, ask for
input from the user in visually irresistible ways, and add
visual pizzazz just for fun.
In the next three chapters, you'll learn how to use the
Amiga BASIC graphics commands. This chapter concen
trates on the commands you need to create your own
windows, screens, and color palettes. Chapter 5 explains
how to draw lines and create shapes in different colors.
Chapter 6 shows you how to add text to your graphics,
make your graphics adapt to changing window sizes, and
cut and paste sections of graphics.
If you haven't used Amiga BASIC before, you might find that its
unique features take a little getting used to. Unlike most versions of
BASIC, Amiga BASIC doesn't need line numbers. Another difference
is that it uses two different windows for separate activitiesone
window to enter the program, the other to display the results. To
help you use the program examples in the following chapters, this
short introduction shows you how to enter, run, and stop Amiga
BASIC programs. The tutorial is not intended to teach you BASIC
programmingthat's a large job best left to a beginning BASIC
book or a teacherbut it will help start you out painlessly. If you
want more specific information about using Amiga BASIC, you can
find it in the user's manual that comes with the program.
SECTION 2: IMAGES
86
Figure 4-1
These two windows keep the lines of the BASIC program and the
results of the program separate. You enter and store the program
lines in the List window. When you run the program, any vrsible
results that occur, such as text printouts or graphics, usually
appear in the Output window.
87
you get to the text you'd like to change, just start typing to insert
new text, or use the BACKSPACE key to erase characters before the
cursor. You can also delete text by dragging over it with the mouse
to highlight it, then pressing the BACKSPACE key.
RUNNING A PROGRAM
Once you've entered a program, you can run it by choosing Start
from the Run menu. The List window disappears, and the results
appear in the Output window (if they're text or graphics). When
the program is finished, the List window reappears. If the program
doesn't stop by itself, you can stop it by choosing Stop from the
Run menu, or by pressing the right Amiga key together with the
period {.} key, or by holding down CTRL and pressing C. If the List
window doesn't automatically appear after the program stops
running, you can choose Show List from the Windows menu, or use
the keyboard shortcut and press the right Amiga key together with
the L key to make it reappear.
SAVING A PROGRAM
If you want to save a program that you've written, just choose
Save from the Project menu. Amiga BASIC will prompt you for a
name. Click in the box to get a cursor, then type the name in and
SECTION 2: IMAGES
88
press RETURN; your program will be saved on disk as a BASIC file.
You'll see the title of the program appear in the title bar of the
Output window. As you modify the program, you can continue to
use Save. Each time you choose it, Amiga BASIC will save the
program in its current state under the same name, overwriting the
oid version already on the disk. To save an existing program under
a different name, choose Save As from the Project menu and type in
another name. The name displayed in the Output windows title
bar will change to the new name, and the old file will remain
untouched on disk.
To load a program from disk, choose Open from the Project menu,
click in the box, then enter the name of the program and press
RETURN. If the program you're working on hasn't been saved in its
current state, you will be warned and given the opportunity to
either save or throw out the changes. After that, Amiga BASIC will
erase the program that is currently in the List window and replace
it with the program you chose. The same is true if you choose New
to begin entering a program from scratch.
LEAVING BASIC
When you want to leave BASIC to get back to the Workbench,
you can quit Amiga BASIC by choosing Quit from the Project menu,
or by closing both the List and Output windows by selecting their
close gadgets. If you just want to see the Workbench without
quitting BASIC (to see how full the disk is, for example}, you can
select the back gadgets on both the List and Output windows to
put them behind the other windows on the Workbench. Once
you've seen what you want to see, you can bring the List and
Output windows back to the foreground by selecting their front
gadgets, or by selecting the back gadgets on the other Workbench
windows. In some cases, you may have to choose Show List from the
Windows menu to see the List window again.
89
The size of the pixels the Amiga uses to build images deter
mines the resolution of the picture. In a high-resolution picture,
the pixels are small and not easily seen, so you can create curves
and diagonal lines that appear fairly smooth. In a low-resolution
picture, the pixels are larger and more evident; diagonals and
curves have a distinct jagged look, and you can see the indi
vidual pixels more easily.
SCREENS
The Amiga offers four different resolution modes for displaying
graphics and text on the monitor. You choose any of the resolutions
and work with it by creating a screen (explained in the SCREEN
statement section in this chapter). You can have up to five screens
on the monitor at one time, and each can have its own resolution
mode. Each Amiga screen extends across the full width of the
monitor screen and has a title bar at the top (you can create a
screen that is not displayed across the full width, but it will
"command" the entire width of the screen). You can gjab the title
bar with the pointer and drag the screen up and down on the
monitor by holding down the Select button of the mouse and rolling
the mouse forward and back. This reveals the screen immediately
behind the current screen (if any), and you can then grab that
screen's title bar and move it up and down.
The screen's title bar is also used to display menus. When you
press and hold down the Menu button of the mouse, the titles of
the menus appear in the title bar. You can make an individual menu
appear by pointing to the menu title with the pointer while the
Menu button is still depressed.
The title bar also includes back and front gadgets in the right
corner. If there is more than one screen on the monitor at one time,
those screens are layered, one covering another. Selecting the left
(back) gadget moves that screen behind any other screens, and
selecting the right (front) gadget moves that screen in front of any
screens on the monitor.
A good example of a screen is the Workbench screen. When you
first boot the Amiga, the Workbench screen appears with Workbench
release 1.1 (or something similar) in the title bar and the icons for any
disks you have in the drives. You can drag the screen up and down
SECTION 2: IMAGES
90
by pointing to the title bar with the pointer, holding down the
Select button, and rolling the mouse forward and back. If you try
the back and front gadgets, nothing happens because there aren't
any other screens on the monitor at this point. When you press the
Menu button on the mouse, you get the Workbench menus in the
title bar. You can see the Workbench screen, complete with
gadgets, in Figure 4-2 (on the next page).
WINDOWS
Screens provide areas of different resolution on the monitor.
Within each screen, windows provide clearly defined areas of
activity. If you want to create graphics or put text on a screen, you
must do it within a windowyou can't put graphics or text on a
screen without a window. Windows share the same resolution and
colors as the screen they belong to, so you can't create windows
with different resolutions or colors on the same screen.
Unlike screens, windows don't have to extend across the full
width of the monitor. They can be almost any size, as long as
they fit within the screen they're on. Each window has its own
boundaries, and can include an optional title bar at the top. The
title bar can show the name of the window, and can also include
three optional gadgets: the close gadget, the back gadget, and the
front gadget. Selecting the close gadget will make the window
disappear from the screen. Selecting the back gadget will move the
window behind any other windows on the screen; selecting the
front gadget will move the window m front of any other windows
on the screen.
In the lower right corner of the window is an optional sizing
gadget. By pointing to the sizing gadget, holding down the Select
button on the mouse, and then rolling the mouse, you can change
the size of the window. Also, if the window has a title bar and is
smaller than the screen, you can move the entire window around
within the boundaries of the screen by pointing to the window's
title bar, holding down the Select button, and rolling the mouse.
If you open the Workbench disk icon on the Workbench screen
as shown in Figure 4-2. you can see a good example of a window
with all the gadgets, the title bar, and full mobility. You can drag it
around to any spot on the screen, resize it, and close it if you wish.
If you drag the Workbench screen up and down on the monitor, all
the windows it contains will move with it.
91
Figure 4-2
PALETTES
Each screen on the Amiga monitor also has its own set of colors,
called a palette. The palette for each screen can have up to 32
different colors. You can choose each of the colors in the palette
from a total of 4096 different colors, so it's possible to create a
unique palette for each screen. The procedures for changing the
colors in the palette from BASIC are explained later in this chapter.
The Amiga uses the colors in the palette to color all the pixels in
its screen and any windows on that screen that use those colors.
For example, the first color in the palette is used to color the
background of the screen and its windows, and the second color is
used to fill in the boundaries of the windows and the title bars. The
last two colors in the palette are used to create inverse colors that
appear when you select any menu item.
When you first boot the Workbench, you see a blue background
with white window borders and title bars (that is, if you haven't
changed the colors). When you select menu items, they turn to the
inverse colors of black and orange. If you use Preferences to change
your Workbench colors, you are choosing new colors for the palette
of the Workbench screen, which show up as new colors for the
background, window borders, and inverse menu lettering.
SECTION 2: IMAGES
92
THE SCREEN STATEMENT
When you start working with Amiga BASIC, you use the List and
Output windows that BASIC creates on the Workbench screen. Any
graphics you create or text you print will appear in the Output
window using the Workbench screen's resolution and four-color
limitation. You'll probably want to use more colors and a different
resolution. To do so, you need to create a new screen with the
SCREEN statement. It uses this format:
93
By combining the two different widths and two different heights
of the pixels, you have four different resolutions available that you
can specify with the following resolution mode numbers:
SECTION 2: IMAGES
94
shown in Figure 4-3. You can't drag this screen above its current
position, but you can drag it down lower. Notice also that the area
to the right of the screen is blank, but it will drag up and down
with the screen, since the resolution of the screen covers the full
width of the monitor.
Figure 4-3.
A160-by-100model
screen.
SCREEN DEPTH
The depth of a screen is measured in bit planes. The number
of bit planes in a screen determines how many colors the screen
and all the windows in that screen can display. Each bit plane is
a section of the Amiga's RAM that uses one bit to store color
information for each pixel in the screen. By combining bit planes,
the Amiga can use multiple bits for color storage for each pixel
m the screen.
You can specify anywhere from one to five bit planes when you
create a screen. A screen with one bit plane supports just two
colors, because there's only one bit in memory for each pixel (the
bit can be either on or off, hence two colors). Each additional bit
plane you add to a screen assigns one additional bit m memory for
each pixel, allowing more colors to choose from for displaying each
pixel. For example, a 2-bit-plane screen assigns two bits to each
pixel, giving you four colors to choose fromsince two bits allows
four combinations of zeros and ones. Each bit plane you add
doubles the color capacity of each pixel, since each bit doubles the
possible combinations of zeros and ones. The following chart
95
shows how many colors are available for each pixel when you
assign the corresponding screen depth:
1 2
2 4
3 8
4 16
5 32
SECTION 2: IMAGES
96
To see how to create several screens of different resolutions at
once on the monitor, enter and run this very short program:
Figure 4-4.
97
In Figure 4-4, you'll notice that the sizes of the title bars and
gadgets change from screen to screen, depending on the screen's
resolution. You can also see that the screens are layered in the order
you created them. Each new screen you create always appears in
front of any screens you previously created.
SCREEN CLOSE 3
SCREEN CLOSE 4
SCREEN CLOSE 3
SCREEN CLOSE 2
SCREEN CLOSE 1
When you create a screen, you set the resolution and number of
colors you want to work with. To create an area on that screen to
put graphics and text into, you must create a window with the
WINDOW statement. You can create as many windows as the
SECTION 2: IMAGES
98
Amiga's memory will support, and you can make them in different
sizes, locations, and with different features. You can make windows
in the Workbench screen or any other screens you have already
created with the SCREEN statement.
The format for the WINDOW statement is:
99
row of pixels is row 0, the rows following below it are numbered 1,
2, 3, 4, and so on until you reach the bottom of the screen. The first
column of pixels on the left is numbered column 0, and the col
umns following it to the right are numbered 1, 2, 3, 4, and so on
until you reach the right side of the screen. Figure 4-5 shows you
how this numbering system works.
Columns
Figure 4-5.
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17*
addressing system. 1
2
R
o 3
W
4
s
7 I
8
\
To locate any one pixel, you use a pixel address that is the pixel's
column number followed by its row number. For example, a pixel at
address 5,7 is 6 columns over and 8 rows down from the upper left
corner of the screen. Because the numbering starts with zero, the
actual row and column is always one count greater than the row
and coiumn number in the address.
In Amiga BASIC, pixel addresses are always enclosed in
parentheses with the column number first, followed by a comma
and the row number. The pixel address shown before would appear
as (5.7) in a BASIC program. When you use two addresses, as you
do to show the two opposing corners of a window, you separate
them with a dash. So a window occupying the upper left quarter of
a 320-by-200 screen would be shown as (0,0) - (159,99). These two
addresses are the upper left corner of the screen and the center of
the screen. The window they position looks like the one shown in
Figure 4-6.
SECTION 2: IMAGES
100
Figure 4-6.
n Corner Window
A window created in
WINDOW FEATURES
Windows come in different sizes and varieties, as you've
probably found out by working with different Amiga programs.
Some windows can be dragged around the screen, while others are
stationary Some have all sorts of gadgets; others have none.
The WINDOW statement gives you the chance to customize your
window as you create it. You can pick features for the window
somewhat like choosing items from a catalog. Each feature has a
value associated with it. After you decide which features you want
in your window, you take the value for each feature and add all the
values together. The resulting number is the window features
101
number, and it tells WINDOW which features you've chosen. The
following is a list of window features you can specify with their
corresponding feature values:
Figure 4-7 shows a window with all of the features that are
visible on a window. (It obviously can't show window dragging or
refreshing!)
As an example of specifying window features, if you want a
window with a sizing gadget, back and front gadgets, and a close
gadget, you sum their feature values1, 4, and 8to get 13.
Entering 13 as the window-features number after the WINDOW
statement specifies those features. If you don't enter any window-
features number and simply include a comma where it would be,
WINDOW assumes you want all the features.
Not all of these features are free. Some will cost you extra
memory, and you should avoid specifying them unless you really
need them. Window refreshing takes a good-sized chunk of RAM to
store the contents of the window. The amount depends on the size
of the window; a large window needs much more RAM for window
SECTION 2: IMAGES
102
Close gadget Tide Title bar Back and front gadgets Figure 4-7.
features.
Sizing gadget
103
you don't specify a screen number, BASIC assumes you mean
the Workbench screen, and will automatically create your
window there.
If you want to try it out, enter and run this short program:
The screen created by this program should look like Figure 4-8.
You can move the window around with the pointer and use the
gadgets. To return to the Workbench screen, choose Show List from
the Windows menu. The List and Output windows will then
reappear.
Figure 4-8
El Dir ty Window
SECTION 2 IMAGES
104
As mentioned earlier, the only specification that has to be in the
WINDOW statement is the window ID number. The statement
WINDOW 2
will work just fine. It creates window number 2, which has all the
window features, no title, and fills the entire Workbench screen.
If you want to include a specification at the end of the statement
without filling in all the other specifications, you must insert
commas in place of the omitted specifications, or you'll get a
syntax error. To open a window number 2 in screen number 1 with
no other specifications, you'd use the command;
WINDDW 2, , , , 1
Even if there is more than one window open, Amiga BASIC will
create graphics and print text in only one window at a time. If that
weren't the case, BASIC wouldn't know which window to use to
display the results of any graphics or printing commands you issue.
The one window that is currently active for text and graphics is
called the output window.
When you create windows with the WINDOW statement, the last
window you create is automatically set to be the output window.
Ail output from graphics commands and text from print statements
that follow will show up in that window.
You can use the WINDOW statement to re-create a window,
bringing it up in front of other windows and making it the output
window. For example, the short program shown below will create
two windows, 2 and 3, and then re-create 2, bringing it out from
behind 3 in the same location and size, making it the output
window. The PRINT statement at the end of the program tests to
see which window becomes the output window.
WINDDW 2
105
unghosted title bar. The input and output windows don't neces
sarily have anything to do with each other.
Notice also that the third program line recreates Window 2
without changing its original size and location. Whenever you use
a WINDOW statement without specifications for a window that
already exists, BASIC uses the first set of specifications you chose
for that window.
WINDOW OUTPUT 3
SECTION 2: IMAGES
106
BASIC program, you can use the WINDOW CLOSE command, which
uses this format:
WINDOW CLOSE 2
As you recall, each screen on the monitor has its own palette
with its own array of colors that it uses to color in its background,
borders, menu items, and any graphics and text in any of its
windows. The Amiga uses 32 different locations in RAM, called
color registers, to store those colors. The color registers are num
bered from 0 to 31, and there is a separate set of 32 registers for
each screen.
When you first turn on the Amiga, the color registers are already
filled with default colors that you can use without changing if they
suit your needs. If you'd like to see them, run this program:
PSET(G,190]
FOR i - 0 TO 31
NEXT i
107
in the Workbench to change your Workbench and pointer colors,
you change the contents of color registers 0 to 3 and 17 to 20.
You can't always use all 32 color registers in each screen. The
number of color registers you can use in any screen is limited by
the screen's depth in bit planes. The foDowing chart shows which
color registers are used for screens of different depths:
register number
COLOR 2, 3
If you leave out the comma and the second number, COLOR sets
just the foreground color without altering the background color. If
you follow COLOR with a comma and then a number, it sets the
background color without changing the foreground color. If you
SECTION 2: IMAGES
108
don't use the COLOR statement in a program, BASIC assumes that
the color in color register 1 is the foreground color and the color in
register 0 is the background color. Once you set new foreground
and background colors with the COLOR statement, BASIC uses
them for any drawing commands that follow By changing the
background and foreground colors between drawing commands,
you can set new colors for new figures.
Changing the foreground color will have an obvious effect: Any
drawing or text statements that follow the COLOR statement will
use the new foreground color, since BASIC statements that create
graphics draw with the foreground color, as you'D see in the next
chapter. Changing the background color is not always so obvious.
Unless you use a statement that uses the background color when
it executes, you won't see any change to the current background
color. The important thing to remember about changing the
foreground and background colors is that they will affect drawing
statements that follow the COLOR statementanything created up
to that point will remain on the screen in the color it was created
with (unless you re-create it after the subsequent COLOR
statement).
When you choose foreground and background colors with the
COLOR statement, you're restricted to the colors available in the
color registers that the screen contains. For example, if you're
drawing in a screen with two bit planes, that screen has four color
registers and your choice is limited to just those four colors. If the
default colors in the four color registers aren't to your liking, you'll
want to change them to colors that you like so the choice, although
limited, offers you desirable colors. The PALETTE statement lets
you change the contents of any color register to any one of 4096
different colors.
109
HOW COLOR REGISTERS STORE COLOR
Each color register stores one color as a combination of the
primary colorsred, green, and blue. When you tell BASIC what
color you want to store in the register you specify, you must tell it
the strength of each primary color that you want to use to make up
the new color. There are 16 levels of strength that can be specified
for each of the primary colors, making a total of 4096 colors to
choose from (16 times 16 times 16 equals 4096).
Instead of specifying whole numbers from 1 to 16 (for example, 5
parts red, 8 parts green, and 16 parts blue), Amiga BASIC requires
you to specify the strength of each color as a fractional number
from 0 to 1. A value of 0 means that the primary color isn't present,
while a value of 1 means the color is present in full strength. The
chart in Figure 4-9 will help you determine the fractional numbers
to use in the PALETTE statement to represent the strength of each
primary color. Using this chart, you can specify a color as shown
above (5 parts red, 8 parts green, and 16 parts blue), and then
translate these numbers into the fractional numbers that BASIC
expects in the PALETTE statement (.28, .47, and 1 in our example).
Figure 4-9.
Primary color strength PALETTE value
SECTION 2- IMAGES
110
table above, after the PALETTE statement. For example, the
following statement will change the color in register 0 (the
background color register) to a shade of green by setting red to
strength .34, green to .84, and blue to 0 (no blue present):
FDR i - 0 TO 31
NEXT i
PSET(0,190)
FOR l = 0 TO 31
NEXT l
The loop just after the WINDOW 3 statement uses the PALETTE
statement to create a random set of colors for the second screen's
color registers. When you run the program, you can see these
random colors. If you drag the randomly colored screen down by its
title bar, you can see your first screen with an entirely different set
of colors just behind it. By putting different screens on the monitor,
111
each with its own unique set of colors, you can display more than
32 colors on the monitor at one time (shown below in Figure 4-10).
Figure 4-10.
SECTION 2: IMAGES
112
CHAPTER FIVE
AMIGA BASIC
GRAPHICS:
CREATING IMAGES
Creating a new screen, setting an output window,
and deciding on the colors you want in a palette are only
the preliminary steps of creating BASIC graphics on the
Amiga. Once you've set up the area you're going to work in,
you can start being imaginative, filling windows with
figures of your own creation.
In this chapter, you'll learn about Amiga BASIC state
ments that allow you to draw simple shapes, change the
color of a single pixel or an entire window, and create
different patterns for drawing lines and filling in figures.
You'll also learn a new way to address pixels, and find out
how to set background and foreground colors. When you're
finished with this chapter, you should be well on your way
to becoming an Amiga BASIC artist.
ABSOLUTE ADDRESSING
Absolute addressing is the same addressing system you use to
specify the opposing corners of a window in a screen (described in
the WINDOW statement section m the previous chapter), except
that it specifies an address within the boundaries of a window
instead of a screen. In absolute addressing, the address you spec
ify is always in reference to the upper left corner of the window.
SECTION 2. IMAGES
114
The pixels are numbered by column and row, starting with (0,0) in
the upper left corner of the window. The addresses are enclosed
in parentheses and use a comma to separate the column number
from the row number. For example, (13,20) specifies an address
14 columns to the right and 21 rows down from the upper left
corner (0,0) of the window.
RELATIVE ADDRESSING
Relative addressing lets you describe a new pixel location as
the distance from a previous pixel address. Each relative address
starts with the keyword STEP, followed by a distance in columns
and a distance in rows, separated by a comma and enclosed in
parentheses. For example, STEP(5,8) specifies a new address five
columns to the right and eight rows down from the last pixel
address you used. If you want to use a relative address to move
to the left or up from the last pixel address, you use negative
numbers. For example, STEP(-7, -9) specifies a new address that
is 7 columns to the left and 9 rows above the old address.
Relative addressing saves you the time you'd take to calculate a
new absolute address. For example, if you use absolute addressing
and you start with a pixel at location (10,5), then want to specify a
pixel 10 columns to the right and 20 rows down, you have to add 10
to the column number and 20 to the row number to get a new
address of (20.25). If you use relative addressing, you can specify the
second address using STEP{10,20) to move 10 columns to the right
and 20 rows down. Figure 5-1 shows how this works.
Figure 5-1.
address.
115
Relative addressing works especially well in FOR... NEXT loops
where the address changes in each cycle of the loop. Instead of
calculating new absolute addresses for each cycle, a simple relative
address will change the address by the incremental value of the
loop for each iteration. For example, the program shown in Figure
5-2 uses the PSET statement (discussed shortly) to plot a point on
the screen 100 pixels over and 50 pixels down using an absolute
address, then uses another PSET statement in a FOR... NEXT loop to
plot 10 more points, each one plotted in relation to the previous
point specified.
Figure 5-2.
SECTION 2 IMAGES
116
WINDOW BOUNDARIES
When using pixel addresses in the drawing statements, it's
important to make sure you remain inside the boundaries of the
output window Some statements simply won't work if you specify
an address outside the window, while others will stop the program
and return an error message.
When you first create a window with the WINDOW command,
you set the size of the window's interior with opposite corner
addresses. (See Chapter 4 for details on creating a window.) If you
create a window with opposite corners at (50,20) and (250,120), with
a title bar, no sizing gadget, and no front and back gadgets, you
have a window interior that measures 201 pixels across (the
distance from column 50 to column 250, inclusive) and 101 pixels
from top to bottom (the distance from row 20 to row 120, inclusive).
The window that appears on the screen is actually larger than 201
by 101 because it includes the border and the title, which are
outside the interior area. It also includes an interior border that
measures one pixel across the top and bottom, and two pixels wide
on either side, just inside the window border, as you can see in
Figure 5-3. Since the interior border is the same color as the
background color, you can't really see it there. It's impossible to fill
those pixels m, since this "invisible" interior border is always in
placeyou can't turn it off or disable it.
Figure 5-3.
117
If you add a sizing gadget to a window, the window becomes
15 pixels wider to accommodate the sizing gadget. You can't draw
in the 10 columns next to the right border, though, so you gain only
5 columns of usable space in the window's interior. If you create a
window without a title bar, the interior of the window moves up to
occupy the space where the title bar would be, and you gain 10
more rows of pixels at the bottom of the window. Figure 5-4 shows
a window with the same opposing corner addresses as the window
in Figure 5-3, but with a sizing gadget and no title bar. You can see
that it has an interior that measures 206 columns by 111 rows5
pixels wider and 10 pixels higher than the same window with a
title bar and no sizing gadget.
Figure 5-4.
SECTION 2 IMAGES
118
THE CLS STATEMENT
CLS
FDR i = 1 TO 3
COLOR , i
CLS
NEXT i
COLOR , 0
CLS
PSET{149,99)
fills in the pixel at column 150, row 100, using the current foreground
color. If you specify a color-register number, PSET uses the color
119
in that register to color the pixel instead of using the foreground
color. For example,
PSET(199,149), 3
uses color register 3 to fill in the pixel at column 200, row 150
instead of using the foreground color.
You can't specify a color register not used by the screen you're
working with. For example, if you're using a 2-bit-plane screen,
such as the default Workbench screen, you can only specify regis
ters 0 through 3, since a 2-bit-plane screen allows only four color
registers. Also, specifying a color-register number affects that pixel
onlysubsequent pixels set with the PSET statement will use the
default foreground color unless another register is specified.
The PRESET statement works almost exactly like the PSET com
mand. The difference is that PRESET colors the pixel at the address
with the background color instead of the foreground color if you
don't specify a color register. It uses the same format as PSET:
PRESET(14,74)
SECTION 2: IMAGES
120
statement with a different address and color for each pixel. If you
want to do this, it helps to use graph paper to draw your figure and
work out the pixel addresses and colors.
An easier way to create figures is to let a FOR... NEXT loop
do some of the work for you. As a simple example, the following
program draws a diagonal line on the screen:
FOR i = 1 TD 100
PSET( 1,1)
NEXT i
If you have some experience with trigonometry, you can use its
functions to plot some nice shapes in the output window. By using
the value of the counter variable in the FOR.. .NEXT loop as one of
the addresses (either the column or the row number), and a
trigonometric function to set the value for the other half of the
address, you can actually chart values in the output window. As an
example, the following program uses the SIN function to create a
sine wave on the screen, as shown in Figure 5-5.
FOR i = 0 TO GOO
NEXT i
Figure 5-5.
onometric function
121
If you analyze the row address in the PSET statement, you can
see that it uses one full cycle of a sine wave (6.28318, which is two
times pi), that it multiplies the results by 80 so the wave goes to the
top and bottom of the window, then adds this value to 90 to center
the wave horizontally in the window. The last line in the program is
merely an "infinite loop" that keeps the program running and the
List window hidden; otherwise, it might appear and cover up the
right half of the wave. To end the program and show the List
window, use the Menu button on the mouse and choose Stop from
the Run menu.
Figuring out mathematical solutions to create figures may not be
your cup of tea, but if you know how to use them, they can create
some fascinating shapes, save you a lot of tedious single-pixel
plotting, and give you a practical application for all that trig you
slogged through in high school.
CREATING LINES
All you need do to create a line is supply the beginning- and
ending-point addresses, like this:
L1NE(7O,54) - (10,5)
SECTION 2: IMAGES
122
As you can see in Figure 5-6, this statement draws a line from the
point at (70,54) to the point at (10,5), using the default foreground
color. To use any other color register for the line, just follow the
statement with a color-register number:
L!NE(70,54 10,5
This statement draws the same line as before, but colors it using
the color in color register 2 instead of the foreground color. You
should note that specifying a color-register number affects only
that line; subsequent lines drawn with no color-register number
specified will use the foreground color. Also, the number of color
registers available depends on the depth (number of bit planes) of
the screen containing the output window
Figure 5-6.
creates a line.
CREATING BOXES
To create a box with the LINE statement, you specify the upper
left and lower right corners of the box, and add a box option after
the color-register number (if you want to use the current foreground
color, you must include the comma at its position). There are two
box options: B and BF. The B option will make LINE draw a hollow
box instead of a line, using the starting and ending addresses as
123
opposing corners of the box. The BF option draws a box filled with
the current foreground color. For example,
L1NE(1OQ,25) - STEP(100,50), , B
draws a box with its upper left corner at address (100,25) and its
lower right corner 100 columns to the right and 50 rows down
(recall that STEP indicates a relative address). In this example, the
box is a hollow box, since we used the B option, and it's drawn
with the current foreground color since no color register was
specified. You can see the results in Figure 5-7, together with a
filled box created with this statement:
LINE(IOO.IOO) - STEP(100,50), , BF
Figure 5-7
SECTION 2: IMAGES
124
You must specify the center address and radius values. The
center address can be absolute or relative. The color-register
number, the arc starting and ending points, and the aspect are all
optional. All the values have to be separated with commas if you
include them.
CREATING CIRCLES
To create a simple circle, you supply CIRCLE with an address for
the center of the circle and a value for the radius. The radius is
measured in pixels from the center of the circle to the edge of the
circle. For example, the statement to create a circle centered at
(150,100) with a radius of 50 pixels is:
CIRCLE(150,100), 50
Figure 5-8.
creates a circle.
ClRCLE(150,100), 50, 3
creates the same circle as before, but draws it using the color in
color register 3.
125
CREATING ARCS
To create an arc, add a starting and ending point on the circle
for each end of the arc. To specify these points, measure the circle
in radians and give CIRCLE the two ends of the arc as radian
measurements. Think of a radian as a unit of measurement that
describes the diameter of a circle. A full circle is 6.28318 radians; a
half circle is 3.14159 radians (mathematically referred to as pi).
Radian measurement for the CIRCLE statement begins at the
three o'clock position of the circle, where the measurement is zero.
You measure from that point counterclockwise around the circle
twelve o'clock is 1.57079 radians (pi divided by two), nine o'clock is
3-14159 (pi), six o'clock is 4.71238 (pi times 1.5), and a full circle is
6.28318 radians (two times pi).
If the value specified for the starting point is smaller than the
value specified for the ending point, the arc will be drawn counter
clockwise. If the first value is larger than the second, the arc will be
drawn clockwise.
In addition to drawing the arc itself, you can add straight lines
from the starting and/or ending points of the arc to the center of the
circle by making either or both the arc starting- or ending-point
value a negative number. BASIC draws the arc as if the values were
positive, then draws a line from the point(s) specified as negative
numbers to the circle's center. This statement draws an arc with a
straight line from its ending point, as shown in Figure 5-9:
Figure 5-9.
SECTION 2: IMAGES
126
Many people are more familiar with measuring circles as
degrees of arc rather than radians. To convert degrees into radians,
you can use the following formula:
A circle measured in
radians.
1 Radian
1 Radian
1 Radian
1 Radian
1 Radian
CREATING OVALS
By changing the aspect of the CIRCLE statement, you can
change the height of the circle it creates and turn it into an oval.
The aspect follows the starting and ending points of an arc in the
CIRCLE statement.
The formula that CIRCLE uses to create a circle assumes that
pixels on the monitor screen are perfectly square. However, the
monitor doesn't create absolutely square pixels, even in resolution
modes 1 and 4the pixels are slightly taller than they are wide. To
compensate for this difference, Amiga BASIC normally uses a
default aspect value that keeps circles looking perfectly round on
the Amiga monitor.
If you don't specify an aspect, CIRCLE uses a .44 aspect auto
matically, a value that creates perfect circles in the default mode 2
screen. If you want to increase or decrease the pixel aspect ratio,
just specify a new aspect value. If you aren't creating an arc, you
127
don't have to specify starting and ending points, but you do have
to use commas to hold their places. As an example, increase the
aspect value to stretch up the circle you've been working with:
CIRCLE{150 ,100) , 50 , , , , 1
Figure 5-11.
When you increase the aspect value above the default value, the
circle is stretched out vertically; when you decrease the aspect
below the default value, the circle is stretched out horizontally.
Since each screen-resolution mode uses a different size of pixel,
you need to use different aspects to keep the circles perfect for
each mode. In a mode 2 screen, the default value that Amiga BASIC
uses will create round circles automaticallyyou don't have to
specify an aspect value. Mode 1, mode 3, and mode 4 screens,
however, require you to enter a value in order to get round circles.
The following table gives you the circular aspect for each mode:
.88
.44
1.76
SECTION 2: IMAGES
128
If you set the aspect value to create ovals and also include
starting and ending points for an arc, CIRCLE will create arcs that
are curved just like the ovaljust as the aspect normally would
create if it were a complete circle.
AREA and AREAFILL are two Amiga BASIC statements you use
together to create multi-sided figures and fill them with solid colors
or intricate patterns. They work a little like a connect-the-dots
picturefirst you set the invisible dots in the output window with
AREA, and then use AREAFILL to connect the dots, and to fill the
area with a color or pattern.
AREA(address)
AREA(120,9B)
AREA(1S0,50)
AREA STEP{100,50)
AREA STEP(-100,SO)
AREA STEP(-100,-50|
129
THE AREAFILL STATEMENT
AREA statements by themselves have no effect on the appear
ance of the output windowthey only set the points for the shape
you're drawing. AREAFILL connects the points with lines and fills in
the interior of the shape with either the foreground color by default,
or with a color or pattern you specify. (If you want to create a shape
that isn't filled in, you have to draw each line of the shape individu
ally, using graphics statements other than AREA/AREAFILL.)
AREAFILL uses this format:
The mode number is an option that specifies how to fill the area;
you can omit it if you just want to use the foreground color.
In order for AREAFILL to work, you have to precede it with at
least two AREA statements. AREAFILL first connects the points you
set with the AREA statements in the order that you set the points.
When it reaches the last point you set, it connects it to the first
point you set, so you don't have to end your series of AREA
statements with the address that you started with (although it
won't hurt if you do).
After the points are connected, AREAFILL fills the interior and
the boundaries of the shape with the foreground color if you haven't
specified a mode number. Since it fills in the boundaries as well as
the interior, the shape is one solid color; it doesn't have an outline
in a different color.
You can specify a mode number if you want to control the color
of the shape. A 0 will color the shape with a pattern you've created
with the PATTERN statement (discussed later) or, if you haven't
defined a pattern, with the foreground color. If you specify a mode
number of 1, AREAFILL changes the colors of all pixels within the
area defined by the AREA statements to their inverse colors. A
color's inverse color is found in the color register at the opposite end
of the palette. For example, the table below shows the inverse
colors of an eight-color (3-bit-plane) screen:
0 7
1 6
2 5
3 4
4 3
5 2
6 1
7 0
SECTION 2: IMAGES
130
If you omit the mode number, AREAFILL assumes a 0 and uses
the current pattern {or the foreground color, if no pattern has
been defined).
To see AREAFILL do its work, add it to the four AREA statements
you used before to set the points of a diamond shape and then run
the program;
AREA(1S0,50)
AREA STEP(100,50)
AREA STEP(-100,50)
AREA STEP(-100,-50)
AREAFILL
You can see the diamond shape appear on the screen, filled with
the foreground color, in Figure 5-12.
Figure 5-12.
AREAFILL 1
and run the program again, you'll see the same diamond shape
repeated on the screen, but instead of filling it with the foreground
color, the diamond will appear in the inverse color of the back
ground pixels. Since there are no pixels of any other color within
the AREA boundaries, AREAFILL 1 inverts just the color of the
background pixels.
131
As you create shapes with AREA commands followed by
AREAFILL, you don't have to keep the boundaries of the shapes
from crossing each other. For example, this short program creates
two filled triangles because the side boundaries cross each other,
as you can see in Figure 5-13:
AREA(GO,50}
AREA STP(200,0)
AREA STEP(-200,100)
AREA STEP(200,0)
AREAFILL
Figure 5-13.
statements.
SECTION 2: IMAGES
132
THE PAINT STATEMENT
As you've seen, the LINE statement gives you the option to fill in
the boxes you create with color. Similarly, you can use AREAFILL to
fill in with a color or a pattern the shapes you create with AREA
statements. Amiga BASIC also allows you to fill in any other
enclosed shapes you've created (with the CIRCLE statement, or
with a series of PSET or LINE statements, for example). Your tool for
doing this is the PAINT statement. Its format is:
register number
CIRCLE(140,9D), 100
PAINT(140,90)
133
Figure 5-14.
PAINT(140,90), 2
If you try this PAINT statement with the last circle you created, it
will paint over the boundaries of the circle and fill the entire output
window. That's because PAINT only recognizes boundaries of the
same color as the color it uses to fill with. If you want to fill a shape
with a color other than its border color, you can follow the fill color-
register number with a comma and the color-register number of the
color you want to use as a border As an example, here's PAINT set
up to fill with the color in register 3, recognizing the color in
register 1 as a boundary:
PflINT(120,100), 3, 1
If you enter and run the following program, you'll see the circle in
Figure 5-15, with an outside boundary of foreground color, filled
inside with color 3:
CIRCLE(120,100), 100
PAiNT(120,100), 3, 1
SECTION 2: IMAGES
134
Figure 5-15.
When you use Amiga BASIC to draw lines and fill in shapes and
areas, you usually draw and fill with solid lines and colors. If you
want to add some variety and texture to your graphics creations,
you can use the PATTERN statement to create patterns that you can
use to draw lines and fill in areas. Once you've created and set
these patterns, any drawing commands that follow a PATTERN
statement will use the line and area patterns instead of solid lines
and colors.
PATTERN uses this format;
You can omit either the line mask or the pattern-mask array name
from the PATTERN command, but you can't omit both of them.
135
CREATING A LINE PATTERN
To create a line pattern, you must first create a 16-bit mask
that is, a binary (base 2) number that uses 16 ones and zeros. Each
one in the mask stands for the foreground color, each zero stands
for the background color. The binary number 1010101010101010, for
example, is a mask that alternates the foreground and background
colors every pixel. Once you set the line pattern, any lines you draw
with Amiga BASIC will use the pattern in the mask (from left to
right) over and over as many times as necessaryif a line is longer
than 16 pixels, Amiga BASIC repeats the mask until the line is
finished. If the line is shorter than 16 pixels, Amiga BASIC starts at
the beginning (left end) of the mask and uses as much of the
pattern as it can.
If you want to create a dashed-line pattern, try the line mask
1111000011110000, which alternates four pixels of foreground color
with four pixels of background color. If you want a mostly solid line
with small breaks of background, try 1111111111110000. You can exper
iment to find what suits you best when you use the PATTERN
statement to put your line mask into effect.
0000 0 1000 8
0001 1 1001 9
0010 2 1010 A
0011 3 1011 B
0100 4 1100 C
0101 5 1101 D
0110 6 1110 E
0111 7 mi F
SECTION 2: MAGES
136
For example, the mask 1110011111100111 would break into 1110 0111
1110 0111. Using the table, these four groups translate into E, 7, E,
and 7, so the entire hexadecimal number is E7E7. In Amiga BASIC,
hexadecimal numbers are always preceded by &H, so the mask
becomes &HE7E7 in hexadecimal. If the &H isn't specified,
PATTERN assumes you are using a decimal (base 10) number.
Although you can use a decimal number, you will probably find it
easier to work with hexadecimal values.
PATTERN 4HE7E7
L1NE(65,4O) - STEP(150,100), , B
In Figure 5-16, you can see how Amiga BASIC draws the box
using the line pattern you set with the &HE7E7 line mask. If you
continue using the LINE statement, Amiga BASIC will use the same
pattern to draw any other lines and boxes you create. The line pat
tern won't affect any circles or arcs drawn with the CIRCLE state
ment, though.
Figure 5-16.
137
To set the line pattern back to a solid line, use
PATTERN 4HFFFF
0000111100001111
0000111100001111
0000000000000000
0000000000000000
1111000011110000
1111000011110000
0000000000000000
oooooooooooooooo
0F0F
OFOF
0000
0000
F0F0
FOFO
0000
0000
SECTION 2: IMAGES
138
After you translate each line of the mask, you count the number
of lines and create an integer array in your program using exactly
the same number of elements as you have lines. For the polka-dot
pattern in our example, you need to specify eight elements (one for
each line), so you dimension the array to 7 with a DIM statement.
(Since each array starts with element number 0, you actually have 8
elements in an array dimensioned to 7.) You then assign the lines of
the mask in top-to-bottom order to the elements of the array. The
program lines below assign the polka-dot mask to the integer array
POLKADOT% (the % signifies an integer array):
POLKADOTX(0] = 4H0F0F
POLKADQTX|1) - &HOFOF
POLKADOTXU) = AHOOOO
POLKADOTX(3) = iHOOOO
POLKADDTX(1) = iHFOFO
POLXfiDDTXf5) = J.HFOFO
P0LKADDT%(6) =* 4HOOO0
PDLKADDT7.(7) = 4H0OO0
PATTERN, PDLKADDTX
139
The following short program brings everything together to draw
the box filled with polka-dots shown in Figure 5-17:
DIM PQLKADDTX(7]
POLKADCTX(O) - 4HOF0F
POLKADOTXf1} = &HQF0F
PQLKAD0TX{2) = 4H000O
P0LKADDTX(3) = 4H0000
P0LKADDTX(4) = &HF0F0
PDLKADDTX(5) = 4HFOF0
POLKftDOTXlG) = 4HOO00
P0LKAD0TX[7) - 4H0O00
PATTERN, PQLKADDTX
LINE(70,10] - 5TEP(150,1GC , BF
Figure 5-17
A polka-dot box
If you type this program yourself, you may notice that BASIC
abbreviates the numbers you type in for each array element. For
example, after you type &H0000 and press RETURN, BASIC converts
the number to &H0, which has the same value.
SECTION 2; IMAGES
140
To turn the area pattern back to a solid foreground color, you
create a simple two-element integer array, assign a solid pattern
mask, then apply it in a PATTERN command:
dim solidxi1)
sol1dx[0) = 4hffff
SQLIDXd ) - &HFFFF
PATTERN, SQLIDX
141
CHAPTER SIX
AMIGA BASIC
GRAPHICS: ODDS
AND ENDS
Amiga BASIC has a number of miscellaneous graphics
statements and functions that don't create screens and
windows and fill them with graphics. Instead, these "odds
and ends" statements and functions allow you to label your
graphics, change their size with the size of a window, or
copy them from one area of the screen to another.
You can use several of these statements and functions to
work creatively with text; you can add text to your pictures
with the PRINT statement, and you can use the LOCATE and
COLOR statements to position your text in just the right
location with the colors you want. To keep track of the
text's location, you can use the CSRLIN and POS(O)
functions.
Other statements and functions help you adapt your
graphics to the changing dimensions of a resizable win
dow. You can use the window() function within the
program to read the window's width and height, and use
this information to change the graphics to fit the window's
new size when the program user changes it with the sizing
gadget. You can also use the WINDOWO function to check
the window's ID number, to see how many colors it will
support, and to examine other pertinent window informa
tion. To check the color of an individual pixel within the
window, you can use the POINT function.
The GET and PUT statements allow you to cut and paste
graphics in a window. With GET and PUT, you can also
present a series of pictures in rapid succession in the
output window.
CHARACTER ADDRESSING
SECTION 2: IMAGES
144
Text-character addresses start with a different pair of numbers
than pixel addresses; instead of lines and columns starting at 0,
text lines and columns start at 1. For example, the character in the
upper left corner of the window is in address 1,1, not address (0,0).
Text-address numbering starts in the upper left corner of the
window, and the numbers increase as you move to the right or
move down the screen, just like the numbering system for pixel
addresses. Figure 6-1 shows how the lines and columns of text are
numbered.
1 2 3 4 5 6 7 a 9 10 11 12 -
3 I
4
R 5 A
,
......
O 6
......
....
......
W 7
s
8
9
10
.,...
11
......
12
.......
z I
......
""
Instead of specifying first the column and then the row as a pixel
address does, a text-character address specifies first the line and
then the column. You separate the two numbers with a comma, but
you don't enclose them in parentheses as you do a pixel address.
For example, a character in the fourth line down the screen seven
columns to the right is at address 4.7-
The size of the characters in the font you use with Amiga BASIC
determines the number of text lines and columns that fit on the
screen, so of course this affects the numbers you use in a text
address. When you first open Amiga BASIC, it uses the same font
145
size you're working with in the Workbench. The Preferences
program on the Workbench disk allows you to change the font you
use on the Workbench screen.
There are two font-size options available: the default 60-column
font and the 80-column font. The 60-column font uses characters
that measure 10 pixels wide by 9 pixels high, wide enough to
show up clearly on TV sets and composite video monitors. The 80-
column font uses smaller characters to fit more text on the monitor
screen. These characters measure 8 pixels wide by 8 pixels high,
skinnier and shorter than 60-column characters. 80-column charac
ters aren't always legible on TV sets and composite video screens,
but they're very readable on RGB monitors.
The size of the characters in a window also depends on the
resolution of the screen the window belongs to. All characters in
the font have the same size as measured in pixels, but since the
size of the pixels changes with different screen resolutions, the
overall size of the characters changes also. For example, characters
are twice as wide in a screen that uses low-resolution pixels as
they are in a screen that uses high-resolution pixels. Characters are
twice as high in a screen that uses non-interlaced pixels as they
are in a screen that uses interlaced pixels.
The combination of font and resolution determines how many
characters will fit in a full-screen window. The following chart
shows how many rows and columns of text fit in a full-screen
window with a title bar and sizing gadget.
SECTION 2 IMAGES
146
Figure 6-2.
147
THE LOCATE STATEMENT
If you mix text with graphics in a window and want to print text
at an exact character address to fit with the graphics, trying to
position the text cursor with numerous PRINT statements using
commas and semicolons can be very tedious and sometimes
impossible. Not only do you have to use a separate PRINT statement
for each line you want to move down the screen, but if you go too
far down the screen, the text might scroll up and ruin the position
of everything else. For precisely positioning text, you're much
better off using the LOCATE statement.
The LOCATE statement specifies a location on the screen
where the next PRINT statement you use will start printing. It uses
this format:
Statement Result
SECTION 2: IMAGES
148
statement in a series from 1,1 to 19,19 to print a diagonal line of
words across the screen:
for i - i to 19
LOCATE i, i
PRINT "Diagonal"
NEXT i
Figure 6-3.
[Diagonal
LOCATE in a
FOX i = 1 TO if FOR ... NEXT loop
LOCATE I* I
creates a diagonal
PRINT "Mag
NEXT i line of words.
Diagonal
Diagonal
Diagonal
Diagonal
Diagonal
Diagonal ;
Diagonal
Diagonal
Diagonal
LOCATE 11,5
FDR i = 1 TO 100
LOCATE 11 , 22
PRINT i
NEXT i
149
LOCATING THE TEXT CURSOR WITH
THE CSRLIN AND POS(O) FUNCTIONS
Many times you'll want to align some new text with text already
on the screen. You can use the LOCATE statement, but it may be
difficult to find the exact location you need. For example, to figure
the address for the second LOCATE statement in the last program,
you have to add up the characters in the string The count is now:
and add the total to the location of the first LOCATE statement
along with an extra count to add a space after now:. You can use
two functions, CSRLIN and POS(O), to locate and record the address
of the text cursor at any time for use in a later LOCATE statement.
CSRLIN returns the Sine number of the text cursor's position.
You can assign the value it returns to a variable for storage. For
example,
x - CSRLIN
stores the line number of the text cursor's current position in the
variable x.
POS{0) returns the column number of the text cursors position.
Like the CSRLIN function, you can assign the value POS(O) returns to
a variable for storage. For example,
y - PDS(O)
locate 11, s
X - CSRLIN
y = PDS(O)
FDR 1 = 1 TD 100
LOCATE x, y
PRINT 1
NEXT 1
SECTION 2: IMAGES
150
CSRLIN and POS(O) can read its address. Notice also that the second
LOCATE statement put the text cursor directly after the end of the
The count is now:, but the number is printed with a space before
it. That's because the PRINT statement always inserts a space
before a positive number. To position text effectively, it's important
that you know where the PRINT statement leaves the text cursor.
In the last chapter, you used the COLOR statement to set the
foreground and background colors for the drawing statements. You
can also use COLOR to set the foreground and background colors
for text. When PRINT puts characters on the screen, it uses the
foreground color to create the characters and the background color
to create the background for the characters.
If you try the following statements, you'll see text printed with
color 3 on a background strip of color 2:
COLOR 3, 2
COLOR 1, 0
If you're putting text on top of graphics figures, you can set the
background color of the text to match the figure's colors and blend
the characters into the figure, or you can set the background color
to a different color to make the text stand out as a strip against the
figure. The following program draws three shapes in different colors
in the output window and then uses LOCATE to print labels on
each shape. The background and foreground colors of the text
are changed for each labelin two of the shapes, the text's back
ground matches the shape's color. In the third shape, the text's
background is set to a different color to make the text stand out.
The LOCATE statements in the program use addresses set for the
60-column text font. If you run it using the 80-column font, the
labels won't show up in the right places.
MakeCircle:
CIRCLE(1G0,50) , 100 , 5
PAINT(160,501. 5, 5
(continued)
151
MakeTrlangle:
COLOR 6
AREA(480,5)
AREA STEP[120,90)
AREA 5TEP(-210,0)
AREAFILL
AddLabels:
LOCATE 6, 11
COLOR 2, 5
PRINT "Circle"
LOCATE 8, 45
COLOR 2, 6
PRINT "Triangle"
LOCATE 17, 26
COLOR 2, 0
PRINT "Rectangle"
Figure 6-4.
in the window.
SECTION 2: IMAGES
152
AN INTRODUCTION TO INTERACTIVE GRAPHICS
WINDDN(condjfjor) number)
153
The condition number can be any integer from 0 to 8, and
determines which condition WINDOW{) will read. The WINDOW()
function does no work m a program line by itself; it returns a value
that should be assigned to a variable or used in a statement.
The following list gives the nine condition numbers followed by
the condition that they read:
Condition Value
number returned
SECTION 2: IMAGES
154
window, using WINDOW(l) and WINDOW(O) to read those values. If
you move the pointer around the screen while the program is
running and select different windows, you'll see the number of the
selected window change.
x1 = PDS(O): y1 = CSRLIN
Loop :
LOCATE yi, x1
PRINT WINDOW)1)
LOCATE y2, x2
PRINT WINDOW(O)
GOTO Loop
Figure 6-5.
155
make the graphics that will follow interesting. The 13th line ties the
timer to the RND function to make it truly random. The fast 11 lines
are a continuous loop that fills the output window with 18-sided
AREAFILL figures.
In the first two lines of the loop, two WINDOW{6) functions return
the number of colors available, which are modified by the RND and
INT functions to return two random integers from 0 to the highest
color-register number available. The COLOR statement uses these
two integers to set random foreground and background colors.
The FOR... NEXT loop that follows sets 18 random points using
the AREA statement. The address of the random points is set using
the WIND0W{2) and WINDOW(3) functions so that the address will
never fall outside the window boundaries. The AREAFILL statement
that follows the FOR ... NEXT loop connects the points and fills in
the figure, and the GOTO statement after that starts the loop over
again to create another random 18-sided figure. In Figure 6-6, you
see an example of the random graphics this program generates.
When you run this program, try changing the size of the win
dow with the sizing gadget. When the window changes size, the
random figures created in it will adapt their size to reflect the new
size of the window.
DIM area.patX(7)
area.patX(1) = SH9F9F
area.patX(3) = SHE7E7
RANDOMIZE TIMER
Loop :
FOR l = 1 TO 18
x = INT(WIHDDW{2) - 1) RND(1|
y - INT(WIND0W(3} - 1) RND(1)
AREA(x, y)
NEXT i
AREAFILL
GOTO Loop
SECTION 2: IMAGES
156
Figure 6-6.
row = 4: column = 8
GOSUB Boxlt
END
Boxlt:
x1 = WINDOW^) : y1 - WINDOWfS
PRINT text*;
x2 = NINDQW{4) y2 - UINDDU(S)
RETURN
157
Figure 6-7
WIND0W{4) and
WIND0W(5) locate the texts = "Box it uj*
start and end of a text row - 4: colunn = 3
string to allow you to GOSUB Boxlt
ENS
draw a box around it
Boxlt:
sJL- HIHS0HC5): yl :
PRINT texts;
x2 = HIND0HC4): y2 = HIHHttf
LINE Cxi - 2,yi - 7) - Cx2 *
RETURN
The POINT function looks at any pixel in the output window and
returns the number of the color register used to color that pixel. Its
format is simple:
POINT(pixel address)
LINE(O.O) - (620,60), BF
LINE(0,B1) - (620,120), 2, BF
FDR i = 0 TO 2
LDCATE(7 i) + 3, 5
NEXT i
SECTION 2: IMAGES
158
COPYING AND PASTING GRAPHICS
There are times when you will want to copy graphics from one
section of the output window to another section of the output
window without redrawing them. Amiga BASIC has two state
mentsGET and PUTthat allow you to copy a square section of
any window and move it to another window or to another location
in the same window.
Like the box options of the LINE statement, GET needs two
opposing corner pixel addresses to define a graphics block. They
can only be absolute addresses, not relative addresses. They're
enclosed in parentheses and separated by a dash; for example,
(30,0} - (60.40) defines a block 31 pixels wide and 41 pixels high.
The array name is the name of a variable array that you use to
store the contents of the graphics block. It's followed by an optional
index number in parentheses; the index number is explained
later in this chapter.
159
A short review of arrays might help you understand how GET
uses an array to store the graphics block. When you first create an
array wth a DIM statement, you set the number of elements in
the array For example,
DIM graphiC5X(34)
SECTION 2: IMAGES
160
Graphics block Figure 6-8.
fag aa a q b cjn;
f'gg a g a g a a a no; How an array stores the
qdamaamaddooo=
minnrn
graphics data of a graph
ics block.
LiCiL;Pw2~czi
Bit plane 1
Elen nl 3 da BM nt 4 Dan nt B
Row ia.
Hani: Bit pl.no 3
Elec enl 6 Ele B
nt 7 Elen ant 8
Row 3:
Haw 4:
etc.
161
Try an example: If you're going to store a graphics block that
stretches from (36,5) to (105,72) in a 16-color (4-bit-plane) screen, you
have a block that's 70 pixels wide by 68 pixels high by 4 bit planes
deep. It takes 5 array elements to store one line (70 divided by 16
yields 4 with a remainder of 6, so it takes 5 elements). Multiply that
by the height (68) and the depth (4), and you get 1360. Add 3 to
store the dimensions of the block, and you get a total of 1363
dimensions. You use the statement
Dim blockX(1362)
DIM blockX(1362,4)
SECTION 2: IMAGES
162
When you save the five graphics blocks with five GET state
ments, the two index numbers change for each block. The first
block is stored starting at block%(0,0) and ending at block%(1362,0).
The second block starts at block%(0,l) and ends at block%(1362,1).
And so it goes until the fifth block is stored starting at block%(0,4)
and ending at block%(1362,4).
To point to the beginning of the data for each graphics block,
you just set the first index number of the array to 0, then set the
second index number to the number of the block (0 to 4). This
makes it very easy to use different GET statements to store different
blocks with the same variable. For example, these five GET state
ments store five different graphics blocks in five different parts of
the block% array:
DIM blockX(5276)
to create one.
When you copy the three graphics blocks to the array, you use
elements 0 to 1232 for the first block, which requires 1233 elements.
You use elements 1233 to 5123 for the second block, which requires
163
3891 elements, and you use elements 5124 to 5276 for the third block,
which requires 153 elements. Note the star ting-element index
number for each block so you can use it with three different GET
statements when you copy the three blocks. For example, these
statements save the three example blocks, starting at index number
0 for the first block, index number 1233 for the second block, and
index number 5124 for the third block:
You can store as many different blocks in one array as you wish,
as long as you dimension the array large enough and you don't run
out of memory.
PUTf0,0),
SECTION 2: IMAGES
164
will put the graphics block stored in swath% in the window with
the upper left corner of the block located at pixel (0,0).
If you saved several blocks in one array and used different index
numbers to mark the beginning of each block, then use the same
array name and index number for each block that you used in the
GET statement. For example, to display the five equal-sized blocks
you saved earlier in the array named block%, use these five
PUT statements:
PUT(0,0), b)ock%(0,0)
PUT(160,0), blockXfO,2)
PUT(240,0), blockX(0,3)
PUT(0,100), blockX(0,4)
You can copy the same block to different locations in the win
dow as many times as you want. Just use the same array name
and index with different addresses. For instance, these four state
ments copy the graphics block stored in swath% to four different
locations in the output window:
PUT(0,0),
PUT(50,50), awathX
PUT(110,100), swathX
PUT(204,0}, swathX
PSET
Puts the graphics block in the window, covering up any
graphics that lie beneath it.
PRESET
Turns every color m the graphics block to its inverse color, and
then puts the graphics block in the window, covering up any
graphics that lie beneath it.
AND
Performs the Boolean AND operation between each pixel in the
graphics block and the pixel in the output window that it
covers up and displays the result. It's easiest to understand if
you concentrate on the results, rather than the process.
Wherever there is background color (color-register 0) in the
output window, AND won't lay down any of the contents of the
165
graphics block- Wherever there is the last possible color of the
window (the highest possible color-register number), AND puts
down the colors of the graphics-block just as they are. Any
other colors in the output window combine with the graphics
block colors to create new colors predictable only by using
Boolean AND algebra.
OR
Performs the Boolean operation OR between each pixel of the
graphics block and the pixel in the output window that it
covers. OR lays down the graphics block in its original colors
wherever there is background color, and doesn't lay down
anything where the last possible color of the window (the
highest color-register number) is. Any other colors in the
graphics block combine with colors in the output window to
create new colors predictable only by using Boolean OR
algebra.
XOR
Performs the Boolean operation XOR between each pixel of the
graphics block and the pixel in the output window that it
covers. XOR lays down the graphics block in its original colors
wherever a background-color pixel in the output window is
covered with a graphics-block pixel Wherever a background
color m the graphics block covers an output window pixel,
XOR lays down the output window pixel color. Wherever two
non-background colors are merged, a new color that is neither
of the two merging colors results.
SECTION 2: IMAGES
166
stencil define shapes, such as block letters, that you can paint in
but you can't paint in the surrounding area because the stencil
paper covers it up; a background mask similarly defines a shape in
a window that the PUT statement using AND and OR must use
when it lays down a graphics block.
You can create a mask by creating a shape in the output win
dow using the highest possible color register and then surrounding
it by background color. When you lay a graphics block over the
mask using the AND merge option, the mask will be filled with the
colors in the graphics block, and the surrounding area won't be
affected by the graphics block. A mask works much the same way
with OR, but instead of filling the mask with the graphics block, OR
leaves it alone and fills the surrounding area with the block instead.
You can see an example of masking m the program that follows
later in this chapter.
You can see the results of ail five merge choices in Figure 6-91ater
in this chapter.
167
SCREEN 1 , 320, 200 ,4,1
WINDOW 2, , , 0, 1
WIDTH }:
FDR l = 1 TD 3
FOR j = 0 TO 15
k = j + 1
IF k > 15 THEN k = 0
COLOR j , It
PRINT "Trinidad11;
NEXT j
NEXT i
LOCATE 16, 1
PAINTti ,170)
NEXT l
DIM blocfcS(802,4)
FOR i = 0 TO 4
GET(60 i,0) - {(60 i) + 59,49), blockX(O.i)
NEXT l
PUT(194,130) , block2(0 ,0 ) , OR
PUT(257,130), blockX{0,0>, XDR
SECTION 2: IMAGES
168
Figure 6-9.
a aUSOS EEtEJ *
GET and PUT
statements copy blocks
from one section of the
window to another sec
tion using the five merge
choices.
169
SECTION
Most people know that sound comes to your ears through the air.
After all, if you cover your ears with your hands, you can cut out a
lot of sound. It's also obvious that sound usually comes from a
variety of sources around you. In a room full of people talking, you
can usually tell which person is speaking (at least if you're close
enough). What most people don't know is how it all workswhy
some sounds are different than others, and how your ears interpret
each sound.
Sounds begin with a vibrating object like a gong, vocal cords,
or a plucked string. As the object vibrates forward, it pushes and
slightly compresses the air around it. As the object vibrates back, it
pulls back and rarefies (creates a slight vacuum in) the air. As it
continues vibrating, it creates more compressions and rarefactions
of the air. These pressure variations travel away from the object as
sound waves, as you can see in Figure 7-1. They spread through the
air much like ripples spread out from a rock thrown into a still pond,
and travel until they die out or hit another object (such as your ear).
SECTION 3: SOUNDS
174
Figure 7-1.
UJ ..
the ear.
Eardrum
Cochlea
175
The cochlea is a cavity in the bony part of the skull that's coiled
like a snail shell. It's filled with a liquid called perilymph, and
divided along its coiled length with a very sensitive membrane
called the basilar membrane. The amplified vibrations of the ear
drum pass on to the perilymph, which makes the basilar mem
brane vibrate. Nerve endings on the basilar membrane send the
sensations of vibration on to the brain, which analyzes them so you
can hear sound.
CHARACTERISTICS OF SOUND
When your brain analyzes sound, it can discern four main
characteristics of vibration. They are frequency, amplitude, timbre,
and duration. Using these four characteristics, you can describe
any sound you hear, or use them to provide the specifications for
creating a new sound.
Frequency
Frequency is the speed of vibration. When an object vibrates
slowly, it creates a low-frequency sound; when it vibrates quickly,
it creates a high-frequency sound. The frequency of a sound
determines its pitchthe higher the sounds frequency, the higher
the pitch.
As an example of different frequencies, think of plucking the
strings on a guitar. Because the thicker strings are heavier than the
thin strings, they vibrate more slowly and therefore sound lower in
pitch than the thin strings.
Frequency is measured in hertz, abbreviated Hz, a unit that
stands for cycles (vibrations) per second. The average range of
human hearing stretches from 20 Hz to 20,000 Hz.
Amplitude
Amplitude is the strength of vibration. When an object vibrates
with strong vibrations {that is. it vibrates back and forth over a
relatively large distance), it creates a sound of strong amplitude.
When it vibrates with weaker vibrations (vibrating back and forth
over a relatively small distance), it creates a sound of weaker
amplitude. The amplitude of a sound determines its volumethe
higher the amplitude, the louder the sound. As an example of
amplitude, think of the guitar strings in the previous example. If
you pluck them hard, they vibrate violently, creating a sound of
great amplitude. If you pluck them gently, they vibrate so little you
can barely see them move, making sounds of little amplitude.
The amplitude of a sound is measured in decibels. A decibel is
the smallest change in loudness that a human ear can detect.
Increasing a sound's amplitude by ten decibels makes the sound
double in loudness to the human ear. Human hearing ranges from
one decibel (the threshold of hearing) to somewhere over 120
decibels (the threshold of pain).
SECTION 3: SOUNDS
176
Timbre
Timbre (pronounced tam'-burr) is a little more complicated than
frequency and amplitude. It is a mixture of frequencies within a
single sound. Most vibrating objects don't vibrate at just one fre
quency they vibrate at several frequencies simultaneously. The
lowest frequency is called the fundamental, and it's the fundamental
that you hear as the main frequency of the sound. The fundamen
tal sets the pitch of the sound- The higher frequencies are called
overtones, and they blend in with the fundamental frequency to
change the tonal quality of the sound.
The timbre of a sound determines its tone color. The more
overtones present in the sound, the richer its timbre; the fewer
the overtones, the thinner its timbre. Timbre isn't measured in any
unit of measurement, although it is possible to analyze the number
of overtones present in a sound (a process called Fourier analysis)
to see how many overtones are present. Instead, most people use
words like "rich," "thin," "fat," or "buzzy" to describe timbre.
A good example of timbre is the difference between a violin and
a flute playing exactly the same note. Each instrument produces
sounds with an entirely different overtone series, so each has its
own distinct timbre, and won't be mistaken for the other.
Although Fourier analysis can show the individual overtones of a
sound, the most common way to show the timbre of a sound
visually is to use a waveform. A waveform is a record of the air
pressure of a sound wave over time that shows the summation of
sound's overtones. By looking at the shape of the cycles in the
waveform, you can see differences in timbre. In Figure 7-3, you can
see three basic wave shapes: the sine wave, the square wave, and
the sawtooth wave. The sine wave sounds gentle and smooth. The
square wave is rich and full, and the sawtooth wave is quite
piercing and colorful.
Figure 7-3.
Square wave
Sawtooth wave
177
Duration
Duration is used to measure the first three sound attributes:
frequency amplitude, and timbre. In its simplest use, duration
measures all three together, and so measures the length of the
entire sound from its first hearing to its last fadeout. In other cases,
duration measures each attribute individually, recording how it
changes over time. For example, a singer can hold out a note on
one pitch, but get louder and then fade away. Duration can
measure how long the amplitude increased and how long the
amplitude decreased. A trumpet player might play a long note on
the same pitch, but stick a mute in halfway through the note.
Duration could be used in this case to measure the length of the
first timbre before it was replaced by the muted timbre. If a
saxophone player squeaked at the beginning of a note, duration
could measure the time it took the squeak frequency to drop back
down to the frequency of the final note.
The graph of any of these three attributes over time defines
the envelope of that attribute. Envelopes are very important in
describing the quality of a sound. For example, a plucked harp
string has a sharp twang at the beginning that dies away as the
note lingers. Looking at the amplitude envelope of that note in
Figure 7-4 shows that the note immediately jumps to large
amplitude (loud), then slowly decreases its amplitude over time
(gets softer and fades away).
Figure 7-4.
Time
SECTION 3- SOUNDS
178
PRODUCING ELECTRONIC SOUNDS
THE SPEAKER
If you look at Figure 7-5, you can see a cutaway drawing of a
speaker. The vibrating part of the speaker, the part that produces
sound waves, is the speaker cone. A speaker cone is a conical
piece of stiff paper or plastic mounted m a circular metal frame.
The outer edge of the cone is suspended in the frame by very
flexible folds of rubber or rubber-like material so the cone can move
in and out easily within the metal frame.
Figure 7-5.
Flexible fold
A cutaway view of a
speaker.
Speaker cone
To amplifier
Metal frame
Flexible fold
179
When the amplifier sends an audio signal through the coil, it
creates a magnetic field in the coil that either attracts or repels the
magnetic field created by the fixed magnet. This pushes the coil
forward or backward, moving the speaker cone with it. The direc
tion and amount of the speaker-cone movement depends on the
strength of the magnetic field created by the audio signal going
through the coil. The stronger the field, the more the cone moves.
The audio signal coming from the amplifier changes the strength
of the field very rapidly, so the speaker cone vibrates quickly
enough to create sounds. As the audio signal changes in frequency,
amplitude, and overtones, the sound produced by the speaker
changes with it. A good speaker cone will accurately interpret
every nuance of change in the audio signal as a nuance in the
sound it creates.
In a good high-fidelity speaker, there are usually at least three
speaker cones, one for each of three different frequency ranges.
One speaker cone, appropriately called the woofer, produces low
sounds. The mid-range speaker cone produces mid-range frequen
cies, and the tweeter is a speaker cone that produces high pitches.
A system of filters, called the crossover network, separates the
audio signal from the amplifier into three separate signals of the
three different frequency ranges, which are sent out over separate
wires to each speaker cone. The result, if the speaker components
are of good quality, is excellent reproduction of all the frequencies in
the human hearing range.
THE AMPLIFIER
An audio signal from sources like cassette decks, turntables,
radio tuners, or the Amiga is too weak to drive a speaker by itself,
it needs amplification in order to be heard. An amplifier's job is to
take an audio signal from a weak source and boost its strength so
that it's strong enough to move the speaker cone in and out. Almost
all amplifiers have a volume knob so you can control how much the
signal is amplified; some amplifiers also have tone controls that
change the timbre of the incoming signal before it's amplified and
sent out to the speaker.
STEREO
Most people have a stereo home-audio system with two
speakers, one for the right of the listening area, the other for the
left of the listening area. These speakers convert two separate
audio signals (called the left and right channels) into two sound
sources that create the illusion of many different sources of sound
located throughout a room (a process called imaging).
SECTION 3: SOUNDS
180
To see how stereo imaging works, consider an example. A re
cording engineer records a woodwind trio spread across a stage;
the oboe on the left, the clarinet in the middle, and the bassoon
on the right. He uses two microphones to record, one for each
channel. The left microphone is close to the oboe and further from
the other instruments, and so records the left channel with a strong
oboe sound, a medium clarinet sound, and a weak bassoon sound.
The right microphone, close to the bassoon, records the right
channel with a strong bassoon sound, a medium clarinet sound,
and a weak oboe sound.
When you listen to the recording (facing the speakers with the
left-channel speaker on your left and the right-channel speaker on
your right), you hear a lot of oboe sound coming from the left
speaker and not much oboe sound coming from the right speaker,
so you perceive the oboe to be to your left. The clarinet sound
comes equally from both speakers, so you perceive the clarinet
coming from the center area between the two speakers. The
bassoon sound comes mostly from the right speaker, so you
perceive the bassoon to be on your right. Your stereo system uses
this same imaging technique to create the illusion of an entire
orchestra of instruments spread across your living room.
The Amiga has stereo outputs so you can connect it to a stereo
system, but its left and right channels are discretethat is, the left
signal goes entirely to the left speaker, and the right signal goes
entirely to the right speaker. These discrete signals don't allow
imaging, since there is no mixture of the sound coming from both
speakers. To blend the Amiga's sound signals through both left and
right channels to create imaging, you need an audio mixer,
described later in the chapter.
SYNTHESIZING MUSIC
181
SYNTHESIZERS
In concept, a synthesizer is simple. It sets the frequency, ampli
tude, and waveshape of an audio signal, and sends it as an un-
amplified audio waveform to the amplifier. The amplified waveform
is then sent to the speaker, where it is translated directly into sound
waves, audibly duplicating the original synthesized waveform. In
practice, sound synthesis isn't quite so simple. It takes a lot of work
to create an audio signal that's interesting to the human ear. The
first synthesizers to succeed were analog synthesizers, instruments
that are still popular today.
Analog synthesizers
Analog synthesizers use a series of electronic components first
to create a simple audio signal, then to twist, tickle, and torture the
signal into a much more complex and interesting form. The heart of
the analog synthesizer is the voltage-controlled oscillator, or VCO for
short. The VCO creates an audio signal from scratch in one of
several waveforms that you can choose. These waveforms are
usually quite simplesine waves, triangle waves, sawtooth waves,
square waves, and perhaps a few others.
The VCO changes pitch according to a control voltage, which
usually comes from a keyboard or a sequencer. For each different
note, the keyboard or sequencer sends a different control voltage to
change the pitch of the VCO. To make the sound more interesting,
the signal from the VCO can be passed through voltage-controlled
filters and voltage-controlled amplifiers that add attributes such as
overtones, duration, and amplitude to each note. The signal can be
enhanced even more by passing it through other synthesizer mod
ules; ring modulators, white noise generators, sample and hold
modules, high-pass filters, low-pass filters, band-pass filters, and
others. The effect of each module on the signal is different, but the
purpose of each is to change the original signal from a plain and
uninteresting sound to a rich and intriguing sound.
Digital synthesizers
The Amiga, like many other modern synthesizers, is a digital
synthesizer. Instead of producing a simple signal with an oscillator
and then enhancing it by passing it through other electronic equip
ment, a digital synthesizer creates a sound as a digital mathe
matical model, then turns the model into an audio signal that it
sends directly to the amplifier. With digital synthesizers, creating
new and unique sounds becomes as much a matter of mathematics
as it does electronics.
SECTION 3: SOUNDS
182
The Amiga makes its digital models fay creating the waveform of
a sound in its memory. To understand how it does this, think of
how a waveform depicts the quality of a sound. You read a wave
form like the one in Figure 7-6 from left to right. The waveform goes
up for higher air pressure, down for lower air pressure. This
corresponds directly with the motion of the speaker cone: Each
time the waveform goes above the horizontal center line, the
speaker cone moves out to create higher pressure. Each time the
waveform goes below the horizontal center line, the speaker cone
moves in to create lower pressure.
Figure 7-6.
A typical waveform.
As you read the waveform, you can see the entire record of the
speaker cone's motion from the beginning to the end of the sound.
The more waves there are in the waveform, the faster the cone
moves in and out. The higher and lower the waveform goes, the
more motion the cone goes through. By sending the waveform of a
sound as an amplified audio signal to a speaker, you can create that
entire sound.
To store a waveform in the Amigas memory, it has to be chopped
up into a series of numbers. A good way to think of it is to imagine
describing a waveform over the phone to another person. You can
chop the waveform up horizontally into tiny equal segments, shown
in Figure 7-7 (on the next page). By measuring the height of each
segment, you can pass the measurements on to the person at the
other end of the phone line, who can reconstruct the waveform if
you tell him the width of the segments you used.
183
Figure 7-7
A waveform chopped
into measured segments.
s
The amplitude measure A X \
\
HHILJllltfllll
Mdtruvr
line to another person
SECTION 3: SOUNDS
184
orchestra. That waveform has sound information for over a hundred
instruments simultaneously playing different pitches. If you play the
waveform back over a speaker, you can hear all the different pitches
played in the orchestra. A waveform table containing that same
orchestra] waveform and stored in one of the Amiga's internal audio
channels would create the same number of pitches when you
played it back.
In practice, getting more than four independent musical voices
on the Amiga at once is a complicated process. Using mathe
matical synthesis to create a multi-pitch waveform table on one
audio channel isn't as easy as creating a single-pitch waveform
table. Once you create the mathematical model of a multi-pitch
waveform table, the pitches in the waveform table are locked
together. When the audio channel speeds up or slows down its
playback rate to raise or lower the pitch, all the pitches are raised
or lowered together, so they aren't actually independent musical
voices. To change pitches independently within a multi-pitch audio
channel, the Amiga has to calculate a new waveform table for each
individual pitch change. This requires some tricky programming,
but it's not impossible, so look for software that can play eight or
even sixteen independent voices of music on the Amiga.
When you use your Amiga as a synthesizer, you don't have to
mathematically calculate your own waveform tables (although you
can, if you're an advanced programmer). Instead, you can use a
variety of methods offered by different Amiga synthesizer pro
grams. For example, some music programs use on-screen controls
that look very much like the controls of an analog synthesizer. Other
programs may use menus to change various aspects of sound, or
they may let you draw waveforms directly on the screen. No matter
what controls the program provides, they all change the mathe
matical formulas that create the waveform table inside the Amiga.
Sampled sounds
The Amiga and some other digital synthesizers can create
sounds without synthesizing them. Instead, they record the sounds
from the outside world, storing them in a waveform table as a
series of waveform measurements. These recorded sounds are
called sampled soundsthe measurement of each segment of the
waveform is called a sample, and the process of making those
measurements and storing the waveform as a series of numbers is
called sampling.
To create a sampled sound, you need to add a microphone and a
sampler to the Amiga. When the microphone picks up a sound, it
185
sends the waveform of the sound as an unamplified audio signal to
the sampler. The sampler chops the waveform up into approxi
mately 20.000 segments per second (the number of samples varies
with the sampling rate), takes a reading of the amplitude of each
segment, and sends each sample to the Amiga in the order it was
taken. This stream of samples is stored in the Amiga's memory as a
waveform table, and can be played back through an audio channel's
D-to-A converter just as a synthesized waveform is played back.
Sampled sounds are usually very rich, since they're recorded
directly from a very complex acoustic source. They do have a
drawback, though; they need a lot of RAM for storage, because
each individual sample is stored in memory, unlike a synthesized
waveform, which is stored as a formula. When you consider that
each sample of a sound needs one byte to store it in memory, and
that a sampler samples 20,000 segments per second, a sampled
sound of two seconds needs 40,000 bytes. This adds up quickly if
you use many sampled sounds at once in the Amiga. Synthesized
sounds, on the other hand, require a very small amount of memory.
Instead of storing the entire waveform table in memory as a series
of individual numbers, the Amiga stores only the mathematical
formula needed to create a synthesized sound. When you want to
play a synthesized sound, the Amiga recalls the formula and
creates the waveform from it.
Sampled sounds are inflexible if played back normally; the wave
form plays back at the same pitch, loudness, timbre, and length as
the original soundit's just a digitized recording of the sound.
Fortunately, the Amiga can alter the playback of a sampled sound
to use it musically. By increasing and decreasing the values of the
samples, it can change the loudness of the sound. By sending the
samples to the D-to-A converter at a slower or faster rate, it can
change the frequency of the sound.
To change the duration of the sampled sound, the Amiga must
repeat part of it over and over. It's important that the repeated
section sound smooth, so somebody has to listen to the sound
produced by a sampled-sound waveform to find the best section to
repeat (called the sustain loop). If the sustain loop is too near the
beginning of the waveform, you might hear the attack of the sound
over and over againthe "pick" of a guitar string or the biurble of
a trumpet notea very distracting effect. If the sustain loop is set
too near the end of the waveform, the sound may have died away to
nothing, so repeating it does no good.
Obviously, setting a sustain loop is a matter of judgment. The
sampled sounds you get with a program like Deluxe Music have
SECTION 3: SOUNDS
186
the sustain loop already picked out and recorded with the sound on
disk. To create your own sampled sounds, you'll need extra
software to go with the sampler and the microphone you use to
capture the sampled sounds. Once you have the sounds, you'll have
to use the software to look at their waveforms on the screen and
adjust the beginning and end of the sustain loop until you find the
best sound.
SEQUENCERS
A musical sequencer is a device that controls and plays a
musical instrument. For example, a player piano uses a roll of paper
containing holes to play the piano keys. Each hole on the roll cor
responds to one key pressed on the piano keyboard. An electronic
music sequencer works on similar principles; it stores notes elec
tronically and uses them to play music on a synthesizer. Early
sequencers were simple affairselectromechanical devices that
stored a sequence of pitches and nothing more. They played
perhaps 20 to 50 pitches on the synthesizer, all the same duration,
and then repeated them over and over again until the sequencer
was stopped.
Today's sequencers are much different. They use computers, and
they're no longer restricted to a small set of pitches. They can store
hundreds of thousands of pitches. They can also control durations
of notes and regulate other musical factors such as volume,
instrumentation, and timbre.
Sequencer programs on the Amiga can be very sophisticated.
You can enter notes into them using a traditional music staff or
a notation system designed especially for the program. The se
quencer software stores the notes as a sequence of events with
precise timing. The events can be items like the start of a note, the
end of a note, an instrument change, a volume change, and other
musical factors. When the sequencer plays back its score, it sends
these events to the Amiga's built-in synthesizer as control signals.
These control signals act like a phantom musician, starting and
stopping notes, and twiddling synthesizer "dials" to change the
tonal quality of the sounds.
The advantage of using a sequencer over playing a keyboard is
that the sequencer can perform music that no one human musician
could create. It can control more voices, play faster and more
complex music, and transpose to any key or change to any tempo
with a single command. The disadvantage is that no sequencer is
spontaneous. It has to be programmed beforehand, and can't react
to the mood around it, changing its performance to respond to
the audience.
187
SYNTHESIZING SPEECH
If you listen closely to yourself speaking, you can hear the small
elements of speechchanges in timbre when you change vowels
and consonants, and changes in pitch and volume as you speak
with inflection, accenting different syllables. By synthesizing a
waveform that includes all these quick and very subtle changes in
timbre, pitch, and volume, it's possible to make a synthesizer
speak.
The Amiga has a device in its system software that makes
speech synthesis easy. It takes text m strings of letters from
sources such as the keyboard or memory, and turns them into
waveforms that create speech instead of music when they're
converted into sound on an audio channel. The text to be
translated into speech is spelled out phonetically, using a special
computer phonetic spelling; that is, using a spelling like
"LAH5NCHWAE2GIN" for a word like "lunchwagon." (The Amiga's
phonetic spellings are discussed in Chapter 9, along with other
details of speech synthesis.)
Phonetic spelling gives you detailed control of word pronuncia
tion and syllable inflection, but it takes some time to translate
normal English words into the correct phonetic spelling. To make
things easier, the Amiga's system software also contains devices
that translate strings of English words into strings of phonetic
spellings to be turned into synthesized speech. When you consider
how many different pronunciations exist for some letters in English
(take the "o" in "women" for example), it's quite a feat to decide
which pronunciation should be used for a letter. The translation
devices in the Amiga's system software do it quite well.
The speech device can also alter the quality of the Amiga's
speaking voice. It can speak in a high or low voice to sound male
or female, and it can use different pitches to sing lyrics to a song. It
can speak with a lot of inflection or in a monotone. It can also
change the volume and the speed of the speech.
Playing music on the Amiga is great fun, but most people won't
get a chance to hear your creations unless you drag your Amiga
out in the streets or you invite large numbers of people over to
stand in your computer room. The best solution is to record your
music on tape. Anyone with a sound system is likely to own a
cassette player, so if you gave them a tape they can play back your
SECTION 3: SOUNDS
188
music. You can copy the tape and send it off to faraway relatives
and recording executives, and you can play it back to yourself in
your car tape deck as you drive.
Recording on tape has additional advantages: You can mix in
sounds from sources outside your Amiga. For example, if you enter
the accompaniment to "Ode to the Wombat" on the Amiga, you
can play it back while singing the words into a microphone, and
record the whole performance for posterity. You can also blend the
left and right audio channels of the Amiga together to image their
sounds, and use some tricks to record your Amiga playing with
your Amiga. All you need is the right equipment.
TAPE RECORDERS
The most important piece of equipment you'll need is a tape
recorder. The most common type is the cassette recorder, but you
can also use a reel-to-reel recorder or a videocassette recorder (hi-fi
VCRs have impressive audio recording capabilities}. Use a cassette
recorder if you want a tape medium that's easy to use and easy for
most people to play back. Consider a reel-to-reel recorder if you
plan to edit your recordingsreel-to-ree! recordings are much
easier to edit than cassette or video tapes.
Most tape recorders are stereo recorders: They use two discrete
tracks on the tape. Each track stores a different audio signal that
plays back to create the two signals needed for stereo sound
reproduction. Some tape recorders (usually reel-to-reel recorders)
have more than two tracks, ranging from 4 to 32 discrete tracks.
Each individual track can record a separate signal. Multi-track
recorders (the type used in recording studios) are used to record
one musical line per track so the volume and tonal quality of each
line can be adjusted individually when you play it back. Recording
one track at a time allows a single musician to create a tape of
himself playing different instruments simultaneously, so he ends up
performing an entire song by himself.
MIXERS
To feed many different audio signals into a tape recorder, you
need a mixer. Mixers can adjust the strength of each individual
audio signal to give you a good balance between them. For ex
ample, if you plan to record using a microphone and your Amiga,
you may find the microphone signal to be weaker than the signal
from the Amiga. A mixer will adjust for the differences in signal
strengths and can also help to create imaging effects in a stereo
recording. A mixer can take the two discrete sounds coming from
the left and right audio jacks of the Amiga and blend them across
the left and right channels of the recorder. A small knob called a
pan pot lets you position the apparent location of the sounds from
the Amiga-
189
SIMPLE RESULTS
If you just want to create a simple recording of your Amiga, you
don't need fancy equipment. One cassette recorder with two line-
level input jacks will work. (A line-ievel signal is an unamplified
audio signal.) The audio jacks on the back of the Amiga produce a
line-ievel output, which can be directly connected to the input
jacks of a cassette deck using two audio cables. All you need to do
is put a cassette in the recorder and start recording.
MIDI
SECTION 3; SOUNDS
190
MIDI connection to attached synthesizers. The computer used in
this type of arrangement is called a MIDI recorder, and is very
useful, since the MIDI events stored in memory are easy to modify.
191
Figure 7-8.
DDDDaDDCDDOn
nonaoaaaaoaa
n n a a n r; d n n a
oonaanacnoac
Figure 7-9.
devices.
SECTION 3: SOUNDS
192
MIDI MESSAGES
The signals that pass from machine to machine over the MIDI
cables are similar to the signals that pass from computer to com
puter when the computers are connected together with a modem.
Modem communication normally uses a type of code called ASCII
(American Standard Code for Information Interchange) that uses a
set of code numbers to represent letters of the alphabet, numerals,
punctuation marks, as well as computer information such as
carriage returns, line feeds, and other control characters.
MIDI also uses a set of code numbers, but instead of represent
ing letters and numbers, each one stands for different occurrences
on a synthesizer. These MIDI code numbers are strung together in
groups called messages. Typical MIDI messages communicate
events like note-on (that a keyboard key was pressed, what pitch it
was, and how hard the key was pressed), note-off (that a key was
released and what key it was), and that a pitch wheel was moved
(how far the pitch wheel, a device that bends pitch up or down,
was moved).
MIDI messages are sent over the cables in 16 different software-
controlled channels. Each channel carries messages for one MIDI
machine (you specify which machine uses which channel), so it's
possible to connect 16 different MIDI machines together on the
same MIDI network with each machine sending and receiving MIDI
messages on its own channel. Each MIDI channel can transmit all
the events happening on its synthesizer, so each channel can trans
mit a full performancechords, fancy fingerwork, instrument
changes, and all. A central computer controlling external syn
thesizers can use the separate channels to send messages to and
record events from individual synthesizers.
Now you know how sound is created, how you hear it,
and how it can be electronically produced. You've learned
how sound synthesis works, and how the Amiga can syn
thesize its own sounds and speech and re-create sam
pled sounds. You've also been introduced to MIDI, and
learned how to attach external synthesizers to the Amiga.
With the information you gained in this chapter, you're now
well equipped to go on to the next two sound chapters and
start making your own sounds, music, and computer-
generated speech.
193
CHAPTER EIGHT
AMIGA MUSIC
TOOLS
Today's equivalent of Johann Sebastian Bach ruining his
eyesight by poring over scores in candlelight is the modern
musician staring at his computer monitor in the wee hours
of the morning. Although the tools have changed, composi
tion is still a combination of inspiration, structuring,
recording, and struggling to bring the music to perfor
mance. The Amiga can't help you with the inspiration and
creative process, but it can relieve a lot of the drudgery
involved in writing your music and getting it played. In
this chapter, you'll learn some Amiga music techniques
that will enable you to spend more time listening to your
music and less time staring at your monitor.
A wide variety of music programs has been written for
the Amiga. Some programs record the notes of your music
in the Amiga's memory and play them back at your re
quest; others let you play on an attached keyboard or on
the Amiga's keyboard, using the Amiga as a musical instru
ment. There are also programs that let you create and mod
ify your own Amiga synthesized instruments. The program
featured in this chapter, Electronic Arts' Deluxe Music,
concentrates on storing notes and playing them back.
Deluxe Music lets you enter scores with traditional music
notation and play back your scores using the Amiga's
built-in synthesizer or an attached MIDI synthesizer.
This chapter teaches you advanced Deluxe Music tech
niques. You'll learn special methods for entering tempo
and instrument changes, using 64th notes, and working
with MIDI instruments. You'll also find some tips and hints
that make score entry easy. Later sections in the chapter
show you how to record your musical creations on tape,
and take you on a tour through other music software and
hardware available for the Amiga.
SECTION 3: SOUNDS
196
the mouse pointer on the keys of a music keyboard Deluxe Music
displays on the bottom of the screen. If you have a MIDI keyboard
connected to the Amiga, you can also enter pitches by pressing its
keyboard keys.
Deluxe Music's score-entry system is quite powerful- It provides
up to eight staffs of music on the screen at one time, and allows
you to choose treble, bass, alto, or tenor clefs for each of the staffs.
You can enter notes and rests that range from a whole note to a
32nd note, dot any note, and use the notes to create triplets or
quintuplets if you like. You can tie and slur groups of notes; put in
crescendos, diminuendos, and dynamic markings ranging from ppp
(very soft) to iff (very loud); and change time and key signatures
within the score-
Deluxe Music has powerful editing features that let you cut,
copy, and paste music much like a word processor works with text.
You can transpose groups of notes up and down in pitch. Deluxe
Music's features let you make the score more visually appealing,
both on the screen and on the printed copy. You can set the
direction of note stems and beam groups of 8th, 16th, and 32nd
notes together for clarity. (Beaming individual notes together, as
shown in Figure 8-1 on page 199, makes them easier for a musician
to read.) You can reposition the notes, rests, and staffs for maxi
mum clarity, and add text to the score for lyrics, tempo markings,
or directions to musicians. Deluxe Music has a special built-in
music font that contains music symbols like violin up and down
bow markings, trill markings, and other characters useful in a
music score. When the score looks just the way you want it, you
can print it out on an attached printer.
Deluxe Music plays back your scores using sampled sound
instruments that it loads from disk into the Amiga's memory. Once
the instruments are in memory, Deluxe Music plays them using the
Amiga's four internal audio channels. You can orchestrate your
score by making instrument changes at different locations in the
score. Using only the Amiga's four audio channels limits Deluxe
Music to a maximum of four notes played at once, but you can add
extra voices by attaching an external MIDI synthesizer. Deluxe
Music will use the external synthesizer's instruments in addition to
the Amiga's instruments (a very handy feature, considering that
Deluxe Music lets you enter a large number of simultaneous notes
on up to eight staffs).
197
STRETCHING DELUXE MUSIC'S CAPABILITIES
Many people use Deluxe Music to enter scores directly from
sheet music, copying the music note by note so they can hear the
Amiga play it back. It's a simple task to enter just the notes and
rests you see on the page. Unfortunately, music entered like this
often sounds mechanical or bland. Notes and rests are merely the
framework of musicthe real soul and expression come from the
musician's flexibility and spontaneity while playing each of those
notes back.
Deluxe Music offers several features that help to give your scores
style in playback: You can use crescendo and diminuendo along
with dynamic markings to make your music rise and fall expres
sively in volume. You can slur groups of notes together so they play
smoothly from note to note, or you can make notes staccato so
each one jumps out at you as an individual note. These features
are available on a note-by-note basis: You can start the effect at
any note in the score and end it on any other note in the score.
Deluxe Music has other features to add pizzazz to your playing
styie. For example, you can start playing a voice in the score using
one instrument and then change to another instrument to give it a
different timbresudden timbre changes can really perk up a
listener's ears. You can also change the tempo of the score playback
in the middle of the score; suddenly speeding up or slowing down
playback can also have a dramatic impact on a listener. Although
these two playing-style features are very useful, Deluxe Music
doesn't let you apply them on a note-by-note basis. You can only
start them at the beginning or end of a measure; you can't change
tempo or instruments in the middle of a measure.
Most music uses measures only as a timing reference, so the bar
lines in a score don't always fall at the precise point where you
want to change an instrument or the tempo. In fact, if you want to
use accelerando (where the tempo steadily increases over a group
of notes) or ritardando (where the tempo steadily decreases over a
group of notes), Deluxe Music's ability to jump to a new tempo at
every bar line won't give you the effect you want if you use ordinary
measures.
SECTION 3: SOUNDS
198
Fortunately Deluxe Music lets you create measures of almost
any size, so you can get around the measure limitations of tempo
and instrument changes to stretch Deluxe Musics capabilities. By
using some of the Measures menu commands like Insert Measure, Split
Measure, and Join Measure, and then setting a different time signa
ture for each measure, you can rearrange the bar lines in a score to
fall exactly where you want them to fall for changes. The next
section shows you how to take advantage of this feature.
Figure 8-1.
An example of ntardando
in two measures of
music.
1. Use the New Score command from the File menu to create a
new score.
3. Enter the notes as you see them in Figure 8-1: sixteen 16th
notes in the first measure and a whole note in the second
(last) measure.
4. Choose Score Setup from the Window menu and make sure the
Beats per Min slider is set to 90.
199
7. Use the Split Measure command from the Measures menu to
insert a new bar line at the location of the note-entry cursor,
splitting the first measure into two new measures, each with
eight 16th notes.
8. Use the editing arrow and the Split Measure command to split
the second new measure into four measures, each measure
with two 16th notes.
You should now have six measures in the score: the first measure
with eight 16th notes, measures two through five with two 16th
notes, and measure six with a whole note. To see all six measures
at once, use the editing arrow to drag the right boundary of each
measure to the left until all measures are visible on the screen.
If you play the score now, you'll hear the 16th notes play back
with long pauses where you inserted the new bar lines. This
happens because the measures are all 4/4 measures, and aren't
filled up. To tighten the rhythmic slack, you must change the time
signatures of the new measures:
3. Use the same method to set the sixth measures time signa
ture back to 4/4. Now each measure's time signature is set so
the measure's contents fill it up completely.
If you play back the score now, it sounds just like it did when you
first entered it. If it seems like you just did a lot of work for nothing,
keep in mind that you now have a lot of handy bar lines sprinkled
through the notes, so you're ready to add a ritardando:
SECTION 3: SOUNDS
200
1. Play back the score at different tempos by moving the Beats
per Min slider in the Score Setup window to find a slow tempo
that you want the ritardando to reach by the last measure.
For this example, 90 beats per minute works well for the
initial tempo, slowing down to 56 beats per minute by the
final whole note.
The final score should look like Figure 8-2. If you play back the
score now, you'll hear the ritardando as the tempo gets progres
sively slower toward the end of the score.
Figure 8-2.
duce a ritardando in
Deluxe Music.
201
If you use this method with two or more staffs, you should note
that whenever you split a measure in one staff. Deluxe Music splits
the corresponding measures in any other staffs of your score. If you
split the third measure of the first staff, for example, the third
measure in the other staffs will be split as well. To compensate for
this, you'll have to break up the notes in the other staffs to match
the measures you create for your ritardando. As an example, if you
had a second staff accompanying the music in the last example,
and the second staff had a whole note in the first measure, you'd
have to break up the whole note into a single half note and four
eighth notes to fit in the new measures, then tie them together to
make them sound like one note.
A rhythmic pattern is di
i h.
vided between many Bass Drum
alternating instruments.
Cymbal
Clave
Tom Drum
SECTION 3: SOUNDS
202
To try the two measures in Figure 8-3 in a Deluxe Music score,
follow these instructions:
1. Create a new score. Open the Score Setup window and add
three staffs to the score. This will give you a total of five
staffs for the five different instruments in the music. Set the
score to C major in 4/4 time.
2. Load from disk the instruments for the score. You need five
instruments: a bass drum, a snare drum, a cymbal, a clave,
and a torn drum. {If you don't have these instruments, you
can approximate with five other instruments you think might
sound similar.) To load them, choose the Load Instrument...
command from the Sounds menu five times, selecting a dif
ferent instrument each time so the five instruments appear at
the top of the Sounds menu.
3. To assign the snare drum to the first staff, select the first
measure of the staff, choose the snare drum from the Sounds
menu, then choose Set Instrument from the Measures menu. The
name of the instrument should appear just above the begin
ning of the first measure.
4. Use the same method to assign the bass drum to the first
measure of the second staff, the cymbal to the first measure
of the third staff, the clave to the first measure of the fourth
staff, and the torn drum to the first measure of the fifth staff,
5. To enter the snare drum notes, select the first measure of the
snare drum staff, then enter all the snare drum notes, filling
in with rests where there are notes in the music that will be
played by other instruments.
When you play back your score, you should hear a full rhythm
section that uses only one Amiga voice for each note. If you want
to add more voices to the score, you can add three more staffs and
enter a part using a different instrument in each of the staffs. For
example, you could have a lead guitar line in the sixth staff, a sax
line in the seventh staff, and a piano line in the eighth staff.
203
As you enter notes for these new voices (or for that matter any
score with four voices), be careful where you use chords. You can
use up the Amiga's voices quickly, and this may leave some notes
unplayed. For example, if you put a three-note chord in the piano
voice at the same moment that the other three voices are playing
notes, you have a total of six simultaneous notes- Since Deluxe
Music can play only four of those notes on the Amiga, two of the
notes won't be played.
To make sure important instruments are played in case of too
many simultaneous notes in a score, you can use a louder dynamic
marking for the staff you want to be heard. Deluxe Music will
always play the notes in a staff set with a higher dynamic before it
plays notes in a staff set to a lower dynamic. For example, if you
have five different staffs playing notes at the same time, and the
staffs are set at pp, mp, mf, f, and ff, then Deluxe Music will play
only the notes on the four loudest staffs; it won't play the notes in
the staff set at pp. By setting one staff slightly louder than the
others, at f, for instance, while all the others are set at mf, you can
ensure that staff will always be heard, even if it isn't significantly
louder than the other staffs.
SECTION 3: SOUNDS
204
fourth second. The note durations are entirely flexible, and depend
on the tempo at which you play the music. The relative lengths of
the notes are fixed, however: A quarter note is always twice as
long as an eight note, a half note is always twice as long as a
quarter note, and so on.
As you enter music using different note lengths, you aren't
actually entering a series of time durations, you're entering a series
of relative lengthsthis note is twice as long as this one, this note
is a third as long as this one-and so on throughout the whole
score. It doesn't actually matter what notes you use, the only thing
that matters is how long the notes are in relation to each other.
When you want to copy a run of 64th notes from printed music,
you won't be able to find notes in Deluxe Musics note palette that
are half as long as the 32nd notes in the score. You can make the
proportions work out, however, by making all the other notes in the
score twice as long and then entering the run as 32nd notes. Try
this example:
2. Enter the notes of the music in Figure 8-4 until you reach the
64th notes at the end of the second measure.
Figure 8-4.
205
4. To accommodate the new note lengths, you'll have to double
the time signature of the measures. Select the first measure
of the score, then reset the time signature to 6/4 time using
the Set Time Signature... command in the Measures menu.
5. Enter the 64th notes as 32nd notes at the end of the last
measure. If you play back the score now, all the notes will
have the same relative length to each other, but the note
values themselves have been doubled, so the playback tempo
is half as fast as it was previously.
Now when you play back the score, it sounds just like it would
if you had entered it the way it was wiitten and played it at the
original tempo. You have entered the score using 32nd notes to
produce the rhythm that was originally written in 64th notes.
If you go on to enter more notes in a score in which you've
doubled the tempo, be sure to double all the note and rest lengths
as you enter them from the printed score. As a shortcut, you can
enter the notes and rests as they are written, then select them and
double them with the Double Time command.
Whenever you use this method while entering scores, be sure to
double the time signature of all the measures in the score. If you
have time-signature changes within the score, doubling just the
first time signature won't affect the measures with the time-
signature changes, so you have to double each changed measure
individually. To double a time signature, it's easiest just to halve the
number at the bottom of the time signature. For example, 4/4 time
doubled is 4/2, 3/8 doubled is 3/4. If you can't halve the bottom
number, then you can double the top number. For example, 3/1
doubled is 6/1.
SECTION 3: SOUNDS
206
To use one or several MIDI synthesizers with Deluxe Music,
you must first connect them to the Amiga with a MIDI adaptor.
Connect the first (or only) synthesizer by running a MIDI cable from
its MIDI Out port to the MIDI adaptor's MIDI In port, and running
another cable from the adaptor's MIDI Out port to the synthesizer's
MIDI In port. To connect additional synthesizers, run a cable from
the first synthesizer's MIDI Thru port to the second synthesizer's
MIDI In port, another cable from the second synthesizers MIDI Thru
port to the third synthesizer's MIDI In port, and so on until you have
all the synthesizers connected. Examples of these connections,
along with a more detailed explanation of MIDI, can be found at the
end of Chapter 7.
You must set up each synthesizer so it receives MIDI messages
on its own MIDI channel (unless you use just one synthesizer). You'll
have to do some reading through the synthesizers' users manuals
to see how to set the incoming MIDI channel. If you can't set a
synthesizer's incoming MIDI channel, chances are the synthesizer
receives messages on MIDI channel 1.
Once you have the connections made, you can turn on the
synthesizers and use them with Deluxe Music. If you want to play
part of the score through the synthesizer, first set up MIDI using
commands in the Sounds menu:
1. Choose the MIDI Active command to load the MIDI driver from
the Deluxe Music disk into the Amiga's memory.
207
Now that the MIDI connection is set up for the specific sound
you want on a specific synthesizer, you put the setting in your
score the same way you choose an instrument:
SECTION 3: SOUNDS
208
Use keyboard shortcuts
Since the note palette is displayed on the screen in plain sight,
it's easy to forget that you often don't need to use it. Deluxe Music
lets you use keyboard shortcuts instead to choose the length of
note you want to enter in a score. Read about the shortcuts in the
manual and use them! They make life much easier. As musical
inspiration is flowing through your head and you're getting into the
swing of entering a melody on a staff, it's much easier to quickly
press a function key with your non-mouse hand to choose a new
note value than it is to move the pointer all the way to the side of
the screen, select a new note, and then try to find your staff
location and inspiration a second time.
209
adjust the volume to the maximum level your recorder can
handle without distorting. Stop the score playback when
you're finished.
SECTION 3: SOUNDS
210
BeethovenA in stereo on tracks 1 and 2. When you're finished, you
can rewind the tape and start recording BeethovenB alongside
BeethovenA on tracks 3 and 4. When you play back the recording,
you can hear both scores playing together simultaneously in the full
eight-voice composition.
The Porta One also offers overdubbmg: This means that you
can mix the contents of any tape track already recorded with the
contents of another recorded track and record the mixture to a third
track, or you can mix one track with a new signal coming in, and
record the combination to a second track. In theory, this means
that you can keep overdubbmg to add an infinite number of voices
to the recording. For example, you can use overdubbmg with your
Amiga to create a recording of all of the 50 or so voices you'd need
to recreate Stravinsky's "Rite of Spring" accurately. In practice,
each overdub deteriorates the quality of the recording a little, so too
many levels of overdubs can make the recording sound hissy and
indistinct. The Porta One has an excellent noise-reduction system
that lets you perform several levels of dubs, though, enough to
record over 40 Amiga voices without too much distortion.
211
the beginning of the music in the score. You can synchronize a
second score to this by starting the second score at the exact spot
where you think the ninth snare drum beat would fall: The two
scores should start simultaneously. This takes some practice and
attentive Listening to get it just right, but if you're recording the
results, the tape recorder won't mind if you stop and start over
again when you miss the beat.
INSTANT MUSIC
Instant Music is a simple but enjoyable music program from
Electronic Arts. It's perfect for music dabblers. You can enter scores
up to 64 measures long on Instant Music using sampled sound
instruments included on the disk, and can play them back at dif
ferent speeds. Instead of using traditional notation, the scores are
laid out as a graph of pitch and time, which can be a real advan
tage if you don't read music as you can simply draw in voices on
the graph using the mouse and the pointer.
Instant Music also lets you perform music with a feature called
"mousejam." Using mousejam, instant Music plays higher and
lower pitches as you move the mouse pointer up and down. You
can play a score and use mousejam as accompaniment. You can
also limit the notes and rhythms you play with mousejam so that
no matter where you move the pointer, the notes you play will
sound good with the accompanying score.
SOUNDSCAPE
SoundScape is a music program from Mimetics Corporation that
is actually a lot of programs in one package. It can perform a range
of music tasks that make it useful to many different kinds of users,
including neophyte musicians who want to play their Amiga as a
SECTION 3: SOUNDS
212
musical instrument, advanced musicians who want to tie banks
of synthesizers together to create sophisticated music, and ad
vanced programmers who want an easy way to add music to
their programs.
The heart of SoundScape is a music operating system that
specializes in handling music data and running music programs.
When you first load SoundScape, the music operating system
integrates itself with the Amiga operating system so they work
together simultaneously. The music operating system contains
many routines to create and play scores, handle waveform tables,
and create music much like the Amiga operating system's devices
and libraries take care of graphics, text, math operations, and other
functions. These routines make full use of the sound software in the
Amiga's operating system.
Advanced programmers can use SoundScape's music operating
system as an extended version of the Amiga's operating system to
create music without doing all the programming themselves. Since
SoundScape's music routines run simultaneously with other Amiga
programs, a programmer creating an education application, for ex
ample, can feed SoundScape some simple information about the
music that he wants in his program, and SoundScape will play
the music in the background while the education program runs.
For non-programmers, SoundScape comes with its own pro
grams that use the music operating system. When you first load
SoundScape, the music operating system is loaded, then several
windows open on the monitor screen. Each window contains its
own program. These programs all run simultaneously, and they
work together so you can create some impressive music with them.
One of the simplest SoundScape programs lets you play the
Amiga's keyboard like a musical instrument. Another simple pro
gram is a MIDI clock, a fancy sort of metronome that ticks out time
in different tempos and subdivisions so that MIDI instruments
and programs connected to it are synchronized by its signals.
Another very useful and enjoyable SoundScape program is the
sampled sound editor. It lets you alter sampled sound instruments
from the Mimetics SoundScape sound sampler (discussed later in
this chapter) or from other programs like Instant Music or Deluxe
Music. You can use the editor to select which portion of the sound
to use as the sustain loop, set the amplitude envelope of the
instrument, and transpose the sound to new octaves, among other
things. When you're finished, the editor saves the new or revised
sampled sound instruments to disk so you can use them with the
other SoundScape programs or other music application programs.
213
The most extensive of SoundScape's programs is the MIDI
recorder. It records notes and other performance events played on
synthesizers attached to the Amiga through a MIDI adaptor or on
the Amiga's own keyboard. The recorder has an unlimited number
of tracks in its memory. You can record music on each track, and
later mix the notes on individual tracks together on one track, or
play back any combination of tracks through the MIDI adaptor or
the Amiga's own audio channels. The MIDI recorder can receive or
transmit on 16 different MIDI channels, so you can use it to record
and control up to 16 MIDI devices at a time. The MIDI recorder also
includes an editor that lets you look at the information recorded on
any track, change it to correct any mistakes you made while
playing the music, or add new notes.
Another SoundScape program, the mixing panel, controls all
the other programs that run with it. It lets you connect any of the
other SoundScape programs and MIDI channels with any other
SoundScape program or MIDI channel. This gives you a wide range
of possibilities. For example, you can use the Amiga's keyboard to
record your performance on the MIDI recorder. Or you can connect
the MIDI In signals to the Amiga itself so you can play the sampled
sound instruments stored in the Amiga using the keyboard of an
attached synthesizer. The possibilities offered by the mixing panel
are numerous enough to keep you occupied for months at least, and
when you consider that the modular nature of SoundScape makes it
easy to add other programs to it, the possibilities become limitless.
SECTION 3: SOUNDS
214
ADDITIONAL SOUND HARDWARE FOR THE AMIGA
SPEAKERS
The speaker in most computer monitors is no better than the
tiny (and tinny) speaker in the average television set. If you've ever
listened to the garbled sound of music coming from an average TV
set, then you know why it pays to add some high-fidelity speakers
to your Amiga system if you plan to use it for any kind of music at
all and want to take advantage of its superior multi-voice sound
capabilities.
215
After the connection is made, turn on the power to both
systems, load your music program, then play a score. Turn up the
volume of the stereo system slowly. If the speakers blare out when
you've barely cracked the volume, then you know the Amiga's
signal is too strong. Repeat the connection process and try another
pair of inputs.
Self-powered speakers
If you don't have a stereo system you want to use with your
Amiga, you might consider buying a pair of self-powered speakers
that contain their own amplifiers. Self-powered speakers don't have
to be part of a larger sound systemyou just hook them up
directly to the Amiga's audio ports and turn them on. Most self-
powered speakers are also small, and can fit on your desk on each
side of the Amiga for good stereo separation.
The most common type of self-powered speakers are the small
speakers designed to work with very small, portable cassette
players. Unfortunately, most of these speakers won't work with the
Amiga because they're designed to use the signal from the head
phone jack of the cassette player, which has already been ampli
fied by the player so that it's stronger than a line-level signal.
Speakers designed to use just a headphone signal don't have
enough amplification power to work well with the Amiga.
Some self-powered speakers are designed to work with syn
thesizers. They use a line-level input, have plenty of amplification,
and usually have good sound. A good example of this kind of
speaker is the Casio AS-20 speaker. It has a built-in graphic
equalizer and chorus knobs that let you jazz up the sound, a
headphone jack, and two separate inputs.
SECTION 3: SOUNDS
216
Portable cassette players
Another way to get good sound from your Amiga is to use a
battery-powered portable cassette player with an amplifier and
stereo speakers built in. Many of these players have jacks for a line-
level input where you can plug in the Amiga. Portable cassette
players have an added advantage: You can also use them to record
your Amiga music.
SOUND SAMPLERS
Some of the best-sounding instruments in the music application
software mentioned here are sampled sound instruments. They
were created with a sound sampler (sometimes called an audio
digitizer), a device that converts analog signals from a microphone,
tape deck, or other sound source into a digital waveform table.
If you want to create your own sampled sound instruments, you
can buy a sound sampler and start collecting sounds. Several are
made to work with the Amiga. Some have their own built-in
microphones; some take stereo sound samples. One important
feature to look for is accompanying software that defines your
sound samples and saves them to disk as sampled sound
instruments.
One of the best (and most inexpensive) samplers available is the
SoundScape sound sampler from Mimetics Corporation. It's a small
stereo sampler that plugs into the second joystick port of the
Amiga, which is an advantage over sound samplers that plug into
the Amiga's expansion connector and block it so you can't add
other peripherals without removing the sampler. It doesn't have a
built-in microphone, but has a microphone jack and a set of stereo
line-level jacks so that you can use your own microphone or other
sound source.
The SoundScape sound sampler comes with software that lets
you create a waveform table with the sampler, edit it, and then save
it to disk. It uses the same sampled sound editor included with the
SoundScape program described in the software section of this
chapter. The software also lets you control the Amiga via a MIDI
adaptor so you can play the Amiga and its sampled sounds with an
attached external synthesizer.
217
THE MIDI ADAPTOR
As you recall from the last chapter, MIDI is a synthesizer industry
standard that lets synthesizers exchange music information. To
change the signals coming from the Amiga to a MIDI signal, you
need to attach a MIDI adaptor to the serial port. Several companies
market MIDI adaptors for the Amiga.
Any MIDI adaptor you get should plug directly into the Amiga
serial port and should have all three MIDI connections on it: MIDI In,
MIDI Out, and MIDI Thru. Watch for bargains: Some software
companies may include a MIDI adaptor with their MIDI programs,
others may have a great price on the MIDI adaptor alone.
SECTION 3: SOUNDS
218
In the special mode, the CZ-101 lets you choose four different
instruments from its memory, one for each of four MIDI channels.
Each instrument is monophonicthat is, it only plays back one
note at a time. It can't play back chords. To use the special mode,
an Amiga MIDI recorder can send signals through the four different
channels to play a four-part score using four individual instruments.
(Since all 16 MIDI channels come through a single cable, you only
need a single MIDI In connection-) Most synthesizers don't let you
use more than one instrument at a time, so you gain guite a bit of
versatility using the CZ-101.
219
CHAPTER NINE
AMIGA BASIC
SOUND: MUSIC AND
SPEECH
Amiga BASIC doesn't have nearly as many statements
and functions that deal with sound as statements and
functions that deal with graphics: There are a total of six
sound statements if you count BEEP (which many people
don't), and one sound function. But don't let their numbers
fool you. Amiga BASIC sound statements are powerful, and
capable of a wide variety of effects.
This chapter deals with two kinds of sound statements:
statements that create music and sound effects, and state
ments (well, actually a statement and a function) that
create speech. In addition to explaining how these state
ments work, this chapter also shows you how to use the
statements in larger programs, and how to create musical
scales and play back musical scores.
BEEP
SECTION 3: SOUNDS
222
THE SOUND STATEMENT
223
26163 cps. The A above that is A4, the note that orchestras use to
tune. Musicians know it as A440, so it's not surprising that its
frequency is 440 cps.
Figure 9-1
Pitch Frequency Pitch Frequency Pitch Frequency
SECTION 3: SOUNDS
224
If you double the frequency of a pitch, you get a pitch one octave
higher. If you halve the frequency, you get a pitch one octave lower.
For example, if you double A4's frequency of 440 cps, you get 880
cps, which is A5, an A one octave higher. 220 cps, half of 440 cps, is
A3, an A one octave lower than An.
Figure 9-1 gives you a list of the pitches SOUND can create,
followed by their frequencies. This list of pitches is a tempered
scale, a standard used by most musicians, and is tuned so that A4
is at 440 cps.
To be able to hear all these pitches, you need to connect your
Amiga to a good audio system. If you use only the Amiga's monitor
speaker to produce sounds, you probably won't be able to hear any
pitches under 100 cps or over 8000 cps unless you change the
waveform of the pitch with the WAVE statement (discussed later in
this chapter).
If you figure out the length in seconds of the note you want to
sound, you can multiply it by 18.2 to come up with the duration
value to use in the SOUND statement. For example, a^-second
sound would use 9.1 as its duration value. To make a sound last
longer than 4.23 seconds, you can use two or more SOUND state
ments with the same pitch, volume, and audio channel values,
one after the other. They will run together to create one long note.
For example, these two statements play one F4 that lasts for seven
seconds:
225
SETTING THE VOLUME
Choosing a SOUND volume is a simple matter of choosing a
number from 0 to 255. If you choose 0, you won't be able to hear the
note you set, so it doesn't matter what frequency you specified. The
silence will last as long as the duration you set, so you can use 0
volume to create a rest. For example, the middle SOUND statement
below puts a /?.-second rest in between two surrounding notes that
play at full volume:
You can use volume values between 0 and 255 to play a note
at different volumes. Just remember that the volume you set is
affected by the volume control on your monitor or stereo system.
If you turn the volume control down to half of its previous volume,
all the notes created with the SOUND statement will be halved
in volume.
SECTION 3: SOUNDS
226
on that channel. You can change the waveform with the WAVE
statement, discussed later in this chapter. If you set different
waveforms for each of the audio channels, then you can choose the
timbre of the note a SOUND statement plays by specifying the audio
channel with the waveform you want.
SYNCHRONIZING SOUNDS
SOUND WAIT
227
through the speakers. The queues are cleared as the stored notes
are played. The format of SOUND RESUME is simply:
SOUND RESUME
To see how SOUND WAIT and SOUND RESUME work, try the
following program. It creates five notes for each of three audio
channels: channel 0, channel 1, and channel 2. There is a loop just
after the SOUND statements for channel 1 that extends the length of
time the program takes to get to the channel 2 SOUND statements.
This makes it easy to hear a time lag between voices. There is also
an infinite loop at the end of the program to keep the List window
from appearing. If a window appears while notes are playing, it can
delay one of the audio channels and ruin the synchronization of the
four voices.
First enter and run this program without typing in the SOUND
WAIT and SOUND RESUME statements shown:
SOUND WAIT
SOUND RESUME
SECTION 3: SOUNDS
228
THE WAVE STATEMENT
You can use the WAVE statement to create a new waveform table
for each of the four audio channels. Changing a channel's waveform
table changes the timbre of any sound played through that channel.
WAVE uses this format:
DIM formX(255)
The next step is to fill the elements of the array with waveform
table data. Each of the 256 elements in the array must be an integer
between -128 to 127, inclusive. The array elements in order from
lowest to highest describe the shape of a waveform from left to
right in a waveform graph. To get an idea of how this works, look
at Figure 9-2 on the next page. It depicts a waveform on a graph,
and then shows the first section of the waveform magnified, with
the first 6 waveform table values plotted. These first 6 values go
into the first 6 elements of the integer array, followed by the next
250 elements needed to describe the full waveform.
229
Figure 9-2.
+ 127-r
waveform, showing an
enlargement of the be
ginning of the waveform
and the first six wave
form table values
-128-1-
SECTION 3: SOUNDS
230
The following statements show a FOR,. .NEXT loop that runs 256
times and reads a waveform value into the lorm.% array each time.
The DATA statements following the loop contain the waveform data,
but not all the DATA statements are shown here (you don't really
want to read 256 values, do you?):
DIM formX(2S5)
FOR i M TO 255
READ formX(1)
NEXT i
DATA -112, -112, -111, -110, -108, -105, -103, -94 , -83 etc .
DIM formX(2SS)
FDR i = 0 TD 2S5
formX(i) =127-i
NEXT i
This short loop would create the waveform you see in Figure 9-3 if
form% is applied using a WAVE statement.
A sawtooth waveform
can be created with a
simple formula.
231
Here are some other simple formulas and program steps that will
create more simple waveforms with distinct timbres. Just put them
m the same loop shown above, replacing the sawtooth formula with
the formula you want- You can see the waves created by the
formulas in Figure 9-4, except for the random waveform, which
turns out a different waveform each time you use it.
A square waveform;
A triangle waveform:
IF l < 128 THEN formX(i) - (2*i) - 128 ELSE formX(i) - 383 -(2*i
A notch waveform:
A random waveform:
Figure 9-4.
128- 128 J
Square waveform Triangle waveform Notch waveform
SECTION 3: SOUNDS
232
in a WAVE statement. To hear the waveform, you can use a SOUND
statement to play a note using the same audio channel. The fol
lowing short program creates a notch waveform in channel 0, then
plays an A,, for one second at full volume in channel 0 so you can
hear the waveform:
DIM formX(255)
FDR i - 0 TD 255
WAVE 0, form*
DIM pitch(118)
halfstep* = 2#A(1#/12#)
f requency# = 13.75
FDR i = 1 TO 8
FDR i = 4 TO 116
pitch(i) frequency^
NEXT i
FDR i = 4 TO 116
233
Chances are you won't hear all the pitches when you run the
program, since some of them are beyond the range of the monitor
speaker, and the default sine waveform that plays the notes is hard
to hear in the low range. If you assign a notch waveform to channel
0 with a WAVE statement at the beginning of this program, you
should be able to hear the low notes much better.
Crucial to this program is the fact that if you multiply a
frequency by the 12th root of 2 (which is 2 A (1/12) in Amiga BASIC),
the resulting frequency is one half step higher than the original
frequency The variable halfstep# is set to the 12th root of 2 in the
second line of the program, and is used in lines 5 and 8 as a
multiplier to create half step increases in frequency. The program
starts with a base frequency of 13.75, one octave below Ag, to tune
the entire scale at 440 cps for A4 (13.75 is 440 divided by 2 five
times, and is therefore five octaves below A440recall that halving
a frequency lowers it by one octave). The variable frequency^
holds the current frequency values. These two variables are both
double-precision variables (specified by the "#") and use double-
precision constants in their calculations to ensure accuracy of
intonation over many different multiplications.
The first loop in the program multiplies frequency^ by halfstep#
to create eight half step pitches, but doesn't store them in the pitch
array, since they're all below 20 cps, and cannot be used in the
SOUND statement. The next loop, which steps from 4 to 116, con
tinues multiplying frequency^ by halfstep# to create new half-step
frequencies, starting where the last loop left off. It stores them in
the successive elements of the array pitch, starting at element 4,
the lowest pitch, and ending with element 116, the highest pitch.
The series starts at 4 because the lowest pitch in the array is Eo,
which is the lowest pitch possible in Amiga BASIC. By numbering
this pitch 4, all the following C's, which begin each octave of
pitches, are numbered as multiples of 12. This makes it easier to
remember the elements of the pitch array, as you'll see later.
The last loop at the end of the program plays the pitches stored
in the array, stepping through pitches from pitch(4) to pitch(W).
To determine which pitch in an array to use in a SOUND state
ment, multiply the octave number of the pitch you want by 12, then
add a number from this chart for each different pitch:
Figure 9-5.
c 0 FC or Gb 6
Cfl or Db 1 G 7
Traditional music
D 2 GS or Ab 8
notation showing the
DC or Eb 3 A 9
positions of notes and
E 4 Atf or Bb 10
their names
F 5 B 11
SECTION 3: SOUNDS
234
For example, A^ would be pitch element number 57 (4 times 12,
plus 9). To play an A4 for one second, you would use:
SDUND WAIT
FOR l = 0 TO 3
SDUND 30, 5, , i
NEXT i
SDUND RESUME
Loop :
FDR i = 0 TO 3
GOTO Loop
(continued)
235
KlllTlmei
MusicDa ta:
SECTION 3: SOUNDS
236
If it's not the end of the score, the next line of the FOR.. .NEXT
loop multiplies the octave value by 12 and adds the scale pitch
value to come up with the correct element of the pitch array which
it uses as the frequency in the SOUND statement. The notes dura
tion is set by dividing a set value, arbitrarily set here at 32, by the
duration value that is read from the DATA statement. The note's
volume is set by using the volume value that is read directly from
the DATA statement.
After four passes (once for each audio channel), the FOR.. .NEXT
loop ends, and the Loop: loop repeats, running the FOR., .NEXT loop
again and again until it encounters the - l's read from the DATA
statements. When it does, the program goes to KBTime:, and a
short FOR.. .NEXT loop there kills a little time before the program
ends so the List window doesn't appear too soon. If the list win
dow appears while the music is playing, it makes the notes falter
The note data in the DATA statements are organized so you have
four notes in each DATA line, one for each voice, in voice order 0,1,
2, and 3. Each note has four valuespitch, octave, duration, and
volume. The pitch is an integer from 0 to 11 that corresponds to a
pitch name; A, F, Eb, etc.. as discussed earlier in the section on
pitch arrays. The octave is an integer from 0 to 9 corresponding to
the octave subscript that usually foDows a pitch name.
The duration is a value corresponding to the length of note you
want played: 1 for a whole note, 2 for a half note, 4 for a quarter
note, 8 for an eighth note, 16 for a sixteenth note, etc. These values
don't set a specific length of time by themselves: They are used by
the SOUND statement to divide a number (in this example 32) that
sets the duration of a whole note. By changing this number, you
actually change the speed of the music, because all the duration
values in the DATA statements are divided into this number to
determine each note's length. For example, change the 32 in the
SOUND statement to 64 and run the program again, and you'll hear
the flourish played at half the previous speed. If you change it to
16, you'll hear it played twice as fast.
The last value for each note is volume, which sets the volume in
the SOUND statement.
Each DATA statement contains four notes, one for each voice.
Within each DATA statement, each note's data is separated from the
next note's data by a space, so you can easily distinguish the four
notes on each line. Voice 0 is the group immediately following the
word DATA on each line. Note that the duration value for voice 0's
data on each line is 16, which indicates sixteenth notes. Voices 1, 2,
and 3 all play quarter notes (as indicated by the 4 for their duration
values), and only require the first three DATA statements
237
to hold their note data. Because voice 0 has more individual notes
than the other three voices, the values in the remaining DATA
statements for the other voices become 0, 0, 16, 0, effectively
making a rest that's a sixteenth note in length to hold a place for
those voices so voice 0 can continue to read its data. (If you specify
a duration of 0, the program will try to use the value to divide with,
and you'll get a division-by-zero error.)
At the end of the DATA axe four - l's to signify the end of the
score. You have to have four - l's because the program reads data
in chunks of four.
If you use this system of READ and DATA statements to store
notes, you can create new and longer scores just by using different
data in the DATA statements. If you precede the program with
WAVE statements to change the timbre of the different audio
channels, you can give each voice its own unique timbre to play
the notes. Experiment, and have fun!
GENERATING SPEECH
SECTION 3: SOUNDS
238
THE TRANSLATE$() FUNCTION
TRANSLATEt("text at ring")
The text string can be any string of characters that's legal to use
in Amiga BASIC, or a string variable representing the text to be
spoken. A text string must be specified using quotation marks
within parentheses; a string variable requires only parentheses.
Since TRANSLATES)) is a function, it doesn't do anything by
itself. The string of phoneme codes it returns should be assigned to
a string variable, used directly with the SAY statement or printed
out using a PRINT statement. Using TRANSLATES!) directly with
SAY is very convenient. For example,
prints out the phoneme code that SAY used in the last example:
239
USING PUNCTUATION
When you use English strings with TRANSLATESQ, you can use
punctuation marks to alter the inflection of the spoken text. They
affect speech inflection as follows:
SECTION 3: SOUNDS
240
create the words with the phoneme codes, but you might find it
easier to try some creative misspelling with the TRANSLATE${)
function instead.
For example, TRANSLATE$() has trouble with the name Michael,
which it pronounces more like "Mitch ay ell." A simple misspelling
will correct the pronunciation. Try both of these SAY statements to
hear the difference:
SAY TRANSLATE$("Michael")
SAY TRANSLATEM'Tiykul")
You use the SAY statement to tell the Amiga what to say and
how to say it. SAY uses this format:
PHONEME CODES
English is a tricky language to spell and pronounce. The same
letter in two different words can be pronounced two different ways,
as you can hear by listening to the "c" in "cycle" and the "c" in
"call." To accurately tell SAY what you want it to pronounce, you
must break up the words into separate sounds, called phonemes,
and use the Amiga's phoneme codes to spell out each phoneme.
The easiest way to do this is to let the TRANSLATES*) function do
the work for you. However, since TRANSLATES!) doesn't always
interpret words correctly and its pronunciation rules are limited
241
to the English language, you may want to use phonetic spellings in
place of the TRANSLATES*) function to make SAY speak with the
greatest possible accuracy.
Appendix H of the Amiga BASIC manual goes into great detail
about how to spell with phoneme codes. Although you can use the
TRANSLATES;) function to create the phoneme codes for you, taking
time to learn the codes yourself will be worth it if you want SAY to
speak with the greatest possible accuracy. You can use the pho
neme codes to specify precise accents, pauses, and emphasis you
want to put in a sentence, or to make SAY speak in a foreign lan
guage. For example, the following statement says "Wie gent es
Ihnen?", German for "How are you?":
SECTION 3: SOUNDS
242
Choosing inflection or monotone
Element number 1 of the array is either a 0 or a 1, and is used
to specify speech with inflection, or monotone speech without
inflection. The default is 0, speech with inflection. A 1 specifies
monotone speech.
You'll probably want to use inflection most of the time to add life
to the Amiga's utterances. If you want SAY to keep a steady base
pitch, then you can use monotone. Monotone also does a great old-
fashioned robot imitation.
243
general voice quality you want by using the default pitch of 22000
and changing the other voice attributes. Once you have the voice
quality, reset the base pitch to find the new pitch you want.
0 Channel 0
1 Channel 1
2 Channel 2
3 Channel 3
4 Channels 0 and 1
5 Channels 0 and 2
6 Channels 3 and 1
7 Channels 3 and 2
8 Any available channel that comes out of the left
audio port
9 Any available channel that comes out of the right
audio port
10 Any available pair of channels that come out of both
the right and left audio ports (the default)
11 Any available single channel
SECTION 3: SOUNDS
244
channel assignment choice to make, since it's always more likely
that a single audio channel will be available than it is that a left-
right pair of audio channels will be open for use. However, if you
use choice 11 and you have the Amiga hooked up to a stereo
system with two speakers, you won't be able to predict which
speaker the voice will come out of.
Value Meaning
245
SAY STATEMENT EXAMPLES
It's simple to use a specification array to change the quality
of SAY's speech- You don't need to dimension the array since it's
less than 11 elements long, and you can use a READ statement in
a FOR.. .NEXT loop to read the values from a DATA statement for
each element. For example, the following short program sets the
specifications for the SAY statement to speak in a rapid female
voice. It stores them in the array voice%, and uses it in a SAY
statement that speaks the tongue twister "Peter Piper picked a
peck of pickled peppers":
FOR i = 0 TD 8
READ voiceX( i )
NEXT l
When you run the program, you may notice that it pauses briefly
to load something from the BASIC disk. This is because BASIC
needs to open the speech device when it first encounters a SAY
statement in a program. Any SAY statements that follow will be
spoken immediatelyBASIC needs to open the speech device only
once each time the program is run.
If you want to play around with different voice qualities, you can
change the values in the DATA statement, then run the program
once again.
The next program reads four different voice-specification arrays
and uses the values to create four different SAY voices. The first
voice is a female voice, created by raising the base pitch of the
default voice from 110 to 220 cps. The second voice is a laconic-
sounding robot voice created by lowering the base pitch to 70 cps,
choosing monotone, and setting the speech rate to a slow 80 words
per minute. The third voice has a nasal sound created by raising
the base pitch to 320 cps and lowering the sampling frequency
to 10000 cps. The last voice is very rich and deep, but fast; the
base pitch is dropped to 65, the speech rate is sped up to 350
words per minute, and the sampling frequency is raised to 28000.
SECTION 3; SOUNDS
246
FDR 1 = 0 TO 7
NEXT i
DATA 0, 1, 0, 0
DATA 1, 0, 0, 1
DATA 1 , 1 , 1 , 1
When you run the program, you'll notice that even though the
PRINT statements follow the SAY statement they describe, they print
on the screen at the same time the SAY statement starts speaking.
That's because all four voices are in asynchronous speech and
BASIC proceeds immediately to the PRINT statement as soon as the
SAY statement starts speaking. The FOR.. .NEXT loop at the end of
the program is a timing loop to prevent the List window from
appearing before voice 4 is finished speaking.
If you change the second to the last DATA statement to a line
of four zeros, the PRINT statement will wait until each voice is
finished speaking, because the SAY statements now use synchro
nous speech. (If you switch to synchronous speech, the timing loop
at the end of the program is no longer necessary.)
Now that you've had a chance to try out the Amiga BASIC
sound statements, you can use them for your own crea
tions. BEEP and SOUND will create sound effects and notes,
WAVE will create timbres, and SAY and TRANSLATES!) will
control the Amiga's speech. You can synchronize your
SOUND creations with SOUND WAIT and SOUND RESUME. By
tying all of these statements together, you can create
music, distinctive voices, and other audio effects that will
really enhance your programs. And if you enjoy the
dynamic quality of your sonic creations, you'll also enjoy
reading about the next section's subject: animation.
247
TION
FUNDAMENTALS OF ANIMATION
SECTION 4: ANIMATION
252
eye; video animation can present 60 images per second. Why don't
you see each of those images individually, iike a very speedy slide
show? There are two answers: continuity and presentation speed.
Your mind is more likely to accept a series of still images as
one single image moving over time if the images are all similar,
especially if there is little change in position between images. This
establishes continuity from image to image. Figure 10-1 shows six
images of a bird flapping its wings. If you see the six images in
rapid succession, centered in the same spot, your mind will prob
ably interpret them as one bird flapping its wings. This is true even
if the images are shown in slow succession. The human mind likes
to bind together separate elements into a meaningful whole.
Figure 10-1.
253
If it takes at least 25 different images (usually called frames) per
second of animated motion, you can see that even a one-mmute
animated commercial needs 1500 different frames. That's a lot of
work to do if you have to create each frame by hand. It's even a lot
of work if you create the frames using a computer. Fortunately,
there are shortcuts to use so that you won't have to draw 1500
individual frames.
One such shortcut is a common animation technique that
involves creating each new image in a sequence of images by
copying the preceding image and altering only the parts of the
image that are in motion. Because the stationary elements don't
change at all from frame to frame, you can separate the moving
elements from the stationary elements and concentrate on redraw
ing just the moving elements.
The simplest way to separate moving elements from stationary
elements is to separate them into two parts: the background and
the moving objects. The background can be something like a wall,
a mountain, or a forest that doesn't move, but provides a backdrop
for the action of moving objects. Moving objects can be people,
animals, airplanes, or anything else you want to animate.
The background
A good background sets the locale and mood for animation, like
the scenery in live theater does for a play. Since you might only
have to draw the background once for an animated sequence, you
can afford to spend a lot of time to make it rich in detail and a
useful backdrop for the animated objects that will move around in
front of it.
Although a background usually remains stationary during an
animated sequence, there are times when it too will move, usually
to indicate a change in viewpoint. For example, put your hand in
front of your face and look at your fingers. Notice the background
behind your hand. Now turn your head and hand slowly to the right
as you continue to watch your fingers. Notice that the background
seems to be moving to the left in relationship to your fingers. By
moving the background slowly to the left or right, up or down, or
diagonally, you can make it appear that the viewpoint is changing
in your animation. In traditional animation, this action is called
panning. In computer animation, it's called scrolling.
The background can also change if the viewpoint moves closer
or further from the background. The background gets larger as the
viewpoint moves toward it, smaller as the viewpoint moves away
from it. By steadily enlarging the background, you can make it
appear that the viewer is moving forward. Likewise, by steadily
shrinking the background, you can make it appear that the viewer
is moving backward.
SECTION 4: ANIMATION
254
Traditional animators create the background by painting it and
putting it on an animation stand, a flat surface similar to a drafting
table with an attached movie camera set up to photograph one
frame of movie film at a time. The animator can use the animation
stand to move the background by moving the painting slightly from
frame to frame (panning the background), or by moving the camera
closer or farther away from the background from frame to frame
(moving the viewpoint in or out). This is a time-consuming pro
cess, because each sequence of background movement requires
the animator to move either the background painting or the camera
just the right amount, expose one frame of film, move the painting
or camera again, and repeat the process again and again.
Moving the background is much easier for the computer anima
tor; he can create the background painting using the computer's
drawing software, and then store it in the computer's memory.
Once the drawing is in memory, the animator simply instructs the
computer to pan the background by scrolling the image in the
desired direction, or to move the viewpoint in and out by shrinking
or enlarging the image through manipulation of the picture data.
Moving objects
Once the background is in place, the animator creates objects to
move around in front of it. Each of these moving objects can have
two basic kinds of motion: external and internal. External motion is
the movement of the entire object in relation to the background.
Internal motion is the movement of the parts of an object. Consider
the example of a man walking across a street. His external motion
is his entire body crossing the street. His internal motion is his legs
striding back and forth, his arms swinging, his torso bobbing up
and down, and a grin passing over his face.
In traditional animation, the animator creates moving objects by
drawing or painting them on clear sheets of acetate (called gels).
These gels are placed on top of the background painting on the
animation stand for filming. Since the acetate allows the back
ground to show through wherever an object isn't painted, the movie
camera photographs the gels and the background together as a
frame that looks like a single completed drawing, even though there
may be several layers of gels on top of the background painting.
To create external motion alone, the traditional animator simply
moves a single gel small distances over the background as he
shoots successive frames. A computer animator uses a similar
process: He first draws the object, and then instructs the com
puter to display it in front of the background. He then gives the
computer instructions telling it where to move the object. Both tra
ditional and computerized methods for producing external motion
255
are fairly simple. Unfortunately, external motion without internal
motion is usually very unconvincing, and looks frozen and cheap. If
you try to animate a man crossing the street without moving his
arms and legs, it looks like a lifeless paper doll being pushed across
the screen. External motion alone might work for something as
simple as a rock dropping from a cliff, but even a failing rock would
look much more realistic if it tumbled and turned as it fell.
Creating internal motion often takes more work than any other
part of animation, which is only fair when you consider that it adds
the most life to animation. To create internal motion, the animator
has to draw a series of successive images to show how the object
changes. The six drawings of a bird flapping its wings (used earlier
in the chapter) are an example of creating internal motion through
successive images. To show half a minute of this bird flying, you
would have to create hundreds of successive wing-flapping, head-
twisting, and body-turning images to capture all the variety of
motions that a real bird makes in flight-
To create internal motion, a traditional animator draws a
sequence of gels, each showing a slightly different position of a
moving object. By photographing the gels in succession on top of
the background painting, the animator creates animation with
internal motion. A computer animator can use a similar method; he
creates a series of images in computer memory that the computer
displays in sequence on the screen. Neither the traditional nor com
puterized method for creating internal motion is easyeach
requires a lot of time drawing images.
You can take advantage of the cyclic nature of movement to
make the task of creating internal motion much simpler. For exam
ple, birds flap their wings down, then up, then down, then up, and
so on as they fly. If you ignore some of the minor variations that oc
cur from wingflap to wingflap, you can draw a sequence of images
that animate just one wingflap, and then repeat that sequence
over and over for each flap of the bird's wingsa process called
cycling. Instead of creating hundreds of images for a half minute
of bird flight, you can create just a few images that you can repeat
over and over again as the bird flies. Cycling a sequence isn't as
convincing as drawing all the images individually (as you can see
in cheap Saturday morning cartoons, which use a lot of cycling),
but it does give you internal motion with a fraction of the work it
would normally take.
Once you create a series of images to internally animate an
object, it's important to make sure that internal motion matches
external motion. For example, if you create a man who walks
SECTION 4: ANIMATION
256
swinging both arms and legs and don't give him some external
motion (or at least move the background behind him), he'll look like
he's slipping on ice, not getting anywhere. Likewise, if the man has
too much external motion, he'll look like he's wearing seven-league
boots, taking giant strides with each small step.
ADDING PERSPECTIVE
Animation is ultimately displayed on a two-dimensional medium
such as a computer monitor or a movie screen. You can use
different animation and drawing techniques to transcend the two
dimensions of the screen and portray your animated images in any
of three different perspectives: two dimensions (2-D), three dimen
sions (3-D), and two and a half dimensions (2&-D). Each perspective
has its advantages and disadvantages.
2-D perspective
A two-dimensional perspective assumes there is no depth to
the picture, and that the objects in motion move horizontally and
vertically, but not toward and away from the viewer. 2-D perspective
usually works best for animation that is a symbolic representation
of reality (not attempting to look real).
A good example of 2-D animation is cars moving on a map of
city streets, as seen below in Figure 10-2. Since cars don't as a rule
fly away from the streets, the cars on the map won't move toward
or away from the viewer. Their motion is strictly horizontal, vertical,
or diagonal-all two-dimensional motion.
Figure 10-2.
cars on a map.
257
One important property of 2-D animation is that a moving object
can't pass in front of or behind other moving objects (at least not if
you keep it realistic). Since the objects are confined to a two-
dimensional plane, they collide when they meet. For example, two
cars in the map example can't pass through each other One has to
go around the other, or they will crash.
2-D animation may not look realistic, but it has some advantages
over other perspectives. First, it's usually much simpler to create
than 2/2-D and 3-D animation because you don't have to keep track
of an object's depth, only of its location on a single two-dimensional
plane. Second, a simple symbolic representation can show the
important elements of the animated sequence with much more
clarity If the streets in the map example were drawn as they would
actually look from the air with hills and valleys and black pavement
roads, it would be a much more realistic animation, but it would
also be much harder to see what was happening as the cars moved
around the streets.
3-D perspective
A three-dimensional perspective adds depth and realism to the
image on the screen. Objects in 3-D animation can move toward
and away from the viewer as well as horizontally and vertically
Since the third dimension, depth, is portrayed on a two-
dimensional screen, it's strictly an illusion sustained by different
animation techniques.
The most familiar technique used to create a 3-D perspective is
the artificial horizon, an invisible horizontal line used by animators
as a point of reference. If you're not familiar with artificial horizons,
consider a real horizon. When you look far out over the ocean, the
line where the sea meets the sky is the horizon. Any boats floating
in the water close to you appear far below the horizon. As they sail
away from you, they seem to rise closer and closer to the horizon as
they get smaller and smaller and then finally disappear. Likewise,
any airplanes flying from directly above you to far out over the
ocean at first appear quite a distance above the horizon, then drop
closer and closer to the horizon and get smaller and smaller until
they disappear.
Figure 10-3 shows two ships sailing toward the horizon. Since
the one in the lower left corner is larger and further from the
horizon than the one in the middle, it appears closer to the viewer.
SECTION 4: ANIMATION
258
Figure 10-3.
259
One of the easiest ways to establish the depth location of a
moving object is to pass it in front of or behind another object on
screen. If the object passes in front of another object, as it does in
Figure 10-4, it's obviously closer to the viewer than the second
object. If it passes behind another object, it must be further away
from the viewer. If two objects collide and don't pass over or behind
each other, then both objects are the same distance away from
the viewer.
Figure 10-4.
2Y2-D perspective
A two-and-a-half-dimensional perspective is a compromise
between the simple 2-D perspective and the complex but more
realistic 3-D perspective. Objects in 2J/2-D animation are restricted
to horizontal and vertical motion in a single plane as they are in 2-D
animation, but there are several planes in the picture to create an
illusion of depth.
SECTION 4: ANIMATION
260
To get a good idea of how 2/2-D perspective works, think of a
theater stage with an underwater mountain painted on a flat
backdrop. This is one plane of the image the audience sees from
the theater seats. In front of the backdrop is an aquarium, full of
fish, wide enough to stretch to both sides of the theater and tall
enough to extend to the top of the proscenium, but only four inches
from front to back. This is a second plane of images. In front of the
aquarium is a second aquarium just like the first one, also full of
fish, which creates the third plane of images. In front of both
aquariums and the backdrop is a facade of coral that rises halfway
up the height of the aquariums. This is the fourth plane of images.
Figure 10-5 shows you how these planes in the fictitious theater
are set up.
When you look at everything on stage from the audience, you see
coral in front. Behind the coral, you see fish swimming back and
forth, some passing m front of other fish. Behind the fish you see an
underwater mountain. Even though there are only four planes of
depth, you can see it as a full-depth picture.
If you were the fish director, you would never have to worry
about the fish in the back tank upstaging the fish in the front tank,
because they can only move horizontally and vertically, and can't
swim out of their tank into the tank in front of them. Likewise, as a
2V2-D animator, you don't have to worry about objects moving
261
toward or away from the viewer. They stay in their plane of motion,
passing behind objects in planes before them, passing m front of
objects in planes behind them, and colliding with objects in the
same plane.
2&-D animation is simpler than 3-D animation. You don't have as
much to worry about in terms of changing the size, color, and
amount of internal motion of an object, and keeping track of which
object passes in front of another object becomes much easier.
INTERACTIVE ANIMATION
SECTION 4: ANIMATION
262
ANIMATION ON THE AMIGA
THE PLAYFIELD
You're probably already familiar with the concept of a playfield
on the Amiga, but not with its name. The playfield is the graphic
background for any animation. It's usuaUy motionless, and provides
a backdrop for the objects that move over it. When you create still
pictures with graphics applications like Graphicraft or Deluxe
Paint, you're actually drawing figures in a playfield. The cursor or
the paintbrush that you move around over the playfield is a moving
object, animated by the graphics program and the movements of
the mouse.
You'll recall from Chapter 2 that the Amiga can scroll the con
tents of a window (a playfield) horizontally and vertically. This is a
useful tool for advanced programmers to pan the background in
animation. For example, as a background for animation, a pro
grammer can create a panoramic view of a mountain scene that
is much wider than the window it appears in, as seen below in
Figure 10-6. To move the viewpoint to the left, he can scroD the
entire playfield to the right. To move the viewpoint right, he can
scroll the playfield left.
Figure 10-6.
A panoramic background
shows through an Amiga
window. Scrolling left
and right moves the
viewpoint.
263
You'll also recall from Chapter 2 that the Amiga can lay one
screen over another with transparent areas in the front screen so
the back screen shows through- This gives advanced programmers
two different playfields to work with, which is a very handy tool for
2'/2-D animation. Like the underwater mountain backdrop in the
2J6-D animation example, the back playfield provides a backdrop for
moving objects in front of it. The front playfield can act as a
foreground, much like the coral facade. A programmer can pass
moving objects behind the front playfield, but the objects wiH move
around in front of the back playfield. When a programmer scrolls
both playfields, he can scroll the front playfield faster than the back
playfield to make the background look further in the distance and
make the whole scene look more realistic.
GELS
The Amiga allows you to create moving objects in Amiga BASIC
or in application programs like Deluxe Video or Aegis Animator.
These objects, called geis, can be moved over the playfield. Gel is
an Amiga animation term that stands for Graphic ELement, and
shouldn't be confused with the gels used in traditional animation.
There are two kinds of Amiga gels: sprites and bobs. Sprites are
usually small, simple, and fast, and take very little computing work
to move around the playfield. Bobs can be much larger than sprites
and have more color and detail, but they take more memory to store
and much more computing work to move, so they are sometimes
slower than sprites. If you understand how the Amiga creates
sprites and bobs, you'll understand why they have different
characteristics.
Sprites
A sprite is a small object placed directly on the playfield by
the Denise chip. It's like a flashlight pointer used on a projected
picture: As the flashlight moves up, down, and around, the beam
of light moves around without changing the image underneath at
all. Like the flashlight beam, a sprite isn't part of the picture drawn
on the playfield; as it moves around the screen, the sprite passes
over the playfield without changing it.
Sprites are common animation devices on home computers such
as the Atari 800 and the Commodore 64. What sets the Amiga's
sprites apart are their number and their coloring. You can create up
to eight sprites on the Amiga, and each of those sprites can be
colored with up to four different colors. One of those colors is
"transparent"; you can see the background through transparent
parts of sprites. To create a sprite with more colors, advanced
SECTION 4: ANIMATION
264
programmers can program the Amiga to combine two sprites to
create a new sprite that is the same size as a single sprite, but can
use sixteen colors.
Sprites are easy to create, and they take very little memory to
store. They're quite useful as fast-flying objects in video games,
and also work well as pointers. The pointer in the Amiga
Workbench is a familiar example of a sprite.
Bobs
Unlike a sprite, which moves over the playfield without changing
it, a bob is a gel drawn directly into the playfield. To get an idea of
how a bob moves around the screen, think of a traditional animator
creating a sequence of frames by drawing on a single sheet of
paper. He draws a swamp pond with a duck floating on the right
side of the pond, then snaps a picture of it. To make the duck swim
to the left side of the pond, the animator erases the entire duck,
then redraws it a fraction of an inch to the left of its original
position. He fills in the swamp pond to the right where the duck
used to be. He repeats this for each frame of the animation until
the duck reaches the left side of the pond.
A bob on the playfield is like the duck in the swamp picture.
The blitter (the fast-drawing section of the Agnus custom chip) is
the animator. It draws, erases, and redraws the bob and the
background underneath the bob with lightning speed to make the
bob move smoothly across the playfield.
Bobs can use up to 32 colors at once, and can be drawn in any
size as long as they fit in the playfield. Since bobs are drawn and
redrawn to move around the playfield, they take more computing
time to move than sprites, and are a little more difficult to create.
Nevertheless, bobs, once created, can usually move as quickly and
smoothly as sprites if they're not too large.
Bobs are useful to create animated objects of complex shape and
color. A good use of a bob would be as a large object like a car that
travels across the playfield. A sprite wouldn't be able to create an
object as large or with as much detail. A familiar example of a bob
is a custom brush you pick up from the mam picture in Deluxe
Paint. When you select a section of your picture, make it a brush,
and paint with it, you're actually using a bob.
265
Sequenced drawing
Sequenced drawing is a method of animation available to
advanced programmers using the animation routines in the
Amiga's system software, or to dedicated Deluxe Video users. It
uses the technique shown earlier in the chapter used to animate
the wings of a bird: The programmer draws a sequence of indi
vidual pictures of different stages of internal motion. He then plays
back the sequence to create motion on the screen.
To use sequenced drawing with a gel, the programmer creates a
sequence of shapes and colors, and then uses the Amiga's system
software to assign the sequence to a single gel. The Amiga then
cycles through the drawing sequence to create an internally
animated gel. The programmer can move the sequenced drawing
gel around the playfield while it's running through a sequence of
drawings just by specifying the distance, speed, and direction for
it to move.
As an example, to animate a flying bird, a programmer would
produce a cycle of bird shapes that make the bird flap its wings
once. He would then assign the cycle of shapes to a gel. The
Amiga cycles through those shapes to create a bird flapping its
wings. To make the bird fly forward over the playfield, the pro
grammer tells the Amiga how far, in what direction, and how fast
to move the gel so the external motion of the bird will match the
internal motion of the wing flaps.
Component motion
An advanced programmer can also use component motion, a
second method of creating internal motion in a figure. The
programmer creates a set of small gels and groups them together
using the animation routines in the Amiga's system software to
create a single animated figure. Each individual gel has its own
external motion (with no internal motion), yet moves correctly with
the other gels in the figure to make the set of gels look like one
figure with internal motion.
As an example, consider the animated sequence of a man
walking across the street. The man has a separate gel for each of
his legs, torso, head, and arms. Each of these gels has its own
motion: The arms and legs swing backward and forward, the head
bobs up and down, and so on. When all these actions combine, the
figure of the man goes through walking motions. This is the figure's
internal motion. Adding external motion to the figure is done by
moving all the gels together in a single direction while they are still
going through their walking motion to let the man actually make
some progress in walking.
SECTION 4: ANIMATION
266
The Amiga's system software takes care of the tricky process of
calculating the motion of each individual gel when the entire figure
moves in one direction or another. All the programmer has to do is
create the individual component gels, define a set of motions for
each gel, and then give the Amiga a direction and speed for the
external motion of the entire figure.
For short animated sequences, component motion might be
harder to create than sequenced drawing. However, it's very useful
for long and varied animated sequences, and for interactive ani
mation where the individual gels can change their motion accord
ing to the input of the viewer or changing instructions from a
program.
267
Some intriguing possibilities for interactive animation use fancy
hardware. For example, if you add an audio sampler to the Amiga
(see Chapter 8 for information on audio samplers) that sends
information to an animation program about sounds in the room
around the Amiga, the animation program can change the actions
of the figures on the screen to match the sounds in the room
around them. Likewise, if you have a digital thermometer that
sends temperature information to the Amiga through the serial
port, an animation program might be able to create different
animation for cold weather, cool weather, warm weather, and
hot weather.
SECTION 4: ANIMATION
268
CHAPTER ELEVEN
AMIGA ANIMATION
TOOLS
Animation is rarely a spontaneous activity; the typical
animator doesn't have a brilliant idea one evening, work a
few hours to bring an inspiration to reality, and then
perform the work for an adoring public the next day. You,
however, can come closer to spontaneity using some of the
animation tools available for the Amiga. They make ani
mation a much simpler process.
In this chapter, you'll learn about the available Amiga
animation tools. In the first half of the chapter, you'll learn
how to use advanced techniques with Deluxe Video, an
animation program, to create animated videos with pol
ished results. You'll discover tricks to put more animation
on the screen, get smoother results, and spend less time
creating a video. You'll also learn how to record your
finished videos on videocassette.
In the second half of this chapter, you will read about
Aegis Animator, another animation program for the Amiga.
You'll also read about the variety of hardware you can add
to the Amiga to enhance its video-production capabilities.
SECTION 4: ANIMATION
270
Deluxe Video is not a simple program; it has to coordinate
motion, size changes, file loading {from disk}, disappearances,
music, sound effects, and many other elements. To use Deluxe
Video effectively, you have to compose a video much like a music
composer composes music, carefully thinking through the appear
ance and sequence of each video effect, using the techniques you
learn as you gain experience creating scripts. The following sec
tions explain some advanced techniques and tips you can use to
create your own Deluxe Video scripts.
271
think that the objects it contains can also use up to eight colors.
Instead, they are limited to seven colors, because the eighth
colorthe background coloris transparent so the background
playfield can show through. And, since the background and fore
ground playfields can each use different sets of colors, by com
bining playfields you have a total of 15 colors that you ci:\\ use
in a video.
When you create objects and pictures for a single video script,
you can set the Deluxe Paint colors so that you use only one set of
eight colors for the background and another set of seven colors for
the foreground. Since Deluxe Paint has a spare screen, you can
work on the background in one screen, and on the objects for the
foreground in the other. Follow the instructions below to create a
picture and several objects to use in Deluxe Video.
First, set up Deluxe Paint:
3. Set the eight colors in the left column to colors you want to
use in your background picture.
4. Set the first seven colors in the right column as the colors
you want to use in the objects. Since you'll use the eighth
object color as the background color, it will be transparent in
Deluxe Video, so it doesn't matter what color you choose for
the last color in the right column. As you choose the object
colors, try to make them different from, but complementary
to, the background colors you set in the left column. This will
make your video look much more colorful when you put your
objects and the picture together.
SECTION 4: ANIMATION
272
Now that Deluxe Paint is set for work, you can create a
background picture:
4. When the Save requester appears, click in the Drawer box, and
use the DELETE key to delete the contents of the box. If the
Parts disk is in an external drive, first type the name of the
drive (such as dfl:), then type Pictures. To enter the
background picture name, click in the File box, and type the
name. Click the Save button to save your background picture
in the Pictures drawer on your Deluxe Video Parts disk.
2. Use the right mouse button to select the bottom color in the
right column of the palette as the background color, then
select the CLR button to fill the screen with this color. Since
the background color will be transparent on the screen in
Deluxe Video, it doesn't really matter what color it is on the
palette in Deluxe Paint.
3. Draw your objects in this screen using the first seven colors
in the right column of the palette.
273
6. Choose the Save As ... command from the Brush menu to start
to save the object.
SECTION 4: ANIMATION
274
animation uses quite a bit of processor time and memory, and
makes the motion on screen jerkier as you add more objects. If you
want to use a different method of animation that requires very little
memory and processor time, and also lets you add animation to the
background playfield, you can use color-cycle animation.
You've probably played with color cycling using Deluxe Paint. By
choosing a range of colors as a cycle range, painting a succession
of those colors on the screen, and then cycling the colors, you can
create the illusion of motion. You can also use color cycling in
Deluxe Video by choosing which colors will cycle in either the
foreground or background piayfields. You can use Deluxe Paint to
create background pictures or objects to use with Deluxe Video's
color-cycling effect.
The following example uses color cycling. It creates a back
ground picture depicting a carnival shooting arcade, with a series
of target ducks moving on a conveyor belt at the back of the arcade
tent. To create this background picture, first load Deluxe Paint and
set the palette:
3. The eight colors in the left column are for use in the
background picture. Leave the first three colors black, white,
and red, but change the fourth to brown. You'll use these four
colors to create the carnival tent and a wooden counter top.
5. Set the last four background-picture colors (the one you just
changed to yellow, and the three below it} as color cycle
number one (Cl). (See Chapter 3 for more information if you
don't know how to set a color cycle.)
1. Use the first four colors in the left column to draw a carnival
tent with countertop and a runway strip for the target ducks
as you see in Figure 11-1 on the next page. The brown strip
in the middle of the picture is the duck runway.
275
Figure 11-1.
5 SHOTS WIN A
WORTHLESS
PRIZEt
Mill HIM
Duck runway
Countertop
Figure 11-2.
A duck to be selected
as a brush.
SECTION 4: ANIMATION
276
3. Use the brush-selection tool to select the duck as a brush,
and switch back to the carnival picture.
4. Choose Cycle from the Mode menu so the brush will cycle
through the colors in the cycle range you set earlier in
the palette.
5. Select the first of the four cycle colors in the control strip
(yellow) as the foreground color. This makes the brush-color
cycle start from this color.
Figure 11-3.
WIN A
WORTHLESS
PRIZE*
If you cycle the colors by pressing the TAB key at this point, the
ducks will look like they're standing still and changing colors. To
make them look like they're moving, you have to change the palette
once again:
2. Copy the brown that you used to paint the duck runway to
the last three colors of the cycle range (colors six, seven,
and eight).
277
3. Select OK to close the palette.
4. Press the TAB key to test the color cycling. You should see a
well-spaced chain of yellow ducks moving across the runway.
7. Drag the first arrow of the CycleClr effect to the time in the
script where you want the ducks to start moving, and drag
the second arrow of the effect to the time where you want
the ducks to stop moving. Figure 11-4 shows a scene script
with the carnival picture loaded and the color cycling set to
last for eighteen seconds.
SECTION 4: ANIMATION
278
Figure 11-4.
- carnival-
CyelcClr
C hckirri-
r
279
The first thing you need to do is draw your image sequence
using Deluxe Paint:
2. Set the last seven colors in the palette to the colors you want
to use for your images. You'll use the first color as the
background color. It doesn't matter what color you set it to,
because Deluxe Video recognizes it as the background color,
and makes it transparent in the video.
3. Draw your first image in the upper left corner of the screen,
leaving room for the other images in the sequence in the rest
of the screen. Be sure to draw your image a little below the
title bar If you draw it too high, you won't be able to frame it
later with the Deluxe Video Framer: It will be too high on the
screen for the frame to slide up to.
Figure 11-5.
be duplicated to create a
sequence of images.
SECTION 4: ANIMATION
280
5. Use the brush-selection tool to select the box and its
contents as a brush.
6. Lay down copies of the box next to each other, as you see in
Figure 11-6. Make sure the borders of the boxes don't overlap:
Wherever they touch there should be a double-width line. If
you run out of room in one row, start a new row going from
left to right under the last row.
Figure 11-6.
A sequence of images
ready to be altered.
281
Figure 11-7.
A sequence of changing
images.
5. Drag the upper left corner of the frame grid that appears until
it lines up with the upper left corner of your set of boxes.
6. Drag the lower right corner of the box labeled "a" down and
to the right to size the frame grid to exactly cover the borders
of your boxes.
SECTION 4: ANIMATION
282
7. The images will have letter names in the upper left corner of
each section of the frame grid like the images in Figure 11-8.
Note what happens in each framewhen you use the
Deluxe Video Maker later, it lets you change the sequence
order by typing in the frame letters in the desired order.
Figure 11-8.
A sequence of images
10. Choose the Save... command from the Object menu to save
your sequence as an object in the Objects drawer of your Parts
disk. Note that Framer will add a -1 extension to your old
filename for youjust click Save to save the sequence under
this name.
283
Once you've set up your animation sequence with the Framer,
you can quit the Framer and use the Deluxe Video Maker program,
where you can put your animation sequence in a script:
8. Drag the left arrow of the AnimSeqn event to the time in the
script where you want your animated sequence to start
running, and drag the right arrow to where you want the
sequence to stop running. Deluxe Video will run through the
number of images in the sequence you specified over the
time period set for the effect, so if you stretch the start and
stop points of the effect out over a long period of time, the
animated sequence will step through the images slowly. If
you limit the effect to a short period of time, the sequence
will cycle through the images quickly.
SECTION 4: ANIMATION
284
You can use sequential animation to very good effect. Keep in
mind that while the object is cycling through its sequence of
images, you can move it with a Move To effect. If you create a
walking or flying object, you can coordinate its external motion
(set with the Move To effect) with its internal motion (set with the
AnimSeqn effect) to make it look as if it's really walking or flying.
SYNCHRONIZING EFFECTS
As you use Deluxe Video, you'll find it very important to
synchronize effects in your script so sounds will accompany the
right actions, so motion can start at the same time as an object
appears, and so other effects that should happen together do
happen together One easy way to synchronize effects is to start
them together by lining up the left arrows of the effect boxes. You
can read the script time of the arrow at the top of the script as you
drag it along the track.
There are times when you may want to set the beginning of one
effect to occur at a specific point in the middle of another effect.
For example, you may want to add a "pop" sound in the middle of
an animated sequence that shows a pop bottle opening. How do
you find the correct point in the sequence without resorting to
tedious trial and error? You can use the remote control to locate the
exact time of the pop bottle opening.
Whenever you run a video or scene with the remote control
showing on the screen, the bottom of the remote control displays
the script time, running it forward or backward as you play
different parts of the script in different directions. To find the script
time of a specific effect in a scene, you can stop the scene from
playing and then read the time at the bottom of the remote control.
To make it easy to find, you can play the scene to approximately
where the effect occurs, and then play the scene using the single-
step mode.
To use single-step mode, select the button in the remote control
with the three dots in it, then use either the forward-play or
reverse-play button to go through the script one step at a time.
Whenever you find the exact point in the scene that you're looking
for, note the time at the bottom of the remote control When you go
back to the script, you can set a new effect at exactly the time you
noted by positioning its left arrow, using the time reading that
appears at the top of the script.
When you use this timing method, be sure that the Realtime
option isn't selected in the Options menu. If it's selected, the time
display at the bottom of the remote control will keep incrementing
during disk-loading operations as well as during video effects, so
the readout won't have anything to do with the time location of
effects in the script.
285
MAKING YOUR SCRIPTS READABLE
As you create video scripts, the tracks and effects begin to add
up to an on-screen jumble, especially if you have many effects
running at the same time on one track. If you want to revise your
script, it can be very hard to see what you're doingsome effect
boxes may completely cover other effect boxes, effect-box arrows
may be crammed into one tiny space so you can't see where the
effects start and end, and some effect boxes might be placed so far
away from their arrows that you can't follow the connecting lines.
To avoid these problems, follow these rules of thumb to make
your script easy to read and revise:
SECTION 4: ANIMATION
286
Figure 11-9.
287
Making the recording
Once the connections are made, you can start recording. To
capture all the video on tape without recording the process of your
loading and running the script, follow these instructions:
1. Run the Deluxe Video Maker and load whatever video you
want to record. Choose Play Video from the Project menu.
5. Move the pointer off the bottom right corner of the screen so
that no part of it shows on screen.
7. Wait for a few seconds until the VCR's tape heads are up to
speed, then press the Amiga keyboard's right cursor key to
start the video playing.
8. At the end of the video, stop the VCR- You've just recorded
your video onto tape.
SECTION 4: ANIMATION
288
to use a composite video signalmost VCRs will only accept a
composite video signal. You can improve the quality of the tape
recording, though, by buying a high-quality home VCR and using a
good-quality recording tape. If you buy a Beta VCR, try to get a
SuperBeta recorder, which has substantially better video quality
than other types of Beta recorders. If you buy a VHS VCR, you
should consider an HQ VHS, which also has video quality much
improved over other VHS VCRs.
Deluxe Video is not the only animation software you can buy for
your Amiga. Electronic Arts plans some further additions to Deluxe
Video, and Aegis Development has an animation program called
Aegis Animator.
AEGIS ANIMATOR
Aegis Animator, sold by Aegis Development, is a simple but
effective animation program. It's inexpensive, easy to use, and can
create some great three-dimensional animation using simple
abstract objects. Aegis Development bundles Aegis Animator
together with the Aegis Images graphics program, so you can
use pictures created in Aegis Images as backgrounds and objects
in Aegis Animator videos.
Aegis Animator uses a type of animation called metamorphic
animation for most of its effects. In metamorphic animation, the
Amiga doesn't calculate the motion of every bit in an object that it's
moving around the screen. Instead, it uses simple geometric
objects such as lines and polygons that it can define by setting a
series of points and connecting them with lines. The Amiga has to
calculate only the endpoints of an object as it moves it around the
screen instead of calculating the motion of every bit in each object.
For example, to keep track of a square, the Amiga has only to keep
track of the location of the four corner points. As Animator moves
these simple objects around, it calculates new positions for the
endpoints and then draws the rest of the object by connecting the
points and filling it in if it's a solid object.
The advantage of metamorphic animation is that it takes very
little calculation to manipulate objects on screen. Aegis Animator
makes good use of this advantage, and offers a variety of special
effects you can use on an object, such as moving it from one
location to another, changing its size, rotating it around three
289
different axes, and changing it from one shape to another. Another
advantage of metamorphic animation is that the motion of an
object is often much smoother than it is in blitter or sequenced
drawing animation, because of the reduced calculation time.
The disadvantage of metamorphic animation is that you have to
work with simple geometric shapes. This is no drawback if you're
working on abstract animation, but it's a distinct disadvantage if
you want to create objects like people, animals, and other
irregularly shaped items.
Animator offers you some alternatives to metamorphic anima
tion: You can use a 32-color picture created with Aegis Images,
Deluxe Paint, or another IFF standard graphics program as a
background to your animation. (Animator uses a single 5-bit-plane
playfield for animation instead of the two 3-bit-plane playfields
Deluxe Video uses, so it's possible to get 32 colors.) You can also
create individual objects with up to 32 different colors in a graphics
program, and Animator will use them in simple animation; it
moves them around the screen, but it won't rotate or size them or
change their shapes as it can with geometric objects.
Animator doesn't use a script the way Deluxe Video does.
Instead, it lets you create objects on the Animator screen, and then
move them around and control them with other effects. You record
each step of your motion and control effects, and Animator
remembers the whole sequence so it can play it back later. Once
you finish a sequence, you can create other sequences, and then tie
them all together in a special screen called the storyboard. This
makes it easier to create a short video than by using a script, but it
also makes it harder to edit a video and to synchronize many
effects at once.
Unlike Deluxe Video, Animator is strictly animationthere
is no sound, so you can't add sound effects or a musical score to
accompany your creations unless you run a music program simul
taneously. Also, Animator does not have commands for adding
text to your animation.
SECTION 4: ANIMATION
290
ANIMATION AND THE IFF STANDARD
Since animation has no set notation standard, and different
animation programs use entirely different techniques to create their
effects, there is no IFF standard for video scripts. This means that
you can't create a video on Deluxe Video and then play it using the
Aegis Animator or vice versa. The individual parts of the videos
use the IFF standard, though. Pictures, sounds, and music can be
transferred from one animation program to another that uses the
IFF standard and can make use of them.
291
can directly read both internal and external memory, it can quickly
bring the animation elements into the chip memory when they're
needed without the delay that would be caused by loading them
from a floppy disk.
Several companies make external RAM cards that plug into the
Amiga's expansion port. Most of these cards contain two mega
bytes of RAM, memory enough to store more than the contents
of two floppy disks. Some of the RAM cards allow you to add
additional 2-megabyte RAM cards up to a total of 8 megabytes.
The 2-megabyte memory board sold by The Micro Forge is a typ
ical example of external memory you can add to your Amiga.
SECTION 4: ANIMATION
292
displayed on a moving background of the 5 o'clock news, or
whatever the television receiver is receiving. The TV background
replaces the normal blue background you see in Workbench. You
would also hear the audio portion of the 5 o'clock news on your
monitor speakers. If the Amiga beeps at you as you work, you'll
hear the beep mixed in with the news.
The Genlock board is very useful for titling videotapes, among
other things. If you connect one VCR to Genlock's input and a
second to the Genlock's composite-video output, you can play a
videotape on the first VCR, add overlaid graphics on the Amiga,
and record the two mixed together on the second VCR- When you
consider that the effects created using Deluxe Video or Aegis
Animator will work with Genlock, all you have to do is lay down
background color in your Amiga videos wherever you want the
videotaped images to show through. You can then have titles
scrolling over your own family videos.
293
The Amiga can be used in combination with a laser disc player,
the IU-04 interface, and a Genlock board to create some interesting
educational programs. For example, you might start with an inter
esting laser disc like one of the Space Archive laser discs sold by
Video Vision Associates. Each Space Archive disc has filmed
sequences of moon landings, shuttle launches, and satellite mis
sions, as well as hundreds of still pictures, stored one per frame.
The Amiga can play the laser disc through the Genlock board on
the Amiga's monitor. While the disc plays, the Amiga can put up
captions on the screen, point out items of interest on the screen,
and even make comments in its synthesized voice. At any point in
the disc, the Amiga can use the IU-04 to freeze the action. It can
ask the viewer if he wants to jump to any other section of the disc,
or it might ask questions in a short quiz. It can then move on to
another disc section, depending on the user's input.
No existing software application works with a laser disc and
Genlock this way, but the hardware and the disc are available, and
you can use Amiga BASIC to create a program that can do just
what was described.
SECTION 4: ANIMATION
294
CHAPTER TWELVE
AMIGA BASIC
ANIMATION:
CREATING MOVING
OBJECTS
Amiga BASIC contains a wide variety of statements
and functions that allow you to move objects around your
monitor screen in different directions at varying speeds. It
can pass one object over another object, and make objects
disappear and reappear at your command. It keeps track of
every object on the screen, and checks to see if they have
collided with each other or with the edges of the window
they're moving in. Amiga BASIC provides you with the tools
you need to create interesting animation.
The first step in creating animation is to draw the ob
jects you want to animate with the Object Editor, a BASIC
program included on your Amiga BASIC disk. The Object
Editor can save the objects to disk for later use in your
BASIC programs. When you write a BASIC program, you can
use BASIC animation statements to bring the objects back
into memory from disk, put objects in the output window,
set the speeds of the objects, start the objects moving, stop
the objects, and remove them from the screen. You can also
include other statements that read the speeds and locations
of objects on the screen, and keep track of their collisions.
In this chapter you'll use the Object Editor program to
create objects, and you'll also try out some of the BASIC
animation statements that put objects on the screen and
move them around. In Chapter 13, you'll learn how to
control the objects' motion, how to make one object pass
over another, and how to control collisions to create
convincing animation.
SECTION 4. ANIMATION
296
MODIFYING THE OBJECT EDITOR
The Object Editor on your Amiga BASIC disk was written to
work on a 256K Amiga, and is limited to creating objects just two
bit planes deep (a four-color limit) in a screen that uses mode 2
resolution. Since Amiga BASIC can use objects of all different
depths and resolutions, you should modify the Object Editor
program if you have a 512K Amiga so the Object Editor will create
objects of all different depths and resolutions. Fortunately, the pro
gram is easy to changeall you have to do is make some minor
modifications.
First, open the Object Editor. If its running, stop it and then
open the List window. Widen the List window so you can see the
full length of the program lines. If you scroll through the program,
you'll see that it's quite long, but divided up into short sections,
most of them starting with a label and ending with a blank line.
As you modify the Object Editor, you'll replace a few subsections
and alter others. To view a particular subsection, just select the
Output window and type list, followed by a space and the name of
the program section. The Last window will list the program starting
at the first line of that program section. You can then alter the
subsection or replace it entirely.
To modify the Object Editor, follow these instructions exactly:
SetScreen:
IF res = 4 THEN
ELSE
(continued)
297
wide * 320: high = 200
END IF
5Crn 1
StatusLine 23
PnntColorBar :
COLOR CurrentColor
ColorBar = WIND0W(5) - 10
COLOR 1
FOR l = 0 TO maxColor
z = newbar + ColorBar
x = x + 20
newbar newbar + 10
barcount = (x - 70) / 20
barend = x: x 70
END IF
NEXT l
RETURN
SECTION 4: ANIMATION
298
6. List the subroutine CheckColor:. Replace the entire sub
routine with this modified version:
CheckColor :
CurrentColor- i
GQSUB PrintColorBar
RETURN
DRAWING AN OBJECT
You can use the modified Object Editor to create both sprites
and bobs. (See Chapter 10 for more information about sprites and
bobs if you don't know what they are.) Run the modified Object
Editor program. When it starts, the program will ask you first for a
resolution mode and then for a depth. If you're going to draw a
sprite, enter mode 1 and depth 2. (You may have to click in the
window first to make the window active.)
If you're going to draw a bob, choose a resolution mode that
matches the resolution mode you want to use in your animation
program. Choose a screen depth that gives you the number of
colors you want to work with. (Recall that different bit-plane depths
give you a different number of colors to work with: 1 bit plane = 2
colors; 2 bit planes = 4 colors; 3 bit planes = 8 colors; 4 bit planes
= 16 colors; and 5 bit planes = 32 colors.)
Once you've chosen a resolution mode and depth, the editor
screen appears, unless you chose a resolution of mode 1 and a
depth of 2, in which case you're asked to choose between editing a
sprite and editing a bob. Once you've made your choice, the editor
screen (seen in Figure 12-1 on the next page) will appear and you
can begin to draw your object.
299
Figure 12-1.
Drawing a sprite
When you draw a sprite, the drawing area of the Object Editor
has a fixed width that limits the maximum width of the sprite.
That's because sprites are limited in width by the hardware that
draws them on the screen. The height of the drawing area is
adjustable, though, so you can change its size to fit the height of
the sprite you want to create.
Once you've set the height, you have a choice of four colors with
which to draw the sprite. Keep in mind that the first color in the
Object Editor's color bar, the background color, will be transparent
when the sprite appears in a window Any areas of the sprite you
colored using the background color (or didn't color at all, since by
default all the pixels are the background color) will let the playfield
and any other objects beneath the sprite show through.
When you finish drawing your sprite, you can save it to disk
using the Save command in the File menu. It will help jog your
memory later if you add .spr at the end of the name of each of the
sprites you create. For example, you might name a sprite shaped
like a pencil Pencil.spr. Later, when you look at all the names of the
different objects you created and stored on disk, you can identify
the sprites by reading the suffixes.
Take some time now to draw a sprite in the shape of a bee and
store it on disk. Name it Bee.spr. You can use it in the program
examples in Chapter 13.
SECTION 4: ANIMATION
300
Drawing a bob
You can draw a bob using any of four different resolutions and
anywhere from two to 32 different colors, depending on the depth
you set. The bob can be a variety of heights and widths. You can
change the size of the drawing area by stretching it horizontally
and vertically to the size you want. The Object Editor won't let you
stretch the drawing area to a size that will cteate a bob too large
for memory
The colors that appear in the color bar at the bottom of the
screen are the default colors contained in the color registers for that
screen. When you choose colors to draw your bob, remember that
the first color, the background color, is transparent when the bob
appears on the screen, just as it is when you use the background
color for a sprite.
When you save a bob to disk, you should add a suffix to its name
that identifies it as a bob and tells its resolution and how many bit
planes it uses. For example, if you create a mode 2 resolution 3-bit-
plane bob that is shaped like a car, you might name it Car.2bob3.
You might also name a mode 1 5-bit-plane bob shaped like a
bratwurst sandwich Bratsan.lbob5.
Before you finish creating objects with the Object Editor, use it
to draw several mode 1 bobs to use in the program examples later
in the chapter. Draw a l-bit-plane bob and save it as Bird.lbobl, a
3-bit-plane bob saved as Flower. Ibob3, and a 5-bit-plane bob
saved as Robot.Ibob5. Don't make them too large! You can use
these bobs later. When you've finished using the Object Editor,
choose Quit to stop running it.
CREATING A PLAYFIELD
Once you've drawn and saved some bobs and sprites, the first
step in creating a BASIC animation program that uses them is to
create the playfield, a background on which they can move. To do
this, you must first create a screen, and then create an output
window using the SCREEN and WINDOW statements you worked
with in Chapter 4. If you want to create a playfield that includes
more than just the background color, you can use some of the
BASIC drawing and printing statements to create figures or patterns
in the output window. Anything you put in the playfield with the
drawing and printing statements will be part of the background
when you put objects on the playfield with the BASIC animation
statements.
301
SCREEN RESOLUTION
When you set the screen resolution with the SCREEN statement,
try to match it to the resolution of the bobs you plan to use. You
can put a bob created in one resolution in a screen of a different
resolution, but the proportions of the bob will change as a result of
the change in proportion of the pixels that build it. For example, a
bob created using mode 1 will look half as wide in a mode 2 screen
because all the pixels on the screen are half as wide as they are on
a mode 1 screen. Figure 12-2 shows a mode 1 bob as it appears in
mode 1, mode 2, mode 3, and mode 4 screens-
Figure 12-2
Sprites look the same no matter what the resolution of the screen
they're displayed in. That's because a sprite is not part of the
screen itself. It's displayed separately by the Amiga's hardware
using mode 1 pixels.
SCREEN DEPTH
To take full advantage of all the colors you selected for a bob, you
should create a screen that's as deep or deeper than the deepest
bob you want to use. For example, if you want to use two bobs, one
two bit planes deep and the other three bit planes deep, you should
create a screen at least three bit planes deep to fully accommodate
the two bobs.
SECTION 4: ANIMATION
302
You can place a bob on a screen with fewer bit planes than the
bob if you want, but you won't see all the colors in the bob because
the bob is limited to the number of bit planes in the screen. For
example, if you put a 5-bit-plane bob with 32 colors on a 2-bit-plane
screen that supports just four colors, the bob will be limited to two
bit planes, and will have only four colors- Any pixels using colors
that are above the range of that screen's depth will be displayed
using the background coloronly pixels with colors within the
depth of the screen will be displayed.
Sprites use their own color registers, so the depth of the screen
they appear on won't affect the color of the sprite.
CHOOSING COLORS
When you put bobs and sprites on a screen, the screen uses the
colors stored in its color registers to color the bob. These colors can
differ from the colors you used to draw the bob, because the Object
Editor doesn't save the actual colors you used. Instead, it saves the
color-register number of each pixel you used to draw the bob,
starting with 0 for the background color, and counting to the right
in the Object Editor's color bar. If there is more than one color bar,
the count resumes at the left end of the next bar down, and con
tinues to the right. For example, a mode 1 Object Editor screen
with 32 colors in the color bar would be numbered as shown in
Figure 12-3.
Figure 12-3.
0 1 2 3 4 5 6 7 8 9 10 11
303
second color (the third Workbench color) as black, and the third
color (the fourth Workbench color) as orange. Later, when you recall
the sprite back to the screen in an Amiga BASIC program, the
sprite appears with those colors.
The Amiga uses color registers 17 through 19 to store the colors
of the first two sprites on the screen, color registers 21 through 23 for
the next two sprites, color registers 25 to 27 for the next two sprites,
and color registers 29 to 31 for the last two sprites. When BASIC
loads a sprite from disk, it assigns the colors stored with the sprite
to the color registers that sprite will use, changing any colors that
might already be there. If you're using a screen with 16 colors or
less, this has no effect on the screen colors. If you're using a 32-
color screen, the colors on the screen that use the same color
registers as the sprite uses will change as soon as a sprite appears.
If you want to create sprites with colors other than turquoise,
black, and orange, you can list the section of the Object Editor
titled SaveFile: and change the 20th, 21st and 22nd lines of the
section. These lines assign three hexadecimal RGB values to the
sprite disk file, one for each color of the sprite. The value in
parentheses following MKIS on each line contains a three digit
hexadecimal number (preceded by an "&H") that specifies the
amount of red, green, and blue that sprite color will contain. The
first digit of each number (the one on the left) is the red value, the
second digit of each number is the green value, and the third digit
of each number is the blue value of that sprite color. Each digit
represents the proportion, or strength, of that color on a scale of
0 to 15 (which, in hexadecimal, is 0 to F), so a value of FFF would
produce a white color (all three colors at maximum strength),
and a value of 000 would produce a black color (all three colors
"turned off").
WINDOW SIZE
Any objects and playfield drawings you create have to appear in
a window You can use any type and size of window as your output
window, but to make the most of the animation, you should have
plenty of room for the objects to move around. A type 0 window
a full-screen window with no title bar, gadgets, or window
refreshgives you the most room to work with. It also keeps the
window from being resized or dragged, activities that interfere
temporarily with animation in the window.
SECTION 4: ANIMATION
304
As an example, the following statements create a playfield for
animation statements you'll use later in the chapter. The SCREEN
statement creates a mode 1 screen that is five bit planes deep. The
WINDOW statement creates a type 0 window without a title bar on
the screen to serve as the playfield. The following FOR.. .NEXT loop
creates 50 boxes of random colors and sizes to create an interesting
background in the playfield:
Na IcePlayf 1 e Ic
NINDOW 2, .,0,1
FDR 1 = 1 TD 50
xl = INTfWiNDOW(2) RND)
x2 - INT(WIND0W(2) RND)
yi = INT(WINDOW(3) RND)
y2 - INT(W!ND0W(3) RND)
LINE (xl,yl) - (x2, y2) , INT(32 RND) , B
NEXT i
Figure 12-4.
A mode 1 playfield.
305
PUTTING OBJECTS ON THE PLAYFIELD
AND MOVING THEM
SECTION 4: ANIMATION
306
themselves, since the individual statements need to work with
other statements to create and move objects. To make the ex
amples work, you must add them to other program sections to
create a complete program, and then run the program. The
instructions preceding each program example will tell you how
to combine the sections together into a complete program that
you can run.
OBJECT.SHAPE 1, INPUT$(LDF(1),1)
CLOSE 1
307
In the first line, the OPEN statement opens a channel of com
munication numbered "1" between the disk file and the Amiga's
memory. In the second line, OBJECT.SHAPE creates an object
numbered 1 using the string created by the INPUTS statement.
The INPUTS statement creates the string by reading all the way to
the end of the file (found by LOF(l)) that's open on communication
channel 1. The third line closes communication channel 1. If you'd
like more information about OPEN, CLOSE, INPUTS, and LOFQ,
consult the Amiga BASIC manual.
SECTION 4. ANIMATION
308
You should also keep in mind that objects created by the Object
Editor will automatically be stored in the drawer containing the
Object Editor unless you specify otherwise using a pathname. To
avoid confusion, you should always copy your objects into the
drawer you intend to use them from immediately after you quit the
Object Editor.
To make some objects for your example program, add the follow
ing program section to the playfield example you typed in earlier.
(These object filenames assume your objects are in the same
drawer as your program.) This program section, which is named
MakeObjects, creates three objects numbered 1, 2, and 3 in the
Amiga's memory:
Mak eOb]ects:
OBJECT.SHAPE 1, INPUTt(LOF(1), I)
CLOSE 1
OBJECT.SHAPE 2, INPUT$(LDF(1), 1)
CLDSE 1
CLOSE 1
309
Figure 12-5. Reference for OBJECT.X and OBJECT.Y
With this in mind, you should try to create objects in the Object
Editor as close to the upper left corner of the drawing area as
possible. This makes positioning the object easier and more
accurate, especially if the object is much smaller than the drawing
area. Don't worry about the invisible boundary interfering with the
way objects collide-Amiga BASIC uses the boundary only to
position the object. It ignores the boundary when objects collide,
and pays attention only to the non-background pixels in the object.
To position an object using OBJECT.X and OBJECT.Y, find the
address of the pixel on the playfield where you want to position the
upper left corner of the object's boundary. Then follow OBJECT.X
with the ID number of the object and the x (horizontal) coordinate
of the pixel address, then foDow OBJECT.Y with the ID number of
the object and the y (vertical) coordinate of the pixel address. For
example, to position the upper left corner of object 1 on pixel (34.50),
use these two statements;
OBJECT.X 1, 34
OBJECT.Y 1, 50
SECTION 4: ANIMATION
310
It's also possible to position an object entirely outside the
boundaries of the window you're using as a playfield. If you use x
and y coordinates beyond the range of the window, the object will
be positioned beyond the window boundaries. For example,
OBJECT.X 1, 1028
OBJECT.Y 1, 50
would put the object far off the right side of the window, even if it
was a full-width mode 4 window with 640 pixels across.
To position the three objects you made earlier for the example
program, add this program section at the end of the program;
PlaceObj ects:
OBJECT.X 1 , 0: OBJECT.Y 1 , 0
311
If you follow OBJECT.ON with one or more object ID numbers,
only the objects you specify will become visible on the playfield.
Unspecified objects will remain invisible. For example, the
statement
OBJECT.DN 3
OBJECT.DN
To see the objects, try running the program. You should see the
objects appear where you positioned them, as shown below in
Figure 12-6.
Figure 12-6.
SECTION 4: ANIMATION
312
The object ID number is any of the ID numbers used by earlier
OBJECT.SHAPE statements in the program to create objects. The x
and y velocities can be any integers from -32768 to +32767.
The x and y velocities measure the speed of the object m pixels
per second. The x veiocity measures the horizontal speed, and the
y veiocity measures the vertical speed. A positive x veiocity value
moves the object right, and a negative x veiocity value moves the
object left. A positive y velocity value moves the object down, and
a negative y velocity value moves the object up. For example,
OBJECT.VX 1, 23
DBJECT.VY 1, 42
OBJECT.VX 1, -52
OBJECT.VY 1, -4
Figure 12-7.
313
Direction of object
Keep in mind as you set an object's direction with x and y
velocity values that the proportions of the individual pixels in the
screen are an important factor in figuring the final direction of the
object. For example, an x velocity of 5 and an equal y velocity of 5
in a mode 1 screen will move the object at a 45-degree diagonal.
The same velocities in a mode 2 screen will move the object, at
approximately a 30-degree diagonal: The pixels are half as wide as
they are high, so 5 pixels down per second is twice the distance of
5 pixels to the right. On a mode 3 screen, x and y velocities of 5 will
move the object at approximately a 60-degree angle: The pixels are
half as high as they are wide, so 5 pixels to the right per second is
twice the distance of 5 pixels down. Figure 12-8 illustrates this.
Figure 12-8. x = 5 =b
\ \
Mode 1 pixels Mode 2 pixels Mode 3 pixels
MoveObjecta:
OBJECT.VX 2, 0: OBJECT.VY 2, 10
SECTION 4: ANIMATION
314
These three program lines move object 1 diagonally down and to
the right at a 45-degree angle, object 2 straight down, and object 3
quickly from left to right across the playfield.
OBJECT.START
If you want to see how the program works now, add this one-line
program section at the end of the program and run it:
315
THE OBJECT.AX AND OBJECT.AY STATEMENTS
After setting an object's velocity and moving it with
OBJECT.START, it moves in one direction at a steady speed. To
change an object's direction and speed, you can use the
OBJECT.AX and OBJECT.AY statements. They use these formats:
OBJECT.AX 2, -2
OBJECT.AY 2, -5
x velocity y velocity
Start speed: 25 25
1 second: 23 20
2 seconds: 7A 15
3 seconds: 19 10
4 seconds: 17 5
5 seconds: 1', o
6 seconds: 13 5
7 seconds: 11 -10
8 seconds: (i -15
9 seconds: 7 -20
10 seconds: 5 - 25
SECTION 4: ANIMATION
316
After 10 seconds, the object has curved to change its direction
up and a little to the right.
By applying acceleration changes to the straight directions you
set with OBJECTVX and OBJECT.VY, you can move your object in
some very interesting curves. Experiment to see what you can do!
To add some interesting acceleration to your example program,
run the program after adding this short program section just before
the Loop; section at the end of the program:
ChangeMotion:
OBJECT.AV 3, -2
You should see object 3 curve up toward the top of the screen.
S t opObjec t:
OBJECT.STOP 2
The FOR.. NEXT loop makes the program wait so object 2 can
move partially down the screen before it's stopped by the
OBJECT.STOP statement.
317
OBJECT.OFF automatically stops the motion of each object it
makes disappear. An object can't move while it's invisible, unless
you assign it a new location with the OBJEGT.X and OBJECT.Y
statements. If you don't change the object's location before you use
OBJECT.ON to make the object reappear, the object will reappear
and resume moving from exactly the same location where it
disappeared.
To see how OBJECT.OFF works, replace the StopObject: section
of your example program with the following section, and then run
the program;
Bl inkObj ects:
OBJECT.OFF
OBJECT.ON
The first FOR.. .NEXT loop lets the objects move normally for a
while. When the loop is finished, you should see all the objects in
motion disappear briefly while the second FOR.. .NEXT loop
executes, and then reappear in the same spot they disappeared,
resuming their previous motion.
SECTION 4: ANIMATION
318
endless loop to keep the animation moving, the user has to use the
Stop command in the Run menu to stop the program, so there's no
possibility of closing the objects within the program. After stop
ping the program, you can use OBJECT.CLOSE as an immediate
command in the Output window, but this doesn't provide the user
with an efficient means of clearing memory. It's even better to
create an alternative way for the user to quit the program, so the
program can finish up by closing screens and windows and
clearing objects from memory.
If you write animation programs that use many objects, you can
save memory and work by duplicating existing objects. You can use
the OBJECT.SHAPE statement to duplicate any object already in
memory, and then use the OBJECTPLANES statement to change the
colors of either the original or the duplicate objects.
319
the original object. However, if you close the original object, the
duplicate objects will freeze in their tracks and refuse to respond to
any statement that asks them to move or change location, so avoid
closing an original object before you close its duplicates.
The following program creates a playfield and uses the
OBJECT.SHAPE statement to make three duplicates of an original
object. It places the four objects in the four corners of the playfield,
and moves them toward the center of the playfield:
PlayField:
WINDOW 2, , , 0, 1
Mak eOrlginal:
OBJECT.SHAPE 1, 1NPUT$(LDF(1), 1)
CLOSE 1
Malt eDupl i ca t es :
FOR l = 2 TD 4
OBJECT.SHAPE i, 1
NEXT l
PlaceDbj ects:
OBJECT.ON
MoveQb j ec t 5 :
OBJECT.STflRT
PlaneOnOff value
SECTION 4: ANIMATION
320
The object ID number can specify any object already created
with the OBJECT.SHAPE statement, whether it's an original or a
duplicate object. The PlanePick and PlaneOnOff values can be any
integers from 0 to 31 in a 5-bit-plane screen, 0 to 15 in a 4-bit-plane
screen, 0 to 7 in a 3-bit-plane screen, and 0 to 3 in a 2-bit-plane
screen. The OBJECTPLANES statement has no practical effect on a
1-bit-plane screen. You can omit either the PlanePick value or the
PlaneOnOff value, in which case they're set to 0, but you can't omit
both. If you omit the PlanePick value, be sure to hold its place with
a comma.
* To set a bob back to its original colors, set the PlanePick and
PlaneOnOff values at 0.
SECTION 4: ANIMATION
322
Setting PlanePick and PlaneOnOff values
What follows are tables of PlanePick and PlaneOnOff values for
bobs of different bit-plane depths. These tables are designed to
reduce your trial and error time, as the values they contain have
been calculated to produce meaningful results. The PlanePick
values in the table won't decrease the number of colors in the bob,
and the table's PlaneOnOff values will change the colors set by the
PlanePick value.
1-bit-plane bobs
...in a 1 0, 2
2-bit-plane 2 0, 1
screen
...in a 1 0,2,4 ,6
3-bit-plane 2 0, 1,4 , 5
screen 4 0, 1,2 , 3
323
2-bit-plane bobs
...in a 3 0, 4
3-bit-plane 5 0, 2
screen 6 0, 1
...in a 3 0, 4, 8, 12
4-bit-plane 5 0, 2, 8, 10
screen 6 0, 1,8, 9
9 0, 2, 4, 6
10 0, 1. 4, 5
12 0. 1,2, 3
3-bit-plane bobs
...in a 7 0, 8
4-bit-plane 11 0,4
screen 13 0, 2
14 0, 1
...in a 7 0, 8. 16. 24
5-bit-plane n 0, 4, 16, 20
screen 13 0, 2, 16, 18
14 0, 1, 16, 17
19 0, 4, 8, 12
21 0, 2, 8, 10
22 0, 1, 8, 9
25 0, 2, 4, 6
26 0, 1,4, 5
28 0, 1, 2, 3
SECTION 4: ANIMATION
324
4-bit-plane bobs
...in a 15 0, 16
5-bit-plane 23 0, 8
screen 27 0.4
29 0, 2
30 0, 1
An OBJECT.PLANES example
The best way to use these different values is to find the table of
values for the bob and screen you're working with. Plug the
different values into the OBJECT.PLANES statement and run the
program to see what colors you come up with. Trial and error will
eventually find the colors you want. For example, the following
program section uses three of the sets of values that change the
color of three 3-bit-plane bobs in a 5-bit-plane screen:
Co 1orBob5:
OBJECT.PLANES 2, 19, 8
OBJECT.PLANES 3, 19, 0
OBJECT.PLANES 1, 14, 1
325
CHAPTER THIRTEEN
AMIGA BASIC
ANIMATION:
CONTROLLING
MOTION
In the last chapter, you put objects on a playfield,
instructed them to move, and watched them move like
drifting boats until you stopped them or until they ran into
another object or the playfield border. Amiga BASIC can
control moving objects with much more finesse than that.
By constantly checking the position and speed of each
object, BASIC can tell when the object reaches a desired {or
undesired) location or speed, and can then take appropriate
actions. By checking to see if any of the objects collide with
another object or the playfield border, it can act on the
collision to let one object pass over another, make the
object change direction, remove it from the playfield, or
perform any number of other actions.
In this chapter, you'll learn how to use the Amiga BASIC
animation statements that check and control motion and
collisions, and you'll see how to put the statements
together to make objects move with rhyme and reason.
You'll also find out how to control which object passes over
another object to create 2Y2-D animation, and how to avoid
collisions between objects. The end of the chapter has
information about interesting miscellaneous animation
abilities of Amiga BASIC: how to scroll a section of the
playfield, and how to use the PUT and GET statements to
create true sequeneed-image animation.
SECTION 4: ANIMATION
328
also use OBJECT-CLIP to create motion boundaries that are beyond
the borders of the output window so objects can move beyond the
window borders, out of sight, before they hit a boundary.
The corner addresses are like the standard pixel addresses you
use with drawing statements, except that the x and y coordinates
can be any integer from -32768 to +32767, making addresses
located outside of the output window like (-1045,73) possible. Like
the two addresses used to create a box with the LINE statement,
these two corner addresses set the location of two opposing corners
of a rectangle.
Any objects moving within the OBJECT.CLIP rectangle will move
until they collide with one of its sides or another object. Any ob
jects located outside the rectangle won't move even if they're given
an OBJECT START command.
In the following program example, the OBJECT.CLIP statement
creates an invisible rectangle in the middle of the screen. When you
run the program, an object is positioned within the rectangle and
instructed to move until it is stopped by one of the boundaries.
Figure 13-1 fon the next page) shows you how it works.
MakePlayfleld:
WINDOW 2, , , 0, 1
MakeObject:
OBJECT.SHAPE 1, INPUT$(LDF(1), 1)
CLOSE 1
MoveDbj ec t:
OBJECT.VX 1, 25
OBJECT.CLIP(50,50) - (250,150)
OBJECT.ON
OBJECT.START
329
Figure 13-1. (50,50) Object stops here
An object is stopped by
boundaries set by the
OBJECT CUP statement.
To get more control over moving objects than you can get with
OBJECT.CLIP, it's important for BASIC to be able to read the location
and velocity of each moving object at any moment. Amiga BASIC
has four functions that return the x and y coordinates and the x and
y velocities of any object on the playfield. You can write a BASIC
program to test the values the functions return, and then act
accordingly.
DBJECT.X(object ID number)
SECTION 4: ANIMATION
330
Don't confuse these two functions with the OBJECT.X and
OBJECT.Y statements you read about in the last chapter. The
functions here use parentheses around the object ID number and
don't include coordinate valuesthis is what distinguishes them
as functions, not statements. The object ID number is the ID
number of any object created previously in the program by an
OBJECT.SHAPE statement.
OBJECT. X() and OBJECT. Y() return the x and y coordinates of the
pixel address of the upper left corner of the object's rectangular
boundary. (See the description of the OBJECT.X and OBJECT.Y
statements in Chapter 12 for more information about how the upper
left corner of an object's boundary is determined.} OBJECT.XQ
returns the x (horizontal) coordinate, OBJECT.Y() returns the y
(vertical) coordinate.
Since OBJECT.XO and OBJECT.Yf) are functions that don't actually
perform any task when used alone in a program line, they must be
used as a value assigned to a variable or used within a statement
in a program line. For example, the following two program lines
assign the x and y coordinates of object 3 to the variables x3 and y3:
x3 - OBJECT.X(3)
y3 = OBJECT.Y(3]
OBJECT.VX(object IDnumber)
OBJECT.VY(object ID number)
331
Like OBJECT.XO and OBJECT.Y{), OBJECT.VXO and OBJECT.VY()
are functions, so they can't be used alone in a program line. They
must be assigned to a variable or used as a value with another
statement. For example, the following two program lines use the
OBJECT.VXO and OBJECT.VYO functions to read the x and y
velocities of object 2, and use the OBJECT.VX and OBJECT.VY
statements to assign them as the velocities for object number 3:
OBJECT.VX 3, OBJECT.VX(2)
OBJECT.VY 3, OBJECT.VY(2)
MalcePlayf leld:
WINDOW 2, , , 0 , 1
MafceObj ecta :
OBJECT.SHAPE 1, INPUT$(LOF(1), 1}
CLOSE 1
OBJECT.SHAPE 3, INPUTS(LOF(1), 1)
CLOSE 1
PlaceObj ecta:
OBJECT.X 1, 0: OBJECT.Y 1, 0
OBJECT.DN
(continued)
SECTION 4: ANIMATION
332
MoveObj ec 15 :
OBJECT.START
Tes t :
Stopi:
OBJECT.STOP 1
RETURN
Steady3:
DBJECT.AX 3, 0
RETURN
333
some other action in the event of a collision. With the OBJECT.HIT
statement, you can ask BASIC to ignore a collision, in which case
the objects will just pass each other. You use the OBJECT.PRIORITY
statement to tell BASIC which object should appear on top as they
pass. If you do allow objects to collide, you can use the COLLISION
ON and ON COLLISION GOSUB statements with the COLUSIONO
function to control how the objects react when they collide.
SECTION 4: ANIMATION
334
If you want an object to be defined as just one object type, use
the value for that one type as the type value. For example, to define
an object as just a type 16 object, you use a type value of -32768. If
you use a type value of 0, you tell BASIC that the specified object
isn't any of the 16 types. If you want to define an object as all 16
object types, you use the type value of -1, which is the sum of all
16 values in the table.
The hit value is a number that identifies all the types of objects
that an object can collide with. When an object touches a second
object in the playfield, BASIC checks the first object's type value to
see what type (or types) of object it is. It then checks the second
object's hit value to see what types of objects it's supposed to col
lide with. If the first object is on the second object's hit list, BASIC
registers a collision between the two objects. If the first object isn't
on the hit list, the two objects pass by without collision.
The hit value uses the same table of values that the type value
uses. To set the hit value, you choose the type or types of objects
you want to put on the hit list, find their values, then add them
together to get the hit value. If you don't want any types of objects
or the boundaries on the hit list, then use a hit value of 0. If you
want all types of objects on the hit list, then use a hit value of -1.
If you want only boundaries on the hit list, then use a hit value of 1.
When two objects touch on the playfield, it's important for BASIC
to determine which is the fust object and which is the second
object, since BASIC must match the hit value of the first object
against the type value of the second object. The rule of collision is
that the object that is the upper leftmost of the two objects is the
first object. If you want to define an object that won't collide with
any other object on the playfieid, you have to assign it a type value
of 0 and a hit value of 0 or 1, since you can never be sure if it wiil be
the first object that BASIC checks for type, or the second object that
BASIC checks for a hit list.
When an object hits a boundary BASIC always checks the hit list
of the object. The boundary has no hit list itself. It has only a type
value of 1.
As an example, think of a simple animation with three types of
moving objects: bees, flowers waving in the wind, and birds. Bees
shouldn't collide with other bees and birds, but should collide with
flowers so they can stop for nectar. Birds shouldn't collide with
any of the three types of objects., and flowers shouldn't collide with
other flowers or birds, but should collide with bees.
If you decide that bees are object type 2, birds are object type 3,
and flowers are object type 4, then you can assign type and hit
values for the objects. Bees should have a type value of 2 and a hit
335
value of 9. so they can hit both flowers (8) and boundaries (1). Birds
should have a type value of 4. and a hit value of 1, so they can col
lide with boundaries, but not anything else. Flowers should have a
type value of 8 and a hit value of 3. so they can collide with bees
(2) and boundaries (1).
The following simple example program puts one bee, one bird,
and one flower in motion on the playfield. using those type and hit
values. This example uses the sprites and bobs that you drew in
Chapter 12. When you run it, you should see the bee (object 1) move
diagonally across the screen, while the bird (object 2) and the
flower (object 3} move horizontally across the screen. The bee will
pass over the bird and stop when it collides with the flower. Figure
13-3 illustrates the objects' actions.
MakePlayfleld:
WINDDN 2, , , 0, 1
MafceObjects:
OBJECT.SHAPE 1, I NPUTS(LDF(1) , 1)
CLOSE 1
OBJECT.SHAPE 2, INPUTi(LOF(1}, 1)
CLOSE 1
OBJECT.SHAPE 3, 1 NPUTtfLOF(1 ) , 1)
CLOSE 1
PlaceObj ects:
OBJECT.X 1, 0: OBJECT.Y 1, 0
OBJECT.X 2, 0: OBJECT.Y 2, 75
OBJECT.ON
I dent ifyObjects:
OBJECT.HIT 1,2,9
OBJECT.HIT 2,4,1
OBJECT.HIT 3, 8, 3
MoveObj ectsNew:
OBJECT.VX 2, 20
OBJECT.VX 3, 20
OBJECT.START
SECTION 4: ANIMATION
336
Bee passes over bird Figure 13-3.
Using OBJECT.HIT to
define different types of
objects enables a bee to
pass over a bird and col
lide with a flower.
337
then add this program section just before the MoveObjectsNew:
section of the last example, when you run the program the robot
will pass under the bird instead of over it, because the robot's
priority is lower than the bird's:
OBJECT.PRIORITY 1, 0
OBJECT.PRIORITY 2 , 10
COLLISION ON
SECTION 4: ANIMATION
338
statement, it looks at the collision queue to see if any collisions
have occurred. If there are no collisions, BASIC keeps executing
more program statements just as it would normally. If a collision
occurs, BASIC immediately jumps to the beginning of the sub
routine you specified in the ON COLLISION GOSUB statement,
executes it, and then returns to execute the statement that follows
the last statement it executed before it detected the collision.
If you want to turn off the ON COLLISION GOSUB statement so
that BASIC won't jump to a subroutine for every collision that
occurs, use:
DN COLLISION GDSUB 0
COLLISiaH(ID number)
339
indicates which of the four boundaries has been hit. Those
four boundary ID numbers are:
BOUNDARY ID NUMBER
Top: -1
Left: -2
Bottom:
Right: -4
The collision queue stores collisions in the order they occur; that
is, the first collision in the queue is the collision that occurred
before all the other collisions; the last collision in the queue is the
most recent collision. Figure 13-4 shows how this works.
SECTION 4: ANIMATION
340
another space open for a collision at the end of the gueue. If
COLLISIONO finds no collision m the gueue involving the specified
object, it returns a 0 and doesn't alter the contents of the queue.
To give you an idea of how COLLISIONO works, consider this
example. Three successive collisions occur on a playfield while the
collision queue is turned on: Object 2 collides with object 1, object
4 collides with the left boundary, and object 3 collides with object 1.
If you use
PRINT CQLLISIDN(D)
PRINT CDLLISIDN(2}
PRINT CDLLISIDNJ1)
CDLL1SION(4)
341
move away from what they hit. The second line of the subroutine
gets the object number of the first object in the first collision and
stores it in the variable objectid The third line checks it to see if
there actually has been a coUisionif there hasn't, it returns
program execution to the Loop: section, which is an endless loop
that loops until a collision occurs. The fourth line of CheckCollision:
reads the ID number of the object that was hit in the first collision
in the queue, and assigns it to the variable hitobject.
The next two lines of the subroutine check to see if the object
has hit the upper or lower boundary f -1 or - 3), and if it has,
reverses the vertical motion of the object. Lines 7 and 8 check to
see if the object has hit the left or right boundary (- 2 or - 4), and
reverses the horizontal motion of the object if it has. Lines 9, 10, and
11 assume that if the object hasn't hit any boundaries, it must have
hit another object. They reverse the vertical and horizontal motion
of both objects involved in the collision.
The OBJECT.START statement toward the end of the subroutine
starts the colliding object or objects in motion again, since BASIC
automatically stops them when they collide. The last line of the
subroutine returns program execution to the Loop: section of
the program.
MakePlayfield:
WINDOW 2, , , 0, 1
Malt eDbj ec 15 :
CLOSE 1
OBJECT.SHAPE 2, 1NPUT$(LQF(1) , 1)
CLOSE 1
OBJECT.SHAPE 3, 1NPUT$(LOF(1), 1)
CLOSE 1
PlaceObj ects :
OBJECT.X 1, 0: OBJECT. Y 1 , 0
OBJECT.DN
(continued)
SECTION 4: ANIMATION
342
MoveDbj ec t 5:
COLLISION ON
hitobject - COLLISiaN(objectid)
OBJECT.START
RETURN
COLLISION STOP
343
THE COLLISION OFF STATEMENT
The COLLISION OFF statement turns off the collision queue
entirely. It uses this format:
COLLISION OFF
The corner addresses are the same as the corner addresses you
use with the OBJECTCLIP statement. The x and y coordinates can
be any integer from - 32768 to + 32767, making addresses like
(-1045,78} possible. These two addresses set the location of two
opposing corners of a scrolling rectangle. The x shift and y shift are
each integers from - 32768 to + 32767. You can use just an x-shift,
or just a y-shift, but if you omit the x-shift value, be sure to hold its
place with a comma.
The two corner addresses set the opposing corners of a rect
angular area on the output window. You can use them to create a
scrolling rectangle within the output window that's smaller than
the window, or to create a scrolling rectangle that covers the full
window. Although you can set addresses far outside the borders of
the output window you're using, any addresses outside the window
will be treated as if they're on the border of the window. For
example, if you create a scrolling rectangle with the corner
addresses (- 256, - 45) - (600,450) in a mode 1 window, you won't
actually create a scrolling rectangle larger than the window, you'll
create a rectangle the size of the full window.
SECTION 4: ANIMATION
344
The x-shift value specifies in pixels how far you want to
horizontally move the contents of the scroll rectangle. A positive
number means you want to move the contents to the right, a
negative number specifies a shift to the left. The y-shift value
specifies in pixels how far you want to vertically move the contents
of the scroll rectangle. A positive number specifies a shift down, a
negative number specifies a shift up. By using the two values
together in a SCROLL statement, you can create a diagonal shift.
For example, this statement shifts the contents of a scroll rectangle
in the upper left corner of the output window, moving them 20
pixels to the right and 30 pixels down:
Figure 13-5.
A single SCROLL statement does not actually scroll the contents picture shows the win
of the scroll rectangle. It shifts them in one instantaneous motion. dow after the last
To achieve a smooth scrolling effect, you need to use several SCROLL statement.
345
For example, the following program creates a background, then
scrolls a section of the background diagonally back and forth using
FOR. ..NEXT loops:
MakePiayfleld:
SCREEN 1, 320, 200, 5, 1
WINDON 2, . . 0, 1
FillText:
WIDTH "10
FOR i = 1 TO 100
Scr-ol IBlock :
FOR i = 1 TO 15
FOR i - 1 TD 1S
NEXT i
GOTO ScrollBloct
SECTION 4: ANIMATION
346
moving individual sprites and bobs can be tricky; it requires
keeping track of the location and movement of many separate
objects on the playfield at once. Using sequential-animation
techniques provided by the PUT statement makes the job easier.
Chapter 6 explains how GET and PUT can save a block of
graphics in a variable array and paste it elsewhere in the output
window. It also tells how to use GET to store a series of graphics
blocks in a two-dimensional array. If you store a series of blocks
containing continuous images, you can use PUT to sequentially
place those blocks on the screen, creating a moving object with in
ternal and external motion using sequential-animation techniques.
The following program uses GET to store four simple frames of a
bird flying. It then uses PUT in two FOR.. .NEXT loops to cycle
through the frames to make the bird look as if it's flying. Figure 13-6
(on the next page) shows the bird's motion.
Na k eW i ndow :
WINDOW 2, , , 0, 1
CreateArray:
DrawFrames:
frame = 0
CLS
f rame - 1
GDSLJB GetFrame
CL5
frame - 2
GDSUB GetFrame
CLS
frame - 3
GQSUB GetFrame
CLS
(continued)
347
x = o: y = o
SequenceFnames:
FDR i = 0 TD 3
NEXT i
FDR i = 2 TD 1 STEP -1
NEXT l
x=x+5: y = y + 5
GOTO SequenceFrames
GetFrame:
RETURN
Figure 13-6.
When you run the program, you'll see a brief flash in the center
of the window as it draws the four frames of a bird flying and saves
them with the GET statement. The stick bird (it is very simple) will
then appear in the upper left corner of the screen, flapping its
wings. As it flaps, it flies toward the lower right corner, and passes
beyond the output-window border.
To understand how the program works, take a look at its parts.
MakeWindow: creates a low-resolution, 2-bit-plane screen with a
full-sized window. CreateAnay: creates a two-dimensional array
named bird to hold the bird frames. The section that follows,
SECTION 4: ANIMATION
348
DrawFrames:, is divided into four parts, one for each frame of bird
flight. Each part sets a frame number, then draws the bird using
two simple LINE statements. It calls the subroutine GetFiame: that
saves the block containing the bird to the bird anay. It then clears
the screen for the next part.
The next section, SequenceFrames:, runs through the sequence
of frames to animate the bird. To initially position the bird, the line
before the SequenceFrames: section sets the x and y coordinates
for placing the PUT block equal to zero.
The two FOR.. .NEXT loops within the SequenceFrames: section
flap the bird's wings. The first loop flaps them down, the second
flaps them up. You'll notice that there are two identical PUT state
ments within each loop, separated by a small, nested FOR.. .NEXT
loop. The first PUT statement draws the bird's frame on Che screen.
The FOR.. NEXT loop pauses to keep the image on the screen. The
second PUT statement draws the same frame at the same location,
effectively erasing the bird's frame from the screen. (Recall that PUT
uses the XOR option by default to draw the frame. XORing the same
frame twice erases it completely. See Chapter 6 for the details.)
At the end of the two loops is a line that adds 5 to both the x and
y coordinates, which changes the PUT blocks location for each
loop, which makes the bird move down and to the right after
each wing-flap cycle. The next line loops the program back to
SequenceFrames:, which begins the wing-flap cycle over again.
There are advantages and disadvantages to this kind of animation.
It takes a lot of memory especially if you use a deep screen, a large
frame size, and many frames. It does flicker as you draw the
original frames, and it takes a lot of programming work to draw
frames that look more realistic than the stick bird you just saw.
Nevertheless, it does give you internal motion in an object that can
move around the screen. If you want to get rid of the initial drawing
flicker, you can draw the frames in one program and save them to
disk, then load them for the actual animation program. (You'll have
to spend some time getting familiar with the BASIC disk file
statements to do this.)
349
AFTERWORD
351
APPENDIX A: AMIGA BASIC
STATEMENT FORMATS
GRAPHICS
SCREEN
blue strength
CLS
354
DRAWING STATEMENTS
This statement colors the pixel at the specified address using the
color in the specified color register. If no color-register number is
specified, it uses the current foreground color.
This statement colors the pixel at the specified address using the
color in the specified color register. If no color-register number is
specified, it uses the current background color.
This statement draws a line from the starting address to the ending
address using the color in the specified color register. It can also
create filled or hollow boxes.
This statement draws a circle around the center address using the
specified radius and the color in the specified color register. It can
also draw ovals and arcs.
AREA (address)
color-register number
This statement creates line and fill patterns that are used when
line-drawing and fill statements put graphics in the output window.
355
LOCATE Jjne number, column number
This statement puts the text cursor at the specified line and
column positions.
:sri in
This function returns the line number of the text cursor's current
position.
POS(O)
This statement stores the pixels within the rectangle set by the
opposing corner addresses in the specified array.
This statement puts the pixels stored in the specified array in the
output window at the address specified, merging them with the
pixels they cover using the specified merge choice.
SOUND
MUSIC
BEEP
SOUND WAIT
356
SOUND RESUME
SPEECH
This function translates the text string and returns the phoneme
codes necessary for the SAY statement.
ANIMATION
357
OBJECT.START object id number, abject id number, . . .
This statement freezes the motion of the specified objects (or all
objects, if no object ID numbers are specified).
CONTROLLING OBJECTS
object id number
PlaneOnO-ff value
OBJECT.X(object id number)
OBJECT.Yfobject id number)
OBJECT.VX(object id number)
358
OBJECT.VYfobjec! id number)
This statement defines the object type of an object, and defines the
types of objects it can hit.
COLLISION ON
COLLISION/id number)
COLLISION STOP
COLLISION OFF
359
APPENDIX B: COMPANIES MENTIONED
IN THIS BOOK
360
AmigaDOS (Disk Operating System).
INDEX
21. 23
CLI commands, 23
Exec, 19-20
Page numbers for illustrations are
RAM. 21
in italics
Amplifier, 180
Amplitude (loudness), 176.
186.188
Aegis Animator. 264, 289- Animation. 252-325. See also
90, 351 Deluxe Video
Amiga BASIC, 23. 41, 45, 351 fundamentals, 252-62 (see also
Amiga BASIC, animation, 296-325. Illusion of motion;
See also Object Editor Perspective)
controlling motion, 328-49 (see IFF standard, 291
also Appendix A: specific interactive. 262. 267-68
statements and functions) internal motion, 26567
creating a motion boundary, 328- Anti-aliasing, 39
29 (see aiso OBJECT CLIP Area pattern, 138-41
statement) applying an area pattern. 13941
drawers, storing files in, putting the area pattern mask into
308-9 an integer array, 138-39
gels, 264 AREA statement, 129
handling object collisions, 333-44 AREAFILL statement, 130-32
(see also Appendix A; specific filling a shape with a
statements and functions) pattern, 132
placing and moving objects. 306 Array, musical scale. 233-35
19 (see a/so specific traditional music notation. 234
sta temen ts) Array, PUT and GET variable, 159-
playfields, 263-67, 301 64. See also PUT and GET
reading an object's location and statements
Index
361
B Commodore-Amiga, 79, 80
BEEP statement. 222 Component motion, 266-67
waveform of, 222 Console, 7, 7
Binary line mask, 136-37 custom chips, 9
Bit planes, 57. 95-96 internal disk drive, 10-11
Blend mode, 65. 70 memory chips, 10
creation of rainctouds, 77 motherboard, 8
Blitter, 48 Motorola 68000 microprocessor, 9
Bob, 301 power supply. 7-8
Brush modes, Deluxe Paint, 63-72 Creating precise drawings. 60-63
blend, 65 coordinates command and brush
blend to create rainclouds, 70 position. 60
color, 63-64 grid alignment. 61-63
cycle, 65 SHIFT key and drawing straight
object. 63 lines. 60-61
object and color to outline figures, Cycle mode, 65
66-67
replace, 64
shade,64
D
Deluxe Music, 23, 196-213
shade to create shadow, 71-72
capabilities, 198-206
smear. 64
recording, 209-12
smear to create sandy
special effects using Tascam
background. 68
Ministudio Porta One
text brush to create outlined
text, 67
recorder, 210-11
synchronizing scores, 211-12
tips, 208-9
use with MIDI, 206
Casio CZ-101 synthesizer, 218 Deluxe Paint, 23. 41, 45, 48. 49, 54-
Casio CZ-1000 synthesizer, 218 83. 263, 265. See also Brush
Character addressing, 144-45 modes; Color palette
line and column number choosing screen resolution and
ing, 145 depth. 56-57
CIRCLE statement, 124-29, 125 creating background and
circle measured in radians, 127 matching objects for
creating arcs, 126, 126 animation. 271-74
creating circles, 125 creating precise drawings and
creating ovals. 127-29 color-cycle animation, 274-79
CLI (Command Line Interpreter), 22, creating sequenced drawings for
74 animation, 279-85
CLS Statement, 119 creating a work disk, 55-56
COLLISION!) function, 339-41 photographing, 78
collision queue, 339. 340 printing Deluxe Paint pictures. 74-
COLLISION OFF statement, 344 78
COLLISION ON statement, 339-41 tricks, 73-74
COLLISION STOP statement. 343 Deluxe Video. 23, 45, 264
Color. 28-31 and Deluxe Paint, 271-85 (see also
HIS (Hue, Intensity, Saturation) Deluxe Paint)
creation, 30-31 blitter. 270, 275
primary, 28-29 color cycle. 274-79, 276, 277, 279
RGB creation, 29 library disks, 290
Color mode, 63-64. 66-67 making scripts readable, 286, 287
Color palette, 46-47, 107-12 recording onto videotape. 287-89
design, 57-59 sequential drawing. 279-85, 280,
HAM (Hold and Modify), 47 281, 282. 283
palette window, 58 synchronizing effects with sound,
picture using HAM mode for 285
shading, 47 Deluxe Video Framer, 279, 280. 282
range, 59 Deluxe Video Maker, 279, 283, 284
COLOR statement, 108-9 Denise (chip), 264
changing background color, 109 Direct Memory Access (DMA), 10-11
changing foreground color, 109 Drawing pictures, 48
with PRINT statement. 151-52 and Agnus chip. 48
storing color, 110 blitter, 48
Index
362
Duplicating objects. See Hardware, sound
OBJECT.SHAPE statement speakers, 215-16
Duration, 186. 187. 235 stereo, 15
and SOUND statement, 225 Hawkins, Trip, xi
Hexadecimal numbers. 136-37
E
Electronic Arts. 212. 270. 290 I
Exec, 19-20 Illusion of motion, 252-57, 253
and Kickstart disk. 19-20 background, 254-55
and ROM. 19 moving objects, 255-57
External disk drive, 16 Infinite loop, 122
Interlacing. 94
Intuition, 21, 45
F
user-interface routines, 21
Firmware. 10
Fonts, using different sizes, 145-46
Frequency (of sounds), 176 K
and SOUND statement, 223-25 Keyboard, 5-6, 6
Functions. See also Appendix A and
specific functions
Index
363
Multi-sided figure creation, 129-32. PATTERN statement, 135-41, 140.
132. See also AREA See also Area pattern, Lint*
statement; AREAFILL pattern
statement applying a line pattern. 137. 137
Musical score, playing. See Amiga changing pattern colors, 141
BASIC, sound conversion of binary line mask into
a hexadecimal number, 136-
37
N
and creation of line pattern. 136
NTSC (National Television Systems
Peripherals. 11, 14-17
Committee). 14
external disk drives, 16-17
external RAM. 17
impact dot-matrix printers. 15
Object Editor, 296-301 ink-jet printers, 15
drawing an object, 299-301, 300 laser printers, 16
modification of, 297-99 letter-quality printers, 15
Object mode, 63, 66-67 thermal-transfer printers, 15
OBJECT.AX statement, 316-17 Perspective, 257-62
OBJECT.AY statement. 316-17 three-dimensional. 258-60, 259,
OBJECT.CLIP statement, 329, 330 260
Index
364
PRINT statement.147
with COLOR statement. 151-52. SAY statement, 243-47. See also
152 Array, specification
Printers, 15, 16.81-82 examples. 246-47
Diablo C-150 and Xerox 4020, 82 phoneme codes, 241-42
Epson JX-80. 82 Screen (horizontal areas), 45
Okimate 20, 81 SCREEN CLOSE statement, 98
Printing SCREEN statement, 93-98
printer driver, 52, 74 conserving memory, 96
Printing Deluxe Paint pictures, 74- depth, 95-96
78. See also Preferences examples, 96-97
Printing video images five simultaneous screens, 97. 97
converting color to black and ID number, 93
white. 39-40.40 memory requirements, 96
fidelity, 37-38 mode 1 screen. 95, 95
printing in color, 40-41 resolution mode, 93-94
PSET statement, 119-22 width and height, 94-95
with trigonometric command, 121 Screens. 90-91. 93-98- See also
PUT statement. 164-65 SCREEN CLOSE statement;
array name and index. 164-65 SCREEN statement
merge choices, 165 67 title bar, 90. 91
sequential animation, 346-49. 348 SCROLL statement, 342
setting PUT address. 164 scrolling the playheld. 344. 345
Scrolling, 50
Sequenced drawings, 266
R Sequencer, 187
RAM {Random Access Memory), 10
Serial printer, 13
and animation storage, 291-92
Shade mode, 64. 71-72
and bit planes, 57 creation of shadow, 72
and fonts, 49
Sizing gadget, 118
and resolution. 44
Smear mode, 64, 68-69
and sequencers. 181 creation of sandy background. 69
and window refreshing, 102-3
Software, 17-23. 29. See also
and Workbench, 21 AmigaDOS; CL1 (Command
Recording, animation. 287-89 Line Interpreter); Exec;
quality. 288 Intuition; Libraries and
Recording, Deluxe Music scores, devices: Workbench
209-12 manufacturers (mentioned in text),
Recording, sound, 188-90 360-61
Replace mode, 64 Software, animation. See Aegis
Resolution Animator; Amiga BASIC,
affect on memory, 44-45 animation; Deluxe Video
animation, 302 Software, graphics, 79-80. See aJso
anti-aliasing, 39, 39 Amiga BASIC; Deluxe Paint
depth. 56-57 Aegis Images, 79
font size, 146, 147 Graphicraft, 79
"jaggies." 39, 38 IFF (Interchange File Format)
mixing. 45. 45 Graphics Standard. 80
picture using high-resolution Software, sound. See Amiga BASIC.
pixel. 44 sound; Deluxe Music
picture using low-resolution IFF music standard, 214
pixel. 43 Instant Music, 212
SCREEN statement, 93-94 Sound. See also MIDI; Recording;
Workbench display using 640- Sounds, electronic;
by-200 resolution screen, 42 Synthesized music;
RGB monitor. 5. 80-81 Synthesized speech
analog. 80-81 characteristics of, 176-78
controls of the Preferences and hearing. 174-76
program, 29 sampled, 185-87
digital, 80-81 samplers, 217
ROM (Read Only Memory), 10, 19 sine, square, and sawtooth
waves, 177
Index
365
Sound, synchronization. See Amiga V
BASIC, sound; SOUND Video-signal converter, 12
RESUME statement; SOUND Video Vision Associates Space
WAIT statement Archive laser disc, 294
SOUND RESUME statement, 228 Videotape, 36
SOUND statement, 223-28 Voltage-controlled oscillator (VCO).
choosing audio channel, 226 182
setting duration, 225 Volume, 235
setting frequency, 223-25, 224 and SOUND statement, 226
setting volume, 226
SOUND WAIT statement, 227-28
Sounds, electronic, 179-81 w
WAVE statement, 229-33. See also
Speakers, 179-80
Speech, generation, 238-47 {see Waveform table
specific statements
assigning to audio channel, 232-
33
Stereo, 180-81
Synthesized music, 181-87. See aJso calculation, 231-32
Sequencer; Synthesizers creation of. 229-30
Synthesizers
array, 230-31
WINDOW CLOSE statement, 106-7
analog, 182
WINDOW!) function, 153-57
digital, 182-87
digital-to-analog converter (D-to-A examples. 154-57. 155, 157, 158
Index
366
About the Author
A classical oboist by training, Michael Boom became involved with
computers in 1980, when he purchased an Atari 800. He is the
author of Understanding Atari Graphics, How to Use Atari
Computers, and How to Use the Commodore 64, all published as
Alfred Handy Guides. He has also written for Compute! magazine.
For the past two years, Michael has worked as a consultant in the
microcomputer field, including a year as the music consultant for
Commodore-Amiga. Michael Boom currently lives in Oakland,
California.
The manuscript for this book was prepared and submitted to
Microsoft Press in electronic form. Text files were processed and
formatted using Microsoft Word.