News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Super Mario Bros. - Other Ways to Start on Worlds 2-8?  (Read 713 times)

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Super Mario Bros. - Other Ways to Start on Worlds 2-8?
« on: December 18, 2019, 01:54:09 am »
Regarding Super Mario Bros. for the NES, how do I change the code to make myself start on World 2, but not restart back at the world number I input into the GG?

World number assignments:
00 = World 1
01 = World 2
02 = World 3
03 = World 4
04 = World 5
05 = World 6
06 = World 7
07 = World 8

The Game Genie codes to start on a different world are...
YSAOPE+YEAOZA+PEAPYA for World 2
YSAOPE+YEAOZA+ZEAPYA for World 3
YSAOPE+YEAOZA+LEAPYA for World 4
YSAOPE+YEAOZA+GEAPYA for World 5
YSAOPE+YEAOZA+IEAPYA for World 6
YSAOPE+YEAOZA+TEAPYA for World 7
YSAOPE+YEAOZA+YEAPYA for World 8

or...
YSAOLO for World 2
YSAOLO + ZEAOPP for World 3
YSAOLO + LEAOPP for World 4
YSAOLO + GEAOPP for World 5
YSAOLO + IEAOPP for World 6
YSAOLO + TEAOPP for World 7
YSAOLO + YEAOPP for World 8

How it works...
Code: [Select]
A9 XX    = LDA #$XX (where "XX" is the world number; e.g., 01 for World 2)
8D 5F 07 = STA $075F (the absolute address that assigns the world number)

What happens is this: after beating the world number you changed to using the GG, and going to the world after it, beating the first level of the world after the one you input (e.g. cleared World 3-1), then you start back at the second level of the world you just input (e.g. World 2-2). You also return to the world you input if you die in the next world, or go down a pipe.

Therefore, how could this be fixed? What GG codes would I use to start at a desired world, but not lose your place in the world after it when you die, go down a pipe or clear the first level of this next world? That is, what I want to do is start from World 2, but to have it progress all the way to World 8 normally and not revert back to World 2 when I clear the first level of the world after.

Would I change anything in this part of the code to get the result I want?
Code: [Select]
StartWorld1:
00:82E6: 20 03 9C - JSR $9C03 ($9C03 = LoadAreaPointer)       
00:82E9: EE 5D 07 - INC $075D ($075D = Hidden1UPFlag)         ;set hidden 1-UP flag for both players
00:82EC: EE 64 07 - INC $0764 ($0764 = OffScr_Hidden1UPFlag) 
00:82EF: EE 57 07 - INC $0757 ($0757 = FetchNewGameTimerFlag) ;set fetch new game timer flag
00:82F2: EE 70 07 - INC $0770 ($0770 = OperMode)              ;set next game mode
00:82F5: AD FC 07 - LDA $07FC ($07FC = WorldSelectEnableFlag) ;if world select mode is on, then primary
00:82F8: 8D 6A 07 - STA $076A ($076A = PrimaryHardMode)       ;hard mode must be on as well
00:82FB: A9 00    - LDA #$00
00:82FD: 8D 72 07 - STA $0772 ($0772 = OperMode_Task)         ;set game mode here, and clear demo timer
00:8300: 8D A2 07 - STA $07A2 ($07A2 = DemoTimer)
00:8303: A2 17    - LDX #$17
00:8305: A9 00    - LDA #$00
InitScores:
00:8307: 9D DD 07 - STA $07DD,X ($07DD = ScoreandCoinDisplay) ;clear player scores and coin displays
00:830A: CA       - DEX
00:830B: 10 FA    - BPL $8307                                 
ExitMenu:
00:830D: 60
GoContinue:
00:830E: 8D 5F 07 - STA $075F ($075F = WorldNumber)           ;start both players at the first area
00:8311: 8D 66 07 - STA $0766 ($0766 = OffScr_WorldNumber)    ;of the previously saved world number
00:8314: A2 00    - LDX #$00                                  ;note that on power-up using this function
00:8316: 8E 60 07 - STX $0760 ($0760 = AreaNumber)            ;will make no difference
00:8319: 8E 67 07 - STX $0767 ($0767 = OffScr_AreaNumber)   
00:831C: 60       - RTS


Thank you!


~Ben

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 437
  • I am the baldest romhacker
    • View Profile
Re: Super Mario Bros. - Other Ways to Start on Worlds 2-8?
« Reply #1 on: December 18, 2019, 05:37:53 am »
For example, by sacrificing changing Mario name to Luigi, you can change this

Code: [Select]
 00:885F: AD 7A 07  LDA $077A
 00:8862: F0 1D     BEQ $8881
 00:8864: AD 53 07  LDA $0753
 00:8867: CA        DEX
 00:8868: D0 09     BNE $8873
 00:886A: AC 70 07  LDY $0770
 00:886D: C0 03     CPY #$03
 00:886F: F0 02     BEQ $8873
 00:8871: 49 01     EOR #$01
 00:8873: 4A        LSR
 00:8874: 90 0B     BCC $8881
 00:8876: A0 04     LDY #$04
 00:8878: B9 ED 87  LDA $87ED,Y
 00:887B: 99 04 03  STA $0304,Y
 00:887E: 88        DEY
 00:887F: 10 F7     BPL $8878
 00:8881: 60        RTS

