Advertiser Content

Research Exploring Ruby and Emerald Page 3

Started by LCCoolJ95 March 20th, 2014 12:56 PM
  • 35224 views
  • 137 replies
Male
Seen November 14th, 2017
Posted January 2nd, 2017
83 posts
9.7 Years
Actually when I repointed the Seen/Caught flags, the glitchy scrolling problem went away It seems that the glitchy scrolling problem only happens if I have gaps in the Pokédex. Right now it seemingly works perfectly except for the following problems:
*The flags aren't appearing to be writing to 0x0203D000 even though I made sure they're pointed to
*Scrolling in the dex around 490~ish freezes the game (99% sure it's flag-related)
*When pressing START while in the dex, if you press B without selecting a different dex mode, then the Pokédex list will be blank
*If you scroll up while there are gaps in the Pokédex, it will get a little glitchy

My guess as to what's wrong is that either I did the save block hack wrong, or I just need to pick a different offset for the seen/caught flags.

EDIT: and yes, once this is fully working and documented, of course you'll be credited :)

EDIT: I got the new flags working properly. Now the only problem I have is the glitchy scrolling when scrolling up through blank entries, and the issue where the list appears blank if you press START in the dex but don't change modes.
Try finding the global vars via a debugger as I said above. I am quite sure the english version of emerald contains some differences to the german one. I had those glitches as well but as soon as I fixed all of the global vars (just by adding one to the value of any lsl opcodes that are responsible for the global var offsets) those glitches were fixed and the dex kept working.

I think I also have some german offsets I did not put into the post above, just because I researched them after posting, those should be:

@0x080be8c2: Manual calculus of offset (0x660) -> 09 01
@0x080bd05a: Manual calculus of offset (0x640) -> 12 01
@0x080bd074: Manual calculus of offset (0x640) -> 09 01
@0x080bd08e: Manual calculus of offset (0x640) -> 09 01

I never experieced the bug with the dex menu though. If it persits after you change those values there are definitely differences between the languages(Which I guess is because the C compiler operates differently after all the translations were done in both texts and images)

~SBird
Male
Seen August 19th, 2018
Posted August 19th, 2018
1,312 posts
12 Years
Try finding the global vars via a debugger as I said above. I am quite sure the english version of emerald contains some differences to the german one. I had those glitches as well but as soon as I fixed all of the global vars (just by adding one to the value of any lsl opcodes that are responsible for the global var offsets) those glitches were fixed and the dex kept working.

I think I also have some german offsets I did not put into the post above, just because I researched them after posting, those should be:

@0x080be8c2: Manual calculus of offset (0x660) -> 09 01
@0x080bd05a: Manual calculus of offset (0x640) -> 12 01
@0x080bd074: Manual calculus of offset (0x640) -> 09 01
@0x080bd08e: Manual calculus of offset (0x640) -> 09 01

I never experieced the bug with the dex menu though. If it persits after you change those values there are definitely differences between the languages(Which I guess is because the C compiler operates differently after all the translations were done in both texts and images)

~SBird
Alright, so right now everything is working perfectly EXCEPT the problem that happens with the dex appearing blank when you enter and exit the mode change menu without doing anything. And yes, I found the routines that load the global variables, starting at around 080BB3C2 (although with inferences to your notes, the first variable to change is at BB6B8), but my question is: Did you actually write down every single offset of the variable? Because there's well over 100 of them! At first I just used a hex editor search and replace function to replace any instance of [__ 06 00 00] to [__ 0D 00 00] within the offsets 0xBB6AC-0xC217C (these are the english ROM offsets). But after several tests, I can confirm that something that I changed here is what's causing the blank list to appear, since I redid everything on a separate ROM and can confirm for sure that that's whats causing it. So then I resorted to looking through the routine and writing down every global variable offset, but I stopped after writing down nearly 50 of them, because from what it looks like there's at least 100+ or even 200+ of them. Did you use a search function, or did you actually painstakingly go through the routine and right down every one? If so, major respect to you, my friend.

(In case I didn't make sense, what I need to do is add 0x700 to every 0x000006XX, which is what I've done, but my method of doing it isn't 100% accurate and is causing the blank list glitch, even though I made sure I'm only overwriting offsets that are 4-byte aligned)
Male
Seen November 14th, 2017
Posted January 2nd, 2017
83 posts
9.7 Years
No I didn't go and record every single one I replaced, even though I made sure that the majority is in fact correct and used to define a global var in the pokedex script via the VBA disassembler. I actually wrote a script that goes through the routine and does what I need to do. It also checks if the offset is 4-aligned.

~SBird
Male
Seen August 19th, 2018
Posted August 19th, 2018
1,312 posts
12 Years
Hey guys guess what ;)

Turns out there were a couple extra lsl rX, rX, #0x3 operations that weren't in SBird's notes so I went through parts of the routines and added 1 to them to see what works, and voila, this is now working.

I will post a tutorial soon :)

LCCoolJ95

Limited Capacity

