[ Main : Compilers : 5200BAS : Commands ]

5200BAS Command Reference

Index

label:   '   :   }   ASM   ATTRACT   AUTHOR   CHARSET   CLS   DATA   DEFINE   DIV8   DIV16   DLIST   DO   DOWN   END SUB   EXIT DO   EXIT FOR   EXIT SELECT   EXIT SUB   FOR   GOSUB   GOTO   IF   INKEY   INPUT   INTERNAL   JOYTRIG   JOYTRIG2   JOYX   JOYY   KEYPAD   LEFT   LOCATE   LOOP   MEMAREA   MEMCOPY   MISSILES   MOVEUP   MUL8   MULADD   NEXT   PALETTE   PEEK   POKE   POP   POS   PRINT   PUSH   PUT   RETURN   RIGHT   SCREEN   SELECT CASE   SET   SOUND   SPRITES   SUB   TITLE   UP   VOLUME



<text>:
v1.00a

Syntax
label:

Purpose
To specify a name for the current line.

Remarks
If a line needs a label, the label must be the first statement on the line, or alone on a line.

Spaces are permitted before the label.

Example
FREEZE:
GOTO FREEZE




' text
v1.00a

Syntax
'text comment

Purpose
Provides a place to put code comments.

Remarks
Comments can be placed either alone or after all other program statements on a line.

Examples
'my program.
A=RND 'get a random number




: Separator
v1.00a

Syntax
statement [:[statement]]

Purpose
To allow for more than one program statement per line

Remarks
Statements after an IF...THEN GOTO statement will be executed as if they were on the next program line.

Examples
A=N:A=A+20:N=A
IF A=29 THEN GOTO ABC:A=A+5 'the A=A+5 will be executed when A<>29
IF A>=30 THEN:N=0:END IF




} Statement
v1.10a

Syntax
}

Purpose
To move the cursor right one character and scroll the screen if needed.

Registers modified
A, X, Y

Included files
right.inc, chkrow.inc, pos.inc, mul8.inc, moveup.inc

Example
PRINT "HELLO, "}:PRINT "WORLD" 'prints HELLO, WORLD



ASM Commands
v1.10a

Commands

LDALDXLDYSTASTXSTYTAX
TAYTXATYATXSTSXJMPJSR
RTSCMPCPXCPYBNEBEQBMI
BPLBCCBCSBVCBVSADCSBC
ANDORAEORINCDECINXINY
DEXDEYRORROLLSRASLCLC
SECCLDSEDCLISEIBRKCLV
PHAPLAPHPPLPBRKBITRTI
NOP.ORG.END#INCLUDE.BYTE.WORD.TEXT

Purpose
To be able to include plain ASM statements in the code.

Remarks
Each ASM statement should be alone on the line. Use ; rather than ' for trailing comments.

Examples
CLI ;clear interrupt enable
.ORG $A000
#INCLUDE MYDATA.INC
.BYTE $00,$01,$02




ATTRACT Statement
v1.50

Syntax
ATTRACT

Purpose
To reset the attract mode timer. A good time to do this is after a key press or joystick movement.

Registers modified
A

Example
INPUT K:ATTRACT



AUTHOR Statement
v1.70

Syntax
AUTHOR " <text> "

Purpose
To set the scrolling ATARI screen game author & copyright message.

Remarks
Lowercase letters in <text> become capital letters and change colors. Capital letters remain capitals.

The copyright text can be a maximum of 20 characters in length.

Example
AUTHOR "(C) 2002 J. JOHNSTON"



CHARSET Statement
v1.10a

Syntax
CHARSET <16-bit memory address>

Purpose
To change the character set using the data at the specified memory address.

Remarks
This command only examines the high byte of the address. For example: $1234 becomes $12, $B000 becomes $B0, and $56 becomes $00 because it is interpreted as $0056.

Registers modified
A

Example
CHARSET $A400 'set character set location to page $A4



CLS Statement
v1.00a

Syntax
CLS

Purpose
To clear the screen.

Remarks
This command will only work properly for ANTIC 2 or 4 screens.

Registers modified
A,Y

Included files
cls.inc

Example
CLS 'clear the screen



DATA Statement (deprecated)
v1.00a

Syntax
DATA {CHAR | SPRITE} <list of constants>

Purpose
To store the numeric constants that are needed to build characters or sprites. This statement has been implemented, but there is no way to make use of the data collected. Use #INCLUDE or .BYTE instead.

