From 4e7284410675e56331cb9c376c10d91db8002108 Mon Sep 17 00:00:00 2001 From: Alexander B <4866817+MathyFurret@users.noreply.github.com> Date: Fri, 17 Sep 2021 19:41:58 -0500 Subject: [PATCH] Max IVs: A couple fixes * Fix checksum calculation when pokemon list isn't full * Add option to turn off Forretress mode --- Makefile | 2 +- main.bsps | 3 +-- maxivs.bsps | 35 ++++++++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 3f1979a..b6ca40c 100644 --- a/Makefile +++ b/Makefile @@ -6,4 +6,4 @@ bsp/bspcomp: bsp/bspcomp.c clean: rm *.bsp - rm bsp/bspcomp \ No newline at end of file + rm bsp/bspcomp diff --git a/main.bsps b/main.bsps index b83e42b..36644a3 100644 --- a/main.bsps +++ b/main.bsps @@ -13,8 +13,7 @@ main: .message3 string "What would you like to do?" .options - dw .option1 - dw -1 + dw .option1, -1 .option1 string "Max out all IVs (only option currently)" diff --git a/maxivs.bsps b/maxivs.bsps index 0935f62..1ec08d5 100644 --- a/maxivs.bsps +++ b/maxivs.bsps @@ -1,19 +1,30 @@ define GALLERY_BLOCK_OFFSET, 0x78b6 define HEADER_LENGTH, 0x18 define WARRIOR_LIST_LENGTH, 0xe10 - define TOTAL_LENGTH, 0x3c84 define FORRETRESS, 56 - define NUM_POKEMON, 1000 define i, 0 define species, 1 define checksum, 2 + define forretress_override, 3 + define total_length, 4 + define num_pokemon, 5 Max_IVs: - add #0, GALLERY_BLOCK_OFFSET, HEADER_LENGTH - add #0, WARRIOR_LIST_LENGTH - seek #0 + print .message + menu #forretress_override, .options + + seek GALLERY_BLOCK_OFFSET + seekfwd 4 + readword #total_length + shiftright #total_length, 9 + + seekfwd 0x10 + seekfwd WARRIOR_LIST_LENGTH + + subtract #0, #total_length, WARRIOR_LIST_LENGTH + divide #num_pokemon, #0, 0xc xor #i, #i .loop readword #species @@ -28,6 +39,7 @@ Max_IVs: lockpos readword #2 unlockpos + jumpnz #forretress_override, .not_forretress ifne #species, FORRETRESS, .not_forretress xor #3, 0x1f, 0xffffffff @@ -39,7 +51,7 @@ Max_IVs: writeword #2 increment #i - iflt #i, NUM_POKEMON, .loop + iflt #i, #num_pokemon, .loop ; calculate checksum add #0, GALLERY_BLOCK_OFFSET, HEADER_LENGTH @@ -50,9 +62,18 @@ Max_IVs: readbyte #3 add #checksum, #3 increment #i - iflt #i, TOTAL_LENGTH, .checksum_loop + iflt #i, #total_length, .checksum_loop seek GALLERY_BLOCK_OFFSET writeword #checksum return + +.message + string "I can automatically give 0 Speed IVs to any Forretress. Would you like this?" +.yes + string "Yes" +.no + string "No" +.options + dw .yes, .no, -1