Main Menu
Main Page
Forums
New pages
Recent changes
Random page
Help

Glitches
Arbitrary code execution
Pokémon cloning
Pomeg glitch and Glitzer Popping
Tweaking and voiding
Glitches by generation
Glitch categories

References/Resources
Databases
Disassembly projects
The Big HEX List
Pokémon cheat codes
Pokémon glitch terminology
Useful tools
More

Affiliates
Legendary Star Blob 2 (Hakuda) (日本語/Japanese)
Pokémon Speedruns wiki (English)
PRAMA Initiative (Français/French)
MissingNo. Glitch City (Italiano/Italian)
Become an affiliate!

Technical
Site source code

Search Wiki

 

Search Forums

 

Author Topic: Anyone with a knowledge of hex help me out?  (Read 164 times)

0 Members and 1 Guest are viewing this topic.

greentyphlosion

  • GCLF Member
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Anyone with a knowledge of hex help me out?
« on: August 14, 2019, 05:23:02 am »
Apologies if this is in the wrong thread, etc.

I've just got my hands on an Xploder cartridge which I've been using on various games. I have a working shiny code for Pokemon Emerald which is great (especially as I have a Max IV code that works in conjunction with it) but for some reason every Pokemon I catch has a Lonely nature. Unfortunately while I've a little experience with Hex I'm unable to discern what part of the code exactly is fixing the Natures. Can anyone assist?

Codes below:

(m)
928817F0298A
BBC1B6B105C4
B84FBA534945

(Shiny code)
1130CB63CD01
3004FB634D27
118263F709DD
56FC0D142272
D9A856E44D4C


greentyphlosion

  • GCLF Member
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #1 on: August 14, 2019, 07:48:00 am »
...well, this is interesting.

I've just tried the same code on a different save file. Same result, except that all the Pokemon caught are Relaxed instead of Lonely.

My new theory is that the code is working on each individual file's ID. Presumably, further save files will elicit different results. Will keep researching...

Sherkel

  • Ringsome on the aquaface
  • Administrator
  • *****
  • Offline Offline
  • Gender: Male
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #2 on: August 14, 2019, 09:13:20 am »
What you're looking for is someone who knows how the Xploder encrypts its codes. The way all of these devices work is by writing a byte to a specific location in memory, or multiple instances of that in case of a longer code. After the original GameShark, for whatever reason the developers decided to make the mechanism less obvious by throwing an encryption algorithm on top of it. I tried using this, but it needs to know the Xploder version and a "game ID" which I don't know the first thing about.

However, it's not hard to guess how the code works, given how these games decide what's shiny once it's encountered or hatched. It simply takes the PID (4 bytes) of the Pokémon in question, calculates the XOR of the upper and lower 2 bytes, then calculates the XOR of your ID and secret ID (2 bytes each), and if the difference is less than 8 (0 included, so in short a chance of 8/65536 or 1/8192), it's a shiny. It can be traded to other games and stay shiny due to its status as such being permanent, but if it were originally encountered on that other game, it wouldn't be, unless the ID and secret ID were the same or extremely close.

That said, the code probably works in one of two ways:

Code: [Select]
Store your ID to an unused memory location (i.e. read it)
Store your secret ID to an unused memory location
Upon encountering the next Pokémon, make the PID be identical to that (as a xor a is 0, which is less than 8)

or (which seems more likely, based on what you said):

Code: [Select]
Load a specific value to the PID of the next encountered Pokémon
Temporarily change your ID to match that, putting it in an out of an unused location before and after the battle

It's a pretty silly method, but "it's just Pokémon", and it gets the job done. What makes it so obviously silly, though, is the fact that a PID includes nature (and in Gen III, can be extrapolated directly to IVs in wild encounters), so those will always be the same if the code temporarily changes your ID to a specific value or something along those lines. It might not be that exactly; I'd have to check the decomp instead of going off what's off the top of my head, but keep in mind that shininess and nature are inherently intertwined.

EDIT:
...well, this is interesting.

I've just tried the same code on a different save file. Same result, except that all the Pokemon caught are Relaxed instead of Lonely.

My new theory is that the code is working on each individual file's ID. Presumably, further save files will elicit different results. Will keep researching...
Okay, so it's more likely to be the first one. With how few lines of machine code it is, it's bound to just be copying your ID and SID to the PID of whatever you encounter, making it always the same, and the most obvious tell of that without using PKHex would be nature.
« Last Edit: August 14, 2019, 09:20:41 am by Sherkel »

Kind of on hiatus for the next few weeks at least, but I always come back and in the meantime would like to encourage discussion on how the site is organized so as to let visitors find the most useful info (whatever that may be) in a clean and efficient fashion.
I don't have a habit of keeping Discord open, so direct inquiries are still preferred through here.

greentyphlosion

  • GCLF Member
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #3 on: August 14, 2019, 02:56:36 pm »
This is useful to know, thanks. I'll sniff around Reddit and Gamefaqs but these sorts of devices are such old hat I won't hold my breath.

After further testing can definitely confirm that the code is simply using my PID as a base. The characteristics of all the Pokemon encountered appear to be identical; I've caught a bunch of shiny Relaxed Wurmple and every single one of them has evolved into a Cascoon.

That site you linked to is interesting - it doesn't have anything for Emerald, but it does have an entry for FireRed (I assume the basics are the same).

