The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > ROM Hacking > Tools, Tutorials & Resources
Sign Up Rules/FAQ Live Battle Blogs Mark Forums Read

Notices

Tools, Tutorials & Resources Various tools to help you develop your hacks can be found here.
New threads in this forum are to be approved by a moderator before they are displayed.


Advertise here

Reply
 
Thread Tools
  #1    
Old June 30th, 2010, 08:10 AM
Prof. 9
 
Join Date: Jun 2006
Location: The Netherlands
Gender: Male

Advertise here
A while ago I set out to make a personal ROM hack that changes all the things I didn't like about Pokémon Emerald. This includes, but is not limited to, ASM hacks. One of the ASM hacks I did was putting back Mystery Event in the menu. I figured I'd write up a tutorial so other peopel can incorporate it in their hacks too, if they want. It's not really useful on its own but perhaps an ASM script can be built for it so it does something completely new, like a new game plus, or loading another GBA rom.

Mystery Event is a special feature only present in Ruby, Sapphire and the Japanese versions of Emerald. It allows you to connect to the e-Reader to download special event stuff like the Eon Ticket and the e-Reader Berries. This tutorial will show how to put it back in Pokémon Emerald (U).

Note: I'm using a random save file I found on Filetrip

When you press Start at the title screen, the game first checks if you have a save file. If you do, then it checks if the Mystery Gift flag has been set. Depending on if you have a save file/Mystery Gift unlocked, the game will load a specific menu value. It then uses that to decide which options will appear in the menu.
Code:
Menu 0
NEW GAME
OPTION

Menu 1
CONTINUE
NEW GAME
OPTION

Menu 2
CONTINUE
NEW GAME
MYSTERY GIFT
OPTION

Menu 3
CONTINUE
NEW GAME
MYSTERY GIFT
MYSTERY EVENTS
OPTION
Anything higher than 3 returns menu 0. There's no menu with just MYSTERY EVENTS, without MYSTERY GIFT. So in order to unlock Mystery Event, we will have to make the game load Menu 3 instead of Menu 2 if it detects Mystery Gift has been unlocked.

