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!

#1
February 3rd, 2010 (2:36 PM). Edited April 19th, 2010 by HackMew.
 HackMew Mewtwo Strikes Back Crystal Tier Join Date: Jun 2006 Posts: 1,314

# Brief Intro

Here I've got a couple of routines for you. They are designed to get the minimum and maximum levels respectively.

# Description

As you can see, the routines are pretty short and simple so I did not comment them on purpose.
Either way, here's a brief description of what happens:
1. Get the Pokémon party level address into r1.
2. Load the first value into r0, and assume it's the minimum (or maximum) value yet.
3. Loop 5 times, and update the mininum (or maximum) value if needed.
4. Get the LASTRESULT var address into r1 and store the minimum (or maximum) level.
The minimum routine, however, is slighty different because a zero-level is not an acceptable value so there's an extra check to take that into account (otherwhise as long as your team is not full, the minimum level would always be zero, which is no good obviously). That also means the routine will loop up to 5 times rather than always 5 as it happens in the maximum routine.

# The Code

## GetMinPartyLevel

• FireRed/LeafGreen

Code:
```.text
.align 2
.thumb
.thumb_func
.global GetMinPartyLevel

main:
push {r0-r3, lr}
ldr r1, .PARTY_LVL
ldrb r0, [r1]
mov r3, #0x5

loop:
ldrb r2, [r1]
cmp r2, #0x0
beq return
cmp r2, r0
bge next

next:
sub r3, #0x1
cmp r3, #0x0
bne loop

return:
ldr r1, .VAR
strh r0, [r1]
pop {r0-r3, pc}

.align 2
.PARTY_LVL:
.word 0x02024284 + 0x54
.VAR:
.word 0x020270B6 + (0x800D * 2)```
• Ruby/Sapphire

Note: The routine is the same as the FR/LG one; just replace the bottom part with the following:

Code:
```.align 2
.PARTY_LVL:
.word 0x03004360 + 0x54
.VAR:
.word 0x0201E8C2 + (0x800D * 2)```
• Emerald

Note: The routine is the same as the FR/LG one; just replace the bottom part with the following:

Code:
```.align 2
.PARTY_LVL:
.word 0x020244EC + 0x54
.VAR:
.word 0x020275D6 + (0x800D * 2)```

## GetMaxPartyLevel

• FireRed/LeafGreen

Code:
```.text
.align 2
.thumb
.thumb_func
.global GetMaxPartyLevel

main:
push {r0-r3, lr}
ldr r1, .PARTY_LVL
ldrb r0, [r1]
mov r3, #0x5

loop:
ldrb r2, [r1]
cmp r2, r0
ble next

next:
sub r3, #0x1
cmp r3, #0x0
bne loop

return:
ldr r1, .VAR
strh r0, [r1]
pop {r0-r3, pc}

.align 2
.PARTY_LVL:
.word 0x02024284 + 0x54
.VAR:
.word 0x020270B6 + (0x800D * 2)
```
• Ruby/Sapphire

Note: The routine is the same as the FR/LG one; just replace the bottom part with the following:

Code:
```.align 2
.PARTY_LVL:
.word 0x03004360 + 0x54
.VAR:
.word 0x0201E8C2 + (0x800D * 2)```
• Emerald

Note: The routine is the same as the FR/LG one; just replace the bottom part with the following:

Code:
```.align 2
.PARTY_LVL:
.word 0x020244EC + 0x54
.VAR:
.word 0x020275D6 + (0x800D * 2)```

You are not allowed to copy, modify or distribute it without permission.
__________________

#2
February 4th, 2010 (4:33 AM).
 Spherical Ice ModeratorSilver Tier Join Date: Nov 2007 Location: Bristol, UK Age: 19 Posts: 5,149
