It is currently Tue Nov 13, 2018 8:36 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Oct 30, 2018 7:44 am 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 141
Location: Colorado
Thanks for your help Doug

dougeff wrote:
EDIT2 - yes. Your title / pre-game code checks for the Start button about 3-4 frames before the Lives / Score and Sprite Zero collision tile are loaded.


So the sprite0 check is not supposed to happen on the open screen. I have a flag called open_screen_active that should be set at the end of the reset code to '1'. If the value is 1 it should skip the sprite0 code. If I go into the Mesen menu and tell it to reset from there, everything works fine. The flag is set, and there is no sprite0 check on the open screen (as it should be).

If I use the start button on game over to call the reset, for some reason that flag is not set to 1, but is 0 so the sprite0 code runs.

If I put a debug break point in the start button press and step through it with the debugger, everything works fine and the flag is set as it's supposed to be.

Not that I'm typing this out, I wonder if I'm calling that start button code more than once and therefore calling the reset multiple times in a row. Will need to investigate.


dougeff wrote:
On a side note. You might want to make the "lives" lower on the screen. Old CRT TVs will tend to cut off some of those pixels. See the "overscan" entry in the wiki.


I might do that. This is more of a personal research project and I'm not super concerned about the game running on old CRTs. I'm not sure anyone will actually be playing it on an old CRT, but I'll see what I can do.

Thanks again,
Rick

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
PostPosted: Tue Oct 30, 2018 9:00 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2329
Location: DIGDUG
You're missing the point. The problem is you are doing things out of order. Although it is unlikely that the user will be holding the start button down at exactly the power on moment... if it crashes the game, it needs fixed, especially now that you restart the game by jumping to reset.

Either load the BG tiles as soon as possible, before buttons are ever read, ...or disable button presses until those tiles are loaded.

Or you could make Pressing Start the trigger to load the BG tiles in place, and disable Sprite zero hits until that is done.

The reason it doesn't happen during debugging is because it's difficult to hold down the Start button while you step through the game in a debugger.

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


Top
 Profile  
 
PostPosted: Tue Oct 30, 2018 9:30 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20761
Location: NE Indiana, USA (NTSC)
And if all else fails, yet another way to avoid a freeze is to make the sprite 0 waiting loop resilient to failure, where you get a momentary graphical glitch instead.
Code:
s0offloop:
  bit $2002
  bvs s0offloop

  ; Now wait for either sprite 0 or vblank
  lda #$C0
s0onloop:
  bit $2002
  beq s0onloop
  bmi vblank_was_hit_instead


Top
 Profile  
 
PostPosted: Tue Oct 30, 2018 10:32 am 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 141
Location: Colorado
dougeff wrote:
Either load the BG tiles as soon as possible, before buttons are ever read, ...or disable button presses until those tiles are loaded.


Thanks Doug.

I fixed the issue, although not quite how you indicated. Basically I started pulling code out of the reset into a subroutine and called that from the start button press. This way I was able to move things in and out until the system either didn't clear everything I needed it to, or broke. I think part of the problem was that I was clearing all of memory and flags were getting overwritten at the wrong time.

Out of curiosity, how do you disable button presses? Can you do something to $4016 to disable the gamepad?

Thanks

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
PostPosted: Tue Oct 30, 2018 10:46 am 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10959
Location: Rio de Janeiro - Brazil
battagline wrote:
Can you do something to $4016 to disable the gamepad?

No, you just ignore any input in the game logic.


Top
 Profile  
 
PostPosted: Tue Oct 30, 2018 11:00 am 
Offline
User avatar

Joined: Wed Sep 05, 2018 11:13 am
Posts: 141
Location: Colorado
tokumaru wrote:
No, you just ignore any input in the game logic.


In the future I should probably have a reset_complete flag that gets set to 1 after the reset finishes. I could probably key off of that for all the things that may run when they shouldn't during the reset.

Thanks

_________________
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com


Top
 Profile  
 
PostPosted: Tue Oct 30, 2018 5:31 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2035
Location: Fukuoka, Japan
Good to hear you found it.

So it was a sprite 0 bug. I would have never guessed by debugging (I did check a little bit) since I never programmed one but I kind of knew it was something timing related since debugging caused it to make it work fine, somehow.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: NOOPr and 4 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