Jump to content
IGNORED

Is 2600 programming a good way to learn 6502?


Arno1978

Recommended Posts

My apologies if this has been asked before. I've just recently (as in starting 2 weeks ago) learning 6502 assembly. My intent is to eventually create a NES game. But in the past few days, I've also been looking at the Atari 2600, finally understanding how it's limited graphics worked, and reading about or watching docs on many of the original Atari programmers. I watched Warren Robinett's GDC talk on Adventure a few years ago. For a system that was originally meant to run and display Combat and Pong and a few more variations of those 2 titles, the creativity the first programmers and homebrew programmers have shown is incredibly genius and astounding. I had 2 Atari's myself and had a few favorite titles that I would play hours on end. I've sometimes pondered learning to make an Atari game. But with such extreme limitations, and being a beginner at learning assembly, the architecture, "racing the beam", and trying to fit a game in to 4k rom that can only use 128 bytes of ram that has both game logic and display logic, is it the right system to start with? It seems almost masochistic to make a game for this system (no offense at all to programmers/devs). I'm sure the feeling is exhilarating when successfully making a game for the system, and is definitely a feat to be proud of.

Edited by Arno1978
  • Like 1
Link to comment
Share on other sites

Alternatively, a good platform to start learning assembly programming on the 2600 is actually batari Basic. bB allows for inline assembly, so you can start with snippets of assembly within a working framework. It also has modular kernels - so you can experiment with writing your own display kernel when that time comes.

 

The benefit of starting with bB would be that you'll be learning the 2600 resources and limitations, rather than the resources and limitations of another 8-bit computer that you may not be deeply interested in. Of course, you'll be learning a bit of bB programming priot to 6502 assembly, but it's a rather straightforward language to pick up, and it has usefulness in addition to learning assembly.

  • Like 3
Link to comment
Share on other sites

21 hours ago, Thomas Jentzsch said:

Short answer: No!

 

Seconded.

 

Have you seen Easy 6502?  It's an online tutorial with an assembler and simple virtual machine.

 

The first program example:

 

1134624730_ScreenShot2022-02-25at12_30_24PM.thumb.png.06f85a86af4c623f833de31b14bb1ebd.png

 

Click Assemble, status update in the grey box at the bottom:

 

920281280_ScreenShot2022-02-25at12_30_29PM.thumb.png.6a0bcc029ae9d2a08c1a9a7c871f293d.png

 

Click Run, results in the black box on the upper right:

 

974248885_ScreenShot2022-02-25at12_30_33PM.thumb.png.167b33b3b113c4ac937dffaa919bd7a4.png

 

Replace the code with a simple example, click Assemble, then Run:

 

469850260_ScreenShot2022-02-25at12_33_51PM.thumb.png.5e06867b01d31947a358b12406d104c4.png

 

	lda #0
	ldx #0
loop:
	sta $0200,x
	adc #7
	inx
	bne loop

 

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thank you for the resources. I've actually been working on Easy 6502. I love it. At the moment, I'm trying out my own code to figure out how the carry flag works for the ADC and SBC operations. Binary math is pretty neat, but definitely has a few little catches. It seems in an SBC operation, you would only need the carry flag, if you subtract a number that's larger than half of what you're subtracting it from. Example. 15-8 would require it, but 15-7 wouldn't. Unless, I'm wrong. I'll figure it out. I am enjoying it though.

 

The reason, I was thinking about 2600 programming, is that there are a lot of great resources and tutorials for it - covering every aspect of it. I tend to learn that way, by seeing examples of how a particular function of operations might work together, and then deconstructing them to see what is going on behind the scenes. I do now understand how the graphics at least work, and how they're manipulated in creating "sprites" or other interesting effects, etc. I have great respect for anyone who has programmed on the 2600. I love seeing creative things done with extreme limitations. I like doing things like that myself.

 

Thank you for the replies. I'll stick to just learning the 6502 by itself. As I said in the first post, it's a NES game that I eventually want to make. The Atari still has a special place in my heart though, along with my other 80s consoles, so perhaps in a decade or so, I might try it out.

  • Like 2
Link to comment
Share on other sites

If you haven't found it, 6502.org has a lot of good resources. Their Source Code Repository has lots of examples for doing math.

 

39 minutes ago, Arno1978 said:

The reason, I was thinking about 2600 programming, is that there are a lot of great resources and tutorials for it - covering every aspect of it. I tend to learn that way, by seeing examples of how a particular function of operations might work together, and then deconstructing them to see what is going on behind the scenes.

 

Not a bad reason - if you do want to try coding for the 2600 my Collect Tutorial covers writing a 2K game from scratch.   I put lots of comments in the source code, so be sure to download that when you go thru each part of the tutorial.

  • Like 1
Link to comment
Share on other sites

Thank you so much Spiceware. I had forgotten to mention, before you had replied earlier, I was watching your 2600 homebrew talk earlier this morning.. Haven't finished it yet (I'm at work), but will tonight. Thank you for linking the Source Code Repository. That's how I learn. Even if I get the concept, I like going through a number of examples to really get a thorough understanding - until it clicks and is almost 2nd nature. I call it patient learning, but it has made things slow to learn. I've been programming in Lua for 14 years and I'm still intermediate level, because I've been very slowly going through the language, and mostly coding with a portion of it. I also tend to re-invent the wheel the wrong way. I mean it's neat when you can make a little space exploration .. thing with 100 lines and a 5-d array, but was it the best approach? I don't think it was. :P

 

