-
Notifications
You must be signed in to change notification settings - Fork 0
/
maxivs.bsps
79 lines (65 loc) · 1.53 KB
/
maxivs.bsps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
define FORRETRESS, 56
define i, 0
define species, 1
define checksum, 2
define forretress_override, 3
define total_length, 4
define num_pokemon, 5
define block_offset, 6
Max_IVs:
print .message
menu #forretress_override, .options
set #block_offset, GALLERY_BLOCK_OFFSET1
call Max_IVs_Patch
set #block_offset, GALLERY_BLOCK_OFFSET2
call Max_IVs_Patch
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
Max_IVs_Patch:
seek #block_offset
readword #2 ; dummy read
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
and #species, 0xff
getfileword #2
or #2, 0x3fff8000
writeword #2
getfileword #2
jumpnz #forretress_override, .not_forretress
ifne #species, FORRETRESS, .not_forretress
xor #1, 0x1f, 0xffffffff
and #2, #1
jump .endif
.not_forretress
or #2, 0x1f
.endif
writeword #2
increment #i
iflt #i, #num_pokemon, .loop
; calculate checksum
add #0, #block_offset, HEADER_LENGTH
seek #0
xor #i, #i
xor #checksum, #checksum
.checksum_loop
readbyte #1
add #checksum, #1
increment #i
iflt #i, #total_length, .checksum_loop
seek #block_offset
writeword #checksum
return