The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking > Binary Hack Research & Development
Reload this Page Code ASM 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
  #576   Link to this post, but load the entire thread.  
Old May 7th, 2015 (3:35 PM).
Lance32497's Avatar
Lance32497 Lance32497 is offline
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Posts: 792
Quote:
Originally Posted by eMMe97 View Post
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
__________________
This signature has been disabled.
Scrollbar appears
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Reply With Quote
  #577   Link to this post, but load the entire thread.  
Old May 8th, 2015 (1:47 AM).
eMMe97 eMMe97 is offline
 
Join Date: Jan 2015
Posts: 51
Quote:
Originally Posted by Lance32497 View Post
You should put waitstate
Thank you guy!!! (yes...i'm stupid xD)
Reply With Quote
  #578   Link to this post, but load the entire thread.  
Old May 8th, 2015 (1:56 AM).
Percy's Avatar
Percy Percy is offline
 
Join Date: Sep 2014
Location: Asia
Gender: Male
Nature: Quiet
Posts: 3,045
I have 1 request: you can run away from trainer battles.
__________________
i don't want to have a signature
Reply With Quote
  #579   Link to this post, but load the entire thread.  
Old May 8th, 2015 (12:51 PM).
daniilS's Avatar
daniilS daniilS is offline
busy trying to do stuff not done yet
 
Join Date: Aug 2013
Age: 23
Gender: Male
Posts: 409
Quote:
Originally Posted by Percy View Post
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.
__________________
Reply With Quote
  #580   Link to this post, but load the entire thread.  
Old May 8th, 2015 (4:40 PM).
Deokishisu's Avatar
Deokishisu Deokishisu is offline
Mr. Magius
 
Join Date: Feb 2006
Location: If I'm online, it's a safe bet I'm at a computer.
Gender: Male
Nature: Relaxed
Posts: 984
Quote:
Originally Posted by daniilS View Post
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.
Reply With Quote
  #581   Link to this post, but load the entire thread.  
Old May 13th, 2015 (3:16 PM). Edited May 17th, 2015 by Criminon.
Criminon's Avatar
Criminon Criminon is offline
Forever Spriting
 
Join Date: Aug 2012
Location: California
Gender: Male
Nature: Timid
Posts: 264
Quote:
Originally Posted by FBI agent View Post

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.
__________________
Unbound Team / Crown Team
Reply With Quote
  #582   Link to this post, but load the entire thread.  
Old May 24th, 2015 (2:20 AM). Edited July 28th, 2015 by Trainer 781.
Trainer 781
Guest
 
Posts: n/a
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
Reply With Quote
  #583   Link to this post, but load the entire thread.  
Old May 25th, 2015 (3:13 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 KDS View Post
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.
__________________
Reply With Quote
  #584   Link to this post, but load the entire thread.  
Old May 26th, 2015 (3:15 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by MrDollSteak View Post
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.
Reply With Quote
  #585   Link to this post, but load the entire thread.  
Old May 26th, 2015 (3:47 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 KDS View Post
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).
__________________
Reply With Quote
  #586   Link to this post, but load the entire thread.  
Old May 26th, 2015 (4:02 AM). Edited May 26th, 2015 by Trainer 781.
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by MrDollSteak View Post
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.)
Reply With Quote
  #587   Link to this post, but load the entire thread.  
Old May 28th, 2015 (10:49 PM).
robinjea's Avatar
robinjea robinjea is offline
 
Join Date: Sep 2012
Age: 25
Gender: Male
Nature: Quirky
Posts: 534
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 View Post

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
Reply With Quote
  #588   Link to this post, but load the entire thread.  
Old May 29th, 2015 (7:31 AM). Edited July 18th, 2015 by Trainer 781.
Trainer 781
Guest
 
Posts: n/a
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.




Reply With Quote
  #589   Link to this post, but load the entire thread.  
Old May 29th, 2015 (11:16 AM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by KDS View Post
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
Reply With Quote
  #590   Link to this post, but load the entire thread.  
Old May 29th, 2015 (11:33 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by kleenexfeu View Post
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.
Reply With Quote
  #591   Link to this post, but load the entire thread.  
Old May 30th, 2015 (11:01 PM). Edited June 4th, 2018 by Xencleamas.
Xencleamas's Avatar
Xencleamas Xencleamas is offline
Suddenly lurking in the shadows...
 
Join Date: Feb 2014
Gender: Male
Nature: Adamant
Posts: 456
Note: This is not 100% working. I left this here just in case someone would like fix this one.

Quote:
Originally Posted by KDS View Post
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. :/
__________________
Reply With Quote
  #592   Link to this post, but load the entire thread.  
Old May 30th, 2015 (11:35 PM). Edited June 1st, 2015 by Trainer 781.
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by Sky High View Post
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.
Reply With Quote
  #593   Link to this post, but load the entire thread.  
Old May 31st, 2015 (1:48 AM).
kleenexfeu kleenexfeu is offline
 
Join Date: Aug 2013
Gender: Male
Posts: 218
Quote:
Originally Posted by KDS View Post
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 ?
Reply With Quote
  #594   Link to this post, but load the entire thread.  
Old May 31st, 2015 (3:07 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by kleenexfeu View Post
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.
Reply With Quote
  #595   Link to this post, but load the entire thread.  
Old May 31st, 2015 (3:38 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 KDS View Post
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.
__________________
Reply With Quote
  #596   Link to this post, but load the entire thread.  
Old May 31st, 2015 (4:24 AM).
Trainer 781
Guest
 
Posts: n/a
Quote:
Originally Posted by MrDollSteak View Post
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.
Reply With Quote
  #597   Link to this post, but load the entire thread.  
Old June 2nd, 2015 (5:34 AM).
jiangzhengwenjzw's Avatar
jiangzhengwenjzw jiangzhengwenjzw is offline
now working on katam
 
Join Date: Sep 2012
Gender: Male
Posts: 175
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?
Reply With Quote
  #598   Link to this post, but load the entire thread.  
Old June 2nd, 2015 (5:41 PM).
Joexv's Avatar
Joexv Joexv is offline
ManMadeOfGouda
joexv.github.io
 
Join Date: Oct 2012
Location: Oregon
Age: 25
Gender: Male
Nature: Sassy
Posts: 1,035
Quote:
Originally Posted by jiangzhengwenjzw View Post
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
__________________
New living flesh vessel who dis?
Reply With Quote
  #599   Link to this post, but load the entire thread.  
Old June 2nd, 2015 (11:24 PM).
jiangzhengwenjzw's Avatar
jiangzhengwenjzw jiangzhengwenjzw is offline
now working on katam
 
Join Date: Sep 2012
Gender: Male
Posts: 175
Quote:
Originally Posted by joexv View Post
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
Reply With Quote
  #600   Link to this post, but load the entire thread.  
Old June 7th, 2015 (4:11 AM). Edited June 8th, 2015 by Trainer 781.
Trainer 781
Guest
 
Posts: n/a
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 */


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

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:46 AM.