Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zaksabeast committed Apr 14, 2023
0 parents commit 206d6dc
Show file tree
Hide file tree
Showing 7 changed files with 561 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.bin
*.ips
*.zip
15 changes: 15 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: patch clean

patch:
@armips main.s
@flips -c code.bin code_patched.bin code.ips

clean:
@rm code_patched.bin code.ips
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# XY All Friend Safaris Patch

This patch allows Pokemon XY v1.5 to access any friend safari Pokemon. It makes the game think the console has 71 friends that have every available friend safari with all three slots unlocked.

This does not modify your actual 3ds friends list, it just makes the game think fake friends are available. You should probably avoid going online when using this patch - I'm not responsible for anything that goes wrong when using it.

## Usage

Console:

1. Download `code.ips` from the releases page
2. Enable luma game patches
3. Copy `code.ips` to your 3ds sd at `/luma/titles/0004000000055D00/code.ips` for X and `/luma/titles/0004000000055E00/code.ips` for Y

Citra:

1. Download `code.ips` from the releases page
2. Right click on the game and select "Open Mods Location"
3. Copy `code.ips` into the directory that appears

## Friend safari generation

There's a common misconception that friend safaris are calculated with the friend code used to add online 3ds friends. Friend safaris are actually calculated with a hidden local friend code. Check out `friend-safari-generator/index.js` to learn more.
139 changes: 139 additions & 0 deletions friend-safari-generator/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
const MT = require("./mt.js");

const FRIEND_SAFARIS = [
[
["Lillipup", "Dunsparce", "Teddiursa", "Aipom"],
["Kecleon", "Minccino", "Loudred", "Audino"],
["Eevee", "Ditto", "Smeargle", "Chansey"],
],
[
["Meditite", "Mankey", "Machoke", "Mienfoo"],
["Pancham", "Pancham", "Throh", "Sawk"],
["Hariyama", "Tyrogue", "Riolu", "Breloom"],
],
[
["Pidgey", "Spearow", "Farfetch’d", "Doduo"],
["Hoothoot", "Tranquill", "Swanna", "Woobat"],
["Rufflet", "Tropius", "Fletchinder", "Hawlucha"],
],
[
["Kakuna", "Cascoon", "Seviper", "Gloom"],
["Venomoth", "Swalot", "Garbodor", "Ariados"],
["Toxicroak", "Drapion", "Muk", "Whirlipede"],
],
[
["Phanpy", "Wooper", "Trapinch", "Sandshrew"],
["Marowak", "Camerupt", "Dugtrio", "Nincada"],
["Palpitoad", "Gastrodon", "Diggersby", "Diggersby"],
],
[
["Dwebble", "Dwebble", "Nosepass", "Boldore"],
["Pupitar", "Corsola", "Onix", "Magcargo"],
["Rhydon", "Shuckle", "Barbaracle", "Barbaracle"],
],
[
["Butterfree", "Combee", "Ledyba", "Paras"],
["Beautifly", "Masquerain", "Volbeat", "Illumise"],
["Vivillon", "Venomoth", "Pinsir", "Heracross"],
],
[
["Shuppet", "Shuppet", "Lampent", "Lampent"],
["Phantump", "Phantump", "Pumpkaboo", "Pumpkaboo"],
["Golurk", "Drifblim", "Dusclops", "Spiritomb"],
],
[
["Ferroseed", "Ferroseed", "Mawile", "Magneton"],
["Metang", "Klang", "Skarmory", "Forretress"],
["Bronzong", "Excadrill", "Klefki", "Klefki"],
],
[
["Ponyta", "Growlithe", "Pansear", "Magmar"],
["Charmeleon", "Pyroar", "Slugma", "Larvesta"],
["Braixen", "Braixen", "Fletchinder", "Ninetales"],
],
[
["Krabby", "Bibarel", "Panpour", "Octillery"],
["Wartortle", "Quagsire", "Gyarados", "Floatzel"],
["Frogadier", "Frogadier", "Azumarill", "Poliwhirl"],
],
[
["Oddish", "Tangela", "Pansage", "Sunkern"],
["Ivysaur", "Petilil", "Sawsbuck", "Swadloon"],
["Quilladin", "Quilladin", "Maractus", "Gogoat"],
],
[
["Electrode", "Emolga", "Dedenne", "Pachirisu"],
["Pikachu", "Helioptile", "Electabuzz", "Stunfisk"],
["Luxio", "Galvantula", "Zebstrika", "Manectric"],
],
[
["Abra", "Drowzee", "Grumpig", "Munna"],
["Wobbuffet", "Sigilyph", "Espurr", "Espurr"],
["Duosion", "Xatu", "Girafarig", "Gothorita"],
],
[
["Snorunt", "Delibird", "Spheal", "Snover"],
["Bergmite", "Bergmite", "Sneasel", "Beartic"],
["Lapras", "Cloyster", "Dewgong", "Piloswine"],
],
[
["Gabite", "Gabite", "Fraxure", "Fraxure"],
["Shelgon", "Dragonair", "Noibat", "Noibat"],
["Druddigon", "Druddigon", "Sliggoo", "Sliggoo"],
],
[
["Pawniard", "Vullaby", "Nuzleaf", "Mightyena"],
["Sneasel", "Sandile", "Cacturne", "Crawdaunt"],
["Liepard", "Inkay", "Absol", "Sableye"],
],
[
["Kirlia", "Snubbull", "Togepi", "Dedenne"],
["Mawile", "Jigglypuff", "Spritzee", "Swirlix"],
["Floette", "Clefairy", "Floette", "Floette"],
],
];

const FRIEND_SAFARI_TYPES = [
0, 9, 10, 11, 12, 14, 1, 3, 4, 2, 13, 6, 5, 7, 15, 16, 8, 17, 0, 9, 10, 11,
12, 14, 1, 3, 4, 2, 13, 6, 5, 7,
];

const FRIEND_SAFARI_SHIFT_NUMS = [3, 6, 9, 12, 16];
const SLOT_1_SHIFT_NUMS = [20, 23];
const SLOT_2_SHIFT_NUMS = [27, 30];
const SLOT_3_SHIFT_NUMS = [15, 24];

const twistRand = (rand, shiftNums) => {
let result = 0;

for (let i = 0; i < shiftNums.length; i++) {
const shiftNum = shiftNums[i] - 1;
result |= ((rand & (1 << shiftNum)) >> shiftNum) << i;
}

return result;
};

const getSafarisFromLocalFriendCode = (localFriendCode) => {
const maskedSeed = localFriendCode | 0x81000008000801n;
const seedLow = Number(maskedSeed & 0xffffffffn);
const seedHigh = Number(maskedSeed >> 32n);
const seedArr = [seedLow, seedHigh];
const mt = new MT();
mt.init_by_array(seedArr, seedArr.length);
const rand = mt.genrand_int32();

const friendSafariIndex =
FRIEND_SAFARI_TYPES[twistRand(rand, FRIEND_SAFARI_SHIFT_NUMS)];
const slot1Index = twistRand(rand, SLOT_1_SHIFT_NUMS);
const slot2Index = twistRand(rand, SLOT_2_SHIFT_NUMS);
const slot3Index = twistRand(rand, SLOT_3_SHIFT_NUMS);

const friendSafari = FRIEND_SAFARIS[friendSafariIndex];

return [
friendSafari[0][slot1Index],
friendSafari[1][slot2Index],
friendSafari[2][slot3Index],
];
};
Loading

0 comments on commit 206d6dc

Please sign in to comment.