Getting started again!! Romhacker to NES Game Programmer

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

User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by DRW »

Kasumi wrote:I'm not sure we're reading the same things. That's what everyone is saying!
I guess I misunderstood this one:
dougeff wrote:IF your game logic goes longer than 1 frame, the logic will miss a change in button presses event.
[...]
Have a flag for when the game logic is done, and only check buttons if it is set, or something like that.
The first statement sounded like the following to me:
"The logic might miss a button press if it goes longer than one frame [therefore don't use the controller reading in the game logic but in NMI because then you will never miss controller updates]."

And the second sentence and its talking about a flag sounded like proposing NMI as well. Because when you have controller readings in the game logic anyway, then you don't need any flag specifically for the controller. If you're in the game logic, it's time to update the controller, end.
But the NMI is an interrupt, so controller reading in NMI might require a flag to decide if the controller values should be updated or ignored, based on outside conditions.

That's where I got the idea that this post suggested moving the controller reading to NMI.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by Kasumi »

I don't think you misunderstood that post. He was suggesting a way to fix the problem, as you were.

For what it's worth: My reply with the "jump miss" example was only because I wasn't sure you saw that case. Because you did ask. You asked why it could be a problem, and I answered with that.

I wasn't trying to say, "You can't fix this." or "This can't be fixed", just "This is the case people are talking about."
User avatar
DRW
Posts: 2225
Joined: Sat Sep 07, 2013 2:59 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by DRW »

Yeah, I guess I understood it incorrectly. But we can summarize:

Controller reading in game logic: No problem.

Controller reading in NMI: No problem and no overhead either.
You need a check to prematurely exit the NMI anyway. So, you just put the controller reading after that check. No need for any flags, other than the general one that you need in NMI to begin with.
My game "City Trouble":
Gameplay video: https://youtu.be/Eee0yurkIW4
Download (ROM, manual, artworks): http://www.denny-r-walter.de/city.html
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Getting started again!! Romhacker to NES Game Programmer

Post by tepples »

One reason you might want to read the controller in NMI is if you're using even number of cycles since OAM upload as a means of DMC glitch avoidance, as Rahsennor discovered. Perhaps use the "is a new sprite list ready" flag as a signal for whether the main thread is ready to accept a new set of keypresses.
User avatar
Kasumi
Posts: 1293
Joined: Wed Apr 02, 2008 2:09 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by Kasumi »

thefox: There's this thing: viewtopic.php?f=22&t=14532&hilit=buttons

Edit: I guess you might have meant one that measures times less than a frame.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Getting started again!! Romhacker to NES Game Programmer

Post by tokumaru »

If you have to read the controllers in the NMI because of DMC or whatever, you can save the result to a temporary location, and have the main loop read this location instead of using the hardware registers. The main loop would still be responsible for calculating holds, releases, etc., the NMI code would just abstract the hardware part.
User avatar
dougeff
Posts: 3079
Joined: Fri May 08, 2015 7:17 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by dougeff »

One game (maybe Silver Surfer) rolls each button into a different address, so it can tell how many frames a button has been pressed, up to 8 frames.
Not pressed = 00000000
First frame = 00000001
Then = 00000011
00000111
00001111
00011111
00111111
01111111
11111111
Stays like that till button released...

11111110
11111100
11111000
Etc, back to zero
nesdoug.com -- blog/tutorial on programming for the NES
User avatar
rainwarrior
Posts: 8735
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: Getting started again!! Romhacker to NES Game Programmer

Post by rainwarrior »

thefox wrote:Has anybody done measurements on what is a typical minimum "pulse width" on button presses (or releases) that one can expect? That is, if a player quickly taps the button. Or, holds it down, quickly releases it and then holds it down again.

I guess I might throw together a small test ROM for it.
I seem to recall reading a study on button pressing a while back (can't remember the source, sorry), and I think something like 10 (edit: 16?) times per second was the upper limit for human rapid fire.

As for whether people can generate single frame input, you can if you try. A normal "tap" is going to be a few frames, but it's not hard to do a glancing tap of the button that only connects very briefly.
Last edited by rainwarrior on Sat Aug 27, 2016 1:38 pm, edited 1 time in total.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Getting started again!! Romhacker to NES Game Programmer

Post by tepples »

I think I can do about 14 on a standard controller. I can make a video if you want.
hackfresh
Posts: 101
Joined: Sun May 03, 2015 8:19 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by hackfresh »

It depends on how long you sample the input for. I made a hack for Tecmo Super Bowl that displays the number of taps when two (man controlled) players collide.

The game takes 64 frames worth of input (~ one second). The fastest tappers in our community hit about 16 on average. But in any one sample it ranges ~ +/-10%.

So a guy who averages 16 could have a high of 18 and a low of 14.
User avatar
Myask
Posts: 965
Joined: Sat Jul 12, 2014 3:04 pm

Re: Getting started again!! Romhacker to NES Game Programmer

Post by Myask »

That's 6.66…% more than a second. How many buttons does Tecmo Super Bowl sample?

Mario Party 4's "Domination" minigame does a ten-second sample of A. It also, apparently, caps out at 160, possibly a subtle nod to Takahashi.

I can(could?) do ~14 as well, one-button.
Post Reply