Originally posted by: KHAN Games
Is there other code that only allows that flag to be set at a certain event?
I would try setting those two variables to their respective values as you're changing the gamestate back to the title, and not when it's actually already in the title gamestate.
The only other place that calls for that code is when the a directional pad is pushed only during game play. I only look at the Start Button on the Game Over and Title Screen. During gameplay, the code is skipped unless one of the directions is pressed.
This was the first way I done it. The title screen works fine at first boot, but breaks when called by the Game Over Screeb. I actually had it like this first:
;-----------------------------------------------------------
;-----------------------START TITLE-------------------------
;-----------------------------------------------------------
StartTitle:
LDA #STATETITLE
STA gamestate
JSR DisablePPU
JSR LoadBackground
JSR EnablePPU
LDA #$01
STA ChangeColor ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
LDA #$29
STA attribute_RAM ;Color to change to $29
StartTitleDone:
RTS
--------------
And like this
;-----------------------------------------------------------
;-----------------------START TITLE-------------------------
;-----------------------------------------------------------
StartTitle:
LDA #STATETITLE
STA gamestate
JSR DisablePPU
JSR LoadBackground
LDA #$01
STA ChangeColor ;Flag to tell the system to run UpdateColor Subroutine in the NMI section (00=Skip ColorUpdate, 01=Run ColorUpdate)
LDA #$29
STA attribute_RAM ;Color to change to $29
JSR EnablePPU
StartTitleDone:
RTS
I thought I was doing everything correct for the NMI process, but maybe not. I have all of the practice code downloaded from NN, in fact this program is directly built off the last NN tutorial. I just ripped out the code and inserted mine as I went along.
I thought I was being clever by leaving out the code that is irrelvant to the situation (I just didn't want to paste my code for all to see) but maybe it is leaving out what you were wanting to see. If you want to request it, I would do a temp pastebin for either of you for the entire code. Just know, there are parts that are intentionally left wrong because I haven't cleaned that part up yet or I am not on that step (such as the attributes for the Title and Game Over Screens.
I will run through the tutorials again. I really don't understand what you mean by some of the suggestions such as "you should be pushing/popping your registers in NMI or it will cause more problems", so apparently I misunderstood something in the tutorials.
MRN, thanks for the slight change to UpdateColor, it's cleaner. Never thought to code it that way.