• 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.

[ASM & Hex] Shiny Chance/Charm

Zervais

Island Kahuna
258
Posts
7
Years
  • I'm a big lover of shiny Pokemon and want players of my hack to experience them more often, if possible. I am looking for information/a way to increase the shiny chance. Is there specific bytes I can edit to change the chance shinies are encountered? And is there a way to implement an item much like the shiny charm in the later games?

    Thanks, friends.
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years

  • lets be real here.

    Code:
    	mov r0, #0xA
    	lsl r0, r0, #0x7
    	add r0, r0, #0x55 @1/1365 chance with shiny charm
    	b calcChance

    replace that with:

    Code:
    	ldr r0, =(1365)
    	b calcChance

    I used to have this idea that calculating large values was faster than just setting them. Setting them makes the code actually easier to edit though, and the speed is negligible due to execution frequency. It does take 2 extra bytes of extra space if the loaded value is an entire word, but 2 bytes is nothing.

    You'll notice that Gamefreak's compiler chose to optimize these into bit shifts, but it's probably the case that their original values were set, rather than derived. I think everyone should use ldr (or mov in the case of 1 byte values) to set values, even if it's purely for readability.
     

    BluRose

    blu rass
    812
    Posts
    10
    Years
  • Spoiler:
    but fbi! it's always nice to be able to read gf's code based on their optimization and things. i mean, it's really a simple difference anyways (let's be real, you're not sorting through ida looking for something if you don't even know all/most of the asm commands themselves), but i almost think it would be better just to keep within the game's style for consistency? granted, a communal comsistency is probably more important...
    nevermind i guess ahaha~
    watch as one day in the future lag becomes a problem because of decisions made now based off of "negligible speed differences"
     

    Blah

    Free supporter
    1,924
    Posts
    11
    Years
  • but fbi! it's always nice to be able to read gf's code based on their optimization and things. i mean, it's really a simple difference anyways (let's be real, you're not sorting through ida looking for something if you don't even know all/most of the asm commands themselves), but i almost think it would be better just to keep within the game's style for consistency? granted, a communal comsistency is probably more important...
    nevermind i guess ahaha~
    watch as one day in the future lag becomes a problem because of decisions made now based off of "negligible speed differences"

    It depends on where you are neglecting optimizations. This code here is only run once every time the game needs to generate a Pokemon. Now consider that the game executes code every row of pixels that is drawn on the screen for things like flash and battle animations. Optimizing something like the Hblank IRQ service routine is important, this shiny routine? Not at all XD

    As for consistency, I think readability is much more important than keeping it harder to read. Remember that gamefreak's ASM is output by a compiler, the original is written in C. You shouldn't try to copy the compiler's tendencies at the cost of making your code harder to modify in the future. :)
     
    Back
    Top