The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary Hack Research & Development (https://www.pokecommunity.com/forumdisplay.php?f=195)
-   -   Code ASM Resource Thread (https://www.pokecommunity.com/showthread.php?t=339153)

Lance32497 May 7th, 2015 3:35 PM

Quote:

Originally Posted by eMMe97 (Post 8740142)
I found the special but is only a pop up, when i click yes...nothing, the script restart with "would you like to save the game?".

You should put waitstate

eMMe97 May 8th, 2015 1:47 AM

Quote:

Originally Posted by Lance32497 (Post 8740892)
You should put waitstate

Thank you guy!!! (yes...i'm stupid xD)

Percy May 8th, 2015 1:56 AM

I have 1 request: you can run away from trainer battles.

daniilS May 8th, 2015 12:51 PM

Quote:

Originally Posted by Percy (Post 8741522)
I have 1 request: you can run away from trainer battles.

Would that really have any use? I mean if you really want to quit a battle you might as well spam stupid moves until you die.

Deokishisu May 8th, 2015 4:40 PM

Quote:

Originally Posted by daniilS (Post 8742254)
Would that really have any use? I mean if you really want to quit a battle you might as well spam stupid moves until you die.

I guess it would have a use if you have a story battle that you can't possibly win and have to retreat. Like an evil team boss battle or something.

Criminon May 13th, 2015 3:16 PM

Quote:

Originally Posted by FBI agent (Post 8533505)

Ability switching:



Very simple, it turned out to not have to adjust the PID.

How to insert:

Just compile the following routine into free space:

Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
        push {r0-r4, lr}
        ldr r1, =(0x20370C0) @var 0x8004
        ldrb r1, [r1]
        mov r2, #0x64
        mul r1, r1, r2
        ldr r0, =(0x2024284)
        add r0, r0, r1 @slot
        mov r4, r0 @save slot
        mov r1, #0x2E
        ldr r3, =(0x803FBE8 +1)
        bl linker
        cmp r0, #0x1
        beq setZero
        mov r0, #0x1
        b setNew

setZero:
        mov r0, #0x0

setNew:
        lsl r0, r0, #0x18
        lsr r0, r0, #0x18
        ldr r2, =(0x20370D0) @set inverse
        strb r0, [r2]
        mov r0, r4
        mov r1, #0x2E
        ldr r3, =(0x804037C +1)
        bl linker
        pop {r0-r4, pc}

linker:
        bx r3

.align 2




Usage:

Set in variable 0x8004 the slot number of the Pokemon who's ability you want to swap. Note that Pokemon with only 1 ability won't have their abilities swapped. I've made it so it's easy to use with special 0x9F in your ability swap item script.



Am I supposed to be calling the ASM on this?

Spoiler:
#dynamic 0x800000
#org @start
lock
call @menu
special2 0x800B 0xBA
goto @next
'---------------
#org @menu
special 0x9F
waitstate
return

'---------------
#org @end
release
end

'---------------
#org @next
fanfare 0x71
waitfanfare
msgbox @text1 MSG_KEEPOPEN '"[buffer1]'s potential has\nbeen re..."
removeitem 0x72 0x1 ///this is set up for items. this is the item I used.
closeonkeypress
release
end


'---------
' Strings
'---------
#org @text1
= [buffer1]'s ability has\nbeen swapped.


This is what I'm using for it, but it doesn't seem to be doing anything. I AM using the JPAN engine if that helps. I know it references 8004 a lot, but it shouldn't matter on this, right?

Also! I have a few ASM ideas, and as long as its not against the rules, I would be happy to pay you for them!

Would it be possible to make it so you permanently have a chance to receive a held item from wild pokemon after fainting them? Kind of like a loot system? Maybe even a check to see if you have enough item space and then maybe spawning a pokeball with the item for a later pickup that disappears once you leave the map? I'm imagining the later would be harder, but would love to hear back from you. Everything you do is amazing, and I can't wait to understand ASM more.

Another interesting one would be modifying the trainer views to have it when a certain variable is set, they don't see you. I've been planning on adding in the cardboard box from MSG, haha.

And finally a variable that when toggled causes a certain amount of money to be taken from each battle you have. with a message. IE: "20% of your rewards have gone to Team Rocket" I plan on making being a team rocket member a possibility, allowing you to catch trainer pokemon, (which is already done) but at the same time you lose funds from trainer battles, as well as people treat you differently.

Trainer 781 May 24th, 2015 2:20 AM

Damage Reduction Berries

1. Assemble the following table and insert it somewhere in Free Space:
Spoiler:


Replace YYY with the index number of the berries mentioned in the comments.
The byte below the index number for each berry represents the type of the move the berry protects it against.
Code:

.align 2
.text

main:
/*OCCA*/
.hword 0x0YYY
.byte 0x0A

/*PASHO*/
.hword 0x0YYY
.byte 0x0B

/*WACAN*/
.hword 0x0YYY
.byte 0x0D

/*RINDO*/
.hword 0x0YYY
.byte 0x0C

/*YACHE*/
.hword 0x0YYY
.byte 0x0F

/*CHOPLE*/
.hword 0x0YYY
.byte 0x01

/*KEBIA*/
.hword 0x0YYY
.byte 0x03

/*SHUCA*/
.hword 0x0YYY
.byte 0x04

/*COBA*/
.hword 0x0YYY
.byte 0x02

/*PAYAPA*/
.hword 0x0YYY
.byte 0x0E

/*TANGA*/
.hword 0x0YYY
.byte 0x06

/*CHARTI*/
.hword 0x0YYY
.byte 0x05

/*KASIB*/
.hword 0x0YYY
.byte 0x07

/*HABAN*/
.hword 0x0YYY
.byte 0x10

/*COLBUR*/
.hword 0x0YYY
.byte 0x11

/*BABIRI*/
.hword 0x0YYY
.byte 0x08

/*ROSELI*/
.hword 0x0YYY
.byte 0x17

/*end table*/
.hword 0xFFFF
.byte 0xFF




2. Assemble this routine and make bytes changes mentioned in the code
Spoiler:


Code:

.text
.align 2
.thumb
.thumb_func
.global reductionberry

ValidMoveCheck:
    ldr r0, .Outcome
    ldrb r1, [r0]
    mov r2, #0x29
    and r2, r1
    cmp r2, #0x0
    bne Exit

SubCheck:
    ldr r3, .Target
    ldr r4, .PokemonData
    mov r2, #0x58
    ldrb r0, [r3]
    mul r0, r2
    add r7, r0, r4
    ldr r2, [r7, #0x50]
    ldr r3, .subval
    and r2, r3
    cmp r2, #0x0
    bne Exit

NormalMoveCheck:
    ldr r4, .MemoryLoc
    ldr r3, [r4]
    ldrb r6, [r3, #0x13]
    mov r2, #0x3f
    and r6, r2
    cmp r6, #0x0
    bne SuperEffectiveCheck
    ldr r4, .MoveTable
    ldr r3, .CurrMove
    mov r2, #0xC
    ldrh r1, [r3]
    mul r1, r2
    add r2, r1, r4
    ldrb r6, [r2, #0x2]
    cmp r6, #0x0
    bne SuperEffectiveCheck

ChilanBerryCheck:
    ldrh r5, [r7, #0x2E]
    ldrh r0, .ChilanIndex
    cmp r5, r0
    beq DamageReducer

SuperEffectiveCheck:
    ldr r0, .Outcome
    ldrb r1, [r0]
    mov r2, #0x2
    and r1, r2
    cmp r1, #0x0
    beq Exit

LoadItem:
    ldrh r5, [r7, #0x2E]
    ldr r3, .BerryTable
    ldrh r4, .FFHW

Loop:
    ldrh r0, [r3]
    cmp r0, r5
    beq TypeCheck
    cmp r0, r4
    beq Exit
    add r3, #0x3
    b Loop

TypeCheck:
    ldrb r0, [r3, #0x2]
    cmp r6, r0
    bne Exit

DamageReducer:
    ldr r4, .Damage
    ldrh r2, [r4]
    lsr r2, #0x1
    cmp r2, #0x0
    bne NotZero
    mov r2, #0x1

NotZero:
    strh r2, [r4]
    ldr r4, .ScriptIndex
    ldr r3, [r4]
    add r3, #0x1
    str r3, [r4]
    bl ScriptCall
    ldr r3, .BattleScript
    sub r3, #0x1
    str r3, [r4]
    ldr r0, .ItemBuffer
    strh r5, [r0]

Exit:
    bl Random
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    mov r1, #0xF
    ldr r2, .Return
    bx r2

Random:
    ldr r2, .RNG
    bx r2

ScriptCall:
    ldr r2, =0x08017545
    bx r2

.align 2
.subval: .word 0x01000000
.ItemBuffer: .word 0x2023D68
.CurrMove: .word 0x2023D4A
.Damage: .word 0x02023D50
.Outcome: .word 0x02023DCC
.Target: .word 0x02023D6C
.PokemonData: .word 0x02023BE4
.MemoryLoc: .word 0x02023FE8
.MoveTable: .word 0x08XXXXXX
.BerryTable: .word 0x08TTTTTT
.Return: .word 0x0801F111
.RNG: .word 0x08044EC9
.ScriptIndex: .word 0x02023D74
.BattleScript: .word 0x08BBBBBB
.FFHW: .word 0xFFFF
.ChilanIndex: .hword 0x0YYY

@1F106: 00 00 00 48 00 47 XX+1 XX XX 08


TTTTTT is the pointer to the table created above.
YYY is the index of Chilan Berry


3. Battle Script at BBBBBB:
Spoiler:


Assuming the setword command is FA
Code:

45 00 07 00 00 00 00 FA 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 6A 00 3C


String at SSSSSS:
Code:

FD 10 B4 E7 00 FD 16 FE E6 D9 D8 E9 D7 D9 D8 00 FD 14 B4 E7 00 E4 E3 EB D9 E6 AB



MrDollSteak May 25th, 2015 3:13 PM

Quote:

Originally Posted by KDS (Post 8764736)
Damage Reduction Berries

1. Assemble the following table and insert it somewhere in Free Space:
Spoiler:


Replace YYY with the index number of the berries mentioned in the comments.
The byte below the index number for each berry represents the type of the move the berry protects it against.

That's awesome KDS! Have you found where the other berries activate ? (to try and make it more like 6th gen, where they activate in the end of a battle script as opposed to the start/end of turn).

I guess this would be pretty separate to that, but still I'd love to try and fix that, and buff the sitrus berry too while I'm at it.

Trainer 781 May 26th, 2015 3:15 AM

Quote:

Originally Posted by MrDollSteak (Post 8767100)
That's awesome KDS! Have you found where the other berries activate ? (to try and make it more like 6th gen, where they activate in the end of a battle script as opposed to the start/end of turn).

I guess this would be pretty separate to that, but still I'd love to try and fix that, and buff the sitrus berry too while I'm at it.

Yes. It is located where I made the hook for blacksludge. It reads a table using the held item effect byte as a index for pinch berries and leftovers then selects the routine from the table.

MrDollSteak May 26th, 2015 3:47 AM

Quote:

Originally Posted by KDS (Post 8767720)
Yes. It is located where I made the hook for blacksludge. It reads a table using the held item effect byte as a index for pinch berries and leftovers then selects the routine from the table.

Ooh cheers KDS, I'll look into that. It must be located after all the move / ability effects (such as Rain Dish) etc. I'll try and redo the Sitrus berry routine, and just nop the entry table, and instead trigger them from the end BS routine.

Also while I'm at it, which command removes the item exactly? I'm just thinking for the Focus Sash (and a few other consumable items), but more importantly would like to see how the game handles consumability, so that I can make an Unburden check there somewhere (so that when an item is consumed I'd double the stat in the RAM, that way it resets on switch).

Trainer 781 May 26th, 2015 4:02 AM

Quote:

Originally Posted by MrDollSteak (Post 8767743)
Ooh cheers KDS, I'll look into that. It must be located after all the move / ability effects (such as Rain Dish) etc. I'll try and redo the Sitrus berry routine, and just nop the entry table, and instead trigger them from the end BS routine.

Also while I'm at it, which command removes the item exactly? I'm just thinking for the Focus Sash (and a few other consumable items), but more importantly would like to see how the game handles consumability, so that I can make an Unburden check there somewhere (so that when an item is consumed I'd double the stat in the RAM, that way it resets on switch).

To remove item from battling pokemon, the battle script command 6a (with a byte as a single parameter) can be used. I was also thinking to used this routine to set unburden. Also to avoid the hassle of unsetting unburden bytes you can use the special status flag structure starting at x2023dfc which automatically resets on switching and has a few vacant values left and most importantly does not stack with baton pass unlike ingrain and block.
You can disable the table by setting the entries to the fail pointer (which is same for deepseascale which does not have any end turn effect) except leftovers or change the table reader routine to only accomodate leftovers (and similar items like black sludge,sticky barb etc.)

robinjea May 28th, 2015 10:49 PM

It's been some time since I've been around this thread because I have been testing every single ASM posted here. Though just yesterday, I was testing this one and found a little bit of problem.

Quote:

Originally Posted by FBI agent (Post 8523908)

Bag Deletion and Restoration


Delete Backup



It may be the case that you want to use this "bag swap" more than once. For that to work, you will have to delete the current backup. Normally if you don't delete the backup and you attempt to restore the bag for a second time, you will not have a problem. However, in the case that the first time you had your bag and you had more items that time than the second time it will not all be overwritten and you will add "extras". So to be on the safe side, after an event is over ALWAYS delete the backup!

How to insert:

Compile and insert into free space the following routine:

Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

main:
    push {r0-r3, lr}
    ldr r0, .STORAGE
    mov r1, #0x0
    mov r2, #0xBA
    ldr r3, =(0x81E5ED8 +1)
    bl linker
    pop {r0-r3, pc}

linker:
    bx r3

.align 2

.STORAGE:
    .word 0x203C280 @ItemStorage


Here is a compiled version:
Code:

0F B5 05 48 00 21 BA 22 04 4B 00 F0 01 F8 0F BD 18 47 C0 46 8C 98 03 02 80 C2 03 02 D9 5E 1E 08




Usage:
Like all of these routines, you just need to callasm to this routine somewhere in your script. That's all, the rest is handle automagically!

That part of the Bag Deletion and Restoration Routines. Whenever I try to delete the backup I made, and try to restore the "should've-been-deleted backup" of my items (for testing purposes), it proves that the only things it deletes in the backup are the Normal ITEMS (i.e. the Pokeballs and Key Items are still there and even keep adding more). Why is it? Can it be fixed?

Oh, and I have a few requests that I hope someone could fulfill.

1. A loot system routine (like what Criminon suggested earlier that I think nobody noticed) that will give you items or money after a wild battle. I know it can be done via scripting but I personally think that doing it that way is not kinda good. I think if it was ASM'd, it would be better.
2. A display money in textbox routine. I'm not sure if this is doable via scripting because the only thing I saw there was the showmoney and I wouldn't like it. I actually wanted money to be shown via some kind of a buffer.
3. A gender change routine. Well a name player in overworld routine exists, why not a gender change routine? :P
4. Uhmm... I don't think this is possible, a Display a 256color fullscreen image routine.
5. A Change trainer levels routine based on your party's average level.
6. A Bag deletion and restoration routine that only deletes the normal items and keeps the key items and pokeballs.
That's about it. I hope someone can. Thank you! :D

Trainer 781 May 29th, 2015 7:31 AM

Flame Orb and Toxic Orb

Spoiler:

Inserting this is a bit complicated than other items. Also this was the most challenging to implement.
Anyways, here are the steps:
Step I
Spoiler:

Select the bytes from x182FC to x1834B. This is a table and we are going to repoint it.
Search for 80 (or 0x50) bytes of contiguous free space and then copy and paste the table.
Now go to x182F8 and insert a series of 4 bytes corresponding to the pointer to the new location of our table. For example, if the table is at 0x731240 then in reverse hex it would be 40 12 73 08.


Step II
Spoiler:

Insert this routine in free space.

Routine at XXXXXX:
Spoiler:

EEEEEE is location for a battle script to be inserted which I will tell about later.
Code:

.text
.align 2
.thumb
.thumb_func
.global orbz

ldr r5, =0x2023fe8
ldr r5, [r5]
ldrb r0, [r5, #0x1]
ldr r2, =0x2023BCC
ldrb r2, [r2]
add r0, #0x1
cmp r0, r2
bne Exit
ldr r0, =0x02023D6E
mov r2, #0x0
strb r2, [r0]
ldr r0, =0x08EEEEEE
ldr r2, =0x08018C05
bx r2

Exit:
ldr r2, =0x08018C13
bx r2




Now expand the table in such a way that XX XX XX 08 (Don't use +1 in this case) is the second last entry of the table (do not remove the old entries). This ensures that the orbs will activate at the extreme end of a turn after ingrain, weather damage etc.
The last entry should be 38 8C 01 08 (which is there in the original) because it successfully terminates the operation of this table.
Since the no. of entries in the table have been changed to 0x14 from 0x13, we need to break the limiters. Goto x182e6 and x18C64 and insert 0x14 there


Step III
Spoiler:

Insert the Battle Scripts and Routines in free space and change the dummy pointers mentioned in the post according to where there are inserted.
Thie battle scripts assume that F8 is the callasm command and FB is the setword command., so change it according to your ROM.

Battle Script at EEEEEE:
Code:

F8 ZZ+1 ZZ ZZ 08 3E


Routine at ZZZZZZ:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global orbiterator

Main:
      push {lr}
      ldr r7, .counter
      ldr r6, .battleData
      ldr r5, .bank
      ldr r2, .scriptPointer
      mov r4, #0x58
Loop:
      ldrb r0, [r7]
      ldr r1, .noOfPokes
      ldrb r1, [r1]
      cmp r0, r1
      bge Quit
      ldr r1, .turnOrder
      add r1, r1, r0
      ldrb r1, [r1]
      strb r1, [r5]
      mul r1, r4
      add r3, r1, r6
      add r0, #0x1
      strb r0, [r7]

      ldrh r0, [r3, #0x28]
      cmp r0, #0x0
      beq Loop

      ldr r0, [r3, #0x4C]
      cmp r0, #0x0
      bne Loop

      ldrh r0, [r3, #0x2E]

      bl GetEffectByte
      cmp r0, #0xKK
      beq FlameOrb
      cmp r0, #0xLL
      bne Loop

ToxicOrb:
      add r3, #0x20

      ldrb r0, [r3]
      cmp r0, #0x11
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      ldr r0, .ToxicOrbScript
      b Branch

FlameOrb:
      add r3, #0x20
      ldrb r0, [r3]
      cmp r0, #0x29
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      ldr r0, .FlameOrbScript
Branch:
      sub r0, #0x5
      str r0, [r2]
Quit:
      pop {r0}
      bx r0

GetEffectByte:
      ldr r1, =0x809a925
      bx r1

.align 2
.counter: .word 0x02023D6E
.battleData: .word 0x02023BE4
.bank: .word 0x02023D6B
.scriptPointer: .word 0x02023D74
.noOfPokes: .word 0x02023BCC
.turnOrder: .word 0x02023BDE
.ToxicOrbScript: .word 0x8PPPPPP
.FlameOrbScript: .word 0x8MMMMMM


Replace KK with the effect byte of Flame Orb.
Replace LL with the effect byte of Toxic Orb.


Battle script at MMMMMM:
Spoiler:

Code:

F8 VV+1 VV VV 08 39 40 00 64 01 FB 20 C0 03 02 RR RR RR 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at VVVVVV:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x10
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1





String at RRRRRR:
Code:

FD 0F 00 EB D5 E7 00 D6 E9 E6 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 C0 E0 D5 E1 D9 00 C9 E6 D6 AB FF


Battle Script at PPPPPP:
Spoiler:

Code:

F8 WW+1 WW WW 08 39 40 00 64 01 FB 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at WWWWWW:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x80
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1




String at SSSSSS:
Code:

FD 0F 00 EB D5 E7 00 D6 D5 D8 E0 ED 00 E4 E3 DD E7 E3 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 CE E3 EC DD D7 00 C9 E6 D6 AB


Some info about the table
Spoiler:

This table controls the order of end turn events like (weather, some end turn abilities, pinch berries, poison damage etc.) and executes them.
Interchanging the order of the table entries results in change of the order of their execution at the end turn. i.e You can make the 'Ingrain Healing' script play after the 'Burn Damaging' script by changing the order.
By expanding the table you can add things like Aqua Ring (prefably should be placed near the 1st entry which is for Ingrain), custom counters etc.





kleenexfeu May 29th, 2015 11:16 AM

Quote:

Originally Posted by KDS (Post 8772423)
Flame Orb and Toxic Orb

Spoiler:

Inserting this is a bit complicated than other items. Also was the most challenging to implement.
Anyways, here are the steps:
Step I
Spoiler:

Select the bytes from x182FC to x1834B. This is a table and we are going to repoint it.
Search for 80 (or 0x50) bytes of contiguous free space and then copy and paste the table.
Now go to x18F28 and insert the pointer of the new location of our table. For example, if the table is at 0x731240 then in reverse it would be 40 12 73 08.


Step II
Spoiler:

Insert this routine in free space.

Routine at XXXXXX:
Spoiler:

EEEEEE is location for a battle script to be inserted which I will tell later.
Code:

.text
.align 2
.thumb
.thumb_func
.global orbz

ldr r5, =0x2023fe8
ldr r5, [r5]
ldrb r0, [r5, #0x1]
ldr r2, =0x2023BCC
ldrb r2, [r2]
add r0, #0x1
cmp r0, r2
bne Exit
ldr r0, =0x02023D6E
mov r2, #0x0
strb r2, [r0]
ldr r0, =0x08EEEEEE
ldr r2, =0x08018C05
bx r2

Exit:
ldr r2, =0x08018C13
bx r2




Now expand the table in such a way that XX XX XX 08 (Don't use +1 in this case) is the second last entry of the table (do not remove the old entries). This ensures that the orbs will activate at the extreme end of a turn after ingrain, weather damage etc.
The last entry should be 38 8C 01 08 (which is there in the original) because it successfully terminates the operation of this table.
Since the no. of entries in the table have been changed to 0x14 from 0x13, we need to break the limiters. Goto x182e6 and x18C64 at change it to 0x14.


Step III
Spoiler:

Insert the Battle Scripts and Routines in free space and change the dummy pointers mentioned in the post according to where there are inserted.

Battle Script at EEEEEE:
Code:

F8 ZZ+1 ZZ ZZ 08 3E


Routine at ZZZZZZ:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global orbiterator

Main:
      push {lr}
      ldr r7, .counter
      ldr r6, .battleData
      ldr r5, .bank
      ldr r2, .scriptPointer
      mov r4, #0x58
Loop:
      ldrb r0, [r7]
      ldr r1, .noOfPokes
      ldrb r1, [r1]
      cmp r0, r1
      bge Quit
      ldr r1, .turnOrder
      add r1, r1, r0
      ldrb r1, [r1]
      strb r1, [r5]
      mul r1, r4
      add r3, r1, r6
      add r0, #0x1
      strb r0, [r7]

      ldrh r0, [r3, #0x28]
      cmp r0, #0x0
      beq Loop

      ldr r0, [r3, #0x4C]
      cmp r0, #0x0
      bne Loop

      ldrh r0, [r3, #0x2E]

      bl GetEffectByte
      cmp r0, #0xKK
      beq FlameOrb
      cmp r0, #0xLL
      bne Loop

ToxicOrb:
      add r3, #0x20

      ldrb r0, [r3]
      cmp r0, #0x11
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      ldr r0, .ToxicOrbScript
      b Branch

FlameOrb:
      add r3, #0x20
      ldrb r0, [r3]
      cmp r0, #0x29
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      ldr r0, .FlameOrbScript
Branch:
      sub r0, #0x5
      str r0, [r2]
Quit:
      pop {r0}
      bx r0

GetEffectByte:
      ldr r1, =0x809a925
      bx r1

.align 2
.counter: .word 0x02023D6C
.battleData: .word 0x02023BE4
.bank: .word 0x02023D6B
.scriptPointer: .word 0x02023D74
.noOfPokes: .word 0x02023BCC
.turnOrder: .word 0x02023BDE
.ToxicOrbScript: .word 0x8PPPPPP
.FlameOrbScript: .word 0x8MMMMMM


Replace KK with the effect byte of Flame Orb.
Replace LL with the effect byte of Toxic Orb.


Battle script at MMMMMM:
Spoiler:

Code:

F8 VV+1 VV VV 08 39 40 00 64 01 FB 20 C0 03 02 RR RR RR 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at VVVVVV:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x10
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1





String at RRRRRR:
Code:

FD 0F 00 EB D5 E7 00 D6 E9 E6 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 C0 E0 D5 E1 D9 00 C9 E6 D6 AB FF


Battle Script at PPPPPP:
Spoiler:

Code:

F8 WW+1 WW WW 08 39 40 00 64 01 FB 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at WWWWWW:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x80
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1




String at SSSSSS:
Code:

FD 0F 00 EB D5 E7 00 D6 D5 D8 E0 ED 00 E4 E3 DD E7 E3 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 CE E3 EC DD D7 00 C9 E6 D6 AB


Some info about the table
Spoiler:

This table controls the order of end turn events like (weather, some end turn abilities, pinch berries, poison damage etc.) and executes them.
Interchanging the order of the table entries results in change of the order of their execution at the end turn. i.e You can make the 'Ingrain Healing' script play after the 'Burn Damaging' script by changing the order.
By expanding the table you can add things like Aqua Ring (prefably should be place near the 1st entry which is for Ingrain), custom counters etc.





This is awesome, congrats on that ! You should precise that is for firered, I didn't see it in the post

Trainer 781 May 29th, 2015 11:33 AM

Quote:

Originally Posted by kleenexfeu (Post 8772618)
This is awesome, congrats on that ! You should precise that is for firered, I didn't see it in the post

Thanks. Actually, the first post states that the routines are mainly for Fire Red so I didn't mention it.

Xencleamas May 30th, 2015 11:01 PM

Note: This is not 100% working. I left this here just in case someone would like fix this one.

Quote:

Originally Posted by KDS (Post 8772423)
Flame Orb and Toxic Orb

Spoiler:

Inserting this is a bit complicated than other items. Also this was the most challenging to implement.
Anyways, here are the steps:
Step I
Spoiler:

Select the bytes from x182FC to x1834B. This is a table and we are going to repoint it.
Search for 80 (or 0x50) bytes of contiguous free space and then copy and paste the table.
Now go to x18F28 and insert a series of 4 bytes corresponding to the pointer to the new location of our table. For example, if the table is at 0x731240 then in reverse hex it would be 40 12 73 08.


Step II
Spoiler:

Insert this routine in free space.

Routine at XXXXXX:
Spoiler:

EEEEEE is location for a battle script to be inserted which I will tell about later.
Code:

.text
.align 2
.thumb
.thumb_func
.global orbz

ldr r5, =0x2023fe8
ldr r5, [r5]
ldrb r0, [r5, #0x1]
ldr r2, =0x2023BCC
ldrb r2, [r2]
add r0, #0x1
cmp r0, r2
bne Exit
ldr r0, =0x02023D6E
mov r2, #0x0
strb r2, [r0]
ldr r0, =0x08EEEEEE
ldr r2, =0x08018C05
bx r2

Exit:
ldr r2, =0x08018C13
bx r2




Now expand the table in such a way that XX XX XX 08 (Don't use +1 in this case) is the second last entry of the table (do not remove the old entries). This ensures that the orbs will activate at the extreme end of a turn after ingrain, weather damage etc.
The last entry should be 38 8C 01 08 (which is there in the original) because it successfully terminates the operation of this table.
Since the no. of entries in the table have been changed to 0x14 from 0x13, we need to break the limiters. Goto x182e6 and x18C64 and insert 0x14 there


Step III
Spoiler:

Insert the Battle Scripts and Routines in free space and change the dummy pointers mentioned in the post according to where there are inserted.
Thie battle scripts assume that F8 is the callasm command and FB is the setword command., so change it according to your ROM.

Battle Script at EEEEEE:
Code:

F8 ZZ+1 ZZ ZZ 08 3E


Routine at ZZZZZZ:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global orbiterator

Main:
      push {lr}
      ldr r7, .counter
      ldr r6, .battleData
      ldr r5, .bank
      ldr r2, .scriptPointer
      mov r4, #0x58
Loop:
      ldrb r0, [r7]
      ldr r1, .noOfPokes
      ldrb r1, [r1]
      cmp r0, r1
      bge Quit
      ldr r1, .turnOrder
      add r1, r1, r0
      ldrb r1, [r1]
      strb r1, [r5]
      mul r1, r4
      add r3, r1, r6
      add r0, #0x1
      strb r0, [r7]

      ldrh r0, [r3, #0x28]
      cmp r0, #0x0
      beq Loop

      ldr r0, [r3, #0x4C]
      cmp r0, #0x0
      bne Loop

      ldrh r0, [r3, #0x2E]

      bl GetEffectByte
      cmp r0, #0xKK
      beq FlameOrb
      cmp r0, #0xLL
      bne Loop

ToxicOrb:
      add r3, #0x20

      ldrb r0, [r3]
      cmp r0, #0x11
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      ldr r0, .ToxicOrbScript
      b Branch

FlameOrb:
      add r3, #0x20
      ldrb r0, [r3]
      cmp r0, #0x29
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      ldr r0, .FlameOrbScript
Branch:
      sub r0, #0x5
      str r0, [r2]
Quit:
      pop {r0}
      bx r0

GetEffectByte:
      ldr r1, =0x809a925
      bx r1

.align 2
.counter: .word 0x02023D6E
.battleData: .word 0x02023BE4
.bank: .word 0x02023D6B
.scriptPointer: .word 0x02023D74
.noOfPokes: .word 0x02023BCC
.turnOrder: .word 0x02023BDE
.ToxicOrbScript: .word 0x8PPPPPP
.FlameOrbScript: .word 0x8MMMMMM


Replace KK with the effect byte of Flame Orb.
Replace LL with the effect byte of Toxic Orb.


Battle script at MMMMMM:
Spoiler:

Code:

F8 VV+1 VV VV 08 39 40 00 64 01 FB 20 C0 03 02 RR RR RR 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at VVVVVV:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x10
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1





String at RRRRRR:
Code:

FD 0F 00 EB D5 E7 00 D6 E9 E6 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 C0 E0 D5 E1 D9 00 C9 E6 D6 AB FF


Battle Script at PPPPPP:
Spoiler:

Code:

F8 WW+1 WW WW 08 39 40 00 64 01 FB 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at WWWWWW:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x80
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1




String at SSSSSS:
Code:

FD 0F 00 EB D5 E7 00 D6 D5 D8 E0 ED 00 E4 E3 DD E7 E3 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 CE E3 EC DD D7 00 C9 E6 D6 AB


Some info about the table
Spoiler:

This table controls the order of end turn events like (weather, some end turn abilities, pinch berries, poison damage etc.) and executes them.
Interchanging the order of the table entries results in change of the order of their execution at the end turn. i.e You can make the 'Ingrain Healing' script play after the 'Burn Damaging' script by changing the order.
By expanding the table you can add things like Aqua Ring (prefably should be placed near the 1st entry which is for Ingrain), custom counters etc.





Nice work KDS... I have somehow change the offsets which would work on Emerald:

Spoiler:

Inserting this is a bit complicated than other items. Also this was the most challenging to implement.
Anyways, here are the steps:
Step I
Spoiler:

Select the bytes from x409C8 to x40A17. This is a table and we are going to repoint it.
Search for 80 (or 0x50) bytes of contiguous free space and then copy and paste the table.
Now go to x41644 and insert a series of 4 bytes corresponding to the pointer to the new location of our table. For example, if the table is at 0xDE4B40 then in reverse hex it would be 40 4B DE 08.


Step II
Spoiler:

Insert this routine in free space.

Routine at XXXXXX:
Spoiler:

EEEEEE is location for a battle script to be inserted which I will tell about later.
Code:

.text
.align 2
.thumb
.thumb_func
.global orbz

ldr r5, =0x202449C
ldr r5, [r5]
ldrb r0, [r5, #0x1]
ldr r2, =0x202406C
ldrb r2, [r2]
add r0, #0x1
cmp r0, r2
bne Exit
ldr r0, =0x0202420E
mov r2, #0x0
strb r2, [r0]
ldr r0, =0x08EEEEEE
ldr r2, =0x080412D1
bx r2

Exit:
ldr r2, =0x080412DF
bx r2




Now expand the table in such a way that XX XX XX 08 (Don't use +1 in this case) is the second last entry of the table (do not remove the old entries). This ensures that the orbs will activate at the extreme end of a turn after ingrain, weather damage etc.
The last entry should be 04 13 04 08 (which is there in the original) because it successfully terminates the operation of this table.
Since the no. of entries in the table have been changed to 0x14 from 0x13, we need to break the limiters. Goto x409B2 and x41330 and insert 0x14 there


Step III
Spoiler:

Insert the Battle Scripts and Routines in free space and change the dummy pointers mentioned in the post according to where there are inserted.
Thie battle scripts assume that F9 is the callasm command and FA is the setword command., so change it according to your ROM.

Battle Script at EEEEEE:
Code:

F9 ZZ+1 ZZ ZZ 08 3E


Routine at ZZZZZZ:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global orbiterator

Main:
      push {lr}
      ldr r7, .counter
      ldr r6, .battleData
      ldr r5, .bank
      ldr r2, .scriptPointer
      mov r4, #0x58
Loop:
      ldrb r0, [r7]
      ldr r1, .noOfPokes
      ldrb r1, [r1]
      cmp r0, r1
      bge Quit
      ldr r1, .turnOrder
      add r1, r1, r0
      ldrb r1, [r1]
      strb r1, [r5]
      mul r1, r4
      add r3, r1, r6
      add r0, #0x1
      strb r0, [r7]

      ldrh r0, [r3, #0x28]
      cmp r0, #0x0
      beq Loop

      ldr r0, [r3, #0x4C]
      cmp r0, #0x0
      bne Loop

      ldrh r0, [r3, #0x2E]

      bl GetEffectByte
      cmp r0, #0xKK
      beq FlameOrb
      cmp r0, #0xLL
      bne Loop

ToxicOrb:
      add r3, #0x20

      ldrb r0, [r3]
      cmp r0, #0x11
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      ldr r0, .ToxicOrbScript
      b Branch

FlameOrb:
      add r3, #0x20
      ldrb r0, [r3]
      cmp r0, #0x29
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      ldr r0, .FlameOrbScript
Branch:
      sub r0, #0x5
      str r0, [r2]
Quit:
      pop {r0}
      bx r0

GetEffectByte:
      ldr r1, =0x80D74DD
      bx r1

.align 2
.counter: .word 0x0202420E
.battleData: .word 0x02024084
.bank: .word 0x0202420B
.scriptPointer: .word 0x02024214
.noOfPokes: .word 0x0202406C
.turnOrder: .word 0x0202407E
.ToxicOrbScript: .word 0x8PPPPPP
.FlameOrbScript: .word 0x8MMMMMM


Replace KK with the effect byte of Flame Orb.
Replace LL with the effect byte of Toxic Orb.


Battle script at MMMMMM:
Spoiler:

Code:

F9 VV+1 VV VV 08 39 40 00 64 01 FA 20 C0 03 02 RR RR RR 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at VVVVVV:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x0202420B
ldrb r0, [r3]
ldr r1, =0x02024084
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x10
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02024064
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x08033901
bx r6

function2:
ldr r1, =0x0803F801
bx r1





String at RRRRRR:
Code:

FD 0F 00 EB D5 E7 00 D6 E9 E6 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 C0 E0 D5 E1 D9 00 C9 E6 D6 AB FF


Battle Script at PPPPPP:
Spoiler:

Code:

F9 WW+1 WW WW 08 39 40 00 64 01 FA 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at WWWWWW:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x0202420B
ldrb r0, [r3]
ldr r1, =0x02024084
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x80
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02024064
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x08033901
bx r6

function2:
ldr r1, =0x0803F801
bx r1




String at SSSSSS:
Code:

FD 0F 00 EB D5 E7 00 D6 D5 D8 E0 ED 00 E4 E3 DD E7 E3 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 CE E3 EC DD D7 00 C9 E6 D6 AB


Some info about the table
Spoiler:

This table controls the order of end turn events like (weather, some end turn abilities, pinch berries, poison damage etc.) and executes them.
Interchanging the order of the table entries results in change of the order of their execution at the end turn. i.e You can make the 'Ingrain Healing' script play after the 'Burn Damaging' script by changing the order.
By expanding the table you can add things like Aqua Ring (prefably should be placed near the 1st entry which is for Ingrain), custom counters etc.






I only changed the offsets used in the ASMs and Battle Script commands. I haven't changed offsets in Battle Scripts. I just dunno which is right which will work on Emerald. I haven't tested this yet so KDS, hope you can help me this one now.

Replace KK with the effect byte of Flame Orb.
Replace LL with the effect byte of Toxic Orb.


Quick question: What do you mean for this one? Is it the item number of those two or is it something it has to do on the expanded table on the first step? I'm really confuse with this one. :/

Trainer 781 May 30th, 2015 11:35 PM

Quote:

Originally Posted by Sky High (Post 8775210)
Quick question: What do you mean for this one? Is it the item number of those two or is it something it has to do on the expanded table on the first step? I'm really confuse with this one. :/

http://www.pokecommunity.com/showthread.php?t=335014
Refer to this thread about info on held items and effect byte. Also good job porting, I might test this myself.

EDIT: Didn't read the first point regarding the offsets. In the battle scripts, change the first paramter of setword command to x203e320 from x203c020 in reverse hex. Also make the battle string loader has the same offset as the parameter.

kleenexfeu May 31st, 2015 1:48 AM

Quote:

Originally Posted by KDS (Post 8772423)
Flame Orb and Toxic Orb

Spoiler:

Inserting this is a bit complicated than other items. Also this was the most challenging to implement.
Anyways, here are the steps:
Step I
Spoiler:

Select the bytes from x182FC to x1834B. This is a table and we are going to repoint it.
Search for 80 (or 0x50) bytes of contiguous free space and then copy and paste the table.
Now go to x18F28 and insert a series of 4 bytes corresponding to the pointer to the new location of our table. For example, if the table is at 0x731240 then in reverse hex it would be 40 12 73 08.


Step II
Spoiler:

Insert this routine in free space.

Routine at XXXXXX:
Spoiler:

EEEEEE is location for a battle script to be inserted which I will tell about later.
Code:

.text
.align 2
.thumb
.thumb_func
.global orbz

ldr r5, =0x2023fe8
ldr r5, [r5]
ldrb r0, [r5, #0x1]
ldr r2, =0x2023BCC
ldrb r2, [r2]
add r0, #0x1
cmp r0, r2
bne Exit
ldr r0, =0x02023D6E
mov r2, #0x0
strb r2, [r0]
ldr r0, =0x08EEEEEE
ldr r2, =0x08018C05
bx r2

Exit:
ldr r2, =0x08018C13
bx r2




Now expand the table in such a way that XX XX XX 08 (Don't use +1 in this case) is the second last entry of the table (do not remove the old entries). This ensures that the orbs will activate at the extreme end of a turn after ingrain, weather damage etc.
The last entry should be 38 8C 01 08 (which is there in the original) because it successfully terminates the operation of this table.
Since the no. of entries in the table have been changed to 0x14 from 0x13, we need to break the limiters. Goto x182e6 and x18C64 and insert 0x14 there


Step III
Spoiler:

Insert the Battle Scripts and Routines in free space and change the dummy pointers mentioned in the post according to where there are inserted.
Thie battle scripts assume that F8 is the callasm command and FB is the setword command., so change it according to your ROM.

Battle Script at EEEEEE:
Code:

F8 ZZ+1 ZZ ZZ 08 3E


Routine at ZZZZZZ:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func
.global orbiterator

Main:
      push {lr}
      ldr r7, .counter
      ldr r6, .battleData
      ldr r5, .bank
      ldr r2, .scriptPointer
      mov r4, #0x58
Loop:
      ldrb r0, [r7]
      ldr r1, .noOfPokes
      ldrb r1, [r1]
      cmp r0, r1
      bge Quit
      ldr r1, .turnOrder
      add r1, r1, r0
      ldrb r1, [r1]
      strb r1, [r5]
      mul r1, r4
      add r3, r1, r6
      add r0, #0x1
      strb r0, [r7]

      ldrh r0, [r3, #0x28]
      cmp r0, #0x0
      beq Loop

      ldr r0, [r3, #0x4C]
      cmp r0, #0x0
      bne Loop

      ldrh r0, [r3, #0x2E]

      bl GetEffectByte
      cmp r0, #0xKK
      beq FlameOrb
      cmp r0, #0xLL
      bne Loop

ToxicOrb:
      add r3, #0x20

      ldrb r0, [r3]
      cmp r0, #0x11
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0x3
      beq Loop

      cmp r0, #0x8
      beq Loop

      ldr r0, .ToxicOrbScript
      b Branch

FlameOrb:
      add r3, #0x20
      ldrb r0, [r3]
      cmp r0, #0x29
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      add r3, #0x1
      ldrb r0, [r3]
      cmp r0, #0xA
      beq Loop

      ldr r0, .FlameOrbScript
Branch:
      sub r0, #0x5
      str r0, [r2]
Quit:
      pop {r0}
      bx r0

GetEffectByte:
      ldr r1, =0x809a925
      bx r1

.align 2
.counter: .word 0x02023D6E
.battleData: .word 0x02023BE4
.bank: .word 0x02023D6B
.scriptPointer: .word 0x02023D74
.noOfPokes: .word 0x02023BCC
.turnOrder: .word 0x02023BDE
.ToxicOrbScript: .word 0x8PPPPPP
.FlameOrbScript: .word 0x8MMMMMM


Replace KK with the effect byte of Flame Orb.
Replace LL with the effect byte of Toxic Orb.


Battle script at MMMMMM:
Spoiler:

Code:

F8 VV+1 VV VV 08 39 40 00 64 01 FB 20 C0 03 02 RR RR RR 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at VVVVVV:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x10
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1





String at RRRRRR:
Code:

FD 0F 00 EB D5 E7 00 D6 E9 E6 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 C0 E0 D5 E1 D9 00 C9 E6 D6 AB FF


Battle Script at PPPPPP:
Spoiler:

Code:

F8 WW+1 WW WW 08 39 40 00 64 01 FB 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 98 01 28 EE EE EE 08




Routine at WWWWWW:
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

push {lr}
add sp, #-0x8
ldr r3, =0x02023D6B
ldrb r0, [r3]
ldr r1, =0x02023BE4
mov r6, #0x58
mul r0, r6
add r5, r1, #0x0
add r5, #0x4C
add r2, r0, r5
ldr r0, [r2, #0x0]
mov r1, #0x80
orr r0, r1
str r0, [r2, #0x0]
ldr r4, =0x02023BC4
ldrb r0, [r3]
strb r0, [r4, #0x0]
ldrb r0, [r4, #0x0]
mul r0, r6
add r0, r0, r5
str r0, [sp, #0x0]
mov r0, #0x0
mov r1, #0x28
mov r2, #0x0
mov r3, #0x4
bl function1
ldrb r0, [r4, #0x0]
bl function2
add sp, #0x8
pop {r0}
bx r0

function1:
ldr r6, =0x0800DFF1
bx r6

function2:
ldr r1, =0x08017249
bx r1




String at SSSSSS:
Code:

FD 0F 00 EB D5 E7 00 D6 D5 D8 E0 ED 00 E4 E3 DD E7 E3 E2 D9 D8 FE D6 ED 00 E8 DC D9 00 CE E3 EC DD D7 00 C9 E6 D6 AB


Some info about the table
Spoiler:

This table controls the order of end turn events like (weather, some end turn abilities, pinch berries, poison damage etc.) and executes them.
Interchanging the order of the table entries results in change of the order of their execution at the end turn. i.e You can make the 'Ingrain Healing' script play after the 'Burn Damaging' script by changing the order.
By expanding the table you can add things like Aqua Ring (prefably should be placed near the 1st entry which is for Ingrain), custom counters etc.





I thought about something, I didn't take a look into it yet but, do you think we could use the same place for life orb ? If you can give a statut we could also make the pok takes damages. For Bad Dreams I made a simple operation and put the result at 020241F0 (if I remember well, and in Emerald), could it be possible the same way here ?

Trainer 781 May 31st, 2015 3:07 AM

Quote:

Originally Posted by kleenexfeu (Post 8775361)
I thought about something, I didn't take a look into it yet but, do you think we could use the same place for life orb ? If you can give a statut we could also make the pok takes damages. For Bad Dreams I made a simple operation and put the result at 020241F0 (if I remember well, and in Emerald), could it be possible the same way here ?

IMO, the life orb recoil should pe part of a damaging battle script. It means to make an hook in an existing BS command that appears in all damaging battle scripts and then inserting the life orb logic.

MrDollSteak May 31st, 2015 3:38 AM

Quote:

Originally Posted by KDS (Post 8775431)
IMO, the life orb recoil should pe part of a damaging battle script. It means to make an hook in an existing BS command that appears in all damaging battle scripts and then inserting the life orb logic.

Probably the Set effect with chance command would make sense, or the faint Pokemon command.
Those are in all of them I believe.

It would also allow for life orb damage to be blocked by Sheer Force more easily as the best place for the Sheer Force check is in the set effect with chance command anyway.

Trainer 781 May 31st, 2015 4:24 AM

Quote:

Originally Posted by MrDollSteak (Post 8775448)
Probably the Set effect with chance command would make sense, or the faint Pokemon command.
Those are in all of them I believe.

It would also allow for life orb damage to be blocked by Sheer Force more easily as the best place for the Sheer Force check is in the set effect with chance command anyway.

Yes, these commands look the best place.
The only problem to solve is to make a command push more than one Battle Scripts per command.
These commands already have a chance to push another battle script for burn,recoil, item knock off, etc.

jiangzhengwenjzw June 2nd, 2015 5:34 AM

In the "reusable TM" you said
Quote:

To insert:
Do the byte changes below
0x124F78: 00 00 00 00
0x125C80: 00 00 00 00
Make it Ungivable:
insert that at 0x1326B8: 00 00 17 E0

Make it consumable after animation:
Insert: 00 00 00 00 at 0x124F78
But in another post you said
Quote:

TM deletion fix (another one):
This one is for if you try and teach a Pokemon with less than 4 moves a TM. Apparently it does the deletion else where. To fix this insert the following byte changes:
@ 0x124EAC: 00 00 00 00
Should the latter be included in the "reusable TM" post or it is for another hack?

Joexv June 2nd, 2015 5:41 PM

Quote:

Originally Posted by jiangzhengwenjzw (Post 8778625)
In the "reusable TM" you said


But in another post you said


Should the latter be included in the "reusable TM" post or it is for another hack?

Included

jiangzhengwenjzw June 2nd, 2015 11:24 PM

Quote:

Originally Posted by joexv (Post 8779530)
Included

Thank you for your reply. I thought it should be included previously but I'm just not sure as he didn't edit the original post, as you know. XD

Trainer 781 June 7th, 2015 4:11 AM

EV-enhancing items (Power Items)


Spoiler:


The routine now does not require any new Held Effect Item Byte. The new power items are tied to Macho Brace's Held Item Effect Byte. (Thanks to MrDollSteak for giving the idea.)
The type of EV gain is now differentiated by the Second Held Effect Byte (the byte just after the Primary Held Effect Byte in the Item Table).
There is no need to code the Speed Drop explicitly for Power Items.

Usage is now like this by using the following parameters in the Item Table:
Primary Byte | Secondary Byte | Item Name
0x18 | 0x0 | Macho Brace
0x18 | 0x1 | Power Weight
0x18 | 0x2 | Power Bracer
0x18 | 0x3 | Power Belt
0x18 | 0x4 | Power Anklet
0x18 | 0x5 | Power Lens
0x18 | 0x6 | Power Band

Also, there are additional byte changes mentioned in the Spoiler to limit the EVs for each stat from 255 to 252 to avoid wastage of EVs by normal battling.

Fire Red:-
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

Main:
    push {r2}
    mov r0, r8  /*Load pokemon slot no*/
    mov r1, #0xC
    mov r2, #0x0
    bl Decrypter /* Load pokemon's item */
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    pop {r2} /* Restore Pokerus Factor*/
    cmp r0, #0xAF
    beq EnigmaBerry
    add r3, r0, #0x0
    bl GetItemEffect /* Get Held Item's Effect Byte*/
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r0, #0x18
    bne NoPowerItem
    add r0, r3, #0x0
    bl GetSecondEffectByte
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r0, #0x0
    beq MachoBrace
    add r1, r6, #0x1 /*Load a Power Item's Secondary Effect Byte*/
    cmp r1, r0 /*Match items*/
    bne NoPowerItem /*No Power Item or No Match for that particular stat*/
    lsl r2, r2, #0x2
    add r4, r4, r2 /* Add 4 EVs or 8 (due to Pokerus) */
NoPowerItem:
    ldr r3, =0x080439D9
    bx r3

EnigmaBerry:
    ldr r3, =0x0804398F
    bx r3

MachoBrace:
    ldr r3, =0x080439D5
    bx r3

Decrypter:
    ldr r3, =0x0803FBE9
    bx r3

GetItemEffect:
    ldr r1, =0x0809A925
    bx r1

GetSecondEffectByte:
    ldr r1, =0x0809A949
    bx r1

/*At 43978: 04 1C 54 43 00 49 08 47 XX+1 XX XX 08 00 00 00 00 00 00 00 00 00 00*/
/*At 439FC && 43A02: FC to limit EV growth for each stat to 252 */




Emerald:-
Spoiler:

Code:

.text
.align 2
.thumb
.thumb_func

Main:
    push {r2}
    mov r0, r8  /*Load pokemon slot no*/
    mov r1, #0xC
    mov r2, #0x0
    bl Decrypter /* Load pokemon's item */
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    pop {r2} /* Restore Pokerus Factor*/
    cmp r0, #0xAF
    beq EnigmaBerry
    add r3, r0, #0x0
    bl GetItemEffect /* Get Held Item's Effect Byte*/
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r0, #0x18
    bne NoPowerItem
    add r0, r3, #0x0
    bl GetSecondEffectByte
    lsl r0, r0, #0x18
    lsr r0, r0, #0x18
    cmp r0, #0x0
    beq MachoBrace
    add r1, r6, #0x1 /*Load a Power Item's Secondary Effect Byte*/
    cmp r1, r0 /*Match items*/
    bne NoPowerItem /*No Power Item or No Match for that particular stat*/
    lsl r2, r2, #0x2
    add r4, r4, r2 /* Add 4 EVs or 8 (due to Pokerus) */
NoPowerItem:
    ldr r3, =0x0806DC25
    bx r3

EnigmaBerry:
    ldr r3, =0x0806DBDB
    bx r3

MachoBrace:
    ldr r3, =0x0806DC21
    bx r3

Decrypter:
    ldr r3, =0x0806A519
    bx r3

GetItemEffect:
    ldr r1, =0x080D74DD
    bx r1

GetSecondEffectByte:
    ldr r1, =0x080D7501
    bx r1

/*At 6DBC4: 04 1C 54 43 00 49 08 47 XX+1 XX XX 08 00 00 00 00 00 00 00 00 00 00*/
/*At 6DC48 && 6DC4E: FC to limit EV growth for each stat to 252 */






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


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.