Let's have a look at the routine that checks if Mystery Gift has been unlocked:
Code:
0802f974 fda6f06d bl $0809d4c4
0802f978 2800     cmp r0, #0x0
0802f97a d002     beq $0802f982
0802f97c 8820     ldrh r0, [r4, #0x0]
0802f97e 3001     add r0, #0x1
0802f980 8020     strh r0, [r4, #0x0]
At 0x09D4C4 is a subroutine that checks if flag 8DB has been set. If it hasn't, then it returns 0 and the rest of the routine is skipped. If it has been set, the game loads the menu value, adds 1 to it and stores it again. This is what you get:

Remember how the menu with Continue and Mystery Gift came right after the menu with just Continue. So, all we have to do is make it add 2 instead. Now we get this:

(It says MYSTERY EVENTS instead of MYSTERY EVENT. That can be changed with a text hack.)

Try choosing MYSTERY EVENTS and you'll see that it works (it can connect to the e-Reader fine too, but there aren't any e-cards you can use, sadly):

This creates a new problem, though. Try choosing MYSTERY GIFT.

It appears the MYSTERY GIFT button now points to the wrong area. A simple pointer edit should fix that. This is the routine the game uses for finding out where to jump to after you choose an option.
Code:
08030338 5ee0 ldsh r0, [r4, r3]
0803033a 2801 cmp r0, #0x1
0803033c d024 beq $08030388 (New Game)
0803033e 2801 cmp r0, #0x1
08030340 dd20 ble $08030384 (Continue)
08030342 2802 cmo r0, #0x2
08030344 d002 beq $0803034c (Mystery Gift)
08030346 2803 cmp r0, #0x3
08030348 d046 beq $080303d8 (Option)
0803034a e01b b $08030384
That one is for menu 2. The game first determines which button was selected, then it uses that to figure out where it needs to jump to next.

The game uses a slightly different routine for menu 3.
Code:
08030360 0080 lsl r0, r0, #0x02
08030362 4902 ldr r1, [$0803036c] (=$08030370)
08030364 1840 add r0, r0, r1
08030366 6800 ldr r0, [r0, #0x0]
08030368 4687 mov pc, r0

0803036c 08030370 (start of data)
08030370 08030384 (Continue)
08030374 08030388 (New Game)
08030378 0803038c (Mystery Gift)
0803037c 080303bc (Mystery Events)
08030380 080303d8 (Option)
Here, it first loads the starting address of a list of addresses, then multiplies the button value by 4 and uses it as an offset for the starting address in order to load the address it has to jump to.

If you look closely, you'll see that the two addresses used for Mystery Gift are slightly different. So all we have to do is subtract 0x40 from the second address and then it should be fixed:

Also, you can make it boot straight into the Mystery Gift menu (bypassing the Wireless Adapter check) by adding 0xEC to the address instead. When you try to receive any Wonder Cards/Wonder News, the game throws an error at you, though.

Code:
Change the byte at 0x02F97E to 0x02
Subtract 0x40 from the value at 0x030378
Once you've done all this, Mystery Event should be unlocked together with Mystery Gift since they share the same flag.

Last edited by Prof. 9; July 5th, 2010 at 11:32 AM.
Reply With Quote
  #2    
Old July 3rd, 2010, 07:28 AM
Shiny Quagsire's Avatar
Shiny Quagsire
どないやねん, ヤドン
 
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 16
Gender: Male
Nature: Jolly
Interesting tutorial. I never knew that emerald had it in there :\
__________________



Reply With Quote
  #3    
Old July 3rd, 2010, 12:04 PM
Team Fail's Avatar
Team Fail
The fine line between in|sanity
Community Supporter
 
Join Date: May 2009
Age: 19
Gender: Male
Nature: Brave
Now that you think of it, I now wonder if it also exists in Pokemon FireRed and Pokemon LeafGreen. Hmmm.... Interesting tutorial, though. Now, all we have to do is make a way for the roms to connect easily so that dot codes will work on them.


Quote:
Originally Posted by Prof. 9 View Post
Also, you can make it boot straight into the Mystery Gift menu (bypassing the Wireless Adapter check) by adding 0xEC to the address instead. When you try to receive any Wonder Cards/Wonder News, the game throws an error at you, though.
the 0xEC thing there, that is the check to see if the adapter is attached, from my guess at what I see here. Since it runs the check as the save is loading, it runs it. After it loads, though, you can remove the Wireless Adapter and the option will still be there, and you can use it, that is until it gives you the error.
__________________

Pairs:
Kevin, Echidna
Follow me on Twitter! @TeamFail
Alt 1, リザードン
Miiverse
Pokémon Hackers Online
Alt 2: Jack Cayman



[04:20.39] <@GoGo> I WILL INSERT WITH PLEASURE
[04:20.45] <@GoGo> shut it Bela

[05:41.55] <Team_Fail> Blue Spider is interesting, but #MEHMasterRace
[05:42.20] <diegoisawesome> Team_Fail: Sounds like a bunch of unmotivated people that still want to try to take over the world
Reply With Quote
  #4    
Old July 3rd, 2010, 12:07 PM
Prof. 9
 
Join Date: Jun 2006
Location: The Netherlands
Gender: Male
Quote:
Originally Posted by Team Fail View Post
Now that you think of it, I now wonder if it also exists in Pokemon FireRed and Pokemon LeafGreen. Hmmm.... Interesting tutorial, though. Now, all we have to do is make a way for the roms to connect easily so that dot codes will work on them.
I had a look at FireRed and LeafGreen actually, but there was no menu with a Mystery Event option. The text doesn't appear in the ROM either.

EDIT: I just tried out Mystery Event in No$gba and it actually works.



But then...



So yeah. It fully works, but it can't really be used for the simple reason there are no compatible e-cards for it (AFAIK). I wonder if I can dig up a Japanese Eon Ticket e-card somewhere.

Last edited by Prof. 9; July 5th, 2010 at 11:31 AM.
Reply With Quote
  #5    
Old August 10th, 2010, 06:03 PM
diegoisawesome's Avatar
diegoisawesome
Not the Script Help Thread
Community Supporter
 
Join Date: Dec 2007
Location: Goldenrod City, Johto
Age: 17
Gender: Male
Nature: Quirky
Take a look at Emerald's questionnaire script:
Code:
'---------------
#org 0x27381B
lockall
msgbox 0x827339F MSG_YESNO '"There is a questionnaire.\nWould y..."
compare LASTRESULT 0x0
if 0x1 goto 0x82738FD
setvar 0x8004 0x14
call 0x8271E7C
lock
faceplayer
special2 0x8008 0x1ED
compare 0x8004 0x1
if 0x1 goto 0x827386D
compare 0x8004 0x2
if 0x1 goto 0x82738B5
compare LASTRESULT 0x0
if 0x1 goto 0x82738FD
compare LASTRESULT 0x1
if 0x1 goto 0x82738FF
end

'---------------
#org 0x2738FD
releaseall
end

'---------------
#org 0x271E7C
fadescreen 0x1
special 0x62
fadescreen 0x0
return

'---------------
#org 0x27386D
checkflag 0x861
if 0x0 goto 0x82738FF
checkflag 0x8AC
if 0x1 goto 0x82738FF
applymovement 0x8008 0x82725B0
waitmovement 0x0
sound 0x15
applymovement 0x8008 0x8272598
waitmovement 0x0
applymovement 0x8008 0x827259A
waitmovement 0x0
msgbox 0x8273506 MSG_KEEPOPEN '"Oh, hello!\nYou know those words?\..."
setflag 0x8AC
msgbox 0x8273559 MSG_KEEPOPEN '"Once you save your game, you can\n..."
releaseall
end

'---------------
#org 0x2738B5
checkflag 0x861
if 0x0 goto 0x82738FF
checkflag 0x8DB
if 0x1 goto 0x82738FF
applymovement 0x8008 0x82725B0
waitmovement 0x0
sound 0x15
applymovement 0x8008 0x8272598
waitmovement 0x0
applymovement 0x8008 0x827259A
waitmovement 0x0
msgbox 0x8273446 MSG_KEEPOPEN '"Oh, hello!\nYou know those words?\..."
setflag 0x8DB
msgbox 0x82734CC MSG_KEEPOPEN '"Once you save your game, you can\n..."
releaseall
end

'---------------
#org 0x2738FF
applymovement 0x8008 0x82725B0
waitmovement 0x0
msgbox 0x82733D8 MSG_KEEPOPEN '"Thank you for taking the time to\n..."
releaseall
end


'---------
' Strings
'---------
#org 0x27339F
= There is a questionnaire.\nWould you like to fill it out?

#org 0x273506
= Oh, hello!\nYou know those words?\pThat means you must know about\nthe MYSTERY EVENT.

#org 0x273559
= Once you save your game, you can\naccess the MYSTERY EVENT.

#org 0x273446
= Oh, hello!\nYou know those words?\pThat means you must know about\nthe MYSTERY GIFT.\pFrom now on, you should be\nreceiving MYSTERY GIFTS!

#org 0x2734CC
= Once you save your game, you can\naccess the MYSTERY GIFT.

#org 0x2733D8
= Thank you for taking the time to\nfill out our questionnaire.\pYour feedback will be used for\nfuture reference.


'-----------
' Movements
'-----------
#org 0x2725B0
#raw 0x0 'Face Down
#raw 0xFE 'End of Movements

#org 0x272598
#raw 0x56 'Exclamation Mark (!)
#raw 0xFE 'End of Movements

#org 0x27259A
#raw 0x14 'Delay5
#raw 0x14 'Delay5
#raw 0x14 'Delay5
#raw 0xFE 'End of Movements
I wonder, does setting flag 0x8AC actually give you Mystery Event?
I can't check it ATM as I have to get off now... :/
Maybe somebody else could look into it?
__________________


My other resources:
My Website
diegoisawesome's MEGA-HUGE XSE Scripting Tutorial
diegoisawesome's Miscellaneous Finds
The Ruins of Alph Puzzles
Reply With Quote
  #6    
Old August 10th, 2010, 07:45 PM
Shiny Quagsire's Avatar
Shiny Quagsire
どないやねん, ヤドン
 
Join Date: May 2009
Location: Hoenn Safari Zone
Age: 16
Gender: Male
Nature: Jolly
It seems like it. No specials or anything, just the variable..... :\
__________________



Reply With Quote
  #7    
Old August 13th, 2010, 02:02 AM
Prof. 9
 
Join Date: Jun 2006
Location: The Netherlands
Gender: Male
Quote:
Originally Posted by diegoisawesome View Post
I wonder, does setting flag 0x8AC actually give you Mystery Event?
I can't check it ATM as I have to get off now... :/
Maybe somebody else could look into it?
No. Only the the flag for Mystery Gift is checked on startup. There is no menu with just Mystery Gift either. I guess it should be possible to add one.
Reply With Quote
  #8    
Old August 16th, 2010, 04:28 AM
Wichu's Avatar
Wichu
Project Amethyst
 
Join Date: Sep 2007
Location: North Herts, England
Age: 21
Gender: Male
Nature: Naive
Quote:
Originally Posted by Prof. 9 View Post
So yeah. It fully works, but it can't really be used for the simple reason there are no compatible e-cards for it (AFAIK). I wonder if I can dig up a Japanese Eon Ticket e-card somewhere.
It should be possible to hack Emerald into thinking that it's actually R/S, and therefore able receive the ticket.

A bit pointless in a hack, seeing as most people play them in emulators and hardly anyone has an e-reader, but still...
__________________
Reply With Quote
  #9    
Old August 16th, 2010, 08:29 AM
Multi's Avatar
Multi
Beginning Trainer
 
Join Date: Aug 2010
Gender: Male
thank you nice Tutorial helps a lot
Reply With Quote
Reply
Quick Reply

Sponsored Links


Advertise here
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
Minimum Characters Per Post: 25



All times are UTC -8. The time now is 03:19 AM.


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