Reset problems and Schrodinger's cat
Moderator: Moderators
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Reset problems and Schrodinger's cat
I'm having a kind of Schrodinger's cat problem with my reset. I have a value that is getting set when the game loads up but doesn't get set when I hit reset. However, if I step through the reset in the Mesen debugger, it gets set and everything works fine.
Any ideas why that would happen?
Thanks
Any ideas why that would happen?
Thanks
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
Re: Reset problems and Schrodinger's cat
In mesen?reset
Soft reset (reset button) or hard reset (power off and on)?
Do you have "Default power on state for RAM = random" set in Advanced settings?
nesdoug.com -- blog/tutorial on programming for the NES
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
Yes, in Mesendougeff wrote: In mesen?
Soft reset through the menu. Hard reset (reloading the file) seems to work fine.dougeff wrote: Soft reset (reset button) or hard reset (power off and on)?
In Advanced settings I see "Start game from power on instead of resuming the previous gameplay session", but I'm not sure that's the setting your talking about.dougeff wrote: Do you have "Default power on state for RAM = random" set in Advanced settings?
Thanks for your help
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
I found that setting you were talking about in Emulation. My background gets random tiles dumped into it (thought I was clearing the background but I guess not). That doesn't give me the other problem though
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
Re: Reset problems and Schrodinger's cat
No, but that could be a clue that something at startup isn't behaving like you think.
Maybe something isn't getting zeroed, or maybe you aren't waiting enough vblanks before writing to PPU.
Code or .nes file would help.
Maybe something isn't getting zeroed, or maybe you aren't waiting enough vblanks before writing to PPU.
Code or .nes file would help.
nesdoug.com -- blog/tutorial on programming for the NES
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
Ok, I'm no longer having an issue with the reset (I don't think). I am having a problem when I try to force a reset when the game is over. I added adougeff wrote:No, but that could be a clue that something at startup isn't behaving like you think.
Maybe something isn't getting zeroed, or maybe you aren't waiting enough vblanks before writing to PPU.
Code or .nes file would help.
Code: Select all
jmp reset
I'm attaching the game and the mesen dbg file.
Thanks for your help Doug
- Attachments
-
- nesteroids.nes
- ROM File
- (40.02 KiB) Downloaded 144 times
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
I had to rename the .dbg file with a .txt extension for some reason
- Attachments
-
- nesteroids.nes.dbg.txt
- Had to rename this with a .txt extension
- (449.7 KiB) Downloaded 142 times
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
The procedure that calls the reset is "press_start"
Basically I'm trying to trigger a reset when the game is over and the player hits start. I do this with a jmp. I'm not sure if there's a different way to do this, but a soft reset seems to be working now. Now I'm just having an issue triggering the reset from the game over screen
Code: Select all
.proc press_start
lda PRESS_START
and gamepad_press
beq skip_press_start
advance_random_ptr ; advance the random pointer based on the frame
lda start_delay
bne skip_press_start
lda open_screen_active
beq dont_start
lda #0
sta open_screen_active
jsr start_game
lda #30
sta start_delay
jmp start_end
dont_start:
lda game_over_active
beq dont_reset
lda #30
sta start_delay
lda #0
sta PPU_CTRL
set nmi_ready, #1 ; I ADDED THIS RECENTLY TO DISABLE THE NMI (IN CASE THAT WAS THE PROBLEM)
jmp reset ; THIS WORKS IF I START DEBUGGING FROM HERE
dont_reset:
; THE START BUTTON IS PRESSED
; start button action
jmp start_end
skip_press_start:
; if the start is not pressed
start_end:
rts
.endproc
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
Re: Reset problems and Schrodinger's cat
I'm just guessing here:
before the reset, you set the PPUCTRL to 0, which disable the NMI. If you had some NMI code that had to be done then it may have stopped processed the thing you were waiting for, like a flag that waits for nmi to continue or things like that.
before the reset, you set the PPUCTRL to 0, which disable the NMI. If you had some NMI code that had to be done then it may have stopped processed the thing you were waiting for, like a flag that waits for nmi to continue or things like that.
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
Thanks for getting back to me.Banshaku wrote:I'm just guessing here:
before the reset, you set the PPUCTRL to 0, which disable the NMI. If you had some NMI code that had to be done then it may have stopped processed the thing you were waiting for, like a flag that waits for nmi to continue or things like that.
I don't think that's the issue because initially I didn't have that in there and it was happening. I added that because at first I thought the NMI was coming in and clobbering things or possibly doing something in a half baked state. It didn't fix anything so I'll try it again without the PPUCTRL stuff. Maybe some other changes I made would have fixed it if I hadn't added that code in.
Anyway, I'll give it a quick try just in case.
Thanks again
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
Re: Reset problems and Schrodinger's cat
It's is sometime hard to find a issue without looking a the complete code (reset etc) and the only thing that can be done in that case is give opinion on what could be going wrong.
The currently shown code doesn't seems to do anything strange, so calling the "reset", if it is the same one as the one when pressing the reset button, should have restarted it properly. This means there is a good chance that something is going on in the reset code that causes it to freeze. A good guess would be that it is something state related, like a state that occurs when a variable has not been reset properly and cause the game to do something it was not supposed to.
You should review your reset code for such state.
The currently shown code doesn't seems to do anything strange, so calling the "reset", if it is the same one as the one when pressing the reset button, should have restarted it properly. This means there is a good chance that something is going on in the reset code that causes it to freeze. A good guess would be that it is something state related, like a state that occurs when a variable has not been reset properly and cause the game to do something it was not supposed to.
You should review your reset code for such state.
- battagline
- Posts: 152
- Joined: Wed Sep 05, 2018 11:13 am
- Location: Colorado
- Contact:
Re: Reset problems and Schrodinger's cat
I'm not sure my code is in a great state for a review right now. The problem seems to be a value in a flag "open_screen_active" that should be getting set at the end of my reset isn't getting set for some reason. However, if I step through the code with the debugger to see why it isn't getting set, it magically gets set and everything works just fine.Banshaku wrote:It's is sometime hard to find a issue without looking a the complete code (reset etc) and the only thing that can be done in that case is give opinion on what could be going wrong.
The currently shown code doesn't seems to do anything strange, so calling the "reset", if it is the same one as the one when pressing the reset button, should have restarted it properly. This means there is a good chance that something is going on in the reset code that causes it to freeze. A good guess would be that it is something state related, like a state that occurs when a variable has not been reset properly and cause the game to do something it was not supposed to.
You should review your reset code for such state.
I was wondering if doing a jmp reset needs to do something else to make it work. Do I need to do something to clear out the stack? Or does the ldx #$ff and txs near the beginning of my reset work the same if I'm jumping to that code as it would if I hit the reset through the menu system? Since I'm doing the jmp from within a procedure, do I need to worry about it jumping back to the calling procedure when the reset is complete?
I'm mostly looking for some ideas of things to look in to. This has been helpful so far because it's given me some new areas to explore. Unfortunately none of them have been the problem yet.
Is it normal to try and reset the game back to the main menu using a jmp to reset on the game over screen? Or is that a strange thing to do and perhaps I should try a different method of restarting the game?
Thanks for your help
A few of my web games
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
https://www.embed.com
Or if you're bored at work
https://www.classicsolitaire.com
Re: Reset problems and Schrodinger's cat
I can't test at the moment since i don't have access to a computer, but if NMI was causing the problem, it's possible that the code was executing with a different timing due to the debugger being opened? A good way to check would be to use the trace logger and compare both executions to see where they differ (ppu cycle and scanline,etc.) and confirm if NMI had something to do with it.
In general though, the debugger should never affect the execution of the game (if it does, that's a bug)
In general though, the debugger should never affect the execution of the game (if it does, that's a bug)
Re: Reset problems and Schrodinger's cat
@battagline
Well, jumping from that part of code to reset, if the stack is reset properly should be fine. As for reset is the "right" way, it may be a matter of preference. I personally prefer to use reset when the machine is powered or reset is pressed. That code just prepare the machine initial state, special settings for mapper etc.
Once this is done, I enter my main loop which decide what to do next. In your case the main loop would "jsr" to the start state and once the "playing" look is over, it would return to the main loop, reset some state and wait what to do next.
Everything is suggestive, there is no best way, just what is easier for you to manage.
Well, jumping from that part of code to reset, if the stack is reset properly should be fine. As for reset is the "right" way, it may be a matter of preference. I personally prefer to use reset when the machine is powered or reset is pressed. That code just prepare the machine initial state, special settings for mapper etc.
Once this is done, I enter my main loop which decide what to do next. In your case the main loop would "jsr" to the start state and once the "playing" look is over, it would return to the main loop, reset some state and wait what to do next.
Everything is suggestive, there is no best way, just what is easier for you to manage.
Re: Reset problems and Schrodinger's cat
I had a chance to look at it.
The problem happens when you are holding down the start button while the game is reset. It seems you are checking the start button before something critical is done. (not exactly sure what that 'something' is).
It crashes on a sprite zero hit that never happens.
EDIT - it seems the sprite is in place, but there is no non-transparent tile in place.
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.
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.
The problem happens when you are holding down the start button while the game is reset. It seems you are checking the start button before something critical is done. (not exactly sure what that 'something' is).
It crashes on a sprite zero hit that never happens.
EDIT - it seems the sprite is in place, but there is no non-transparent tile in place.
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.
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.
nesdoug.com -- blog/tutorial on programming for the NES