Remarks
DATA statements are non-executable and may be placed anywhere in the program. A DATA statement may contain as many constants as will fit on a line (separated by commas). Any number of DATA statements may be used in a program. The data contained therein may be thought of as one continuous list of items, regardless of how many items are on a line or where the lines are placed in the program.

<list of constants> should only contain numbers in the range 0-255 decimal.



DEFINE Statement
v1.00a

Syntax
DEFINE <variable name>,<zero page memory address>
DEFINE <variable name>,<any memory address>v1.10a

Purpose
To create a label for a memory address that can be referenced by <variable name>.

Remarks
<variable name> must not be A, X, or Y.

Example
DEFINE COUNT,$FF



DIV8 Statement
v1.60

Syntax
DIV8

Operation
TEMPL remainder A=TEMPL/TEMPH

Purpose
To divide two 8 bit numbers and return an 8-bit result and remainder.

Remarks
To use DIV8, prepare the variables then issue the statement. The variables TEMPL and TEMPH represent the 8-bit numbers that will be used in the division.

Registers modified
A, X

Included files
div8.inc

Example
TEMPL=123:TEMPH=12:DIV8 '123/12, result: TEMPL=10 and A=3



DIV16 Statement
v1.60

Syntax
DIV16

Operation
TEMPH:TEMPL remainder A=TEMPH:TEMPL/FROML

Purpose
To divide a 16-bit number by an 8-bit number and return a 16-bit result and 8-bit remainder.

Remarks
To use DIV16, prepare the variables then issue the statement. The variables TEMPH and TEMPL represent the 16-bit number to be divided (dividend). FROML represents the divisor.

Registers modified
A, X

Included files
div16.inc

Example
TEMPH=$12:TEMPL=$34:FROML=$56:DIV16 '$1234/$56, result: TEMPH=$00, TEMPL=$36 and A=$10



DLIST Statement
v1.40

Syntax
DLIST <num>

Purpose
To switch to a new memory location for the display list.

Registers modified
A

Example
DLIST $A600



DO...LOOP Statements
v1.00a

Syntax
DO [ WHILE <expression> | UNTIL <expression> ]v1.60
DO_ [ WHILE <expression> | UNTIL <expression> ]v1.60
   [statement block]
   [EXIT DO]
   [statement block]
   [IF...THEN EXIT DO]
   [statement block]
LOOP [ WHILE <expression> | UNTIL <expression> ]v1.60
LOOP_ [ WHILE <expression> | UNTIL <expression> ]v1.60

Purpose
To allow a series of instructions to be performed in a loop an indefinite number of times.

Remarks
EXIT DO must only be used inside DO...LOOP. It can be used alone, or instead of GOTO in an IF statement. See the IF statement for a list of valid expressions.

Registers modified
none

Example
DO 'return a random number from 0 to 9.
  A=RND
  A=A AND 15
LOOP UNTIL A<10




DOWN Statement
v1.00a

Syntax
DOWN

Purpose
Moves the cursor down toward the bottom of the screen by one row.

Remarks
Assumes a 40-character line.

Registers modified
X

Included files
down.inc, right.inc

Example
PRINT "HI":DOWN:PRINT "THERE"

displays

HI
THERE




END IF Statement
v1.60
See IF...THEN statements.



END SUB, EXIT SUB Statements
v1.30
See SUB statement. END SUB replaces END DLI.



EXIT DO, EXIT FOR and EXIT SELECT Statements
v1.00a
See DO...LOOP, FOR...NEXT, or SELECT CASE statements.



FOR...NEXT Statements
v1.00a

Syntax
FOR <variable> TO <final>
  [statement block]
  [EXIT FOR]
  [statement block]
  [IF...THEN EXIT FOR]
  [statement block]
NEXT
FOR_ <variable> TO <final>v1.20

Purpose
To allow a series of instructions to be performed in a loop a given number of times.

Remarks
<variable> is used as a counter, and must not be A, X, or Y. It should contain the initial value of the counter. The program lines following the FOR statement are executed until the NEXT statement is encountered or until interrupted by EXIT FOR. Then the value of the counter is incremented by 1. A check is performed to see if the value of the counter is now greater than the final value <final>. If it is not greater, execution continues at the statement after the FOR statement and the process is repeated. If it is greater, or an EXIT FOR statement is encountered, execution continues with the statement following the NEXT statement. This is a FOR...NEXT loop.

