- 218
- Posts
- 11
- Years
- Seen Nov 12, 2021
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.Spoiler:
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)
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 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 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: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 IV (Restores disabled abilities at the end of move execution)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
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