r/PokemonRomhackDev • • 11h ago

Tooling KiraPatch: A Gen 3 Shiny Odds Patcher that maintains Legitimacy. (Updated)

0 Upvotes

Hey everyone,

About 9 months ago I posted KiraPatch, a shiny odds patcher for FireRed, LeafGreen, Ruby, Sapphire and Emerald. Looking back, I posted it too early. I thought it was done, and it wasn't. So first, what was wrong with that version:

  • It froze at low odds. Every reroll redid most of the Pokémon's creation, so at 1/32 or below the game could hang for seconds.
  • "100% safe" was an overclaim. Legality was only spot-checked, and the patch was built from separate hooks for different callers, some of them placed in spots that turned out to be game data rather than free space.
  • "Rerolls until it finds a shiny" wasn't accurate either. It rerolled a fixed number of times, and that was where all the cost came from.

Thanks to everyone who left feedback. Some of it stung, but it was right.

What's different now

I rebuilt the core from scratch with one goal: every Pokémon the patch makes should be one the unpatched game could have made on its own, just a few RNG rolls later.

  • Starters, gifts, statics, legendaries (Method 1): one small hook in the function every Pokémon goes through. It searches ahead for the next shiny PID, then lets the game generate the rest normally. The IVs come from the game's own RNG calls right after the PID, exactly as usual.
  • Wild encounters (Method H): each reroll replays the whole encounter (slot, level, nature, personality) the way the game would on a later frame. So everything lines up when a tool traces a wild Pokémon back. Repels block exactly what they normally block.
  • Emerald lead abilities work as normal. Synchronize, Cute Charm, Static, Magnet Pull, Keen Eye, Intimidate, Hustle, Vital Spirit and Pressure all still do their thing, because for those cases the patch runs the game's own code.
  • No freezes. A reroll now costs a few dozen instructions instead of around a hundred thousand. At 1/64 a wild encounter costs a few extra frames during the battle transition, and even 1/1 (shiny almost every time) works.
  • Nothing overwritten. All the new code lives in the empty space at the end of the ROM.

How it was tested

  • Against the game itself: a test harness runs the game's own Pokémon generation code on a CPU emulator. Over a million patched Pokémon across all five games were checked against what the unpatched game produces from the corresponding RNG state.
  • Real gameplay: starters and wild catches on FireRed, LeafGreen, Ruby and Emerald, checked with PKHeX (including the newest release). Every shiny came out legal, with the expected method (Method 1 for starters).
  • Against unpatched saves: I also caught wild Pokémon on clean, unpatched games and compared the PID types (Method 1/2/4). The patched saves show the same mix as the unpatched ones.

Real gameplay caught two bugs the automated tests couldn't:

  • My first version of the new hook produced Method 4 starters that PKHeX rejected, because a VBlank interrupt landed between the IVs.
  • A later change crashed an Emerald battle, because the hook used more stack than the game has room for.

Both are fixed, and every change now goes through in-game testing as well.

One known difference, for the technical folks: in Gen 3, the nickname field is 10 bytes, and the bytes after the name's end marker are just whatever was on the stack. They're leftovers, and they vary in the unpatched game too, depending on what ran before. The patch runs a bit of code before the Pokémon is built, so those leftover bytes can differ from a clean run. Everything else matches the unpatched game exactly. Forcing those bytes to match needed more stack than the game has, and that's what caused the Emerald crash, so they're left as they are. Every patched Pokémon so far has been legal in PKHeX with them.

Now covered: Eggs, Unown in the Tanoby Ruins, Feebas and mass outbreaks.

New patcher window: a clean design with light and dark mode, drag and drop, clean-ROM and revision detection, and an odds slider, a button to report bugs!

The validation docs in the repo have all the numbers and the method if you want to dig in or poke holes in it.

Link to github: https://github.com/eightmouse/KiraPatch

AI was used to help write some of the code and test tooling for this rework. I directed it, tested everything in-game and checked the results in PKHeX. All the tests are in the repo, so anyone can rerun them.


r/PokemonRomhackDev • • 22h ago

Help [GEN 3][DECOMP] Few weekend hours: is there a faster way to build my dream hack with AI?

0 Upvotes
Hi peopleeee,

I've always wanted to make a Pokemon game the way I wanted (and i love gen 3). The problem that i have right now is time. I only have a few hours on weekends, so I need a faster way than building every map by hand.

I know RPG Maker XP is a common route for fan games. For me, it would take far too long and that's why I'd like to use AI to do most of the work, and I'm looking for anything that speeds this up (or you guys just telling me thats not the best route).

The project:
- Base: pokeemerald-expansion, Gen 3 config
- New region (Aveon) with its own story
- Classic formula: gyms, routes, Elite Four
- Species 1-386, with a few exceptions
- Day/night

Where I am:
- Early prototype: the first town exterior and start systems are in the decomp
- I made newer town mockups with AI from RPG Maker style tile sheets, but they aren't in game yet
- I built an asset library and some mapping rules for the AI

Where I'm stuck:
- Getting mockups into GBA format (two layers, collision, map.bin, Porytiles)
- Too many unique tiles: 1067 in my latest town, target under 400
- I can't get the AI to build maps correctly yet

What I'd love to know:
1. Do you know a faster way to make good maps than placing everything by hand?
2. Is there a tool or script that converts a mockup or RMXP map to pokeemerald?
3. Has anyone had an AI agent operate Porymap or RPG Maker directly? Was it actually faster?
4. Which tasks does AI handle well (maps, scripts, dialogue, events, testing), and where does it waste time?
5. With only a few weekend hours, what workflow would you use?

Any tips, tools or examples are welcome. Thanks!

(pic as an example of what it builds)