<final> can be any variable, register, or number from 0-255. The register A is destroyed each time the FOR statement is executed.

The body of the loop is skipped if the initial value of <variable> is greater than <final>.

If the FOR loop is too large and generates an out of range error in the assembler, use FOR_ instead. FOR_ uses a JMP instruction to reach the target label, at the expense of a few bytes for an extra branch instruction.

Registers modified
A

Example
Z=65:FOR Z TO 90:PRINT CHR$(A):RIGHT:NEXT Z



GOSUB...RETURN Statements
v1.00a

Syntax
GOSUB <line label>
.
.
.
<line label>
[statement block]
RETURN

Purpose
To branch to, and return from, a subroutine

Remarks
<line label> in the GOSUB statement represents the first line of the subroutine.

A subroutine may be called any number of times in a program. A subroutine also may be called from within another subroutine. Such nesting of subroutines is limited only by available stack space.

Subroutines may appear anywhere in the program, but it is recommended that the subroutine be readily distinguishable from the main program.

Registers modified
none

Example
GOSUB ABC
...
ABC:
RETURN




GOTO Statement
v1.00a

Syntax
GOTO <line label>

Purpose
To branch unconditionally to a specified line label.

Remarks
If <line label> is an executable statement, that statement and those following are executed. If it is a non-executable statement, execution proceeds at the first executable statement encountered after <line label>.

Registers modified
none



IF...THEN Statements
v1.00a

Syntax
IF <expression> THEN {GOTO <line label> | EXIT DO | EXIT FOR | EXIT SELECT}
IF_ <expression> THEN {GOTO <line label> | EXIT DO | EXIT FOR | EXIT SELECT}v1.20
IF <expression> THENv1.60
IF_ <expression> THENv1.60
{IF | IF_} <expression> [AND <expression>] [OR <expression>] THENv1.91
   [statement block]
[ELSE]v1.60
[ELSE_]v1.60
   [statement block]
END IFv1.60

Purpose
To make a decision regarding program flow based on <expression>.

Remarks
If the test <expression> is true, then the THEN cause is executed. If the destination label is too far away and generates an out of range error in the assembler, use IF_ instead. IF_ uses a JMP instruction to reach the target label, at the expense of a few bytes for an extra branch instruction. Multiple AND and OR operators can be included, but parenthesis are not supported.

List of valid expressions:

ExpressionExplanation
A=NV=
A<>NV<>
A<NV<
A<=NV<= (slower, use < instead)
A>NV> (slower, use >= instead)
A>=NV>=
A<<NVsigned <
A>>=NVsigned >=
CFLAG=0BCC
CFLAG=1BCS
NFLAG=0BMI
NFLAG=1BPL
ZFLAG=0BNE
ZFLAG=1BEQ

For CFLAG, NFLAG, and ZFLAG the constants TRUE and FALSE can be used instead of 1 or 0.

Registers modified
none

Examples
IF A=123 THEN:X=X+1:END IF
IF_ X>=MYVAR THEN GOTO ABC
IF ZFLAG=TRUE THEN
END IF




INKEY Function
v1.10a

Syntax
A=INKEY

Purpose
To allow input from the keypad during program execution.

Remarks
Unlike INPUT, program execution does not pause. The register A is replaced by the keypad value.

Possible values returned in <variable>:
ValueKey
$000
$011
$022
$033
$044
$055
$066
$077
$088
$099
$0A*
$0B#
$0CStart
$0DPause
$0EReset
$FFNo key waiting

Registers modified
A, X, Y

Example
DO
  A=INKEY
  IF A=$0C THEN EXIT DO
LOOP




INPUT Statement
v1.00a

Syntax
INPUT <variable>

Purpose
To allow input from the keypad during program execution.

Remarks
When an INPUT statement is encountered, program execution pauses to wait for a keypress. When a key is pressed, the value of the key will be placed in <variable> and execution will continue.

See the INKEY function for possible values returned in <variable>. Note: $FF won't be returned by INPUT.

Registers modified
A, X, Y

Included files
input.inc

Example
DO
  INPUT A
  IF A=$0C THEN EXIT DO
LOOP




INTERNAL Statement
v1.40

Syntax
INTERNAL <number>

Purpose
To manually add an included file.

