• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Putting back Mystery Event in Emerald

150
Posts
17
Years
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).
nomevent.png

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:
meventunlocked.png

(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):
itworksmaybe.png

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

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:
150
Posts
17
Years
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.

itactuallydoeswork.png


But then...

incompatiblelololol.png


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:

Sierraffinity

Desperately trying to retire from ROM hacking
1,069
Posts
16
Years
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?
 
150
Posts
17
Years
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.
 
2,048
Posts
16
Years
  • Age 31
  • Seen Sep 7, 2023
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...
 
Back
Top