Skip to content

Commit

Permalink
Add support for the Following Platinum mod
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGag96 committed Nov 24, 2021
1 parent 6c8f20b commit c81bba2
Show file tree
Hide file tree
Showing 60 changed files with 997 additions and 35 deletions.
56 changes: 56 additions & 0 deletions Hijack_WalkingPokemon.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
.thumb

Hijack_WalkingPokemon: @ hook at overlay 5, 0x1D21E (0x021EDF9E) and 0x1D2DC (0x021EE05C)
push {r4, lr}

@ r1 contains the subfile ID inside the narc file root/data/mmodel/mmodel.narc containing all the OW sprites
mov r4, r1

ldr r3, =0x021EDCF5
blx r3

push {r0, r1, r2}

@ r0 now contains pointer to the BTX file that was just loaded

@ skip this code if we did not just load a Pokemon OW sprite
@ these bounds are the IDs of Pokemon OW sprites specifically
ldr r1, =471
cmp r4, r1
blt .end
ldr r1, =1324
cmp r4, r1
bgt .end

ldr r3, =0x020501E0 @ location of "free ram" area

@ do not continue if 0xF0110 was not set earlier
ldr r2, [r3, #0x18]
ldr r1, =0x000F0110
cmp r2, r1
bne .end

@ reset flag used to look for 0xF0110
mov r1, #0
str r1, [r3, #0x18]

ldr r2, =0x1180 @ offset of normal palette in BTX file
add r0, r0, r2

ldr r1, [r3, #0x0] @ contains personality value of last read pkmn data

ldr r2, =0x020500BD @ location of code from hueshift.c

push {r0, r1, r2, r3}
blx r2
pop {r0, r1, r2, r3}

add r0, r0, #0x20 @ run code on shiny palette also since Pokemon may be shiny
blx r2

.end:

@ restore old code
pop {r0, r1, r2}

pop {r4, pc}
16 changes: 16 additions & 0 deletions Hijack_WalkingPokemonDetect.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.thumb

Hijack_WalkingPokemonDetect: @ hook at overlay 5, 0xAFE (0x021D187E)
push {lr}
push {r0, r1}

ldr r0, =0x000F0110
ldr r1, =0x020501E0 @ location of in battle flag
str r0, [r1, #0x18]

@ restore old code
pop {r0, r1}
mov r1, #0x22
mov r2, #0x4

pop {pc}
16 changes: 16 additions & 0 deletions Hijack_WalkingPokemonDetect2.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.thumb

Hijack_WalkingPokemonDetect2: @ hook at Following Platinum sythetic overlay, 0x50 (0x023C8050), 0x1050 (0x023C9050), and 0x23A6 (0x023CA3A6)
push {lr}
push {r0, r1}

ldr r1, =0x020501E0 @ location of in battle flag
ldr r0, [r0, #0x0]
str r0, [r1, #0x0]

@ restore old code
pop {r0, r1}
mov r1, #5
mov r2, #0

pop {pc}
31 changes: 21 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,20 @@ List of changed Pokémon (so far):

1. Install [devkitARM](https://devkitpro.org/wiki/Getting_Started).
2. Install a [D compiler](https://dlang.org/download.html).
3. Use a program like Nitro Explorer 3 to extract `arm9.bin`, `overlay9-12.bin`, `overlay9-16.bin`, `overlay9-86.bin`, and `overlay9-87.bin` from your Platinum ROM.
4. Place them in the root folder of this repo, and name them to `arm9_vanilla.bin`, `overlay12_vanilla.bin`, `overlay16_vanilla.bin`, `overlay86_vanilla.bin`, and `overlay87_vanilla.bin`, respectively.
5. Run `./build.sh`.
6. Inject `arm9_patched.bin`, `overlay12_patched.bin`, `overlay86_patched.bin`, and `overlay87_patched.bin` back into `arm9.bin`, `overlay9-12.bin`, `overlay9-16.bin`, `overlay9-86.bin`, and `overlay9-87.bin`, respectively.
7. Extract `poketool/pokegra/pl_pokegra.narc`.
8. For each image in the `ShinyChanges` folder, insert that image to the proper place using "Pokemon Ds/Pic Platinum". (Note that some Pokémon might have changes to the base sprite.)
9. Reinsert `pl_pokegra.narc`.
10. If you want to be really thorough, extract `poketool/pokegra/pokegra.narc` and replace each changed palette entry (only the palette ones, not the image ones, unless necessary like Blissey!).
3. Download [PokEditor v1](https://github.com/turtleisaac/PokEditor/releases), extract it into the root folder of this repo, and rename folder that got extracted to `PokEditor`.
4. Use a program like Nitro Explorer 3 to extract `arm9.bin`, `overlay9-5.bin`, `overlay9-12.bin`, `overlay9-16.bin`, `overlay9-86.bin`, and `overlay9-87.bin`, and `data/weather_sys.narc` from your Platinum ROM.
5. Place them in the root folder of this repo, and name them to `arm9_vanilla.bin`, `overlay5_vanilla.bin`, `overlay12_vanilla.bin`, `overlay16_vanilla.bin`, `overlay86_vanilla.bin`, `overlay87_vanilla.bin`, and `weather_sys.narc`, respectively.
6. Use Tinke or PokEditor v2 (not v1) to extract file 65 from `weather_sys.narc` as `weather_sys_065_vanilla.bin`.
7. Run `./build.sh`.
8. Overwrite file 65 from `weather_sys.narc` with `weather_sys_065_patched.bin`.
9. Inject `arm9_patched.bin`, `overlay5_patched.bin` `overlay12_patched.bin`, `overlay86_patched.bin`, `overlay87_patched.bin`, and `weather_sys.narc` back into `arm9.bin`, `overlay9-5.bin`, `overlay9-12.bin`, `overlay9-16.bin`, `overlay9-86.bin`, `overlay9-87.bin`, and `data/weather_sys.narc`, respectively.
10. Extract `poketool/pokegra/pl_pokegra.narc`.
11. For each image in the `ShinyChanges` folder, insert that image to the proper place using "Pokemon Ds/Pic Platinum". (Note that some Pokémon might have changes to the base sprite.)
12. Reinsert `pl_pokegra.narc`.
13. If you want to be really thorough, extract `poketool/pokegra/pokegra.narc` and replace each changed palette entry (only the palette ones, not the image ones, unless necessary like Blissey!).
14. Extract `data/mmodel/mmodel.narc` as `ow_sprites.narc`.
15. Run `./pack_follow_pal.sh`.
16. Insert the resulting `ow_sprites_patched.narc` to `data/mmodel/mmodel.narc`.


## How It Works
Expand All @@ -162,13 +168,13 @@ The added code used to make this work are inserted in `arm9.bin` at `0x5003C` th

| Address | Description |
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `0x020501E0` | Personality value of player Pokémon 1 |
| `0x020501E0` | Personality value of player Pokémon 1 (and the OW following Pokémon) |
| `0x020501E4` | Personality value of enemy Pokémon 1 |
| `0x020501E8` | Personality value of player/partner Pokémon 2 |
| `0x020501EC` | Personality value of enemy Pokémon 2 |
| `0x020501F0` | Saved-off variable battle data pointer |
| `0x020501F4` | Unused |
| `0x020501F8` | `0xBA771E` if currently in battle, something else otherwise. Set by `Hijack_BattleStart`, `Hijack_BattleEnd`, `Hijack_BattleEndCaught`. Read by `Hijack_HueShift.s` |
| `0x020501F8` | `0xBA771E` if currently in battle, something else otherwise. Set by `Hijack_BattleStart`, `Hijack_BattleEnd`, `Hijack_BattleEndCaught`. Read by `Hijack_HueShift.s`; `0xF0110` if a OW following sprite is going to be loaded. Set by `Hijack_WalkingPokemonDetect2.s`, read by `Hijack_WalkingPokemon.s`. |
| `0x020501FC` | Read in `Hijack_GbaPal.s` to determine if up the call chain, it was signalled that a Pokémon's battle sprite palette is being loaded. `0xBEEFXXXX` where `XXXX` is the index of the sprite being loaded (0-3). Also set to `0xFA3E` when loading a sprite for the Hall of Fame, to be read in `Hijack_PaletteUpload.s`; `0x0E66` when loading the egg hatching animation graphics, to be read by `Hijack_AnimPal.s`. |
| `0x02050200` | Contains the personality value of the Pokémon read by the last call to `GetPkmnData` or `GetBoxPkmnData`, read by `Hijack_HueShift.s` and `Hijack_MiscSprite.s`. |

Expand Down Expand Up @@ -210,6 +216,11 @@ A rundown of the code files involved:

* `Hijack_AnimPal.s` - Hijacks a common function related to loading palettes (unsure of its exact purpose), just before uploading to palette RAM occurs. Checks if `0x020501FC` was set to `0x0E66` earlier in the call chain - if so, loads the personality value at `0x02050200`, calls the code at `hueshift.c`, then resets `0x020501FC` to `0`.

* `Hijack_WalkingPokemonDetect.s` - Hijacks a function in overlay 5 called when the overworld sprites are about to load during an OW load (e.g. entering/exiting a door, closing a fullscreen menu). `0x000F0110` is set to `0x020501F8` to be used by `Hijack_WalkingPokemon.s` later.

* `Hijack_WalkingPokemonDetect2.s` - Hijacks three places in Following Platinum's synthetic overlay (`data/weather_sys.narc`, file 65) where a Pokémon's species is about to be determined for loading its proper sprite. The personality value of the Pokémon being considered is saved to `0x020501E0` to be used by `Hijack_WalkingPokemon.s` later. (Unfortunately, by the time `Hijack_WalkingPokemon.s` is hit, the last-read Pokémon's personality value can't be used because of some other code that gets called between `Hijack_WalkingPokemonDetect.s` and it.)

* `Hijack_WalkingPokemon.s` - Hijacks two places in overlay 5, right at the point the BTX file for an overworld sprite gets loaded from `data/mmodel/mmodel.narc`. The overwritten call to load the BTX is ran. Then, if the file ID being read from the narc is one of the following Pokémon sprites (471-1324), and `0x020501F8` was set to `0x000F0110` earlier, we call the code at `hueshift.c` using the personality value in `0x020501E0` on both the normal and shiny palettes in the BTX file. `0x020501F8` is set to `0`.

## Credits

Expand Down
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/1014_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#98B878
#000000
#B0C8F8
#28A0F8
#4d51bd
#cf27cf
#45368f
#5b44cf
#7b69f0
#9b98f5
#A88818
#F8D060
#A8A0C8
#000000
#404040
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/1015_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#98B878
#000000
#000000
#000000
#000000
#cf27cf
#573da6
#5b44cf
#7b69f0
#9b98f5
#1fb5a4
#53f5d4
#A8A0C8
#000000
#404040
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/496_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#d8a040
#ad7918
#F808F8
#F808F8
#F808F8
#F808F8
#F808F8
#686050
#a39b81
#ded6bf
#303030
#403830
#000000
#A8A0C8
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/497_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#d8a040
#ad7918
#F808F8
#F808F8
#F808F8
#F808F8
#F808F8
#686050
#a39b81
#ded6bf
#303030
#403830
#000000
#A8A0C8
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/498_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#d08030
#e09828
#785850
#806850
#b09888
#c8b8a8
#e0c8c0
#786848
#d0a868
#e8b068
#303030
#382820
#000000
#A8A0C8
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/503_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#B08080
#382840
#805088
#b068c0
#d898e0
#b0b888
#686848
#602818
#F800F8
#F800F8
#b8b895
#d8d8c8
#C8C8C8
#000000
#606060
#E8E8F8
Binary file added ShinyChanges/FollowPals/524.btx
Binary file not shown.
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/525_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#30403b
#a0c0b8
#31694d
#985018
#409068
#88d098
#b8f0c0
#660834
#c24476
#679e73
#F800F8
#F800F8
#000000
#404040
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/535_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#604820
#F808F8
#F808F8
#D8B870
#F8E0A0
#a66d93
#cf9dbc
#F808F8
#F808F8
#F808F8
#F808F8
#F808F8
#000000
#585858
#E8E8F8
Binary file added ShinyChanges/FollowPals/536.btx
Binary file not shown.
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/558_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#B8C890
#807058
#66543f
#b09880
#f0e0b8
#502020
#C04058
#E08090
#705820
#E8C860
#F8F0B8
#D09808
#000000
#000000
#606060
#E8E8F8
Binary file added ShinyChanges/FollowPals/559.btx
Binary file not shown.
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/565_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#B8C890
#524b66
#886888
#b090c8
#c8a8d8
#F800F8
#3840A0
#3870D0
#F800F8
#F800F8
#F800F8
#B8B8B8
#989898
#000000
#484848
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/566_normal.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#1a161f
#281838
#483058
#684868
#F800F8
#F800F8
#e05060
#f77982
#F800F8
#282828
#B8B8B8
#989898
#000000
#606060
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/566_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#B8C890
#473847
#9c7b9c
#c09bc7
#d9c1e0
#F800F8
#F800F8
#8080e8
#79b2f7
#F800F8
#282828
#e6e6e6
#cfcfcf
#000000
#cfcfcf
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/595_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#C0B0D8
#5c1d15
#883800
#db7f5a
#B09828
#F0D848
#A86048
#F0A890
#000000
#000000
#000000
#504010
#B0B0C8
#000000
#808080
#E8E8F8
16 changes: 16 additions & 0 deletions ShinyChanges/FollowPals/597_shiny.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#A0B080
#403820
#1d4b54
#2c93a3
#50c8f0
#000000
#000000
#000000
#000000
#000000
#485050
#707070
#909090
#000000
#303030
#E8E8F8
Loading

0 comments on commit c81bba2

Please sign in to comment.