.text
.align 2
.thumb
.thumb_func
.global endmoveberries
.include "T:/asdS/thumb/bsmacros.asm"
@@https://www.pokecommunity.com/showpost.php?p=9062722&postcount=332
@@ Paste all the content from the 'BS Macro & Defines' Spoiler in this link to a new blank ASM file and include its path.
.equ RomAreaOffset, 0x8000000
.equ BerryLoc, 0xE10000
.equ ContraryID, 0x7F
.equ GluttonyID, 0x53
.equ BattleData, 0x2024084
.equ Sitrus, 0x8E
.equ Return, 0x08045674+1
.equ Return2, 0x0804582A+1
.equ ItemBuffer, 0x2024208
.equ ScriptPointer, 0x2024214
.equ ScriptPusher, 0x803FAFC+1
.equ MiscBufferCountersArea, 0x2024474
.equ Bank_F, 0x202420F
.equ ActiveBank, 0x2024064
.equ Damage, 0x20241F0
.equ NoOfBattlers, 0x202406C
.equ UserBank, 0x202420B
.equ TargetPartner, 0x202420E
.equ BattleOutcome, 0x2022F58
.equ Divider, 0x82e7540+1
.equ ConfuseAccToNature, 0x806e880+1
.equ RNG, 0x806F5CC+1
.equ DivMod, 0x82E7Be0+1
.equ OranHealBSLoc, OranHealBS+RomAreaOffset
.equ HealAndConfuseBSLoc, HealAndConfuseBS+RomAreaOffset
.equ FocusBerryBSLoc, FocusBerryBS+RomAreaOffset
.equ StatRaiseBSLoc, StatRaiseBS+RomAreaOffset
.org 0x45280
mov r7, #0x0
ldr r0, =NoOfBattlers
ldrb r0, [r0]
cmp r7, r0
bcc CheckBankHP
b 0x4582A
CheckBankHP:
ldr r1, =BattleData
mov r8, r1
mov r0, #0x58
mul r0, r7
add r0, r0, r1
ldrh r2, [r0, #0x28]
cmp r2, #0x0
bne HasHP
b 0x45674
HasHP:
ldr r4, =ItemBuffer
ldrh r0, [r0, #0x2E]
strh r0, [r4]
bl 0xD74DC
lsl r0, r0, #0x18
lsr r5, r0, #0x18
sub r0, r5, #1
cmp r0, #0x1B
bls LoadBerryTable
b 0x45674
LoadBerryTable:
lsl r0, r0, #2
ldr r1, BerryTableLoc
add r0, r0, r1
ldr r3, [r0]
ldrh r0, [r4]
bl 0xD7500
lsl r0, r0, #0x18
lsr r0, r0, #0x18
mov r9, r0
mov pc, r3
.align 2
BerryTableLoc: .word BerryLoc+RomAreaOffset
.align 2
.pool
.org BerryLoc
.word HPRestoreBerry+RomAreaOffset @Oran, Sitrus, Berry Juice
.word 0x8045354 @Cheri Berry
.word 0x8045444 @Chesto Berry
.word 0x8045390 @Pecha Berry
.word 0x80453CC @Rawst Berry
.word 0x8045408 @Aspear Berry
.word 0x8045674 @Leppa Berry
.word 0x804548C @Persim Berry
.word 0x8045520 @Lum Berry
.word HPRestoreConfuseBerry+RomAreaOffset @Figy
.word HPRestoreConfuseBerry+RomAreaOffset @Wiki
.word HPRestoreConfuseBerry+RomAreaOffset @Mago
.word HPRestoreConfuseBerry+RomAreaOffset @Aguav
.word HPRestoreConfuseBerry+RomAreaOffset @Iapapa
.word StatRaiseBerry+RomAreaOffset @Leichi
.word StatRaiseBerry+RomAreaOffset @Ganlon
.word StatRaiseBerry+RomAreaOffset @Salac
.word StatRaiseBerry+RomAreaOffset @Petaya
.word StatRaiseBerry+RomAreaOffset @Apicot
.word LansatBerry+RomAreaOffset @Lansat
.word StarfBerry+RomAreaOffset @Starf
.word 0x8045674
.word 0x8045614 @White Herb
.word 0x8045674
.word 0x8045674
.word 0x8045674
.word 0x8045674
.word 0x80454C8 @Mental Herb
@@@@@@@@@@@@@@@Oran
.align 2
HPRestoreBerry:
mov r1, r8
mov r0, #0x58
mul r0, r7
add r2, r0, r1
ldrh r1, [r2, #0x2C]
ldrh r3, [r2, #0x28]
lsr r0, r1, #1
cmp r3, r0
bls RestoreHP
b Quit
RestoreHP:
ldrh r0, [r4]
ldr r4, =Damage
mov r5, r9
cmp r0, #Sitrus @Sitrus
bne NotZero
ldrh r0, [r2, #0x2C]
lsr r5, r0, #0x2
cmp r5, #0x0
bne NotZero
mov r5, #0x1
NotZero:
add r0, r3, r5
cmp r0, r1
ble NegDamage
sub r5, r1, r3
NegDamage:
neg r5, r5
str r5, [r4]
ldr r6, =ScriptPusher
bl Linker
ldr r1, =ScriptPointer
ldr r0, =OranHealBSLoc
str r0, [r1]
mov r0, #0x1
str r0, [sp, #0xC]
b SetupBuffersAndExit
.align 2
.pool
@@@@@@@@@@@@@@@@@@@@@@@@@@
HPRestoreConfuseBerry:
mov r0, r5
sub r0, #0xA
mov r10, r0
mov r0, #0x58
mov r1, r7
mul r1, r0
str r1, [sp, #0x18]
mov r4, r1
add r4, r8
ldrh r0, [r4, #0x2C]
ldrh r1, [r4, #0x28]
lsr r0, r0, #0x1
cmp r1, r0
bls RestoreHPAttemptConfuse
b Quit
RestoreHPAttemptConfuse:
ldr r1, =BattleOutcome
mov r0, #0xFD
strb r0, [r1]
mov r0, #0x8
strb r0, [r1, #0x1]
mov r0, r10
strb r0, [r1, #0x2]
mov r0, #0xFF
strb r0, [r1, #0x3]
ldr r5, =Damage
ldrh r0, [r4, #0x2C]
mov r1, r9
ldr r6, =Divider
bl Linker
str r0, [r5]
cmp r0, #0x0
bne NotZeroWiki
mov r0, #0x1
str r0, [r5]
NotZeroWiki:
ldrh r2, [r4, #0x28]
ldr r0, [r5]
add r0, r2, r0
ldrh r1, [r4, #0x2C]
cmp r0, r1
ble CheckConfusion
sub r0, r1, r2
str r0, [r5]
CheckConfusion:
ldr r0, [r5]
neg r0, r0
str r0, [r5]
mov r0, r8
add r0, #0x48
ldr r2, [sp, #0x18]
add r0, r2, r0
ldr r0, [r0]
mov r1, r10
ldr r6, =ConfuseAccToNature
bl Linker
lsl r0, r0, #0x10
blt BerryConfuse
ldr r6, =ScriptPusher
bl Linker
ldr r1, =ScriptPointer
ldr r0, =OranHealBSLoc
str r0, [r1]
mov r0, #0x1
str r0, [sp, #0xC]
b SetupBuffersAndExit
BerryConfuse:
ldr r6, =ScriptPusher
bl Linker
ldr r1, =ScriptPointer
ldr r0, =HealAndConfuseBSLoc
str r0, [r1]
mov r0, #0x1
str r0, [sp, #0xC]
b SetupBuffersAndExit
.align 2
.pool
@@@@@@@@@@@@@@@@@@
StatRaiseBerry:
mov r0, r5
sub r0, #0xF
mov r10, r0
mov r0, #0x58
mul r0, r7
mov r3, r8
add r5, r0, r3
ldrh r4, [r5, #0x28]
ldrh r0, [r5, #0x2C]
GluttonyCheck:
mov r2, #0x20
add r2, r2, r5
ldrb r2, [r2]
cmp r2, #GluttonyID
bne CheckPinchActivation
lsl r0, r0, #0x1
CheckPinchActivation:
mov r1, r9
ldr r6, =Divider
bl Linker
cmp r4, r0
bls CheckForContrary
b Quit
CheckForContrary:
mov r6, #0xC
cmp r2, #ContraryID
bne NoContrary_Re
mov r6, #0x0
NoContrary_Re:
mov r0, r10
add r0, #0x19
add r0, r0, r5
ldrb r0, [r0]
cmp r0, r6
bne BoostStat
b Quit
BoostStat:
ldr r1, =BattleOutcome
mov r2, #0xFD
strb r2, [r1]
mov r0, #5
strb r0, [r1, #0x1]
mov r0, r10
add r0, #0x1
strb r0, [r1, #0x2]
mov r0, #0xFF
strb r0, [r1, #0x3]
ldr r0, =TargetPartner
strb r7, [r0]
ldr r1, =MiscBufferCountersArea
mov r0, r10
add r0, #0x11
strb r0, [r1, #0x1A]
sub r0, r0, #0x2
strb r0, [r1, #0x10]
mov r0, #0x0
strb r0, [r1, #0x11]
ldr r6, =ScriptPusher
bl Linker
ldr r1, =ScriptPointer
ldr r0, =StatRaiseBSLoc
str r0, [r1]
mov r0, #0x1
str r0, [sp, #0xC]
b SetupBuffersAndExit
.align 2
.pool
@@@@@@@@@@@@@Lansat Berry:
LansatBerry:
mov r0, #0x58
mul r0, r7
mov r3, r8
add r5, r0, r3
ldrh r4, [r5, #0x28]
ldrh r0, [r5, #0x2C]
GluttonyCheck_Lansat:
mov r2, #0x20
add r2, r2, r5
ldrb r2, [r2]
cmp r2, #GluttonyID
bne CheckPinchActivation_Lansat
lsl r0, r0, #0x1
CheckPinchActivation_Lansat:
mov r1, r9
ldr r6, =Divider
bl Linker
cmp r4, r0
bls CheckFocus
b Quit
CheckFocus:
ldr r2, [r5, #0x50]
mov r3, #0x80
lsl r3, r3, #0xD
mov r0, r2
and r0, r3
cmp r0, #0x0
beq SetFocus
b Quit
SetFocus:
orr r2, r3
str r2, [r5, #0x50]
ldr r6, =ScriptPusher
bl Linker
ldr r1, =ScriptPointer
ldr r0, =FocusBerryBSLoc
str r0, [r1]
mov r0, #0x1
str r0, [sp, #0xC]
b SetupBuffersAndExit
.align 2
.pool
@@@@@@@@@@@@@@@
StarfBerry:
mov r0, #0x58
mul r0, r7
mov r3, r8
add r5, r0, r3
ldrh r4, [r5, #0x28]
ldrh r0, [r5, #0x2C]
GluttonyCheck_Starf:
mov r2, #0x20
add r2, r2, r5
ldrb r2, [r2]
cmp r2, #GluttonyID
bne CheckPinchActivation_Starf
lsl r0, r0, #0x1
CheckPinchActivation_Starf:
mov r1, r9
ldr r6, =Divider
bl Linker
cmp r4, r0
bgt Quit
CheckStats:
mov r6, #0xC
cmp r2, #ContraryID
bne NoContrary
mov r6, #0x0
NoContrary:
mov r0, #0x0
mov r10, r0
add r0, r5, #0x1
mov r1, r8
add r1, #0x18
add r0, r0, r1
ldrb r0, [r1]
lsl r0, r0, #0x18
asr r0, r0, #0x18
cmp r0, r6
bne RaisableStat
mov r0, r8
add r0, #0x19
add r1, r5, r0
Loop:
add r1, #1
add r2, #1
add r10, r2
mov r3, r10
cmp r3, #0x4
bgt Quit
ldrb r0, [r1]
cmp r0, r6
beq Loop
RaisableStat:
mov r0, #0x58
mov r0, r7
add r4, r0, r7
ldr r5, =0x202409C
mov r9, r6
StatSelect:
ldr r6, =RNG
bl Linker
lsl r0, r0, #0x10
lsr r0, r0, #0x10
mov r1, #0x5
ldr r6, =DivMod
bl Linker
lsl r0, r0, #0x10
lsr r0, r0, #0x10
mov r10, r0
add r0, r0, r4
add r0, r0, r5
ldrb r0, [r0]
lsl r0, r0, #0x18
asr r0, r0, #0x18
mov r6, r9
cmp r0, r6
beq StatSelect
BoostRandomStat:
ldr r1, =BattleOutcome
mov r2, #0xFD
strb r2, [r1]
mov r0, #5
strb r0, [r1, #0x1]
mov r0, r10
add r0, #0x1
strb r0, [r1, #0x2]
mov r0, #0xFF
strb r0, [r1, #0x3]
ldr r0, =TargetPartner
strb r7, [r0]
ldr r1, =MiscBufferCountersArea
mov r0, r10
add r0, #0x21
strb r0, [r1, #0x1A]
add r0, #6
strb r0, [r1, #0x10]
mov r0, #0x0
strb r0, [r1, #0x11]
ldr r6, =ScriptPusher
bl Linker
ldr r1, =ScriptPointer
ldr r0, =StatRaiseBSLoc
str r0, [r1]
mov r0, #0x1
str r0, [sp, #0xC]
SetupBuffersAndExit:
ldr r0, =MiscBufferCountersArea
strb r7, [r0, #0x17]
ldr r0, =Bank_F
strb r7, [r0]
ldr r4, =ActiveBank
strb r7, [r4]
Quit2:
ldr r1, =Return2
bx r1
Quit:
ldr r1, =Return
bx r1
Linker:
bx r6
.align 2
.pool
SwapBanks:
ldr r1, =UserBank
ldrb r0, [r1]
ldr r3, =Bank_F
ldrb r2, [r3]
strb r0, [r3]
strb r2, [r1]
bx lr
.align 2
.pool
@@@@OranBerryBS:
OranHealBS:
playanimation 0xA 0x7 0x0
printstring 0x12A
waitmessage 0x40
orword 0x2024280 0x100
graphicalhpupdate 0xA
datahpupdate 0xA
removeitem 0xA
return
.align 2
@@@@
HealAndConfuseBS:
playanimation 0xA 0x7 0x0
printstring 0x12A
waitmessage 0x40
orword 0x2024280 0x100
graphicalhpupdate 0xA
datahpupdate 0xA
printstring 0x144
waitmessage 0x40
callasm SwapBanks+RomAreaOffset+1
setbyte 0x2024335 0x47
seteffecttarget
callasm SwapBanks+RomAreaOffset+1
removeitem 0xA
return
@@@@
FocusBerryBS:
playanimation 0xA 0x7 0x0
printstring 0x146
waitmessage 0x40
removeitem 0xA
return
.align 2
@@@@@@@
StatRaiseBS:
playanimation 0xA 0x7 0x0
callasm SwapBanks+RomAreaOffset+1
statbuffchange 0x41 StatRaiseAnimation+RomAreaOffset
StatRaiseAnimation:
callasm SwapBanks+RomAreaOffset+1
setbyte 0x2024337 0x4
playanimation 0x2 0x1 0x2024484
printfromtable 0x85CC89C
waitmessage 0x40
removeitem 0xA
return