I will bookmark your Collect Tutorial and will definitely go through it if I try my hand at 2600.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Arno1978 said:

It seems in an SBC operation, you would only need the carry flag, if you subtract a number that's larger than half of what you're subtracting it from. Example. 15-8 would require it, but 15-7 wouldn't. Unless, I'm wrong. I'll figure it out.

Try these exact examples. Try them with SEC before the SBC, and then try them again but with CLC instead of SEC.

Link to comment
Share on other sites

If you are fairly intelligent and more importantly patient, the VCS is not that hard to learn on, however you would probably be happier with the NES if that is the machine you are most interested in writing a game for. 

On 2/24/2022 at 1:20 PM, Arno1978 said:

My apologies if this has been asked before. I've just recently (as in starting 2 weeks ago) learning 6502 assembly. My intent is to eventually create a NES game.

 

Link to comment
Share on other sites

batariBASIC has been my gateway into 6502 assembler.   I can make small, experimental changes in assembly and immediately see the results on screen.  BUT that's come over years of learning the nuances of Atari 2600 hardware so I *comprehend the results.

 

The NES has its own variant of the 6502 and talks to very different hardware and cartridge enhancements.  You're better off following the Nerdy Nights tutorial and lurking in the NESdev forums.

 

https://nerdy-nights.nes.science/

 

 

* Have a small chance in heck of understanding why the emulator went into debug mode whilst I rage, grunt and throw bananas.

Link to comment
Share on other sites

On 2/24/2022 at 9:20 PM, Arno1978 said:

My intent is to eventually create a NES game.

My suggestion on tackling this: for learning 6502 use the simulator like SpiceWare suggested. But as soon as possible, start with your desired target system the NES. Gather a nice dev environment with an emulator with debugging options, as much as example code as you can get your hands on, and an assembler that can work with your example code.

 

Then take those examples as templates to come up with your own code, replacing more and more of the example with your own implementations. Not doing this was the biggest mistake I made when started to code for the 2600: I was accustomed to 6502 assembler from my childhood with a C64, took the original Stella programming manual, read it thoroughly and started creating my own code from scratch.

 

My first code just didn't work, and frustrated after hours of not figuring out why, I switched to modifying example code to finally get some sort of result. Weeks later it turned out, that I missed a line the docs stating that I needed three lines for a sync, I just did one.

 

When I do workshops showing how to code for the 2600, I typically use some code displaying a Space Invader using the mirrored playfield graphics. This code is then to be modified to display a bitmap using the asymmetrical playfield technique racing the beam. By modifying the example code, people can focus on the main goal, racing the beam, not caring about generating the sync signal, initializing the system or something similar. And since people do something timing critical, it is so much more than just a "hello world", and it really feels like an achievement.

Link to comment
Share on other sites

  • 4 weeks later...
  • 6 months later...

a c64 is a good machine to start. but i would use an emulator for that. maybe you want to look at kick asm. but there are of course many assemblers available to program for the c64.
the atari 2600 is a difficult beast to program. the c64 has a rum with basic to start with.
screen buffers with a tile map are a convinient way to visualize text. you just write an ascii code in an address of the memory that reflexts the x and y coordinate of the screen buffer and you have your ascii symbol on the screen.
when you start with 6502 assembler, you always need to know something about the registers of the chipset that is built-in in your machine.
on the c64, you can start with basic to program these registers of the video chip, like sprite registers. or the registers of the SID audio chip to make noise or music.
learning to use these registers would be the first step. this can be done with "pokes" on the c64 in basic. when you know what to do with the registers, then your can try to switch from basic to 6502 assembler.
there are multiple assemblers available to generate the machine code from your text assembler file that you can write with notepad++ on windows for example.
try a few of them and report back which one worked for you.

i did a little bit of C programming a while ago and i used kickC for that. it worked good. i made a simple batch script that automatically started the C64 emulator on windows, running my program. it was a convenient way to develop.

Link to comment
Share on other sites

On 2/24/2022 at 3:20 PM, Arno1978 said:

My apologies if this has been asked before. I've just recently (as in starting 2 weeks ago) learning 6502 assembly. My intent is to eventually create a NES game. But in the past few days, I've also been looking at the Atari 2600, finally understanding how it's limited graphics worked, and reading about or watching docs on many of the original Atari programmers. I watched Warren Robinett's GDC talk on Adventure a few years ago. For a system that was originally meant to run and display Combat and Pong and a few more variations of those 2 titles, the creativity the first programmers and homebrew programmers have shown is incredibly genius and astounding. I had 2 Atari's myself and had a few favorite titles that I would play hours on end. I've sometimes pondered learning to make an Atari game. But with such extreme limitations, and being a beginner at learning assembly, the architecture, "racing the beam", and trying to fit a game in to 4k rom that can only use 128 bytes of ram that has both game logic and display logic, is it the right system to start with? It seems almost masochistic to make a game for this system (no offense at all to programmers/devs). I'm sure the feeling is exhilarating when successfully making a game for the system, and is definitely a feat to be proud of.

I'd try the NES first. 

The NES is a lot easier than the 2600- It has a lot of convienient features, like real sprites, a tilemap, and more RAM. I started with 2600 though and it's fine to start with it, just it's very limited.

 

Edit: If you still want to do Atari coding, do the Atari 8 bit/ Atari 5200 since it is easy, similar to the 2600, and has more capability.

Edited by Ecernosoft
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.

Guest
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.

Loading...
  • Recently Browsing   0 members

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