The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking > Binary Hack Research & Development
Reload this Page Code Ability Resource Thread

Notices
For all updates, view the main page.

Binary Hack Research & Development Got a well-founded knack with your binary Pokémon hacks? Love reverse-engineering them? For the traditional Pokémon ROM hacker, this is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!

Ad Content
Reply
 
Thread Tools
  #201   Link to this post, but load the entire thread.  
Old December 8th, 2015 (5:29 AM). Edited January 27th, 2016 by MrDollSteak.
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 28
Gender: Male
Posts: 859
Quote:
Originally Posted by pokefreak890 View Post
i have another request for abilites can u guys do ice body and magician for emerald?
Ice Body is written up at the moment but it's part of a huge set of routines so it might be a while. Magician I haven't looked into but I imagine it can go into the table that KDS did for the Life Orb thing.

So the Speed and Priority abilities are something I've had written up for awhile but since edited because of KDS and Kleenex's rewrite of the Turn Order Loader. This routine has new items included in it as well, and a few moves such as Trick Room and Tailwind.

Prankster, Gale Wings, Stall, Sand Rush, Slow Start and Quick Feet

Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global TurnOrderLoader
.org 0x14CD8

Main:
	push {r4-r7, lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	add sp, #0x04
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	mov r9, r0
	lsl r1, r1, #0x18
	lsr r1, r1, #0x18
	mov r10, r1
	mov r0, #0x0
	str r0, [sp, #0x0]

#r9=UserBank
#r10=TargetBank

CheckTurn:
	cmp r2, #0x0
	bne BracketCalc
PriorityCalc:
	mov r0, r9
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r3, r0, #0x18
	mov r8, r3
	mov r0, r10
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r4, r0, #0x18
	mov r3, r8
	cmp r3, r4
	beq BracketCalc
	cmp r3, r4
	bge Exit @FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit @SecondBankGoesFirst
BracketCalc:
	mov r0, r9
	bl BracketBL
	mov r8, r0
	mov r0, r10
	bl BracketBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	beq SpeedCalc
	cmp r3, r4
	bge Exit @FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit @SecondBankGoesFirst
SpeedCalc:
	mov r0, r9
	bl SpeedBL
	mov r8, r0
	mov r0, r10
	bl SpeedBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	bne TrickRoomCheck
	bl 0x044EC8
	mov r1, #0x1
	and r0, r1
	cmp r0,	#0x0
	bne Exit
	mov r2, #0x2 @SpeedTie
	str r2, [sp, #0x0]
	b Exit
TrickRoomCheck:
	ldr r0, .TrickRoomLoc
	ldrb r0, [r0]
	cmp r0, #0x0
	beq SpeedCheck
TrickRoom:
	mov r8, r3
	mov r3, r4
	mov r4, r8
SpeedCheck:
	cmp r3, r4
	bcs Exit @FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
Exit:
	ldr r0, [sp, #0x0]
	add sp, #0x4
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r1}
	bx r1

.align 2
.TrickRoomLoc: .word 0x02TRTRTR

.align 2

PriorityBL:
	mov r3, r0
LoadMenuChoice:
	ldr r0, .MenuChoiceLoc
	add r1, r3, r0
	mov r0, #0x0
	ldrb r1, [r1]
	cmp r1, #0x0
	bne Return
FightOptionChosen:
	ldr r0, .ProtectStructure
	lsl r1, r3, #0x4
	add r1, r1, r0
	ldrb r0, [r1]
	lsl r0, r0, #0x1D
	cmp r0, #0x0
	bge LoadMoveIndex
Struggle:
	mov r4, #0xA5
	b BufferMoveData
LoadMoveIndex:
	ldr r0, .Pointer
	ldr r0, [r0, #0x0]
	add r0, r3
	add r0, #0x80
	ldrb r0, [r0] @MoveSlotChosen
	lsl r0, r0, #0x1
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldr r1, .BattleData
	add r0, r0, r1
	ldrh r4, [r0, #0xC]
BufferMoveData:
	ldr r2, .MoveData
	lsl r0, r4, #0x1
	add r0, r0, r4
	lsl r0, r0, #0x2
	add r4, r0, r2
BufferBattleData:
	ldr r0, .BattleData
	add r0, #0x20
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldrb r1, [r0]
	mov r0, #0x0
PranksterCheck:
	cmp r1, #0x9F
	bne GaleWingsCheck
Prankster:
	ldrb r1, [r4, #0xA]
	cmp r1, #0x2
	bne LoadMovePriority
	mov r0, #0x1
	b LoadMovePriority
GaleWingsCheck:
	cmp r1, #0xB2
	bne LoadMovePriority
Galewings:
	ldrb r1, [r4, #0x2]
	cmp r1, #0x2
	bne LoadMovePriority
	mov r0, #0x1
LoadMovePriority:
	ldrb r1, [r4, #0x7]
	add r0, r0, r1
Return:
	bx lr

.align 2
.MenuChoiceLoc: .word 0x02023D7C
.ProtectStructure: .word 0x02023E8C
.Pointer: .word 0x02023FE8
.BattleData: .word 0x02023BE4
.MoveData: .word 0x08250C04

.align 2

BracketBL:
	push {lr}
	mov r3, r0
	mov r1, #0x58
	ldr r0, .BattleDataItem
	mul r1, r3
	add r4, r0, r1
CheckItem:
	ldrh r0, [r4, #0xE]
	cmp r0, #0xAF
	bne LoadItemEffect
EngimaBerry:
	ldr r1, .EnigmaRamLoc
	lsl r0, r3, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r6, [r0, #0x7]
	ldrb r5, [r0, #0x1A]
	b QuickClawCheck
LoadItemEffect:
	bl 0x9A924
	lsl r0, r0, #0x18
	lsl r6, r0, #0x18
	ldrh r0, [r4, #0xE]
	bl 0x9A948
	lsl r0, r0, #0x18
	lsl r5, r0, #0x18
QuickClawCheck:
	cmp r6, #0x1A
	bne CustapBerryCheck
QuickClawActivationCalc:
	ldr r0, .RandomLoc
	ldrh r7, [r0]
	lsl r0, r5, #0x10
	sub r0, r0, r5
	mov r1, #0x64
	bl 0x1E4018
	cmp r7, r0
	bge StallCheck
	mov r7, #0x1
	b StoreBracket
CustapBerryCheck:
	cmp r6, #0x4D
	bne LaggingTailCheck
CustapBerry:
CheckHP:
	ldrh r0, [r4, #0x8]
	ldrh r1, [r4, #0xC]
	lsl r1, r1, #0x2
	cmp r0, r1
	bgt StallCheck
SetRamLoc:
	mov r7, #0x1
	ldr r0, .CustapBerryLoc
	strb r7, [r0]
	b StoreBracket
LaggingTailCheck:
	cmp r6, #0x4A
	bne StallCheck
LaggingTail:
	mov r0, #0x2
	neg r7, r0
	b StoreBracket
StallCheck:
	mov r7, #0x0
	ldrb r0, [r4]
	cmp r0, #0x65
	bne StoreBracket
Stall:
	mov r0, #0x1
	neg r7, r0
StoreBracket:
	mov r0, r7
PopRegister:
	pop {r1}
	bx r1
	
.align 2
.BattleDataItem: .word 0x2023C04
.EnigmaRamLoc: .word 0x2023F54
.RandomLoc: .word 0x2023E80
.CustapBerryLoc: .word 0x02CCCCCC

.align 2

SpeedBL:
	push {lr}
	add sp, #-0x4
	mov r7, r0
	mov r5, #0x58
	ldr r6, .BattleData2
	mul r5, r7
	add r6, r5, r6
	mov r5, #0x1
	str r0, [sp, #0x0]
ApplyStatBoost:
	ldrh r5, [r6, #0x6]
	ldr r2, .StatModTable
	ldrb r1, [r6, #0x1B]
	lsl r1, r1, #0x1
	add r2, r1, r2
	ldrb r0, [r2]
	mul r0, r5
	ldrb r1, [r2, #0x1]
	bl 0x1E4018
	mov r5, r0
CloudNineCheck:
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0xD
	mov r3, #0x0
	bl 0x19F18
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
AirLockCheck:
	mov r0, #0x0
	str r0, [sp, #0x0] 
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0x4D
	mov r3, #0x0
	bl 0x19F18
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
LoadWeather:
	ldr r4, .WeatherLoc
	ldrh r4, [r4]
	add r2, r2, r6
	add r2, #0x20
	ldrb r2, [r2]
RainCheck:
	mov r0, #0x7
	and r0, r4
	cmp r0, #0x0
	beq SunCheck
SwiftSwimCheck:
	cmp r2, #0x21
	beq WeatherBoost
SunCheck:
	mov r0, #0x60
	and r0, r4
	cmp r0, #0x0
	beq SandstormCheck
ChlorophyllCheck:
	cmp r2, #0x22
	beq WeatherBoost
SandstormCheck:
	mov r0, #0x18
	and r0, r4
	cmp r0, #0x0
	beq NoWeather
SandRushCheck:
	cmp r2, #0x93
	bne NoWeather
WeatherBoost:
	lsl r5, r5, #0x1
NoWeather:
	mov r2, r6
	add r2, #0x20
	ldrb r2, [r2]
SlowStartCheck:
	cmp r2, #0x71
	bne TailwindCheck
	ldr r0, .SlowStartLoc
	add r0, r0, r7
CheckTurnCounter:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq TailwindCheck
	lsr r5, r5, #0x1
TailwindCheck:
	ldr r0, .TailwindAddr
	cmp r7, #0x1
	beq EnemyTailwind
	cmp r7, #0x3
	beq EnemyTailwind
PlayerTailwind:
	b CheckFlag 
EnemyTailwind:
	add r0, #0x1
CheckFlag:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq CheckItem2
	lsl r5, r5, #0x1
CheckItem2:
	ldrh r0, [r6, #0x2e]
	cmp r0, #0xAF
	bne LoadItemEffect2
EnigmaBerry2:
	ldr r1, .EnigmaRamLoc2
	lsl r0, r7, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r0, [r0, #0x7]
	b MachoBraceCheck
LoadItemEffect2:
	bl 0x9A924
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
MachoBraceCheck: 
	cmp r0, #0x18 
	bne IronBallCheck
	lsr r5, r5, #0x1
IronBallCheck:
	cmp r0, #0x47
	bne QuickPowderCheck
	lsr r5, r5, #0x1
QuickPowderCheck:
	cmp r0, #0x48
	bne ChoiceScarfCheck
	ldrh r0, [r6]
	cmp r0, #0x84
	bne ChoiceScarfCheck
	lsr r1, r5, #0x1
	add r5, r1, r5
ChoiceScarfCheck:
	cmp r0, #0x1D
	bne BadgeCheck
	bl 0x9A948
	lsl r0, r0, #0x18
	lsl r0, r0, #0x18
	cmp r0, #0x2
	bne BadgeCheck
	lsr r0, r5, #0x1
	add r5, r0, r5
BadgeCheck:
	ldr r0, .BadgeLoc
	ldr r0, [r0]
	mov r1, #0x2
	and r0, r1
	cmp r0, #0x0
	bne StatusCheck
	ldr r0, .Flag
	bl 0x6E6D0
	lsl r0, r0, #0x18
	cmp r0, #0x0
	beq StatusCheck
	mov r0, r7
	bl 0x751C4
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne StatusCheck
	mov r0, #0x6E
	mul r0, r5
	mov r1, #0x64
	bl 0x1E460C
	mov r5, r0
StatusCheck:
	ldr r0, [r6, #0x4c]
	add r6, #0x20
	ldrb r1, [r6, #0x0]
	cmp r1, #0x9B
	bne ParalysisCheck
QuickFeetCheck:
	cmp r0, #0x0
	beq ReturnSpeed
	lsl r5, r5, #0x1
	b ReturnSpeed
ParalysisCheck:
	mov r1, #0x40
	and r0, r1
	cmp r0, #0x0
	beq ReturnSpeed
	lsr r5, r5, #0x2
ReturnSpeed:
	mov r0, r5
	add sp, #0x4
	pop {r1}
	bx r1

.align 2
.BattleData2: .word 0x02023BE4
.StatModTable: .word 0x0825DEAD
.WeatherLoc: .word 0x02023F1C
.SlowStartLoc: .word 0x02SSSSSS
.TailwindAddr: .word 0x02TTTTTT
.EnigmaRamLoc2: .word 0x02023F54
.BadgeLoc: .word 0x02022B4C
.Flag: .word 0x00000822
This routine replaces the entire Turn Order calculation to make it more efficient and to work with Gyro Ball and Electro Ball. The locations for Trick Room, Custap Berry, Slow Start and Tailwind refer to free ram locations that you allocate yourself. The one for Slow Start must be the same as the other routines for the ability.

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global TurnOrderLoader
.org 0x3CF10

Main:
	push {r4-r7, lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	add sp, #-0x4
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	mov r9, r0
	lsl r1, r1, #0x18
	lsr r1, r1, #0x18
	mov r10, r1
	mov r0, #0x0
	str r0, [sp, #0x0]

#r9=UserBank
#r10=TargetBank

CheckTurn:
	cmp r2, #0x0
	bne BracketCalc
PriorityCalc:
	mov r0, r9
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r3, r0, #0x18
	mov r8, r3
	mov r0, r10
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r4, r0, #0x18
	mov r3, r8
	cmp r3, r4
	beq BracketCalc
	cmp r3, r4
	bge Exit @FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit @SecondBankGoesFirst
BracketCalc:
	mov r0, r9
	bl BracketBL
	mov r8, r0
	mov r0, r10
	bl BracketBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	beq SpeedCalc
	cmp r3, r4
	bge Exit @FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit @SecondBankGoesFirst
SpeedCalc:
	mov r0, r9
	bl SpeedBL
	mov r8, r0
	mov r0, r10
	bl SpeedBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	bne TrickRoomCheck
	bl 0x6F5CC
	mov r1, #0x1
	and r0, r1
	cmp r0,	#0x0
	bne Exit
	mov r2, #0x2 @SpeedTie
	str r2, [sp, #0x0]
	b Exit
TrickRoomCheck:
	ldr r0, .TrickRoomLoc
	ldrb r0, [r0]
	cmp r0, #0x0
	beq SpeedCheck
TrickRoom:
	mov r8, r3
	mov r3, r4
	mov r4, r8
SpeedCheck:
	cmp r3, r4
	bcs Exit @FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
Exit:
	ldr r0, [sp, #0x0]
	add sp, #0x4
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r1}
	bx r1

.align 2
.TrickRoomLoc: .word 0x02TRTRTR

.align 2

PriorityBL:
	mov r3, r0
LoadMenuChoice:
	ldr r0, .MenuChoiceLoc
	add r1, r3, r0
	mov r0, #0x0
	ldrb r1, [r1]
	cmp r1, #0x0
	bne Return
FightOptionChosen:
	ldr r0, .ProtectStructure
	lsl r1, r3, #0x4
	add r1, r1, r0
	ldrb r0, [r1]
	lsl r0, r0, #0x1D
	cmp r0, #0x0
	bge LoadMoveIndex
Struggle:
	mov r4, #0xA5
	b BufferMoveData
LoadMoveIndex:
	ldr r0, .Pointer
	ldr r0, [r0, #0x0]
	add r0, r3
	add r0, #0x80
	ldrb r0, [r0] @MoveSlotChosen
	lsl r0, r0, #0x1
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldr r1, .BattleData
	add r0, r0, r1
	ldrh r4, [r0, #0xC]
BufferMoveData:
	ldr r2, .MoveData
	lsl r0, r4, #0x1
	add r0, r0, r4
	lsl r0, r0, #0x2
	add r4, r0, r2
BufferBattleData:
	ldr r0, .BattleData
	add r0, #0x20
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldrb r1, [r0]
	mov r0, #0x0
PranksterCheck:
	cmp r1, #0x9F
	bne GaleWingsCheck
Prankster:
	ldrb r1, [r4, #0xA]
	cmp r1, #0x2
	bne LoadMovePriority
	mov r0, #0x1
	b LoadMovePriority
GaleWingsCheck:
	cmp r1, #0xB2
	bne LoadMovePriority
Galewings:
	ldrb r1, [r4, #0x2]
	cmp r1, #0x2
	bne LoadMovePriority
	mov r0, #0x1
LoadMovePriority:
	ldrb r1, [r4, #0x7]
	add r0, r0, r1
Return:
	bx lr

.align 2
.MenuChoiceLoc: .word 0x0202421C
.ProtectStructure: .word 0x0202433C
.Pointer: .word 0x0202449C
.BattleData: .word 0x02024084
.MoveData: .word 0x0831C198

.align 2

BracketBL:
	push {lr}
	mov r3, r0
	mov r1, #0x58
	ldr r0, .BattleDataItem
	mul r1, r3
	add r4, r0, r1
CheckItem:
	ldrh r0, [r4, #0xE]
	cmp r0, #0xAF
	bne LoadItemEffect
EngimaBerry:
	ldr r1, .EnigmaRamLoc
	lsl r0, r3, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r6, [r0, #0x7]
	ldrb r5, [r0, #0x1A]
	b QuickClawCheck
LoadItemEffect:
	bl 0xD74DC
	lsl r0, r0, #0x18
	lsl r6, r0, #0x18
	ldrh r0, [r4, #0xE]
	bl 0xD7500
	lsl r0, r0, #0x18
	lsl r5, r0, #0x18
QuickClawCheck:
	cmp r6, #0x1A
	bne CustapBerryCheck
QuickClawActivationCalc:
	ldr r0, .RandomLoc
	ldrh r7, [r0]
	lsl r0, r5, #0x10
	sub r0, r0, r5
	mov r1, #0x64
	bl 0x2E7540
	cmp r7, r0
	bge StallCheck
	mov r7, #0x1
	b StoreBracket
CustapBerryCheck:
	cmp r6, #0x4D
	bne LaggingTailCheck
CustapBerry:
CheckHP:
	ldrh r0, [r4, #0x8]
	ldrh r1, [r4, #0xC]
	lsl r1, r1, #0x2
	cmp r0, r1
	bgt StallCheck
SetRamLoc:
	mov r7, #0x1
	ldr r0, .CustapBerryLoc
	strb r7, [r0]
	b StoreBracket
LaggingTailCheck:
	cmp r6, #0x4A
	bne StallCheck
LaggingTail:
	mov r0, #0x2
	neg r7, r0
	b StoreBracket
StallCheck:
	mov r7, #0x0
	ldrb r0, [r4]
	cmp r0, #0x65
	bne StoreBracket
Stall:
	mov r0, #0x1
	neg r7, r0
StoreBracket:
	mov r0, r7
PopRegister:
	pop {r1}
	bx r1
	
.align 2
.BattleDataItem: .word 0x020240A4
.EnigmaRamLoc: .word 0x02024404
.RandomLoc: .word 0x02024330
.CustapBerryLoc: .word 0x02CCCCCC

.align 2

SpeedBL:
	push {lr}
	add sp, #-0x4
	mov r7, r0
	mov r5, #0x58
	ldr r6, .BattleData2
	mul r5, r7
	add r6, r5, r6
	mov r5, #0x1
	str r0, [sp, #0x0]
ApplyStatBoost:
	ldrh r5, [r6, #0x6]
	ldr r2, .StatModTable
	ldrb r1, [r6, #0x1B]
	lsl r1, r1, #0x1
	add r2, r1, r2
	ldrb r0, [r2]
	mul r0, r5
	ldrb r1, [r2, #0x1]
	bl 0x2E7540
	mov r5, r0
CloudNineCheck:
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0xD
	mov r3, #0x0
	bl 0x42828
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
AirLockCheck:
	mov r0, #0x0
	str r0, [sp, #0x0] 
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0x4D
	mov r3, #0x0
	bl 0x42828
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
LoadWeather:
	ldr r4, .WeatherLoc
	ldrh r4, [r4]
	add r2, r2, r6
	add r2, #0x20
	ldrb r2, [r2]
RainCheck:
	mov r0, #0x7
	and r0, r4
	cmp r0, #0x0
	beq SunCheck
SwiftSwimCheck:
	cmp r2, #0x21
	beq WeatherBoost
SunCheck:
	mov r0, #0x60
	and r0, r4
	cmp r0, #0x0
	beq SandstormCheck
ChlorophyllCheck:
	cmp r2, #0x22
	beq WeatherBoost
SandstormCheck:
	mov r0, #0x18
	and r0, r4
	cmp r0, #0x0
	beq NoWeather
SandRushCheck:
	cmp r2, #0x93
	bne NoWeather
WeatherBoost:
	lsl r5, r5, #0x1
NoWeather:
	mov r2, r6
	add r2, #0x20
	ldrb r2, [r2]
SlowStartCheck:
	cmp r2, #0x71
	bne TailwindCheck
	ldr r0, .SlowStartLoc
	add r0, r0, r7
CheckTurnCounter:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq TailwindCheck
	lsr r5, r5, #0x1
TailwindCheck:
	ldr r0, .TailwindAddr
	cmp r7, #0x1
	beq EnemyTailwind
	cmp r7, #0x3
	beq EnemyTailwind
PlayerTailwind:
	b CheckFlag 
EnemyTailwind:
	add r0, #0x1
CheckFlag:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq CheckItem2
	lsl r5, r5, #0x1
CheckItem2:
	ldrh r0, [r6, #0x2e]
	cmp r0, #0xAF
	bne LoadItemEffect2
EnigmaBerry2:
	ldr r1, .EnigmaRamLoc2
	lsl r0, r7, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r0, [r0, #0x7]
	b MachoBraceCheck
LoadItemEffect2:
	bl 0xD74DC
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
MachoBraceCheck: 
	cmp r0, #0x18 
	bne IronBallCheck
	lsr r5, r5, #0x1
IronBallCheck:
	cmp r0, #0x47
	bne QuickPowderCheck
	lsr r5, r5, #0x1
QuickPowderCheck:
	cmp r0, #0x48
	bne ChoiceScarfCheck
	ldrh r0, [r6]
	cmp r0, #0x84
	bne ChoiceScarfCheck
	lsr r1, r5, #0x1
	add r5, r1, r5
ChoiceScarfCheck:
	cmp r0, #0x1D
	bne BadgeCheck
	bl 0xD7500
	lsl r0, r0, #0x18
	lsl r0, r0, #0x18
	cmp r0, #0x2
	bne BadgeCheck
	lsr r0, r5, #0x1
	add r5, r0, r5
BadgeCheck:
	ldr r0, .BadgeLoc
	ldr r0, [r0]
	ldr r1, .BadgeCheck
	and r0, r1
	cmp r0, #0x0
	bne StatusCheck
	ldr r0, .Flag
	bl 0x9D790
	lsl r0, r0, #0x18
	cmp r0, #0x0
	beq StatusCheck
	mov r0, r7
	bl 0xA6A30
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne StatusCheck
	mov r0, #0x6E
	mul r0, r5
	mov r1, #0x64
	bl 0x2E7B68
	mov r5, r0
StatusCheck:
	ldr r0, [r6, #0x4c]
	add r6, #0x20
	ldrb r1, [r6, #0x0]
	cmp r1, #0x9B
	bne ParalysisCheck
QuickFeetCheck:
	cmp r0, #0x0
	beq ReturnSpeed
	lsl r5, r5, #0x1
	b ReturnSpeed
ParalysisCheck:
	mov r1, #0x40
	and r0, r1
	cmp r0, #0x0
	beq ReturnSpeed
	lsr r5, r5, #0x2
ReturnSpeed:
	mov r0, r5
	add sp, #0x4
	pop {r1}
	bx r1

.align 2
.BattleData2: .word 0x02024084
.StatModTable: .word 0x08329D2E
.WeatherLoc: .word 0x020243CC
.SlowStartLoc: .word 0x02SSSSSS
.TailwindAddr: .word 0x02TTTTTT
.EnigmaRamLoc2: .word 0x02024404
.BadgeLoc: .word 0x02022FEC
.BadgeCheck: .word 0x023F0102
.Flag: .word 0x00000868
This routine replaces the entire Turn Order calculation to make it more efficient and to work with Gyro Ball and Electro Ball. The locations for Trick Room, Custap Berry, Slow Start and Tailwind refer to free ram locations that you allocate yourself. The one for Slow Start must be the same as the other routines for the ability.

If the command mov r10, r1 at the beginning of both routines is having trouble compiling, just set it to mov r0, r1, and once its inserted in your rom, change the hex manually of that section to 8A 46. It should be at 14CEE in Fire Red or 3CF26 in Emerald.
__________________
Reply With Quote
  #202   Link to this post, but load the entire thread.  
Old December 8th, 2015 (6:38 AM). Edited December 8th, 2015 by kleenexfeu.
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by MrDollSteak View Post
Ice Body is written up at the moment but it's part of a huge set of routines so it might be a while. Magician I haven't looked into but I imagine it can go into the table that KDS did for the Life Orb thing.

So the Speed and Priority abilities are something I've had written up for awhile but since edited because of KDS and Kleenex's rewrite of the Turn Order Loader. This routine has new items included in it as well, and a few moves such as Trick Room and Tailwind.

Prankster, Gale Wings, Stall, Sand Rush, Slow Start and Quick Feet

Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global TurnOrderLoader
.org 0x14CD8

Main:
	push {r4-r7, lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	add sp, #-x04
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	mov r9, r0
	lsl r1, r1, #0x18
	lsr r1, r1, #0x18
	mov 10, r1
	mov r0, #0x0
	str r0, [sp, #0x0]

#r9=UserBank
#r10=TargetBank

CheckTurn:
	cmp r2, #0x0
	bne BracketCalc
PriorityCalc:
	mov r0, r9
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r3, r0, #0x18
	mov r8, r3
	mov r0, r10
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r4, r0 #0x18
	mov r3, r8
	cmp r3, r4
	beq BracketCalc
	cmp r3, r4
	bge Exit #FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit #SecondBankGoesFirst
BracketCalc:
	mov r0, r9
	bl BracketBL
	mov r8, r0
	mov r0, r10
	bl BracketBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	beq SpeedCalc
	cmp r3, r4
	bge Exit #FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit #SecondBankGoesFirst
SpeedCalc:
	mov r0, r9
	bl SpeedBL
	mov r8, r0
	mov r0, r10
	bl SpeedBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	bne TrickRoomCheck
	bl 0x08044EC8
	mov r1, #0x1
	and r0, r1
	cmp r0,	#0x0
	bne Exit
	mov r2, #0x2 #SpeedTie
	str r2, [sp, #0x0]
	b Exit
TrickRoomCheck:
	ldr r0, .TrickRoomLoc
	ldrb r0, [r0]
	cmp r0, #0x0
	beq SpeedCheck
TrickRoom:
	mov r8, r3
	mov r3, r4
	mov r4, r8
SpeedCheck:
	cmp r3, r4
	bcs Exit #FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
Exit:
	ldr r0, [sp, #0x0]
	add sp, #0x4
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r1}
	bx r1

.align 2
.TrickRoomLoc: .word 0x02TRTRTR

.align 2

PriorityBL:
	mov r3, r0
LoadMenuChoice:
	ldr r0, .MenuChoiceLoc
	add r1, r3, r0
	mov r0, #0x0
	ldrb r1, [r1]
	cmp r1, #0x0
	bne Return
FightOptionChosen:
	ldr r0, .ProtectStructure
	lsl r1, r3, #0x4
	add r1, r1, r0
	ldrb r0, [r1]
	lsl r0, r0, #0x1D
	cmp r0, #0x0
	bge LoadMoveIndex
Struggle:
	mov r4, #0xA5
	b BufferMoveData
LoadMoveIndex:
	ldr r0, .Pointer
	ldr r0, [r0, #0x0]
	add r0, r3
	add r0, #0x80
	ldrb r0, [r0] @MoveSlotChosen
	lsl r0, r0, #0x1
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldr r1, .BattleData
	add r0, r0, r1
	ldrh r4, [r0, #0xC]
BufferMoveData:
	ldr r2, .MoveData
	lsl r0, r4, #0x1
	add r0, r0, r4
	lsl r0, r0, #0x2
	add r4, r0, r2
BufferMoveData:
	ldr r0, .BattleData
	add r0, #0x20
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldrb r1, [r0]
	mov r0, #0x0
PranksterCheck:
	cmp r1, #0x9F
	bne GaleWingsCheck
Prankster:
	ldrb r1, [r4, #0xA]
	bne LoadMovePriority
	cmp r1, #0x2
	mov r0, #0x1
	b LoadMovePriority
GaleWingsCheck:
	cmp r1, #0xB2
	bne LoadMovePriority
Galewings:
	ldrb r1, [r4, #0x2]
	cmp r1, #0x2
	bne LoadMovePriority
	mov r0, #0x1
	b LoadMovePriority
LoadMovePriority:
	ldrb r1, [r4, #0x7]
	add r0, r0, r1
Return:
	bx lr

.align 2
.MenuChoiceLoc: .word 0x02023D7C
.ProtectStructure: .word 0x02023E8C
.Pointer: .word 0x02023FE8
.BattleData: .word 0x02023BE4
.MoveData: .word 0x08250C04

.align 2

BracketBL:
	push {lr}
	mov r3, r0
	mov r1, #0x58
	ldr r0, .BattleDataItem
	mul r1, r3
	add r4, r0, r1
CheckItem:
	ldrh r0, [r4, #0xE]
	cmp r0, #0xAF
	bne LoadItemEffect
EngimaBerry:
	ldr r1, .EnigmaRamLoc
	lsl r0, r3, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r6, [r0, #0x7]
	ldrb r5, [r0, #0x1A]
	b QuickClawCheck
LoadItemEffect:
	bl 0x0809A924
	lsl r0, r0, #0x18
	lsl r6, r0, #0x18
	ldrh r0, [r4, #0xE]
	bl 0x0809A948
	lsl r0, r0, #0x18
	lsl r5, r0 #0x18
QuickClawCheck:
	cmp r6, #0x1A
	bne CustapBerryCheck
QuickClawActivationCalc:
	ldr r0, .RandomLoc
	ldrh r7, [r0]
	lsl r0, r5, #0x10
	sub r0, r0, r5
	mov r1, #0x64
	bl 0x081E4018
	cmp r7, r0
	bge StallCheck
	mov r7, #0x1
	b StoreBracket
CustapBerryCheck:
	cmp r6, #0x4D
	bne LaggingTailCheck
CustapBerry:
CheckHP:
	ldrh r0, [r4, #0x8]
	ldrh r1, [r4, #0xC]
	lsl r1, r1, #0x2
	cmp r0, r1
	bgt StallCheck
SetRamLoc:
	mov r7, #0x1
	ldr r0, .CustapBerryLoc
	strb r7, [r0]
	b StoreBracket
LaggingTailCheck:
	cmp r6, #0x4A
	bne StallCheck
LaggingTail:
	mov r0, #0x2
	neg r7, r0
	b StoreBracket
StallCheck:
	mov r7, #0x0
	ldrb r0, [r4]
	cmp r0, #0x65
	bne StoreBracket
Stall:
	mov r0, #0x1
	neg r7, r0
StoreBracket:
	mov r0, r7
PopRegister:
	pop {r1}
	bx r1
	
.align 2
.BattleDataItem: .word 0x2023C04
.EnigmaRamLoc: .word 0x2023F54
.RandomLoc: .word 0x2023E80
.CustapBerryLoc: .word 0x02CCCCCC

.align 2

SpeedBL:
	push {lr}
	add sp, #-0x4
	mov r7, r0
	mov r5, #0x58
	ldr r6, .BattleData2
	mul r5, r7
	add r6, r5, r6
	mov r5, #0x1
	str r0, [sp, #0x0]
ApplyStatBoost:
	ldrh r5, [r6, #0x6]
	ldr r2, .StatModTable
	ldrb r1, [r6, #0x1B]
	lsl r1, r1, #0x1
	add r2, r1, r2
	ldrb r0, [r2]
	mul r0, r5
	ldrb r1, [r2, #0x1]
	bl 0x1E4018
	mov r5, r0
CloudNineCheck:
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0xD
	mov r3, #0x0
	bl 0x19F18
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
AirLockCheck:
	mov r0, #0x0
	str r0, [sp, #0x0] 
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0x4D
	mov r3, #0x0
	bl 0x19F18
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
LoadWeather:
	ldr r4, .WeatherLoc
	ldrh r4, [r4]
	add r2, r2, r6
	add r2, #0x20
	ldrb r2, [r2]
RainCheck:
	mov r0, #0x7
	and r0, r4
	cmp r0, #0x0
	beq SunCheck
SwiftSwimCheck:
	cmp r2, #0x21
	beq WeatherBoost
SunCheck:
	mov r0, #0x60
	and r0, r4
	cmp r0, #0x0
	beq SandstormCheck
ChlorophyllCheck:
	cmp r2, #0x22
	beq WeatherBoost
SandstormCheck:
	mov r0, #0x18
	and r0, r4
	cmp r0, #0x0
	beq NoWeather
SandRushCheck:
	cmp r2, #0x93
	bne NoWeather
WeatherBoost:
	lsl r5, r5, #0x1
NoWeather:
	mov r2, r6
	add r2, #0x20
	ldrb r2, [r2]
SlowStartCheck:
	cmp r2, #0x71
	bne TailwindCheck
	ldr r0, .SlowStartLoc
	add r0, r0, r7
CheckTurnCounter:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq EndSlowStart
	lsr r5, r5, #0x1
TailwindCheck:
	ldr r0, .TailwindAddr
	cmp r7, #0x1
	beq EnemyTailwind
	cmp r7, #0x3
	beq EnemyTailwind
PlayerTailwind:
	b CheckFlag 
EnemyTailwind:
	add r0, #0x1
CheckFlag:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq LoadItem
	lsl r5, r5, #0x1
CheckItem2:
	ldrh r0, [r6, #0x2e]
	cmp r0, #0xAF
	bne LoadItemEffect2
EnigmaBerry2:
	ldr r1, .EnigmaRamLoc2
	lsl r0, r7, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r0, [r0, #0x7]
	b MachoBraceCheck
LoadItemEffect2:
	bl 0x09A924
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
MachoBraceCheck: 
	cmp r0, #0x18 
	bne IronBallCheck
	lsr r5, r5, #0x1
IronBallCheck:
	cmp r0, #0x47
	bne QuickPowderCheck
	lsr r5, r5, #0x1
QuickPowderCheck:
	cmp r0, #0x48
	bne ChoiceScarfCheck
	ldrh r0, [r6]
	cmp r0, #0x84
	bne ChoiceScarfCheck
	lsr r1, r5, #0x1
	add r5, r1, r5
ChoiceScarfCheck:
	cmp r0, #0x1D
	bne BadgeCheck
	bl 0x0809A948
	lsl r0, r0, #0x18
	lsl r0, r0 #0x18
	cmp r0, #0x2
	bne BadgeCheck
	lsr r0, r5, #0x1
	add r5, r0, r5
BadgeCheck:
	ldr r0, .BadgeLoc
	ldr r0, [r0]
	mov r1, #0x2
	and r0, r1
	cmp r0, #0x0
	bne StatusCheck
	ldr r0, .Flag
	bl 0x6E6D0
	lsl r0, r0, #0x18
	cmp r0, #0x0
	beq StatusCheck
	mov r0, r7
	bl 0x751C4
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne StatusCheck
	mov r0, #0x6E
	mul r0, r5
	mov r1, #0x64
	bl 0x1E460C
	mov r5, r0
StatusCheck:
	ldr r0, [r6, #0x4c]
	add r6, #0x20
	ldrb r1, [r6, #0x0]
	cmp r1, #0x9B
	bne ParalysisCheck
QuickFeetCheck:
	cmp r0, #0x0
	beq ReturnSpeed
	lsl r5, r5, #0x1
	b ReturnSpeed
ParalysisCheck:
	mov r1, #0x40
	and r0, r1
	cmp r0, #0x0
	beq ReturnSpeed
	lsr r5, r5, #0x2
ReturnSpeed:
	mov r0, r5
	add sp, #0x4
	pop {r1}
	bx r1

.align 2
.BattleData2: .word 0x02023BE4
.StatModTable: .word 0x0825DEAD
.WeatherLoc: .word 0x02023F1C
.SlowStartLoc: .word 0x02SSSSSS
.TailwindAddr: .word 0x02TTTTTT
.EnigmaRamLoc: .word 0x02023F54
.BadgeLoc: .word 0x02022B4C
.Flag: .word 0x00000822
This routine replaces the entire Turn Order calculation to make it more efficient and to work with Gyro Ball and Electro Ball. The locations for Trick Room, Custap Berry, Slow Start and Tailwind refer to free ram locations that you allocate yourself. The one for Slow Start must be the same as the other routines for the ability.

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global TurnOrderLoader
.org 0x3CF10

Main:
	push {r4-r7, lr}
	mov r7, r10
	mov r6, r9
	mov r5, r8
	push {r5-r7}
	add sp, #-x04
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
	mov r9, r0
	lsl r1, r1, #0x18
	lsr r1, r1, #0x18
	mov 10, r1
	mov r0, #0x0
	str r0, [sp, #0x0]

#r9=UserBank
#r10=TargetBank

CheckTurn:
	cmp r2, #0x0
	bne BracketCalc
PriorityCalc:
	mov r0, r9
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r3, r0, #0x18
	mov r8, r3
	mov r0, r10
	bl PriorityBL
	lsl r0, r0, #0x18
	asr r4, r0 #0x18
	mov r3, r8
	cmp r3, r4
	beq BracketCalc
	cmp r3, r4
	bge Exit #FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit #SecondBankGoesFirst
BracketCalc:
	mov r0, r9
	bl BracketBL
	mov r8, r0
	mov r0, r10
	bl BracketBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	beq SpeedCalc
	cmp r3, r4
	bge Exit #FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
	b Exit #SecondBankGoesFirst
SpeedCalc:
	mov r0, r9
	bl SpeedBL
	mov r8, r0
	mov r0, r10
	bl SpeedBL
	mov r4, r0
	mov r3, r8
	cmp r3, r4
	bne TrickRoomCheck
	bl 0x0806F5CC
	mov r1, #0x1
	and r0, r1
	cmp r0,	#0x0
	bne Exit
	mov r2, #0x2 #SpeedTie
	str r2, [sp, #0x0]
	b Exit
TrickRoomCheck:
	ldr r0, .TrickRoomLoc
	ldrb r0, [r0]
	cmp r0, #0x0
	beq SpeedCheck
TrickRoom:
	mov r8, r3
	mov r3, r4
	mov r4, r8
SpeedCheck:
	cmp r3, r4
	bcs Exit #FirstBankGoesFirst
	mov r2, #0x1
	str r2, [sp, #0x0]
Exit:
	ldr r0, [sp, #0x0]
	add sp, #0x4
	pop {r3-r5}
	mov r8, r3
	mov r9, r4
	mov r10, r5
	pop {r4-r7}
	pop {r1}
	bx r1

.align 2
.TrickRoomLoc: .word 0x02TRTRTR

.align 2

PriorityBL:
	mov r3, r0
LoadMenuChoice:
	ldr r0, .MenuChoiceLoc
	add r1, r3, r0
	mov r0, #0x0
	ldrb r1, [r1]
	cmp r1, #0x0
	bne Return
FightOptionChosen:
	ldr r0, .ProtectStructure
	lsl r1, r3, #0x4
	add r1, r1, r0
	ldrb r0, [r1]
	lsl r0, r0, #0x1D
	cmp r0, #0x0
	bge LoadMoveIndex
Struggle:
	mov r4, #0xA5
	b BufferMoveData
LoadMoveIndex:
	ldr r0, .Pointer
	ldr r0, [r0, #0x0]
	add r0, r3
	add r0, #0x80
	ldrb r0, [r0] @MoveSlotChosen
	lsl r0, r0, #0x1
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldr r1, .BattleData
	add r0, r0, r1
	ldrh r4, [r0, #0xC]
BufferMoveData:
	ldr r2, .MoveData
	lsl r0, r4, #0x1
	add r0, r0, r4
	lsl r0, r0, #0x2
	add r4, r0, r2
BufferMoveData:
	ldr r0, .BattleData
	add r0, #0x20
	mov r1, #0x58
	mul r1, r3
	add r0, r0, r1
	ldrb r1, [r0]
	mov r0, #0x0
PranksterCheck:
	cmp r1, #0x9F
	bne GaleWingsCheck
Prankster:
	ldrb r1, [r4, #0xA]
	bne LoadMovePriority
	cmp r1, #0x2
	mov r0, #0x1
	b LoadMovePriority
GaleWingsCheck:
	cmp r1, #0xB2
	bne LoadMovePriority
Galewings:
	ldrb r1, [r4, #0x2]
	cmp r1, #0x2
	bne LoadMovePriority
	mov r0, #0x1
	b LoadMovePriority
LoadMovePriority:
	ldrb r1, [r4, #0x7]
	add r0, r0, r1
Return:
	bx lr

.align 2
.MenuChoiceLoc: .word 0x0202421C
.ProtectStructure: .word 0x0202433C
.Pointer: .word 0x0202449C
.BattleData: .word 0x02024084
.MoveData: .word 0x0831C198

.align 2

BracketBL:
	push {lr}
	mov r3, r0
	mov r1, #0x58
	ldr r0, .BattleDataItem
	mul r1, r3
	add r4, r0, r1
CheckItem:
	ldrh r0, [r4, #0xE]
	cmp r0, #0xAF
	bne LoadItemEffect
EngimaBerry:
	ldr r1, .EnigmaRamLoc
	lsl r0, r3, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r6, [r0, #0x7]
	ldrb r5, [r0, #0x1A]
	b QuickClawCheck
LoadItemEffect:
	bl 0x080D74DC
	lsl r0, r0, #0x18
	lsl r6, r0, #0x18
	ldrh r0, [r4, #0xE]
	bl 0x080D7500
	lsl r0, r0, #0x18
	lsl r5, r0 #0x18
QuickClawCheck:
	cmp r6, #0x1A
	bne CustapBerryCheck
QuickClawActivationCalc:
	ldr r0, .RandomLoc
	ldrh r7, [r0]
	lsl r0, r5, #0x10
	sub r0, r0, r5
	mov r1, #0x64
	bl 0x082E7540
	cmp r7, r0
	bge StallCheck
	mov r7, #0x1
	b StoreBracket
CustapBerryCheck:
	cmp r6, #0x4D
	bne LaggingTailCheck
CustapBerry:
CheckHP:
	ldrh r0, [r4, #0x8]
	ldrh r1, [r4, #0xC]
	lsl r1, r1, #0x2
	cmp r0, r1
	bgt StallCheck
SetRamLoc:
	mov r7, #0x1
	ldr r0, .CustapBerryLoc
	strb r7, [r0]
	b StoreBracket
LaggingTailCheck:
	cmp r6, #0x4A
	bne StallCheck
LaggingTail:
	mov r0, #0x2
	neg r7, r0
	b StoreBracket
StallCheck:
	mov r7, #0x0
	ldrb r0, [r4]
	cmp r0, #0x65
	bne StoreBracket
Stall:
	mov r0, #0x1
	neg r7, r0
StoreBracket:
	mov r0, r7
PopRegister:
	pop {r1}
	bx r1
	
.align 2
.BattleDataItem: .word 0x020240A4
.EnigmaRamLoc: .word 0x02024404
.RandomLoc: .word 0x02024330
.CustapBerryLoc: .word 0x02CCCCCC

.align 2

SpeedBL:
	push {lr}
	add sp, #-0x4
	mov r7, r0
	mov r5, #0x58
	ldr r6, .BattleData2
	mul r5, r7
	add r6, r5, r6
	mov r5, #0x1
	str r0, [sp, #0x0]
ApplyStatBoost:
	ldrh r5, [r6, #0x6]
	ldr r2, .StatModTable
	ldrb r1, [r6, #0x1B]
	lsl r1, r1, #0x1
	add r2, r1, r2
	ldrb r0, [r2]
	mul r0, r5
	ldrb r1, [r2, #0x1]
	bl 0x2E7540
	mov r5, r0
CloudNineCheck:
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0xD
	mov r3, #0x0
	bl 0x42828
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
AirLockCheck:
	mov r0, #0x0
	str r0, [sp, #0x0] 
	mov r0, #0x13
	mov r1, #0x0
	mov r2, #0x4D
	mov r3, #0x0
	bl 0x42828
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne NoWeather
LoadWeather:
	ldr r4, .WeatherLoc
	ldrh r4, [r4]
	add r2, r2, r6
	add r2, #0x20
	ldrb r2, [r2]
RainCheck:
	mov r0, #0x7
	and r0, r4
	cmp r0, #0x0
	beq SunCheck
SwiftSwimCheck:
	cmp r2, #0x21
	beq WeatherBoost
SunCheck:
	mov r0, #0x60
	and r0, r4
	cmp r0, #0x0
	beq SandstormCheck
ChlorophyllCheck:
	cmp r2, #0x22
	beq WeatherBoost
SandstormCheck:
	mov r0, #0x18
	and r0, r4
	cmp r0, #0x0
	beq NoWeather
SandRushCheck:
	cmp r2, #0x93
	bne NoWeather
WeatherBoost:
	lsl r5, r5, #0x1
NoWeather:
	mov r2, r6
	add r2, #0x20
	ldrb r2, [r2]
SlowStartCheck:
	cmp r2, #0x71
	bne TailwindCheck
	ldr r0, .SlowStartLoc
	add r0, r0, r7
CheckTurnCounter:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq EndSlowStart
	lsr r5, r5, #0x1
TailwindCheck:
	ldr r0, .TailwindAddr
	cmp r7, #0x1
	beq EnemyTailwind
	cmp r7, #0x3
	beq EnemyTailwind
PlayerTailwind:
	b CheckFlag 
EnemyTailwind:
	add r0, #0x1
CheckFlag:
	ldrb r0, [r0, #0x0]
	cmp r0, #0x0
	beq LoadItem
	lsl r5, r5, #0x1
CheckItem2:
	ldrh r0, [r6, #0x2e]
	cmp r0, #0xAF
	bne LoadItemEffect2
EnigmaBerry2:
	ldr r1, .EnigmaRamLoc2
	lsl r0, r7, #0x3
	sub r0, r0, r3
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldrb r0, [r0, #0x7]
	b MachoBraceCheck
LoadItemEffect2:
	bl 0x0D74DC
	lsl r0, r0, #0x18
	lsr r0, r0, #0x18
MachoBraceCheck: 
	cmp r0, #0x18 
	bne IronBallCheck
	lsr r5, r5, #0x1
IronBallCheck:
	cmp r0, #0x47
	bne QuickPowderCheck
	lsr r5, r5, #0x1
QuickPowderCheck:
	cmp r0, #0x48
	bne ChoiceScarfCheck
	ldrh r0, [r6]
	cmp r0, #0x84
	bne ChoiceScarfCheck
	lsr r1, r5, #0x1
	add r5, r1, r5
ChoiceScarfCheck:
	cmp r0, #0x1D
	bne BadgeCheck
	bl 0x080D7500
	lsl r0, r0, #0x18
	lsl r0, r0 #0x18
	cmp r0, #0x2
	bne BadgeCheck
	lsr r0, r5, #0x1
	add r5, r0, r5
BadgeCheck:
	ldr r0, .BadgeLoc
	ldr r0, [r0]
	ldr r1, .BadgeCheck
	and r0, r1
	cmp r0, #0x0
	bne StatusCheck
	ldr r0, .Flag
	bl 0x9D790
	lsl r0, r0, #0x18
	cmp r0, #0x0
	beq StatusCheck
	mov r0, r7
	bl 0xA6A30
	lsl r0, r0, #0x18
	cmp r0, #0x0
	bne StatusCheck
	mov r0, #0x6E
	mul r0, r5
	mov r1, #0x64
	bl 0x2E7B68
	mov r5, r0
StatusCheck:
	ldr r0, [r6, #0x4c]
	add r6, #0x20
	ldrb r1, [r6, #0x0]
	cmp r1, #0x9B
	bne ParalysisCheck
QuickFeetCheck:
	cmp r0, #0x0
	beq ReturnSpeed
	lsl r5, r5, #0x1
	b ReturnSpeed
ParalysisCheck:
	mov r1, #0x40
	and r0, r1
	cmp r0, #0x0
	beq ReturnSpeed
	lsr r5, r5, #0x2
ReturnSpeed:
	mov r0, r5
	add sp, #0x4
	pop {r1}
	bx r1

.align 2
.BattleData2: .word 0x02024084
.StatModTable: .word 0x08329D2E
.WeatherLoc: .word 0x020243CC
.SlowStartLoc: .word 0x02SSSSSS
.TailwindAddr: .word 0x02TTTTTT
.EnigmaRamLoc: .word 0x02024404
.BadgeLoc: .word 0x02022FEC
.BadgeCheck: .word 0x023F0102
.Flag: .word 0x00000868
This routine replaces the entire Turn Order calculation to make it more efficient and to work with Gyro Ball and Electro Ball. The locations for Trick Room, Custap Berry, Slow Start and Tailwind refer to free ram locations that you allocate yourself. The one for Slow Start must be the same as the other routines for the ability.
Little thing to note, you miss the fact that there might be more than one poke with slow start.
You can use 2 bytes instead of one, and use 3 bits for each bank, to code the five turns.

Other than that, looks great!

EDIT : My bad, I guess r7 is the bank. Well, you can still use 2 bytes instead of 4.

Also, I don't see where you decrease the counter for slow start, will it be in the end turn routine maybe ?
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #203   Link to this post, but load the entire thread.  
Old December 8th, 2015 (6:42 AM). Edited December 8th, 2015 by MrDollSteak.
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 28
Gender: Male
Posts: 859
Quote:
Originally Posted by kleenexfeu View Post
Little thing to note, you miss the fact that there might be more than one poke with slow start.
You can use 2 bytes instead of one, and use 3 bits for each bank, to code the five turns.

Other than that, looks great!
What? No I don't. The routine is called for each banked pokemon. It adds the bank. So far I'm using 4 bytes, one for each of the banks.

EDIT: Yes it will be in a separate routine. So far it uses 4. One when the pokemon enters that sets the routine, counter decrease, then the attack and speed reductions.
I haven't posted the enter or end of turn routines yet because there are so many haha! Also KDS rewrote the enter routines to be a bit better so I am yet to completely redo them to match his new system. The counter decrease routines are going to be very annoying because there are so many new moves and abilities with counters.
__________________
Reply With Quote
  #204   Link to this post, but load the entire thread.  
Old December 8th, 2015 (10:45 AM).
pokefreak890's Avatar
pokefreak890 pokefreak890 is offline
The One that will make everything great
 
Join Date: Nov 2014
Gender: Male
Posts: 853
Oh i see well cant wait to see ice body and sorry to request again on the same day but do u have download and cursed body?
__________________
3DS FREIND CODE : 2724-3540-0898
Reply With Quote
  #205   Link to this post, but load the entire thread.  
Old December 8th, 2015 (12:30 PM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by pokefreak890 View Post
Oh i see well cant wait to see ice body and sorry to request again on the same day but do u have download and cursed body?
Every ability will be done at some point.
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #206   Link to this post, but load the entire thread.  
Old December 9th, 2015 (12:20 AM).
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 28
Gender: Male
Posts: 859
Quote:
Originally Posted by pokefreak890 View Post
Oh i see well cant wait to see ice body and sorry to request again on the same day but do u have download and cursed body?
Download and Cursed body are in a similar boat to Ice Body. They're both part of huge routines with lots of pre requisites, namely entry and contact abilities.
__________________
Reply With Quote
  #207   Link to this post, but load the entire thread.  
Old December 9th, 2015 (1:41 PM).
azurile13 azurile13 is offline
 
Join Date: Mar 2015
Posts: 417
This slightly off topic question is mostly directed at MrDollSteak/KDS/kleenexfeu based on number of contributions to this thread, though anyone can reply. Do any of you have a very detailed idb with a strong focus on the battle engine that you’d be willing to share? I get annoyed by adding a ton of little hooks here and there within a single routine/ also wanted to research battling in general, so I was going through the routines from which some of your hooks originate. I was plowing through the damage multiplier section with relative ease, throwing in easy additions like new ability and item multipliers. I thought I was making quick progress until I bumped into the horrendous ability_somethingeverything routine. There is (so far) no specific part of it that is terribly difficult to understand, but the sheer size makes me want to cry. Also, I’m guessing that I’m wasting my time as it seems likely that at least one of you has already documented these horrendous 7.3 kilobytes. I understand if you’d prefer not to, but if you’d be willing to share you research, I’d be very grateful :D
Reply With Quote
  #208   Link to this post, but load the entire thread.  
Old December 9th, 2015 (4:32 PM). Edited December 10th, 2015 by Spherical Ice.
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
I've update my signature, you can find a link on my IDB, I wouldn't call it a "strong focus on the battle engine" but it's still something, I guess.

For battlestuffs, look in the name windows, the labels with check_something, or battle_something.

There are others labels I used but I don't have them all on the top of my head.

Also, it's emerald, not FR, but the battle engines are praticly the same (not completly though).



I don't know why we didn't do that earlier : I think it should be linked in the OP, in case people want to see/help.
Perhaps KDS has a better documentation, he seems far more organised than I am x)

Hope it'll help
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #209   Link to this post, but load the entire thread.  
Old December 9th, 2015 (5:12 PM).
azurile13 azurile13 is offline
 
Join Date: Mar 2015
Posts: 417
:D THANK YOU
Even though it is Emerald :P
I agree that it would be a useful link in the OP and could encourage more people to contribute.
Reply With Quote
  #210   Link to this post, but load the entire thread.  
Old December 10th, 2015 (1:26 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by azurile13 View Post
I thought I was making quick progress until I bumped into the horrendous ability_somethingeverything routine. There is (so far) no specific part of it that is terribly difficult to understand, but the sheer size makes me want to cry. Also, I’m guessing that I’m wasting my time as it seems likely that at least one of you has already documented these horrendous 7.3 kilobytes. I understand if you’d prefer not to, but if you’d be willing to share you research, I’d be very grateful :D
Actually, this routine is a collection of around 18 different sections. The table which contains pointers to different sections is located at x1a0dc (FR). Each section has different purpose i.e one is for switchin abilities, one for contact, one for end turn abilities, etc. This routine is referenced from different locations for different purposes using r0 as a parameter to execute different section of this routine.
Reply With Quote
  #211   Link to this post, but load the entire thread.  
Old December 11th, 2015 (4:18 PM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by MrDollSteak View Post
What? No I don't. The routine is called for each banked pokemon. It adds the bank. So far I'm using 4 bytes, one for each of the banks.

EDIT: Yes it will be in a separate routine. So far it uses 4. One when the pokemon enters that sets the routine, counter decrease, then the attack and speed reductions.
I haven't posted the enter or end of turn routines yet because there are so many haha! Also KDS rewrote the enter routines to be a bit better so I am yet to completely redo them to match his new system. The counter decrease routines are going to be very annoying because there are so many new moves and abilities with counters.
This message is addressed both to MrDS and KDS, is the switch-in system on the first page up to date ?

Because I made one myself, using more or less the same principle, except I hooked at the same place than weathers abilities. It has the advantage tu support mega evolution without having the call different parts of ability_something.
Indeed after the mega evo, I call ability_something with r0 = 0 (for switch in), and it's the same for role play/trace etc.
It also support custom messages etc.
With that I've made of the switch-in abilities (I think) : mold breaker, pressure and auras messages, download, imposter, updated weathers (snow warning, mega primal, drizzle/drought/sand stream)

So, my point here is to ask, did I forgot something apart from the counter for slow start ?
And, what system do you use for switch-in ? To see which one we should use
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #212   Link to this post, but load the entire thread.  
Old December 11th, 2015 (8:40 PM).
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 28
Gender: Male
Posts: 859
Quote:
Originally Posted by kleenexfeu View Post
This message is addressed both to MrDS and KDS, is the switch-in system on the first page up to date ?

Because I made one myself, using more or less the same principle, except I hooked at the same place than weathers abilities. It has the advantage tu support mega evolution without having the call different parts of ability_something.
Indeed after the mega evo, I call ability_something with r0 = 0 (for switch in), and it's the same for role play/trace etc.
It also support custom messages etc.
With that I've made of the switch-in abilities (I think) : mold breaker, pressure and auras messages, download, imposter, updated weathers (snow warning, mega primal, drizzle/drought/sand stream)

So, my point here is to ask, did I forgot something apart from the counter for slow start ?
And, what system do you use for switch-in ? To see which one we should use
The one KDS posted is the most recent one yes. It's the one I would recommend as it fixes intimidate though I guess you could handle that separately.

The full list of abilities discounting weather afaik are:
2E - Pressure entry Message
59 - Download
69 - Mold Breaker entry Message
6C - Anticipation
6D - Forewarn
71 - Slow Start counter set and entry message
78 - Frisk
80 - Unnerve entry Message
97 - Imposter
A4 - Turboblaze entry Message
A5 - Teravolt entry Message
BB - Dark Aura entry Message
BC - Fairy Aura entry Message
BD - Aura Break entry Message

I've done Anticipation and Forewarn on my old system as well as the ones you've mentioned. I've done the Slow Start one too. I have some code for Frisk working but I couldn't get it to cycle through the battle script twice for Double Battles, though KDS has explained a bit better how to do that.
__________________
Reply With Quote
  #213   Link to this post, but load the entire thread.  
Old December 12th, 2015 (1:09 AM).
azurile13 azurile13 is offline
 
Join Date: Mar 2015
Posts: 417
Quote:
Originally Posted by KDS View Post
Actually, this routine is a collection of around 18 different sections. The table which contains pointers to different sections is located at x1a0dc (FR). Each section has different purpose i.e one is for switchin abilities, one for contact, one for end turn abilities, etc. This routine is referenced from different locations for different purposes using r0 as a parameter to execute different section of this routine.
Yep, I saw the jumptable and knizz pointed out the "huge switch,", but after going through the first case, I had posted my requests in hopes that I wouldn't have to read the rest of them >_<
Reply With Quote
  #214   Link to this post, but load the entire thread.  
Old December 14th, 2015 (9:43 AM).
Xencleamas's Avatar
Xencleamas Xencleamas is offline
Suddenly lurking in the shadows...
 
Join Date: Feb 2014
Gender: Male
Nature: Adamant
Posts: 456
Quote:
Originally Posted by MrDollSteak View Post
Prankster, Gale Wings, Stall, Sand Rush, Slow Start and Quick Feet
Line 14: add sp, #-x04?
Line 20: mov 10, r1. Is it r10 for real?
Line 39: Forgotten the comma between r0 and #0x18
Line 73: Branch out of range
Line 150: Another BufferMoveData? I guess should it be BufferBattleData or what?
Line 212: Branch out of range
Line 216: Branch out of range
Line 218: Forgotten the comma between r0 and #0x18
Line 228: Branch out of range
Line 414: Branch out of range
Line 416: Forgotten the comma between r0 and #0x18
Line 472: Is it actually EnigmaRamLoc2?
__________________
Reply With Quote
  #215   Link to this post, but load the entire thread.  
Old December 14th, 2015 (11:10 AM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by Sky High View Post
Line 14: add sp, #-x04? used to save some data sometimes
Line 20: mov 10, r1. Is it r10 for real? Yeah, why not ?
Line 39: Forgotten the comma between r0 and #0x18
Line 73: Branch out of range
Line 150: Another BufferMoveData? I guess should it be BufferBattleData or what?
Line 212: Branch out of range
Line 216: Branch out of range
Line 218: Forgotten the comma between r0 and #0x18
Line 228: Branch out of range
Line 414: Branch out of range
Line 416: Forgotten the comma between r0 and #0x18
Line 472: Is it actually EnigmaRamLoc2? Yeah, enigma is actually a placeholder for other items or berries, in link or some stuff like that
Some responses in bold red
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #216   Link to this post, but load the entire thread.  
Old December 24th, 2015 (12:27 PM).
Exodrake's Avatar
Exodrake Exodrake is offline
The Manliest Chick that Ever Manlied
 
Join Date: May 2013
Age: 29
Gender: Female
Nature: Quirky
Posts: 163
Is anybody currently researching Anger Point? This ability is one that I am eager to implement in my hack. Not trying to be pushy or anything, I'm just curious if there's any progress on this ability. :)
__________________

I'M A WITCH THAT'S HOW
Reply With Quote
  #217   Link to this post, but load the entire thread.  
Old December 24th, 2015 (1:28 PM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by Exodrake View Post
Is anybody currently researching Anger Point? This ability is one that I am eager to implement in my hack. Not trying to be pushy or anything, I'm just curious if there's any progress on this ability. :)
Fairly easy to implement. It requires to expand the table at x1a848 and write small amount of code for it. If you're using MrDS's rombase, then I think the table routine and the table have been changed so you might need to account for that.
Reply With Quote
  #218   Link to this post, but load the entire thread.  
Old December 24th, 2015 (6:30 PM).
pokefreak890's Avatar
pokefreak890 pokefreak890 is offline
The One that will make everything great
 
Join Date: Nov 2014
Gender: Male
Posts: 853
Quote:
Originally Posted by KDS View Post
Fairly easy to implement. It requires to expand the table at x1a848 and write small amount of code for it. If you're using MrDS's rombase, then I think the table routine and the table have been changed so you might need to account for that.
what about for emerald would it be the same or would there be a diffrent offset?
Reply With Quote
  #219   Link to this post, but load the entire thread.  
Old December 25th, 2015 (4:01 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by pokefreak890 View Post
what about for emerald would it be the same or would there be a diffrent offset?
Different ofcourse!
Reply With Quote
  #220   Link to this post, but load the entire thread.  
Old January 9th, 2016 (4:59 AM).
pokefreak890's Avatar
pokefreak890 pokefreak890 is offline
The One that will make everything great
 
Join Date: Nov 2014
Gender: Male
Posts: 853
I was wondering if u guys can create the new switch in ability system for emerald?
__________________
3DS FREIND CODE : 2724-3540-0898
Reply With Quote
  #221   Link to this post, but load the entire thread.  
Old January 9th, 2016 (6:02 AM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by MrDollSteak View Post
The byte changes actually re-insert the routine for you. The implementation was broken, so the byte changes make it reflect this new routine.



Fur Coat and Multiscale definitely work 100% as intended, no breaking at all.
I fixed No Guard, basically I put a ldr, instead of ldrb, for the bank check, it definitely works now.

Mold Breaker, Teravolt and Turboblaze

Spoiler:
Emerald (credits to KDS for the original Fire Red routines)
Spoiler:
Step 1
Spoiler:
Mold Breaker Table
Spoiler:
00 00 00 00 01 01 00 01 01 00 01 01 01 00 00 01
00 02 01 01 01 01 00 00 00 01 02 00 00 01 00 00
00 00 00 00 00 00 00 01 01 01 00 01 00 00 00 01
00 00 00 01 01 00 00 00 00 00 00 00 01 00 00 01
00 00 00 00 00 00 00 00 01 01 00 01 00 00 01 01
00 00 01 00 00 00 01 01 01 00 00 00 00 00 00 00
00 00 00 00 00 00 00 02 00 00 00 00 00 00 01 00
01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 01
00 00 00 00 00 00 00 01 01 01 00 00 00 01 00 01
00 00 01 00 01 00 00 00 00 00 00 00 00 01 01 00
00 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Insert this table if your ROM has the abilities in the same order that is mentioned in the OP (otherwise you will have to modify according to the format.
There are 256 entries in this table which equal to the maximum No. of abilities that can be accomodated in a GBA rom.

An entry for each ability takes one byte of space and there are entries for every ability. The entry is set to 00 if Mold Breaker does not negate the ability, 01 (or a non-zero value) if Mold Breaker is able to negate it and 02 if the the ability is negated to simulate the Gen V hazard effect.

For e.g, the first entry is for Ability ID 0x0 and does not need to be negated by mold breaker so its entry is set to 00. The second entry is for Stench (ID = 0x1) so set to 00. The 6th entry is set to 01 because MB negates Sturdy (ID = 0x5).

There are some abilities that do not work with this method and require special explicit checks and there entry is set to 00 to avoid wastage of time.
Spoiler:
1. Damp (it checks in the whole battle field rather than a single target, so the 'faintifnotdamp' battlescript command needs to be edited for this. I'm leaving this for now)

2. Lightning and Storm Drain (mold breaker should allow redirection of move).

3. Friend Guard, Aroma Veil, Sweet Veil, Flower Veil (the target's boosts are sometimes by virtue of its ally's ability).

Modify the table accordingly if there is a need to.

Step 2
1a. Replace x8TTTTTT in the routines with the offset of the Mold breaker table.
1b. Insert these routines with byte changes in the respective code comments.
Spoiler:
Routine 1 (Checks for user's Mold Breaker prior to move execution and then disables abilities that negate, also probably the best place to insert Stance Change)
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global moldbreaker
     
AbilityBufferUser:
     	push {r2-r4}
	ldr r0, .Bank
	ldrb r0, [r0]
	mov r1, #0x58
	ldr r2, .BattleData
	mul r0, r1
	add r0, r0, r2
	ldrb r0, [r0]
MoldBreakerCheck:
	cmp r0, #0x69
   	beq MoldBreaker
    	cmp r0, #0xA4
    	beq MoldBreaker
    	cmp r0, #0xA5
    	bne Return
MoldBreaker:
AbilityBufferTarget:
     	ldr r0, .Bank
	add r0, #0x1
     	ldrb r4, [r0]
	mul r1, r4 
	add r1, r1, r2 
     	ldrb r3, [r1]
LoadTable:
     	ldr r0, .MoldBreakerTable
   	add r2, r0, r3
     	ldrb r0, [r2]
CheckIfAffected:
    	cmp r0, #0x0
     	beq Return
Affected:
     	mov r0, #0xFF
     	strb r0, [r1]
     	ldr r0, .DisabledAbilityLoc
     	add r0, r4
     	strb r3, [r0]
Return:
    	pop {r2-r4}
     	bl Canceler
     	lsl r0, r0, #0x18
     	lsr r2, r0, #0x18
     	cmp r2, #0x0
     	beq Continue
     	ldr r0, .Return
     	bx r0
Continue:
     	ldr r0, .Return2
     	bx r0

Canceler:
     	ldr r0, .Return3
     	bx r0

.align 2

.Bank: .word 0x0202420B
.BattleData: .word 0x020240A4
.MoldBreakerTable: .word 0x08TTTTTT
.DisabledAbilityLoc: .word 0x0203E32C
.Return: .word 0x08046399
.Return2: .word 0x08046073
.Return3: .word 0x08041A6D

#insert 00 48 00 47 xx xx xx 08 at 046064

Routine II (Checks for user's Mold Breaker in target iterating moves like Earthquake and then disables abilities that negate damage)
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global moldbreakermultipletargets
     
AbilityBufferUser:
     	push {r1-r4}
	ldr r0, .Bank
	ldrb r0, [r0]
	mov r1, #0x58
	ldr r2, .BattleData
	mul r0, r1
	add r0, r0, r2
	ldrb r0, [r0]
MoldBreakerCheck:
	cmp r0, #0x69
   	beq MoldBreaker
    	cmp r0, #0xA4
    	beq MoldBreaker
    	cmp r0, #0xA5
    	bne Return
MoldBreaker:
AbilityBufferTarget:
     	ldr r0, .Bank
	add r0, #0x1
     	ldrb r4, [r0]
	mul r1, r4 
	add r1, r1, r2 
     	ldrb r3, [r1]
LoadTable:
     	ldr r0, .MoldBreakerTable
   	add r2, r0, r3
     	ldrb r0, [r2]
CheckIfAffected:
    	cmp r0, #0x0
     	beq Return
Affected:
     	mov r0, #0xFF
     	strb r0, [r1]
     	ldr r0, .DisabledAbilityLoc
     	add r0, r4
     	strb r3, [r0]
Return:
    	pop {r1-r4}
     	ldr r0, [r1]
	add r0, #0x1
	str r0, [r1]
	pop {r0}
	bx r0

.align 2

.Bank: .word 0x0202420B
.BattleData: .word 0x020240A4
.MoldBreakerTable: .word 0x08TTTTTT
.DisabledAbilityLoc: .word 0x0203E32C

#insert 00 48 00 47 xx xx xx 08 at 04AF78

Routine III (Generation V effect. Makes the foe affected by entry hazards even if it has an ability to negate the hazards effect (except Magic Guard))
Spoiler:
At 028308 insert a pointer to free space XX XX XX 08.

Battle Script at XX XX XX
Code:
09 0A E2 00 58 00 3A 
2B 04 EC 2F 02 02
08 00 00 00
YY YY YY 08
2E 3A 43 02 02
05 F6
Battle Script at YY YY YY
Code:
4C 00
4D 00
4E 00
00 3A 10 54 01
F9 XX+1 XX XX 08 
52 00 28 4E 8A 2D 08
Routine at XX XX XX
Code:
.text
.align 2
.thumb
.thumb_func
.global moldbreakermultipletargets
     
AbilityBufferUser:
     	push {lr}
	ldr r0, .Bank
	ldrb r0, [r0]
	mov r1, #0x58
	ldr r2, .BattleData
	mul r0, r1
	add r0, r0, r2
	ldrb r0, [r0]
MoldBreakerCheck:
	cmp r0, #0x69
   	beq MoldBreaker
    	cmp r0, #0xA4
    	beq MoldBreaker
    	cmp r0, #0xA5
    	bne Return
MoldBreaker:
AbilityBufferTarget:
     	ldr r0, .Bank
	add r0, #0x1
     	ldrb r4, [r0]
	mul r1, r4 
	add r1, r1, r2 
     	ldrb r3, [r1]
LoadTable:
     	ldr r0, .MoldBreakerTable
   	add r2, r0, r3
     	ldrb r0, [r2]
CheckIfAffected:
    	cmp r0, #0x0
     	beq Return
Affected:
     	mov r0, #0xFF
     	strb r0, [r1]
     	ldr r0, .DisabledAbilityLoc
     	add r0, r4
     	strb r3, [r0]
Return:
	pop {r0}
	bx r0

.align 2

.Bank: .word 0x0202420B
.BattleData: .word 0x020240A4
.MoldBreakerTable: .word 0x08TTTTTT
.DisabledAbilityLoc: .word 0x0203E32C

Routine IV (Restores disabled abilities at the end of move execution)
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global restoreabilities
     
EndTurn:
     	ldr r0, .Outcome
	mov r1, #0x0
	strb r1, [r0]
	ldr r0, .Index
	strb r1, [r0]
RestoreAbilities:
	push {r2-r6}
	ldr r4, .Battlers
	ldrb r4, [r4]
	mov r3, #0x0
	ldr r5, .DisabledAbilityLoc
	ldr r6, .BattleData
Loop:
	ldrb r2 [r5, #0x0]
	cmp r2, #0x0
	beq EndLoop
	strb r2, [r6]
	strb r1, [r5]
EndLoop:
	add r3, r3, #0x1
	cmp r3, r4
	bge Exit
	add r5, r5, #0x1
	add r6, r6, #0x58
	b loop
Exit:
	pop {r2-r6}
	ldr r1, .EndLoc
	mov r0, #0xB
	strb r0, [r1]
	pop {r0}
	bx r0

.align 2

.Outcome: .word 0x0202427C
.Index: .word 0x02024064
.Battlers: .word 0x0202406C
.DisabledAbilityLoc: .word 0x0203E32C
.BattleData: .word 0x020240A4
.EndLoc: .word 0x02024083

#insert 00 48 00 47 xx xx xx 08 at 04B67C
In the routine that makes pokemon forced to switch-out being affected by the entry hazards, we shouldn't use the index 0xFF, it is used to set the weather depending on the map :
Spoiler:

Code:
ROM:08042A7E loc_8042A7E:                            @ CODE XREF: ability_something+252j
ROM:08042A7E                 CMP             R0, #0xFF        @ ability switching-in poke
ROM:08042A80                 BEQ             loc_8042A86
ROM:08042A82                 BL              loc_804441E @ jumptable 080429BE default case
ROM:08042A86 @ ---------------------------------------------------------------------------
ROM:08042A86
ROM:08042A86 loc_8042A86:                            @ CODE XREF: ability_something+258j
ROM:08042A86                 LDR             R0, =battle_flags
ROM:08042A88                 LDR             R0, [R0]
ROM:08042A8A                 MOVS            R1, #0x1000000
ROM:08042A8E                 ANDS            R0, R1
ROM:08042A90                 CMP             R0, #0
ROM:08042A92                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042A94                 BL              weather_get_current
ROM:08042A98                 LSLS            R0, R0, #0x18
ROM:08042A9A                 LSRS            R0, R0, #0x18
ROM:08042A9C                 SUBS            R0, #3  @ switch 11 cases
ROM:08042A9E                 CMP             R0, #0xA
ROM:08042AA0                 BHI             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042AA2                 LSLS            R0, R0, #2
ROM:08042AA4                 LDR             R1, =jpt_8042AAA
ROM:08042AA6                 ADDS            R0, R0, R1
ROM:08042AA8                 LDR             R0, [R0]
ROM:08042AAA                 MOV             PC, R0  @ switch jump
ROM:08042AAA @ ---------------------------------------------------------------------------
ROM:08042AAC off_8042AAC:    .long battle_flags      @ DATA XREF: ability_something:loc_8042A86r
ROM:08042AB0 off_8042AB0:    .long jpt_8042AAA       @ DATA XREF: ability_something+27Cr
ROM:08042AB4 jpt_8042AAA:    .long loc_8042AE0       @ DATA XREF: ability_something+27Co
ROM:08042AB4                                         @ ability_something:off_8042AB0o
ROM:08042AB4                                         @ jump table for switch statement
ROM:08042AB8                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042ABC                 .long loc_8042AE0       @ jumptable 08042AAA cases 3,5,13
ROM:08042AC0                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AC4                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AC8                 .long loc_8042B04       @ jumptable 08042AAA case 8
ROM:08042ACC                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AD0                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AD4                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AD8                 .long loc_8042B28       @ jumptable 08042AAA case 12
ROM:08042ADC                 .long loc_8042AE0       @ jumptable 08042AAA cases 3,5,13
ROM:08042AE0 @ ---------------------------------------------------------------------------
ROM:08042AE0
ROM:08042AE0 loc_8042AE0:                            @ CODE XREF: ability_something+282j
ROM:08042AE0                                         @ DATA XREF: ability_something:jpt_8042AAAo ...
ROM:08042AE0                 LDR             R2, =weather @ jumptable 08042AAA cases 3,5,13
ROM:08042AE2                 LDRH            R1, [R2]
ROM:08042AE4                 MOVS            R0, #7
ROM:08042AE6                 ANDS            R0, R1
ROM:08042AE8                 CMP             R0, #0
ROM:08042AEA                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042AEC                 MOVS            R0, #5
ROM:08042AEE                 STRH            R0, [R2]
ROM:08042AF0                 LDR             R1, =bank_user_for_switch_in_when_0x17_added
ROM:08042AF2                 MOVS            R0, #0xA
ROM:08042AF4                 STRB            R0, [R1,#0x10]
ROM:08042AF6                 MOV             R2, R10
ROM:08042AF8                 STRB            R2, [R1,#0x17]
ROM:08042AFA                 B               loc_8042B42
ROM:08042AFA @ ---------------------------------------------------------------------------
ROM:08042AFC off_8042AFC:    .long weather           @ DATA XREF: ability_something:loc_8042AE0r
ROM:08042B00 off_8042B00:    .long bank_user_for_switch_in_when_0x17_added
ROM:08042B00                                         @ DATA XREF: ability_something+2C8r
ROM:08042B04 @ ---------------------------------------------------------------------------
ROM:08042B04
ROM:08042B04 loc_8042B04:                            @ CODE XREF: ability_something+282j
ROM:08042B04                                         @ DATA XREF: ability_something+2A0o
ROM:08042B04                 LDR             R3, =weather @ jumptable 08042AAA case 8
ROM:08042B06                 LDRH            R1, [R3]
ROM:08042B08                 MOVS            R2, #0x18
ROM:08042B0A                 MOVS            R0, R2
ROM:08042B0C                 ANDS            R0, R1
ROM:08042B0E                 CMP             R0, #0
ROM:08042B10                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042B12                 STRH            R2, [R3]
ROM:08042B14                 LDR             R1, =bank_user_for_switch_in_when_0x17_added
ROM:08042B16                 MOVS            R0, #0xC
ROM:08042B18                 STRB            R0, [R1,#0x10]
ROM:08042B1A                 MOV             R3, R10
ROM:08042B1C                 STRB            R3, [R1,#0x17]
ROM:08042B1E                 B               loc_8042B42
ROM:08042B1E @ ---------------------------------------------------------------------------
ROM:08042B20 off_8042B20:    .long weather           @ DATA XREF: ability_something:loc_8042B04r
ROM:08042B24 off_8042B24:    .long bank_user_for_switch_in_when_0x17_added
ROM:08042B24                                         @ DATA XREF: ability_something+2ECr
ROM:08042B28 @ ---------------------------------------------------------------------------
ROM:08042B28
ROM:08042B28 loc_8042B28:                            @ CODE XREF: ability_something+282j
ROM:08042B28                                         @ DATA XREF: ability_something+2B0o
ROM:08042B28                 LDR             R3, =weather @ jumptable 08042AAA case 12
ROM:08042B2A                 LDRH            R1, [R3]
ROM:08042B2C                 MOVS            R2, #0x60 @ '`'
ROM:08042B2E                 MOVS            R0, R2
ROM:08042B30                 ANDS            R0, R1
ROM:08042B32                 CMP             R0, #0
ROM:08042B34                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042B36                 STRH            R2, [R3]
ROM:08042B38                 LDR             R1, =bank_user_for_switch_in_when_0x17_added
ROM:08042B3A                 MOVS            R0, #0xB
ROM:08042B3C                 STRB            R0, [R1,#0x10]
ROM:08042B3E                 MOV             R5, R10
ROM:08042B40                 STRB            R5, [R1,#0x17]
ROM:08042B42
ROM:08042B42 loc_8042B42:                            @ CODE XREF: ability_something+2D2j
ROM:08042B42                                         @ ability_something+2F6j
ROM:08042B42                 MOV             R0, R9
ROM:08042B44                 ADDS            R0, #1
ROM:08042B46                 LSLS            R0, R0, #0x18
ROM:08042B48                 LSRS            R0, R0, #0x18
ROM:08042B4A                 MOV             R9, R0
ROM:08042B4C
ROM:08042B4C loc_8042B4C:                            @ CODE XREF: ability_something+26Aj
ROM:08042B4C                                         @ ability_something+278j ...
ROM:08042B4C                 MOV             R0, R9  @ jumptable 08042AAA default case
ROM:08042B4E                 CMP             R0, #0
ROM:08042B50                 BNE             loc_8042B56
ROM:08042B52                 BL              loc_804443A
ROM:08042B56 @ ---------------------------------------------------------------------------
ROM:08042B56
ROM:08042B56 loc_8042B56:                            @ CODE XREF: ability_something+328j
ROM:08042B56                 BL              weather_get_current
ROM:08042B5A                 LDR             R1, =battle_preparation_phase
ROM:08042B5C                 STRB            R0, [R1,#5]
ROM:08042B5E                 LDR             R0, =(dword_82DACE4+3)
ROM:08042B60                 BL              execute_battle_script
ROM:08042B64                 BL              loc_804441E @ jumptable 080429BE default case


So perhaps we should use the index 0x0
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #222   Link to this post, but load the entire thread.  
Old January 9th, 2016 (8:43 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by kleenexfeu View Post
In the routine that makes pokemon forced to switch-out being affected by the entry hazards, we shouldn't use the index 0xFF, it is used to set the weather depending on the map :
Spoiler:

Code:
ROM:08042A7E loc_8042A7E:                            @ CODE XREF: ability_something+252j
ROM:08042A7E                 CMP             R0, #0xFF        @ ability switching-in poke
ROM:08042A80                 BEQ             loc_8042A86
ROM:08042A82                 BL              loc_804441E @ jumptable 080429BE default case
ROM:08042A86 @ ---------------------------------------------------------------------------
ROM:08042A86
ROM:08042A86 loc_8042A86:                            @ CODE XREF: ability_something+258j
ROM:08042A86                 LDR             R0, =battle_flags
ROM:08042A88                 LDR             R0, [R0]
ROM:08042A8A                 MOVS            R1, #0x1000000
ROM:08042A8E                 ANDS            R0, R1
ROM:08042A90                 CMP             R0, #0
ROM:08042A92                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042A94                 BL              weather_get_current
ROM:08042A98                 LSLS            R0, R0, #0x18
ROM:08042A9A                 LSRS            R0, R0, #0x18
ROM:08042A9C                 SUBS            R0, #3  @ switch 11 cases
ROM:08042A9E                 CMP             R0, #0xA
ROM:08042AA0                 BHI             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042AA2                 LSLS            R0, R0, #2
ROM:08042AA4                 LDR             R1, =jpt_8042AAA
ROM:08042AA6                 ADDS            R0, R0, R1
ROM:08042AA8                 LDR             R0, [R0]
ROM:08042AAA                 MOV             PC, R0  @ switch jump
ROM:08042AAA @ ---------------------------------------------------------------------------
ROM:08042AAC off_8042AAC:    .long battle_flags      @ DATA XREF: ability_something:loc_8042A86r
ROM:08042AB0 off_8042AB0:    .long jpt_8042AAA       @ DATA XREF: ability_something+27Cr
ROM:08042AB4 jpt_8042AAA:    .long loc_8042AE0       @ DATA XREF: ability_something+27Co
ROM:08042AB4                                         @ ability_something:off_8042AB0o
ROM:08042AB4                                         @ jump table for switch statement
ROM:08042AB8                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042ABC                 .long loc_8042AE0       @ jumptable 08042AAA cases 3,5,13
ROM:08042AC0                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AC4                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AC8                 .long loc_8042B04       @ jumptable 08042AAA case 8
ROM:08042ACC                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AD0                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AD4                 .long loc_8042B4C       @ jumptable 08042AAA default case
ROM:08042AD8                 .long loc_8042B28       @ jumptable 08042AAA case 12
ROM:08042ADC                 .long loc_8042AE0       @ jumptable 08042AAA cases 3,5,13
ROM:08042AE0 @ ---------------------------------------------------------------------------
ROM:08042AE0
ROM:08042AE0 loc_8042AE0:                            @ CODE XREF: ability_something+282j
ROM:08042AE0                                         @ DATA XREF: ability_something:jpt_8042AAAo ...
ROM:08042AE0                 LDR             R2, =weather @ jumptable 08042AAA cases 3,5,13
ROM:08042AE2                 LDRH            R1, [R2]
ROM:08042AE4                 MOVS            R0, #7
ROM:08042AE6                 ANDS            R0, R1
ROM:08042AE8                 CMP             R0, #0
ROM:08042AEA                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042AEC                 MOVS            R0, #5
ROM:08042AEE                 STRH            R0, [R2]
ROM:08042AF0                 LDR             R1, =bank_user_for_switch_in_when_0x17_added
ROM:08042AF2                 MOVS            R0, #0xA
ROM:08042AF4                 STRB            R0, [R1,#0x10]
ROM:08042AF6                 MOV             R2, R10
ROM:08042AF8                 STRB            R2, [R1,#0x17]
ROM:08042AFA                 B               loc_8042B42
ROM:08042AFA @ ---------------------------------------------------------------------------
ROM:08042AFC off_8042AFC:    .long weather           @ DATA XREF: ability_something:loc_8042AE0r
ROM:08042B00 off_8042B00:    .long bank_user_for_switch_in_when_0x17_added
ROM:08042B00                                         @ DATA XREF: ability_something+2C8r
ROM:08042B04 @ ---------------------------------------------------------------------------
ROM:08042B04
ROM:08042B04 loc_8042B04:                            @ CODE XREF: ability_something+282j
ROM:08042B04                                         @ DATA XREF: ability_something+2A0o
ROM:08042B04                 LDR             R3, =weather @ jumptable 08042AAA case 8
ROM:08042B06                 LDRH            R1, [R3]
ROM:08042B08                 MOVS            R2, #0x18
ROM:08042B0A                 MOVS            R0, R2
ROM:08042B0C                 ANDS            R0, R1
ROM:08042B0E                 CMP             R0, #0
ROM:08042B10                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042B12                 STRH            R2, [R3]
ROM:08042B14                 LDR             R1, =bank_user_for_switch_in_when_0x17_added
ROM:08042B16                 MOVS            R0, #0xC
ROM:08042B18                 STRB            R0, [R1,#0x10]
ROM:08042B1A                 MOV             R3, R10
ROM:08042B1C                 STRB            R3, [R1,#0x17]
ROM:08042B1E                 B               loc_8042B42
ROM:08042B1E @ ---------------------------------------------------------------------------
ROM:08042B20 off_8042B20:    .long weather           @ DATA XREF: ability_something:loc_8042B04r
ROM:08042B24 off_8042B24:    .long bank_user_for_switch_in_when_0x17_added
ROM:08042B24                                         @ DATA XREF: ability_something+2ECr
ROM:08042B28 @ ---------------------------------------------------------------------------
ROM:08042B28
ROM:08042B28 loc_8042B28:                            @ CODE XREF: ability_something+282j
ROM:08042B28                                         @ DATA XREF: ability_something+2B0o
ROM:08042B28                 LDR             R3, =weather @ jumptable 08042AAA case 12
ROM:08042B2A                 LDRH            R1, [R3]
ROM:08042B2C                 MOVS            R2, #0x60 @ '`'
ROM:08042B2E                 MOVS            R0, R2
ROM:08042B30                 ANDS            R0, R1
ROM:08042B32                 CMP             R0, #0
ROM:08042B34                 BNE             loc_8042B4C @ jumptable 08042AAA default case
ROM:08042B36                 STRH            R2, [R3]
ROM:08042B38                 LDR             R1, =bank_user_for_switch_in_when_0x17_added
ROM:08042B3A                 MOVS            R0, #0xB
ROM:08042B3C                 STRB            R0, [R1,#0x10]
ROM:08042B3E                 MOV             R5, R10
ROM:08042B40                 STRB            R5, [R1,#0x17]
ROM:08042B42
ROM:08042B42 loc_8042B42:                            @ CODE XREF: ability_something+2D2j
ROM:08042B42                                         @ ability_something+2F6j
ROM:08042B42                 MOV             R0, R9
ROM:08042B44                 ADDS            R0, #1
ROM:08042B46                 LSLS            R0, R0, #0x18
ROM:08042B48                 LSRS            R0, R0, #0x18
ROM:08042B4A                 MOV             R9, R0
ROM:08042B4C
ROM:08042B4C loc_8042B4C:                            @ CODE XREF: ability_something+26Aj
ROM:08042B4C                                         @ ability_something+278j ...
ROM:08042B4C                 MOV             R0, R9  @ jumptable 08042AAA default case
ROM:08042B4E                 CMP             R0, #0
ROM:08042B50                 BNE             loc_8042B56
ROM:08042B52                 BL              loc_804443A
ROM:08042B56 @ ---------------------------------------------------------------------------
ROM:08042B56
ROM:08042B56 loc_8042B56:                            @ CODE XREF: ability_something+328j
ROM:08042B56                 BL              weather_get_current
ROM:08042B5A                 LDR             R1, =battle_preparation_phase
ROM:08042B5C                 STRB            R0, [R1,#5]
ROM:08042B5E                 LDR             R0, =(dword_82DACE4+3)
ROM:08042B60                 BL              execute_battle_script
ROM:08042B64                 BL              loc_804441E @ jumptable 080429BE default case


So perhaps we should use the index 0x0
Good find! 0x0 should not be used because of Gastro Acid. 0xFE would bhi better in this case.
Reply With Quote
  #223   Link to this post, but load the entire thread.  
Old January 9th, 2016 (12:00 PM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by KDS View Post
Good find! 0x0 should not be used because of Gastro Acid. 0xFE would bhi better in this case.
What is the matter with gastro acid ?
Also 0xFE is used to check water or mudsport, I don't remember. Though when rewritting the damage calculator I updated them so it shouldn't be a problem

Perhaps we could change the index to something that has no effect in battle, like pickup
__________________
Arceus and Giratina Forms
Dynamic Pokémon Data
Reply With Quote
  #224   Link to this post, but load the entire thread.  
Old January 9th, 2016 (2:54 PM). Edited January 10th, 2016 by DizzyEgg.
DizzyEgg's Avatar
DizzyEgg DizzyEgg is offline
 
Join Date: Feb 2014
Location: Poland
Age: 25
Gender: Male
Nature: Quiet
Posts: 794
Quote:
Originally Posted by MrDollSteak View Post
Sorry for the lack of updates in a while guys, I've got heaps of projects going on, and am very busy in real life at the moment. Anyway I've since written up the Regenerator routine that my rombase uses, it was improved immensely by Doesnt. It's bug free as far as I can tell considering I just fixed the bug wherein it broke Natural Cure.

Regenerator

Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global regenerator
 
AbilityBuffer:
    add r0, r1, r3
    add r0, #0x20
    ldrb r0, [r0]
RegeneratorCheck:
    cmp r0, #0x91
    beq Regenerator
NaturalCureCheck:
    cmp r0, #0x1E
    bne NoAbility
NaturalCure:
    ldr r0, .Return
    bx r0
NoAbility:
    ldr r0, .Return2
    bx r0
Regenerator:
GetHP:
    add r3, #0x28
    add r3, r1, r3
    ldrh r0, [r3, #0x4]
    mov r1, #0x20
    mul r0, r1
    mov r1, #0x60
    push {r3}
    bl Divide
    pop {r3}
    ldrh r1, [r3]
    add r0, r0, r1
CheckHP:
    ldrh r2, [r3, #0x4]
    cmp r0, r2
    ble StoreHP
MaxHP:
    mov r0, r2
StoreHP:
    strh r0, [r3]
BufferHealthChange:
    ldr r2, .CommandTable
    ldrb r1, [r4]
    ldr r0, .RamLoc
    ldr r0, [r0]
    add r0, r1, r0
    add r0, #0x58
    ldrb r0, [r0]
    lsl r0, r0, #0x2
    add r0, r0, r2
    ldrb r2, [r0]
    mov r0, r1
    mul r0, r6
    add r0, r0, r3
    str r0, [sp]
    mov r0, #0x0
HealthChangeIndex:
    mov r1, #0x2A
Success:
    ldr r3, .Return3
    bx r3
Divide:
    ldr r3, .DivideLoc
    bx r3

.align 2

.Return: .word 0x0802CCE7
.Return2: .word 0x0802CD1B
.CommandTable: .word 0x0825E45C
.RamLoc: .word 0x02023FE8
.Return3: .word 0x0802CD0F
.DivideLoc: .word 0x081E4019

#insert 00 48 00 47 xx xx xx 08 00 00 at 02CCDC
The buffer health change command as far as I can tell gets the game to recognise the changes in both status for natural cure, and health for Regenerator, it likely updates the graphics also.

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global regenerator
 
AbilityBuffer:
    add r0, r1, r3
    add r0, #0x20
    ldrb r0, [r0]
RegeneratorCheck:
    cmp r0, #0x91
    beq Regenerator
NaturalCureCheck:
    cmp r0, #0x1E
    bne NoAbility
NaturalCure:
    ldr r0, .Return
    bx r0
NoAbility:
    ldr r0, .Return2
    bx r0
Regenerator:
GetHP:
    add r3, #0x28
    add r3, r1, r3
    ldrh r0, [r3, #0x4]
    mov r1, #0x20
    mul r0, r1
    mov r1, #0x60
    push {r3}
    bl Divide
    pop {r3}
    ldrh r1, [r3]
    add r0, r0, r1
CheckHP:
    ldrh r2, [r3, #0x4]
    cmp r0, r2
    ble StoreHP
MaxHP:
    mov r0, r2
StoreHP:
    strh r0, [r3]
BufferHealthChange:
    ldr r2, .CommandTable
    ldrb r1, [r4]
    ldr r0, .RamLoc
    ldr r0, [r0]
    add r0, r1, r0
    add r0, #0x58
    ldrb r0, [r0]
    lsl r0, r0, #0x2
    add r0, r0, r2
    ldrb r2, [r0]
    mov r0, r1
    mul r0, r6
    add r0, r0, r3
    str r0, [sp]
    mov r0, #0x0
HealthChangeIndex:
    mov r1, #0x2A
Success:
    ldr r3, .Return3
    bx r3
Divide:
    ldr r3, .DivideLoc
    bx r3

.align 2

.Return: .word 0x08055A9F
.Return2: .word 0x08055AD3
.CommandTable: .word 0x0832A328
.RamLoc: .word 0x0202449C
.Return3: .word 0x08055AC7
.DivideLoc: .word 0x082E7541

#insert 00 48 00 47 xx xx xx 08 00 00 at 055A94
The buffer health change command as far as I can tell gets the game to recognise the changes in both status for natural cure, and health for Regenerator, it likely updates the graphics also.
Regenerator doesn't work for me in double battles or when AI switches out.(Fire Red) HP may not update, kill AI pokemon or break health bar depending on the position of a pokemon. I played with it for a while and it seems the problem lies in str r0, [sp]. This only works for user, changing it to str r0, [sp, #0x28] will work for AI but freeze the game if player switches out. Double battles won't work either way. I think it has to do with bank position of switching and aforementioned sp.

EDIT: So I did some tests and it turns out that AI switching statused Pokemon with Natural Care in double battles also doesn't work. It doesn't have to do with your routine though, it just doesn't work in vanilla FR. Nvm, vanilla natural care works fine with all Pokemon, so the problem is somewhere in your routine.
Reply With Quote
  #225   Link to this post, but load the entire thread.  
Old January 10th, 2016 (12:17 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by kleenexfeu View Post
What is the matter with gastro acid ?
Also 0xFE is used to check water or mudsport, I don't remember. Though when rewritting the damage calculator I updated them so it shouldn't be a problem

Perhaps we could change the index to something that has no effect in battle, like pickup
Actually, 0x0 turns out to be good. I verified by re-evaluating the situation.
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 8:52 AM.