It is currently Sun Dec 17, 2017 8:36 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 46 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Sun Mar 26, 2017 2:56 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
I recently saw someone elses (very small) example code of C for cc65 for NES... they did things in a way that the user, basically, doesn't need to understand anything under the hood. Hiding 2006/2007 writes in hidden function definitions, for example.

Personally, I like to understand everything that is going on, but I suppose a casual user, who just wants to make a simple game, might prefer to know nothing about the inner workings of the PPU.

This seems to me, to be a more modern approach. The library takes care of technical details, the programmer can focus on the game.

Thoughts?

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Sun Mar 26, 2017 4:21 pm 
Offline

Joined: Tue May 28, 2013 5:49 am
Posts: 934
Location: Sweden
Personally I'm with you that I don't want to include anything I don't fully understand, so I think it's good if both types of tutorials are out there. I prefer to at least know how the code I'm using works, so no libraries, but I don't need to know every little hardware detail under the hood (although I try to learn that too to a degree).

However, although a tutorial that explains everything, doesn't need explain everything the moment they are introduced, as long as it tells the reader that it is something necessary that will be explained later.
For example the Nerdy Nights doesn't explain the init code, leaving the reader wondering why there's suddenly extra code in the source file that the tutorial didn't mention and even seems to contradict what it said.


Top
 Profile  
 
PostPosted: Mon Mar 27, 2017 10:45 am 
Offline

Joined: Tue Jul 12, 2011 10:58 am
Posts: 265
I stick to higher level languages because it allows me to focus on game logic and prototyping ideas easily.

I kinda failed to even get a basic program working in NESICIDE. So, hardware details are nice but a distant priority/motivator.


Top
 Profile  
 
PostPosted: Tue Mar 28, 2017 5:05 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
Thanks for the replies.

This was the example code I saw, that made me think I could have made it MUCH easier...

https://github.com/algofoogle/nes-gamed ... ello-nes.c

Especially lines like this...

Code:
/* Write a byte to a given address: */
#define poke(addr, data)        (*((unsigned char*)addr) = data)

/* Write a pair of bytes to the PPU VRAM Address 2. */
#define ppu_2(a, b)             { poke(PPU_VRAM_ADDR2, a); poke(PPU_VRAM_ADDR2, b); }


I wouldn't use this 'poke' stuff, but it's interesting. I was thinking of something like set_ppu_address (x,y) where the definition somehow converts the x,y coordinates AT COMPILE TIME into writes to $2006.

The user would then only have to use set_ppu_address() and never worry about PPU addresses.

Or, perhaps, everything should be buffered, and written during V-blank. So people won't have to worry about timing things, just an automated system, that buffers all writes, and auto-writes it during NMI routine.

Hmm.

Edit, actually, the very next line of code above...

#define ppu_set_cursor(x, y) ppu_2(0x20+((y)>>3), ((y)<<5)+(x))

Would do what I said.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Last edited by dougeff on Tue Mar 28, 2017 5:26 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Tue Mar 28, 2017 5:13 pm 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 130
dougeff wrote:
I wouldn't use this 'poke' stuff, but it's interesting. I was thinking of something like set_ppu_address (x,y) where the definition somehow converts the x,y coordinates AT COMPILE TIME into writes to $2006.


Every neslib I've seen has used NTADR to do this:

https://github.com/jmk/cc65-nes-example ... mple1.c#L9

I like to use PPU_DATA and PPU_ADDR in my C projects to simplify memory-mapped registers:

https://github.com/dustmop/annotatecc65 ... e/common.h

In general, macros are dangerous, but can be super useful for readability if used carefully.


Top
 Profile  
 
PostPosted: Tue Mar 28, 2017 5:29 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
It's cool that you can highlight specific lines on github with a #L

I'm learning lots today :D

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Mar 28, 2017 5:37 pm 
Offline
User avatar

Joined: Wed Oct 16, 2013 7:55 am
Posts: 130
If you click on the line-numbers on the left-side of the code display, it sends your browser to the line-highlighted link. No need to memorize the anchor or anything!


Top
 Profile  
 
PostPosted: Tue Mar 28, 2017 5:47 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
I was very reluctant to use Shiru's neslib in my example code. For one thing, I'm not sure I understand it 100% fully. Another thing. I'm pretty sure Shiru hates me. A lot.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Wed Mar 29, 2017 2:38 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 363
Neslib is pretty straightforward, is well built, simple, barebones, yet it manages to conceal all the fiddly stuff. But it's there anyways and easily modifiable if you know what you are doing. So it was great for my beginnings and also great now that I have a proper understanding of the system. So easily tweakable. I like it.

