1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-26 22:31:14 +00:00
8bitworkshop/help/bataribasic/manual.html

3909 lines
211 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>batari Basic Command Reference</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META NAME="description" CONTENT="batari Basic help file.">
<META NAME="keywords" CONTENT="atari 2600, basic, batari">
<META NAME="robots" CONTENT="noindex, nofollow, NOARCHIVE">
<STYLE TYPE="text/css"><!--
body {
color:#000000;
margin:0px;
padding:0px;
}
a:link {font-weight:bold;}
a:visited {color:#7B009A; font-weight:bold;}
a:hover {text-decoration:none; color:#FFFFFF; background-color:rgb(204,0,51); font-weight:bold;}
a:active {text-decoration:none; color:#FFFFFF; background-color:rgb(204,0,51); padding:0px; margin:0px; font-weight:bold;}
h3 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 18px; line-height:38px; font-weight: bold; color: black; background-color:rgb(255,204,0); margin-top:40px; margin-right:0px; margin-bottom:10px; margin-left:8px; padding-top:0px; padding-right:8px; padding-bottom:0px; padding-left:8px; border-top-width:2px; border-bottom-width:2px; border-top-color:rgb(254,255,129); border-bottom-color:rgb(254,255,129); border-top-style:solid; border-bottom-style:solid;}
h4 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:11px; line-height:16px; font-weight:normal; color: black; margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:8px; padding-bottom:0px; padding-left:8px;}
h5 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:13px; line-height:21px; font-weight: bold; text-decoration:none; background-color:rgb(255,204,0); margin-top:0px; margin-right:0px; margin-left:0px; margin-bottom:0px; padding-top:0px; padding-right:0px; padding-bottom:0px; padding-left:8px; border-top-width:2px; border-bottom-width:2px; border-top-color:rgb(254,255,129); border-bottom-color:rgb(254,255,129); border-top-style:solid; border-bottom-style:solid;}
h6 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:24px; font-weight: bold; text-decoration:none; margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:8px; padding-bottom:0px; padding-left:16px; }
p { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:22px; text-decoration:none; margin-top:0px; margin-right:0px; margin-bottom:0px; margin-left:0px; padding-top:0px; padding-right:8px; padding-bottom:0px; padding-left:16px; }
ol { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:22px; text-decoration:none; }
ul { font-family: Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:22px; text-decoration:none; }
acronym {
border-bottom: 1px dashed #000;
cursor:help;
}
td.myhover:hover{
background-color:rgb(255,255,204);
}
tr.mytrhover:hover{
background-color:rgb(255,255,204);
}
.bbborder {
margin-right:8px;
margin-left:32px;
padding-top:4px;
padding-right:8px;
padding-bottom:4px;
padding-left:2px;
border-width:1px;
border-color:rgb(0,136,0);
border-style:solid;
font-size:12px;
line-height:18px;
font-family:Courier, monospace;
}
.bbsecondary {
font-size:18px;
line-height:40px;
background-color:whitesmoke;
margin-left:8px;
margin-top:32px;
padding-left:8px;
margin-bottom:5px;
border-top-width:2px;
border-bottom-width:2px;
border-top-color:rgb(204,204,204);
border-bottom-color:rgb(204,204,204);
border-top-style:solid;
border-bottom-style:solid;
}
.bbsecondary a{
text-decoration:none;
background-color:transparent;
color:black;
}
.bbtertiary {
font-size:18px;
line-height:40px;
background-color:rgb(255,255,204);
margin-left:8px;
margin-top:28px;
padding-left:8px;
margin-bottom:5px;
border-top-width:2px;
border-bottom-width:2px;
border-top-color:whitesmoke;
border-bottom-color:whitesmoke;
border-top-style:solid;
border-bottom-style:solid;
}
.bbtertiary a{
text-decoration:none;
background-color:transparent;
color:black;
}
.bbquaternary {
font-size:18px;
line-height:40px;
margin-left:8px;
margin-top:28px;
padding-left:8px;
margin-bottom:5px;
border-top-width:2px;
border-bottom-width:2px;
border-top-color:rgb(248,248,144);
border-bottom-color:rgb(248,248,144);
border-top-style:solid;
border-bottom-style:solid;
}
.bbquaternary a{
text-decoration:none;
background-color:transparent;
color:black;
}
td.bbtdbot {
border-bottom-width:1px;
border-bottom-color:rgb(228,228,228);
border-bottom-style:solid;
}
td.bbtdside {
border-left-width:1px;
border-left-color:rgb(228,228,228);
border-left-style:solid;
}
.bm a{
text-decoration:none;
background-color:transparent;
color:black;
}
--></STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="black" LINK="#2222EE" VLINK="#7B009A" ALINK="#CC0033" TOPMARGIN="0" LEFTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">
<A NAME="top"></A>
<TABLE CELLPADDING="0" CELLSPACING="0" STYLE="margin-top:12px;">
<TR>
<TD WIDTH="745" ALIGN="left" VALIGN="top">
<H6 STYLE="font-size:32px; line-height:32px; margin-bottom:8px;"><B>batari Basic Command Reference</B></H6>
<H6 STYLE="font-size:18px; line-height:18px; margin-bottom:16px;"><B>&nbsp;By Fred &quot;batari&quot; Quimby (adapted by Duane Alan Hahn)</B></H6>
<P>
This document is intended as an offline version of the bB 1.0 Command Reference at Duane Alan Hahn's <A HREF="http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html" TARGET="_blank" TITLE="External site opens in new window">web site</A>. Visit the <A HREF="http://bataribasic.com/" TARGET="_blank" TITLE="External site opens in new window">official batari Basic site</A> for the latest bB news, tutorials, downloads and more.
<BR><BR>
</P>
<H3 STYLE="margin-top:0px;">Things You Should Know</H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B><A NAME="memory">Memory</A></B></H6>
<P>
The Atari 2600's microprocessor can only address 4K of ROM at a time, and the console has only has 128 bytes of RAM. Of this RAM, 26 bytes are available for general use in your programs, as variables a-z. It may not sound like much, and it isn't, but many great games have been written despite these limitations.
<BR><BR>
Some ways to mitigate the above limitations are to use bank switching and/or Superchip RAM. Bank switching allows programs up to 32K in size, and the Superchip gives us another 128 bytes of RAM. There are drawbacks to both, however.
<BR><BR>
See <A HREF="#bankswitching">Bank Switching</A> and/or <A HREF="#superchipram">Superchip</A> for more information.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><A NAME="timing">Timing</A></B></H6>
<P>
Timing is crucial in batari Basic, in that you only have about 2 milliseconds between successive calls to drawscreen. See <A HREF="#drawscreen">drawscreen</A> and <A HREF="#vblank">vblank</A> for more information.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><A NAME="whitespace">White Space</A></B></H6>
<P>
It is recommended that you include white space in your program. Blank lines can help to create a physical separation of some code, and some space between commands and tokens can help readability. Earlier versions of bB had trouble with white space, but this problem should be resolved now.
<BR><BR>
Some of us (myself included) do not leave much, if any, white space between commands, and bB can still parse most code correctly, regardless. For example, the statement:
</P>
<PRE CLASS="bbborder">
for l=1 to 10:t=t+4:next
</PRE>
<P>
is acceptable. Also, the following would be parsed the same way:
<BR>
</P>
<PRE CLASS="bbborder">
for l = 1 to 10 : t = t + 4 : next<BR>
for l =1 to 10:t=t +4: next<BR>
for l=1 to 10 : t= t+4 :next
</PRE>
<P>
The following would not:
</P>
<PRE CLASS="bbborder">
forl=1to10:t=t+4:next
forl=1 to 10:t=t+4:next
for l=1 to10 :t=t+4:next
</PRE>
<P>
In other words, any keywords or commands must be spaced properly or batari Basic will think they are variables and compilation will fail, but anything else is fair game. As long as there is a recognizable separator, such as +, -, =, :, *, /, &amp;, &amp;&amp;, |, ||, ^ and possibly others, you can space however you want (or not at all).
<BR>
</P>
<H6 CLASS="bbsecondary"><A NAME="dos">DOS Compatibility</A></H6>
<P>
Although batari Basic is a command-line program, you are expected to run it under Windows 95 or later because it requires a DPMI (DOS protected mode interface) and uses long filenames. If you wish to run under pure DOS, however, you can, but you will need to:
<BR><BR>
</P>
<UL>
<LI>
obtain a DPMI program, such as cwsdpmi.exe, and run this before running batari Basic.
<BR>
</LI>
<LI>
rename all filenames to 8.3 format
<BR>
</LI>
<LI>
edit includes files to point to renamed files above
<BR>
</LI>
<LI>
use the command-line parameter <B>-r</B> to specify an alternate variable redefinition file that conforms to 8.3.
<BR>
</LI>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="miscellcommand">Miscellaneous Commands</A></H3>
<UL>
<H6 STYLE="margin-top:8px;" CLASS="bbsecondary"><A NAME="rem">rem</A> <SPAN STYLE="font-size:14px;">(short for Remark)</SPAN></H6>
<P>
The rem statement is used for in-program comments. These comments are very helpful not only to other programmers trying to make sense of your code, but to yourself if your memory is anything like mine :)
<BR><BR>
Note that, unlike old <acronym TITLE="Run line by line, directly from the source code without compiling first.">interpreted Basics</acronym>, you can use <B>rem</B> as much as you want and it will not affect the length of your compiled program.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
rem *****************************************************
rem * Name: Space Nuggets
rem * Version: 0001-2007y02m14d
rem *
rem *****************************************************
rem * Programmer: Scadoobie Floinkenburger
rem * Started: 2007y - 02m - 14d
rem * Language: batari Basic v1.0
rem * System: Atari 2600 VCS
rem *****************************************************
</PRE>
<H6 CLASS="bbsecondary"><A NAME="reboot">reboot</A></H6>
<P>
This command will <acronym TITLE="Restart a computer under software control.">warm boot</acronym> your game. <b>reboot</b> will clear everything similar to turning the Atari 2600 off and back on again, so do not use it if you need to store things such as the highest level reached, high score, current game selections and so on.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
if switchreset then reboot
</PRE>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="variables">Variables</A></H3>
<P>
You have 26 general purpose variables in batari Basic, fixed as a-z. Although they are fixed, you can use the <A HREF="#dim">dim</A> command to map an alias to any of these variables.
<BR><BR>
26 variables is not a lot, so you will use them up quickly. Therefore, it's recommended that you use the <A HREF="#bit">bit operations</A> to access single bits when using variables for flags or game state information wherever possible.
<BR><BR>
If you do run out of variables, you can use four bytes from the playfield if you're not scrolling it. You can also use temp1-temp6 as temporary storage, but these are <acronym TITLE="Destroyed, erased.">obliterated</acronym> when drawscreen is run, and some are used for playfield operations as well, so use these at your own risk.
<BR><BR>
Although there might be unused bytes in the stack space, it is not recommended that you use these in your program since later versions of batari Basic will probably use these for something else.
<BR>
</P>
<UL>
<H6 CLASS="bbsecondary"><B><A NAME="let">let</A></B> (optional)</H6>
<P>
The let statement is optional, and is used for variable assignment. It was left in because an early unreleased version of batari Basic required it. If you wish to use it, it will not affect program length—it will simply be ignored by the compiler.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
let x = x + 1
</PRE>
<H6 CLASS="bbsecondary"><A NAME="dim">dim</A> <SPAN STYLE="font-size:14px;">(create descriptive names for variables/assign names to fixed point types)</SPAN></H6>
<P>
Used to create more descriptive names for the 26 variables, or to create a fixed-point type and assign it to some of these variables.
<BR>
</P>
<UL>
<H6 CLASS="bbtertiary"><B>Using dim to Create More Descriptive Names</B></H6>
<P>
Unlike other Basics, the most common use of the dim statement is not for arrays in batari Basic, but rather for creating an alias, a more descriptive name for each variable than a-z. The statement simply maps a descriptive name to any of the original 26 variables.
<BR><BR>
Although dim is typically called at the beginning of the program, for creating a variable alias, it can actually be called at any time, and is applicable to the entire program no matter where it is placed (this is not true for creating fixed point variables). The first character of an alias must be one of the 26 letters of the alphabet.
<BR><BR>
Examples:</P>
<PRE CLASS="bbborder">
dim monsterxpos=a
dim monsterypos=b
</PRE>
<P>
Note that more than one alias may be mapped to the same variable. This is useful for when you will inevitably need to reuse variables in multiple places.
</P>
<H6 CLASS="bbtertiary">Using dim to Map Variables to Fixed Point Types</H6>
<P>
Although you can use the variables a-z as <acronym TITLE="Numbers without a decimal (positive, negative or zero). Whole numbers.">integers</acronym> without ever using dim, you cannot use a-z as fixed point variables without using dim. See <A HREF="#fixedpoint">fixed point variables</A> for more information.
</P>
</UL>
<H6 CLASS="bbsecondary"><A NAME="bit">Bit Operations</A> (squeeze more out of your variables)</H6>
<P>
On modern systems, you may not think twice of using an entire byte or even a word for every flag. For example, to determine whether a game is in progress or it is over, often an entire byte is used even though its only value is 0 or 1.
<BR><BR>
Since the Atari 2600 only has 128 bytes of RAM, and batari Basic only has 26 bytes available for variables, it is very likely that you will need to use individual bits for game state information. For example, a common flag is to determine whether a game is over or still in progress.
<BR><BR>
The bits of a byte are numbered from 0 to 7, with 0 being the least significant bit (LSB) or smallest.
<BR><BR>
<P STYLE="margin-bottom:5px;">For example, to access the LSB in a variable or register:</P>
<PRE CLASS="bbborder">
a{0} = 1
a{0} = 0
if !a{0} then gameover
</PRE>
<P>
You may also assign one bit to another bit. For example:</P>
<PRE CLASS="bbborder">
d{3}=r{4}
f{5}=!f{5}
</PRE>
<P>
Accessing the bits of a variable is almost like turning it into 8 separate variables. Instead of having only 26 variables, you potentially have 208. You just have to remember that these itty-bitty variables can only hold 0 or 1.</P>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="bitwise">Bitwise (Logical) Operators</A></B> (&amp;, |, ^)</H6>
<P>
Batari Basic has three operators for logical operations. They are tokenized as:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>&amp; = AND</B></SPAN>
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>| = OR</B> </SPAN>(Note: the &quot;|&quot; key is usually above the backslash: &quot;\&quot;)
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>^ = XOR</B> </SPAN>(exclusive OR)
<BR><BR>
These can be used to change the state of individual bits or to mask multiple bits.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
a = a &amp; $0F
a = b ^ %00110000
a = a | 1
</PRE>
</UL>
<H6 CLASS="bbsecondary"><A NAME="fixedpoint">Fixed Point Variables</A></H6>
<P>
Fixed point variables can be assigned to fractional values, similar to floating point variables in other languages. bB provides two fixed point types:
<BR><BR>
</P>
<UL>
<LI>a two-byte variable, with one byte as the <acronym TITLE="Any number without a decimal (positive, negative or zero). A whole number.">integer</acronym> portion and one as the fractional portion. This is referred to as an 8.8 type. These can range from 0 to 255, with a fractional portion
that is accurate to within 1/256 or 0.00390625. This type can also be considered as signed in the same way an integer variable is.
<BR><BR>
</LI>
<LI>a one-byte variable, with four bits as the integer and four bits as the fraction. This is referred to as a 4.4 type. This type ranges from -8 to 7.9375, and is accurate to within 1/16 or 0.0625. In other words, this type is always signed.
</LI>
</UL>
<P>
<BR>
To declare these special types, you must use the dim statement. To declare an 8.8 type, you must specify the integer and fractional portion by the following:
<BR>
</P>
<PRE CLASS="bbborder">
dim myvar=a.b
dim monsterx=d.r
</PRE>
<P>
The first will use the variable <B>a</B> as the integer and <B>b</B> as the fraction, the second will use <B>d</B> as the integer and <B>r</B> as the fraction. Then any time you use <B>myvar</B> or <B>monsterx</B> in a variable assignment, the compiler will know to use the 8.8 fixed point type.
<BR><BR>
To declare a 4.4 type, you use a similar syntax as the above, but you use the same variable name for the integer and fraction:
<BR>
</P>
<PRE CLASS="bbborder">
dim xvelocity=c.c
dim yvelocity=d.d
</PRE>
<P>
After this dim, using <B>xvelocity</B> will tell the compiler to use the 4.4 type.
<BR><BR>
You may use some fixed-point operations without any changes to your program, but some will require you to include the fixed point module. If you need to include the fixed point module, place this somewhere near the beginning of your program:
<BR>
</P>
<PRE CLASS="bbborder">
include fixed_point_math.asm
</PRE>
<P>
Alternatively, you may modify the includes file to include it automatically. See <A HREF="#include">include</A> or <A HREF="#includesfile">includes file</A> for more information.
<BR><BR>
In a 2600 game, the 8.8 types are particularly useful for specifying coordinates. The 4.4 types are useful for specifying velocity without using the extra bytes needed in 8.8 types.
<BR><BR>
This subpixel movement, or movement of a non-integer number of pixels for each frame, allows more flexibility in gameplay mechanics than ordinary integer variables provide, or at least it simplifies the calculations that would otherwise be required using only integers.
<BR><BR>
The 8.8 type can be used interchangeably anywhere an integer would normally be used. If this is done, for example by assigning an 8.8 to player0x, the fractional portion of the number will be ignored, just like the int() function in other BASIC dialects. The 4.4 types, however, cannot be used anywhere — they can only be added, subtracted or assigned to/from themselves, integers or 8.8 types. Well, that's not totally true. If you use a 4.4 type in some way other than an assignment, addition or subtraction, its
value will be multiplied by 16.
<BR><BR>
Also, note that fixed point types are subject to the same limitations in if-then statements. Although you may compare two 4.4 types in an if-then, if you compare a 4.4 with a number or another type, the 4.4 will be multiplied by 16. If you use an 8.8 type in an if-then, the fractional portion will be ignored.
<BR><BR>
If you want to use just the fractional portion in an if-then, this can be done by accessing the variable assigned to the fraction. . . In the examples above this would be <B>b</B> or <B>r</B>. Note that if you access <B>b</B> or <B>r</B> directly, the fractional portion will be multiplied by 256.
<BR><BR>
Multiplication and division of fixed point types is subject to the same limitations above.
<BR><BR>
Some valid operations using fixed point types, that is, ones that are not subject to limitations are listed below. This is not a complete list. Those denoted with a (*) require that the fixed_point_math.asm module is included, those without a (*) do not.
<BR><BR>
Note: assume that <B>my44</B> is a 4.4 type, <B>myint</B> is an integer, and <B>my88</B> is an 8.8:
<BR>
</P>
<PRE CLASS="bbborder">
my88=12.662
my44=4.67
my88=-12.662
my44=-4.67
my88=myint
my44=myint
myint=my44
myint=my88
my88=my44 (*)
my44=my88 (*)
my88=my88+1.45
my44=my44+2.55
my88=my88-1.45
my44=my44-2.55
my88=my44+6.45 (*)
my44=my88+3.45 (*)
my88=my44-6.45 (*)
my44=my88-3.45 (*)
my88=my88+my88
my44=my44+my44
my88=my88-my88
my44=my44-my44
my88=my44+my88 (*)
my44=my88+my44 (*)
my88=my44-my88 (*)
my44=my88-my44 (*)
</PRE>
<P>
In other words, if you mix 4.4 and 8.8 types in a statement, you need to include the fixed_point_math.asm module.
</P>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H6 CLASS="bbsecondary"><A NAME="ephvarreg">Ephemeral Variables and Registers</A> (short-lived)</H6>
<P>
By <acronym TITLE="Lasting for only a short time.">ephemeral</acronym>, we mean variables or <acronym TITLE="Television Interface Adaptor.">TIA</acronym> <acronym TITLE="Locations that hold temporary data similar to variables.">registers</acronym> that are routinely <acronym TITLE="Destroyed, erased.">obliterated</acronym> through normal functioning of bB. Note that this section is not yet complete.
<BR><BR>
The temp variables, temp1-temp6, are always obliterated by the kernel. Also, some bB internal functions use them, such as those for playfield plotting or scrolling. User functions also pass values by way of these variables. Other than that, the temp variables are safe to use for all of your intermediate calculations.
<BR><BR>
Some early versions of bB obliterated certain system variables such as the x and y positions of sprites. Although this is no longer true, this old requirement seems to have rubbed off on newer games, and in turn, programmers are wasting valuable variables to mirror system variables.
<BR><BR>
Again, all player, missile and ball x, y and height variables will keep their values unless changed by the programmer.
<BR><BR>
In addition, the standard kernel will maintain sprite definitions and so these can be placed outside of the game loop. The multisprite kernel, however, will not maintain definitions for player 0, so this needs to be defined within the game loop.
<BR><BR>
TIA registers may be ephemeral, in that the TIA is constantly updated throughout the visible screen so you need to stay on top of most of them. But some TIA registers are persistent, meaning that you can set them once and they will remain in effect throughout your game. Some are obliterated every frame and therefore must be set before each drawscreen. Knowing which are safe to set and once or which need to be redefined every frame will help you write more efficient programs.
<BR><BR>
The following are persistent:<BR>
<SPAN STYLE="font-size:15px; line-height:32px;"><B>
AUDV0<BR>
AUDV1<BR>
AUDC0<BR>
AUDC1<BR>
AUDF0<BR>
AUDF1<BR>
</B></SPAN>
<SPAN STYLE="font-size:15px; line-height:32px;"><B>COLUBK</B></SPAN> (unless background kernel option set)<BR>
<SPAN STYLE="font-size:15px; line-height:32px;"><B>COLUPF</B></SPAN> (unless pfscorecolor variables used and/or pfcolors kernel option set)<BR>
<SPAN STYLE="font-size:15px; line-height:32px;"><B>CTRLPF</B></SPAN><BR>
<BR>
The following are obliterated, but values are predictable and don't necessarily need resetting. The TIA register and its value after a drawscreen are noted below:
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; line-height:24px; margin-left:24px;">
<TR>
<TD WIDTH="100" CLASS="bbtdbot"><H6 STYLE="font-size:18px; padding:0px; margin:0px;">TIA reg</H6>
</TD>
<TD WIDTH="256" CLASS="bbtdbot"><H6 STYLE="font-size:18px; padding:0px; margin:0px;">value after drawscreen</H6>
</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">COLUP0</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">same as scorecolor</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">COLUP1</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">same as scorecolor</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">NUSIZ0</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">0</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">NUSIZ1</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">0</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">REFP0</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">0</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">REFP1</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">0</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">PF0</TD>
<TD WIDTH="256" CLASS="bbtdbot bbtdside">0</TD>
</TR>
</TABLE>
<P>
<BR>
Note that the multisprite kernel uses special variables for its virtual sprites 1-5 that resemble TIA regs, but are not TIA regs themselves (they point to 2600's RAM.) Therefore the values _COLUP1, COLUP2-COLUP5, _NUSIZ1, and NUSIZ2-NUSIZ5 are all persistent. Also note that bit 3 of _NUSIZ1 and NUSIZ2-NUSIZ5 contains the REFP value.
</P>
<H6 CLASS="bbsecondary"><A NAME="const">Constants</A> (variables with a fixed value)</H6>
<P>
To declare a constant in batari Basic, use the <B>const</B> command. <B>const</B> declares a constant value for use within a program. This improves readability in a program in the case where a value is used several times but will not change, or you want to try different values in a program but don't want to change your code in several places first.
<BR><BR>
For example, you might have the following near the beginning of your program:
</P>
<PRE CLASS="bbborder">
const myconst=200
const monsterheight=$12
</PRE>
<P>
After that, any time <B>myconst</B> or <B>monsterheight</B> is used, the compiler will substitute 200 or $12 respectively.
<BR>
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="labels">Labels and Line Numbers</A></H3>
<P>
batari Basic supports <acronym TITLE="Can be made up of letters, numbers, and underscores.">alphanumeric labels</acronym>. You may use line numbers if you prefer. Some old-school programmers like line numbers, or at least use them as a matter of comfort since they were necessary in early Basics. In any case, labels and line numbers are optional. Typically you will only need them when you want to specify a <A HREF="#goto">goto</A> or <A HREF="#gosub">gosub</A> target.
<BR><BR>
Labels, line numbers, and <B>end</B> must <B><FONT COLOR="#CC0033">not</FONT></B> be indented, while all program statements must be. You may use labels with or without program statements after them. A label can have any combination of letters, numbers, or underscores, even as the first character. A label must not match or begin with a known keyword or any labels internal to bB (like <B>end</B>, <B>kernel</B>, and so on). For example, you cannot name a label <B>next</B> or <B>pfpixel</B> and although you could not use '<b>score</b>change' you could use 'change<b>score</b>'.
<BR><BR>
Example:</P>
<PRE CLASS="bbborder">
10 pfpixel 2 3 on
20 drawscreen
player0x=player0x+1:goto mylocation
player0y=29:goto mylocation2
mylocation
x=x+1
mylocation2 x=x-1
</PRE>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="jumpingaround">Jumping Around</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B><A NAME="goto">goto</A></B></H6>
<P>
The goto statement is used to jump to a line number or label anywhere in your program.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
goto 100
goto mysubroutine
</PRE>
<P>
In bank-switched games, if you are jumping to a routine in another bank, you must specify the bank.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
goto movemonster bank2
</PRE>
<H6 CLASS="bbsecondary"><A NAME="ongoto">on … goto</A></H6>
<P>
This works similar to a case statement in other languages. It is useful for replacing multiple if-then statements when conditions happen in an <acronym TITLE="In order such as first, second, third, and so on.">ordinal</acronym> fashion.
<BR><BR>
For example:
</P>
<PRE CLASS="bbborder">
on x goto 100 200 300 400
</PRE>
<P>
is the same as:
</P>
<PRE CLASS="bbborder">
if x=0 then 100
if x=1 then 200
if x=2 then 300
if x=3 then 400
</PRE>
<P>
In bank-switched games, on ... goto can only jump within the current bank.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> There is no checking to see if your variable's value coincides with a label. In the above example, there is no label for <B>x=4</B>, but the statement will try to find a label for it anyway, which almost always means that your program will crash.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="gosub">gosub</A></B></H6>
<P>
The gosub statement is often used for a subroutine that is called by multiple locations throughout your program.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
gosub 100
gosub mysubroutine
if x &gt; 10 then gosub sinkship
</PRE>
<P>
To return control back to the main program, issue a <B>return</B> in your subroutine.
Example:
</P>
<PRE CLASS="bbborder">
mysubroutine
a = a - 1
x = x + 10
return
</PRE>
<P>
Note that each gosub will use two bytes of stack space, which will be recovered after a return. Only 6 bytes of stack space are reserved for this, so do not use too many nested subroutines, especially since this may be changed in later versions.
<BR><BR>
In bank-switched games, if you are jumping to a subroutine in another bank, you must specify the bank.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
gosub movemonster bank2
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="return">return</A></B></H6>
<P>
The return statement is used in a subroutine to return to the part of the program right after a gosub which called the subroutine.
<BR><BR>
Be careful when using <B>return</B>. If a running program encounters one without a gosub that called it, the program will crash or strange things may happen. <B>return</B> can also be used to return a value for a function. See <A HREF="#function">functions</A> for more information.
<BR><BR>
If using <A HREF="#bankswitching">bank switching</A>, there is some additional overhead with every return statement. Although the standard <B>return</B> by itself will automatically return to whatever bank called the subroutine, it takes up ROM space and cycles to automatically return to the proper bank. Instead, you may use <B>thisbank</B> or <B>otherbank</B> after your return:
<BR>
</P>
</UL>
<UL>
<UL>
<P>
<SPAN STYLE="font-size:18px;"><B>return thisbank</B></SPAN><BR>
Returns only to the current bank. Use this whenever possible since it is much faster. The program will crash, however, if you called the subroutine from another bank, so be careful.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>return otherbank</B></SPAN><BR>
Can be used anywhere, just like <B>return</B>. However, this one is faster for returning to other banks and slower for returns within the same bank.
</P>
<H6 CLASS="bbtertiary"><B><A NAME="pop">pop</A></B></H6>
<P>
Cancels the return address from a subroutine. This essentially makes the last gosub command work like it was a goto.
</P>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="decisionmaking">Decision Making — Brains of a Game</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B><A NAME="if">if-then</A></B></H6>
<P>
Perhaps the most important statement is the if-then statement. These can divert the flow of your program based on a condition.
<BR><BR>
The basic syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>if <FONT COLOR="#8501B5">condition</FONT> then <FONT COLOR="#FF5600">action</FONT></B></SPAN><BR>
<BR>
<FONT COLOR="#FF5600"><B>Action</B></FONT> can be a statement, label or line number if you prefer. If the <FONT COLOR="#8501B5"><B>condition</B></FONT> is true, then the statement will be executed. Specifying a line number or label will jump there if the <FONT COLOR="#8501B5"><B>condition</B></FONT> is true. Put into numerical terms, the result of any comparison that equals a zero is false, with all other numbers being true.
<BR><BR>
Note that in specific cases, assembly of if-then statements with a line number or label as the target will fail. If this happens, the assembler will report a &quot;branch out of range.&quot; One way to fix this is to change the offending if-then statement to if-then goto, or you can let the compiler fix the problem for you by turning on smart branching.
<BR><BR>
To do this, use the following:</P>
<PRE CLASS="bbborder">
set smartbranching on
</PRE>
<P>
Place it near the beginning of your program. Be aware that turning on smartbranching will slightly <acronym TITLE="Confuse, darken, make unclear.">obfuscate</acronym> the generated assembly file, so do not use it if you plan to examine the assembly later to see how it works.
See <A HREF="#smartbranching">smartbranching</A> for more information.<BR><BR>
There are three types of if-then statements. The first is a simple check where the condition is a single statement.
<BR><BR>
For example:</P>
<PRE CLASS="bbborder">
if a then 20
</PRE>
<P>
diverts program flow to line 20 if <B>a</B> is anything except zero.
<BR><BR>
This type of if-then statement is more often used for checking the state of various read registers. For example, the joysticks, console switches, single bits and hardware collisions are all checked this way.
<BR><BR>
For example:</P>
<PRE CLASS="bbborder">
if joy0up then x = x + 1
</PRE>
<P>
That will add 1 to <B>x</B> if the left joystick is pushed up.</P>
<PRE CLASS="bbborder">
if switchreset then 200
</PRE>
<P>
Jumps to line 200 if the reset switch on the console is set.
</P>
<PRE CLASS="bbborder">
if collision(player1,playfield) then t=1
</PRE>
<P>
Sets <B>t</B> to 1 if player1 collides with the playfield.
</P>
<PRE CLASS="bbborder">
if !a{3} then a{4}=1
</PRE>
<P>
Sets bit 4 of <B>a</B> if bit 3 of <B>a</B> is zero. See <A HREF="#bit">Bit Operations</A> for more information about using single bits.
<BR><BR>
A second type of statement includes a simple comparison. Valid comparisons are = , &lt; , &gt;, &lt;=, &gt;=, and &lt;&gt;.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
if a &lt; 2 then 50
if f = g then f = f + 1
if r &lt;&gt; e then r = e
</PRE>
<P>
The third type of if-then is a complex or compound statement, that is, one containing a boolean &amp;&amp; (AND) or || (OR) operator. You are allowed one || for each if-then. You can use more than one &amp;&amp; in a line, but you cannot mix &amp;&amp; and ||.
<BR><BR>
For example:
</P>
<PRE CLASS="bbborder">
if x &lt; 10 &amp;&amp; x &gt; 2 then b = b - 1
if !joy0up &amp;&amp; gameover = 0 then 200
if x = 5 || x = 6 then x = x - 4
</PRE>
<P>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> Using multiple if-thens in a single line might not work correctly if you are using boolean operators.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="boolean">Boolean Operators</A></B></H6>
<P>
Boolean operators are used as conditions in if-then statements. They are tokenized as:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>&amp;&amp; = AND</B></SPAN><BR>
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>|| = OR</B></SPAN><BR>
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>! = NOT</B></SPAN><BR>
<BR>
You may use &amp;&amp; or || in a statement, but you cannot mix them. You can use only one || but you may use more than one &amp;&amp; if you wish. The NOT ( ! ) operator may only be used with statements that do not include a comparison token (such as =, &lt;, &gt;, or &lt;&gt;).
<BR><BR>
For example:
</P>
<PRE CLASS="bbborder">
if a &lt; 31 &amp;&amp; a &gt; 0 then 50
if a = 2 || a = 4 then a = a + 1
if !joy0up then 200
</PRE>
<P>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> If you use || in an if-then statement, the statement must be located at the beginning of a line. At this time, compilation will succeed but your program will probably not work correctly. This issue will probably be fixed in a later version.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="else">else</A></B></H6>
<P>
You may use <B>else</B> after an if-then statement. An if-then will check if a condition is true and divert program flow, but an else allows you to also divert program flow in a different way if the condition turns out to be false.
<BR><BR>
An else must be on the same line as the if-then that it belongs to. You can include statements separated by colons before the else, but the else must not come after a colon itself.
<BR><BR>
For example:
</P>
<PRE CLASS="bbborder">
if r=2 then 20 else 30
if a&gt;b then r=2:pfpixel 3 5 on: d=d-1 else d=d+1:r=3
if a&gt;b then 20 else c[4]=12
</PRE>
<P>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> The else keyword might not work correctly in a statement containing &amp;&amp;. The else keyword may also not work as expected when there is more than one if-then on a single line.
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="loops">Loops</A></H3>
<P>
A common form of a loop is a for-next loop, but a loop in general is any program that repeats. In this sense, all batari Basic programs must be loops, in that the programs never exit.
<BR><BR>
In batari Basic, you should limit your use of loops that do not include the drawscreen function somewhere. Too many loops take time which is somewhat limited. See <A HREF="#drawscreen">drawscreen</A> for more information.<BR>
</P>
<UL>
<H6 CLASS="bbsecondary"><B><A NAME="for">for-next</A></B></H6>
<P>
For-next loops work similar to the way they work in other Basics.
<BR><BR>
The syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>for <FONT COLOR="#229922">variable</FONT> = <FONT COLOR="#FF5600">value1</FONT> to <FONT COLOR="#345DF3">value2</FONT> [step <FONT COLOR="#8501B5">value3</FONT>]</B></SPAN>
<BR><BR>
<B><FONT COLOR="#009900">Variable</FONT></B> is any variable, and <B><FONT COLOR="#FF5600">value1</FONT></B>, <B><FONT COLOR="#345DF3">2</FONT></B>, and <B><FONT COLOR="#8501B5">3</FONT></B> can be variables or numbers. You may also
specify a negative step for <B><FONT COLOR="#8501B5">value3</FONT></B>.
<BR><BR>
The <B>step</B> keyword is optional. Omitting it will default the step to 1.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
for x = 1 to 10
for a = b to c step d
for l = player0y to 0 step -1
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="next">next</A></B></H6>
<P>
Normally, you would place a variable after the next keyword, but batari Basic ignores the keyword and instead finds the nearest <B>for</B> and jumps back there. Therefore, the usual way to call <B>next</B> is without a variable. If any variable is specified after a next, it will be ignored.
<BR><BR>
Example:</P>
<PRE CLASS="bbborder">
for x = 1 to 10: a[x] = x : next
</PRE>
<P>
It is also important to note that the <B>next</B> doesn't care about the program flow — it will instead find the nearest <B>for</B> based on distance.
<BR><BR>
For example:</P>
<PRE CLASS="bbborder">
for x = 1 to 20
goto 100
for g = 2 to 49
100 next
</PRE>
<P>
The <B>next</B> above <B><FONT COLOR="#CC0033">WILL NOT</FONT></B> jump back to the first <B>for</B>, instead it will jump to the nearest one, even if this statement has never been executed. Therefore, you should be very careful when using <B>next</B>.
<BR><BR>
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="randomnumbers">Random Numbers</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B><A NAME="rand">rand</A></B></H6>
<P>
<B>rand</B> is a special variable that will implicitly call an 8-bit random number generator when used.
<BR><BR>
The rand function returns a psuedo-random number between 1 and 255 every time it is called. You typically call this function by something like this:
</P>
<PRE CLASS="bbborder">
a = rand
</PRE>
<P>
However, you can also use it in an <A HREF="#if">if-then</A> statement:</P>
<PRE CLASS="bbborder">
if rand &lt; 32 then r = r + 1
</PRE>
<P>
You can also assign the value of rand to something else, at least until it is accessed again. The only reason you would ever want to do this is to seed the randomizer. If you do this, pay careful attention to the value you store there, since storing a zero in rand will &quot;break&quot; it such that all subsequent reads will also be zero!
<BR><BR>
The standard random number generator should be random enough for most games. However, if it isn't random enough, you can optionally specify a 16-bit random number generator. This requires that you set aside one variable, and you can't use this variable for other purposes. To use the improved routine, place:
</P>
<PRE CLASS="bbborder">
dim rand16=&lt;<B>var</B>&gt;
</PRE>
<P>
at the beginning of your program. &lt;<B>var</B>&gt; is one of your 26 variables (a-z.) Then you use <B>rand</B> as you normally would.
<BR><BR>
In bank-switched games, <B>rand</B> may slow down your game if you use it often, as it is typically necessary to switch banks every time it is called. You can get around this limitation using one of the optimization options (see <A HREF="#optimization">optimization</A> under <A HREF="#set">compiler directives</A>.)
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="dataarrays">Data Statements and Arrays (read-only)</A></H3>
<P>
For convenience, you may specify a list of values that will essentially create a read-only array in ROM. You create these lists of values as data tables using the data statement. Although the data statement is similar in its method of operation as in other Basic languages, there are some important differences. Most notably, access to the data does not need to be linear as with the read function in other Basics, and the size is limited to 256 bytes.
<BR><BR>
If you prefer to use a data statement similar to that in other Basics and don't want to be limited to 256 bytes, see <A HREF="#sdata">Sequential Data</A> below.
<BR><BR>
In a regular data statement, any element of the data statement can be accessed at any time. In this vein, it operates like an array. To declare a set of data, use <B>data</B> at the beginning of a line, then include an identifier after the statement. The actual data is included after a linefeed and can continue for a number of lines before being terminated by <B>end</B>. Suppose you declare a data statement as follows, with array name <B>mydata</B>:
</P>
<PRE CLASS="bbborder">
data mydata
200, 43, 33, 93, 255, 54, 22
end
</PRE>
<P>
To access the elements of the data table, simply index it like you would an array in RAM. For example, mydata[0] is 200, mydata[1] is 43, ... and mydata[6] is 22. The maximum size for a data table is 256 elements. Note that there is no checking to see if you have accessed values beyond the table. Doing so will not cause any errors, but the values you get probably won't be very useful.
<BR><BR>
To help prevent this from happening, a constant is defined with every data statement — this constant contains the length, or the number of elements, in the data. The constant will have the same name as the name of the data statement, but it will have _length appended to it.
<BR><BR>
For example, if you declare:
</P>
<PRE CLASS="bbborder">
data mydata
1,2,3,4,5,6,7,8,9
end
</PRE>
<P>
you can then access the length of the data with mydata_length. You can assign this to variables or use anywhere else you would use a number.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
a = mydata_length
</PRE>
<P>
Note again that these data tables are in ROM. Attempting to write values to data tables with commands like mydata[1]=200 will compile but will perform no function.
</P>
<UL>
<H6 CLASS="bbsecondary"><B><A NAME="sdata">Sequential Data (or large data)</A></B></H6>
<P>
The sdata statement will define a set of data that is accessed more like the data in other Basics. The 256-byte limitation is also removed — the effective length is only limited by the size of each bank (4K). <acronym TITLE="In a row or in order without gaps.">Sequential</acronym> data is useful for things like music or a large set of scrolled playfield data. There is also no need to specify a pointer into the data.
<BR><BR>
One drawback, however, is each sequential data statement requires two adjacent variables from normal 2600's RAM (not Superchip) be set aside.
<BR><BR>
To define the set of data, use:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>sdata &lt;<FONT COLOR="#FF5600">name</FONT>&gt;=&lt;<FONT COLOR="#8501B5">variable</FONT>&gt;</B></SPAN>
<BR><BR>
&lt;<B><FONT COLOR="#FF5600">name</FONT></B>&gt; is the name you wish to call it when it is read, and &lt;<B><FONT COLOR="#8501B5">variable</FONT></B>&gt; is the first variable name you are setting aside. Although you just specify one variable, the next variable in sequence will also be used.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
sdata mymusic=a
1,2,3,4,5,6,7,255
end
</PRE>
<P>
The above will set up a sequential data table called <B>mymusic</B> that uses variables <B>a</B> and <B>b</B> to remember the element at which it is currently pointing.
<BR><BR>
Unlike regular data statements, the program must actually run over the sdata statement for it to be properly initialized to the beginning of the data table. Also, it must typically be defined outside the game loop because each time the program runs over the statement, it will be reinitialized to the beginning of the table.
<BR><BR>
To read the data, use the <B CLASS="bm"><A NAME="sread">sread</A></B> function. It works somewhat similar to a regular bB function. Example:
</P>
<PRE CLASS="bbborder">
t = sread(mymusic)
</PRE>
<P>
This will get the next value in the data table <B>mymusic</B> and place it in <B>t</B>.
<BR><BR>
Note that unlike other Basics, there is no error or other indication when reaching the end of data. Since there is no data length variable defined with sequential data, it's usually necessary to place a terminal value at the end of your data. In the above example, 255 was used. In the above example you would then check <B>t</B> for 255.
<BR><BR>
There is no restore function like other basics. However, if you allow your program to run over the sdata statement again, it will be initialized to the beginning of data just like the restore function.
<BR><BR>
Note that all data tables, sequential or otherwise, must be located in the same bank where they are read. If you try to access data that lives in another bank, there will be no errors but the data you get will certainly be incorrect.
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="colors">Colors</A></H3>
<P>
The Atari 2600 can display up to 128 unique colors — that is, 16 unique hues and 8 <acronym TITLE="Brightness.">luminosity</acronym> levels for each hue for <acronym TITLE="National Television Systems Committee or jokingly, Never The Same Color">NTSC</acronym> consoles (see <A HREF="#tv">tv directive</A>.) <acronym TITLE="Phase Alternation Line or jokingly, Picture Always Lousy or Pay Another Licence">PAL</acronym> consoles can display 104 unique colors (13 hues with 8 luminosity levels.)
<BR><BR>
Each player object can be colored independently, as can the playfield, background, score, and objects drawn in a minikernel. Also, you can make multicolored objects by using <A HREF="#kerneloptions">kernel options</A>. The missiles, however, must share their colors with their respective player objects, and the ball will generally be the same color as the playfield.
</P>
<UL>
<H6 CLASS="bbsecondary"><A NAME="colubk"><FONT COLOR="#8501B5">CO</FONT><FONT COLOR="#FF5600">LU</FONT><FONT COLOR="#345DF3">BK</FONT></A> <SPAN STYLE="font-size:14px;">(Color-Luminosity Background)</SPAN></H6>
<P>
Sets the background color. Example: <B>COLUBK = 112</B>
<BR>
</P>
<H6 CLASS="bbsecondary"><B><A NAME="colupf"><FONT COLOR="#8501B5">CO</FONT><FONT COLOR="#FF5600">LU</FONT><FONT COLOR="#345DF3">PF</FONT></A> </B><SPAN STYLE="font-size:14px;">(Color-Luminosity Playfield, Ball)</SPAN></H6>
<P>
Sets the playfield color and ball color. Example: <B>COLUPF = 154</B>
<BR>
</P>
<H6 CLASS="bbsecondary"><A NAME="colup0"><FONT COLOR="#8501B5">CO</FONT><FONT COLOR="#FF5600">LU</FONT><FONT COLOR="#345DF3">P0</FONT></A> <SPAN STYLE="font-size:14px;">(Color-Luminosity Player 0, Missile 0)</SPAN></H6>
<P>
Sets the color for player 0 and missile 0. Example: <B>COLUP0 = 42</B>
<BR>
</P>
<H6 CLASS="bbsecondary"><A NAME="colup1"><FONT COLOR="#8501B5">CO</FONT><FONT COLOR="#FF5600">LU</FONT><FONT COLOR="#345DF3">P1</FONT></A> <SPAN STYLE="font-size:14px;">(Color-Luminosity Player 1, Missile 1)</SPAN></H6>
<P>
Sets the color for player 1 and missile 1. Example: <B>COLUP1 = 222</B>
<BR>
</P>
<H6 CLASS="bbsecondary"><B><A NAME="colorchart">Atari 2600 NTSC TIA Color Chart</A></B> (Decimal Numbers)</H6>
<P>Below is a color chart to make it easier to select colors for your games. I included colors from the two most popular emulators. It seems like Stella is closer to the real colors, but you may not agree. If you need PAL colors, check out <A HREF="http://www.qotile.net/minidig/docs/tia_color.html" TARGET="_blank" TITLE="External site opens in new window">Glenn Saunder's HTML TIA color chart</A>.
<BR><BR>
</P>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="black">
<TR ALIGN="center">
<TD WIDTH="42" BGCOLOR="white">
<FONT FACE="Arial"><SPAN STYLE="font-size:10pt;">&nbsp;&nbsp;&nbsp;#</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">Stella</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">z26</SPAN></FONT></TD>
<TD WIDTH="42" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:10pt;">&nbsp;&nbsp;&nbsp;#</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">Stella</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">z26</SPAN></FONT></TD>
<TD WIDTH="42" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:10pt;">&nbsp;&nbsp;&nbsp;#</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">Stella</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">z26</SPAN></FONT></TD>
<TD WIDTH="42" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:10pt;">&nbsp;&nbsp;&nbsp;#</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">Stella</SPAN></FONT></TD>
<TD WIDTH="47" BGCOLOR="white"><FONT FACE="Arial"><SPAN STYLE="font-size:8pt;">z26</SPAN></FONT></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">0</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#000000"></TD>
<TD WIDTH="47" BGCOLOR="#000000"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">64</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#940000"></TD>
<TD WIDTH="47" BGCOLOR="#7D122C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">128</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#000094"></TD>
<TD WIDTH="47" BGCOLOR="#252593"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">192</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#004400"></TD>
<TD WIDTH="47" BGCOLOR="#0F550A"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">2</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#4A4A4A"></TD>
<TD WIDTH="47" BGCOLOR="#505050"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">66</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A71A1A"></TD>
<TD WIDTH="47" BGCOLOR="#912640"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">130</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#181AA7"></TD>
<TD WIDTH="47" BGCOLOR="#3939A7"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">194</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#1A661A"></TD>
<TD WIDTH="47" BGCOLOR="#23691E"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">4</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#6F6F6F"></TD>
<TD WIDTH="47" BGCOLOR="#646464"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">68</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B83232"></TD>
<TD WIDTH="47" BGCOLOR="#A53A54"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">132</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#2D32B8"></TD>
<TD WIDTH="47" BGCOLOR="#4D4DBB"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">196</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#328432"></TD>
<TD WIDTH="47" BGCOLOR="#377D32"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">6</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#8E8E8E"></TD>
<TD WIDTH="47" BGCOLOR="#787878"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">70</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C84848"></TD>
<TD WIDTH="47" BGCOLOR="#B94E68"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">134</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#4248C8"></TD>
<TD WIDTH="47" BGCOLOR="#6161CF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">198</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#48A048"></TD>
<TD WIDTH="47" BGCOLOR="#4B9146"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">8</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#AAAAAA"></TD>
<TD WIDTH="47" BGCOLOR="#8C8C8C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">72</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D65C5C"></TD>
<TD WIDTH="47" BGCOLOR="#CD627C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">136</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#545CD6"></TD>
<TD WIDTH="47" BGCOLOR="#7575E3"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">200</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#5CBA5C"></TD>
<TD WIDTH="47" BGCOLOR="#5FA55A"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">10</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C0C0C0"></TD>
<TD WIDTH="47" BGCOLOR="#A0A0A0"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">74</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#E46F6F"></TD>
<TD WIDTH="47" BGCOLOR="#E17690"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">138</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#656FE4"></TD>
<TD WIDTH="47" BGCOLOR="#8989F7"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">202</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#6FD26F"></TD>
<TD WIDTH="47" BGCOLOR="#73B96E"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">12</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D6D6D6"></TD>
<TD WIDTH="47" BGCOLOR="#B4B4B4"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">76</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#F08080"></TD>
<TD WIDTH="47" BGCOLOR="#F58AA4"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">140</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#7580F0"></TD>
<TD WIDTH="47" BGCOLOR="#9D9DFF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">204</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#80E880"></TD>
<TD WIDTH="47" BGCOLOR="#87CD82"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">14</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#ECECEC"></TD>
<TD WIDTH="47" BGCOLOR="#C8C8C8"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">78</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#FC9090"></TD>
<TD WIDTH="47" BGCOLOR="#FF9EB8"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">142</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#8490FC"></TD>
<TD WIDTH="47" BGCOLOR="#B1B1FF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">206</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#90FC90"></TD>
<TD WIDTH="47" BGCOLOR="#9BE196"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">16</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#484800"></TD>
<TD WIDTH="47" BGCOLOR="#445400"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">80</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#840064"></TD>
<TD WIDTH="47" BGCOLOR="#730871"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">144</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#001C88"></TD>
<TD WIDTH="47" BGCOLOR="#0F3480"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">208</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#143C00"></TD>
<TD WIDTH="47" BGCOLOR="#1F5100"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">18</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#69690F"></TD>
<TD WIDTH="47" BGCOLOR="#586800"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">82</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#97197A"></TD>
<TD WIDTH="47" BGCOLOR="#871C85"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">146</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#183B9D"></TD>
<TD WIDTH="47" BGCOLOR="#234894"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">210</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#355F18"></TD>
<TD WIDTH="47" BGCOLOR="#336505"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">20</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#86861D"></TD>
<TD WIDTH="47" BGCOLOR="#6C7C00"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">84</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A8308F"></TD>
<TD WIDTH="47" BGCOLOR="#9B3099"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">148</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#2D57B0"></TD>
<TD WIDTH="47" BGCOLOR="#375CA8"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">212</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#527E2D"></TD>
<TD WIDTH="47" BGCOLOR="#477919"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">22</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A2A22A"></TD>
<TD WIDTH="47" BGCOLOR="#809000"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">86</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B846A2"></TD>
<TD WIDTH="47" BGCOLOR="#AF44AD"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">150</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#4272C2"></TD>
<TD WIDTH="47" BGCOLOR="#4B70BC"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">214</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#6E9C42"></TD>
<TD WIDTH="47" BGCOLOR="#5B8D2D"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">24</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#BBBB35"></TD>
<TD WIDTH="47" BGCOLOR="#94A414"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">88</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C659B3"></TD>
<TD WIDTH="47" BGCOLOR="#C358C1"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">152</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#548AD2"></TD>
<TD WIDTH="47" BGCOLOR="#5F84D0"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">216</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#87B754"></TD>
<TD WIDTH="47" BGCOLOR="#6FA141"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">26</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D2D240"></TD>
<TD WIDTH="47" BGCOLOR="#A8B828"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">90</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D46CC3"></TD>
<TD WIDTH="47" BGCOLOR="#D76CD5"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">154</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#65A0E1"></TD>
<TD WIDTH="47" BGCOLOR="#7398E4"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">218</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#9ED065"></TD>
<TD WIDTH="47" BGCOLOR="#83B555"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">28</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#E8E84A"></TD>
<TD WIDTH="47" BGCOLOR="#BCCC3C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">92</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#E07CD2"></TD>
<TD WIDTH="47" BGCOLOR="#EB80E9"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">156</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#75B5EF"></TD>
<TD WIDTH="47" BGCOLOR="#87ACF8"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">220</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B4E775"></TD>
<TD WIDTH="47" BGCOLOR="#97C969"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">30</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#FCFC54"></TD>
<TD WIDTH="47" BGCOLOR="#D0E050"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">94</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#EC8CE0"></TD>
<TD WIDTH="47" BGCOLOR="#FF94FD"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">158</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#84C8FC"></TD>
<TD WIDTH="47" BGCOLOR="#9BC0FF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">222</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C8FC84"></TD>
<TD WIDTH="47" BGCOLOR="#ABDD7D"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">32</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#7C2C00"></TD>
<TD WIDTH="47" BGCOLOR="#673900"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">96</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#500084"></TD>
<TD WIDTH="47" BGCOLOR="#5D0B92"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">160</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#003064"></TD>
<TD WIDTH="47" BGCOLOR="#04425A"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">224</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#303800"></TD>
<TD WIDTH="47" BGCOLOR="#344600"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">34</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#904811"></TD>
<TD WIDTH="47" BGCOLOR="#7B4D00"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">98</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#68199A"></TD>
<TD WIDTH="47" BGCOLOR="#711FA6"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">162</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#185080"></TD>
<TD WIDTH="47" BGCOLOR="#18566E"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">226</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#505916"></TD>
<TD WIDTH="47" BGCOLOR="#485A00"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">36</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A26221"></TD>
<TD WIDTH="47" BGCOLOR="#8F6100"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">100</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#7D30AD"></TD>
<TD WIDTH="47" BGCOLOR="#8533BA"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">164</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#2D6D98"></TD>
<TD WIDTH="47" BGCOLOR="#2C6A82"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">228</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#6D762B"></TD>
<TD WIDTH="47" BGCOLOR="#5C6E14"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">38</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B47A30"></TD>
<TD WIDTH="47" BGCOLOR="#A37513"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">102</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#9246C0"></TD>
<TD WIDTH="47" BGCOLOR="#9947CE"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">166</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#4288B0"></TD>
<TD WIDTH="47" BGCOLOR="#407E96"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">230</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#88923E"></TD>
<TD WIDTH="47" BGCOLOR="#708228"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">40</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C3903D"></TD>
<TD WIDTH="47" BGCOLOR="#B78927"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">104</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A459D0"></TD>
<TD WIDTH="47" BGCOLOR="#AD5BE2"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">168</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#54A0C5"></TD>
<TD WIDTH="47" BGCOLOR="#5492AA"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">232</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A0AB4F"></TD>
<TD WIDTH="47" BGCOLOR="#84963C"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">42</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D2A44A"></TD>
<TD WIDTH="47" BGCOLOR="#CB9D3B"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">106</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B56CE0"></TD>
<TD WIDTH="47" BGCOLOR="#C16FF6"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">170</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#65B7D9"></TD>
<TD WIDTH="47" BGCOLOR="#68A6BE"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">234</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B7C25F"></TD>
<TD WIDTH="47" BGCOLOR="#98AA50"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">44</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#DFB755"></TD>
<TD WIDTH="47" BGCOLOR="#DFB14F"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">108</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C57CEE"></TD>
<TD WIDTH="47" BGCOLOR="#D583FF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">172</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#75CCEB"></TD>
<TD WIDTH="47" BGCOLOR="#7CBAD2"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">236</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#CCD86E"></TD>
<TD WIDTH="47" BGCOLOR="#ACBE64"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">46</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#ECC860"></TD>
<TD WIDTH="47" BGCOLOR="#F3C563"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">110</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D48CFC"></TD>
<TD WIDTH="47" BGCOLOR="#E997FF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">174</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#84E0FC"></TD>
<TD WIDTH="47" BGCOLOR="#90CEE6"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">238</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#E0EC7C"></TD>
<TD WIDTH="47" BGCOLOR="#C0D278"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">48</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#901C00"></TD>
<TD WIDTH="47" BGCOLOR="#7B2504"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">112</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#140090"></TD>
<TD WIDTH="47" BGCOLOR="#401599"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">176</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#004030"></TD>
<TD WIDTH="47" BGCOLOR="#044F30"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">240</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#482C00"></TD>
<TD WIDTH="47" BGCOLOR="#463E00"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">50</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A33915"></TD>
<TD WIDTH="47" BGCOLOR="#8F3918"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">114</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#331AA3"></TD>
<TD WIDTH="47" BGCOLOR="#5429AD"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">178</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#18624E"></TD>
<TD WIDTH="47" BGCOLOR="#186344"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">242</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#694D14"></TD>
<TD WIDTH="47" BGCOLOR="#5A5205"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">52</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#B55328"></TD>
<TD WIDTH="47" BGCOLOR="#A34D2C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">116</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#4E32B5"></TD>
<TD WIDTH="47" BGCOLOR="#683DC1"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">180</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#2D8169"></TD>
<TD WIDTH="47" BGCOLOR="#2C7758"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">244</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#866A26"></TD>
<TD WIDTH="47" BGCOLOR="#6E6619"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">54</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#C66C3A"></TD>
<TD WIDTH="47" BGCOLOR="#B76140"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">118</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#6848C6"></TD>
<TD WIDTH="47" BGCOLOR="#7C51D5"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">182</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#429E82"></TD>
<TD WIDTH="47" BGCOLOR="#408B6C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">246</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A28638"></TD>
<TD WIDTH="47" BGCOLOR="#827A2D"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">56</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D5824A"></TD>
<TD WIDTH="47" BGCOLOR="#CB7554"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">120</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#7F5CD5"></TD>
<TD WIDTH="47" BGCOLOR="#9065E9"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">184</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#54B899"></TD>
<TD WIDTH="47" BGCOLOR="#549F80"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">248</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#BB9F47"></TD>
<TD WIDTH="47" BGCOLOR="#968E41"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">58</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#E39759"></TD>
<TD WIDTH="47" BGCOLOR="#DF8968"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">122</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#956FE3"></TD>
<TD WIDTH="47" BGCOLOR="#A479FD"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">186</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#65D1AE"></TD>
<TD WIDTH="47" BGCOLOR="#68B394"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">250</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#D2B656"></TD>
<TD WIDTH="47" BGCOLOR="#AAA255"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">60</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#F0AA67"></TD>
<TD WIDTH="47" BGCOLOR="#F39D7C"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">124</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#A980F0"></TD>
<TD WIDTH="47" BGCOLOR="#B88DFF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">188</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#75E7C2"></TD>
<TD WIDTH="47" BGCOLOR="#7CC7A8"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">252</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#E8CC63"></TD>
<TD WIDTH="47" BGCOLOR="#BEB669"></TD>
</TR>
<TR ALIGN="right">
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">62</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#FCBC74"></TD>
<TD WIDTH="47" BGCOLOR="#FFB190"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">126</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#BC90FC"></TD>
<TD WIDTH="47" BGCOLOR="#CCA1FF"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">190</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#84FCD4"></TD>
<TD WIDTH="47" BGCOLOR="#90DBBC"></TD>
<TD WIDTH="42"><SPAN STYLE="font-size:10pt;"><FONT FACE="Courier" COLOR="white">254</FONT>&nbsp;</SPAN></TD>
<TD WIDTH="47" BGCOLOR="#FCE070"></TD>
<TD WIDTH="47" BGCOLOR="#D2CA7D"></TD>
</TR>
</TABLE>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="objects">Objects</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B>Player Graphics</B></H6>
<P>
The Atari 2600 can display two player sprites, which are 8 pixels wide and any height. You access these sprites by using various reserved values and commands. To define a sprite, you use <B>player0:</B> and <B>player1:</B>
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
player0:
%00100010
%01110111
%01111111
end
</PRE>
<P>
This will define a player0 sprite which is 3 blocks in height.
<BR><BR>
The <A HREF="#multikernel">multisprite kernel</A> allows you to define sprites 2-5 as well. Keep in mind that sprites 2-5 are actually virtual sprites, which are created by repositioning player1 several times during the visible screen.
<BR><BR>
Note that the bytes that make up a sprite are upside down in your code. Sprites will be flipped in the game. If you have trouble visualizing, you can try <A HREF="http://alienbill.com/2600/playerpalnext.html" TARGET="_blank" TITLE="External site opens in new window">Kirk Israel's Playerpal</A> or the Sprite Editor in attendo's <A HREF="http://alienbill.com/2600/basic/" TARGET="_blank" TITLE="External site opens in new window">batari Basic IDE</A>.
<BR><BR>
To display the objects, you must first set the colors with <B>COLUP0</B> and <B>COLUP1</B>. They are black by default, which will not display against a black background.
<BR><BR>
To set the coordinates, you set player0x, player0y, player1x, or player1y. On the screen, player0x and player1x values between 0 and 159 are useful, as they represent the extreme left and right edges of the screen. You can specify numbers larger than 159 but you may see some jumping at the edges of the screen. Values of player0y and player1y between 0 and about 88 are useful. Others will simply cause the player to move off of the screen.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="missiles">Missiles</A></B></H6>
<P>
Batari Basic can display two missiles on the screen. These are simply vertical lines of a height you specify, and at coordinates you specify. The missiles are the same color as their respective players.
<BR><BR>
To access missiles, you can set missile0x, missile0y, and missile0height for missile 0, and missile1x, missile1y, and missile1height for missile 1.
<BR><BR>
In the multisprite kernel, the missiles are fixed at one unit high, and the missile height variables do not exist.
<BR><BR>
There are more things you can do with missiles by modifying the NUSIZx TIA registers. See <A HREF="#tia">TIA Registers</A> for more information.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="ball">Ball</A></B></H6>
<P>
The ball is one of the objects that the Atari 2600 can display in the screen.
<BR><BR>
The ball is the same color as the playfield. It is accessed by ballx, bally, and ballheight, much like accessing the missiles.
<BR><BR>
In the multisprite kernel, the ball is fixed at one unit high, and the ballheight variable does not exist.
<BR><BR>
You can do a few more things with the ball by changing the CTRLPF TIA register. See <A HREF="#tia">TIA Registers</A> for more information.
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="collision">Collision Detection</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B><FONT COLOR="#345DF3">if</FONT> collision (<FONT COLOR="#FF5600">object</FONT>,<FONT COLOR="#8501B5">object</FONT>)</B></H6>
<P>
This function is used for checking if two objects have collided on the screen. Valid arguments are playfield, ball, player0, player1, missile0, missile1. The two objects can be specified in any order.
<BR><BR>
The collision() function is only valid when used in an if-then statement.
<BR><BR>
Note that the collision detection is hardware-based and is pixel-perfect. The collision detection may or may not be suitable for your game.
<BR><BR>
Note that in the <A HREF="#multikernel">multisprite kernel</A>, you can define objects player2 through player5. However, these are not valid arguments in the collision statement because the Atari 2600 cannot actually display 5 completely independent player objects. Player2-5 are virtual sprites, drawn by repositioning player1 several times during the visible screen. Therefore, a collision with player1 in the multisprite kernel means that you have hit one or more virtual players, and you must do further checks, for example, the y-positions, to determine which one.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
if collision(playfield,player0) then a = a + 1
if !collision(player0,missile1) then 400
</PRE>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="playfield">The Playfield</A></H3>
<P>
In the standard kernel, by default, you get a 32 x 11 bitmapped, asymmetric playfield (32 x 12 if you count the hidden row that is only seen if scrolled). The vertical playfield resolution is no longer fixed — it can be varied to some extent. See below for an explanation.
<BR><BR>
The <A HREF="#multikernel">multisprite kernel</A> gives you a 16-wide playfield, which is mirrored about the center of the screen. Plotting commands such as pfpixel, pfvline and pfhline do not work in this kernel. However, pfread does work if you include a special module. Horizontal scrolling is not possible, but support for vertical scrolling is planned.
<BR><BR>
The playfield resides in the full vertical length of the screen except for the area reserved for the score. Horizontally, the playfield only uses the center 80% of the screen due to timing constraints. You have only limited access to left or right 10% of the screen, namely you can only draw vertical lines there, and they take the full length of the screen. For example, you can put a vertical border around the drawable portion of the playfield by PF0=128. You can use <A HREF="#colubk">COLUBK</A> to set the background color and <A HREF="#colupf">COLUPF</A> to set the playfield color. See the <A HREF="#colorchart">color chart</A> for available colors.
<BR><BR>
You can specify an entire playfield in one command by using the <B>playfield:</B> command. The syntax of the command is:
<BR>
<SPAN STYLE="font-size:18px; line-height:32px;"><B>
&nbsp;playfield: &lt;<FONT COLOR="#FF5600">off</FONT>&gt; &lt;<FONT COLOR="#8501B5">on</FONT>&gt;<BR>
&nbsp;(pixels)<BR>
end<BR>
</B></SPAN>
<BR>
&lt;<FONT COLOR="#FF5600"><B>off</B></FONT>&gt; and &lt;<B><FONT COLOR="#8501B5">on</FONT></B>&gt; are optional. They allow you to change the off/on symbols for the playfield pixels. Default:. and X
example:
</P>
<PRE CLASS="bbborder">
playfield:
X.X...X..XX..X.XX.X....XX..X.X..
X.X....XX..X.X..X.X...X..XX..X.X
end
</PRE>
<P>
You can specify as many lines high as you want, but some may not display if you specify too many.
<BR><BR>
In the standard kernel, use 32 characters for each line.
<BR><BR>
In the multisprite kernel, the above only accepts 16 characters wide, and these 16 are reflected on the right.
<BR><BR>
Please see <A HREF="#pfpixel">pfpixel</A>, <A HREF="#pfvline">pfvline</A>, <A HREF="#pfhline">pfhline</A>, and <A HREF="#pfscroll">pfscroll</A> for more information about drawing to the playfield.
<BR><BR>
The playfield in the standard kernel is no longer fixed at 11+1 pixels high. It can be varied using the <B CLASS="bm"><A NAME="pfres">pfres</A></B> setting. The default value for the vertical resolution is 12. If you wish, you can set pfres to values from 3-11. This will shrink the vertical resolution of the playfield and sometimes the visible screen as well. Doing so has advantages, such as freeing up space for more variables and possibly giving more time for each frame in your bB code or <A HREF="#huds">minikernels</A>.
<BR><BR>
You set the value using <B>const</B>. Example:
</P>
<PRE CLASS="bbborder">
const pfres=10
</PRE>
<P>
The playfield uses 4 bytes for each row, so setting the height to 10 would free up 8 bytes that could then be used as variables. These variables are available as var0-var7.
<BR><BR>
Also, note that reducing the number of rows may or may not shrink the size of your screen. bB tries to fill as much of the screen as possible by varying the height of the pixel rows. The default row heights and free variables corresponding to the overall playfield height (pfres) is:
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Courier; font-size:18px; font-weight:bold; line-height:20px; margin-left:24px;">
<TR>
<TD WIDTH="128" CLASS="bbtdbot"><P STYLE="font-size:18px; padding:0px; margin:0px;"><B>pfres</B></P>
</TD>
<TD WIDTH="128" CLASS="bbtdbot"><P STYLE="font-size:18px; margin:0px; padding:0px;"><B>row height</B></P>
</TD>
<TD WIDTH="168" CLASS="bbtdbot"><P STYLE="font-size:18px; margin:0px; padding:0px;"><B>variables freed</B></P>
</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">12</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">&nbsp;8</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">none</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">11</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">&nbsp;8</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var3</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">10</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">&nbsp;9</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var7</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;9</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">10</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var11</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;8</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">12</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var15</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;7</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">13</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var19</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;6</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">16</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var23</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;5</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">19</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var27</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;4</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">24</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var31</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="128" CLASS="bbtdbot">&nbsp;3</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">32</TD>
<TD WIDTH="168" CLASS="bbtdbot bbtdside">var0-var35</TD>
</TR>
</TABLE>
<P>
<BR>
If you don't like the default row heights, you can specify your own by setting <B CLASS="bm"><A NAME="pfrowheight">pfrowheight</A></B>. Note that if pfres*pfrowheight exceeds 96, the screen size will increase and cut into your bB program's time, or in extreme cases, will make the screen jitter, shake or roll.
<BR><BR>
To set pfrowheight, use <B>const</B>:
</P>
<PRE CLASS="bbborder">
const pfrowheight=7
</PRE>
<P>
If you do not want to be stuck using constant row heights, you can specify the height of individual playfield rows by setting the pfheights kernel option. See <A HREF="#set">Compiler Directives</A> for more information.
<BR><BR>
Lastly, if you are using Superchip RAM, you can use a pfres value up to 32, and all variables from var0-var47 are always free for general use. See <A HREF="#superchipram">Superchip</A> for more information about using Superchip RAM.
</P>
<UL>
<H6 CLASS="bbsecondary"><B><A NAME="drawscreen">drawscreen</A></B></H6>
<P>
The drawscreen command displays the screen. Any objects with changed colors, positions or height will be updated. Internally, this command runs the display kernel.
<BR><BR>
Normally, drawscreen is called once within the normal game loop, but it can be called anywhere. The drawscreen operation takes about 12 milliseconds to complete, since it needs to render the entire television display, one scanline at a time. Control will be returned to batari Basic once the visible portion of the screen has been rendered.
<BR><BR>
It is important to note that the drawscreen command must be run at least 60 times a second. Aside from rendering the visible screen, drawscreen also sends synchronization signals to the television. Failure to run drawscreen quickly enough will result in a display that shakes, jitters, or at worst, rolls.
<BR><BR>
Therefore, it is possible that your game loop will take up too much time and cause the television to lose sync. Note that your game loop cannot execute for more than around 2 milliseconds, so you should keep the number of loops and calls to playfield scrolling routines to a minimum. This works out to about 2,700 machine cycles, which can get used up pretty fast if you are doing many complicated operations.
<BR><BR>
If your screen rolls, jitters or shakes, the only solution is to simplify your operations or to try and spread your operations across two or more television frames by calling drawscreen at strategic times. Note also that doing so may slow your game down if you do not also move your sprites or other objects between calls to drawscreen.
<BR><BR>
Note that emulators are very forgiving about timing, and real hardware will exhibit display problems well before an emulator will. To help troubleshoot timing problems, bB has two debug modes, described elsewhere in this document.
<BR><BR>
If you do run out of time, you will need to optimize your code and/or spread it across multiple frames, which could slow down the game.
<BR><BR>
One alternative is to place some code in the vertical blank area. See <A HREF="#vblank">vblank</A> command for more information about placing code here.
</P>
<UL>
<H6 CLASS="bbtertiary"><A NAME="vblank">vblank</A></H6>
<P>
Normally, bB code runs in overscan. This is the portion of the television screen, roughly 2 milliseconds long, after the visible screen but before the synchronization signals are sent to the television. After this is an area called vertical blank, where the picture is blanked for a couple of milliseconds before the display kernel renders the visible screen.
<BR><BR>
bB runs its kernel setup routines in vertical blank, such as horizontal positioning and setting up the score, and additionally, the multisprite kernel uses this time to determine which virtual sprites to display. With recent improvements in bB's standard kernel, there is now some time available here. How much time depends on a number of factors, but in most cases it should be at least 1000 cycles. You can now run some bB code here if you wish.
<BR><BR>
To use, place the vblank keyword in your code. For example, to scroll left in vblank:
<BR>
</P>
<PRE CLASS="bbborder">
vblank
pfscroll left
return
</PRE>
<P>
The code in vblank will be run automatically every time a drawscreen is called. You can specify vblank only once, and the code should be physically separate from the rest of your code (in other words, it's inadvisable to allow your regular bB code to 'run into' the vblank code.)
<BR><BR>
vblank can be used in bank-switched games, but it must be placed in the last bank (bank 2 for 8K, bank 4 for 16K, and bank 8 for 32K games.)
<BR><BR>
Note that running code here means that certain changes won't take effect until the next drawscreen. Particularly, changing x-positions of objects or the score will be delayed.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> Although some time was freed in the vertical blank area, there still isn't a great deal. In the multisprite kernel, there isn't much time here at all. Although you can still use vblank in the multisprite kernel, its use isn't recommended unless you know what you are doing. Also, at this time there isn't an automatic way to check for the number of cycles left in vblank (as is done using set debug cyclescore.)
</P>
</UL>
<H6 CLASS="bbsecondary"><B><A NAME="pfpixel">pfpixel</A></B> (playfield pixel) •</H6>
<P>
This draws a single pixel with playfield blocks. Uses 80 processor cycles every frame. The syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>pfpixel <FONT COLOR="#229922">xpos</FONT> <FONT COLOR="#FF5600">ypos</FONT> <FONT COLOR="#8501B5">function</FONT></B></SPAN>
<BR><BR>
<B><FONT COLOR="#229922">xpos</FONT></B> can be 0-31, <B><FONT COLOR="#FF5600">ypos</FONT></B> can be 0-11 (11 is hidden off of the screen and only seen if scrolled.)
<BR><BR>
<B><FONT COLOR="#8501B5">function</FONT></B> is any of <B>on</B>, <B>off</B>, or <B>flip</B>. <B>On</B> turns the block on, <B>off</B> turns it off, and <B>flip</B> turns it off if it was on or on if it was off.
<BR><BR>
Note that there is no checking if the bounds of the function are exceeded. If you do so, strange things may happen, including crashing your program.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><A NAME="pfhline">pfhline</A></B> (playfield horizontal line) —</H6>
<P>
This draws a horizontal line with playfield blocks. Uses 250 to 1500 processor cycles every frame depending on length (Approx 210+42*length). The syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>pfhline <FONT COLOR="#229922">xpos</FONT> <FONT COLOR="#FF5600">ypos</FONT> <FONT COLOR="#345DF3">endxpos</FONT> <FONT COLOR="#8501B5">function</FONT></B></SPAN>
<BR><BR>
<B><FONT COLOR="#229922">xpos</FONT></B> can be 0-31, <B><FONT COLOR="#FF5600">ypos</FONT></B> can be 0-11 (11 is hidden off of the screen and only seen if scrolled).
<BR><BR>
<B><FONT COLOR="#345DF3">endxpos</FONT></B> should be greater than <B><FONT COLOR="#229922">xpos</FONT></B> or the command will not work properly, and strange things may happen.
<BR><BR>
<B><FONT COLOR="#8501B5">function</FONT></B> is any of <B>on</B>, <B>off</B>, or <B>flip</B>. <B>On</B> turns the block on, <B>off</B> turns it off, and <B>flip</B> turns it off if it was on or on if it was off.
<BR><BR>
Note that there is no checking if the bounds of the function are exceeded. If you do so, strange things may happen, including crashing your program.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="pfvline">pfvline</A></B> (playfield vertical line) |</H6>
<P>
This draws a vertical line with playfield blocks. Uses 230 to 600 processor cycles every frame depending on length (Approx 200+34*length). The syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>pfhline <FONT COLOR="#229922">xpos</FONT> <FONT COLOR="#FF5600">ypos</FONT> <FONT COLOR="#345DF3">endypos</FONT> <FONT COLOR="#8501B5">function</FONT></B></SPAN>
<BR><BR>
<B><FONT COLOR="#229922">xpos</FONT></B> can be 0-31, <B><FONT COLOR="#FF5600">ypos</FONT></B> can be 0-11 (11 is hidden off of the screen and only seen if scrolled).
<BR><BR>
<B><FONT COLOR="#345DF3">endypos</FONT></B> should be greater than <B><FONT COLOR="#FF5600">ypos</FONT></B> or the command will not work properly, and strange things may happen.
<BR><BR>
<B><FONT COLOR="#8501B5">function</FONT></B> is any of <B>on</B>, <B>off</B>, or <B>flip</B>. <B>On</B> turns the block on, <B>off</B> turns it off, and <B>flip</B> turns it off if it was on or on if it was off.
<BR><BR>
Note that there is no checking if the bounds of the function are exceeded. If you do so, strange things may happen, including crashing your program.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="pfscroll">pfscroll</A></B> (playfield scroll)</H6>
<P>
This command scrolls the playfield. It is useful for a moving background or other purposes.
<BR><BR>
Valid values are:<BR>
<SPAN STYLE="font-size:18px; line-height:32px;"><B>
pfscroll left
<BR>
pfscroll right
<BR>
pfscroll up
<BR>
pfscroll down
<BR>
pfscroll upup
<BR>
pfscroll downdown
</B></SPAN>
<BR><BR>
Using pfscroll left or right will use quite a few processor cycles every frame (500 cycles), so use it sparingly. Using pfscroll up or down uses 650 cycles every 8th time it's called, 30 cycles otherwise.
<BR><BR>
When using pfscroll up or down, the hidden blocks at y position 11 are useful. Although these blocks are never seen, they are &quot;scrolled in&quot; to the visible screen by the commands. This invisible area can therefore be used to simulate a changing background, instead of showing the same background over and over again.
<BR><BR>
upup and downdown will scroll two lines at a time without the need for calling the routine twice.
<BR><BR>
Playfield plotting and scrolling commands do not work with the <A HREF="#multikernel">multisprite kernel</A>. If you try to use them, chances are the program will not compile, or if it does, your program may crash.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="pfread">pfread function</A></B></H6>
<P>
pfread is used to determine whether an existing playfield pixel is on or off. It can only be used in an if-then statement at this time. You may use numbers, variables or arrays as arguments.
<BR><BR>
You access it as follows:
</P>
<PRE CLASS="bbborder">
if pfread(10,8) then 20
if !pfread(a[x], b) then 40
</PRE>
<P>
If you are using the multisprite kernel, you can use a special pfread module, called pfread_msk.asm, made just for this kernel. It is not enabled by default. To enable it, you can use the include or inline command in a 2K or 4K game. For a bank-switched game, only the inline command will work, and the command must be placed in the last bank. For example:
</P>
<PRE CLASS="bbborder">
inline pfread_msk.asm
</PRE>
<P>
The command will work in a similar manner to the standard kernel except that y-values are reversed. See <A HREF="#inline">inline</A> for more information about this command and its proper use. Alternatively, you can create a custom includes file with this module placed such that it will live in the last bank.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="score">score</A></B></H6>
<P>
The score keyword is used to change the score. The score is fixed at 6 digits, and it currently resides permanently at the bottom of the screen. Unlike other variables, batari Basic accepts values from 0-999999 when dealing with the score.
<BR><BR>
Before the score will appear, you should set its color:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>scorecolor = <FONT COLOR="#FF5600">value</FONT></B></SPAN>
<BR><BR>
<B><FONT COLOR="#FF5600">value</FONT></B> should be a number between 0 and 255 in accordance with the <A HREF="#colorchart">color chart</A>.
<BR><BR>
To change the score, some examples of valid operations are:
<BR>
</P>
<PRE CLASS="bbborder">
score = 1000
score = score + 2000
score = score - 10
score = score + a
</PRE>
<P>
Be careful when using the last one. It will compile, but upon execution, <B>a</B> must always be a <A HREF="#bcd">BCD compliant number</A>. If a non-BCD number is in <B>a</B>, part of your score may end up garbled.
<BR><BR>
Conditional statements don't work properly with the score. For example, &quot;if score&lt;10&quot; will compile correctly but will not check if the score is less than 10. This is because the score is a special object: a 24-bit BCD number.
<BR><BR>
If you plan to check to score, you will need to break out its 6 digits into 3 sets of two digits and check each one. One way to pull out the score digits is:
</P>
<PRE CLASS="bbborder">
dim sc1=score
dim sc2=score+1
dim sc3=score+2
</PRE>
<P>
sc1 will contain the first two digits, sc2 the 3rd and 4th, and sc3 the last two. Since these are all BCD numbers, you need to place a &quot;$&quot; in front of any values you check. For example, to check if the score is less than 10:
</P>
<PRE CLASS="bbborder">
if sc1=$00 &amp;&amp; sc2=$00 &amp;&amp; sc3&lt;$10 then ...
</PRE>
<P>
To check if the score is greater than 123456:
</P>
<PRE CLASS="bbborder">
if sc1&gt;=$12 &amp;&amp; sc2&gt;=$34 &amp;&amp; sc3&gt;$56 then ...
</PRE>
<P>
Breaking out score digits is also useful for setting the score to display special values or custom graphics. You can modify score_graphics.asm to include definitions for digits &quot;A-F&quot; and set the score digits manually. How to do this is beyond the scope of this document, but it has been discussed in detail in the <A HREF="http://www.atariage.com/forums/index.php?showforum=65" TARGET="_blank" TITLE="External site opens in new window">AtariAge 2600 Basic forum</A>.
</P>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="pfscorebars">pfscore bars</A></B></H6>
<P>
The area reserved for the score now also contains two 8-wide bars that can be used to display lives, health or other game information. This feature may be enabled by setting <B>pfscore</B> using <B>const</B>. Example:
</P>
<PRE CLASS="bbborder">
const pfscore=1
</PRE>
<P>
The value doesn't matter, as bB will simply look to see if pfscore is defined. This method will be replaced at a later date with the <A HREF="#set">set command</A>, which will give other control over the score. Although the const method will be deprecated then, it will continue to work.
<BR><BR>
The 8-wide bars (called pfscore bars because they use playfield registers) have three special variables:
<BR><BR>
</P>
<UL>
<P>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="pfscorecolor">pfscorecolor</A></B></SPAN><BR>
Color of the bars.
<BR><BR>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="pfscore1">pfscore1</A></B></SPAN><BR>
Binary value displayed left of score.
<BR><BR>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="pfscore2">pfscore2</A></B></SPAN><BR>
Binary value displayed right of score, reversed bit order
<BR><BR>
</P>
</UL>
<P>
For example: Suppose you want to use the left pfscore bar for lives and the right one for health. To initialize, you might do:
</P>
<PRE CLASS="bbborder">
pfscore1=168
pfscore2=255
</PRE>
<P>
The above sets the left bar for 3 separate dots (indicating lives) and the right bar will be full-width.
<BR><BR>
To decrement a life:
</P>
<PRE CLASS="bbborder">
pfscore1=pfscore1/4
</PRE>
<P>
To decrement the health bar:
</P>
<PRE CLASS="bbborder">
pfscore2=pfscore2/2
</PRE>
<P>
When there are no lives left, pfscore1 is zero. Also, when the health bar is empty, pfscore2 is zero.
<BR><BR>
Note that you cannot use pfscore bars in conjunction with the HUDs that are currently available without hacking the source files because they use the same memory locations for their variables.
<BR><BR>
If you wish to disable the score completely, you may do so by defining <B CLASS="bm"><A NAME="noscore">noscore</A></B>. At this time, you can do that by:
</P>
<PRE CLASS="bbborder">
const noscore=1
</PRE>
<P>
As with pfscore above, this method will be deprecated later when score options are integrated with the <A HREF="#set">set command</A>.
</P>
</UL>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="bcd">What is a BCD Compliant Number?</A></B></H6>
<P>
BCD stands for Binary-coded decimal. In essence, it is a hexadecimal number represented as a decimal number.
<BR><BR>
For instance, $99 is the BCD number for decimal 99. $23 is the BCD number for decimal 23. There is no BCD number for $3E, for instance, since it contains a non-decimal value (the E.) For example, if &quot;a&quot; contained $3E, your score could end up garbled.
<BR>
</P>
</UL>
<H6 CLASS="bbsecondary"><B><A NAME="tia">TIA Registers</A></B></H6>
<P>
There are a few TIA registers that may be useful in batari Basic. This is not a complete list. I'm only mentioning the registers and functions therein that you will most likely find useful. You can learn more by visiting the <A HREF="http://alienbill.com/2600/101/docs/stella.html" TARGET="_blank" TITLE="External site opens in new window">Stella Programmer's Guide</A>.
</P>
<UL>
<H6 CLASS="bbtertiary"><A NAME="nusiz">Registers: <B>NUSIZ0</B>, <B>NUSIZ1</B></A></H6>
<P>
Changes the size and/or other properties of player0/1 and missile0/1.
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:18px; font-weight:bold; margin-left:24px;">
<TR>
<TD WIDTH="176" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>value</B></SPAN>
</TD>
<TD WIDTH="416" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>effect</B></SPAN>
</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$0x (x means don't care)</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">missile = 1 pixel wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$1x</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">missile = 2 pixels wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$2x</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">missile = 4 pixels wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$3x</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">missile = 8 pixels wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x0</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">one copy of player and missile</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x1</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">two close copies of player and missile</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x2</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">two medium copies of player and missile</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x3</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">three close copies of player and missile</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x4</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">two wide copies of player and missile</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x5</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">double-sized player</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x6</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">three medium copies of player and missile</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x7</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">quad-sized player</TD>
</TR>
</TABLE>
<P>
<BR>
Note that missile and player properties may be combined in a single write.
<BR><BR>
Example: <B>NUSIZ0=$13</B> will make <B>missile0</B> 8 wide, plus make three close copies of <B>player0</B> and <B>missile0</B>.
<BR>
</P>
<H6 CLASS="bbtertiary"><A NAME="ctrlpf">Register: <B>CTRLPF</B></A></H6>
<P>
Changes properties of the playfield and/or ball.
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:18px; font-weight:bold; margin-left:24px;">
<TR>
<TD WIDTH="176" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>value</B></SPAN>
</TD>
<TD WIDTH="416" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>effect</B></SPAN>
</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$0x (x means don't care)</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">ball = 1 pixel wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$1x</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">ball = 2 pixels wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$2x</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">ball = 4 pixels wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$3x</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">ball = 8 pixels wide</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x1</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">none of the below</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x3</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">left half of PF gets player0 color, right half gets player1 color</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x5</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">players move behind playfield</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">$x7</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">both of the above</TD>
</TR>
</TABLE>
<P>
<BR>
Note that ball and playfield properties may be combined in a single write.
</P>
<H6 CLASS="bbtertiary"><A NAME="refp">Registers: <B>REFP0</B>, <B>REFP1</B></A></H6>
<P>
Reflects player sprites. (Flips them horizontally.)
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:18px; font-weight:bold; margin-left:24px;">
<TR>
<TD WIDTH="176" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>value</B></SPAN>
</TD>
<TD WIDTH="416" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>effect</B></SPAN>
</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">0</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">do not reflect</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="176" CLASS="bbtdbot">8</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">reflect</TD>
</TR>
</TABLE>
<P>
<BR>
This is useful for <acronym TITLE="Sprites that are irregular or lopsided. Not a perfect mirror image on both sides.">asymmetric sprites</acronym> so that they can give the appearance of changing direction without needing to redefine their graphics.
</P>
<H6 CLASS="bbtertiary"><A NAME="pf0">Registers: <B>PF0</B></A></H6>
<P>
Set or clear the left and right 10% of the playfield.
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; line-height:18px; font-weight:bold; margin-left:24px;">
<TR>
<TD WIDTH="176" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>value</B></SPAN>
</TD>
<TD WIDTH="416" CLASS="bbtdbot"><SPAN STYLE="font-size:18px;"><B>effect</B></SPAN>
</TD>
</TR>
<TR>
<TD WIDTH="176" CLASS="bbtdbot">$0x through $Fx</TD>
<TD WIDTH="416" CLASS="bbtdbot bbtdside">set vertical lines covering entire height of playfield</TD>
</TR>
</TABLE>
<P>
<BR>
PF0 is useful for creating a border in batari Basic. In other kernels or in assembly, it has other uses.
<BR>
</P>
<H6 CLASS="bbtertiary">Registers: <B>AUDC0</B>, <B>AUDC1</B>, <B>AUDF0</B>, <B>AUDF1</B>, <B>AUDV0</B>, <B>AUDV1</B></H6>
<P STYLE="margin-bottom:5px;">See <A HREF="#sound">sound</A> for more information about these.
<BR><BR>
</P>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="displaykernel">Display kernel</A></H3>
<P>
The display <acronym TITLE="The fundamental part of an operating system.">kernel</acronym> (usually just &quot;the kernel&quot;) is a carefully-written software routine that renders the television display. The Atari 2600's television signal is controlled largely by software because the hardware is so primitive. Although programming a 2600 kernel is quite difficult, the primitive hardware also affords a good deal of flexibility, in that custom kernels can exploit the primitive hardware to suit particular needs.
<BR><BR>
The original bB kernel was modeled as one-size-fits-all. This allowed for a decent variety of games, but some games were not possible. Furthermore, some of the games that were possible did not look as good as games written in pure assembly.
<BR><BR>
Therefore, the latest version of bB has not one but actually 28 possible kernels to choose from. 27 of those 28 are based on the standard kernel, optionally adding bells and whistles as needed (sometimes for free, sometimes at a cost). See <A HREF="#kerneloptions">kernel options</A> under <A HREF="#set">compiler directives</A> for more information about what these options are and how to use them.
</P>
<UL>
<H6 CLASS="bbsecondary"><B><A NAME="multikernel">Multisprite Kernel</A></B></H6>
<P>
This is an entirely new kernel written from scratch that provides significant features that should be suitable for a wide variety of games.
<BR><BR>
Instead of two player sprites, you get six. Five of the six sprites are subject to certain limitations, however. These limitations are because the 2600's hardware can only display two sprites on any given horizontal line (or y-value).
<BR><BR>
The player0 sprite works much how it did in the standard kernel. Player1-player5 sprites are 'virtual' sprites, and are displayed by repositioning the 2600's second hardware sprite several times during the visible screen.
<BR><BR>
One limitation is that the virtual sprites may flicker if one or more of them share the same vertical region or don't have enough vertical separation between them. Most people don't mind the flicker, and on a real television, it isn't always terribly noticeable if used sparingly. If you prefer to write a game with no flicker, just ensure that there is sufficient vertical separation between sprites. The kernel will automatically detect if two or more sprites are overlapping and will automatically flicker them, so you don't need to do this yourself. It should be noted that the flicker algorithm isn't perfected yet. Under certain conditions, some sprites might not display correctly. This is a known bug and it's being looked at.
<BR><BR>
The virtual sprites also are given their own <B CLASS="bm"><A NAME="virtualspritereg">virtual color and NUSIZ registers</A></B>. COLUP2-COLUP5 and NUSIZ2-NUSIZ5 correspond to sprites 2-5. For sprite 1, use _COLUP1 and _NUSIZ1. Although these look like TIA registers, they are not; they point to the 2600's RAM. The actual TIA registers COLUP1 and NUSIZ1 can be set but they will probably have no effect in the multisprite kernel.
<BR><BR>
Also, although the multisprite kernel doesn't have special variables for REFPx, you can set the reflection bit for each individual sprite by using bit 3 of _NUSIZ1 or NUSIZ2-NUSIZ5, as this bit is unused by the TIA register NUSIZx.
<BR><BR>
Note that missile 1 may be affected by any of sprite 1-5's NUSIZx and COLUPx values depending on where it is located.
</P>
<UL>
<H6 CLASS="bbtertiary"><B>Other Limitations/Considerations</B></H6>
<UL>
<LI>
playfield is mirrored and located in ROM (see below)
</LI>
<LI>
no kernel options (yet)
</LI>
<LI>
missiles and ball are fixed at one unit high
</LI>
<LI>
Y-values are inverted as compared with the standard kernel (in other words, the bottom of the screen is zero and top is around 88)
</LI>
</UL>
<P>
<BR>
One major difference between the standard kernel and this kernel is that the playfield is mirrored and located in ROM. This has several implications:
<BR><BR>
</P>
<UL>
<LI>
The right half of the playfield if always the same as the left
</LI>
<LI>
There are no playfield plotting commands
</LI>
<LI>
Horizontal scrolling is essentially impossible
</LI>
<LI>
Vertical scrolling isn't implemented (yet)
</LI>
<LI>
The only way to draw the playfield is with the <B>playfield:</B> command — this means you must specify the entire playfield at once
</LI>
</UL>
<P>
<BR>
Although the playfield is limited in many ways, the fact that it is stored in ROM is advantageous in one way. Unlike the standard kernel, you are not limited to just 11 rows — you can use up to 44 rows, and you can set the vertical resolution to suit your needs.
<BR><BR>
<B CLASS="bm"><A NAME="pfheight">pfheight</A></B> is a special variable that specifies the height of playfield blocks, minus one. Acceptable values are 31, 15, 7, 3, 1, and 0.
<BR><BR>
A pfheight of zero will actually give a vertical resolution of around 88 rows. However, it doesn't work properly when sprites are on the screen, so it's probably only useful for static displays like title screens. The setting that will give the highest resolution for general-purpose use is pfheight=1.
<BR><BR>
You can also adjust the height of the screen in the multisprite kernel. You may set <B CLASS="bm"><A NAME="screenheight">screenheight</A></B> to 80 to shrink the screen by 8 pixels, by:
</P>
<PRE CLASS="bbborder">
const screenheight=80
</PRE>
<P>
At this time, the only supported values are 80 and 84, and 80 only works for row heights &lt; 8 while 84 only works for row heights &lt; 4. Other values for screenheight may be allowed in the future. If you try to use other values now, strange things may happen.
</P>
</UL>
<H6 CLASS="bbsecondary"><B><A NAME="huds">Minikernels/HUDs</A></B></H6>
<P>
Minikernels are a new feature of bB that allows for further customization of your game. Minikernels are intended for use as a HUD (Heads-up Display), which is the part of the game that shows lives, health, status, time, etc.
<BR><BR>
The HUDs go just below the bB screen but above the score. The minikernels that display the HUDs are totally modular, can be used in most any bB program, and will not take anything away from the visible screen (unless you choose to.)
<BR><BR>
Two minikernels are included with this release of bB. One contains a &quot;<B CLASS="bm"><A NAME="lifecounterstatusbar">life counter</A></B>&quot; that can show up to six icons to represent player lives, and the lives have a variety of display configurations. The other minikernel contains a fixed, left-aligned life counter and a 28-unit &quot;<B>status bar</B>&quot; (for lack of a better term, as the bar could be used to indicate health, time, power, speed, etc.)
<BR><BR>
Of course you never get something for nothing. Since the minikernels obviously take time to run and render their display, this takes some cycles away from your bB game. A typical minikernel will take around 700 machine cycles each frame. Since this is roughly one-quarter to one-third of the available time, you will need to decide if this is more than your game can handle.
<BR><BR>
If you feel that you can't spare the cycles but you want a way to display lives and/or health, there are three remedies.
<BR><BR>
The first is to use the <B>pfres</B> and/or <B>pfrowheight</B> constants in the standard kernel or the <B>screenheight</B> constant in the multisprite kernel to shrink the screen height, or the <B>PFheights</B> kernel option with a total height of less than 88. These may reduce the size of the vertical screen and thus may free enough cycles for a HUD.
<BR><BR>
A second remedy is to eliminate the score. At the moment, you may do this by placing &quot;const noscore=1&quot; near the beginning of your program.
<BR><BR>
Or, if you don't want to limit the height of your playing area or lose the score, another option is the pfscore bars. Built into the score routine are two 8-wide bars on either side that can be used for a variety of purposes. See <A HREF="#score">score</A> for more information.
<BR><BR>
More HUDs are planned, and hopefully, their modularity might encourage other programmers to write them. They might also serve as a simpler way to try out 2600 kernel writing without needing to write an entire kernel.
<BR><BR>
The two that are available now may be used in your game by including one of the modules as inline asm:
<BR>
</P>
<PRE CLASS="bbborder">
inline 6lives.asm
</PRE>
<P>
or
</P>
<PRE CLASS="bbborder">
inline 6lives_statusbar.asm
</PRE>
<P>
With 8K or larger games, you must place the inline command in the last bank since your game will look for the module there. See <A HREF="#inline">inline</A> for more information about this command (and note the warning.) In a 4K game, you can use <B>include</B> instead of <B>inline</B> for minikernels.
<BR><BR>
The minikernels above require that you define the icon used for the life counter using &quot;lives:&quot;. This works similar to a player definition, except that they are currently fixed at 8 units high. For example:
</P>
<PRE CLASS="bbborder">
lives:
%01000100
%11111110
%11111110
%01111100
%00111000
%00010000
%00010000
%00010000
end
</PRE>
<P>
If using 6lives.asm, there are two options that can align your lives to the left or center, or can select from compressed or expanded layouts. The compact layout will place the lives close together — they will actually touch if you define them to be 8 pixels wide. The expanded layout puts 8 pixels between each life. Note that 6lives_statusbar.asm is fixed at left-aligned, compact.
<BR><BR>
The default is left-aligned, expanded. To select centered and/or compact, place one or both of the following at the beginning of your code:
</P>
<PRE CLASS="bbborder">
dim lives_centered=1
dim lives_compact=1
</PRE>
<P>
There are up to four variables that control 6lives_statusbar, and two in 6lives:<BR>
<SPAN STYLE="font-size:18px; line-height:32px;"><B>lives<BR>
lifecolor<BR>
statusbarlength<BR>
statusbarcolor
</B></SPAN>
<BR><BR>
The last two aren't used in 6lives. <B>statusbarcolor</B> is optional in 6lives_statusbar.
<BR><BR>
The new variables are described below:
<BR><BR>
</P>
<UL>
<P>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="lives">lives</A></B></SPAN><BR>
This is a shared variable. The lower 5 bits are used for the icon graphics pointer, and the upper 3 are used to determine how many lives to display. The upper 3 bits can represent 0-7 lives but no more than 6 will diplay. It might sound difficult to use but it really isn't.
<BR><BR>
To assign a number of lives, for example, at the beginning of your game, use the following values:
<BR><BR>
</P>
<TABLE CELLPADDING="8" CELLSPACING="0" STYLE="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:15px; font-weight:bold; line-height:24px; margin-left:24px;">
<TR>
<TD WIDTH="100" CLASS="bbtdbot"><P STYLE="font-size:18px; margin:0px; padding:0px;"><B>#lives</B></P>
</TD>
<TD WIDTH="128" CLASS="bbtdbot"><P STYLE="font-size:18px; margin:0px; padding:0px;"><B>command</B></P>
</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;0</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=0</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;1</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=32</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;2</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=64</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;3</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=96</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;4</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=128</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;5</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=160</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;6</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=192</TD>
</TR>
<TR CLASS="mytrhover">
<TD WIDTH="100" CLASS="bbtdbot">&nbsp;7</TD>
<TD WIDTH="128" CLASS="bbtdbot bbtdside">lives=224</TD>
</TR>
</TABLE>
<P>
<BR>
When you assign a number of lives, you ALWAYS need to define (or redefine) the life icon using <B>lives:</B> or the icon won't display correctly.
<BR><BR>
Adding or subtracting lives is easy. To add a life, do lives=lives+32, to subtract, do lives=lives-32. You do not need to define <B>lives:</B> after adding or subtracting as these operations will not affect the icon graphics pointer.
<BR><BR>
To check for zero lives:
</P>
<PRE CLASS="bbborder">
if lives&lt;32 then ....
</PRE>
<P>
To check for 7 lives:
</P>
<PRE CLASS="bbborder">
if lives&gt;223 then ...
</PRE>
<P>
Subtracting a life from zero will result in seven lives, and adding a life to seven will result in zero lives.
<BR><BR>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="lifecolor">lifecolor</A></B></SPAN><BR>
Sets the color of the lives.
<BR><BR>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="statusbarlength">statusbarlength</A></B></SPAN><BR>
Sets the length of the status bar. Valid values are the full range 0-255, but numbers greater than 224 will show the bar at full length. The bar is 28 discrete units wide, so the bar only changes in multiples of 8 in the variable. If you know what you are doing, the lower 3 bits of this variable could be used for something else.
<BR><BR>
<SPAN STYLE="font-size:18px;" CLASS="bm"><B><A NAME="statusbarcolor">statusbarcolor</A></B></SPAN><BR>
This is optional. If not used, the statusbar will be the same color as the playfield. To use, however, you must reserve one of your 26 user variables using <A HREF="#dim">dim</A>.
<BR><BR>
For example:
</P>
<PRE CLASS="bbborder">
dim statusbarcolor=t
</PRE>
</UL>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="writinghud">Writing Your Own Minikernel/HUD</A></B></H6>
<P>
To write your own minikernel, you will need to use assembly language and follow a few guidelines.
<BR><BR>
You do not need any headers, equates or ORG's in your assembly file — just start the code with a label called &quot;minikernel.&quot; The regular kernel will conditionally assemble a &quot;jsr minikernel&quot; if the label exists, so it will automatically execute when included with the include or inline command.
<BR><BR>
Typically, minikernels will take around 10 scanlines. The interval timer (TIM64T) is set prior to the kernel so you can use more or less if you wish, but using too many can make the visible screen too large and/or limit the amount of time available for the bB code unless certain compromises are made (see <A HREF="#huds">minikernels</A> above.)
<BR><BR>
You should begin your minikernel with a STA WSYNC so it always starts at the beginning of a line. Also, if you want your code to be flexible, it's important to write it such that the timing will be correct regardless of the physical addresses where the code assembles. This means that you should place checks to ensure that branches or tables don't wrap pages or use WSYNC to delineate a new scanline. Simply placing &quot;align 256&quot; in your code will work but it is probably a waste of space — one solution is to use something like this:
</P>
<PRE CLASS="bbborder">
if ((&lt;*+(code_length-minikernel)) &gt; (&lt;*))
align 256
endif
minikernel
... your code ...
code_length
</PRE>
<P>
This will align on a page boundary only if the code would cross a page boundary. Of course there are better ways to do this, but this will work without blatantly wasting space.
<BR><BR>
In general, it's inadvisable to use too much time to before you start drawing, so repositioning 5 objects probably isn't a good idea. The minikernel setup should be minimal, otherwise there may be a large gap between the regular screen and the start of your graphics. But some setup is probably needed. Although most TIA registers are cleared before the minikernel, some may or may not be, such as VDELxx.
<BR><BR>
4 bytes are set aside for exclusive use in the minikernel — aux3-aux6. These bytes are sequential in RAM so they can be used as pointers if needed. In addition, you may use temp1-temp6 for temporary storage in during the minikernel. If you can ensure that the programmer won't try to call drawscreen while in a subroutine while in a bank-switched game, you might be able to use stack3 and stack4 which are normally reserved for stack space. Beyond that, care is needed to ensure that your variables aren't overwritten by something else.
<BR><BR>
Since the minikernel is a subroutine, you just need an rts to return to the regularly scheduled kernel. But before you exit, make sure you clear any TIA registers that your kernel uses.
<BR><BR>
If you write a minikernel and you think it might be useful for other games, please post your code to the <A HREF="http://www.atariage.com/forums/index.php?showforum=65" TARGET="_blank" TITLE="External site opens in new window">Atari 2600 Basic forum</A> at Atariage!
</P>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="set">Compiler Directives (set command)</A></H3>
<P>
The set command tells the compiler or the assembler to build your code a certain way. The syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>set &lt;directive&gt; &lt;option&gt;</B></SPAN>
<BR><BR>
<P>
Currently, the following <B>directives</B> are supported:<BR>
<SPAN STYLE="font-size:18px; line-height:32px;"><B>
smartbranching<BR>
tv<BR>
romsize<BR>
optimization<BR>
kernel<BR>
kernel_options<BR>
debug<BR>
legacy<BR>
</B></SPAN>
<BR>
Typically you will use the directives near the beginning of your program. However, <B>smartbranching</B> and <B>optimization</B> were originally designed to be set, reset, and/or turned on and off throughout your code (though I'm not sure if this actually works :| )
<BR>
</P>
<UL>
<H6 CLASS="bbsecondary"><B>The Directives</B></H6>
</UL>
<UL>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="smartbranching">smartbranching</A></B></H6>
<P>
The smartbranching directive tells the compiler to generate optimal assembly code when it encounters an if-then statement with a line number or label after the then.
<BR><BR>
It is set to &quot;off&quot; by default, because this makes the generated assembly code easier for a human to read and understand. This will sometimes cause the compilation to fail, however. In this case, you will need to use &quot;then goto&quot; instead of just &quot;then&quot; for the if-then statement that caused the problem.
<BR><BR>
if you &quot;set smartbranching on&quot; then you just use &quot;then&quot; and the compiler will figure out whether to use &quot;then&quot; or &quot;then goto&quot; for you. The drawback to doing this is that the generated assembly file will be much harder for a human to read. If you do not care to see the assembly language that bB generates, however, you should set smartbranching on.
<BR><BR>
You can also use &quot;then goto&quot; all the time and not have to worry about smartbranching at all, but &quot;then goto&quot; uses more code space than just &quot;then&quot; so you should take this into consideration as well.
</P>
<H6 CLASS="bbtertiary"><B><A NAME="tv">tv</A></B></H6>
<P>
Specifies the tv format. Valid options are <B>ntsc</B> or <B>pal</B>. <B>ntsc</B> is the default and is unnecessary.
<BR><BR>
<B>set tv pal</B> will build a game that will run on a PAL television. This format is standard in Europe and Australia, among other places.
<BR><BR>
Note that the PAL setting only changes the timing and synchronization signals and not the colors. PAL has a different palette than NTSC and some NTSC colors do not have a PAL counterpart, so you will have to select the colors carefully for each format if you intend to create a game for both formats.
<BR><BR>
Recently, it has been discovered that PAL televisions will play NTSC binaries without any problems except different colors. Optionally, you may prefer to create a PAL60 binary, which uses the NTSC timing but PAL colors. To do so, use the NTSC TV format but specify the colors from the PAL palette.
</P>
<H6 CLASS="bbtertiary"><B><A NAME="romsize">romsize</A></B></H6>
<P>
Allows you to specify the size of the generated binary. 4K is the default. Currently you may generate 2K, 4K, 8K, 16K or 32K binaries. Anything 8K or larger will use bank switching, and additional considerations are needed for this. See <A HREF="#bankswitching">Bank Switching</A> for more information. Append <B>SC</B> (capitalized) on the end to enable <A HREF="#superchipram">Superchip RAM</A> (valid for 8K or larger binaries only.)
<BR><BR>
Examples:
<BR>
</P>
<PRE CLASS="bbborder">
set romsize 2k
set romsize 16k
set romsize 8kSC
</PRE>
<H6 CLASS="bbtertiary"><B><A NAME="optimization">optimization</A></B></H6>
<P>
Tells the compiler to try to generate code that runs faster or has a smaller size. There are five options: speed, size, noinlinedata, inlinerand, and none.
<BR><BR>
</P>
<UL>
<P>
<SPAN STYLE="font-size:18px;"><B>speed</B></SPAN><BR>
May increase speed (particularly, of multiplication and division) at the cost of code size.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>size</B></SPAN><BR>
May decrease the size of generated code (particularly, of multiplication and division) at the cost of speed.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>no<FONT COLOR="#777777">inline</FONT>data</B></SPAN><BR>
Will remove overhead from data tables, saving space. Doing so will limit them to outside of code. That is, you can no longer place data tables inline with code, or you program may crash!
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>inline<FONT COLOR="#777777">rand</FONT></B></SPAN><BR>
Will place calls to the random number generator inline with your code. This is particularly useful for bank-switched games, where a call to the random number generator would normally have to switch banks, so this will speed up your code with a minimal increase in code size. (This setting may become automatic at a later date.)
<BR><BR>
</P>
</UL>
<P>
Examples:
<BR>
</P>
<PRE CLASS="bbborder">
set optimization speed
set optimization inlinerand
</PRE>
<H6 CLASS="bbtertiary"><B><A NAME="kernel">kernel</A></B></H6>
<P STYLE="margin-bottom:8px;">
Determines which kernel to use with your game. Currently there are 28 kernels available. There is a multisprite kernel, a standard kernel, and the remaining 26 of them are technically distinct kernels but are available as options in the standard kernel. The standard kernel is, well, standard, so no directive is needed to use this.
<BR><BR>
Multisprite kernel example:
</P>
<PRE CLASS="bbborder">
set kernel multisprite
</PRE>
<P>
See <A HREF="#multikernel">multisprite kernel</A> for more information about the multisprite kernel.
</P>
<H6 CLASS="bbtertiary"><B><A NAME="kerneloptions">kernel_options</A></B></H6>
<P>
These are options for customizing the kernel for various needs. Generally, adding options will mean that some objects will not be displayed. Currently the options only apply to the standard kernel.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>Options:</B></SPAN></P>
<UL>
<P>
<BR>
<SPAN STYLE="font-size:18px;"><B>readpaddle</B></SPAN><BR>
Set to read a paddle value — must be used with <B>no_blank_lines</B>.<BR><BR>
<SPAN STYLE="font-size:18px;"><B>player1colors</B></SPAN><BR>
Set to use multicolored P1. <FONT COLOR="#CC0033"><B>Cost</B></FONT>: loss of missile1
.<BR><BR>
<SPAN STYLE="font-size:18px;"><B>playercolors</B></SPAN><BR>
Set to use both multicolored players — must be used with above (player1colors). <FONT COLOR="#CC0033"><B>Cost</B></FONT>: loss of missile0.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>no_blank_lines</B></SPAN><BR>
No gaps in PF blocks. <FONT COLOR="#CC0033"><B>Cost</B></FONT>: loss of missile0.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>pfcolors</B></SPAN><BR>
Specify colors of each row of PF blocks. <B><FONT COLOR="#008800">Cost</FONT></B>: free
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>pfheights</B></SPAN><BR>
Specify height of each row. <B><FONT COLOR="#229922">Cost</FONT></B>: free
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>pfcolors and pfheights together</B></SPAN><BR>
<FONT COLOR="#CC0033"><B>Cost</B></FONT>: free, but colors and height are fixed.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>background</B></SPAN><BR>
Change background color instead of playfield color.
<BR><BR><BR>
</P>
</UL>
<P>
The syntax is:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>set kernel_options option [option2 option3 ...]</B></SPAN>
<BR><BR>
The order of the options doesn't matter, but there are limitations as to which options can be used alone and/or together:
<BR><BR>
</P>
<UL>
<P>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#008800">Acceptable singles</FONT>:</B></SPAN><BR>
player1colors<BR>
no_blank_lines<BR>
pfcolors<BR>
pfheights<BR>
<BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Invalid singles</FONT>:</B></SPAN><BR>
playercolors<BR>
readpaddle<BR>
background<BR>
<BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#008800">Acceptable combinations</FONT>:</B></SPAN><BR>
pfcolors pfheights<BR>
pfcolors pfheights background<BR>
pfcolors no_blank_lines<BR>
pfcolors no_blank_lines background<BR>
player1colors no_blank_lines<BR>
player1colors pfcolors<BR>
player1colors pfheights<BR>
player1colors pfcolors pfheights<BR>
player1colors pfcolors background<BR>
player1colors pfheights background<BR>
player1colors pfcolors pfheights background<BR>
player1colors no_blank_lines readpaddle<BR>
player1colors no_blank_lines pfcolors<BR>
player1colors no_blank_lines pfcolors background<BR>
playercolors player1colors pfcolors<BR>
playercolors player1colors pfheights<BR>
playercolors player1colors pfcolors pfheights<BR>
playercolors player1colors pfcolors background<BR>
playercolors player1colors pfheights background<BR>
playercolors player1colors pfcolors pfheights background<BR>
no_blank_lines readpaddle</P>
</UL>
<UL>
<P CLASS="bbquaternary"><SPAN STYLE="font-size:18px;"><B>Using kernel_options</B></SPAN></P>
<UL>
<P>
<BR>
<SPAN STYLE="font-size:18px;"><B>Paddle Reading</B></SPAN><BR>
Specify paddle to read in <B>currentpaddle</B> (0-3) then value will be returned in <B>paddle</B> after a call to <A HREF="#drawscreen">drawscreen</A>.
Value returned should range from about 0-80.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>Multicolored/Variable Height Playfield</B></SPAN><BR>
<BR>
</P>
<UL>
<P>
<SPAN STYLE="font-size:18px;"><B>pfheights</B></SPAN><BR>
Specifies heights of each playfield row. You must specify 11 values, one to a line, followed by <B>end</B>.
The default height is 8. The total should not exceed 88 or you will cut into the time available for your bB program. Specifying less than 88 is fine, but doing so will shrink the size of the visible screen. You can specify <B>pfheights:</B> as many times as you want.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> At this time, if the first row isn't 8, things might not work quite correctly. This problem is being worked on.
<BR><BR>
Example:<BR>
</P>
<PRE CLASS="bbborder">
pfheights:
8
8
15
1
8
8
8
8
8
8
8
end
</PRE>
<P>
<BR>
<SPAN STYLE="font-size:18px;"><B>pfcolors</B></SPAN><BR>
Specifies colors of each playfield row. Must specify 11 values, one to a line, followed by <B>end</B>. You can specify this as many times as you want.
<BR>
</P>
<PRE CLASS="bbborder">
pfcolors:
$f5
$f5
$f5
$43
$f5
$f5
$f5
$f5
$f5
$f5
$f5
end
</PRE>
<P>
<BR>
<SPAN STYLE="font-size:18px;"><B>pfcolors and pfheights used together</B></SPAN><BR>
When used together in the same game, you can only define <B>pfheights:</B> and <B>pfcolors:</B> one time, and you need to define <B>pfheights</B> first.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>playercolors and player1colors</B></SPAN><BR>
Specifies player colors a row at a time.
<BR><BR>
<B>playercolors:</B> allows both players to be multicolored, while <B>player1colors:</B> only allows this for player 1.
<BR><BR>
Use <B>player0color:</B> to define the colors for the player0, and <B>player1color:</B> for player1.
<BR><BR>
For example:
</P>
<PRE CLASS="bbborder">
player0color:
$f5
$f5
$f5
$43
$f5
end
</PRE>
<P>
Note that changing player colors also affects the missile colors during the scanlines where the colors change.
<BR>
</P>
</UL>
</UL>
</UL>
<H6 CLASS="bbtertiary"><B><A NAME="debug">debug</A></B></H6>
<P>
Used to help find bugs in your bB program. Currently it only helps with determining when too many machine cycles are used in a particular frame.
<BR><BR>
Valid options are cycles or cyclescore.
</P>
<UL>
<P>
<BR>
<SPAN STYLE="font-size:18px;"><B>cycles</B></SPAN><BR>
Will flash the background color when the cycle count is exceeded. This has little overhead but its utility is limited.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>cyclescore</B></SPAN><BR>
Will display an estimate of the number of actual machine cycles available in the current frame. It should be accurate to about plus or minus 64 cycles. If the score color is white, the number indicated is positive. If it is red, the number is negative (in other words, you have used too many cycles).
<BR><BR>
Since cyclescore changes every frame, it may be hard to see the numbers flashing by. You may find it useful to record the minimum number of cycles. To do so, you must define mincycles to be one of the 26 user variables. During debugging you can't use the variable for anything else, but of course you get it back once you're done debugging. To use mincycles, for example:
<BR>
</P>
<PRE CLASS="bbborder">
dim mincycles = z
mincycles=255
</PRE>
<P>
The latter statement is needed to set (or reset) mincycles to a large value so it can properly find a minimum.
<BR><BR>
cyclescore only measures +/- 2000 cycles. If your deficit is more than 2000 cycles, the score will probably display garbage or your game may crash. But if your code is more than 2000 cycles over the limit, you have bigger problems than this.
</P>
</UL>
<H6 CLASS="bbtertiary"><B><A NAME="legacy">legacy</A></B></H6>
<P>
Version 1.0 of bB has several new features and has been optimized such that code written for earlier versions may not work quite right. To retain more compatibility with old code, a legacy mode has been implemented that will (hopefully) allow the games to work properly without extensive modifications.
<BR><BR>
The most obvious change is for player/missile/ball x positions in the standard kernel — they will likely be shifted 14 pixels to the right. This change was made because the sprite positioning routine runs at least twice as fast, and the values now accurately represent the boundaries of the screen — 0 is the left edge and 159 is the right edge. The legacy mode will use the old positioning.
<BR><BR>
It is recommended that you fix your old games to account for this discrepancy. But if that's too daunting, you can use the old positioning by setting the legacy mode to 0.99 or less.
<BR><BR>
One way to modify your program for legacy mode:
</P>
<PRE CLASS="bbborder">
set legacy 0.99
</PRE>
<P>
You can also modify your 2600basic.h file to include the line legacy = 99 (in other words, version * 100) to always compile programs in 0.99 legacy mode. This approach isn't recommended except for convenience when compiling a number of old programs.
<BR><BR>
Setting the legacy mode may also change other things, though most of these are minor.
<BR><BR>
Note that while legacy mode may not fix all of the issues that creep up when compiling legacy code, it should fix the most egregious of them.
<BR><BR>
An incomplete list of changes that may affect your game, but are not accounted for in legacy mode:
<BR><BR>
</P>
<UL>
<LI>
A thin playfield line appeared in bB 0.99c (unreleased version) when using the no_blank_lines kernel option. Although this was considered a bug, some programmers exploited it for use as a health bar, etc.<BR>
<BR>
</LI>
<LI>
The score was moved one pixel to the left as a consequence of eliminating the black HMOVE bar to the left of the score<BR>
<BR>
</LI>
<LI>
The score was moved one more pixel to the left in order to accommodate the pfscore bars (see <A HREF="#score">score</A> for more details about using pfscore bars.)<BR>
<BR>
</LI>
<LI>
The rightmost edge of leftmost score digit might not display quite correctly if you redefine the graphics to be 8 pixels wide. But since the score digits are defined to be 6 pixels wide, under normal circumstances, this problem will never surface. It only becomes an issue if the score graphics are redefined to be 8 pixels wide. At the moment, the bug will occur whether or not the pfscore bars are enabled. At a later date, this bug will be fixed when pfscore bars are not enabled. But if they are enabled, there is currently no known solution.<BR>
</LI>
</UL>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="bankswitching">Bank Switching</A> (Up to 32K of ROM for your games!)</H3>
<P>
The Atari 2600 can only address 4K at a time. Games larger than 4K are possible by additional hardware on the cartridge that can swap in two or more banks of 4K. Since the 2600 can only 'see' 4K at once, the 2-8 banks also can't see each other; that is, one bank cannot access data in another bank. Also, since an entire bank needs to be swapped in all at once, normally this would make programming somewhat more difficult.
<BR><BR>
Bank switching in bB cannot get past one limitation — One bank still cannot access data from another bank, so data tables can only be accessed from within the same bank in which they are located.
<BR><BR>
However, the fact that banks must be swapped in all at once doesn't pose any serious technical problems for bB. You can use <A HREF="#goto">goto</A> to jump to any routine in another bank, and you can also use <A HREF="#gosub">gosub</A> for a subroutine, and a <A HREF="#return">return</A> will automatically return to the bank that called the subroutine. This is because bB uses a clever little routine that automatically knows what bank it is in at any time and what bank called a subroutine. This routine does require some overhead in terms of cycles and space, so you should limit bank switching to a few times each frame.
<BR><BR>
To activate bank switching, you just need to set the size of the binary using &quot;set romsize&quot;, with a value of 8K or larger (see <A HREF="#set">compiler directives</A>).
<BR><BR>
You do not need to specify where graphics go, as they all will be automatically placed in the last bank no matter where you define them. Also, the kernel will always be placed in the last bank. Typically, bB modules and functions will as well. You don't need to do anything differently with drawscreen, and you typically don't with built-in functions or modules either.
<BR><BR>
In most cases, you must specify where new banks begin. You do not need to specify where the first bank starts, as it must start at the beginning of your code. Strictly speaking, you don't need to specify where additional banks start, but if you don't, you won't be able to put your code in other banks. This might not be a huge problem for an 8K binary (where a good portion of both banks will be used, regardless) but it doesn't make much sense for a 16K or 32K binary.
<BR><BR>
To specify the beginning of a new bank, use the &quot;bank&quot; keyword, followed by the bank you wish to begin. 8K binaries contain two banks, 16K has four, and 32K has eight.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
bank 2
bank 8
</PRE>
<P>
Note: specifying &quot;bank 1&quot; is not necessary.
<BR><BR>
See <A HREF="#goto">goto</A>, <A HREF="#gosub">gosub</A> and <A HREF="#return">return</A> for more information about jumping from one bank to another.
</P>
<UL>
<H6 CLASS="bbsecondary"><B><A NAME="superchipram">Superchip RAM</A></B></H6>
<P>
The Superchip, also called the SARA chip, provides 128 additional bytes of RAM. Superchip RAM is only used in conjunction with bank switching.
<BR><BR>
Since the Superchip is a separate chip, producing standalone cartridges in this format will increase costs slightly. At the moment, one outfit is selling Superchips for $3 each, along with the special boards you need for them. Superchips can also be salvaged from some old games.
<BR><BR>
Emulators support Superchip binaries with no special considerations. Furthermore, programmable cartridges, such as the Cuttle Cart, Krokodile Cart and Maxcart all support it. If you do not plan on creating actual cartridges, using this scheme will probably not prevent anyone from playing your games. In order for these games to run properly in an emulator, however, it may be necessary to manually specify the bank switching scheme. This might be a non-issue by the time you read this, however, as the latest versions of some popular emulators should detect Superchip binaries automatically.
<BR><BR>
Superchip RAM is enabled automatically with the &quot;set romsize&quot; option — just append <B>SC</B> after the size.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
set romsize 8kSC
</PRE>
<P>
This would enable Superchip RAM with 8K bank switching. See <A HREF="#set">compiler directives</A> for more information.
<BR><BR>
Most existing bB code written for standard bank switching can be adapted to run with Superchip RAM without needing major changes. In doing so, you will use the existing kernels and have the entire 128 bytes available to you as variables. The transition may not be totally seamless because Superchip RAM requires 256 bytes of filler data for every 4K, which will slightly reduce the amount of ROM available.
<BR><BR>
It is important to note that the 128 bytes of Superchip RAM requires special treatment. Because of the design of the chip, reads and writes must be done at different addresses. Therefore, 256 variables have been defined — 128 of them are read-only (r000 to r127) and 128 are write-only (w000 to w127). That is, if you write to w000, you must read the value using r000. This means that code must be written very carefully and there are some limitations. As long as you follow certain guidelines, you should be able to do any variable assignment you want. The guidelines are that write registers always go on the left side of an assignment, and read variables (no matter how many there are) always go on the right. When using functions, use the read variables as the arguments and assign the function to a write variables. In an if-then, use read variables for the comparison.
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
w010=r010+1
w000=r001+r002+4
if r001&lt;4 then 20
w004=myfunction(r001,r002)
COLUP0=r001
pfpixel r001 r002 on
</PRE>
<P>
These special variables cannot be used for fixed-point math, 16-bit multiplication or division, as the counter variable in for-next loops, or any functionality that requires dimming a value to a user variable. There may be other limitations as well. Also, not all variables 000-127 are actually available for general use — this is explained below.
<BR><BR>
To ameliorate Superchip variable use, the 48-bytes previously reserved for the playfield has been placed in Superchip RAM. Therefore 48 bytes of standard RAM has been freed and is not subject to the above limitations. These 48 bytes are named var0-var47.
<BR><BR>
Optionally, since we have extra RAM for the playfield, it can have greater vertical resolution — up to 31+1 lines instead of 11+1. One drawback of this mode is that horizontal playfield scrolling isn't supported (yet) because it runs too slowly (twice as much data to move!) With the standard-sized playfield, r000-r079 (or w000-w079) are free. With the double-sized playfield, r000-r031 (or w000-w031) are free.
<BR><BR>
If you enable Superchip RAM, the above becomes available except the double-height playfield. If you wish to enable the double-height playfield, you need to define the number of rows to display using <B>const</B>. For double-height, use 24. For example:
</P>
<PRE CLASS="bbborder">
const pfres=24
</PRE>
<P>
Note that you can set values from 3-32, but if the number doesn't evenly divide 96, the resultant screen might be smaller than normal. The amount of Superchip RAM used is 4 times the height. The largest size, 32, will use all available Superchip RAM.
<BR><BR>
See <A HREF="#playfield">playfield</A> for more information about the pfres setting.
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="sound">Sound</A></H3>
<P>
There are no special functions for accessing sound in batari Basic. Instead, you must access the TIA registers for sound directly. Don't panic, the TIA registers for sound are quite friendly, at least as far as that damn TIA goes.
<BR>
</P>
<UL>
<H6 CLASS="bbsecondary"><B>Channel 0</B></H6>
<UL>
<H6 CLASS="bbtertiary" STYLE="margin-top:8px;"><B>AUDV0</B></H6>
<P>
Channel 0 <B>Volume</B> (valid values are 0 to 15)
<BR>
</P>
<H6 CLASS="bbtertiary"><B>AUDC0</B></H6>
<P>
Channel 0 <B>Tone </B>[<B>Distortion</B>] (valid values are 0 to 15)
<BR>
</P>
<H6 CLASS="bbtertiary"><B>AUDF0</B></H6>
<P>
Channel 0 <B>Frequency</B> (valid values are 0 to 31)
<BR>
</P>
</UL>
<H6 CLASS="bbsecondary"><B>Channel 1</B></H6>
<UL>
<H6 CLASS="bbtertiary" STYLE="margin-top:8px;"><B>AUDV1</B></H6>
<P>Channel 1 <B>Volume</B> (valid values are 0 to 15)
<BR>
</P>
<H6 CLASS="bbtertiary"><B>AUDC1</B></H6>
<P>
Channel 1 <B>Tone </B>[<B>Distortion</B>] (valid values are 0 to 15)
<BR>
</P>
<H6 CLASS="bbtertiary"><B>AUDF1</B></H6>
<P>
Channel 1 <B>Frequency</B> (valid values are 0 to 31)
</P>
</UL>
</UL>
<P>
Setting the values, for instance, by <B>AUDV0 = 10 : AUDC0 = 12 : AUDF0 = 4</B> will produce a tone, and it will stay on until you set <B>AUDV0 = 0</B>. Typically, a frame counter is set up that keeps sounds on for a specified number of frames (which occur 60 times a second).
<BR><BR>
The following is adapted from <A HREF="http://www.biglist.com/lists/stella/archives/199704/msg00007.html" TARGET="_blank" TITLE="External site opens in new window">Atari 2600 VCS Precise Sound Values and Distortion Breakdown</A> by Glenn Saunders:
<BR><BR>
</P>
<TABLE CELLPADDING="0" CELLSPACING="0" STYLE="margin-left:24px;">
<TR>
<TD WIDTH="72" HEIGHT="20" ROWSPAN="2" STYLE="padding-left:4px;">
<H6 STYLE="font-size:18px; margin:0px; padding:0px;" CLASS="bm"><A NAME="tonechart">Tone</A></H6>
</TD>
<TD WIDTH="576" ROWSPAN="2">
<H6 STYLE="font-size:18px;">What it Sounds Like</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(209,209,209); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;0</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(209,209,209); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>No sound (silent).</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="4" STYLE="border-top-width:4px; border-top-color:rgb(209,209,209); border-top-style:solid;">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="4" STYLE="border-top-width:4px; border-top-color:rgb(209,209,209); border-top-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-top-width:4px; border-right-width:4px; border-top-color:rgb(209,209,209); border-right-color:rgb(209,209,209); border-top-style:solid; border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(249,246,198); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;1</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(249,246,198); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Buzzy tones.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(198,234,249); padding-left:4px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;2</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(198,234,249); padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Carries distortion 1 downward into a rumble.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="10">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(247,255,98); padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;3</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(247,255,98); padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Flangy wavering tones, like a UFO.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(223,173,255); padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;4</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(223,173,255); padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Pure tone.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="16" HEIGHT="8" STYLE="border-top-width:4px; border-right-width:4px; border-top-color:rgb(223,173,255); border-right-color:rgb(223,173,255); border-top-style:solid; border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(223,173,255); padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;5</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(223,173,255); padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Same as 4.</H6>
</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-bottom-width:4px; border-right-color:rgb(223,173,255); border-bottom-color:rgb(223,173,255); border-right-style:solid; border-bottom-style:solid;">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(255,128,128); padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;6</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(255,128,128); padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Between pure tone and buzzy tone (Adventure death uses this).</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="4" STYLE="border-top-width:4px; border-top-color:rgb(255,128,128); border-top-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-top-width:4px; border-right-width:4px; border-top-color:rgb(255,128,128); border-right-color:rgb(255,128,128); border-top-style:solid; border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(128,255,125); padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;7</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(128,255,125); padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Reedy tones, much brighter, down to Enduro car rumble.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(255,128,128); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="16" HEIGHT="4" STYLE="border-top-width:4px; border-right-width:4px; border-top-color:rgb(128,255,125); border-right-color:rgb(128,255,125); border-top-style:solid; border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(255,128,128); border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:white; padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;8</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:white; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>White noise/explosions/lightning, jet/spacecraft engine.</H6>
</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(128,255,125); border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(255,128,128); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(128,255,125); border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(255,128,128); border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(128,255,125); padding-left:4px; padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="font-family:Courier; font-size:20px; font-weight:bold;">&nbsp;9</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(128,255,125); padding-top:2px; padding-bottom:2px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Same as 7.</H6>
</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-bottom-width:4px; border-right-color:rgb(128,255,125); border-bottom-color:rgb(128,255,125); border-right-style:solid; border-bottom-style:solid;">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(255,128,128); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(255,128,128); border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="8" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(255,128,128); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="font-family:Courier; font-size:20px; font-weight:bold;">10</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(255,128,128); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Same as 6.</H6>
</TD>
<TD WIDTH="20" HEIGHT="4" STYLE="border-bottom-width:4px; border-bottom-color:rgb(255,128,128); border-bottom-style:solid;">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-bottom-width:4px; border-right-color:rgb(255,128,128); border-bottom-color:rgb(255,128,128); border-right-style:solid; border-bottom-style:solid;">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-right-color:rgb(209,209,209); border-right-style:solid;">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(209,209,209); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="font-family:Courier; font-size:20px; font-weight:bold;">11</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(209,209,209); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Same as 0.</H6>
</TD>
<TD WIDTH="20" STYLE="border-bottom-width:4px; border-bottom-color:rgb(209,209,209); border-bottom-style:solid;" HEIGHT="4">&nbsp;</TD>
<TD WIDTH="20" STYLE="border-bottom-width:4px; border-bottom-color:rgb(209,209,209); border-bottom-style:solid;" HEIGHT="4">&nbsp;</TD>
<TD WIDTH="16" STYLE="border-right-width:4px; border-bottom-width:4px; border-right-color:rgb(209,209,209); border-bottom-color:rgb(209,209,209); border-right-style:solid; border-bottom-style:solid;" HEIGHT="4">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(255,154,44); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">12</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(255,154,44); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Pure tone, goes much lower in pitch than 4 &amp; 5.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="16" HEIGHT="4" STYLE="border-top-width:4px; border-right-width:4px; border-top-color:rgb(255,154,44); border-right-color:rgb(255,154,44); border-top-style:solid; border-right-style:solid;">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(255,154,44); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="font-family:Courier; font-size:20px; font-weight:bold;">13</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(255,154,44); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Same as 12.</H6>
</TD>
<TD WIDTH="16" HEIGHT="4" STYLE="border-right-width:4px; border-bottom-width:4px; border-right-color:rgb(255,154,44); border-bottom-color:rgb(255,154,44); border-right-style:solid; border-bottom-style:solid;">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(20,255,200); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">14</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(20,255,200); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Electronic tones, mostly lows, extends to rumble.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="72" STYLE="background-color:rgb(155,175,243); padding-left:4px; border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><SPAN STYLE="background-color:black; color:white; font-family:Courier; font-size:20px; font-weight:bold;">15</SPAN></TD>
<TD WIDTH="576" STYLE="background-color:rgb(155,175,243); border-bottom-width:1px; border-bottom-color:black; border-bottom-style:solid;" ROWSPAN="2"><H6>Electronic tones, mostly lows, extends to rumble.</H6>
</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
<TR>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
<TD WIDTH="20" HEIGHT="8">&nbsp;</TD>
</TR>
</TABLE>
<P STYLE="margin-left:16px;">
<BR>
<SPAN STYLE="font-size:18px;"><B>Summary:</B></SPAN>
<BR><BR>
</P>
<TABLE STYLE="font-weight:bold; font-family:Courier; font-size:14px; line-height:24px; margin-left:40px; border-width:1px; border-color:rgb(153,153,153); border-style:solid;" CELLPADDING="6" CELLSPACING="0">
<TR>
<TD WIDTH="88" ALIGN="left" VALIGN="top">Unique
<BR>
Redundant</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;0
<BR>
11
</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;1
</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;2
</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;3
</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;4
<BR>
&nbsp;5</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;6
<BR>
10</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;7
<BR>
&nbsp;9</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
&nbsp;8
</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
12
<BR>
13</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
14
</TD>
<TD WIDTH="28" CLASS="myhover" ALIGN="left" VALIGN="top">
15
</TD>
</TR>
</TABLE>
<UL>
<H6 CLASS="bbsecondary">Sound and Music Resources</H6>
<P STYLE="margin-bottom:9px;"><A HREF="http://www.biglist.com/lists/stella/archives/199704/msg00007.html" TARGET="_blank" TITLE="External site opens in new window">Atari 2600 VCS Precise Sound Values and Distortion Breakdown</A></P>
<P STYLE="margin-bottom:9px;"><A HREF="http://home.arcor.de/estolberg/texts/freqform.txt" TARGET="_blank" TITLE="External site opens in new window">Atari 2600 VCS Sound Frequency and Waveform Guide</A></P>
<P STYLE="margin-bottom:9px;"><A HREF="http://alienbill.com/2600/basic/music/" TARGET="_blank" TITLE="External site opens in new window">the BASICs of batari music</A></P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="joysticks">Joysticks</A></H3>
<P>
Joysticks are read by using an <A HREF="#if">if-then</A> statement. There are four directional functions and one fire function for each joystick:
<BR>
</P>
<UL>
<H6 CLASS="bbsecondary"><B>Left Joystick</B></H6>
<UL>
<H6 CLASS="bbtertiary" STYLE="margin-top:8px;"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy0up</B></H6>
<P>
True if left joystick is pushed up.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy0down</B></H6>
<P>
True if left joystick is pushed down.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy0left</B></H6>
<P>
True if left joystick is pushed left.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy0right</B></H6>
<P>
True if left joystick is pushed right.
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy0fire</B></H6>
<P>
True if left joystick's fire button is pushed.
<BR><BR>
</P>
</UL>
<H6 CLASS="bbsecondary"><B>Right Joystick</B></H6>
<UL>
<H6 CLASS="bbtertiary" STYLE="margin-top:8px;"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy1up</B></H6>
<P>
True if right joystick is pushed up.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy1down</B></H6>
<P>
True if right joystick is pushed down.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy1left</B></H6>
<P>True if right joystick is pushed left.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy1right</B></H6>
<P>
True if right joystick is pushed right.
<BR>
</P>
<H6 CLASS="bbtertiary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>joy1fire</B></H6>
<P>
True if right joystick's fire button is pushed.
</P>
</UL>
</UL>
<P>
Example:
</P>
<PRE CLASS="bbborder">
if joy0up then x = x + 1
</PRE>
<P>
These can also be inverted using the NOT ( <B>!</B> ) token. For example:
</P>
<PRE CLASS="bbborder">
if !joyup then 230
</PRE>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="switches">Console Switches</A></H3>
<P>
Reading the console switches is done by using an <A HREF="#if">if-then</A> statement.</P>
<UL>
<H6 CLASS="bbsecondary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>switchreset</B></H6>
<P>
True if Reset is pressed.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>switchbw</B></H6>
<P>
True if the COLOR/BW switch is set to BW, false if set to COLOR.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>switchselect</B></H6>
<P>
True if Select is pressed.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>switchleftb</B></H6>
<P>
True if left difficulty is set to B (amateur), false if A (pro).
<BR>
</P>
<H6 CLASS="bbsecondary"><B><FONT COLOR="#FF5600">if</FONT> </B><B>switchrightb</B></H6>
<P>
True if right difficulty is set to B (amateur), false if A (pro).
<BR><BR>
</P>
</UL>
<P STYLE="margin-bottom:8px;">These are accessed by, for example:
</P>
<PRE CLASS="bbborder">
if switchreset then 200
</PRE>
<P STYLE="margin-bottom:8px;">These can all be inverted by the NOT (<B>!</B>) token:</P>
<PRE CLASS="bbborder">
if !switchreset then 200
</PRE>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="numbers">Numbers</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B><A NAME="decimal">Decimal Numbers</A></B></H6>
<P>
Numbers in batari Basic are assumed to be in decimal unless otherwise specified by either
the <B>$</B> (for hexadecimal) or the <B>%</B> (for binary).
<BR><BR>
One exception is signed numbers with the negative bit set, when expressed as a negative. See <A HREF="#negative">negative numbers</A> for more information.
<BR>
</P>
<H6 CLASS="bbsecondary"><B><A NAME="hex">Hexadecimal Numbers</A></B></H6>
<P>
Often it is handy to express hexadecimal numbers in your Basic program. Simply place the <B>$</B> before a number to use hexadecimal.
<BR><BR>
</P>
<TABLE STYLE="font-weight:bold; font-family:Courier; font-size:14px; line-height:16px; margin-left:24px; border-width:1px; border-color:rgb(153,153,153); border-style:solid;" CELLPADDING="6" CELLSPACING="0">
<TR>
<TD WIDTH="72">Binary
<BR>
Decimal</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
128
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;64
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;32
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;16
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;8
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;4
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;2
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;1
</TD>
</TR>
</TABLE>
<P>
<BR>
Examples:
</P>
<PRE CLASS="bbborder">
COLUPF = $2E
a[$12] = $F5
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="binary">Binary Numbers</A></B></H6>
<P>
Sometimes it is convenient to express numbers as binary instead of decimal or hexadecimal. To express numbers as binary, place the <B>%</B> before a number. Make sure that you define all 8 bits in the byte. The <B>%</B>&nbsp;operator is particularly useful for accessing certain TIA registers that expect individual bits to be set or cleared, without needing to first convert the numbers to hexadecimal or decimal first. The
<B>%</B>&nbsp;operator is also useful for defining player sprites.
<BR><BR>
</P>
<TABLE STYLE="font-weight:bold; font-family:Courier; font-size:14px; line-height:16px; margin-left:24px; border-width:1px; border-color:rgb(153,153,153); border-style:solid;" CELLPADDING="6" CELLSPACING="0">
<TR>
<TD WIDTH="72">Binary
<BR>
Decimal</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
128
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;64
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;32
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;16
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;8
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;4
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;2
</TD>
<TD WIDTH="40" CLASS="myhover">
&nbsp;&nbsp;1
<BR>
&nbsp;&nbsp;1
</TD>
</TR>
</TABLE>
<P>
<BR>
Examples:
</P>
<PRE CLASS="bbborder">
CTRLPF = %00100010
player0:
%00100010
%11100111
end
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="negative">Negative Numbers</A></B></H6>
<P>
Negative numbers are somewhat supported. Although variable values can contain 0-255, the numbers will wrap if 255 is exceeded. Therefore, you can think of numbers from 128-255 as being functionally equal to -128 to -1. This is called &quot;two's compliment&quot; form because the high bit is set from 128-255, so this high bit can also be called the &quot;sign.&quot;
<BR><BR>
In other words, adding 255 to a variable has exactly the same effect as subtracting 1.
<BR><BR>
bB also supports assignment to a <acronym TITLE="Flips the sign of a variable. Positive becomes negative, negative becomes positive.">unary minus</acronym>, such as a = -a.
<BR><BR>
You can also assign a variable to a negative number, such as a = -1.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> Assignment to negative numbers will not work properly with certain versions of the assembler (DASM). Versions of bB prior to 1.0 were packaged with DASM 2.20.10, which doesn't process negative numbers correctly. Version 2.20.07 of the assembler does work, and so this has been packaged with bB version 1.0.
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="math">Math</A></H3>
<P>
batari Basic supports full expression evaluation for <acronym TITLE="Any number without a decimal (positive, negative or zero). A whole number.">integer</acronym> math. It evaluates expressions as efficiently as possible by using the stack when needed to perform intermediate calculations, so no additional space is needed in most cases.
<BR><BR>
You can only use expression evaluation for variable assignments. You can't (yet) use expressions as arguments in functions, bB commands or comparisons, or with fixed point math.
<BR><BR>
Expressions can contain addition, subtraction, division, multiplication and/or bitwise operators.
<BR><BR>
The order of operations is:
<BR>
<SPAN STYLE="font-size:18px; line-height:32px;"><B>
() Parentheses<BR>
*,/ Multiplication and division (see below)<BR>
+,- Addition and subtraction (see below)<BR>
&amp;,^,| Bitwise operators<BR>
</B></SPAN>
<BR>
Examples of complex expressions:
</P>
<PRE CLASS="bbborder">
a=e-4*2
a=(e-4)*2
a=(e-4)*2*(myarray[4]-(4+c[r]))+2|e
</PRE>
<P>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> using complex expressions might result in a localized overflow (that is, an intermediate value that exceeds 255 or is less than zero) if sub-expressions are not well-constructed or variables allowed to get too large (or small, as the case may be.) Also, complex statements, functions, subroutines, and bank switching all use the stack, so using excessively complex statements in a nested function or subroutine may overflow the stack into the variable space, causing weird bugs. However, stack overflows are still considered to be somewhat unlikely.
</P>
<UL>
<H6 CLASS="bbsecondary"><B>Addition</B></H6>
<P>
The + operator is used for addition. You may use any combination of registers, variables, unsigned values from 0-255 or signed values from -128 to 127 (see also <A HREF="#negative">negative numbers</A>).
<BR><BR>
If the addition causes the result to equal or exceed 256, it will be wrapped around at 0. For instance, 255+1=0, 255+2=1, ... 255+255=254.
<BR><BR>
An exception is the score, which can work with values from 0 - 999999.
<BR><BR>
Examples:</P>
<PRE CLASS="bbborder">
a = a + 1
COLUPF = r + $5F
player0y = player1y + 6 + temp1
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="subtraction">Subtraction</A></B></H6>
<P>
The <B>-</B> operator is used for subtraction. You may use any combination of registers, variables, unsigned values from 0-255 or signed values from -128 to 127 (see also <A HREF="#negative">negative numbers</A>).
<BR><BR>
If the subtraction causes the result to be less than 0, it will be wrapped around to 255. For instance, 0-1=255, 1-2=255, ... 0-255=1.
<BR><BR>
An exception is the score, which can work with values from 0 - 999999.
<BR><BR>
bB also supports a unary minus in a variable assignment (such as a = -a).
<BR><BR>
Examples:
</P>
<PRE CLASS="bbborder">
a = a - 1
COLUPF = r - $5F
player0y = player1y - 6 - temp1
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="multiplication">Multiplication</A></B></H6>
<P>
bB supports multiplication of two <acronym TITLE="Any number without a decimal (positive, negative or zero). A whole number.">integer</acronym> numbers. However, some multiplication operations require you to include a module. In particular, multiplying two variables together requires the module, as does multiplication of a variable or by certain constants greater than 10 (see explanation below). Multiplication of a variable to a number 10 or less does not require you to include a module.
<BR><BR>
Explanation:
<BR>
Multiplication is generally a slow routine requiring lots of precious machine cycles, but bB tries to optimize for speed based on known methods. The concise but technical answer is: If the multiplicand's prime factorization contains only 2, 3, 5, and/or 7, no module is needed, otherwise the module will be needed. If you're not sure or don't want to do figure this out every time, you can try to compile without the module, and if compilation fails, look for &quot;mul8&quot; or &quot;mul16&quot; in the list of unknown symbols.
<BR><BR>
If the multiplication causes the result to exceed 255, the result will probably be bogus. There is a way around this — if you use <B>**</B> as the multiplication operator instead of <B>*</B>, the result will be stored in 16 bits and the value will wrap properly. In this case, the lower byte of the result will be assigned to your variable, and the variable temp1 will contain the upper byte of the result. You should use ** only when you need it, as it takes up additional space and cycles in your program.
<BR><BR>
The division and multiplication are packaged as a single module. If you need to include the module, place this line near the beginning of your program:
</P>
<PRE CLASS="bbborder">
include div_mul.asm
</PRE>
<P>
If you are using <B>**</B>, however, you should include the 16-bit module, by:
</P>
<PRE CLASS="bbborder">
include div_mul16.asm
</PRE>
<P>
Or you may place it in an includes file to include it automatically. See <A HREF="#include">include</A> or <A HREF="#includesfile">includes file</A> for more information.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> 16-bit multiplication is not fully tested.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="division">Division</A></B></H6>
<P>
bB supports division of two <acronym TITLE="Any number without a decimal (positive, negative or zero). A whole number.">integer</acronym> numbers with some limitations. Some division operations require you to include a module. In particular, dividing two variables requires the module, as does division by any number except a power of two, in other words,&nbsp;dividing by 2, 4, 8, 16, 32, 64, or 128 can be done without the module. You can divide by 1 as well, but I can't imagine why you would want to. If you try to divide by zero, no operation will occur and your program will continue to run.
<BR><BR>
The division operation will return an integer result, meaning that any fractional portion or remainder will be lost. If you need the remainder, however, you can use the <B>//</B> operator instead. The remainder will then be stored in temp1.
<BR><BR>
The division and multiplication are packaged as a single module. If you need to include the module, place this line near the beginning of your program:
</P>
<PRE CLASS="bbborder">
include div_mul.asm
</PRE>
<P>
If you are using <B>//</B>, however, you should include the 16-bit module, by:
</P>
<PRE CLASS="bbborder">
include div_mul16.asm
</PRE>
<P>
Or you may place it in an includes file to include it automatically. See <A HREF="#include">include</A> or <A HREF="#includesfile">includes file</A> for more information.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warnings</FONT>:</B></SPAN> The division modules may not work properly on bank-switched games, and the 16-bit routines have not been fully tested.
</P>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="modulus">Modulus Operation</A></B></H6>
<P>
Other languages have a &quot;modulus&quot; operator, typically &quot;<B>%</B>&quot;, that will return the remainder from a division operation. Although bB has no such operator, you can still get the remainder by doing a division using the <B>//</B> operator. See <A HREF="#division">division</A> above for more information.
</P>
</UL>
<H6 CLASS="bbsecondary"><A NAME="function">Functions</A></H6>
<P>
bB provides a simple interface for you to define your own functions. These functions can be defined within your program itself or compiled to their own separate .asm file then included with the include command. Functions can be written in batari Basic or assembly language.
<BR><BR>
To call a function, you assign it to a variable. This is currently the only way to call a function. Functions can have up to six input arguments, but they only have one explicit return value (that which is passed to the variable you assigned to the function.) You can have multiple return values but they will be implicit, meaning that the function will modify a variable and then you can access that variable after you call the function.
<BR><BR>
A function should have input arguments. In bB, a function can be called with no input arguments if you want, but you might as well use a subroutine instead, as it will save space.
<BR><BR>
To declare a function, use the <B>function</B> command, and specify a name for the function. Then place your bB code below and end it by specifying <B>end</B>. To return a value, use the <B>return</B> keyword. Using <B>return</B> without a value will return an unpredictable value.
<BR><BR>
Note that in bB, all variables are global, and arguments are passed to the function by use of the temp variables, temp1-temp6. Therefore it is recommended that you use the same temp variables for calculations within your function wherever possible so that the normal variables are not affected.
<BR><BR>
Example of declaring a function in bB:
</P>
<PRE CLASS="bbborder">
function sgn
rem this function returns the sign of a number
rem if 0 to 127, it returns 1
rem if -128 to 1 (or 128 to 255), it returns -1 (or 255)
rem if 0, it returns 0
if temp1=0 then return 0
if temp1 &lt;128 then return 1 else return 255
end
</PRE>
<P>
To call the above function, assign it to a variable, as follows:
<BR>
</P>
<PRE CLASS="bbborder">
a=sgn(f)
</PRE>
<P>
Note that there is no checking to see if the number of arguments is correct. If you specify too many, the additional arguments will be ignored. If you specify too few, you will likely get incorrect results.
<BR><BR>
To specify more arguments in a function, you can separate them by a comma. Supposing you called a function called <B>max</B> that determined the largest of three values you passed to it:
<BR>
</P>
<PRE CLASS="bbborder">
function max
if temp1&gt;temp2 then temp1bigger else temp2bigger
temp1bigger if temp1&gt;temp3 then return temp1 else return temp3
temp2bigger if temp2&gt;temp3 then return temp2 else return temp3
end
</PRE>
<P>
To call this function, you might do:
<BR>
</P>
<PRE CLASS="bbborder">
f=max(d, a[3], 7)
</PRE>
<UL>
<H6 CLASS="bbtertiary">Special consideration for functions in assembly language</H6>
<P>
To write an asm function for use in bB, many of the considerations are the same — you can pass up to six values to the function and return one. The difference is that the first two arguments are not copied to temp1 and temp2, but instead, the accumulator and the Y register, respectively. Additional arguments are copied to temp3-temp6. To return a value, load it into the accumulator and call an RTS.
<BR><BR>
Also, the function is entered with S and Z flags set according to the current value of the accumulator.
<BR><BR>
For example, here is the sgn function rewritten in asm:
<BR>
</P>
<PRE CLASS="bbborder">
sgn
bpl minus
lda #$FF
rts
minus
beq zero
lda #1
zero
rts
</PRE>
<P>
To use the above function in your bB program, you can either use inline asm in your bB program, or compile it separately and include its asm file using the include command, then you just call it as normal.
<BR><BR>
If you are writing an asm function for use in a bank-switched game, you need to use <B>RETURN</B> instead if <B>rts</B> to return. <B>RETURN</B> is an assembler macro that will automatically return to the calling bank.
<BR>
</P>
<H6 CLASS="bbtertiary"><B>Compiling a Function as a Module</B></H6>
<P>
You can create modules that are written in batari Basic or assembly language. To make an asm module, just write the module and include the file using the include command in bB. To create your own bB module, you must first compile it separately into asm, but not into a full binary. To do this, you can use the following commands. incidentally, the commands in DOS or Unix are the same:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>preprocess &lt; myfile.bas | 2600basic &gt; myfile.asm</B></SPAN>
<BR><BR>
Note that you may need to add a <B>./</B> before preprocess or <B>2600basic</B> in Unix if your path isn't set to look in the current directory.
<BR>
</P>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="assembly">Assembly Language</A></H3>
<UL>
<H6 CLASS="bbsecondary" STYLE="margin-top:0px;"><B>asm</B></H6>
<P>
Use the <B>asm</B> statement to insert inline assembly language into your program. You do not need to preserve any register values when using this feature, except the stack pointer. Mnemonics should be indented by at least one space, and labels should not be indented.
<BR><BR>
Example (clears the playfield)</P>
<PRE CLASS="bbborder">
asm
ldx #47
lda #0
playfieldclear
sta
playfield,x
dex
bne playfieldclear
end
</PRE>
<P>
You may also access any variables from assembly that are defined in batari Basic. For example, another way to express the statement a=20 is:</P>
<PRE CLASS="bbborder">
asm
lda #20
sta a
end
</PRE>
<H6 CLASS="bbsecondary"><B><A NAME="include">include</A></B></H6>
<P>
Used to include modules in the final binary that are not normally available. You may also include additional modules using the includesfile command, but you may prefer to use include if you just want an extra module or two to be compiled in addition to what is already in the default includes file.
<BR><BR>
An example is for fixed point math. Although you do not need to include anything to use many of the fixed point functions, for a few, you will need the fixed_point_math.asm module. You may find it easier to use
<BR>
</P>
<PRE CLASS="bbborder">
include fixed_point_math.asm
</PRE>
<P>
at the beginning of your program instead of (or in addition to) creating a new includes file, and this will allow you to share your source without also needing to attach your includes file as well.
<BR><BR>
With the include command, bB will place the module where it sees fit, typically in the first bank. If you want to have more control over where the modules go, you can use an includes file or the inline command.
<BR><BR>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> The include command must typically precede all other commands. At this time there is no checking to ensure that you do this. Particularly, if you use an includes file or a different kernel, you need to specify all of your include commands first or they will be ignored.
</P>
<UL>
<H6 CLASS="bbtertiary"><B><A NAME="includesfile">includes file</A></B></H6>
<P>
An includes file contains the filenames of all modules that will be included in the final binary. Modules may be general routines, functions or custom display kernels. The includes file also specifies the order in which they will appear (this is crucial.) The default includes file (default.inc) contains the standard kernel and some of the more commonly used modules.
<BR><BR>
To create your own includes file, you can use the default.inc file as a template. The default.inc file itself contains comments that should guide you. Save it to a new name and use the .inc extension. To specify a new includes file in your program, supposing your includes file is called myincludes.inc, use:
</P>
<PRE CLASS="bbborder">
includesfile myincludes.inc
</PRE>
<P>
You do not need to use the includesfile command to use the default.inc file.
<BR><BR>
One reason you may want to use your own includes file, however, is in the case where you need space in your program more than you need a standard module, such as the one for playfield scrolling.
<BR><BR>
Note that if you are using an includes file and you wish to share your Basic code with others, you should also share the includes file so that they can compile your code. Also, if you are using the include command in addition to an includes file, you must specify the include commands first.
<BR><BR>
</P>
</UL>
<H6 CLASS="bbsecondary"><B><A NAME="inline">inline</A></B></H6>
<P>
This command works similar to include, as it is used to include an .asm file in your program. But unlike include, inline allows you to specify exactly where an asm module will go. This is useful when you want to use inline asm code from an external file in your game without copying it into your code. inline is also useful for inserting a minikernel into your game.
<BR><BR>
Example:
</P>
<PRE CLASS="bbborder">
inline 6lives.asm
</PRE>
<P>
<SPAN STYLE="font-size:18px;"><B><FONT COLOR="#CC0033">Warning</FONT>:</B></SPAN> Using inline will insert the asm code exactly where the statement is, so doing so at the wrong place (such as at the beginning of your program) will probably cause your game to crash.
</P>
<H6 CLASS="bbsecondary"><B><A NAME="hackingasm">Hacking batari Basic's .asm Files</A></B></H6>
<P>
You are encouraged to hack the .asm files that come with bB, as doing so can extend its capabilities. Also, this is one avenue to learning assembly language programming.
<BR><BR>
bB 1.0 will search both the includes directory and the current directory for any .asm files it needs to build your game. But since it will search the current directory first, this means that you can now make a copy of an .asm file from the includes directory and modify your copy while keeping the existing files intact.
<BR><BR>
This scenario has the added advantage of allowing you to compile other games without needing to change the files back. Also, you can now distribute modified .asm files with your source code so others can build your game exactly as you intend without requiring them to modify their own .asm files.
<BR><BR>
Perhaps the most common file that people modify is <B>score_graphics.asm</B>. This allows you to define your own digits, and you may also modify digits A-F to make custom score displays. Aside from score graphics, this file also contains assembly directives, some of which you need to change if you wish to create definitions for A-F.
<BR><BR>
You may also copy and modify <A HREF="#includesfile">includes files</A> (.inc extension) and header files (.h extension) in the same fashion.
</P>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="atari7800">Atari 7800</A></H3>
<P>
The Atari 7800 is reverse-compatible with nearly 100% of Atari 2600 games. All bB games should run on the 7800. However, games that use the COLOR/BW switch may have problems. On the 7800, the switch is meant to be used as a PAUSE switch. On the 2600 this is a toggle or rocker switch, but on the 7800 it is a momentary pushbutton.
<BR><BR>
Most games will run exactly the same on either console because most do not use the COLOR/BW switch. But if necessary, bB can detect what console it is running on so you can account for this difference. When your game begins, temp1 will contain zero if the console is a 2600, or 255 if it is a 7800.
<BR><BR>
Note that you must check temp1 at the beginning of your game (it may be overwritten if you don't check it right away) and set a variable depending on temp1's value. A single bit is all you need.
</P>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
<H3 CLASS="bm"><A NAME="troubleshooting">Troubleshooting</A></H3>
<P>
This section does not cover all possible problems, but it does explain some common programming errors and their resolutions.
<BR><BR>
There are two types of programming errors. One type of error is a compilation error, that is, an error is caught by the compilation process and a proper binary is not produced. Another type is when the compilation process is successful but the binary file doesn't work correctly. This section outlines those two types of errors and tries to help resolve them, or at least the most common of them.
</P>
<UL>
<H6 CLASS="bbsecondary"><B>Compilation Errors</B></H6>
<P>
There are 3 stages in the bB compilation process where errors may be caught — in the preprocessor, the compiler or the assembler.
</P>
<H6 CLASS="bbsecondary"><B>Preprocessor Errors</B></H6>
<P>
The preprocessor can only catch the most obvious of errors, such as unrecognized symbols in the code.
<BR><BR>
An example of a preprocessor error:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>(34) unrecognized character: &quot;@&quot;</B></SPAN>
</P>
<H6 CLASS="bbsecondary"><B>Compiler Errors</B></H6>
<P>
The compiler can catch a wider range of errors, but quite a few errors will sneak past the compiler and will only be caught by the assembler.
<BR><BR>
An example of a compiler error:
<BR><BR>
<SPAN STYLE="font-size:18px;"><B>(34) Error: Unknown Keyword: hgoto</B></SPAN>
<BR><BR>
A preprocessor and compiler error, if caught, will point you to the line of code (not linenumber, as linenumbers are not necessary) in the source file where it occurs. In the above examples, the error is found in the 34th line of code in your source file. This should help to pinpoint the cause and fix it easily.
<BR><BR>
Note that compiler errors don't always make a lot of sense, but at least they usually point you to the right place.
</P>
<H6 CLASS="bbsecondary"><B>Assembler Errors</B></H6>
<P>
Assembler errors are more cryptic and harder to find and fix. This is because they occur only after the Basic file is converted to assembly and linked together to a composite asm file. There are many things that can go wrong at this stage, but there are four common errors that can be caught and fixed without too much trouble.
<BR><BR>
The four most common assembly errors are branches out of range, syntax errors, duplicate labels, and unresolved symbols.
</P>
<UL>
<H6 CLASS="bbtertiary"><B>Branches out of Range</B></H6>
<P>
A branch out of range is the easiest to resolve. This usually happens when an if-then statement is located too far away from its target. For example, &quot;if a=1 then 40&quot; will trigger this error if line 40 is far away from the if-then.
<BR><BR>
There are two ways to resolve this. One is to use &quot;if a=1 then goto 40.&quot; The only problem with this approach is that the assembler does not give you much help as to which line contains the error. You need to search the assembly file as described below, or track down the cause by trial and error or just change all relevant thens to then goto.
<BR><BR>
The other approach is to enable smart branching, which will eliminate practically all such errors. To enable smart branching, include the following statement at the beginning of your program:
<BR>
</P>
<PRE CLASS="bbborder">
set smartbranching on
</PRE>
<P>
<A HREF="#smartbranching">Smart branching</A> is not enabled by default because it will complicate the assembly. Since the original vision of batari Basic was that the created .asm file could be studied to learn assembly language, complicating the assembly by default would conflict with that vision.
</P>
<H6 CLASS="bbtertiary"><B>Syntax Errors</B></H6>
<P>
Often caused by a typographical error in a data statement, player or playfield declaration, inline asm or possibly other places. These are sometimes difficult to spot, and can often only be resolved by searching the created .asm file (see <A HREF="#searchingassembly">Searching the Assembly File</A> below.)
</P>
<H6 CLASS="bbtertiary"><B>Duplicate Labels</B></H6>
<P>
These occur when you use the same label or linenumber for two different lines of code. For example,
<BR>
</P>
<PRE CLASS="bbborder">
10 a=4
20 r=4
10 e=10
</PRE>
<P>
will compile but the assembler will claim there is a duplicate label (10.) The resolution is to look in your Basic source and change one of the labels to something else.
<BR><BR>
Note that the assembler sometimes reports bogus duplicate labels, but usually assembly is successful anyway. This is considered an assembler bug. Sometimes, the assembler generates literally hundreds of them. For this reason, all but the first one have been suppressed from the output. Ignore duplicate labels if your game builds successfully, or if the game doesn't build but has a non-empty unresolved symbol list (see next topic).
</P>
<H6 CLASS="bbtertiary"><B>Unresolved Symbols</B></H6>
<P>
Any time the assembler finds an error, it will list some unresolved symbols. If the list is empty, simply ignore it; the problem lies elsewhere. If there is something on the list, this is likely the cause of your error.
<BR><BR>
The most common cause is a goto, if-then, or gosub target to a label that doesn't exist. The following example would cause such an error if line number 300 did not exist:
</P>
<PRE CLASS="bbborder">
goto 300
</PRE>
<P>
It can also be caused by a function call to a non-existent function. The following would cause this error if <B>myfunction</B> was not defined:
<BR>
</P>
<PRE CLASS="bbborder">
a=myfunction(33)
</PRE>
<P>
Another cause occurs when a call to a routine in a module or bB internal function is made but the proper module is not included. For example, the statement &quot;a=e/17&quot; will produce &quot;div8&quot; as an unresolved symbol if the module &quot;div_mul.asm&quot; is not included.
<BR><BR>
Any cause not listed above will likely only be found by searching the assembly file.
</P>
</UL>
<H6 CLASS="bbsecondary"><A NAME="searchingassembly">Searching the Assembly File</A></H6>
<P>
With most assembler errors, the line of code in the composite .asm file will be echoed in parentheses. This line will often be large (sometimes &gt; 10000) so hand-counting the lines is not feasible — you will need to open the file a text editor utility that can jump to this line or at least tell you what line the cursor is on. If you don't have an adequate text editor in Windows, you can use the DOS 'EDIT' program, which will tell you what row of text the cursor is on.
<BR><BR>
Once you jump to the offending line of code, look above for a line of bB code that will be inserted as a comment (after a semicolon.) This is usually where the error has occurred in your Basic source file. Note that the error may be subtle, but it is usually there somewhere.
<BR><BR>
If you do not see any bB code nearby, the error is probably with a player or playfield definition. In this case, take a look at the data in the graphical object and find the corresponding bB code where you defined this object.
<BR><BR>
If none of the above apply, the error could be with some inline asm you have inserted.
</P>
<H6 CLASS="bbsecondary"><B>Other Errors</B></H6>
<P>
This section is intended to help find common errors where compilation is successful but the game doesn't work. This section will be expanded at a later date.
</P>
<UL>
<H6 CLASS="bbtertiary"><B>Blank Screen</B></H6>
<P>
Make sure you are calling drawscreen somewhere in your game loop (and that your game runs in a loop!)
If you are, you probably didn't set colors, as they are all black by default. You use COLUP0 for
player0 and missile0, COLUP1 for player1 and missile1, COLUPF for the playfield and ball, and COLUBK for
the background.
</P>
<H6 CLASS="bbtertiary"><B>Players Use Score Color</B></H6>
<P>
The score actually uses player objects, so COLUP0 and COLUP1 must be set during every frame or their colors will revert to that of the score.
</P>
<H6 CLASS="bbtertiary"><B>Timing problems</B></H6>
<P>
My game jitters, shakes or rolls!
<BR><BR>
Your program is spending too much time in the game loop. You have only about 2 milliseconds of time between successive calls to drawscreen, or about 2700 machine cycles. It doesn't seem like much, but with efficient coding you can get quite a bit in here.
<BR><BR>
The drawscreen command must run 60 times a second, and it takes about 12 milliseconds to complete, as it renders the television display. Your program must run while the television picture is off of the screen and blanked out.
<BR><BR>
The most common cause is probably too many calls to playfield plotting/scrolling routines or too many large loops, though other routines can also use up lots of time.
<BR><BR>
The only solution to this problem is to reduce the complexity of your program between calls to drawscreen, either by calling it more than once throughout your program or spreading your calculations across several frames (calls to drawscreen, that is.) Note that calling drawscreen several times without also moving your objects each time will slow down your game.
<BR><BR>
See <A HREF="#drawscreen">drawscreen</A> for more information about timing problems.
</P>
<H6 CLASS="bbtertiary"><B>Games written for earlier versions of bB don't work correctly</B></H6>
<P>
bB 1.0 has many changes that might 'break' your game. Chances are, the problem is that the players are no longer in the correct places (specifically, 14 pixels to the right.)
<BR><BR>
There is a new compiler directive (legacy) that can solve some of these problems. See <A HREF="#legacy">legacy</A> under compiler directives for more information.
<BR><BR>
If <B>legacy</B> does not solve your problem and you can't figure out what to do, feel free to post a message to the <A HREF="http://www.atariage.com/forums/index.php?showforum=65" TARGET="_blank" TITLE="External site opens in new window">Atari 2600 Basic forum on AtariAge</A>.</P>
</UL>
</UL>
<H6 ALIGN="right" STYLE="margin-top:24px;"><A HREF="#top">Back to Top</A></H6>
</TD>
<TD WIDTH="254" ALIGN="left" VALIGN="top">
<H5 STYLE="padding-left:8px; margin-bottom:5px; margin-top:5px; margin-left:2px; padding-left:6px;">Click on a topic below for help:</H5>
<H6 STYLE="padding-left:8px; margin:0px;">
<A HREF="#hex">$ Operator</A><BR>
<A HREF="#binary">% Operator</A><BR>
<A HREF="#math">Addition</A><BR>
<A HREF="#dim">Alias</A><BR>
<A HREF="#math">Arithmetic Operators (+, -, *, /)</A><BR>
<A HREF="#dataarrays">Arrays</A><BR>
<A HREF="#assembly">asm</A><BR>
<A HREF="#assembly">Assembly Language</A><BR>
<A HREF="#atari7800">Atari 7800</A><BR>
<A HREF="#sound">AUDC0</A><BR>
<A HREF="#sound">AUDC1</A><BR>
<A HREF="#sound">AUDF0</A><BR>
<A HREF="#sound">AUDF1</A><BR>
<A HREF="#sound">AUDV0</A><BR>
<A HREF="#sound">AUDV1</A><BR>
<A HREF="#kerneloptions">background</A> (kernel_options)<BR>
<A HREF="#ball">ball</A><BR>
<A HREF="#bankswitching">Bank Switching</A><BR>
<A HREF="#bcd">BCD Compliant Number</A><BR>
<A HREF="#binary">Binary Numbers</A><BR>
<A HREF="#bit">Bit Operations</A><BR>
<A HREF="#bitwise">Bitwise (Logical) Operators</A><BR>
<A HREF="#boolean">Boolean Operators</A> (if-then)<BR>
<A HREF="#switches">BW/Color Switch</A><BR>
<A HREF="#collision">Collision Detection</A><BR>
<A HREF="#colorchart">Color Chart</A><BR>
<A HREF="#switches">Color/BW Switch</A><BR>
<A HREF="#colors">Colors</A><BR>
<A HREF="#colubk">COLUBK</A><BR>
<A HREF="#colup0">COLUP0</A><BR>
<A HREF="#colup1">COLUP1</A><BR>
<A HREF="#colupf">COLUPF</A><BR>
<A HREF="#set">Compiler Directives</A><BR>
<A HREF="#switches">Console Switches</A><BR>
<A HREF="#const">const</A><BR>
<A HREF="#const">Constants</A><BR>
<A HREF="#ctrlpf">CTRLPF</A><BR>
<A HREF="#debug">cycles</A> (debug)<BR>
<A HREF="#debug">cyclescore</A> (debug)<BR>
<A HREF="#dataarrays">Data Statements</A><BR>
<A HREF="#debug">debug</A> (directive)<BR>
<A HREF="#decimal">Decimal Numbers</A><BR>
<A HREF="#decisionmaking">Decision Making</A><BR>
<A HREF="#dim">Descriptive Names</A><BR>
<A HREF="#switches">Difficulty Switches</A><BR>
<A HREF="#dim">dim</A><BR>
<A HREF="#set">Directives</A><BR>
<A HREF="#division">Division</A><BR>
<A HREF="#dos">DOS Compatibility</A><BR>
<A HREF="#drawscreen">drawscreen</A><BR>
<A HREF="#else">else</A> (if-then)<BR>
<A HREF="#ephvarreg">Ephemeral Variables &amp; Registers</A><BR>
<A HREF="#fixedpoint">Fixed Point Variables</A><BR>
<A HREF="#for">for-next</A><BR>
<A HREF="#function">Functions (User-defined)</A><BR>
<A HREF="#gosub">gosub</A><BR>
<A HREF="#goto">goto</A><BR>
<A HREF="#hackingasm">Hacking batari Basic's .asm Files</A><BR>
<A HREF="#lifecounterstatusbar">Health Bar</A><BR>
<A HREF="#hex">Hexadecimal Numbers</A><BR>
<A HREF="#pfhline">Horizontal Lines</A><BR>
<A HREF="#huds">HUDs</A><BR>
<A HREF="#if">if-then</A><BR>
<A HREF="#include">include</A><BR>
<A HREF="#includesfile">includes file</A><BR>
<A HREF="#labels">Indenting</A><BR>
<A HREF="#dataarrays">Indexing</A><BR>
<A HREF="#inline">inline</A><BR>
<A HREF="#optimization">inlinerand</A> (optimization)<BR>
<A HREF="#joysticks">Joysticks</A><BR>
<A HREF="#jumpingaround">Jumping Around</A><BR>
<A HREF="#kernel">kernel</A> (directive)<BR>
<A HREF="#kerneloptions">kernel_options</A> (directive)<BR>
<A HREF="#labels">Labels</A><BR>
<A HREF="#legacy">legacy</A> (directive)<BR>
<A HREF="#let">let</A><BR>
<A HREF="#lifecounterstatusbar">Life Counter</A><BR>
<A HREF="#lifecolor">lifecolor</A> (life counter/status bar)<BR>
<A HREF="#labels">Line Numbers</A><BR>
<A HREF="#lives">lives</A> (life counter/status bar)<BR>
<A HREF="#loops">Loops</A><BR>
<A HREF="#math">Math</A><BR>
<A HREF="#memory">Memory</A><BR>
<A HREF="#huds">Minikernels</A><BR>
<A HREF="#miscellcommand">Miscellaneous Commands</A><BR>
<A HREF="#missiles">Missiles</A><BR>
<A HREF="#modulus">Modulus Operation</A><BR>
<A HREF="#kerneloptions">Multicolored Sprites</A><BR>
<A HREF="#multiplication">Multiplication</A><BR>
<A HREF="#multikernel">Multisprite Kernel</A><BR>
<A HREF="#negative">Negative Numbers</A><BR>
<A HREF="#next">next</A><BR>
<A HREF="#kerneloptions">no_blank_lines</A> (kernel_options)<BR>
<A HREF="#optimization">noinlinedata</A> (optimization)<BR>
<A HREF="#sound">Noise</A><BR>
<A HREF="#noscore">noscore</A><BR>
<A HREF="#tv">ntsc</A><BR>
<A HREF="#numbers">Numbers</A><BR>
<A HREF="#nusiz">NUSIZ0</A><BR>
<A HREF="#nusiz">NUSIZ1</A><BR>
<A HREF="#objects">Objects</A><BR>
<A HREF="#ongoto">on … goto</A><BR>
<A HREF="#optimization">optimization</A> (directive)<BR>
<A HREF="#tv">pal</A><BR>
<A HREF="#pf0">PF0</A><BR>
<A HREF="#kerneloptions">pfcolors</A> (kernel_options)<BR>
<A HREF="#pfheight">pfheight</A> (Multisprite Kernel)<BR>
<A HREF="#kerneloptions">pfheights</A> (kernel_options)<BR>
<A HREF="#pfhline">pfhline</A> (Playfield)<BR>
<A HREF="#pfpixel">pfpixel</A> (Playfield)<BR>
<A HREF="#pfread">pfread</A> (Playfield)<BR>
<A HREF="#pfres">pfres</A> (Playfield)<BR>
<A HREF="#pfrowheight">pfrowheight</A> (Playfield)<BR>
<A HREF="#pfscorebars">pfscore</A> (pfscore bars)<BR>
<A HREF="#pfscorebars">pfscore bars</A><BR>
<A HREF="#pfscore1">pfscore1</A> (pfscore bars)<BR>
<A HREF="#pfscore2">pfscore2</A> (pfscore bars)<BR>
<A HREF="#pfscorecolor">pfscorecolor</A> (pfscore bars)<BR>
<A HREF="#pfscroll">pfscroll</A> (Playfield)<BR>
<A HREF="#pfvline">pfvline</A> (Playfield)<BR>
<A HREF="#objects">Player Graphics</A><BR>
<A HREF="#kerneloptions">player1colors</A> (kernel_options)<BR>
<A HREF="#kerneloptions">playercolors</A> (kernel_options)<BR>
<A HREF="#playfield">Playfield</A><BR>
<A HREF="#pop">pop</A><BR>
<A HREF="#rand">rand</A><BR>
<A HREF="#randomnumbers">Random Numbers</A><BR>
<A HREF="#kerneloptions">readpaddle</A> (kernel_options)<BR>
<A HREF="#reboot">reboot</A><BR>
<A HREF="#refp">REFP0</A><BR>
<A HREF="#refp">REFP1</A><BR>
<A HREF="#rem">rem</A><BR>
<A HREF="#switches">Reset Switch</A><BR>
<A HREF="#return">return</A><BR>
<A HREF="#return">return otherbank</A><BR>
<A HREF="#return">return thisbank</A><BR>
<A HREF="#romsize">romsize</A> (directive)<BR>
<A HREF="#score">score</A><BR>
<A HREF="#score">scorecolor</A><BR>
<A HREF="#screenheight">screenheight</A><BR>
<A HREF="#sdata">sdata</A> (Sequential Data)<BR>
<A HREF="#switches">Select Switch</A><BR>
<A HREF="#sdata">Sequential Data</A><BR>
<A HREF="#set">set</A><BR>
<A HREF="#optimization">size</A> (optimization)<BR>
<A HREF="#smartbranching">smartbranching</A> (directive)<BR>
<A HREF="#sound">Sound</A><BR>
<A HREF="#optimization">speed</A> (optimization)<BR>
<A HREF="#objects">Sprites</A><BR>
<A HREF="#sread">sread</A> (Sequential Data)<BR>
<A HREF="#lifecounterstatusbar">Status Bar</A><BR>
<A HREF="#statusbarcolor">statusbarcolor</A> (status bar)<BR>
<A HREF="#statusbarlength">statusbarlength</A> (status bar)<BR>
<A HREF="#subtraction">Subtraction</A><BR>
<A HREF="#superchipram">Superchip RAM</A><BR>
<A HREF="#switches">Switches</A><BR>
<A HREF="#tia">TIA Registers</A><BR>
<A HREF="#timing">Timing</A><BR>
<A HREF="#tonechart">Tone Chart</A><BR>
<A HREF="#troubleshooting">Troubleshooting</A><BR>
<A HREF="#tv">tv</A> (directive)<BR>
<A HREF="#variables">Variables</A><BR>
<A HREF="#vblank">vblank</A><BR>
<A HREF="#pfvline">Vertical Lines</A><BR>
<A HREF="#virtualspritereg">Virtual Sprite Registers</A><BR>
<A HREF="#multikernel">Virtual Sprites</A><BR>
<A HREF="#whitespace">White Space</A><BR>
</H6>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>