Age 24
Male
The World That Never Was
Seen 20 Hours Ago
Posted 3 Weeks Ago
603 posts
10 Years
Hey Chaos Rush, that's fantastic! But, how many Pokémon can be added? Is it like in Fire Red, where it goes up to 1020, or is it less than that?
"The greatest obstacle in life is Yourself. Overcome it, and you will achieve the greatest accomplishment of all." -Art Beins, 1982

Pokémon Theta Emerald EX: https://www.pokecommunity.com/showthread.php?t=386240
Male
Seen August 19th, 2018
Posted August 19th, 2018
1,312 posts
12 Years
Hey Chaos Rush, that's fantastic! But, how many Pokémon can be added? Is it like in Fire Red, where it goes up to 1020, or is it less than that?
I'm not 100% sure, but I know that it can support at least 744, as when my flags weren't working properly, it would scroll that high when reading from an FFFFFFFFFFFFFFFFF area for the seen/caught flags.

LCCoolJ95

Limited Capacity

Age 24
Male
The World That Never Was
Seen 20 Hours Ago
Posted 3 Weeks Ago
603 posts
10 Years
I'm not 100% sure, but I know that it can support at least 744, as when my flags weren't working properly, it would scroll that high when reading from an FFFFFFFFFFFFFFFFF area for the seen/caught flags.
Whoa, that's good. I don't know why anyone would want that many in their game, but I won't question it hahaha
"The greatest obstacle in life is Yourself. Overcome it, and you will achieve the greatest accomplishment of all." -Art Beins, 1982

Pokémon Theta Emerald EX: https://www.pokecommunity.com/showthread.php?t=386240
Male
Seen January 2nd, 2015
Posted January 2nd, 2015
258 posts
7.1 Years
Whoa, that's good. I don't know why anyone would want that many in their game, but I won't question it hahaha
744 would be alright, if you wanted EVERY single pokemon from X/Y, and a bit more! But then... THAT would be a big hack... with that many pokemon... But... If someone DID achieve that, especially in an emerald rom, you can bet I'd play it... providing it uses good sprites, as in Chaos Rush's thread, and Mr. Dollsteak's thread! And I wonder how the battle frontier would go with that?
░░░░░███████ ]▄▄▄▄▄▄▄▄
▂▄▅█████████▅▄▃▂
Il███████████████████].
◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤..

If you're looking for a good time, or just want to chat, come over to Weloxux and I's channel at:
http://mibbit.com/?server=irc.mibbit.net&channel=%23Dragons_Den

Age 22
Male
Seen December 18th, 2016
Posted October 26th, 2016
253 posts
6.1 Years
So since this is the "Exploring R/S/E" thread, I think this might be a good place to re-post my reply to Artemis64 in the battle backgrounds tutorial. Hopefully someone can make heads and tails of what I've looked into. (I can't really hack as of now)
I think you meant 0x31ABA8. And it seems like Emerald's table format is a bit different from Firered's, so it looks like we'll need a custom routine.
I might as well contribute what I've discovered so far:
0x31ABA8 - 0x31AC6F: Contains 10 battle backgrounds, the outside battle backgrounds and 2 indoor battle backgrounds, I think.
D8 CC D7 08: A pointer to an indoor battle background. This battle background has tiles on it, and its used for places like the Aqua Hideout and the Elite Four. There's probably a separate loading routine, but I haven't looked into this yet.
0x35838: Has a pointer to the Rayquaza battle background (the one with the clouds). This is the only pointer in the rom that points to the Rayquaza battle background. I haven't looked into this either.

I don't have time to look into this, but I guess someone could look into this? Idk hope this helps somewhat.

xGal

Mhm

Non-binary
A tree
Seen February 16th, 2018
Posted May 20th, 2017
243 posts
7.5 Years
expanding the amount of songs
I once made a tutorial on it. You do not need an ASM code for that, you can do it by moving the table to another location and adding this:
XX XX XX 08 00 YY 00 00
XX XX XX is replaced by the pointer and YY is replaced by 00. It can be replaced with 02 or 03 too, but it's more complicated.

Agastya

Grinding failed. Item Grind level dropped by 3.

Seen January 25th, 2019
Posted January 16th, 2017
72 posts
9.3 Years
I think I figured out opposing Contest trainers in Emerald. They're spread across a master list stored at 0x5880A4 and follow a relatively sane table format for all entries. This is the format itself, using the first entry in the table as an example:

1E 01 | Pokemon Species

CA C9 C9 BD C2 D3 FF 00 00 00 00 | Pokemon nickname

C4 C3 C7 C7 D3 FF 00 00| Trainer name

