• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Our weekly protagonist poll is now up! Vote for your favorite Trading Card Game 2 protagonist in the poll by clicking here.
  • 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.

[Other] [pokeemerald] Can't add more than 511 species?

  • 3
    Posts
    2
    Years
    • Seen Oct 11, 2023
    Hi all,

    I've recently gotten into messing around with decomps, and was attempting to add some of the later generation pokemon to my game. However, I started running into the issue while compiling that certain fields in hall_of_fame.c are always a certain value:

    Code:
    tools/agbcc/bin/agbcc <flags> -o build/emerald/src/hall_of_fame.o src/hall_of_fame.c
    agbcc: warnings being treated as errors
    src/hall_of_fame.c: In function `Task_Hof_DisplayMon':
    src/hall_of_fame.c:583: warning: comparison is always zero due to width of bitfield
    src/hall_of_fame.c: In function `Task_HofPC_DrawSpritesPrintText':
    src/hall_of_fame.c:929: warning: comparison is always zero due to width of bitfield
    src/hall_of_fame.c: In function `Task_HofPC_PrintMonInfo':
    src/hall_of_fame.c:978: warning: comparison is always one due to width of bitfield
    src/hall_of_fame.c: In function `HallOfFame_PrintMonInfo':
    src/hall_of_fame.c:1125: warning: comparison is always one due to width of bitfield
    src/hall_of_fame.c:1152: warning: comparison is always zero due to width of bitfield
    make: *** [Makefile:338: build/emerald/src/hall_of_fame.o] Error 1
    make: *** Deleting file 'build/emerald/src/hall_of_fame.o'

    Looking at them, they all have to do with comparing the pokemon species to the SPECIES_EGG:
    Code:
        if (currMon->species == SPECIES_EGG)
            destY += 10;

    ...and so on. My SPECIES_EGG in species.h is set to 519, one more that my last added pokemon. The issue is in struct HallofFameMon, where species has a max value of 511 due to the sizing restriction: u16 species:9;

    Code:
    struct HallofFameMon
    {
        u32 tid;
        u32 personality;
        [B]u16 species:9;[/B]
        u16 lvl:7;
        u8 nickname[POKEMON_NAME_LENGTH];
    };

    Bumping this up to u16 species:10; gives seems to make the SaveFile too large:
    Code:
    tools/agbcc/bin/agbcc <flags> -o build/emerald/src/save.o src/save.c
    src/save.c:78: size of array `SaveBlock2FreeSpace' is negative
    make: *** [Makefile:338: build/emerald/src/save.o] Error 1
    make: *** Deleting file 'build/emerald/src/save.o'

    Code that triggers it:
    Code:
    // These will produce an error if a save struct is larger than the space
    // alloted for it in the flash.
    STATIC_ASSERT(sizeof(struct SaveBlock2) <= SECTOR_DATA_SIZE, SaveBlock2FreeSpace);


    Does anyone know what I need to change to fix this? It's probably an easy fix, I just couldn't find anything in any of the existing guides. I noticed that pokeemerald-expansion doesn't have this size restriction in struct HallofFameMon, so I'm confused on how that one is able to compile.

    Any help is appreciated!
    TIA
     
    The expansion reduces the number of teams stored in the Hall of Fame in order to make it still fit in the two sectors allocated to it with the increased size of the data stored there. Three lines above the definition of struct HallOfFameMon in src/hall_of_fame.c is the line #define HALL_OF_FAME_MAX_TEAMS 50, which the expansion reduces to 30.
     
    The expansion reduces the number of teams stored in the Hall of Fame in order to make it still fit in the two sectors allocated to it with the increased size of the data stored there. Three lines above the definition of struct HallOfFameMon in src/hall_of_fame.c is the line #define HALL_OF_FAME_MAX_TEAMS 50, which the expansion reduces to 30.

    Thanks for the reply. I tried changing that value earlier but it didn't work. Maybe it wasn't low enough for what I was trying to do. However, I did try the two-line save space trick, and it worked! I'm sure I could do the math to see how many extra Pokemon this buys me, but it's enough for my use case.
     
    Back
    Top