Remarks
Program statements will automatically include any needed support code. The internal procedures and numbers may change from version to version, so use of this statement should be considered a temporary solution at best. Contact me so that I can add a new instruction instead.

Included files
As requested by <number>

Example
INTERNAL 1 'Includes the CLS procedure in the source, even if CLS is never used.



JOYTRIG Function
v1.40

Syntax
AXY=JOYTRIG(number)

Purpose
Returns joystick bottom button (main button) status.

Remarks
The return value will be $01 while the bottom button is not being pressed and $00 when pressed.

Valid (number) entries:
ValueJoystick
$001
$012
$023
$034

Registers modified
A or X or Y

Example
A=JOYTRIG(0):IF A<>$01 THEN GOTO CLICK  'button pushed?
RETURN                                  'no, return from subroutine
CLICK:                                  'yes
A=JOYTRIG(0):IF A<>$01 THEN GOTO CLICK  'wait for button release




JOYTRIG2 Function
v1.92

Syntax
A=JOYTRIG2

Purpose
Returns joystick top button (secondary button) status.

Remarks
The return value will be $08 while the top button is not being pressed and $00 when pressed. Use the KEYPAD statement to select the joystick to be read.

Registers modified
A

Example
A=JOYTRIG2:IF ZFLAG=TRUE THEN   'button pushed?
  DO                            'yes
    A=JOYTRIG2                  'button pushed?
  LOOP UNTIL ZFLAG=FALSE        'loop until button released
  'click code goes here
END IF



JOYX Function
v1.10a

Syntax
AXY=JOYX(number)

Purpose
Returns joystick X reading.

Valid (number) entries:
ValueJoystick
$001
$012
$023
$034

Registers modified
A or X or Y

Example
A=JOYX(2)



JOYY Function
v1.10a

Syntax
AXY=JOYY(number)

Purpose
Returns joystick Y reading.

Valid (number) entries:
ValueJoystick
$001
$012
$023
$034

Registers modified
A or X or Y

Example
A=JOYY(0)



KEYPAD Statement
v1.00a

Syntax
KEYPAD <number>
KEYPAD FIXv1.50

Purpose
To choose the controller that keypad input will be read from or enable keypad debounce.

Remarks
The FIX command adds code for keypad debounce. This corrects "rapid fire" problems. It is only needed when replacing the default VBI Deferred interrupt with another, for example, when using my POK music player.

Valid <number> entries:
ValueJoystick
$001
$012
$023
$034

Registers modified
A



LEFT Statement
v1.00a

Syntax
LEFT

Purpose
Moves the cursor toward the left of the screen by one column.

Registers modified
A

Included files
left.inc

Example
LOCATE 1,2:PRINT "ELLO":LEFT:PRINT "H"

displays

HELLO



LOCATE Statement
v1.00a

Syntax
LOCATE <row>,<col>

<row> is a row number (vertical) on the screen. It can be a number or a variable. Range 0-23.

<col> is a column number (horizontal) on the screen. It can be a number or a variable. Range 0-39.

Remarks
Using the variables A, X, and Y is allowed, but not recommended because they are destroyed.

Assumes a 40-character line. No bounds checking is performed. If a 16-bit number is entered, only the lower byte is used. The calculations are performed at compile time if no variables are used.

Registers modified
A, X, Y (however, if no variables are used then only A is modified)

Included files
locate.inc

Examples
LOCATE 23,39
LOCATE 0,Q
LOCATE MY,MX




LOOP Statement
v1.00a
See DO...LOOP statements.



MEMAREA Statement
v1.20

Syntax
MEMAREA <source>,<destination>,<bytes>,<line length>,<skip length>

<source>, <destination>, and <bytes> are treated as 16-bit numbers, <line length> and <skip length> as 8-bit.

Purpose
To copy a block of memory in a non-contiguous fashion.

Remarks
This statement is much like MEMCOPY, however, it allows for more control over the copy process. <line length> specifies the number of bytes that are written before a skip occurs. <skip length> defines the number of bytes of memory to skip over before writing again.

Registers modified
A, Y

Included files
memarea.inc

Example
MEMAREA $83C0,$1143,75,5,35 'draw door



MEMCOPY Statement
v1.20

Syntax
MEMCOPY <source>,<destination>,<bytes>

<source>, <destination>, and <bytes> are all treated as 16-bit numbers.