into this

Code: [Select]
 00:885F: AD 5F 07  LDA $075F
 00:8862: D0 05     BNE $8869
 00:8864: A9 01     LDA #$01
 00:8866: 8D 5F 07  STA $075F
 00:8869: 60        RTS

Unlike your current GG, this won't constantly overwrite world number. It will set wanted world number only once, when current world is #$00
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 131
    • View Profile
Re: Super Mario Bros. - Other Ways to Start on Worlds 2-8?
« Reply #2 on: December 18, 2019, 07:51:49 pm »
For example, by sacrificing changing Mario name to Luigi, you can change this

Code: [Select]
00:885F: AD 7A 07  LDA $077A
 00:8862: F0 1D     BEQ $8881
 00:8864: AD 53 07  LDA $0753
 00:8867: CA        DEX
 00:8868: D0 09     BNE $8873
 00:886A: AC 70 07  LDY $0770
 00:886D: C0 03     CPY #$03
 00:886F: F0 02     BEQ $8873
 00:8871: 49 01     EOR #$01
 00:8873: 4A        LSR
 00:8874: 90 0B     BCC $8881
 00:8876: A0 04     LDY #$04
 00:8878: B9 ED 87  LDA $87ED,Y
 00:887B: 99 04 03  STA $0304,Y
 00:887E: 88        DEY
 00:887F: 10 F7     BPL $8878
 00:8881: 60        RTS

into this

Code: [Select]
00:885F: AD 5F 07  LDA $075F
 00:8862: D0 05     BNE $8869
 00:8864: A9 01     LDA #$01
 00:8866: 8D 5F 07  STA $075F
 00:8869: 60        RTS

Unlike your current GG, this won't constantly overwrite world number. It will set wanted world number only once, when current world is #$00

What is really going on, that causes the present value to be overwritten in address $9086, whenever I use such codes like YSAOPE+YEAOZA or YSAOLO to overwrite? Here's some more code for you...
Code: [Select]
SecondaryGameSetup:
00:9061: A9 01      LDA #$01
00:9063: 8D 57 07   STA $0757
00:9066: 8D 54 07   STA $0754
00:9069: A9 02      LDA #$02
00:906B: 8D 5A 07   STA $075A
00:906E: 8D 61 07   STA $0761
00:9071: A9 00      LDA #$00
00:9073: 8D 74 07   STA $0774
00:9076: A8         TAY
ClearVRLoop:
00:9077: 99 00 03   STA $0300,X
00:907A: C8         INY
00:907B: D0 FA      BNE $9077
00:907D: 8D 59 07   STA $0759
00:9080: 8D 69 07   STA $0769
00:9083: 8D 28 07   STA $0728
00:9086: A9 01      LDA #$01
00:9088: 8D 5F 07   STA $075F
00:908B: AD 1A 07   LDA $071A
00:908E: 4E 78 07   LSR $0778
00:9091: 29 01      AND #$01
00:9093: 6A         ROR
00:9094: 2E 78 07   ROL $0778
00:9097: 20 ED 90   JSR $90ED
00:909A: A9 38      LDA #$38
00:909C: 8D E3 06   STA $06E3
00:909F: A9 48      LDA #$48
00:90A1: 8D E2 06   STA $06E2
00:90A4: A9 58      LDA #$58
00:90A6: 8D E1 06   STA $06E1
00:90A9: A2 0E      LDX #$0E

And (for when I use YSAOLO)...
Code: [Select]
SetStPos:
00:9165: B9 16 91   LDA $9116,Y
00:9168: 85 86      STA $0086
00:916A: BD 1C 91   LDA $911C,X
00:916D: 85 CE      STA $00CE
00:916F: BD 25 91   LDA $9125,X
00:9172: 8D C4 03   STA $03C4
00:9175: 20 F1 85   JSR $85F1
00:9178: AC 15 07   LDY $0715
00:917B: F0 1A      BEQ $9197
00:917D: AD 57 07   STA $0757
00:9180: F0 15      BEQ $9197
00:9182: B9 2D 91   LDA $912D,Y
00:9185: 8D F8 07   STA $07F8
00:9188: A9 01      LDA #$01
00:918A: 8D 5F 07   STA $075F
00:918D: 4A         LSR
00:918E: 8D F9 07   STA $07F9
00:9191: 8D 57 07   STA $0757
00:9194: 8D 9F 07   STA $079F


~Ben
« Last Edit: December 18, 2019, 08:39:52 pm by SMB2J-2Q »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 437
  • I am the baldest romhacker
    • View Profile
Re: Super Mario Bros. - Other Ways to Start on Worlds 2-8?
« Reply #3 on: December 19, 2019, 01:23:13 am »
These two routines are executed every time the game loads a level. When you complete level 4 and go to the next world, game increases value in $075F. But your code forces this value to always be #$01. So as soon as the game will load a level, like after you die, go into pipe or complete a level - you are back at world 2.

Those GGs supposed to be deactivated once they were used to enter world 2.
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension