Re: [stella] (was: New to 2600 Programming)

Subject: Re: [stella] (was: New to 2600 Programming)
From: Glenn Saunders <cybpunks2@xxxxxxxxxxxxx>
Date: Sat, 10 Nov 2001 01:03:45 -0800
At 11:18 PM 11/9/2001 -0600, you wrote:
Ummm... each bit represents a pixel. If the bit is on, the pixel is on. If
the bit is off, the pixel is off.

Just to finish the thought... there are at least two assembler commands related to data.

.byte indicates a single 8-bit byte of data. .word indicates two bytes of data. .word is often used to store addresses. As the 6502 can address 64K of data, you need two bytes. Even on the 2600 which only addresses 4K at a time, you still need 2 bytes. 4096 bytes requires 12 bits of address data, one bit less than the 6507 in the 2600 can handle, but all the cart port can handle.

When writing a program you separate your code and your data into blocks. Just as in BASIC you have strings and variable declarations, .byte works like that. By using a label above the byte, it's like naming your variables for later reference. In the case of a 2-dimensional shape, you normally put a label to mark the starting address of the shape like so:

(stored upside down)
hat <- represents the starting memory address of the following byte or program line
.byte %11111111
.byte %00111100
.byte %00111100
.byte %00111100
.byte %00111100

Then you run a bit of code in your program to scan out the data to the sprite register on each scanline by referencing 'hat' with an offset (X) that you decrement from 4 to 0.


The advantage of assembler is that all the labels above are resolved to addresses and numbers by the assembler when you assemble your code. This is the key to making machine language readable! And since the 6502 has so few instructions, and the 2600 so few registers, it's really not that hard to read 2600 sourcecode. Understanding WHY it's doing what it's doing is another matter, but you should be able to figure out what it's doing at any one line quite easily after you memorize the 6502 mnemonics and 2600 register names.

This has the equivalent meaning in Basic (if the Atari2600 had a full fledged basic interpreter):

1 hat = 500; REM (Set address of hat graphics)

10 FOR X = 4 TO 0 STEP -1
20 POKE(WSYNC,255)
30 B = PEEK((ADR(hat$)+X))

90 DIM HAT$(5)
100 HAT$="ABBBB" <-- whatever the ascii equivalent is to each of the .bytes.

The "Atari Player Missile Graphics" Book I have that tells you how to program the Atari 8-bit's sprite's in Basic has programs very similar to the above for similar reasons. (that is a really cool book by the way). The above is an assembler-like construct (lots of peeks, pokes, and ADRess functions) in Basic syntax. In C it would be memory pointers instead of ADR(). Higher level languages try to eliminate the need to specify discrete addresses of memory as much as possible, but in assembler you have to point to them all the time. That's why at least in assembler you replace these numbers with labels.

If you've had any prior experience with Basic, this should provide some reference point for you, but again, I suggest you pick up some books.

---------------------------------------------------------------------------------------------- Archives (includes files) at Unsub & more at

Current Thread