Useful patches

From ZeldaHacking Wiki
Jump to: navigation, search

This page describes code patches which can be applied to the disassembly to make various useful changes.

Both games

Remove Beginning Locks

When you begin a game, you cannot open the menu, and music does not play properly. Apply these changes to fix the issue without completing the intro normally.

A single flag named "GLOBALFLAG_INTRO_DONE" is responsible for these events. Run git grep GLOBALFLAG_INTRO_DONE to see where it is used:

$ git grep GLOBALFLAG_INTRO_DONE
code/ages/roomSpecificTileChanges.s:    ld a,GLOBALFLAG_INTRO_DONE
code/bank1.s:   ld a, GLOBALFLAG_INTRO_DONE
code/bank2.s:   ld a,(wGlobalFlags+GLOBALFLAG_INTRO_DONE/8)
code/bank2.s:   bit GLOBALFLAG_INTRO_DONE&7,a
code/seasons/roomGfxChanges.s:  ld a,GLOBALFLAG_INTRO_DONE
constants/globalFlags.s:        GLOBALFLAG_INTRO_DONE                   db ; $0a: Once set, start/select are usable
[...etc...]

It is used many times, but we only care about its usage in "bank1.s" and "bank2.s".

Find the following code in "bank1.s":

checkPlayRoomMusic:
	ld a, GLOBALFLAG_INTRO_DONE
	call checkGlobalFlag
	ret z

Simply delete these 3 lines of code (or comment them out with a semicolon) to enable music. (Don't delete the "checkPlayRoomMusic:" label, only the 3 lines below that.)

Then, find the following code in "bank2.s":

	; Return if you haven't seen the opening cutscene yet
	ld a,(wGlobalFlags+GLOBALFLAG_INTRO_DONE/8)
	bit GLOBALFLAG_INTRO_DONE&7,a
	ld a, SND_ERROR
	jp z,playSound

Again, simply delete these 4 lines of code. This will allow you to open your inventory.