Purpose
To copy a block of memory.

Registers modified
A, Y

Included files
memcopy.inc

Example
MEMCOPY $8000,$1000,960 'draw room



MISSILES Statement
v1.90

Syntax
MISSILES { ON | OFF }

Purpose
To turn missile display on or off.

Remarks
Missiles are on by default, but are not displayed if sprites are off.

Registers modified
A

See also
SPRITES statement

Example
MISSILES OFF



MOVEUP Statement
v1.10a

Syntax
MOVEUP

Purpose
To scroll the screen up one line.

Remarks
The screen contents are shifted 40 characters to the left. This moves the screen up one line. The previous top line is discarded. The new bottom line is blank.

Registers modified
A, X, Y

Included files
moveup.inc

Example
MOVEUP:LOCATE 23,0:PRINT ">"}



MUL8 Statement
v1.60

Syntax
MUL8

Operation
A=TEMPL*TEMPH

Purpose
To multiply two 8-bit numbers and return an 8-bit result.

Remarks
To use MUL8, prepare the variables then issue the statement. The variables TEMPL and TEMPH represent the 8-bit numbers to be multiplied.

Registers modified
A, X

Included files
mul8.inc

Example
TEMPL=20:TEMPH=5:MUL8 '20*5, result is: A=100



MULADD Statement
v1.20

Syntax
MULADD

Operation
(X:A)=A*Y+(X:TEMPL), if Y>0

Purpose
To multiply two 8 bit numbers, add a 16-bit number, and return a 16-bit result.

Remarks
To use MULADD, prepare the variables then issue the statement. The variables A and Y represent the 8-bit numbers that will be multiplied together. Y should not be 0. The variable X should contain the high byte of the 16-bit quantity to add. The equate variable TEMPL should be used to store the low byte. Be sure to rearrange the storage order of the registers so that none of A, X, or Y are overwritten. It is easy to forget that a statement like TEMPL=MYVAR will write to A as well as TEMPL.

This was never originally intended to be a separate command in the language, but it has turned out to be so useful that I had to include it.

Registers modified
A, X, Y

Included files
muladd.inc

Example
TEMPL=MX:X=$20:Y=TX:A=MY:MULADD
TEMPL=A:TEMPH=X:Y=0:A=V:POKE TEMPL*Y,A




NEXT Statement
v1.00a
See FOR...NEXT statements.



PALETTE Statement
v1.00a

Syntax
PALETTE <number>,<color>

Purpose
To set the color for various screen elements.

Remarks
For an explanation of <color> values, see the Atari Reference Manual. <color> can be a number or variable.

Valid <number> entries:
ValuePalette entry
$00Background color
$01Character color 1
$02Character color 2
$03Character color 3
$04Character color 4
$05Sprite color 1
$06Sprite color 2
$07Sprite color 3
$08Sprite color 4

Registers modified
A

Example
PALETTE 0,$30



PEEK Function
v1.10a

Syntax
AXY=PEEK(NV)
AY=PEEK(NV+X)
AX=PEEK(NV+Y)
A=PEEK(NV*Y) or A=PEEK(NV,Y)

Purpose
To read data from the specified memory address.

Registers modified
A or X or Y

Examples
A=PEEK($F0,Y)
Y=PEEK($5200+X)



POKE Statement
v1.10a

Syntax
POKE NV,AXY
POKE NV+X,AY
POKE NV+Y,AX
POKE NV*Y,A

Purpose
To write to the specified memory address.

Registers modified
none

Examples
POKE $F0*Y,A
POKE $5200+X,Y



POP Statement
v1.40

Syntax
POP { A | ALL}

Purpose
To restore previously saved A, X, and Y registers, or just the A register. This command replaces POPA.

Registers modified
A or A, X, Y

Examples
POP A
POP ALL




POS Function
v1.00a

Syntax
POS

Purpose
To get the current cursor location.

Remarks
The current cursor row is returned in X. The current column is returned in A.

The values should range from 0-23 for the row and 0-39 for the column, but could be outside this range if an invalid LOCATE statement was used.

Registers modified
A, X, Y

Included files
pos.inc, mul8.inc

Example
POS:MY=X:MX=A



PRINT Statement
v1.00a

Syntax
PRINT " <text> { <char> }"v1.40
PRINT CHR$( <num> )
PRINTv1.10a

Purpose
To output text or data on the screen.

