NES and $4017

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

Post Reply
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

NES and $4017

Post by charliee1151 »

Hi all:
Got a bit of confusion regarding NES address $4017.

I've made a nice horizontal scrolling prog, with parallax (distant objects scroll slowly, closer objects scroll, well..fastly?), and Sprite 0 hit to allow a static status bar at the bottom.

All works well, and I of course had to study-up on how to use the joystick, including the use of the $4016/$4017 combo.

Then I look at the APU to learn sound, and I see the use of...gasp!...$4017 (frame counter). OK, so I know that there is only one $4017 address, so I assume that the hardware at this address does BOTH the joystick and sound?

But no documentation I have found says the equivalent of "do THIS to use the joystick, but use THAT to use sound".

So, assuming I am not going bonkers and it IS the same $4017, are there any docs that actually indicate the dual usage of this address? (and why not? - wouldn't someone accessing that hardware want the specs on ALL its' functionality?) Or is it expected that you simply read the appropriate doc for joystick, and the other appropriate doc for sound?

Or am I totally off base?

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

Re: NES and $4017

Post by tepples »

Read and write to the same MMIO port often do unrelated things. $4016 read and write and $4017 read are related to controllers. $4017 write is related to the APU frame counter. But a lot of music engines don't use the APU frame counter except to disable it because they don't use hardware envelope, pitch bends, or length counter. If anything, writing to the APU frame counter is most useful for an obscure trick related to smoothing out pitch bends and vibrato around A (NTSC) or A♭ (PAL).
charliee1151
Posts: 22
Joined: Mon Dec 26, 2016 8:58 am

Re: NES and $4017

Post by charliee1151 »

Ok that certainly makes sense. It's just that I'm so used to working/thinking at the chip level (hardware engineer here), that I was unsure how the NES hardware would be explained based on the higher system-level thinking.

(Back with more later , I'm sure)

Thanks
Charlie
Post Reply