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

'warning: left shift count >= width of type' error

31
Posts
3
Years
    • Seen Oct 7, 2023
    After trying to build my rom, I got this error in src/data/pokemon/tmhm_learnsets.h (pokeemerald) on the first line for each pokemon. Prior to to this, I added 10 more TMs to the game (might have something to do with it), and now whenever I try to make the game, I just get a bunch of 'warning: left shift count >= width of type' errors. The first error is on line 11 which reads ' [SPECIES_BULBASAUR] = TMHM_LEARNSET(TMHM(TM06_TOXIC)' the error repeats 3 more times for line 11, and it repeats for the first TM of each pokemon. I attached a screenshot of Bulbasaur's first few moves and the first couple errors (again the error repeated a lot more).
     

    Attachments

    • 'warning: left shift count >= width of type' error
      Screenshot 2021-08-30 155039.png
      37.8 KB · Views: 9

    ellabrella

    PKMN Trainer
    57
    Posts
    5
    Years
    • She/It
    • Seen Apr 17, 2024
    i haven't messed with tmhm learnsets nor added new tms, but i'm interested in helping. judging by the error i have a guess as to what might be happening.

    the error is saying you've tried to bit-shift more bits than fit into the type of data your working with. my first suspicion is that the TMHM learnset data holds exactly x bits, one for each TM in the base game, and your code is trying to write x + 10 bits into it, for each TM in the base game + the 10 you added.

    i don't have a decomp in front of me right now so i can't say if this is correct. i don't know exactly how TMHM_LEARNSET() works. but i think that's the first place to look. you can hopefully find out what size the TMHM learnset data type is, and increase that size to fit your new TMs.
     
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    i haven't messed with tmhm learnsets nor added new tms, but i'm interested in helping. judging by the error i have a guess as to what might be happening.

    the error is saying you've tried to bit-shift more bits than fit into the type of data your working with. my first suspicion is that the TMHM learnset data holds exactly x bits, one for each TM in the base game, and your code is trying to write x + 10 bits into it, for each TM in the base game + the 10 you added.

    i don't have a decomp in front of me right now so i can't say if this is correct. i don't know exactly how TMHM_LEARNSET() works. but i think that's the first place to look. you can hopefully find out what size the TMHM learnset data type is, and increase that size to fit your new TMs.

    Thanks but I don't exactly know how to expand the file size or what file I need to edit for that
     
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    i haven't messed with tmhm learnsets nor added new tms, but i'm interested in helping. judging by the error i have a guess as to what might be happening.

    the error is saying you've tried to bit-shift more bits than fit into the type of data your working with. my first suspicion is that the TMHM learnset data holds exactly x bits, one for each TM in the base game, and your code is trying to write x + 10 bits into it, for each TM in the base game + the 10 you added.

    i don't have a decomp in front of me right now so i can't say if this is correct. i don't know exactly how TMHM_LEARNSET() works. but i think that's the first place to look. you can hopefully find out what size the TMHM learnset data type is, and increase that size to fit your new TMs.

    Any suggestions where to go? I've been looking around the decomp, and I cant find where I am supposed to 'add' more bits to the tmhm_learnsets.h file, so unless I can find it, the only way I can progress is removing the new tms.
     

    ellabrella

    PKMN Trainer
    57
    Posts
    5
    Years
    • She/It
    • Seen Apr 17, 2024
    just woke up, i'll have a look today!

    but it's not the size of the tmhm learnsets .h file that you're trying to increase, it's the data type that stores a pokemon's individual learnset. i expect it'll be in a header file in the include folder somewhere, that's the best place to look for variables.
     
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    If you're having trouble, I managed to insert 50 more TM's a long time ago and it works fine. You can check the changes I made on my repository:

    https://github.com/kevinmc37/pokemon-slumber/commit/0ef243b4ff7c1d0103a5e4b26bfa227020032251

    And here it's explained how I did it:

    https://www.pokecommunity.com/showthread.php?p=10250950#post10250950

    If you need help with anything of it just ask

    I am working on the regular emerald decomp, will the suggestions you made work there? Also I only have 60 TMs as of now, and in your area about src/data/tmhm_learnsets.h you go from tm00-tm64 in your definitions, but I don't have enought tms to do that. Will it still work?
     
    56
    Posts
    8
    Years
  • I am working on the regular emerald decomp, will the suggestions you made work there? Also I only have 60 TMs as of now, and in your area about src/data/tmhm_learnsets.h you go from tm00-tm64 in your definitions, but I don't have enought tms to do that. Will it still work?

    I don't think the expansion changed anything related to TM's so there shouldn't be too much differences in the code, if none at all. But I don't know if my changes will work, as you mention you're only adding 10 TMs (making it a total of 60). If I remember correctly the maximum number of TMs you could have without major changes was 64, and I did all of that to increase that number. The changes you're trying to do should be easier.

    I don't have access to my PC right now so I can't check what you need to do to solve your problem until tomorrow
     
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    I don't think the expansion changed anything related to TM's so there shouldn't be too much differences in the code, if none at all. But I don't know if my changes will work, as you mention you're only adding 10 TMs (making it a total of 60). If I remember correctly the maximum number of TMs you could have without major changes was 64, and I did all of that to increase that number. The changes you're trying to do should be easier.

    I don't have access to my PC right now so I can't check what you need to do to solve your problem until tomorrow

    It's alright, just if you find out let me know.
     
    56
    Posts
    8
    Years
  • Okay, so the first thing I should ask is, in "include/constants/items.h", if you put the new TMs before or after the HMs. I know there's code somewhere that counts the TMs until it reaches HM Cut, so you'd need to put the TMs before those (and consequently change the values of all the following items). And in the same file, change the value of the "#define NUM_TECHNICAL_MACHINES 50" to 60

    After defining the new TMs what I'd do is adding them to the game, adding their entries in the files " src/data/item_icon_table.h", " src/data/text/item_descriptions.h" and " src/data/items.h" in the same order as before.

    Finally you need to add the new moves to the TM's at the end of the file " src/data/party_menu.h", and then put the TMs in "src/data/pokemon/tmhm_learnsets.h" with the same structure the file has.

    You shouldn't need to change anything else to make it work. If for some reason it doesn't, It would be useful if I could see your files, as the first screenshot doesn't provide too much info
     
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    Okay, so the first thing I should ask is, in "include/constants/items.h", if you put the new TMs before or after the HMs. I know there's code somewhere that counts the TMs until it reaches HM Cut, so you'd need to put the TMs before those (and consequently change the values of all the following items). And in the same file, change the value of the "#define NUM_TECHNICAL_MACHINES 50" to 60

    After defining the new TMs what I'd do is adding them to the game, adding their entries in the files " src/data/item_icon_table.h", " src/data/text/item_descriptions.h" and " src/data/items.h" in the same order as before.

    Finally you need to add the new moves to the TM's at the end of the file " src/data/party_menu.h", and then put the TMs in "src/data/pokemon/tmhm_learnsets.h" with the same structure the file has.

    You shouldn't need to change anything else to make it work. If for some reason it doesn't, It would be useful if I could see your files, as the first screenshot doesn't provide too much info

    Haven't worked on the decomp in a while because of school but I finished the tmhm learnsets today and I still got the same error message. I added the tms to all the required files but it still isn't working. If you want to see my work, let me know how I can share it.
     
    56
    Posts
    8
    Years
  • Okay, I understand why it's not working. As I said the maximum number of TMs you could have is 64, the thing is HMs also count, so actually we have 58 TMs. If you add 10 more, it makes to 68 TMs, which is more than the normal. So, despite you're only adding 10 more, you need to do as I did in this post

    https://www.pokecommunity.com/showthread.php?t=438495&page=2

    If you follow all the things I did here and there, you should be able to have the new TMs added. I tested it on a new copy of pret pokeemerald and works as intended

    Unfortunately that means a bit more work on your part regarding pokemon learnsets, as HMs Flash, Rock Smash, Waterfall and Dive need to move to the TMHM2 section, and would give error on all Pokémon who use those moves if not
     
    Last edited:
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    Okay, I understand why it's not working. As I said the maximum number of TMs you could have is 64, the thing is HMs also count, so actually we have 58 TMs. If you add 10 more, it makes to 68 TMs, which is more than the normal. So, despite you're only adding 10 more, you need to do as I did in this post

    https://www.pokecommunity.com/showthread.php?t=438495&page=2

    If you follow all the things I did here and there, you should be able to have the new TMs added. I tested it on a new copy of pret pokeemerald and works as intended

    Unfortunately that means a bit more work on your part regarding pokemon learnsets, as HMs Flash, Rock Smash, Waterfall and Dive need to move to the TMHM2 section, and would give error on all Pokémon who use those moves if not

    When you say that, does that mean I put HM04_strength where you put explosion because that is tm/hm number 64? Here's what I mean:
    #define TMHM2(tmhm) ((u64)1 << (ITEM_##tmhm - ITEM_HM04_STRENGTH))

    and here it is in practice:

    Code:
        [SPECIES_BULBASAUR]   = TMHM_LEARNSET(TMHM(TM06_TOXIC)
                                            | TMHM(TM09_BULLET_SEED)
                                            | TMHM(TM10_HIDDEN_POWER)
                                            | TMHM(TM11_SUNNY_DAY)
                                            | TMHM(TM17_PROTECT)
                                            | TMHM(TM19_GIGA_DRAIN)
                                            | TMHM(TM21_FRUSTRATION)
                                            | TMHM(TM22_SOLARBEAM)
                                            | TMHM(TM27_RETURN)
                                            | TMHM(TM36_SLUDGE_BOMB)
                                            | TMHM(TM42_FACADE)
                                            | TMHM(TM43_SECRET_POWER)
                                            | TMHM(TM44_REST)
                                            | TMHM(HM01_CUT)
                                            | TMHM(HM04_STRENGTH)
    						| TMHM2(TM60_POISON_JAB)
                                            	| TMHM2(HM05_FLASH)
                                            	| TMHM2(HM06_ROCK_SMASH)),

    is this good (I'm noticing now that I don't think poison Jab needs to be in tmhm2, only anything after tmhm 64 (strength in my case), but aside from that I think I got it)?
     
    Last edited:
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    Okay, I understand why it's not working. As I said the maximum number of TMs you could have is 64, the thing is HMs also count, so actually we have 58 TMs. If you add 10 more, it makes to 68 TMs, which is more than the normal. So, despite you're only adding 10 more, you need to do as I did in this post

    https://www.pokecommunity.com/showthread.php?t=438495&page=2

    If you follow all the things I did here and there, you should be able to have the new TMs added. I tested it on a new copy of pret pokeemerald and works as intended

    Unfortunately that means a bit more work on your part regarding pokemon learnsets, as HMs Flash, Rock Smash, Waterfall and Dive need to move to the TMHM2 section, and would give error on all Pokémon who use those moves if not

    also in your code when you say:
    Spoiler:


    will it work for me even if I don't have as big a total of tms/hms?
     
    31
    Posts
    3
    Years
    • Seen Oct 7, 2023
    Okay, I understand why it's not working. As I said the maximum number of TMs you could have is 64, the thing is HMs also count, so actually we have 58 TMs. If you add 10 more, it makes to 68 TMs, which is more than the normal. So, despite you're only adding 10 more, you need to do as I did in this post

    https://www.pokecommunity.com/showthread.php?t=438495&page=2

    If you follow all the things I did here and there, you should be able to have the new TMs added. I tested it on a new copy of pret pokeemerald and works as intended

    Unfortunately that means a bit more work on your part regarding pokemon learnsets, as HMs Flash, Rock Smash, Waterfall and Dive need to move to the TMHM2 section, and would give error on all Pokémon who use those moves if not

    sorry for the repeated responses but after making the changes you suggested, I get repeated messages of

    Code:
    src/data/pokemon/tmhm_learnsets.h:30:66: error: macro "TMHM_LEARNSET" requires 2 arguments, but only 1 given
       30 |                                          | TMHM2(HM06_ROCK_SMASH)),
           |                                                                                                    ^
    src/data/pokemon/tmhm_learnsets.h:1: note: macro "TMHM_LEARNSET" defined here
        1 | #define TMHM_LEARNSET(moves, moves2) {(u32)(moves), ((u64)(moves) >> 32), (u32)(moves2), (u64)(moves2) >> 32}
          |

    and

    Code:
    src/data/pokemon/tmhm_learnsets.h:13: `TMHM_LEARNSET' undeclared here (not in a function)
    src/data/pokemon/tmhm_learnsets.h:13: initializer element for `gTMHMLearnsets[1]' is not constant

    Both of these are repeated for every pokemon, and I'm not sure why this is.
     
    56
    Posts
    8
    Years
  • When you say that, does that mean I put HM04_strength where you put explosion because that is tm/hm number 64? Here's what I mean:
    #define TMHM2(tmhm) ((u64)1 << (ITEM_##tmhm - ITEM_HM04_STRENGTH))
    [/CODE]

    is this good (I'm noticing now that I don't think poison Jab needs to be in tmhm2, only anything after tmhm 64 (strength in my case), but aside from that I think I got it)?

    Where my Tm64_Explosion is, you should be having Hm05_Flash. You should have a maximum of 64 Tms on TMHM and another 64 on TMHM2. And yes, don't worry about it working because I tested it with your example and worked fine.

    You're missing some things though on the Learnset above. As you say, Poison Jab doesn't go in TMHM2, as it's TM60 and fits in the first 64. Then, you have to add a comma after the Poison Jab parenthesis and delete the next |

    It should look like this. In this case I move Poison Jab before the HMs, that's the way I always do it. It should work your way too though


    [SPECIES_BULBASAUR] = TMHM_LEARNSET(TMHM(TM06_TOXIC)
    | TMHM(TM09_BULLET_SEED)
    | TMHM(TM10_HIDDEN_POWER)
    | TMHM(TM11_SUNNY_DAY)
    | TMHM(TM17_PROTECT)
    | TMHM(TM19_GIGA_DRAIN)
    | TMHM(TM21_FRUSTRATION)
    | TMHM(TM22_SOLARBEAM)
    | TMHM(TM27_RETURN)
    | TMHM(TM36_SLUDGE_BOMB)
    | TMHM(TM42_FACADE)
    | TMHM(TM43_SECRET_POWER)
    | TMHM(TM44_REST)
    | TMHM (TM60_POISON_JAB)
    | TMHM(HM01_CUT)
    | TMHM(HM04_STRENGTH), TMHM2(HM05_FLASH)
    | TMHM2(HM06_ROCK_SMASH)),
     
    Back
    Top