NES Programming Blog

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

NES Programming Blog

Post by dougeff »

If you search for tutorials on how to program the NES in C, the examples either aren't very clear, or contain poor examples of programming the NES.

Well, you can include my tutorial / blog to that list.

https://nesdoug.wordpress.com/

This was the super top-secret other project that I've been working on for a month. It has lots of example code for programming the NES in cc65.

And, a tiny example game (vertical space shooter).

If anyone sees any factual errors, or broken links, unclear code, or just plain bad advice...please let me know. I'm hoping that someone out there can use this to get started on NES game development.

Thanks.
nesdoug.com -- blog/tutorial on programming for the NES
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NES Programming Blog

Post by lidnariq »

One thing that I found really nice in thefox's KNES is this macro:

Code: Select all

#define PPU_ADDR(a)                             \
do {                                            \
    PPU.addr = HIBYTE( a );                     \
    PPU.addr = LOBYTE( a );                     \
} while ( 0 )
Proofreading, there's several apostrophe mistakes.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: NES Programming Blog

Post by dougeff »

apostrophe mistakes
.

Huh?
nesdoug.com -- blog/tutorial on programming for the NES
lidnariq
Posts: 11430
Joined: Sun Apr 13, 2008 11:12 am

Re: NES Programming Blog

Post by lidnariq »

Apostrophes:
Post 0, paragraph 11, "mirroring) it’s map" → its (is possessive, not a contraction)
Post 10, paragraph 8, "referenced it's address" → its
Post 10, paragraph 17, "for it’s collision" → its
Post 13, paragraph 3, "the other one’s." → ones (is plural, not possessive nor a contraction)
Post 13, paragraph 13, "with it’s logic" → its
ccovell
Posts: 1045
Joined: Sun Mar 19, 2006 9:44 pm
Location: Japan
Contact:

Re: NES Programming Blog

Post by ccovell »

Image

( http://blog.writeathome.com/index.php/2 ... -teachers/ )

Anyway, of what I read so far, it looks like you explain the NES architecture in a very clear, simple way.
User avatar
splitpane
Posts: 11
Joined: Mon Nov 23, 2015 7:53 pm

Re: NES Programming Blog

Post by splitpane »

Thanks for the tutorial! I will check it out.
User avatar
dustmop
Posts: 136
Joined: Wed Oct 16, 2013 7:55 am

Re: NES Programming Blog

Post by dustmop »

I'd recommend mentioning in "Getting Started" that this is geared towards Windows development. It becomes evident pretty quickly, but this could be a stumbling block for beginners.

Have only skimmed over this so far, but it looks pretty neat! Looking forward to reading the whole thing in depth.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: NES Programming Blog

Post by dougeff »

That's so weird...

I have a little Stats menu on my blog, and I got like 9000 views yesterday, most from a referral on Reddit by zeroone. Those are almost monetizable numbers... (according to some website, if that traffic was sustainable, I could make $20 a day, or $7-8000 a year off ad revenue.)

My most popular YouTube video only got like 100 views all year.

Actually, that's almost enough to get my dropbox account suspended. Google tells me there's a 10gb bandwidth per day limit on public downloads from a free dropbox account. Hmm.
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: NES Programming Blog

Post by zeroone »

@dougeff Awesome stuff. Blogs like this tend to be the catalyst for future projects.
User avatar
dougeff
Posts: 3078
Joined: Fri May 08, 2015 7:17 pm

Re: NES Programming Blog

Post by dougeff »

Wow, they really tore me a new one over at Reddit (ie, didn't like the way I write code.)

https://www.reddit.com/r/programming/co ... game_in_c/

Should I edit the hell out of my example code (to make it look pretty) and add a hundred comments? I don't even know what all these things mean...

"no grouping of globals), no arrays for groups of bullets (he instead has Bullet1x,Bullet1y, Bullet2x, Bullet2y, etc.), no structs, CamelCase, magic number galore, repeated code due to the Something1...SomethingN convention, commented-out code"

What the heck is a CamelCase?
Magic numbers...I get that, I should replace with constants that describe what they are.
Commented-out code...because it was redundant, or a removed debugging element.

And, I don't know why, but some other website on cc65 (??) said 'don't use structs'...so I didn't.
Grouping of globals...they look ok to me. Am I missing something?
nesdoug.com -- blog/tutorial on programming for the NES
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NES Programming Blog

Post by tepples »

You appear to be referring to the comment by _georgesim_.

CamelCase is "HelloWorld" as opposed to something like "hello_world". Different people prefer different styles. CamelCase has the connotation that you're trying to be object-oriented.

"Arrays for groups of bullets" would have been something like this:

Code: Select all

BulletX: .res MAX_BULLETS
BulletY: .res MAX_BULLETS
BulletDX: .res MAX_BULLETS
BulletDY: .res MAX_BULLETS
That at least allows efficient indexing. I explained why structs are dispreferred on 6502.
Celius
Posts: 2158
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Re: NES Programming Blog

Post by Celius »

Most programming stuff I've seen has used the convention of camelCase instead of CamelCase.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NES Programming Blog

Post by rainwarrior »

dougeff wrote:What the heck is a CamelCase?
If someone wants to pick an argument about an arbitrary naming convention like CamelCase, camelCase, underscores, or however you've chosen to do it, I would highly recommend that you ignore them. There is very little productive argument to be had about this. It's generally just a foolish waste of time.

As long as you're consistent with your conventions, it's probably fine.
Celius
Posts: 2158
Joined: Sun Jun 05, 2005 2:04 pm
Location: Minneapolis, Minnesota, United States
Contact:

Re: NES Programming Blog

Post by Celius »

As long as you're consistent with your conventions, it's probably fine.
I would agree with this. Putting multiple conventions together causes confusion and often causes one to doubt whether or not they understand what they're looking at. Camel case isn't really any better or worse than other naming conventions (I personally use a lot of dot notation for things); just as long as it's clear what it means, and is consistent with how other things are named.
User avatar
mikejmoffitt
Posts: 1353
Joined: Sun May 27, 2012 8:43 pm

Re: NES Programming Blog

Post by mikejmoffitt »

Your blog made front-page on Hacker News!

Do you have any plans on discussing PRG bankswitching techniques from a C context?
Post Reply