Remarks
There are three different forms of the PRINT statement. The first form allows printing of <text>. Non-printable characters can be entered by number surrounded by brackets. The second form prints the character associated with <num>. The third form performs a CRLF action positioning the cursor and scrolling the screen if necessary.

Starting with v1.10a the ASCII characters 32-126 will no longer be converted to ATASCII. Use the included custom character set instead.

Registers modified
A, Y or A, Y or A, X, Y

Included files
print.inc or crlf.inc, pos.inc, mul8.inc, muladd.inc, chkrow.inc, moveup.inc

Examples
PRINT "ATARI"
PRINT "5200BAS {2}"
PRINT CHR$(1)
PRINT




PUSH Statement
v1.40

Syntax
PUSH { A | ALL}

Purpose
To save either the A, X, and Y registers or just the A register on the stack. This command replaces PUSHA.

Registers modified
none or A

Examples
PUSH A
PUSH ALL




PUT Statement
v1.40

Syntax
PUT ( <x-coord>,<y-coord> ), <label>, <num>
PUT ( <x-coord>,<y-coord> ), <label>, <num>, <height>v1.91
PUT ( <x-coord>,<y-coord> ), <label>, <num>, -<height>v1.95

Purpose
To draw a sprite or missile on the screen at the specified location.

Remarks
<x-coord> can be a number or variable and should be in the range 0-159. <y-coord> can be a number or variable and should be in the range 0-191. <label> specifies the name representing the location of sprite memory, can also be a number. Sprite memory must always begin on a page boundary (i.e. the last two hex digits are 00), so if a number is specified the last two digits must be omitted. <num> must be a number from 0-7 and chooses the sprite (0-3) or missile (4-7) to be positioned. <height> is optional, if included it can be a number or the variable FROMH, but is recommended for speed if the sprites height is known. If <height> is negative, or -FROMH is specified, the sprite will be drawn upside-down. This is slightly slower than drawing right-side up.

Registers modified
A, X

See also
SPRITES statement

Included files
putspr.inc or putmsl.inc or putsph.inc or putmsh.inc or putspi.inc or putmsi.inc

Examples
PUT (XCOORD,YCOORD),$9F,0
PUT (50,100),SPRMEM,5,40
PUT (0,Y),$80,3,-FROMH




RETURN Statement
v1.00a
See GOSUB...RETURN statements.



RIGHT Statement
v1.00a

Syntax
RIGHT

Purpose
Moves the cursor toward the right of the screen by one column.

Registers modified
none

Included files
right.inc

Example
LOCATE 1,2:PRINT "HELLO":RIGHT:PRINT "ello"

displays

Hello



SCREEN Function
v1.00a

Syntax
{A | X | Y}=SCREEN ( <row>,<col> )
A=SCREEN ( <num>,<num> )

Purpose
To read a character from the specified screen location.

Registers modified
A, X, Y or A

Included files
muladd.inc

Examples
A=SCREEN(0,0)
A=SCREEN(MY,MX)




SCREEN Statement
v1.20

Syntax
SCREEN <mode>

Purpose
To automatically set up the ANTIC display list.

Remarks
On program load an ANTIC 2 screen is prepared by default. Only modes 2 and 4 are valid.

This statement is at a very early stage. At the moment it outputs a fixed number of identical mode lines, for building an ANTIC 2 or 4 screen, although it should work for other modes with the same number of mode lines. If a more sophisticated display list is required, it should be made manually.

Example
SCREEN 4



SELECT CASE Statement
v1.60

Syntax
SELECT CASE { A | X | Y }
CASE { <num> | <var> }
   [statement block]
   [EXIT SELECT]v1.90
   [statement block]
   [IF...THEN EXIT SELECT]v1.90
   [statement block]
CASE_ { <num> | <var> }
   [statement block]
[CASE ...
   [statement block]]
[CASE ELSE
   [statement block]]
END SELECT

Purpose
To execute code depending on the value of an initial variable.

Registers modified
none

Example
INPUT A 'get key
SELECT CASE A 'process key
CASE $04 'left
  PRINT "L"}
CASE $06 'right
  PRINT "R"}
CASE ELSE
  PRINT "?"}
END SELECT



SET Statement
v1.30

Syntax
SET <setting>=<location> [<name>]

Purpose
To set the locations for built in routines or redefine them.

