summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Maps-that-require-Flash.md216
1 files changed, 216 insertions, 0 deletions
diff --git a/Maps-that-require-Flash.md b/Maps-that-require-Flash.md
new file mode 100644
index 0000000..08ce937
--- /dev/null
+++ b/Maps-that-require-Flash.md
@@ -0,0 +1,216 @@
+This tutorial is for how to edit which maps require FLASH to see in.
+## Contents
+- [Location of original code](#location-of-original-code)
+- [0. Understanding the code setup for what needs FLASH](#0-understanding-the-code-setup-for-what-needs-flash)
+- [1. Prepping the code for additions](#1-prepping-the-code-for-additions)
+- [2. Implementing a map](#2-implementing-a-map)
+- [3. Code cleanup](#3-code-cleanup)
+
+## Location of original code
+
+The location of where this is found is in home/overworld.asm.
+Credit goes to wrulfy on the pret Discord server for finding it.
+
+Specifically it is under the WarpFound2:: section
+
+Original code:
+```diff
+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
+```
+
+
+## 0. Understanding the code setup for what needs FLASH
+
+What matters to us are the few lines at and after "cp ROCK_TUNNEL_1F" which are shown here below for simplification.
+```diff
+ 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, this line checks if the new map is ROCK_TUNNEL_1F or more simply maps\RockTunnel1F.blk
+```diff
+ 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 equals zero", or in other words, "If not RockTunnel", since that is what we checked for.
+It translates to "If not ROCK_TUNNEL_1F, then go to the sub-section ".notRockTunnel"
+```diff
+ jr nz, .notRockTunnel
+```
+
+If it is sent to the sub-section ".notRockTunnel", then it jumps (jr) here.
+```diff
+.notRockTunnel
+```
+
+Based on if .notRockTunnel or ROCK_TUNNEL_1F, will load 2 separate states.
+Below is if it is a normal (no FLASH needed) map.
+Nothing fancy, just loads the new map normally.
+```diff
+ call PlayMapChangeSound
+```
+
+This is if it is meant to load a FLASH-required map. It is what sets up "needs FLASH to see".
+```diff
+ ld a, $06
+ ld [wMapPalOffset], a
+ call GBFadeOutToBlack
+```
+This is the termination of the entire action.
+```diff
+ jr .done
+```
+
+
+
+## 1. Prepping the code for additions
+
+The problem with the original code is how it treats the default and the exception.
+Due to the exception being .notRockTunnel, that means the default is Rock Tunnel. Which is fine for only have a single FLASH-required location. But we want more than just that.
+
+So first we are going to change the code to treat the default state as normal, and the exception to the rule as "needing FLASH".
+
+The base step is to change the "if, then jump" line.
+What this will do is instead of a "not, then jump" we'll have a "yes, then jump" action.
+```diff
+- jr nz, .notRockTunnel
++ jr n, .yesRockTunnel
+```
+
+Then we need to rename the jumped to location.
+```diff
+-.notRockTunnel
++.yesRockTunnel
+```
+
+Next we need to swap what is loaded via the default and the exception.
+
+Default state:
+```diff
+- ld a, $06
+- ld [wMapPalOffset], a
+- call GBFadeOutToBlack
++ call PlayMapChangeSound
+```
+
+Exception state:
+```diff
+- call PlayMapChangeSound
++ ld a, $06
++ ld [wMapPalOffset], a
++ call GBFadeOutToBlack
+```
+
+So what the entire section we changed should look like is the following:
+```diff
+ cp ROCK_TUNNEL_1F
+- jr nz, .notRockTunnel ; Old ; If no, then jump to exception
++ jr n, .yesRockTunnel ; New ; If yes, then jump to exception.
+- ld a, $06 ; Old Normal ; needs FLASH
+- ld [wMapPalOffset], a ; Old Normal ; needs FLASH
+- call GBFadeOutToBlack ; Old Normal ; needs FLASH
++ call PlayMapChangeSound ; New Normal ; no FLASH needed
+-.notRockTunnel
++.yesRockTunnel
+- call PlayMapChangeSound ; Old Exception ; no FLASH needed
++ ld a, $06 ; New Exception ; needs FLASH
++ ld [wMapPalOffset], a ; New Exception ; needs FLASH
++ call GBFadeOutToBlack ; New Exception ; needs FLASH
+ jr .done
+```
+
+Having made this change will have no discernible effect in game thus far.
+But we'll have prepped the code for easy addition of other maps to require FLASH.
+
+
+## 2. Implementing a map
+
+This is the easiest 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.
+```diff
+ cp POWER_PLANT ; Checks if POWER_PLANT
+ jr n, .yesPowerPlant ; If yes, then jump to .yesPowerPlant
+.yesPowerPlant
+ ld a, $06 ; New Exception ; needs FLASH
+ ld [wMapPalOffset], a ; New Exception ; needs FLASH
+ call GBFadeOutToBlack ; New Exception ; needs FLASH
+```
+
+We just have to insert the check after the Rock Tunnel check and the jump location after the .yesRockTunnel location.
+
+So the end result would be as follows:
+```diff
+ cp ROCK_TUNNEL_1F
+ jr n, .yesRockTunnel ; New ; If yes, then jump to exception.
++ cp POWER_PLANT ; Checks if POWER_PLANT
++ jr n, .yesPowerPlant ; If yes, then jump to .yesPowerPlant
+ call PlayMapChangeSound ; New Normal ; no FLASH needed
+.yesRockTunnel
+ ld a, $06 ; New Exception ; needs FLASH
+ ld [wMapPalOffset], a ; New Exception ; needs FLASH
+ call GBFadeOutToBlack ; New Exception ; needs FLASH
++.yesPowerPlant
++ ld a, $06 ; New Exception ; needs FLASH
++ ld [wMapPalOffset], a ; New Exception ; needs FLASH
++ call GBFadeOutToBlack ; New Exception ; needs FLASH
+ jr .done
+```
+
+
+## 3. Code cleanup
+
+If you plan on adding a significant number of locations, changing a bit might be best to have a cleaner code. Renaming the exception for ease.
+```diff
+ cp ROCK_TUNNEL_1F ; Checks if ROCK_TUNNEL_1F
+- jr nz, .notRockTunnel
++ jr n, .yesFlashNeeded ; New exception name & condition
++ cp POWER_PLANT ; Checks if POWER_PLANT
++ jr n, .yesFlashNeeded ; New exception name & condition
+- ld a, $06
+- ld [wMapPalOffset], a
+- call GBFadeOutToBlack
++ call PlayMapChangeSound ; New Normal ; no FLASH needed
+-.notRockTunnel
++.yesFlashNeeded
+- call PlayMapChangeSound
++ ld a, $06 ; New Exception ; needs FLASH
++ ld [wMapPalOffset], a ; New Exception ; needs FLASH
++ call GBFadeOutToBlack ; New Exception ; needs FLASH
+ jr .done
+
+
+Add as many location as you want, with the requirement being, it must be entered from the Overworld. \ No newline at end of file