5: Utilities
Joystick Cursor Control
Jeff Brenner
This article will show you how to gain even more control of the Atari editing system. By using a joystick rather than the control-arrow keys, you can have instant, accurate cursor control.

This BASIC program contains a small machine language routine which will be stored in memory and executed during vertical blank. The vertical blank is the period of time between the drawing of the last line of the television screen and the movement of the electron beam to the top of the screen to begin drawing the first line. During this period, the machine language routine will be at work. Since the vertical blank occurs 60 times per second, the routine will be executed 60 times per second. The routine is executed so fast that there is no noticeable delay in computer operation.

The function of the routine is to change the joystick values into the control-arrow key codes and then store this new value in the register which the Atari uses to store keyboard data (764). Try this:

POKE 764,0

Because zero is the keyboard code (not ASCII, but an internal code) for the L character, the letter L will be displayed on the screen. The keyboard codes for the four direction keys and the corresponding joystick values follow:

CONTROL-Up=142 Joystick Up=14
CONTROL-Down=143 Joystick Down=13
CONTROL-Left=134 Joystick Left=11
CONTROL-Right=135 Joystick Right=7

Basically, here is how the program will work. Every 1/60th of a second, the routine will check the joystick port. If the joystick has been moved up, down, left, or right, then a direction code, corresponding to the position of the joystick, is stored in location 764. The Atari will then automatically display its character for that code. In addition, a counter will be used to determine when a direction should be repeated. If the joystick is held to one position for several seconds, that direction will repeat just the way it would on a keyboard. If the joystick trigger is held down as well, the direction will repeat extra fast. Thus the joystick merely replaces the control and direction keys, and is best suited for use as a programming aid.

Joystick Cursor Control
10 DATA 104,162,6,160,147,169,7,32,92,228,169,0,133,204,133,205,133,206,96,173,120,2,201,15,240,24
20 DATA 197,205,240,48,133,205,201,14,240,23,201,13,240,23,201,11,240,23,201,7,240,23,208,6,169,0
30 DATA 133,204,133,205,76,98,228,169,142,208,10,169,143,208,6,169,134,208,2,169,135,141,252,2,208,234
40 DATA 166,204,240,9,166,206,240,13,198,206,76,98,228,169,40,133,206,133,204,208,213,162,5,134,206,174
50 DATA 132,2,208,180,162,1,134,206,208,174,0,-1
60 I=0:C=0:RESTORE 10
70 READ N:C=C+N:IF N=-1 THEN 90
80 POKE 1664+I,N:I=I+1:GOTO 70
90 IF C=15702 THEN A=USR(1664):STOP 

Listing. Joystick Cursor Control.
Download (Saved BASIC) / Download (Listed BASIC)

Return to Table of Contents | Previous Section | Next Section