Skip to content

Commit

Permalink
Max IVs: A couple fixes
Browse files Browse the repository at this point in the history
* Fix checksum calculation when pokemon list isn't full
* Add option to turn off Forretress mode
  • Loading branch information
MathyFurret committed Sep 18, 2021
1 parent 51e4371 commit 4e72844
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ bsp/bspcomp: bsp/bspcomp.c

clean:
rm *.bsp
rm bsp/bspcomp
rm bsp/bspcomp
3 changes: 1 addition & 2 deletions main.bsps
Original file line number Diff line number Diff line change
Expand Up @@ -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)"

Expand Down
35 changes: 28 additions & 7 deletions maxivs.bsps
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -28,6 +39,7 @@ Max_IVs:
lockpos
readword #2
unlockpos
jumpnz #forretress_override, .not_forretress
ifne #species, FORRETRESS, .not_forretress

xor #3, 0x1f, 0xffffffff
Expand All @@ -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
Expand All @@ -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

0 comments on commit 4e72844

Please sign in to comment.