I think it's great for beginners 'cause it solves all the fiddly stuff, and still great for intermediates and advanced coders, 'cause the fiddly stuff is easily modifiable. It was pretty straightforward to make it work in UNROM, MMC1 and MMC3, for example.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Mon Apr 03, 2017 7:42 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
dustmop wrote:
dougeff wrote:
I wouldn't use this 'poke' stuff, but it's interesting. I was thinking of something like set_ppu_address (x,y) where the definition somehow converts the x,y coordinates AT COMPILE TIME into writes to $2006.


Every neslib I've seen has used NTADR to do this:

https://github.com/jmk/cc65-nes-example ... mple1.c#L9

I like to use PPU_DATA and PPU_ADDR in my C projects to simplify memory-mapped registers:

https://github.com/dustmop/annotatecc65 ... e/common.h

In general, macros are dangerous, but can be super useful for readability if used carefully.


The 'cc65-nes-examples' github you linked to is an outdated version. The newer version is from 2015. It has more example code and a completely different neslib.s

Interestingly...the neslib.s from the 2015 examples is different from the example in Chase and different from other Shiru source code (Zooming secretary)

EDIT - I think the newest examples uses the same as the newest Chase source neslib.s, and I think that is what dustmop and na_th_an are using. Nevermind.


Na_th_an / dustmop, which version of neslib.s do you use? It seems that Chase is the most recent version.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Tue Apr 04, 2017 4:56 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 363
My base version comes from this revised version repackaged for the "new" cc65 (current active branch) by lidnariq.

Calima maintains an enhaced version with some fixes.

My own UNROM version is here. I have created simple MMC1 and MMC3 versions but haven't released them yet.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Thu Apr 06, 2017 10:53 am 
Offline

Joined: Fri Dec 27, 2013 4:28 pm
Posts: 54
I'm definitely a fan of having the little details in there. I like what I've seen of your tutorials, (disclaimer: I haven't read all that much) because of those nitty-gritty details. I may be biased due to already using 6502 assembly a lot, however.

At the same time, neslib is awesome, and makes working in C a bit more enjoyable. Neslib made it much easier to bootstrap some examples of my most recent project. It also made those examples more readable - at least as far as using my library goes, as I was able to abstract the system details away.

It seems to me like there's room on the internet and a use for both. I guess it's a question of which experience you want to provide - quickly bootstrapping a working NES game, or giving the user the tools to understand and tinker with everything going on in their game.

This is admittedly not a fully-formed thought - could you do some sort of a hybrid approach, where you use neslib, but also have info boxes that explain the macros/etc for anyone that's inclined to read them? Or maybe even just links to the source for where to see things?


Unrelated note, I didn't realize how many people already had neslib-based bootstrap repos. I'm partway through making an mmc1 example for myself. (Mainly want to use it for ludum dare in a couple weeks) I still probably will, but nice to see more examples coming out. It gives people options for getting started. For example, my typical setup involves using makefiles, a lot of integration with vs code, and automatic circleci builds/releases of every pushed commit. (I only recently figured that last one out; check out my nesnet project if you want an example!) I can see people wanting something simpler or just different.


Top
 Profile  
 
PostPosted: Thu Apr 06, 2017 9:37 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 1870
Location: DIGDUG
This gentleman has the newer example code (Shiru) on his github

https://github.com/peterhellberg/nesdev ... s_examples

Also found source code for SplatooD, which uses neslib / cc65.

https://github.com/SplatooD/splatood


Quote:
hybrid approach, where you use neslib


I might try to use a modified (expanded) version of neslib. Now that I've looked into it, I do think I understand it 99%. Some of the functions could be changed a bit. I'm not a fan of the current controller read functions, for example.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
PostPosted: Fri Apr 07, 2017 2:14 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 363
As for the main topic, I appreciate that you get low in the mud in the tutorials from your site. They have been quite helpful for me, specially undestanding how scrolling works in a lower level (neslib hides this) or understanding MMC3's IRQs.

_________________
http://www.mojontwins.com


Top
 Profile  
 
PostPosted: Fri Apr 07, 2017 1:53 pm 
Offline
User avatar

Joined: Sat Jan 09, 2016 9:21 pm
Posts: 264
Location: Central Illinois, USA
dougeff wrote:
This gentleman has the newer example code (Shiru) on his github

https://github.com/peterhellberg/nesdev ... s_examples

Also found source code for SplatooD, which uses neslib / cc65.

https://github.com/SplatooD/splatood



Just promise us that you won't put global data in .h files like these examples do :shock:

_________________
My games: http://www.bitethechili.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 46 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group