< >
Hello, guest! Please log in or register.

The PokéCommunity

Go Back     The PokéCommunity Forums > ROM Hacking > Research & Development Development Double Wild Pokémon Battles in Emerald

Notices

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. 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!
Research & Development programs in this forum are subject to moderator approval before they are displayed.

Reply Post Reply
 
Thread Tools
  #1    
Old January 27th, 2016 (9:17 AM).
GoGoJJTech's Avatar
GoGoJJTech GoGoJJTech is offline
http://GoGoJJTech.com (WIP!)
Gold Tier
 
Join Date: Nov 2012
Location: Earth
Age: 17
Gender: Female
Nature: Jolly
Posts: 2,416


So I ported what was on this thread, which was ported from Jambo51's 649 patch.

Simply put, it's the same thing, you just need a bunch of changes

Before I put the code up, I'll list the issues:
  1. You can use the bag twice (two pokeballs for example [dunno how it's handled in Unova games])
  2. You can run twice (Can't escape! Got away safely! [still dunno how it works in Unova games])
  3. Upon fainting, it asks if you want to send out the next Pokémon or run. If both faint, it does it twice (still have no idea how it works in blah blah blah games)
  4. The Pokémon in slot 0 (the one on the right) is the one displayed when you successfully catch
  5. Only the 0th Pokémon (the one on the right again) is faded in the battle intro

So the code:
Spoiler:
1.asm:
Spoiler:
Code:
.thumb
/*0xB4F30 -  05 49 08 47
0xB4F48 - XX+1 XX XX 08
0xB06D4 - 00 00*/

str r0, [sp]
ldr r0, .opponent_slot
mov r1, r6 @Pokemon
mov r2, r7 @Level
mov r3, #0x20
ldr r4, .pokemon_make_with_nature
bl linker_4
mov r1, #0
mov r2, #0

loop_1:
mov r4, #0x64
ldr r0, .party_slot
add r0, #0x56
mul r4, r1
add r0, r0, r4
ldrh r0, [r0]
cmp r0, #0
bne add_1

increment:
add r1, #1
cmp r1, #6
bne loop_1
cmp r2, #2
blt back_1
ldr r1, .offset
ldr r2, .save_block_1
ldr r2, [r2]
ldrb r3, [r2, #4] @bank
lsl r3, r3, #2
add r1, r1, r3
ldr r1, [r1]
ldrb r3, [r2, #5] @map
lsl r3, r3, #2
add r1, r1, r3
ldr r1, [r1]
ldr r1, [r1]
ldr r3, [r1, #0x10]
ldr r2, .tileset_table
cmp r3, r2
bne back_1
bl get_block_id
mov r2, #0

loop_2:
mov r1, pc
add r1, #0x92
lsl r3, r2, #2
add r1, r1, r3
ldrh r3, [r1]
cmp r0, r3
beq calculation
ldr r1, .end
cmp r1, r3
beq back_1
add r2, #1
b loop_2

add_1:
add r2, #1
b increment

back_1:
mov r0, #0
ldr r1, .battle_flag
str r0, [r1]

back_2:
add sp, sp, #0xC
pop {r4-r7, pc}

get_block_id:
push {lr}
ldr r0, .npc_state
ldrh r1, [r0, #0x12] @Y
ldrh r0, [r0, #0x10] @X
ldr r4, .getter
bl linker_4
pop {pc}

calculation:
ldrb r4, [r1, #2]
cmp r4, #0x63
bhi doubletwo
bl random
mov r1, #0x64
bl mod_func

doublethree:
add r1, r4, #0
cmp r0, r1
bge back_1

double: 
mov r0, #1
ldr r1, .battle_flag
str r0, [r1]
ldr r4, .rand_grass
bl linker_4
ldr r1, [sp, #0x10]
ldr r1, [r1, #4]
lsl r0, r0, #2
add r0, r0, r1
ldrh r4, [r0, #2]
ldr r1, .generate
bl linker_1
mov r7, r0
bl random
mov r1, #0x19
bl mod_func
ldr r0, .opponent_slot
add r0, #0x64
mov r1, r4 @Pokemon
mov r2, r7 @Level
mov r3, #0x20
ldr r4, .pokemon_make_with_nature
bl linker_4
b back_2

doubletwo:
mov r0, #0
b doublethree

mod_func:
ldr r3, .mod_addr
bx r3

random:
ldr r2, .rand
bx r2

linker_1:
bx r1

linker_4:
bx r4

.word 0x0005000D
.word 0x000501C6
.word 0x000501C7
.hword 0xFEFE

.align 2
.opponent_slot: .word 0x02024744
.pokemon_make_with_nature: .word 0x08067E90+1
.party_slot: .word 0x020244EC
.battle_flag: .word 0x02022FEC
.offset: .word 0x08486578
.save_block_1: .word 0x03005D8C
.tileset_table: .word 0x083DF704
.npc_state: .word 0x02037350
.getter: .word 0x08088224+1
.end: .word 0x0000FEFE
.mod_addr: .word 0x082E7BE0+1
.rand: .word 0x0806F5CC+1
.rand_grass: .word 0x080B4AC8+1
.generate: .word 0x08E40900+1 @pointer to generate.asm+1

2.asm:
Spoiler:
Code:
.thumb
.align 2
/*0x3ED80 - 00 48 00 47 JJ+1 JJ JJ 08*/
ldr r0, [r1]
cmp r0, #5
beq .L_1
mov r1, #1
and r0, r1
cmp r0, #0
bne .L_0

.L_1:
ldr r1, =0x803ED8A+1
bx r1

.L_0:
ldr r1, =0x803EE06+1
bx r1

3.asm:
Spoiler:
Code:
.thumb
.align 2
/*4A60A - 00 47
4A654 - ZZ+1 ZZ ZZ 08*/
ldr r0, =0x2022FEC
ldr r0, [r0]
cmp r0, #5
beq double

audio:
ldr r0, =0x161
ldr r1, =0x80A3778+1
bl jump
ldr r1, =0x804A60E+1

jump:
bx r1

double:
ldr r0, =0x2024084+0x58
mov r1, #0x58
lsl r1, r1, #1
add r1, r0, r1
ldrh r0, [r0, #0x28]
ldrh r1, [r1, #0x28]
add r0, r0, r1
cmp r0, #0
beq audio
ldr r1, =0x804A616+1
bx r1

4.asm:
Spoiler:
Code:
.thumb
.align 2
/*0x56318 - 30 47
0x5634C - MM+1 MM MM 08
0x566BC - 00 00
0x56702 - 00 00
0x5674E - 00 00
0x5679E - 00 00
0x56DF2 - 08 1C
0x56D14 - 00 00
0x56D40 - 00 00
0x56D60 - 00 00
0x56D7E - 04 1C
0x5671C - 0C 42 02 02
0x56840 - 0C 42 02 02
0x56DC0 - 0C 42 02 02
0x56E20 - 0C 42 02 02*/
ldr r6, =0x2022FEC
ldr r6, [r6]
cmp r6, #5
bne normal
ldr r6, =0x2024084+0x58
ldrh r6, [r6, #0x28]
cmp r6, #0
bne case_1

case_2:
mov r0, #3
b back

case_1:
mov r0, #1
b back

normal:
mov r1, #1
eor r0, r1

back:
ldr r6, =0x202420C
ldr r1, =0x805631C+1
bx r1

5.asm:
Spoiler:
Code:
.thumb
.align 2
/*0x56850 - 00 48 00 47 NN+1 NN NN 08*/
push {r4, r5, lr}
ldr r4, =0x02024744
ldr r0, =0x0202420C
ldrb r0, [r0]
lsr r0, r0, #1
mov r1, #0x64
mul r0, r1
add r0, r0, r4
add r4, r0, #0
mov r1, #0xb
ldr r2, =0x08056858+1
bx r2

6.asm:
Spoiler:
Code:
.thumb
.align 2
/*0x568D2 - 00 47
0x568F4 - UU+1 UU UU 08*/
ldr r0, =0x02024744
ldr r1, =0x0202420C
ldrb r1, [r1]
lsr r1, r1, #1
mov r2, #0x64
mul r1, r2
add r0, r1, r0
mov r1, #0xb
ldr r2, =0x080568D4+1
bx r2

7.asm:
Spoiler:
Code:
.thumb
.align 2
/*0x170E50 - 10 47
0x170ED8 - QQ+1 QQ QQ 08*/
ldr r2, =0x02038437
ldr r0, =0x02022FEC
ldr r0, [r0]
cmp r0, #5
bne normal
ldr r0, =0x02024084+0x58
mov r1, #0x58
lsl r1, r1, #1
add r1, r0, r1
ldrh r1, [r1, #0x28]
cmp r1, #0
beq normal
mov r1, #3
strb r1, [r2]

normal:
mov r8, r2
ldr r0, =0x08170E52+1
bx r0

pokeball.asm:
Spoiler:
Code:
.thumb
/*Change all 95 E3 0F 08 to the pointer (+1) to this routine, and please do the change before inserting the routine!!!!!!!!!!!!!!!!!!*/
ldr r1, .battle_flag
ldr r1, [r1]
cmp r1, #5
bne normal
ldr r1, .struct
mov r2, #0x58
lsl r2, r2, #1
add r2, r1, r2
ldrh r1, [r1, #0x28]
ldrh r2, [r2, #0x28]
mul r1, r2
cmp r1, #0
bne two_mon
normal:
ldr r1, .pokeball
bx r1
two_mon:
push {r4,r5, lr}
mov r0, #0
mov r1, #2
ldr r2, .string_shown
ldr r3, .bag_print
ldr r4, .texter
bl jump
pop {r4,r5, pc}
jump:
bx r4

.align 2
.battle_flag: .word 0x2022FEC
.pokeball:  .word 0x80FE394+1
.struct: .word 0x2024084+0x58
.bag_print: .word 0x81ABBBC+1
.texter: .word 0x081ABB4C+1
.string_shown: .word 0x08E40A00 @Pointer to text

generate.asm:
Spoiler:
Code:
.thumb
PUSH    {R4,R5,LR}
MOV    R4, R0
LDRB    R0, [R4,#1]
LDRB    R1, [R4]
CMP     R0, R1
BCC     loc_1
LDRB    R5, [R4]
B       loc_2

loc_1:  LDRB    R5, [R4,#1]
LDRB    R0, [R4]
loc_2: SUB    R4, R0, R5
ADD    R4, #1
LSL    R4, R4, #0x18
LSR    R4, R4, #0x18
LDR    R3, =0x806F5CC+1 @rand
BL      linker
LSL    R0, R0, #0x10
LSR    R0, R0, #0x10
MOV    R1, R4
LDR    R3, =0x82E7650+1 @__modsi3
BL      linker
LSL    R0, R0, #0x18
LSR    R0, R0, #0x18
ADD    R0, R5, R0
LSL    R0, R0, #0x18
LSR    R0, R0, #0x18
POP     {R4,R5}
POP     {R1}
BX      R1

linker: bx R3


generate.asm is not present in the FireRed versions of this implementation. The reason is that this function is actually from FireRed. Since it's not present in Emerald, I just copied it. Just thought you might want to know since this'd make the overall size of this hack larger than the FireRed one.

1.asm generates a table
Code:
.word 0x0005000D
.word 0x000501C6
.word 0x000501C7
.hword 0xFEFE
0005 = 0x5
000D = 0xD
the 5 is the percent chance that a double wild battle will occur. To have double wild battles every single time, you'd put 0x64 (100 in decimal)
0xD is the tile in the tileset that it will occur in. The tiles I have here are the grass tiles used in general areas in Emerald, tileset 0 of course.
0xFEFE ends the table, so be sure to keep it at the end!

This hack does not allow double wild Pokémon if the player only has one Pokémon available to battle!
Reply With Quote

Relevant Advertising!

  #2    
Old January 27th, 2016 (11:47 AM). Edited January 27th, 2016 by Team Fail.
Team Fail's Avatar
Team Fail Team Fail is offline
burning passion
ModeratorCS
 
Join Date: May 2009
Location: yes
Age: 21
Gender: Male
Nature: Brave
Posts: 12,298
Quote:
Originally Posted by GoGoJJTech View Post
  1. You can use the bag twice (two pokeballs for example [dunno how it's handled in Unova games])
  2. You can run twice (Can't escape! Got away safely! [still dunno how it works in Unova games])
  3. Upon fainting, it asks if you want to send out the next Pokémon or run. If both faint, it does it twice (still have no idea how it works in blah blah blah games)
1. Bag is allowed to be used twice (Example: healing), although I'd have to check the case with Pokeballs. I can test this for you really quickly here.
2. I think Run is only done once.
3. Same as above, I can check for you, however, I think what happens is once a Pokemon faints, the game will immediately make you send out a replacement.

Give me 10 minutes and I can check both for you :)

Okay, tests indicate:
1. Bag can be used twice for healing. HOWEVER, if a Pokeball is tossed, it can only be on the first Pokemon. If you try to use a Pokeball with the second Pokemon, it'll tell you "It's impossible to aim without being focused!" If you do toss a Pokeball with the first Pokemon, the second Pokemon doesn't get to do anything.
2. First time Run is selected, the game will try to get you to run. If it fails, it skips the second Pokemon.
3. If any Pokemon faint on the field, the game waits for all moves to proceed and all items to be used, then prompts you to send out new Pokemon. If both faint, it'll ask for the first, then immediately after the second, then it'll show them going out.
CONTENTS
001
  COMPUTERS & TECHNOLOGY
002
  VISITOR MESSAGE
003
  PRIVATE MESSAGE
004
  PUSHING BUTTONS
005
  PUSHING BUTTONS BLOG
006
  ALT
007
  PHO
008
  PAIR 1
009
  PAIR 2
010
  TWITTER
SEEN
151

OWN
151
DATA
CRY
AREA
QUIT
Reply With Quote
  #3    
Old January 27th, 2016 (4:52 PM).
Againsts's Avatar
Againsts Againsts is offline
 
Join Date: Aug 2015
Gender: Female
Posts: 19
This is great.
Reply With Quote
  #4    
Old March 13th, 2016 (4:57 PM).
Jaizu's Avatar
Jaizu Jaizu is offline
Spanish Rom Hacker
 
Join Date: Jan 2010
Location: Spain
Gender: Male
Posts: 75
Do you mind about fixing those bugs?
The video looks great, thanks for the port.

RomHack.it! - Website about RomHacking Resources
Reply With Quote
  #5    
Old March 23rd, 2016 (5:46 PM).
Sky High's Avatar
Sky High Sky High is offline
I rebel.
 
Join Date: Feb 2014
Location: Shiganshina District, Wall Maria
Gender: Male
Nature: Adamant
Posts: 390
Quote:
Originally Posted by GoGoJJTech View Post
You can use the bag twice (two pokeballs for example [dunno how it's handled in Unova games])
As far as I remember, you cannot throw a Poke Ball (or any other) when there are two of them. When you faint one of the two, you can now catch the other one.

Example:
  • Turn 1. Poochyena and Zigzagoon. Poke Ball usage disabled.
  • Turn 2. Poochyena has been fainted. Zigzagoon alone. Poke Ball usage enabled.

Hope I'm correct about it.
Reply With Quote
Reply Post Reply
Quick Reply

Sponsored Links
Thread Tools

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

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

Forum Jump


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


Contact Us Archive Privacy Statement Terms of Service Top