The annoying thing is that with the codes I've currently got I can get a 6IV Pokemon or a shiny Pokemon, but not one that's both (unless, of course, it's Relaxed or Lonely). Might be good for the Battle Palace, I suppose?
« Last Edit: August 14, 2019, 02:57:07 pm by greentyphlosion »

Evie the Mother Hen ☽ ❤

  • Head Administrator
  • *****
  • Offline Offline
  • Gender: Female
  • I love My Melody. I want to be a mum. 🦋 ✿
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #4 on: August 14, 2019, 05:14:32 pm »
Using cbacrypt with these codes (a program to decrypt and encrypt codebreaker codes unfortunately forgot where you can download it), I get:

(m, decrypted):
928817F0 298A
00006FA7 000A
1006AFA4 0007

(shiny code, decrypted):
83007CE4 3020
83007CE6 0300
53003020 0004
001087E5 1EFF
2FE10000 0000

Looks like something is set to 00032030. As the 3007CE4-6 region is affected by DMA (what the address is is affected by randomization), one of the codes possibly anti-DMA, so that it's always wild Pokémon related.

Unfortunately that's as far as I got right now but my guess is this affects the wild Pokémon's PID. When calculating the Shiny Pokémon, both the player's Trainer ID and Secret ID considered (Bulbapedia explains the calculation).

Hope this helps. Sorry for not knowing anything further.

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory)

✿ Hi, I'm Evie. Transgender woman but spiritually doesn't believe 'male'/'female' needs to be defined; lives more stereotypically like a woman. Call me whichever pronouns you like. :)

Feel free to contact me here about anything regarding the site.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3

Sherkel

  • Ringsome on the aquaface
  • Administrator
  • *****
  • Offline Offline
  • Gender: Male
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #5 on: August 15, 2019, 10:31:20 pm »
The annoying thing is that with the codes I've currently got I can get a 6IV Pokemon or a shiny Pokemon, but not one that's both (unless, of course, it's Relaxed or Lonely). Might be good for the Battle Palace, I suppose?
The Battle Video trick makes it fairly easy to get the flawless IVs without cheat codes, assuming you're using wild encounters only (breeding is more complicated but faster). Getting your ID to make them shiny is a TAS thing, but again only if it's wild encounters.

Play the game however it's most fun to you, though, obviously. You just might be limited with an older external device like that in terms of the results you're looking for.

Kind of on hiatus for the next few weeks at least, but I always come back and in the meantime would like to encourage discussion on how the site is organized so as to let visitors find the most useful info (whatever that may be) in a clean and efficient fashion.
I don't have a habit of keeping Discord open, so direct inquiries are still preferred through here.

greentyphlosion

  • GCLF Member
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #6 on: August 16, 2019, 03:57:04 pm »
Using cbacrypt with these codes (a program to decrypt and encrypt codebreaker codes unfortunately forgot where you can download it), I get:

(m, decrypted):
928817F0 298A
00006FA7 000A
1006AFA4 0007

(shiny code, decrypted):
83007CE4 3020
83007CE6 0300
53003020 0004
001087E5 1EFF
2FE10000 0000

Looks like something is set to 00032030. As the 3007CE4-6 region is affected by DMA (what the address is is affected by randomization), one of the codes possibly anti-DMA, so that it's always wild Pokémon related.

Unfortunately that's as far as I got right now but my guess is this affects the wild Pokémon's PID. When calculating the Shiny Pokémon, both the player's Trainer ID and Secret ID considered (Bulbapedia explains the calculation).

Hope this helps. Sorry for not knowing anything further.


No, this is great! Thanks. I've been playing around with codes over the last couple of days and I think I'm a bit more up on how they're put together, so I'm edging ever closer.

greentyphlosion

  • GCLF Member
  • Offline Offline
  • CHARIZRAD 'M ROXORX or is it.
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #7 on: August 16, 2019, 03:58:22 pm »
The annoying thing is that with the codes I've currently got I can get a 6IV Pokemon or a shiny Pokemon, but not one that's both (unless, of course, it's Relaxed or Lonely). Might be good for the Battle Palace, I suppose?
The Battle Video trick makes it fairly easy to get the flawless IVs without cheat codes, assuming you're using wild encounters only (breeding is more complicated but faster). Getting your ID to make them shiny is a TAS thing, but again only if it's wild encounters.

Play the game however it's most fun to you, though, obviously. You just might be limited with an older external device like that in terms of the results you're looking for.

I... was not aware of this. Holy s**t.

Evie the Mother Hen ☽ ❤

  • Head Administrator
  • *****
  • Offline Offline
  • Gender: Female
  • I love My Melody. I want to be a mum. 🦋 ✿
    • View Profile
Re: Anyone with a knowledge of hex help me out?
« Reply #8 on: August 16, 2019, 04:00:11 pm »
No, this is great! Thanks. I've been playing around with codes over the last couple of days and I think I'm a bit more up on how they're put together, so I'm edging ever closer.

Awesome! ^^ ~ Glad to hear and hope you learn more and more. :)

✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿
Here have some free flowers on every post :)
✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿✿



(Images © Sanrio, Nintendo, Pokémon, HAL Laboratory)

✿ Hi, I'm Evie. Transgender woman but spiritually doesn't believe 'male'/'female' needs to be defined; lives more stereotypically like a woman. Call me whichever pronouns you like. :)

Feel free to contact me here about anything regarding the site.

Forgiveness. I feel that the more people pray to our greatest source/God/mathematical equality for world peace, the more and more it manifests into reality (until our next spiritual death).

Thank you Nyapon for this lovely artwork. :3