Jump to content

Any tips for a beginning Atari 2600 programmer?

Recommended Posts

Hello, AtariAge! This is my first post on here, although I have been benefiting from all the information from this amazing community for a while now (and I just realized I should have posted this in the newbie section).


My dad had an Atari 2600 when he was a kid, and he still had it while I was growing up. We had quite a few games, but we ended up losing them in a flood. About a year ago I got the Atari bug and ordered a bunch of games on eBay.


I stumbled onto AtariAge and discovered that there are still people programming games for the system. I watched a lot of David Crane presentation videos and had a pretty good idea of how the games are actually made, but I haven't tried to make one until very recently.


I have been programming since I was about 9. I started with BASIC, and learned Python, C++, and a bit of assembly. I am now preparing to begin writing my first game for the 2600. I have many ideas, but I will start with something simple first. I was thinking of making a snake game and perhaps a Nyan Cat game (yes, I know these have been done before).


I have taken a look at the tutorials on this site ("2600 101" and "Collect") and ordered Racing the Beam and Making Games for the Atari 2600 on Amazon yesterday. Before trying to make a game, though, I wanted to make some super easy (or so I thought) mini-demos.

I wanted to make a USA flag to learn how to use the playfield and players, but I was having a some very strange issues with the colors. I am using assembly language (not batari Basic), the DASM assembler, and the Stella emulator. I also ordered a Harmony cartridge for testing on a real system and *ahem* "research".


So, aside from the "2600 101" and "Collect" tutorials, and Racing the Beam and Making Games for the Atari 2600 (and of course the Stella Programmer's Guide) is there any other material I should be reading or watching to help me out? Any tips for somebody just starting out? And are there any good 6502 manuals that you know of? I know simple 6502 assembly, but when I read other people's code I see a lot of commands that I don't know.


Thank you for your time!

Edited by JeremiahK
  • Like 3
Link to comment
Share on other sites

Welcome to AtariAge!

Great, that you decided to program for the 2600. And absolutely great, that you decided to use Assembler. :thumbsup:

There is a lot of information about the 6502 out there, e.g. this one, which I am using when in doubt. As for the 2600 itself, besides the tutorials you listed and looking at other peoples code, there are some other sources, like the old Stella Mailing List and the MiniDig.


BTW: I start almost every development with "How to Draw a Playfield" which is explained here.

  • Like 3
Link to comment
Share on other sites

Thank you, Thomas! I will definitely be taking a look at those links.


One silly thing which I am trying to find out but can't find any information on is how to simply give names to values which can be used later in the code. (For example, hex values representing colors.)


This is how I tried to do it at first:

; Very early in the code.
; After including vcs.h and macro.h, for example.

USA_RED      = #$36
USA_WHITE    = #$0F
USA_BLUE     = #$84

; ...a lot of code here...

        lda USA_BLUE  ; I would like this act like "lda #$84" during assembly
        sta COLUBK    ; Set the TIA background color register to blue

It took me a while to realize that the assembler was treating USA_BLUE like a memory address (or pointer) rather than a value. Is it possible to give names to values like this in DASM?


Edit: It just dawned on me that this could be done by defining and labeling data in the ROM after the code. I just tested it, and it works!

; ...After all of the code

        .byte $36

        .byte $0E

        .byte $84

; Define the end of the cartridge
Edited by JeremiahK
Link to comment
Share on other sites

You missed the # in from of the label (the # at the definition does nothing)


For the colors, I am using defines and conditional assembling:

NTSC_COL        = 1
YELLOW          = $10
ORANGE          = $20
RED_ORANGE      = $30
RED             = $40
PURPLE          = $50
VIOLET          = $60
INDIGO          = $70
BLUE            = $80
BLUE2           = $90
TURQUOISE       = $A0
CYAN            = $B0
GREEN           = $C0
OCHRE           = $F0
YELLOW          = $20   ; no real equivalent
ORANGE          = $20
RED_ORANGE      = $40
RED             = $60
PURPLE          = $80
VIOLET          = $A0
INDIGO          = $C0
BLUE            = $D0
BLUE2           = $B0
TURQUOISE       = $90
CYAN            = $70
GREEN           = $50
OCHRE_GREEN     = $30   ; no real equivalent
OCHRE           = $20   ; no real equivalent
  • Like 1
Link to comment
Share on other sites

Aha, I was completely misunderstanding the use of the # symbol there. Thank you very much, that is much better than defining data in the cartridge and eating up ROM space.


If you haven't already, make sure you get a good understanding of the different addressing modes that the 6502/6507 supports. The difference between LDA $00 and LDA #$00 can be a large amount of cursing at stella debugger. Also, make sure you configure stella to "Drive unused TIA pins randomly on a read/peek". This option is under TIA in the debugger mode aka pressing ~ key. Driving the unused TIA pins will help you notice when you forget that # and end up with a ZP load instead of an Immediate. And you will forget, we all do.

  • Like 4
Link to comment
Share on other sites

Thanks for the tips, Moonsweeper. It's been a while since I used assembly (and it wasn't for a 6502/6507, either).


That's ZackAttack, Moonsweeper is his rank. Your's is currently Combat Commando while mine's Quadrunner.


Besides setting Randomizing TIA:



You should Randomize RAM and the CPU registers.



I recently had some problems with Draconian were it worked in Stella but not on my 2600. Turns out I'd turned off randomize RAM while researching somebody else's problem and forgot to turn it back on. So in Stella all the RAM was set to 0 while on my 2600 the RAM had random values and was thus causing problems because I'd forgotten to initialize a variable.


tschak909 made a couple videos giving a pretty good overview of the debugger. Check them out in reply #86 and #87 of another topic. I posted some follow up comments/corrections in reply #91.

  • Like 1
Link to comment
Share on other sites

You may find the Easy 6502 tutorial helpful with the addressing modes.


Thank you so much for pointing me to this tutorial. Like I said, I have done assembly programming before, but it had been a while and my memory was a bit rusty. This tutorial quickly explained everything I needed to know, and the examples and exercises helped me grasp what was actually going on inside the CPU.


I just managed to create my first extremely simple kernel (based on the rainbow pattern kernel from SpiceWire's Collect tutorial).

Here is the .bin: usaflag2.bin


I'll post the source code as soon as I clean it up a bit, and then I'll work on making a "bouncing DVD logo" type of demo, and hopefully move on to my first game.

Edited by JeremiahK
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...