The "Not One" Check?

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

SMB2J-2Q
Posts: 230
Joined: Thu Jul 27, 2017 5:13 pm

Re: The "Not One" Check?

Post by SMB2J-2Q »

Dwedit wrote: Mon Jun 09, 2025 9:11 pm Everything depends.

Are you trying to preserve the contents of a register? Preserve the carry flag? I don't know what the requirements are.
Yes, that is my goal. When booting up SMB, these RAM addresses are cleared until you press start to begin a new game.

As I said, RAM address $07FC is the flag for world selection, which on startup is cleared (#$00). Under normal circumstances, if you beat World 8-4, and press B to go back to the title screen, it is then set to #$01 along with the primary hard mode flag (RAM $076A). But if you happen to do a cartridge swap (and this is a trick some players do to try to access invalid worlds from 9 to 256), without turning off the console's power you swap in some other game, and if that other game you're playing also happens to have $07FC among its RAM addresses, and you then try to reload SMB later (again leaving the console turned on), if the value stored in $07FC from that other game is #$02 or higher, then in SMB this value may cause the game to glitch.

In case you'd like to know why I keep bringing this up, here is a snippet of code from TakuikaNinja's version of the SMB1 bugfix:
Source: https://github.com/TakuikaNinja/smb1-bu ... rc/prg.asm

Code: Select all

WBootCheck:
		lda TopScoreDisplay,x     ; check each score digit in the top score
		cmp #10			  ; to see if we have a valid digit
		bcs ColdBoot		  ; if not, give up and proceed with cold boot

		dex
		bpl WBootCheck

		lda WarmBootValidation	  ; second checkpoint, check to see if
		cmp #$a5		  ; another location has a specific value
		bne ColdBoot

		lda ContinueWorld	  ; glitch world fix
		cmp #World8+1		  ; check against max world value + 1 (world 9)
		bcs ColdBoot		  ; cold boot if greater than or equal

		lda WorldSelectEnableFlag ; also check if the world select flag is <= 1 
		lsr
		bne ColdBoot
		
		ldy #WarmBootOffset	  ; if passed, load warm boot pointer
In his bugfix, RAM $07FC was another checkpoint he added upon starting up a new game to prevent glitched worlds, and if the value of $07FC in that instance happened to be #$02 or greater, it would skip to do a cold boot, just as if RAM $07FD would if it contained a value of #$08 or higher.

~Ben
Post Reply