Where do I start?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

User avatar
PrimordialHelios
Posts: 4
Joined: Fri Jul 29, 2016 9:11 pm

Where do I start?

Post by PrimordialHelios »

So I recently got the urge to try and learn how to program for the NES, but I really have no clue where to start. I know a decent amount of C++, and some C, but I don't know any assembly, and other than the fact that I know the NES has a MOS 6502, I don't know anything about the hardware of it. What I want to know is: where should I start? should I start learning 6502 assembly (I have NESASM), or should I learn more about its hardware? I read the "Getting Started" sticky, but I was wondering if there were any guides that were for people who really knew absolutely nothing about the NES or asm, or some kind of documentation for the NES and 6502 asm.
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Where do I start?

Post by Drew Sebastino »

PrimordialHelios wrote:I was wondering if there were any guides that were for people who really knew absolutely nothing about the NES or asm
http://nintendoage.com/pub/faq/NA/index ... s_out.html#

This actually uses NESASM which you have, but most people, (including myself, who looked into the NES when I couldn't find anything for the SNES) think it sucks for various reasons. I don't know of any NES tutorials other than that, but you might want to look at these: The first one is the 6502 instruction set, the second is the video hardware registers for the NES, and the third is the audio hardware registers for the NES: http://www.6502.org/tutorials/6502opcodes.html, http://wiki.nesdev.com/w/index.php/PPU_registers, http://wiki.nesdev.com/w/index.php/APU_registers

I know I'm not that helpful, but I thought I'd try and get you started. feel free to ask questions, which I know you'll have a lot of.
User avatar
PrimordialHelios
Posts: 4
Joined: Fri Jul 29, 2016 9:11 pm

Re: Where do I start?

Post by PrimordialHelios »

Espozo wrote:
PrimordialHelios wrote:I was wondering if there were any guides that were for people who really knew absolutely nothing about the NES or asm
http://nintendoage.com/pub/faq/NA/index ... s_out.html#

This actually uses NESASM which you have, but most people, (including myself, who looked into the NES when I couldn't find anything for the SNES) think it sucks for various reasons. I don't know of any NES tutorials other than that, but you might want to look at these: The first one is the 6502 instruction set, the second is the video hardware registers for the NES, and the third is the audio hardware registers for the NES: http://www.6502.org/tutorials/6502opcodes.html, http://wiki.nesdev.com/w/index.php/PPU_registers, http://wiki.nesdev.com/w/index.php/APU_registers

I know I'm not that helpful, but I thought I'd try and get you started. feel free to ask questions, which I know you'll have a lot of.
Oh cool, thanks a lot!

What do you use if you don't like NESASM?
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Where do I start?

Post by Drew Sebastino »

Ca65 is what I use. (I program for the SNES, but it also works for the NES.) Unfortunately though, if the tutorial (Nerdy Nights) uses NESASM, then that's what you'll have to use for it, unless you know how to convert the syntax to work with Ca65. I imagine you could still look at it for core concepts though, along with the other two links (although I feel like sound is a bit too advanced to be dealing with right now.)

Unfortunately, I can't help you with finding Ca65, as I tried finding it myself but couldn't. It's largely overshadowed by Cc65, which is a compiler instead of an assembler. If you do find Ca65 though, be sure to look at some of the documentation for it, especially if you're going off the Nerdy Nights tutorial.
User avatar
dougeff
Posts: 2875
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Where do I start?

Post by dougeff »

Preferred assemblers =

ASM6

http://www.romhacking.net/utilities/674/

CA65 (part of CC65 suite)

http://cc65.github.io/cc65/

I also wrote a tutorial ( cc65 specific). The deveopers of cc65 were nice enough to change cc65 enough that none of my files will work with the newest version (I've been told...and too busy to fix). I'll have to thank them some time (/sarcasm)

You should also get FCEUX (NES emulator with debugging tools). And possibly NES Screen Tool (from Shiru's website).
Last edited by dougeff on Fri Jul 29, 2016 10:12 pm, edited 1 time in total.
nesdoug.com -- blog/tutorial on programming for the NES
lidnariq
Posts: 10677
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Where do I start?

Post by lidnariq »

Dougeff has a tutorial here.
Shiru has a tutorial here. (You'll need a newer copy of the runtime in order to compile with a newer version of cc65)
User avatar
Drew Sebastino
Formerly Espozo
Posts: 3496
Joined: Mon Sep 15, 2014 4:35 pm
Location: Richmond, Virginia

Re: Where do I start?

Post by Drew Sebastino »

dougeff wrote:CA65 (part of CC65 suite)
Oh... :lol:
User avatar
PrimordialHelios
Posts: 4
Joined: Fri Jul 29, 2016 9:11 pm

Re: Where do I start?

Post by PrimordialHelios »

Espozo wrote:Ca65 is what I use. (I program for the SNES, but it also works for the NES.) Unfortunately though, if the tutorial (Nerdy Nights) uses NESASM, then that's what you'll have to use for it, unless you know how to convert the syntax to work with Ca65. I imagine you could still look at it for core concepts though, along with the other two links (although I feel like sound is a bit too advanced to be dealing with right now.)

Unfortunately, I can't help you with finding Ca65, as I tried finding it myself but couldn't. It's largely overshadowed by Cc65, which is a compiler instead of an assembler. If you do find Ca65 though, be sure to look at some of the documentation for it, especially if you're going off the Nerdy Nights tutorial.
Funnily enough, I also cloned a cc65 git repo that also came with ca65.

Thanks for letting me know, though!
dougeff wrote:Preferred assemblers =

ASM6

http://www.romhacking.net/utilities/674/

CA65 (part of CC65 suite)

http://cc65.github.io/cc65/

I also wrote a tutorial ( cc65 specific). The deveopers of cc65 were nice enough to change cc65 enough that none of my files will work with the newest version (I've been told...and too busy to fix). I'll have to thank them some time (/sarcasm)
lidnariq wrote:Dougeff has a tutorial here.
Shiru has a tutorial here. (You'll need a newer copy of the runtime in order to compile with a newer version of cc65)
Thank you both very much!
User avatar
koitsu
Posts: 4203
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Where do I start?

Post by koitsu »

tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Where do I start?

Post by tepples »

If you're brand new to the 6502, you might want to try programming for a somewhat "friendlier" 6502-based platform before the NES. For me it was Apple IIe (I used hardware; you can use AppleWin/LinApple). For others it was Commodore 64. For you it might be Easy 6502.
User avatar
mikejmoffitt
Posts: 1352
Joined: Sun May 27, 2012 8:43 pm

Re: Where do I start?

Post by mikejmoffitt »

CA65 is part of the CC65 project. It is expected to find it there.
User avatar
tokumaru
Posts: 12106
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Where do I start?

Post by tokumaru »

What worked really well for me was to learn about 6502 and the NES separately. I analyzed a multitude of games using Nesticle's (nowadays you'd use FCEUX or Nintendulator) PPU debugging tools to understand how NES graphics worked, editing things in real time to understand how everything was tied together.

In addition to that, I used a good 6502 simulator to test my understanding of each 6502 instruction. I'd step through the code and watch how flags and registers were modified after each instruction. Then I was confident enough to code some actual routines, to make sure I could use my knowledge of the instructions to write actual, useful logic. I wrote routines for multiplicating, dividing, that kind of thing.

Finally, I tried to combine things by making simple NES programs to draw backgrounds and sprites, using NES documentation to know how to populate the video memory to get the desired results. Adding logic and movement to these programs wasn't hard, because I had some previous game programming experience from my QBASIC days.

As for which assembler to use, ASM6 has always been a favorite of mine for its simplicity. It's as simple as NESASM to use, but has less quirks. I became a big fan of ca65 recently, though. It's a bit complex to set up (if you want to be in total control, as opposed to building on top of someone else's template), but once you understand how it works, it's features are unparalleled, and you can do a lot of cool automation that's not possible with other assemblers.
User avatar
DRW
Posts: 2070
Joined: Sat Sep 07, 2013 2:59 pm

Re: Where do I start?

Post by DRW »

lidnariq wrote:Dougeff has a tutorial here.
Shiru has a tutorial here. (You'll need a newer copy of the runtime in order to compile with a newer version of cc65)
What's the deal with that runtime by Shiru? I still don't get it. As far as I understand, those are a subset of the generic functions, recompiled into a new file.

But why should anybody ever use this? Just add -t nes to your compile command and be done with it. No fiddling around with different versions, nothing.

I mean, who cares how much stuff is in the "nes.cfg"? The compiler will only include the functions that are needed anyway.

For a test, I replaced the original "nes.lib" (604 KB) with shiru's "runtime.lib" (108 KB), renaming it to "nes.lib" as well. Then I compiled the code for my game once with shiru's lib and once with the original lib. Guess what: The ROM is the exact same output file in both cases.
(In case anybody is wondering why there were no compatibility errors: I used CC65 2.13.3 for this test.)

So, why exactly is Shiru's "runtime.lib" a file that has any purpose whatsoever, so that it needs to be referenced when listing hints for a beginner?
Why did shiru create it in the first place and why should anybody ever use it?
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg
na_th_an
Posts: 558
Joined: Mon May 27, 2013 9:40 am

Re: Where do I start?

Post by na_th_an »

This is needed 'cause latest cc65 versions (2.15) are not compatible with the old .lib file format, I seem to recall, and there was something inside the .lib or whatever, I don't know. Or maybe Shiru just had the stripped set of cc65 executables and the stripped down runtime.lib was included for space reasons. You can always ask him :D

You can use the linked assets with the latest cc65 snapshot (2.15 whatever).
Attachments
neslib.zip
Neslib for cc65 2.15 snapshots
(69.31 KiB) Downloaded 81 times
User avatar
DRW
Posts: 2070
Joined: Sat Sep 07, 2013 2:59 pm

Re: Where do I start?

Post by DRW »

na_th_an wrote:This is needed 'cause latest cc65 versions (2.15) are not compatible with the old .lib file format, I seem to recall, and there was something inside the .lib or whatever, I don't know.
This doesn't really make sense to me: If there are incompatibilities, then shiru's file would be the one that potentially doesn't work anymore (since it was compiled years ago). The CC65 compiler suite always has the correct file that belongs to its own specific version. I mean, it's not like CC65's own "nes.lib" doesn't work on itself anymore.
So, my question still stands: Why should anybody ever use a separately compiled "runtime.lib" by someone else instead of linking the "nes.lib" that comes with the compiler itself?
na_th_an wrote:Or maybe Shiru just had the stripped set of cc65 executables and the stripped down runtime.lib was included for space reasons.
Huh? What do you mean with "stripped set of cc65 executables"?

And space reasons:
If you're referring to the space on your computer's hard disk: I'm pretty sure 500 additional KB are a non-issue in the year 2016.
If you're referring to the occupied space in the NES ROM: As I said, using Shiru's lib produces exactly the same output. So, it's not like the 600 KB "nes.lib" actually puts 600 KB of data into your NES ROM while shiru's "runtime.lib" only includes 100 KB.
Available now: My game "City Trouble".
Website: https://megacatstudios.com/products/city-trouble
Trailer: https://youtu.be/IYXpP59qSxA
Gameplay: https://youtu.be/Eee0yurkIW4
German Retro Gamer article: http://i67.tinypic.com/345o108.jpg
Post Reply