Remarks
There are two forms of the SET command. If <name> is not included, the built-in routine is simply placed at the new memory or ROM location. If <name> is included, then the routine will be replaced by the new routine at <name>. The address is still necessary so that the SUB statement can place the new code correctly.

Valid <setting> entries:
SettingMeaningDefault Location
VIMIRQImmediate$FC03
VVBLKIVBI immediate$FCB8
VVBLKDVBI deferred$BC16 (ROM $FCB2)v1.96
VDSLSTDLI (Display List Interrupt)$FEA1
VKYBDIKeypad immediate$FD02
VKYBDFKeypad deferred$BC00 (ROM $FCB2)
VTRIGRSoft trigger$0000
VBRKOPBRK opcode$0000
VSERINSerial in ready$0000
VSERORSerial out ready$0000
VSEROCSerial out complete$0000
VTIMR1Timer 1$0000
VTIMR2Timer 2$0000
VTIMR4Timer 4$0000
SCREENScreen memory$1000
SPRITESSprite graphics$3000v1.40
CHARSETInitial character set$B800 (ROM $F800)v1.96
STRINGSString storage (PRINT)$B000
DLISTDisplay list$BFB4v1.70

The deferred IRQ is almost always the one to redefine rather than the immediate. Vectors with $0000 are not initially defined and must also be enabled manually by setting the appropriate bits in POKMSK.

The DLIST default was $BFC7 prior to version 1.70. The CHARSET default was $A000 and VDSLST was $BC20 prior to version 1.96.

Included files
keypad.inc if default VKYBDF used, defervbi.inc if default VVBLKD used

Examples
SET VDSLST=$A400 MYDLI 'specify new DLI routine, MYDLI at $A400
SET CHARSET=$9000 'relocate the default character set to $9000
SET CHARSET=$9000 MYCHARS 'don't use the default character set, use the one at $9000 instead
SET CHARSET=$F800 ROM 'don't use the default character set, use the ROM set instead



SOUND Statement
v1.80

Syntax
SOUND <channel>, <frequency>

Purpose
To play a sound.

Remarks
The sound will play only when the channel volume is non-zero. <Channel> should be in the range 0-3, and must be a number. <Frequency> can range from 0 to 255.

Registers modified
A

See also
VOLUME statement. For another way to play music, please see my Atari 5200 POK player project.

Example
SOUND 0,100



SPRITES Statement
v1.40

Syntax
SPRITES { ON | OFF }

Purpose
To turn sprite display on or off.

Remarks
Sprites are off by default.

Registers modified
A

See also
MISSILES statement

Example
SPRITES ON



SUB...END SUB Statements
v1.30

Syntax
SUB <name>
  [statement block]
  [EXIT SUB]
  [statement block]
END SUB

Purpose
To allow for custom DLI's, VBI's, or other IRQ's.

Remarks
These commands replace the older SUB DLI...END DLI. The registers A, X, and Y are no longer automatically saved and restored at the beginning and end of the procedure.

<name> should match a name previously defined with the SET statement. The proper offset into the ROM will automatically be included, so .ORG is not needed.

Registers modified
none

See also
POP statement



TITLE Statement
v1.00a

Syntax
TITLE " <text> "
TITLE OFFv1.30

Purpose
To set the scrolling ATARI screen game title, or turn it off.

Remarks
Lowercase letters in <text> become capital letters and change colors. Capital letters remain capitals.

The title can be a maximum of 20 characters in length.

Included files
y2k.inc, if title is used

Example
TITLE "my game"



UP Statement
v1.00a

Syntax
UP

Purpose
Moves the cursor up toward the top of the screen by one row.

Remarks
Assumes a 40-character line.

Registers modified
A, X

Included files
up.inc, left.inc

Example
LOCATE 2,1:PRINT "WORLD":UP:PRINT "HELLO"

displays

HI
THERE




VOLUME Statement
v1.81

Syntax
VOLUME <channel>, <noise>, <volume>

Purpose
To change the volume and distortion of a sound channel.

Remarks
The sound will keep playing until the volume is turned off for the channel. <Channel> should be in the range 0-3, and must be a number. <Noise> should be an even number (or variable) between 0 and 14. <Volume> should be between 0 (silence) and 15 (max volume). The total volume of all channels should not exceed 32.

Registers modified
A

See also
For another way to play music, please see my Atari 5200 POK player project.

Example
VOLUME 0,6,15