07 00 00 | Trainer Sprite (Based on OW sprite #, if you really wanted you could put Rayquaza or Steven in the hall)

FF | No idea, static across all entries
0F | No idea, but occasionally is 8F 4F 2F or 1F in some entries. Once an entry becomes 8F, it decreases to previous until 0F
00 | Still no idea. It occasionally goes to 80 and then counts down to 40 20 10 8 4 2 1, and after a loop or two of this the previous bite begins to count down.
0C | More unknown stuff.

44 | Contests eligible. This is a bitfield:

1: This Pokemon appears in Super-rank contests
2: This Pokemon appears in Hyper-rank contests
* If you do not assign either 1 or 2, the Pokemon will appear in Normal-rank contests.
* If you assign both 1 and 2, the Pokemon will appear in Master-rank contests.

4: This Pokemon appears in Coolness contests
8: This Pokemon appears in Beauty contests
10: This Pokemon appears in Cuteness contests
20: This Pokemon appears in Smartness contests
40: This Pokemon appears in Toughness contests

You can mix and match 4~40 as you see fit.

00 | ???

2E 00 2C 00 24 00 50 01 | Moveset

0A | Cool rating
04 | Beauty rating
0A | Cute rating
03 | Smart rating
04 | Tough rating
32 | "Sheen" rating (how full it is)

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 | Padding?
FF FF 00 00 | More padding?
The unknown bytes are mostly irrelevant considering everything else interesting is covered in the known ones.
Carry on, friends.

Tlachtli

Crit happens.

Age 28
Male
Faraway place
Seen 4 Days Ago
Posted June 15th, 2017
267 posts
7.3 Years
Ok, I'm back with more cleaned-up versions of my Fairy move animations. These are all for Emerald BPEE. Animated gifs may come later, when I'm not feeling lazy :P

Dazzling Gleam:
Spoiler:

00 41 27 00 2F 27 02 74 72 59 08 02 05 01 00 02 00 00 00 0D 00 FF 7F 19 E4 00 C0 0E B4 79 2D 08 05 03 05 5A 11 08 02 06 02 00 00 00 03 00 00 00 10 00 FF 7F 04 04 19 C0 00 C0 05 02 74 72 59 08 02 05 01 00 00 00 0D 00 00 00 FF 7F 05 0B 00 0D 08


Disarming Voice:
Spoiler:

00 DB 27 03 B9 90 15 08 05 01 00 00 0E [XX XX XX XX] 05 04 06 08 02 74 72 59 08 02 05 1F 00 03 00 08 00 00 00 7F 7E 03 65 60 0D 08 05 05 FB FF FB FF 05 00 00 00 00 00 02 80 38 59 08 00 07 2D 00 00 00 00 00 00 00 00 00 00 00 01 00 03 D1 52 0D 08 02 05 01 00 01 00 00 00 06 00 01 00 03 D1 52 0D 08 02 05 03 00 01 00 00 00 06 00 01 00 03 A5 62 11 08 02 04 01 00 00 00 06 00 01 00 03 79 90 15 08 05 00 0F
[XX XX XX XX] = Insert +0x15


Draining Kiss:
Spoiler:

00 ED 27 00 A3 27 00 2F 27 0A 03 2A 01 0C 0C 08 02 74 72 59 08 02 05 01 00 01 00 00 00 08 00 7F 7E 05 02 F0 3A 59 08 82 02 00 00 E8 FF 19 C8 00 3F 05 04 00 00 00 00 01 00 02 00 04 02 05 01 00 00 00 05 00 05 00 01 00 04 00 03 AD 51 0D 08 02 05 01 00 03 00 00 00 06 00 01 00 0E 09 10 2D 08 05 04 00 0E DF 79 2D 08 05 02 74 72 59 08 02 05 01 00 01 00 08 00 00 00 7F 7E 05 0B 03 0D 08


Fairy Wind:
Spoiler:

00 FE 27 19 84 00 C0 02 44 E5 5C 08 02 03 64 00 00 00 64 00 04 19 1A 00 0E CA 4C 2D 08 03 AD 51 0D 08 02 05 01 00 03 00 00 00 06 00 01 00 02 44 E5 5C 08 02 02 37 00 00 00 1A 3F 03 05 5A 11 08 02 06 14 00 01 00 05 00 05 00 0D 00 BF 56 0E CA 4C 2D 08 05 19 85 00 C0 04 00 0B 03 0D 05 08


Moonblast:
Spoiler:

00 D2 27 00 D3 27 00 B3 27 0C 00 10 02 74 72 59 08 02 05 01 00 01 00 00 00 10 00 00 00 05 02 BC 2E 59 08 02 02 78 00 20 00 03 75 7A 0A 08 03 05 00 00 10 00 10 00 00 00 01 00 19 D3 00 00 04 64 19 BD 00 C0 1F 59 8C 15 08 07 C8 00 C0 FF 3F 00 03 00 04 00 00 00 0F 00 0E 9C 31 2D 08 0E 9C 31 2D 08 03 B9 5E 0D 08 05 05 00 00 06 00 00 08 04 00 01 00 03 05 5A 11 08 02 06 04 00 02 00 02 00 00 00 0C 00 5F 7E 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 0E 9C 31 2D 08 04 14 03 C1 25 10 08 02 00 05 08


Play Rough:
Spoiler:

00 97 27 00 EB 27 00 59 27 0A 03 0C 0C 08 19 87 00 C0 1D 8B 00 3F 0A 1D 87 00 C0 14 1D 8B 00 3F 1E 1D 87 00 C0 28 1D 8B 00 3F 32 1D 87 00 C0 3C 1D 8B 00 3F 46 1D 87 00 C0 50 1D 8B 00 3F 5A 03 39 57 0D 08 02 05 00 00 EE FF 06 00 06 00 04 00 03 39 57 0D 08 02 05 01 00 12 00 06 00 06 00 04 00 02 C0 3A 59 08 83 02 00 FF D6 FF 02 C0 3A 59 08 83 02 80 00 F2 FF 02 C0 3A 59 08 83 02 A0 01 DA FF 02 C0 3A 59 08 83 02 80 FF EA FF 04 00 0E D3 26 2D 08 19 8B 00 3F 02 78 5F 59 08 83 04 10 00 08 00 A0 00 E0 FF 02 78 5F 59 08 83 04 10 00 08 00 00 FF D8 FF 02 78 5F 59 08 83 04 10 00 08 00 80 00 F0 FF 02 78 5F 59 08 83 04 10 00 08 00 A0 01 DA FF 02 78 5F 59 08 83 04 10 00 08 00 80 FF EA FF 02 78 5F 59 08 83 04 10 00 08 00 80 FE E1 FF 04 00 0E D3 26 2D 08 19 E2 00 3F 02 C0 3A 59 08 83 02 00 FF D6 FF 02 C0 3A 59 08 83 02 80 00 F2 FF 02 C0 3A 59 08 83 02 A0 01 DA FF 02 C0 3A 59 08 83 02 80 FF EA FF 04 00 19 8B 00 3F 02 78 5F 59 08 83 04 10 00 08 00 A0 00 E0 FF 02 78 5F 59 08 83 04 10 00 08 00 00 FF D8 FF 02 78 5F 59 08 83 04 10 00 08 00 80 00 F0 FF 02 78 5F 59 08 83 04 10 00 08 00 A0 01 DA FF 02 78 5F 59 08 83 04 10 00 08 00 80 FF EA FF 02 78 5F 59 08 83 04 10 00 08 00 80 FE E1 FF 04 00 0E D3 26 2D 08 05 0B 03 0D 05 08
Pokemon Sigma Σmerald:
(now under management by DraconianWing)

A Gen 3 remake de-make, featuring many new encounters and Gen VI mechanics

Seen January 10th, 2017
Posted April 21st, 2016
180 posts
5.2 Years
So I've been trying to implement the Fairy-type into Emerald using the tutorials at Pokecommunity. I've seen that some other Emerald hackers have implemented the fairy type in emerald, but nobody has shared the details on how they did it.

I found that there was a patch as well, however, that patch replaced the ??? type which ruins Struggle (making struggle a normal-type move is not a good solution as it gets type disadvantage against Steel and Rock etc.)

Sorry if I don't give credit to the stuff I list here below, but a lot of different people seem to have found a lot of different things (such as Emerald offsets), none of these things are found by me. I just try to put all the stuff together and make sense out of it.

So ideally, I wanted to create a new Fairy type without replacing the contest types or the ??? type. Simply put, a new type. The only thing that I am struggling with is the Icon, everything else works perfectly fine. Thus, this post will focus on the icon. Name and effectiveness table tutorials can be found in the tutorial section of this forum.

The types are numbered in hex from 00 - 11 (Starts with Normal and ends with Dark). 12 - 16 are the contest types. Currently, I have placed my Fairy type at 14 which replaces Cute. However, I would like to place it at some other position where it does not replace anything.

Method 1
Deleted, I mixed the normal type icons up with the TM icons.

Method 2
This second method involved replacing one of the contest types, so I decided to replace Cute since it had similar background colour to Fairy.

So, I went to NSE and offset D971B0, which holds this picture:
Spoiler:


I changed Cute to Fairy, indexed the picture, and put it in empty space using HxD. However, no matter what I did, I couldn't get the right colour. I went through every single Palette in UNLZ and tried to use the VBA Palette view combine with APE to search for the right Palette, but I couldn't find it. Thus, the picture I added would always be in black and white.

So, my issue is that I have created the Fairy type but I am forced to call it "Cute" which is kind of lame. If anyone has done this entire process before, I would like to ask a couple of questions.

1. Did anyone find the Emerald offset for a location table similar to the one in Fire Red, which enables you to add more status icons? If there is such table, I guess you could just expand it and add a Fairy icon on spot 17 (after Tough).

2. If my only choice is to replace Cute, does anyone know how to get the right colours for the Icons after adding it into free space? I guess you'll have to repoint a Palette, but at what offset is that Palette?

Any help with this is appreciated, I've spent way too many hours trying to figure this out.

EDIT: Ok, just found this:
Not exactly R&D, but a useful image I found:
In Emerald BPEE, the uncompressed type images used for TMs/HMs (different from the ones used on the Poke info page) are found at 0xDC4378 and use the palette at 0xDC4338.

Potentially useful if you're adding new types to a hack and want to make TMs with moves of those types. The Power/Type/PP images are on there too, if you want to change how those look.
So I guess, in my Method 1, I was mixing up with TM/HM icons with the Type icons. My questions for method 2 are still valid though.
Age 22
Male
Seen December 18th, 2016
Posted October 26th, 2016
253 posts
6.1 Years
The palette for R/S/E is different. For Ruby, it is at E726EB, but because the type palette seems to be spread out over many different palettes, I don't think we can edit the palette. The type image uses 256++ colors, so we can't get the right palette.
Are you sure you have the right offset? Because I opened a Ruby rom on NSE 2.x, and I'm getting this:
And I thought the image was 16 colors, not 256 colors. Why would the palette be 256 colors?

Agastya

Grinding failed. Item Grind level dropped by 3.

Seen January 25th, 2019
Posted January 16th, 2017
72 posts
9.3 Years
The palette for R/S/E is different. For Ruby, it is at E726EB, but because the type palette seems to be spread out over many different palettes, I don't think we can edit the palette. The type image uses 256++ colors, so we can't get the right palette.
There are three different palettes that can be edited separately iirc, editing one palette won't change the colors for another palette.

that patch replaced the ??? type which ruins Struggle (making struggle a normal-type move is not a good solution as it gets type disadvantage against Steel and Rock etc.)
Struggle ignores the type chart entirely. It's not ??? type, the game doesn't think it's ??? type.

Le pug

Creator of Pokémon: Discovery / Fat Kid

Age 26
Male
Le bed
Seen 2 Days Ago
Posted October 13th, 2018
870 posts
5.7 Years
Going to be trying to port Jambo's FR asm for the Class Based Trainer Battle Music to Emerald.

Here is the thread: http://www.pokecommunity.com/showthread.php?t=293704

Here is his asm:
Spoiler:
.text
.align 2
.thumb
.thumb_func
.global battlemusichack

main:
	ldr r0, there
	ldr r1, [r0, #0x0]
	mov r0, #0x80
	lsl r0, r0, #0x5
	and r0, r1
	cmp r0, #0x0
	bne later
	mov r0, #0x80
	lsl r0, r0, #0x7
	and r0, r1
	cmp r0, #0x0
	bne later2
	mov r0, #0x2
	and r0, r1
	cmp r0, #0x0
	beq one
later2:	mov r0, #0x85
	lsl r0, r0, #0x1
	b return2
later:	mov r0, #0x95
	lsl r0, r0, #0x1
	b return2
one:	mov r0, #0x8
	and r1, r0
	cmp r1, #0x0
	beq wild
	ldr r2, table
	ldr r2, [r2, #0x0]
	ldr r0, ramoffset
	ldrh r1, [r0, #0x0]
	lsl r0, r1, #0x2
	add r0, r0, r1
	lsl r0, r0, #0x3
	add r0, r0, r2
	ldrb r0, [r0, #0x1]
	cmp r0, #0x54
	beq gym
        cmp r0, #0x57
        beq gym
        cmp r0, #0x5A
        beq champ
normal:	push {r2,r3}
	ldr r3, terminate
	ldr r1, classtable
loop:	ldrh r2, [r1, #0x0]
	cmp r2, r0
	beq loadmusic
	cmp r2, r3
	beq carryon
	add r1, #0x4
	b loop
carryon:	mov r0, #0x2
	pop {r2,r3}
	b return
loadmusic:	ldrh r0, [r1, #0x2]
	pop {r2,r3}
	b return2
wild:	ldr r0, there
	ldr r0, [r0, #0x0]
	mov r1, #0x1
	and r0, r1
	cmp r0, #0x0
	bne alternate
	mov r0, #0x0
	b return
alternate:	mov r0, #0x1
	b return
gym:	mov r0, #0x3
	b return
champ:	mov r0, #0x4
return:	push {r2-r7}
	mov r11, r0
	ldr r0, variable
	bl vardecrypt
	ldrh r0, [r0, #0x0]
	mov r1, #0xA
	mul r0, r1
	ldr r1, normaltable
	add r0, r0, r1
	mov r1, r11
	lsl r1, r1, #0x1
        add r0, r0, r1
	ldrh r0, [r0, #0x0]
	mov r1, #0x0
	mov r11, r1
	pop {r2-r7}
return2:	pop {r1}
	bx r1
vardecrypt:	ldr r1, vardec
	bx r1
.align
table:		.word 0x08044028
there:		.word 0x02022B4C
ramoffset:	.word 0x020386AE
terminate:	.word 0x0000FEFE
classtable:	.word 0x08FDFDFD
normaltable:	.word 0x08FEFEFE
vardec:		.word 0x0806E455
variable:	.word 0x000040F6


I'm not good with asm at all lol and this will probably take me ages so if anyone wants to help .. would be great.
Retired. Thank you guys for a wonderful five years.
Male
Seen August 19th, 2018
Posted August 19th, 2018
1,312 posts
12 Years
I've worked out how to have the Gen IV Roost effect in Emerald. This is how it is achieved:
1. First, in the battle script for Recover, it checks if the move ID is Roost (by having Recover's script, the AI can use Roost properly). If the move ID is Roost, then it branches to a near identical script that also calls a custom routine
2. The custom routine checks if the attacking Pokémon has Flying type in either of its slots and then changes it to the ??? type (0x9). If it's a pure Flying type, then it will become a pure ??? type.
3. Another custom routine is run at the end of every turn that checks for any ???-type Pokémon, and changes it back to Flying.

Here's how to implement it:
1. First, you need Jambo51's callasm routine for Battle Script Pro. It is found right here. Despite Jambo writing the routine for FireRed, it works for Emerald too. However, you need to change the "scriptlocation" offset to 0x02024214. Also this is very important, but unlike FireRed, your new command is not going to be 0xF8! Your new command will be 0xF9. It appears that Emerald has an extra battle command, most likely due to the Battle Frontier.

2. Now to get BSP to recognize our new command, open up the folder where BSP is located, and then there should be another folder called "Data". Then you should see a file called, "commands.bsh". Open it up with Notepad, and put this in:
#command callasm 0xF9 0x1 "Offset of routine" 0x4
This might be confusing, but DO NOT change anything in the quotation marks! That's just there to show minor info in BSP's command list. I repeat, DO NOT CHANGE A SINGLE THING IN THAT QUOTE!!! Also note that if you were using FireRed, your command would be 0xF8, not 0xF9.

3. Now, put in this routine somewhere:
.text
.align 2
.thumb
.thumb_func

/*What this routine does is check if the attacking PKMN
is Flying-type. It then changes its Flying-type to
the ???-type.*/

GetPkmnType1:
push {r0-r5}
ldr r1, .BattleData
ldr r0, .CurPokeIndex
ldrb r0, [r0]
mov r2, #0x58
mul r2, r0
add r1, #0x21
add r1, r2
ldrb r0, [r1]
ldrb r2, [r1, #0x1]
mov r3, #0x2
cmp r0, r3
beq ChangeType1
cmp r2, r3
beq ChangeType2
b End

ChangeType1:
mov r4, #0x9
strb r4, [r1]
cmp r2, r3
beq ChangeType2
b End

ChangeType2:
mov r4, #0x9
strb r4, [r1, #0x1]
b End

End:
pop {r0-r5}
bx lr

.align 2
.BattleData:        .word 0x02024084
.CurPokeIndex:        .word 0x0202420B
4. Now open up BSP, and open up Recover's battle script. Replace it with this:
#dynamic 0x9C5CE0
#freespacebyte 0xFF

#org @start
jumpifhalfword 0x0 0x20241EA 0x163 @RoostHandle
attackcanceler
attackstring
ppreduce
setdamageasrestorehalfmaxhp @full 0x1
attackanimation
waitanimation
orword 0x2024280 0x100
graphicalhpupdate 0x1
datahpupdate 0x1
printstring 0x4B
waitmessage 0x40
goto @finish

#org @full
pause 0x20
printstring 0x4C
waitmessage 0x40
goto @finish

#org @finish
setbyte 0x2024488 0x0
cmd49 0x0 0x0
end

#org @RoostHandle
attackcanceler
attackstring
ppreduce
setdamageasrestorehalfmaxhp @fullroost 0x1
attackanimation
waitanimation
orword 0x2024280 0x100
graphicalhpupdate 0x1
datahpupdate 0x1
printstring 0x4B
waitmessage 0x40
jumpiftype2 0x1 0x2 @changetype
goto @finishroost

#org @fullroost
pause 0x20
printstring 0x4C
waitmessage 0x40
goto @finishroost

#org @changetype
callasm 0x(offset of your routine +1)
goto @finishroost

#org @finishroost
setbyte 0x2024488 0x0
cmd49 0x0 0x0
end
A couple things to note: At the top, we have "jumpifhalfword 0x0 0x20241EA 0x163 @RoostHandle".
Replace 0x163 with your move ID for Roost.

Towards the bottom, at "#org @changetype", you see "callasm 0x(offset of your routine +1)". Obviously, put in the offset of the routine we added earlier, but add 0x1 to the offset.

So far, we have made it so that every time a Flying-type Pokémon uses Roost, it will turn into a ???-type. (If it was part-Flying, it would become part-???, and if it was pure-Flying, it would become pure-???).

5. Now we're going to insert another routine. This second routine will be called at the end of every turn and simply checks to see if there are any ???-type Pokémon, and then changes them back to Flying types.
.text
.align 2
.thumb
.thumb_func

HandlePoke1:
push {r0-r5}
mov r3, #0x9
ldr r1, .Poke1Type
ldrb r0, [r1]
ldrb r2, [r1, #0x1]
cmp r0, r3
beq Poke1ChangeType1
cmp r2, r3
beq Poke1ChangeType2
b HandlePoke2

Poke1ChangeType1:
mov r4, #0x2
strb r4, [r1]
cmp r2, r3
beq Poke1ChangeType2
b HandlePoke2

Poke1ChangeType2:
mov r4, #0x2
strb r4, [r1, #0x1]
b HandlePoke2

HandlePoke2:
ldr r1, .Poke2Type
ldrb r0, [r1]
ldrb r2, [r1, #0x1]
cmp r0, r3
beq Poke2ChangeType1
cmp r2, r3
beq Poke2ChangeType2
b HandlePoke3

Poke2ChangeType1:
mov r4, #0x2
strb r4, [r1]
cmp r2, r3
beq Poke2ChangeType2
b HandlePoke3

Poke2ChangeType2:
mov r4, #0x2
strb r4, [r1, #0x1]
b HandlePoke3

HandlePoke3:
ldr r1, .Poke3Type
ldrb r0, [r1]
ldrb r2, [r1, #0x1]
cmp r0, r3
beq Poke3ChangeType1
cmp r2, r3
beq Poke3ChangeType2
b HandlePoke4

Poke3ChangeType1:
mov r4, #0x2
strb r4, [r1]
cmp r2, r3
beq Poke3ChangeType2
b HandlePoke4

Poke3ChangeType2:
mov r4, #0x2
strb r4, [r1, #0x1]
b HandlePoke4

HandlePoke4:
ldr r1, .Poke4Type
ldrb r0, [r1]
ldrb r2, [r1, #0x1]
cmp r0, r3
beq Poke4ChangeType1
cmp r2, r3
beq Poke4ChangeType2
b End

Poke4ChangeType1:
mov r4, #0x2
strb r4, [r1]
cmp r2, r3
beq Poke4ChangeType2
b End

Poke4ChangeType2:
mov r4, #0x2
strb r4, [r1, #0x1]
b End

End:
pop {r0-r5}
ldr r0, .ReturnAddress
bx r0


.align 2
.Poke1Type: .word 0x020240A5
.Poke2Type: .word 0x020240FD
.Poke3Type: .word 0x02024155
.Poke4Type: .word 0x020241AD
.ReturnAddress:	.word 0x080405B1
6. At 0x402A0, change the bytes there to point to where you inserted the second routine (the one right above). DO NOT ADD +1 TO THE OFFSET. I REPEAT, DO NOT ADD +1. This is because the code that is executed before this appears to already account for that.

And now we have a fully working Roost with Generation IV's effect, and the AI can use it properly too, since we're using Recover's battle script slot, but the battle script is designed so that Recover will still function separately from Roost.

A couple things to note, this routine replicates the Generation IV effect of Roost where if the user was pure-Flying, it would become ??? type upon using Roost. In Generation V+, a pure-Flying type using Roost would become Normal-type.. If anyone wants to mod my routine to have the Generation V effect, feel free to do so.

Credits:
Chaos Rush
DoesntKnowHowToPlay - for the idea of the method to achieve this
Shiny Quagsire - for suggesting to me that Emerald might have more battle commands than FireRed due to the Battle Frontier
Tchlatli - I looked at his custom Protean code to figure out how to correctly calculate the type offset of the attacking Pokémon
JPAN - his documentation on FireRed battle-related RAM offsets helped me find the Emerald offsets

To verify that it's working properly, here are some useful RAM offsets:
02024084 - Battle Data (check out this post to see how its structured.)

020240A5 - Your(1) Type 1
020240A6 - Your(1) Type 2

020240FD - Opponent(1) Type 1
020240FE - Opponent(1) Type 2

02024155 - Your(2) Type 1
02024156 - Your(2) Type 2

020241AD - Opponent(2) Type 1
020241AE - Opponent(2) Type 2

LCCoolJ95

Limited Capacity

Age 24
Male
The World That Never Was
Seen 20 Hours Ago
Posted 3 Weeks Ago
603 posts
10 Years
I did some research into TM extension in Emerald. It seems that the TMs are located at 616040. When I looked at the data, they were two bytes long each. It was a move IDs, in hex, FLIPPED. I used a Pokémon Ruby Gameshark Codes listing to prove it (Here's the link: http://www.ign.com/faqs/2004/pokemon-battle-e-gameshark-sp-codes-list-541208). For example, the move ID for Focus Punch, or or Fighting Punch as the rough Japanese to English translation, in hex would be 108. However, within the TM Data,
it is actually 08 01. It just flipped the first number, 01, with the two other numbers, 08.

The TMs in hex are:
Spoiler:
08 01 51 01 60 01 5B 01 2E 00 5C 00 02 01 53 01 4B 01 ED 00 F1 00 0D 01 3A 00 3B 00 3F 00 71 00 B6 00 F0 00 CA 00 DB 00 DA 00 4C 00 E7 00 55 00 57 00 59 00 D8 00 5B 00 5E 00 F7 00 18 01 68 00 73 00 5F 01 35 00 BC 00 C9 00 7E 00 3D 01 4C 01 03 01 07 01 22 01 9C 00 D5 00 A8 00 D3 00 1D 01 21 01 3B 01


But what about the HMs? They follow right after:
Spoiler:
0F 00 13 00 39 00 46 00 94 00 F9 00 7F 00 23 01


I asked someone about this, and they stated that, no matter what, if the move IDs (in hex) are added BEFORE the HM data, this would be the beginning of the expansion of TMs in the game. HMs, however, will always be the last 8 move IDs (in hex).

Here, I just did an example of doing this process, using an expanded moves table:
Spoiler:
08 01 51 01 60 01 5B 01 2E 00 5C 00 02 01 53 01 4B 01 ED 00 F1 00 0D 01 3A 00 3B 00 3F 00 71 00 B6 00 F0 00 CA 00 DB 00 DA 00 4C 00 E7 00 55 00 57 00 59 00 D8 00 5B 00 5E 00 F7 00 18 01 68 00 73 00 5F 01 35 00 BC 00 C9 00 7E 00 3D 01 4C 01 03 01 07 01 22 01 9C 00 D5 00 A8 00 D3 00 1D 01 21 01 3B 01 AE 01 63 01 B4 01 B8 01 BA 01 83 01 84 01 C0 01 A7 01 C3 01 05 01 C4 01 8D 01 6A 01 C5 01 88 01 75 01 A2 01 65 01 C7 01 C8 01 C9 01 7C 01 CA 01 E7 01 76 01 A5 01 96 01 CC 01 D6 01 77 01 E8 01 E4 01 68 01 79 01 54 01 57 01 7E 01 81 01 CD 01 86 01 BC 01 9F 01 A0 01 C8 00 7A 01 44 01 14 01 94 01 8B 01 0F 00 13 00 39 00 46 00 94 00 F9 00 7F 00 23 01


If you compare it to the original, there are an extra 50 TMs added. Now, I just need to know how to make the legitimate TM item work. If someone were to look into that, that would be awesome.
"The greatest obstacle in life is Yourself. Overcome it, and you will achieve the greatest accomplishment of all." -Art Beins, 1982

Pokémon Theta Emerald EX: https://www.pokecommunity.com/showthread.php?t=386240
Seen January 10th, 2017
Posted April 21st, 2016
180 posts
5.2 Years
I've worked out how to have the Gen IV Roost effect in Emerald.
I did all the steps in the process. Recover works as normal but my game freezes when a Flying types uses Roost to heal up.

My Steps:
callasm routine:
1. Moved the table from 31BD10 (starts with FD5F0408) - 31C0F3 (ends with F96E0508) to the location EF7000. Replaced all 10BD3108 to 0070EF08.

2. Copy/Pasted the first routine Jambo posted in his thread, changed the scriptlocation to 02024214 and put it at EF7400

3. Added a pointer at the end of my new table after F96E0508 which is 0074EF08 (tried 0174EF08 here, too. Neither worked. Not sure which to use).

4. Went to notepad, added your command in those exact word in commands.bsh (It's the only text in this entire notepad, everything else is empty)

5. Copy/Pasted the routine you posted first, put in note pad, thumb, and then placed at offset EF7450.

6. Opened battle script pro. My Roost is at spot 398 so I changed the first row to 0x18E @RoostHandle.
Also changed callasm 0x(offest here) to 0xEF7451 (since offset of routine was EF7451)

7. Notepad, thumb, put in your last routine at EF74A0. Changed 0x402A0 to A074EF08.

8. Gave roost attack animation and edited it properly in PGE.

It seems to be a problem with the callasm as Roost heals the pokemon, the text that it is heals comes up, and then it just stops.
Male
Seen August 19th, 2018
Posted August 19th, 2018
1,312 posts
12 Years
I did all the steps in the process. Recover works as normal but my game freezes when a Flying types uses Roost to heal up.

My Steps:
callasm routine:
1. Moved the table from 31BD10 (starts with FD5F0408) - 31C0F3 (ends with F96E0508) to the location EF7000. Replaced all 10BD3108 to 0070EF08.

2. Copy/Pasted the first routine Jambo posted in his thread, changed the scriptlocation to 02024241 and put it at EF7400

3. Added a pointer at the end of my new table after F96E0508 which is 0074EF08 (tried 0174EF08 here, too. Neither worked. Not sure which to use).

4. Went to notepad, added your command in those exact word in commands.bsh (It's the only text in this entire notepad, everything else is empty)

5. Copy/Pasted the routine you posted first, put in note pad, thumb, and then placed at offset EF7450.

6. Opened battle script pro. My Roost is at spot 398 so I changed the first row to 0x18E @RoostHandle.
Also changed callasm 0x(offest here) to 0xEF7451 (since offset of routine was EF7451)

7. Notepad, thumb, put in your last routine at EF74A0. Changed 0x402A0 to A074EF08.

8. Gave roost attack animation and edited it properly in PGE.

It seems to be a problem with the callasm as Roost heals the pokemon, the text that it is heals comes up, and then it just stops.
At step 2, you said you changed scriptlocation to 02024241. Maybe you made a typo there, but it should be 02024214.

For step 3, the pointer you add at the end of the table is the offset of the callasm routine+1. (Notice how the rest of the offsets in that table are NOT 4-byte aligned)

I'm not at home right now so I can't check if I missed anything, but I do have it working properly on my ROM with any of the four Pokémon in battle using it. I'll check it more thoroughly when I get home if it's still not working for you.

Also make 100% sure you're not getting the two routines mixed up - they're near identical; the first one is called by the battle script to change any instance of Flying type into ??? type, and the second one is called at the end of every turn to change any instance of ??? type into Flying type.
Seen January 10th, 2017
Posted April 21st, 2016
180 posts
5.2 Years
I got it to work!

This part:

#org @changetype
callasm 0xEF7451
goto @finishroost

compiled into

51 74 EF 00

When I looked at it in a HEX editor, so I just changed the 00 to 08 manually in HxD.

I guess I had to put it like:
#org @changetype
callasm 0x8EF7451
goto @finishroost

Pretty simple and stupid mistake that cost me a lot of time. Anyway, thank you very much for taking your time looking into it, I appreciate it a lot.
Advertiser Content