STOPWATCH

by Craig Patchett

As -you probably already know, the ATARI has a built-in, real-time clock (i.e. it keeps track of time while it's turned on). But what good is such a clock if you can't see it? STOPWATCH utilizes this clock in putting a real-time stopwatch on your screen, that works independently of BASIC!

CREATING A COPY OF STOPWATCH

Type and run one of the following programs, depending on whether you want a cassette or disk version. Be careful typing in the data, and make sure you save a copy of the program in case you find out later you made a mistake typing it in. Each of the programs when run will create a machine language copy of STOPWATCH on the medium you chose.

RUNNING THE CASSETTE VERSION

The cassette version of STOPWATCH (the copy you got from the previous step) loads and runs in the following manner.

1. Turn the computer and all peripherals off.
2. Insert the program cassette into the cassette player, rewind it, and press PLAY.
3. Turn the computer on while holding down the START button.
4. After the computer beeps, press RETURN.
5. The program will load; and then RUN automatically.

RUNNING THE DISK VERSION

The disk version of STOPWATCH loads and runs in the following manner.

1. Boot the disk containing the program.
2. Type "DOS" and press RETURN (you must have DOS 11)
3. When the DOS menu appears, type "L" and press RETURN.
4. Type "STOPWATCH, OBJ" in response the computer's request for a filename and press RETURN.
5. When the stopwatch appears on the screen and the "BUSY" light on the disk drive goes out, press SYSTEM RESET.

USING STOPWATCH

You should now have a running stopwatch in the top right-hand corner of your screen. If you don't make sure you followed the instructions correctly, and that you typed in the original BASIC program correctly.

Once you get the stopwatch working, you have the following options.

1. Ignore it (treat it as if it wasn't there)
2. Press START. This will stop the stopwatch if it was running, and start it if it wasn't.
3. If it's stopped, press SELECT. This will reset the stopwatch to 0:00:00.
4. Press SELECT. This will disengage the stopwatch if it was engaged, and engage it if it wasn't.

If STOPWATCH is disengaged, the ATARI will treat it just the same as if it were engaged except it will stop updating it on the screen. The best way to explain this is for you to try it yourself.

5. Press SYSTEM RESET. It has no effect on the stopwatch.

LIMITATIONS

STOPWATCH has the following minor limitations:

1. The ATARI will treat the stopwatch as if you had typed it there yourself. For example, position the cursor on the same line as the stopwatch and press RETURN. If this type of thing gets to be a problem, disengage it using the OPTION button.
2. If you try to use STOPWATCH in conjunction with other machine language routines or with the interface Module, you may run into problems. STOPWATCH uses almost all of page six in memory.
3. STOPWATCH will not work with OS/A= or BASIC A=
4. STOPWATCH will only count up to 9 hrs, 5 9 mins, 59 secs. If this is a problem, get some sleep instead!

Most of these limitations could be corrected by you (yes you) if you so desire and have the ability, but at the cost of having to use extra memory and probably having to relocate.

If you like, you can set STOPWATCH by changing the values of locations 1537 to 1541. Do this using POKE (experiment).

HOW IT WORKS

Below is an extensively commented source listing of the disk version of STOPWATCH, as well as the changes, necessary for the cassette version. Note that the run address is $60A hex = 1546 decimal.

The trick that lets the ATARI act as though the stopwatch isn't there is called vertical blank (VBLANK for short). Briefly, vertical blank is the time during which the electron beam that draws the screen is returning from the bottom of the screen to the top for another pass. Some of this time is available to the machine language programmer and is independent of regular processor time.

If you want to learn more about VBLANK, study the source listing and consult the Operating System User's Manual, which can be purchased from ATARI (part number CO16555).

Hopefully the source listing will, provide an informative introduction to machine language for all you novices out there.
Enjoy!