-
Notifications
You must be signed in to change notification settings - Fork 1k
Maps that require Flash
This tutorial is for how to edit which maps require FLASH to see in.
- Location of original code
- 1. Understanding the code setup for what needs FLASH
- 2. Implementing a map
The location of where this is found is in home/overworld.asm. Credits go to wrulfy on the pret Discord server for finding the location, and Drush for correction with asm logic.
Specifically it is under the WarpFound2:: section
Original code:
WarpFound2::
ld a, [wNumberOfWarps]
sub c
ld [wWarpedFromWhichWarp], a ; save ID of used warp
ld a, [wCurMap]
ld [wWarpedFromWhichMap], a
call CheckIfInOutsideMap
jr nz, .indoorMaps
; this is for handling "outside" maps that can't have the 0xFF destination map
ld a, [wCurMap]
ld [wLastMap], a
ld a, [wCurMapWidth]
ld [wUnusedD366], a ; not read
ldh a, [hWarpDestinationMap]
ld [wCurMap], a
cp ROCK_TUNNEL_1F
jr nz, .notRockTunnel
ld a, $06
ld [wMapPalOffset], a
call GBFadeOutToBlack
.notRockTunnel
call PlayMapChangeSound
jr .done
What matters to us are the few lines at and after "cp ROCK_TUNNEL_1F" which are shown here below for simplification.
cp ROCK_TUNNEL_1F
jr nz, .notRockTunnel
ld a, $06
ld [wMapPalOffset], a
call GBFadeOutToBlack
.notRockTunnel
call PlayMapChangeSound
jr .done
Now to understand, I'm going to separate it up even more.
When entering a new map from the overworld (as this is in the overworld.asm), this line checks if the new map is ROCK_TUNNEL_1F or more simply maps\RockTunnel1F.blk
cp ROCK_TUNNEL_1F
The next line gives a divergent destination based on if yes/no. "jr" means "Jump to close location". "nz" means "If not equals zero", or "if zero flag is not set". In other words, "If not RockTunnel", since that is what we checked for. It translates to "If not ROCK_TUNNEL_1F, then skip the next few lines and go to the sub-section ".notRockTunnel"
jr nz, .notRockTunnel
If it is yes ROCK_TUNNEL_1F, then the jump is not activated, it continues down the command list and loads the next 3 lines that have as an effect to create the "FLASH needed" state.
ld a, $06
ld [wMapPalOffset], a
call GBFadeOutToBlack
If it is sent to the sub-section ".notRockTunnel", then it jumps (jr) here.
.notRockTunnel
Nothing fancy, just loads PlayMapChangeSound. Whether iit skips down or continues down both will complete with the last 2 lines. These are musical notation and completion.
call PlayMapChangeSound
jr .done
This is the editing part. All we have to do is add in a new "check & jump" to the section.
For example, if I wanted to make the Power Plant require FLASH then I would need to create and insert the following.
cp POWER_PLANT ; Checks if POWER_PLANT
jr z, .needsFlash ; If yes, then jump to .needsFlash
.needsFlash
We just have to insert the check before the Rock Tunnel check and the jump location after the .needsFlash location. This applies the FLASH-needed states before it checks for notRockTunnel.
+ cp POWER_PLANT ; Checks if POWER_PLANT
+ jr z, .needsFlash ; If yes, then jump to .needsFlash
cp ROCK_TUNNEL_1F ; Checks if ROCK_TUNNEL_1F
jr nz, .notRockTunnel ; If not, then jump to .notRockTunnel
+.needsFlash
ld a, $06 ; needs FLASH
ld [wMapPalOffset], a ; needs FLASH
call GBFadeOutToBlack ; needs FLASH
.notRockTunnel ; Jump-to location if skipping apply-FLASH
call PlayMapChangeSound
jr .done
Add as many location as you want, with the requirement being, it must be entered from the Overworld.