• 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?".
  • Please note that users with less than 6 posts will have their threads/posts go to the approval queue if it has links or messages. This counts edits made to threads/posts after they were already approved and is intentional anti-spam behavior that is unfortunately necessary. Once you reach 6 posts, this will no longer occur.
  • 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.

Red hack: Shin Pokemon Red/Blue/Green/JP builds (Bugfix, AI, and QoL patch)

  • 536
    Posts
    4
    Years
    • Seen today
    do external randomizers still work?

    No. Generic external randomizers for vanilla red/blue edit bytes that have changed addresses in Shin Pokemon. The game just crashes as a result. That's why I had to make my own external randomizer from scratch.
     
  • 536
    Posts
    4
    Years
    • Seen today
    The randomizer sounds awesome; something that I feel more of these "expansion" hacks should implement as it creates a whole new experience- I'm tired of using the same dang 3 starters each time! lol

    I've learned that this is harder than it looks. A few things I discovered:
    • A built-in randomizer should not go editing its own rom addresses. It will not write anything if using a flash card. If an emulator even allows this in the first place, the rom changes just get lost once you close out. The rom needs to be randomized again with every startup unless there is a way to save the modified rom from the emulator. BGB will let you save, but many people play rom hacks using phone emulators nowadays.
    • So another option is for a built-in randomizer to do its randomizing on the fly. Essentially just load random mons into party rosters and whatnot as needed. This takes lots of code to implement well, and doubly so if you want a lot of different choices (bank sizes can become an issue in GBC games). It also means you cannot track wild pokemon with your 'Dex because it references the wild tables stored in the game rom.
    • Finally, and most practical, is to simply edit the rom file with an external script or program. This requires that the randomizer knows the exact bytes that need to change and their exact positions within the rom file. If an assumed position is off by even one bit, then the whole rom file is probably hosed. Programs like Universal Randomizer are created with vanilla roms in mind where all the relevant byte addresses are well-researched and set in stone. Sometimes they work for rom hacks that just so happen to avoid shifting or changing any byte addresses used by the randomizer. Often, like in Shin Pokemon's case, some assumption the randomizer makes isn't true anymore and the rom file gets hosed somewhere.
    • So that leaves me with the little external bash script I wrote. Run it in a unix terminal. Externally edit the rom. Prompt the user for banks and hex addresses from the rom's matching sym file. Then use the input from the user to point to the correct locations. Better than having to update the dang thing every time I make a small change to the game code. Anyone can see inside the .sh script file to either adapt it for their own project or (more than likely) make fun of my atrocious coding practices.
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    I thought I'd report that upon testing to see if my PKMN could indeed correctly level up past 100 via the cap change I made, while rare candies work, the said PKMN doesn't gain any exp on 100. If I used a rare candy to raise it above 100 and then go into battle, it will reset to 100 and try to learn all of its level up moves. With that said, I've noticed in past Red builds I've made, that this only is affected when using a gift Pokemon. For instance, my Gyarados that I paid for when it was a Magikarp on Route 4 or starter PKMN. I know this isn't a problem from your code, but it's kinda unfortunate as I would have liked to continue to play.
     
  • 536
    Posts
    4
    Years
    • Seen today
    I thought I'd report that upon testing to see if my PKMN could indeed correctly level up past 100 via the cap change I made, while rare candies work, the said PKMN doesn't gain any exp on 100. If I used a rare candy to raise it above 100 and then go into battle, it will reset to 100 and try to learn all of its level up moves. With that said, I've noticed in past Red builds I've made, that this only is affected when using a gift Pokemon. For instance, my Gyarados that I paid for when it was a Magikarp on Route 4 or starter PKMN. I know this isn't a problem from your code, but it's kinda unfortunate as I would have liked to continue to play.

    What did you set as the level cap?
     
  • 536
    Posts
    4
    Years
    • Seen today
    I believe it was 250. I was at 101 via rare candy to test it and went into a battle via the randomized trainer.

    Pokemon structures only have 3 bytes allotted for experience. A max level of 250 causes the CalcExperience function to overflow into 4 bytes. This will be different depending on a mon's growth rate.

    Let's look at mewtwo for example. Math will be done in hex so it's easy to see the bytes being used. 250 in hex is $A8. Mewtwo's growth rate is "slow", so the exp it needs to hit the level cap i$s 5/4 n^3. Calculating ($A8)^3 gives $485a00. That's three bytes, so we're good so far. Now multiply by 5 to get $0169C200. Uh oh, that's 4 bytes. You've overflowed so that leftmost 01 gets tossed out of calculations. That leaves $69C200 / 4 to give a final result of $1A7080. This is an incorrect exp result that corresponds to a much lower level.

    By my calculations, the highest value for max_level without initiating an overflow for any of the growth rates is 140.
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    Pokemon structures only have 3 bytes allotted for experience. A max level of 250 causes the CalcExperience function to overflow into 4 bytes. This will be different depending on a mon's growth rate.

    Let's look at mewtwo for example. Math will be done in hex so it's easy to see the bytes being used. 250 in hex is $A8. Mewtwo's growth rate is "slow", so the exp it needs to hit the level cap i$s 5/4 n^3. Calculating ($A8)^3 gives $485a00. That's three bytes, so we're good so far. Now multiply by 5 to get $0169C200. Uh oh, that's 4 bytes. You've overflowed so that leftmost 01 gets tossed out of calculations. That leaves $69C200 / 4 to give a final result of $1A7080. This is an incorrect exp result that corresponds to a much lower level.

    By my calculations, the highest value for max_level without initiating an overflow for any of the growth rates is 140.

    140? That sucks. This is so much easier in gen 3 hacks, where I can go to 255 with no overflow errors. Thanks for the info. I was using a modified Gyarados with a medium slow exp formula instead of slow so it could go higher but that doesn't matter as much now, I suppose.
     
  • 536
    Posts
    4
    Years
    • Seen today
    140? That sucks. This is so much easier in gen 3 hacks, where I can go to 255 with no overflow errors. Thanks for the info. I was using a modified Gyarados with a medium slow exp formula instead of slow so it could go higher but that doesn't matter as much now, I suppose.

    Not all is lost. The engine for doing multiplication and division actually uses 4 bytes, so there is a bit of leeway the function for calculating experience. I whipped up a little something in about an hour.

    Try implementing the changes in this commit. This updates the CalcExperience function to do math with 4 bytes instead of 3 bytes. This will prevent the left-most byte from being dropped and give accurate math. Since pokemon are still restricted to 3 bytes of exp, I also made it so that it dynamically lowers the max_level for each pokemon (based on growth rate) such that the maximum experience achievable stays within 3 bytes. Theoretically, mons with the fast growth rate can go all the way to level 255 now while mons at the slow growth rate are capped to level 237.
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    Not all is lost. The engine for doing multiplication and division actually uses 4 bytes, so there is a bit of leeway the function for calculating experience. I whipped up a little something in about an hour.

    Try implementing the changes in this commit. This updates the CalcExperience function to do math with 4 bytes instead of 3 bytes. This will prevent the left-most byte from being dropped and give accurate math. Since pokemon are still restricted to 3 bytes of exp, I also made it so that it dynamically lowers the max_level for each pokemon (based on growth rate) such that the maximum experience achievable stays within 3 bytes. Theoretically, mons with the fast growth rate can go all the way to level 255 now while mons at the slow growth rate are capped to level 237.

    I appreciate you doing all that man! I still need to find a way to update from 1.15 to more recent. I've been playing on Goomba and haven't been able to transfer save without starting over. Could I just apply the changes you made in the older version of code I have?

    Also, would this work with a previous save? Or would I need to start over?
     
  • 536
    Posts
    4
    Years
    • Seen today
    I appreciate you doing all that man! I still need to find a way to update from 1.15 to more recent. I've been playing on Goomba and haven't been able to transfer save without starting over. Could I just apply the changes you made in the older version of code I have?

    Also, would this work with a previous save? Or would I need to start over?

    Yeah, it should work if you just apply those changes.

    In terms of updating your game save, have you tried saving outside in pallet town and using the softlock teleport?
     
  • 536
    Posts
    4
    Years
    • Seen today
    I've been playing on Goomba and haven't been able to transfer save without starting over.

    Go ahead and save in pallet town. Then post your save file here. I'll see what I can do in spite of goomba's format.

    As for preserving your code changes for a v1.18 update, you'd probably be fine with either Git Pull or Git Rebase.
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    Go ahead and save in pallet town. Then post your save file here. I'll see what I can do in spite of goomba's format.

    As for preserving your code changes for a v1.18 update, you'd probably be fine with either Git Pull or Git Rebase.

    I'll get to it when I can access my PC. Probably later today. I didn't know there was an option to pull only the changes from the source code on GitHub, but that actually makes a lot of sense. Thanks again.
     

    JOBO

    o/_\O
  • 633
    Posts
    9
    Years
    Hey jojobear! I absolutely love this hack and have put around 70ish hours into it now. I just wanted to thank you again for all of your hard work. Do you have any plans to give gen 2 the same treatment?
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    Go ahead and save in pallet town. Then post your save file here. I'll see what I can do in spite of goomba's format.

    As for preserving your code changes for a v1.18 update, you'd probably be fine with either Git Pull or Git Rebase.

    Here's the .sav. I saved in the player's room in Pallet Town.
     

    Attachments

    • pokered.gbc.sav
      136 KB · Views: 4
  • 536
    Posts
    4
    Years
    • Seen today
    Here's the .sav. I saved in the player's room in Pallet Town.

    Hmm...I'm not sure why this goomba sav is larger than 64 KB.

    Regardless, I was able to extract the save data from the goomba .sav file into a raw gbc .sav format. I loaded it up in BGB emulator with a v1.18M rom. I got invisible walls but no crashes (as expected). I used the softlock teleport to reload the overworld and the invisible walls cleared (also as expected). Everything checks out. I attached the raw gbc .sav file for you as a backup.

    I took the raw gbc .sav and compressed it back into the goomba .sav file. It was truncated to 64KB, but the compressed gbc save data should still be intact. It's also attached, so give it a try.
     

    Attachments

    • pokered.gbc.sav
      64 KB · Views: 2
    • pokered.sav
      32 KB · Views: 1
  • 4
    Posts
    3
    Years
    • Seen Jan 7, 2024
    I recently did a hardcore nuzlocke (nuzlocke + no items, no overleveling, battle every trainer) and it was so fun (version 1.17). This romhack is amazing.

    Though i have to point out something. I don't know if it's intentional or not, but Hypnosis seems to have 100% accuracy (the AI missed 0 times with that, and used it quite a lot), and this makes Agatha way more difficult than the rest of the game. I had very little problems everywhere else, but I almost died there. I lost 1 pokemon and the rest ended up with ~10 HP each (and almost all asleep).

    Also, the champion's Rhydon crit me like 4/8 hits. Assuming critical hits still work with base speed, that's odd. It might have been extremely bad luck, but just in case you want to look into it or something.

    Anyway, excelent job!
     
  • 536
    Posts
    4
    Years
    • Seen today
    I recently did a hardcore nuzlocke (nuzlocke + no items, no overleveling, battle every trainer) and it was so fun (version 1.17). This romhack is amazing.

    Thank you. Glad you had fun. I'm kind of surprised the Rocket in Mt Moon with the raticate didn't end your run.

    Though i have to point out something. I don't know if it's intentional or not, but Hypnosis seems to have 100% accuracy (the AI missed 0 times with that, and used it quite a lot), and this makes Agatha way more difficult than the rest of the game. I had very little problems everywhere else, but I almost died there. I lost 1 pokemon and the rest ended up with ~10 HP each (and almost all asleep).

    Also, the champion's Rhydon crit me like 4/8 hits. Assuming critical hits still work with base speed, that's odd. It might have been extremely bad luck, but just in case you want to look into it or something.

    You just had abysmal luck. Like, Xcom levels of bad luck.

    A note on move accuracy though. Retail red/blue had pretty poor rng to where 60% accuracy moves were actually more like 50% accuracy. Enemy status moves also had a flat 25% chance to miss on top of this to make the game easier. In retail red/blue, Agatha only has around 37% to 40% chance of actually landing hypnosis. She gets the full 60% accuracy in this hack, so that's a huge boost relative to the original games and you really feel it.
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    I tested the .sav you made, but it lead to a new game being started. I believe I'm SOL when it comes to Goomba on my RevoK101 Plus. I'm pretty sure the reason its save file structure is larger is because it stores FW information in the save. Just a guess. Anyway, if you can absolutely guarantee if I start a new game, that I'll be able to go to my said Level cap without issues via that build you made, then I'll start fresh.
     
  • 536
    Posts
    4
    Years
    • Seen today
    I tested the .sav you made, but it lead to a new game being started. I believe I'm SOL when it comes to Goomba on my RevoK101 Plus. I'm pretty sure the reason its save file structure is larger is because it stores FW information in the save. Just a guess. Anyway, if you can absolutely guarantee if I start a new game, that I'll be able to go to my said Level cap without issues via that build you made, then I'll start fresh.

    What happens if you just use your original save but use an updated rom?
     
  • 694
    Posts
    7
    Years
    • Seen Feb 22, 2024
    What happens if you just use your original save but use an updated rom?

    Normally, I can continue progress. But this rom specifically erased my save when I updated a few months ago. Same rom name and all. I had a backup fortunately.

    I appreciate all the help you've given me regardless.
     
    Back
    Top