SlideShare a Scribd company logo
How The Long-Range
Trainer Escape Glitch
(Mew Trick) Works
but like.. technically speaking
Agenda
● Background
● Mew Trick Description
● Technical Analysis
○ Glitch
■ CheckFightingMapTrainers vs. UpdateSprites
○ Setup
■ DisplayEnemyTrainerTextAndStartBattle
○ Final Step
■ InitBattleEnemyParameters
Background
● It was impossible to get Mew, except by attending Nintendo events, as such
it was very exclusive.
● There was a rumour that you could get Mew behind a truck in SS. Anne, but
it wasn't true. Many similar rumours turned out to be false as well.
Background
● However, one of those rumours turned out to be true!
● And at first, it seemed like yet another scam.
Background
Apparently first publicly described in March 2003 by Daniel26, but TheScythe
made it popular in a forum a month later in in April (and later on analyzed in depth
by WhteCat). Daniel26 explained the glitch like this:
Ok, first you must not battled the youngster that has a slowpoke (the one past nugget bridge he's
the one looking up, about the 4th trainer)and not battled the gambler next to the right entrance to
saffron city. THE CODE:fly to saffron city go out the right exit, go up to the door little house (don't go
in) press down, quickly press start(before the ! comes onto the gamblers head) fly to cerulan city, go
up nugget bridge battle the youngster, walk where he is looking,(when you walk in front of him make
sure you have 1 or 2 squares away from him) let him walk to you then he will battle you, after the
battle fly to saffron city, try going out the right side exit again, the menu will pop up,press b to get off
it then the screen will flash like when a pokemon appears in the grass, and a wild MEW at LV:7 will
appear.
Pre-requisites
● not battled the youngster that has a
slowpoke (the one past nugget bridge he's
the one looking up, about the 4th trainer)
● not battled the gambler next to the right
entrance to saffron city
The Glitch
● go up to the door little house (don't go in) press down, quickly press start
The Glitch
● (before the ! comes onto the gamblers head) fly to cerulan city
● fly to cerulan city, go up nugget bridge battle the youngster, walk where he is
looking,(when you walk in front of him make sure you have 1 or 2 squares
away from him) let him walk to you then he will battle you,
The Setup
The Last Step
● after the battle fly to saffron city, try going out the right side exit again, the
menu will pop up,press b to get off it
The Last Step
● then the screen will flash like when a pokemon appears in the grass, and a
wild MEW at LV:7 will appear
How does that work?
Technical Analysis
● The Glitch
○ Escaping from a battle by flying away
● The Setup
○ Fighting with the slowpoke youngster
● The Last Step
○ Going back to where you ran away
Sources
WhteCat analyzed the glitch and published his notes on "The P Files"
github.com/pret has a disassembled version of most Pokemon games
Vocabulary
● Trainer
○ An enemy that will fight you if it sees you.
● Sprite
○ Any in-game object, like a trainer, a door, and so on.
Technical Background
● GameBoy works the following way:
○ The screen is drawn
○ Code is executed
○ The screen is drawn
○ Code is executed
○ The screen is drawn
○ Code is executed
○ The screen is drawn
○ Code is executed
○ …
● What is drawn on the screen depends on what the code that ran before says
Technical Background
● The code (among other things) does:
○ Walking Animation (move the world around the user)
○ Run Map Scripts (code specific to this part of the world)
○ Detect Buttons (if the user pressed any buttons)
○ Check START Menu (if the user pressed the START button)
● The memory (among other things) contains:
○ Temporal memory for holding in-game data.
○ Medium term memory for storing the state in every map.
○ Read only memory for holding the game's code.
Map Scripts
● Most maps contain 3 map scripts:
○ CheckFightingMapTrainers
○ DisplayEnemyTrainerTextAndStartBattle
○ EndTrainerBattle
● CheckFightingMapTrainers
○ code responsible for detecting if any trainer can see the player and then having them walk-up
to the player
● DisplayEnemyTrainerTextAndStartBattle
○ runs after the previous script, and shows the pre-battle text and starts the battle
● EndTrainerBattle
○ finishes the battle and lets the user continue
CheckFightingMapTrainers vs. UpdateSprites
● UpdateSprites: Loop over all Sprites
○ Animate sprites (most move even if static)
○ But don't update sprites if currently walking
● CheckFightingMapTrainers: Loop over all Trainers in the map
○ Ignore those that aren't currently visible
○ If the trainer is looking at the user, fight!
This is where the glitch happens!
The Glitch
● At first, since the player just moved down, the trainer is not yet visible, and so,
can't engage the player. So the player has a single turn to do something
before the trainer becomes visible.
CheckFightingMapTrainers vs. UpdateSprites
● UpdateSprites: Loop over all
Sprites
○ Animate sprites (most
move even if static)
○ But don't update sprites if
currently walking
● CheckFightingMapTrainers:
Loop over all Trainers in the
map
○ Ignore those that aren't
currently visible
○ If the trainer is looking at
the user, fight!
CheckFightingMapTrainers vs. UpdateSprites
● The Glitch is simply that there is a "turn" during which the user can do
something (move out, or press START) when the Trainer is not yet visible.
Teleport / Fly
● When the user Teleports / Flies to somewhere else, the trainer has no time to
start the battle, but has enough time to move the script for the current map to
DisplayEnemyTrainerTextAndStartBattle
DisplayEnemyTrainerTextAndStartBattle
● The Script does the following:
○ Wait for the trainer to finish walking to the player (marked by memory 0xD730)
○ Re-enable the joystick controls (set [wJoyIgnore] = 0)
○ Display the Before Battle Text (marked in wSpriteIndex)
○ Start Battle
Teleport / Fly
● When the user Teleports/Flies to another map, the following happens:
○ The current map is left in it's current state
■ This means the "active" script in the current map (route 8) is left as
DisplayEnemyTrainerTextAndStartBattle waiting for memory 0xD730 to be 0.
○ The map where you are flying to is set as the new "current" map.
■ The state for each map is stored separately, so this simply leaves the previous state
untouched.
● So the Script in the map for Route 8 is left as
DisplayEnemyTrainerTextAndStartBattle, so when the user returns to Route
8, this script will continue running (and waiting for 0xD730 to be 0)
Teleport / Fly
● Most maps contain 3 map scripts:
○ CheckFightingMapTrainers
○ DisplayEnemyTrainerTextAndStartBattle
○ EndTrainerBattle
● So after the user teleports to a new map, the new map's current script is
CheckFightingMapTrainers, however the game is affected by a couple things:
○ The START button is disabled, because memory at D730 is not clear and the game thinks the
trainer is still walking towards the user. Until the D730 is clear, most actions are disabled.
○ Going back to Route 8 will have all trainers disabled because Route 8 is in the
DisplayEnemyTrainerTextAndStartBattle script, so no trainer will know to look for you, but only
on that map, other maps will run the CheckFightingMapTrainers script.
The Setup
● After escaping from Route 8, the player will be crippled by the D730, so he
needs to get that cleared. To do that, the player needs to complete a
DisplayEnemyTrainerTextAndStartBattle routine so that the game clears the
value.
The Setup
● By fighting with another trainer that will walk up to you (it has to walk up to
you as otherwise the "walk to user" code won't be called) the game will mostly
go back to a normal state (except Route 8 which is stuck in the battle mode).
The Setup
● When the player is fighting, the game copies several values of the pokemon
and the trainer on to memory, such as the pokemon's type, it's level, hitpoints,
as well as stats such as attack, defense, speed and special.
● CopyData which copies bc bytes (=1+5*2=11 bytes) from hl
(=wEnemyMonLevel) to de (=wEnemyMonUnmodifiedLevel=cd23).
The Setup
● The address in memory where
this data is copied is CD23, and
the amount of data copied is 11
bytes (NUM_STATS is 5,
hitpoints, attack, defense,
speed, special), so up to CD2D.
● Note, however that the memory
in CD2D is also used for
"wEngagedTrainerClass".
The Setup
● This means that wEngagedTrainerClass will be equal to the "special" stat of
the pokemon you fight against. If you fight the youngster, it will be a Slowpoke
with a "special" stat of 21.
The Setup
● Finally, after fighting the youngster, which serves two purposes
○ Marking the memory at D730 to 0, so that the DisplayEnemyTrainerTextAndStartBattle script
doesn't think there's a trainer walking.
○ Setting the memory at CD2D to 21 via the Slowpoke's "special" stat, so that the
wEngagedTrainerClass will hold that value when read the next time.
The Last Step
● The player can now go back to Route 8. Now, when the user enters Route 8,
the game will still try to run the script DisplayEnemyTrainerTextAndStartBattle
but since we already cleared the D730 memory, the game will try to show the
player the enemy text.
The Last Step
● The DisplayEnemyTrainerAndStartBattle script will try to display the text in the
memory pointed by wSpriteIndex, which is the last text shown to the user,
which in our case is usually the START menu. So when the user enters the
map Route 8 the START menu is displayed.
The Last Step
● And after the START menu is dismissed, the script starts the battle, to do so,
it initializes the battle (the pokemon to fight, it's level and so on) with the
function InitBattleEnemyParameters.
The Last Step
● The wCurOpponent (the pokemon type) is set to wEngagedTrainerClass,
which was set to 21 after fighting against the Youngster's Slowpoke
● Since 21 is less than 200, the battle is defined as a "no trainer" (or "wild")
battle, and the pokemon is loaded as 21. 21 is the pokemon identifier for
MEW, so the player fights a "wild" MEW.
The Last Step
How the long range trainer escape glitch (mew trick) works

More Related Content

Similar to How the long range trainer escape glitch (mew trick) works

Steam Learn: Speedrun et TAS
Steam Learn: Speedrun et TASSteam Learn: Speedrun et TAS
Steam Learn: Speedrun et TAS
inovia
 
prueba02.pdf
prueba02.pdfprueba02.pdf
prueba02.pdf
Mertin2
 
25 tips to build Tutorials on Board Game Arena
25 tips to build Tutorials on Board Game Arena25 tips to build Tutorials on Board Game Arena
25 tips to build Tutorials on Board Game Arena
Board Game Arena
 
Joker Game.pptx
Joker Game.pptxJoker Game.pptx
Joker Game.pptx
GURU103976
 
Street runner final
Street runner finalStreet runner final
Street runner final
Kumar Narayan
 
Controller trollers odin_1115
Controller trollers odin_1115Controller trollers odin_1115
Controller trollers odin_1115
jhouchens99
 
Lecture 3 - Driving.pdf
Lecture 3 - Driving.pdfLecture 3 - Driving.pdf
Lecture 3 - Driving.pdf
SwasShiv
 
Uadventure: the eAdventure reboot (How to create educational games)
Uadventure:  the eAdventure reboot (How to create educational games)Uadventure:  the eAdventure reboot (How to create educational games)
Uadventure: the eAdventure reboot (How to create educational games)
Baltasar Fernández-Manjón
 
EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...
EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...
EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...
eMadrid network
 
Practical level design for F2P
Practical level design for F2PPractical level design for F2P
Practical level design for F2P
Elad Drory
 
Usability - One-handed Controller Design
Usability - One-handed Controller DesignUsability - One-handed Controller Design
Usability - One-handed Controller Design
James J Cartwright
 
Controller Trollers odin_1115
Controller Trollers odin_1115Controller Trollers odin_1115
Controller Trollers odin_1115
Dakota Daugherty
 
Video Game Collaboration
Video Game CollaborationVideo Game Collaboration
Video Game Collaboration
Steven Lambert
 
How to fix steam games not showing up on library
How to fix steam games not showing up on library How to fix steam games not showing up on library
How to fix steam games not showing up on library
TheSoftwareTutorial
 

Similar to How the long range trainer escape glitch (mew trick) works (14)

Steam Learn: Speedrun et TAS
Steam Learn: Speedrun et TASSteam Learn: Speedrun et TAS
Steam Learn: Speedrun et TAS
 
prueba02.pdf
prueba02.pdfprueba02.pdf
prueba02.pdf
 
25 tips to build Tutorials on Board Game Arena
25 tips to build Tutorials on Board Game Arena25 tips to build Tutorials on Board Game Arena
25 tips to build Tutorials on Board Game Arena
 
Joker Game.pptx
Joker Game.pptxJoker Game.pptx
Joker Game.pptx
 
Street runner final
Street runner finalStreet runner final
Street runner final
 
Controller trollers odin_1115
Controller trollers odin_1115Controller trollers odin_1115
Controller trollers odin_1115
 
Lecture 3 - Driving.pdf
Lecture 3 - Driving.pdfLecture 3 - Driving.pdf
Lecture 3 - Driving.pdf
 
Uadventure: the eAdventure reboot (How to create educational games)
Uadventure:  the eAdventure reboot (How to create educational games)Uadventure:  the eAdventure reboot (How to create educational games)
Uadventure: the eAdventure reboot (How to create educational games)
 
EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...
EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...
EDUCON 2017. Digital Education in the Classroom: uAdventure: The eAdventure r...
 
Practical level design for F2P
Practical level design for F2PPractical level design for F2P
Practical level design for F2P
 
Usability - One-handed Controller Design
Usability - One-handed Controller DesignUsability - One-handed Controller Design
Usability - One-handed Controller Design
 
Controller Trollers odin_1115
Controller Trollers odin_1115Controller Trollers odin_1115
Controller Trollers odin_1115
 
Video Game Collaboration
Video Game CollaborationVideo Game Collaboration
Video Game Collaboration
 
How to fix steam games not showing up on library
How to fix steam games not showing up on library How to fix steam games not showing up on library
How to fix steam games not showing up on library
 

Recently uploaded

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
Alberto Brandolini
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
Ayan Halder
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
ICS
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
Peter Muessig
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
Green Software Development
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
Green Software Development
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
TheSMSPoint
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
Sven Peters
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
ToXSL Technologies
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Envertis Software Solutions
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
Remote DBA Services
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
devvsandy
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
Grant Fritchey
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
Patrick Weigel
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
dakas1
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
ssuserad3af4
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
sjcobrien
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
Rakesh Kumar R
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
Łukasz Chruściel
 

Recently uploaded (20)

Modelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - AmsterdamModelling Up - DDDEurope 2024 - Amsterdam
Modelling Up - DDDEurope 2024 - Amsterdam
 
Using Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional SafetyUsing Xen Hypervisor for Functional Safety
Using Xen Hypervisor for Functional Safety
 
Webinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for EmbeddedWebinar On-Demand: Using Flutter for Embedded
Webinar On-Demand: Using Flutter for Embedded
 
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s EcosystemUI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
UI5con 2024 - Keynote: Latest News about UI5 and it’s Ecosystem
 
GreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-JurisicGreenCode-A-VSCode-Plugin--Dario-Jurisic
GreenCode-A-VSCode-Plugin--Dario-Jurisic
 
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, FactsALGIT - Assembly Line for Green IT - Numbers, Data, Facts
ALGIT - Assembly Line for Green IT - Numbers, Data, Facts
 
Transform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR SolutionsTransform Your Communication with Cloud-Based IVR Solutions
Transform Your Communication with Cloud-Based IVR Solutions
 
Microservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we workMicroservice Teams - How the cloud changes the way we work
Microservice Teams - How the cloud changes the way we work
 
Mobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona InfotechMobile App Development Company In Noida | Drona Infotech
Mobile App Development Company In Noida | Drona Infotech
 
How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?How Can Hiring A Mobile App Development Company Help Your Business Grow?
How Can Hiring A Mobile App Development Company Help Your Business Grow?
 
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative AnalysisOdoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
Odoo ERP Vs. Traditional ERP Systems – A Comparative Analysis
 
Oracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptxOracle 23c New Features For DBAs and Developers.pptx
Oracle 23c New Features For DBAs and Developers.pptx
 
Top 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptxTop 9 Trends in Cybersecurity for 2024.pptx
Top 9 Trends in Cybersecurity for 2024.pptx
 
Using Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query PerformanceUsing Query Store in Azure PostgreSQL to Understand Query Performance
Using Query Store in Azure PostgreSQL to Understand Query Performance
 
WWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders AustinWWDC 2024 Keynote Review: For CocoaCoders Austin
WWDC 2024 Keynote Review: For CocoaCoders Austin
 
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
一比一原版(UMN毕业证)明尼苏达大学毕业证如何办理
 
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
316895207-SAP-Oil-and-Gas-Downstream-Training.pptx
 
Malibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed RoundMalibou Pitch Deck For Its €3M Seed Round
Malibou Pitch Deck For Its €3M Seed Round
 
How to write a program in any programming language
How to write a program in any programming languageHow to write a program in any programming language
How to write a program in any programming language
 
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf2024 eCommerceDays Toulouse - Sylius 2.0.pdf
2024 eCommerceDays Toulouse - Sylius 2.0.pdf
 

How the long range trainer escape glitch (mew trick) works

  • 1. How The Long-Range Trainer Escape Glitch (Mew Trick) Works but like.. technically speaking
  • 2. Agenda ● Background ● Mew Trick Description ● Technical Analysis ○ Glitch ■ CheckFightingMapTrainers vs. UpdateSprites ○ Setup ■ DisplayEnemyTrainerTextAndStartBattle ○ Final Step ■ InitBattleEnemyParameters
  • 3. Background ● It was impossible to get Mew, except by attending Nintendo events, as such it was very exclusive. ● There was a rumour that you could get Mew behind a truck in SS. Anne, but it wasn't true. Many similar rumours turned out to be false as well.
  • 4. Background ● However, one of those rumours turned out to be true! ● And at first, it seemed like yet another scam.
  • 5. Background Apparently first publicly described in March 2003 by Daniel26, but TheScythe made it popular in a forum a month later in in April (and later on analyzed in depth by WhteCat). Daniel26 explained the glitch like this: Ok, first you must not battled the youngster that has a slowpoke (the one past nugget bridge he's the one looking up, about the 4th trainer)and not battled the gambler next to the right entrance to saffron city. THE CODE:fly to saffron city go out the right exit, go up to the door little house (don't go in) press down, quickly press start(before the ! comes onto the gamblers head) fly to cerulan city, go up nugget bridge battle the youngster, walk where he is looking,(when you walk in front of him make sure you have 1 or 2 squares away from him) let him walk to you then he will battle you, after the battle fly to saffron city, try going out the right side exit again, the menu will pop up,press b to get off it then the screen will flash like when a pokemon appears in the grass, and a wild MEW at LV:7 will appear.
  • 6. Pre-requisites ● not battled the youngster that has a slowpoke (the one past nugget bridge he's the one looking up, about the 4th trainer) ● not battled the gambler next to the right entrance to saffron city
  • 7. The Glitch ● go up to the door little house (don't go in) press down, quickly press start
  • 8. The Glitch ● (before the ! comes onto the gamblers head) fly to cerulan city
  • 9. ● fly to cerulan city, go up nugget bridge battle the youngster, walk where he is looking,(when you walk in front of him make sure you have 1 or 2 squares away from him) let him walk to you then he will battle you, The Setup
  • 10. The Last Step ● after the battle fly to saffron city, try going out the right side exit again, the menu will pop up,press b to get off it
  • 11. The Last Step ● then the screen will flash like when a pokemon appears in the grass, and a wild MEW at LV:7 will appear
  • 12. How does that work?
  • 13. Technical Analysis ● The Glitch ○ Escaping from a battle by flying away ● The Setup ○ Fighting with the slowpoke youngster ● The Last Step ○ Going back to where you ran away Sources WhteCat analyzed the glitch and published his notes on "The P Files" github.com/pret has a disassembled version of most Pokemon games
  • 14. Vocabulary ● Trainer ○ An enemy that will fight you if it sees you. ● Sprite ○ Any in-game object, like a trainer, a door, and so on.
  • 15. Technical Background ● GameBoy works the following way: ○ The screen is drawn ○ Code is executed ○ The screen is drawn ○ Code is executed ○ The screen is drawn ○ Code is executed ○ The screen is drawn ○ Code is executed ○ … ● What is drawn on the screen depends on what the code that ran before says
  • 16. Technical Background ● The code (among other things) does: ○ Walking Animation (move the world around the user) ○ Run Map Scripts (code specific to this part of the world) ○ Detect Buttons (if the user pressed any buttons) ○ Check START Menu (if the user pressed the START button) ● The memory (among other things) contains: ○ Temporal memory for holding in-game data. ○ Medium term memory for storing the state in every map. ○ Read only memory for holding the game's code.
  • 17. Map Scripts ● Most maps contain 3 map scripts: ○ CheckFightingMapTrainers ○ DisplayEnemyTrainerTextAndStartBattle ○ EndTrainerBattle ● CheckFightingMapTrainers ○ code responsible for detecting if any trainer can see the player and then having them walk-up to the player ● DisplayEnemyTrainerTextAndStartBattle ○ runs after the previous script, and shows the pre-battle text and starts the battle ● EndTrainerBattle ○ finishes the battle and lets the user continue
  • 18. CheckFightingMapTrainers vs. UpdateSprites ● UpdateSprites: Loop over all Sprites ○ Animate sprites (most move even if static) ○ But don't update sprites if currently walking ● CheckFightingMapTrainers: Loop over all Trainers in the map ○ Ignore those that aren't currently visible ○ If the trainer is looking at the user, fight! This is where the glitch happens!
  • 19. The Glitch ● At first, since the player just moved down, the trainer is not yet visible, and so, can't engage the player. So the player has a single turn to do something before the trainer becomes visible.
  • 20. CheckFightingMapTrainers vs. UpdateSprites ● UpdateSprites: Loop over all Sprites ○ Animate sprites (most move even if static) ○ But don't update sprites if currently walking ● CheckFightingMapTrainers: Loop over all Trainers in the map ○ Ignore those that aren't currently visible ○ If the trainer is looking at the user, fight!
  • 21. CheckFightingMapTrainers vs. UpdateSprites ● The Glitch is simply that there is a "turn" during which the user can do something (move out, or press START) when the Trainer is not yet visible.
  • 22. Teleport / Fly ● When the user Teleports / Flies to somewhere else, the trainer has no time to start the battle, but has enough time to move the script for the current map to DisplayEnemyTrainerTextAndStartBattle
  • 23. DisplayEnemyTrainerTextAndStartBattle ● The Script does the following: ○ Wait for the trainer to finish walking to the player (marked by memory 0xD730) ○ Re-enable the joystick controls (set [wJoyIgnore] = 0) ○ Display the Before Battle Text (marked in wSpriteIndex) ○ Start Battle
  • 24. Teleport / Fly ● When the user Teleports/Flies to another map, the following happens: ○ The current map is left in it's current state ■ This means the "active" script in the current map (route 8) is left as DisplayEnemyTrainerTextAndStartBattle waiting for memory 0xD730 to be 0. ○ The map where you are flying to is set as the new "current" map. ■ The state for each map is stored separately, so this simply leaves the previous state untouched. ● So the Script in the map for Route 8 is left as DisplayEnemyTrainerTextAndStartBattle, so when the user returns to Route 8, this script will continue running (and waiting for 0xD730 to be 0)
  • 25. Teleport / Fly ● Most maps contain 3 map scripts: ○ CheckFightingMapTrainers ○ DisplayEnemyTrainerTextAndStartBattle ○ EndTrainerBattle ● So after the user teleports to a new map, the new map's current script is CheckFightingMapTrainers, however the game is affected by a couple things: ○ The START button is disabled, because memory at D730 is not clear and the game thinks the trainer is still walking towards the user. Until the D730 is clear, most actions are disabled. ○ Going back to Route 8 will have all trainers disabled because Route 8 is in the DisplayEnemyTrainerTextAndStartBattle script, so no trainer will know to look for you, but only on that map, other maps will run the CheckFightingMapTrainers script.
  • 26. The Setup ● After escaping from Route 8, the player will be crippled by the D730, so he needs to get that cleared. To do that, the player needs to complete a DisplayEnemyTrainerTextAndStartBattle routine so that the game clears the value.
  • 27. The Setup ● By fighting with another trainer that will walk up to you (it has to walk up to you as otherwise the "walk to user" code won't be called) the game will mostly go back to a normal state (except Route 8 which is stuck in the battle mode).
  • 28. The Setup ● When the player is fighting, the game copies several values of the pokemon and the trainer on to memory, such as the pokemon's type, it's level, hitpoints, as well as stats such as attack, defense, speed and special. ● CopyData which copies bc bytes (=1+5*2=11 bytes) from hl (=wEnemyMonLevel) to de (=wEnemyMonUnmodifiedLevel=cd23).
  • 29. The Setup ● The address in memory where this data is copied is CD23, and the amount of data copied is 11 bytes (NUM_STATS is 5, hitpoints, attack, defense, speed, special), so up to CD2D. ● Note, however that the memory in CD2D is also used for "wEngagedTrainerClass".
  • 30. The Setup ● This means that wEngagedTrainerClass will be equal to the "special" stat of the pokemon you fight against. If you fight the youngster, it will be a Slowpoke with a "special" stat of 21.
  • 31. The Setup ● Finally, after fighting the youngster, which serves two purposes ○ Marking the memory at D730 to 0, so that the DisplayEnemyTrainerTextAndStartBattle script doesn't think there's a trainer walking. ○ Setting the memory at CD2D to 21 via the Slowpoke's "special" stat, so that the wEngagedTrainerClass will hold that value when read the next time.
  • 32. The Last Step ● The player can now go back to Route 8. Now, when the user enters Route 8, the game will still try to run the script DisplayEnemyTrainerTextAndStartBattle but since we already cleared the D730 memory, the game will try to show the player the enemy text.
  • 33. The Last Step ● The DisplayEnemyTrainerAndStartBattle script will try to display the text in the memory pointed by wSpriteIndex, which is the last text shown to the user, which in our case is usually the START menu. So when the user enters the map Route 8 the START menu is displayed.
  • 34. The Last Step ● And after the START menu is dismissed, the script starts the battle, to do so, it initializes the battle (the pokemon to fight, it's level and so on) with the function InitBattleEnemyParameters.
  • 35. The Last Step ● The wCurOpponent (the pokemon type) is set to wEngagedTrainerClass, which was set to 21 after fighting against the Youngster's Slowpoke
  • 36. ● Since 21 is less than 200, the battle is defined as a "no trainer" (or "wild") battle, and the pokemon is loaded as 21. 21 is the pokemon identifier for MEW, so the player fights a "wild" MEW. The Last Step