Wow, this routine unlocks some pretty cool stuff, such as a FR/LG Battle Frontier-style thing (the opponents' Pokémon are the same level as your max Pokémon, for example). It's real cool. Nice one, HackMew!
__________________

A Pokemon that is discriminated!
Support squirtle and make it everyone's favourite.
#3
February 4th, 2010 (9:09 AM).
 0m3GA ARS3NAL Im comin' home... Silver Tier Join Date: Jan 2008 Location: Superjail Penitentiary Age: 24 Gender: Male Nature: Gentle Posts: 1,812
don't mean to put ya down, but couldn't this be done with a script as well?
__________________
>Boot Jailbot
>Pass *****
.
.
Jailbot OS Ver 1.1.2
Greetings Warden
of Superjail Penitentiary
Awaiting user input...

>Display User_Info
╠══User Info══╣
0m3GA ARS3NAL
Age: 18
Sex: Male ♂
Race: Caucasian
Quote:
"What is this
I don't even..."

M/O: Often acts out to get attention, but recently has changed that. Has been studying up on hacking information and hopes to participate in more advanced hacking discussion.
╠══End of File══╣
Awaiting user input...

>
#4
February 4th, 2010 (9:43 AM).
 HackMew Mewtwo Strikes Back Crystal Tier Join Date: Jun 2006 Posts: 1,314
Quote:
 Originally Posted by The Master Wow, this routine unlocks some pretty cool stuff, such as a FR/LG Battle Frontier-style thing (the opponents' Pokémon are the same level as your max Pokémon, for example). It's real cool. Nice one, HackMew!
You're welcome :)

Quote:
 Originally Posted by 0m3GA ARS3NAL don't mean to put ya down, but couldn't this be done with a script as well?
As far as I know, there's no special that can do that. Feel free to prove me wrong.
__________________
#5
February 4th, 2010 (10:22 AM).
 0m3GA ARS3NAL Im comin' home... Silver Tier Join Date: Jan 2008 Location: Superjail Penitentiary Age: 24 Gender: Male Nature: Gentle Posts: 1,812
No specials really it would just be a long script I suppose... Probably much more space-efficient to use your routine... (A script version would require tons of copybyte's and comparefarbytes' as well as knowing RAM locations of variables, it's better to just use your routine and call it with callasm...)
__________________
>Boot Jailbot
>Pass *****
.
.
Jailbot OS Ver 1.1.2
Greetings Warden
of Superjail Penitentiary
Awaiting user input...

>Display User_Info
╠══User Info══╣
0m3GA ARS3NAL
Age: 18
Sex: Male ♂
Race: Caucasian
Quote:
"What is this
I don't even..."

M/O: Often acts out to get attention, but recently has changed that. Has been studying up on hacking information and hopes to participate in more advanced hacking discussion.
╠══End of File══╣
Awaiting user input...

>
#6
February 4th, 2010 (12:14 PM).
 HackMew Mewtwo Strikes Back Crystal Tier Join Date: Jun 2006 Posts: 1,314
Quote:
 Originally Posted by 0m3GA ARS3NAL No specials really it would just be a long script I suppose... Probably much more space-efficient to use your routine... (A script version would require tons of copybyte's and comparefarbytes' as well as knowing RAM locations of variables, it's better to just use your routine and call it with callasm...)
Yeah, indeed. Those routines are definitely more space- and time-efficient then any scripting equivalents.
__________________
#7
February 7th, 2010 (6:28 AM).
 cooley ///Keepin' it simple Silver Tier Join Date: Feb 2007 Location: United States Age: 22 Gender: Male Nature: Impish Posts: 1,147
Nice routine. I'll definitely be using this in the long run, thanks a lot!
__________________
#8
May 16th, 2010 (6:51 PM).
 xGGxToiZ >.//:SO HOT:\\.< Join Date: Mar 2010 Location: We're now near the Tin Tower! . xD Age: 21 Gender: Male Nature: Modest Posts: 44
*Big big Bump*

Wow. This is so cool!
I could use this for my hack

And yeah, it takes less space (about 28 bytes in hex?) than the longer script version.
SO cool.
__________________

JOHTO ELITE FOUR

. . .

 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 [icon] codes HTML code is Off Forum Rules
 Forum Jump Dashboard Private Messages Subscriptions Who's Online Search Forums Forums Home Community Square     Meet & Greet     Feedback & Support         Fan Game Help Pokémon: Main Series Games     Pokémon Ultra Sun & Ultra Moon     Pokémon Sun & Pokémon Moon     Sixth Generation     Fifth Generation     Fourth Generation     Third Generation     Second Generation     First Generation Pokémon: Play Together     Battling & Team Building         Events & Groups Approval     Trade Corner         Trader Reviews         Trade Shops     Challenges         Challenge Logs Pokémon: General Discussions     Pokémon General     Pokémon Gaming Central     Magikarp Jump     Pokémon Anime         Episode Discussion     Pokémon GO     Pokémon Trading Card Game         TCG Deck Reviewing     Pokémon Trivia Fan Games     Fan Games Hub     ROM Hacking         Launchpad         Research & Development         Tools, Tutorials & Resources     ROM Hacks Studio         Progressing ROM Hacks         Sideshow Showcase     PokéCommunity ROM Hack         Applications         Planning     Game Development         Resources         Scripts & Tutorials         Pokémon Essentials     Games Showcase         Progressing Games Create & Discover     Art Studio         A&D School of the Arts     Roleplay Theatre         Roleplay Casting         Roleplay Stage     Fan Fiction and Writing         Writer's Lounge         Fanfiction Archive     PokéCommunity Daily         Published Piece Archive Entertainment & Media     Video Games     Entertainment & Media     Anime & Manga Off-Topic Discussions     Off-Topic     Science & Technology     Discussions & Debates     Forum Games     The Underground         Discussions

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