pret / pokeplatinum

Decompilation of Pokémon Platinum
188 stars 62 forks source link

WIP: Document wild encounter data structure #221

Closed tillgeissler closed 3 months ago

cbt6 commented 3 months ago

I know that this is PR is still a WIP at the moment, but thoughts on having the structs something like this instead?

typedef struct GrassEncounter {
    u8 level;
    u8 padding[3];
    int species;
} GrassEncounter;

typedef struct GrassEncounters {
    int encounterRate;
    GrassEncounter encounters[12];
} GrassEncouters;

typedef struct WaterEncounter {
    u8 maxLevel;
    u8 minLevel;
    u8 padding[2];
    int species;
} WaterEncounter;

typedef struct WaterEncounters {
    int encounterRate;
    WaterEncounter encounters[5];
} WaterEncouters;

typedef struct WildEncounters {
    GrassEncounters grassEncounters;
    // ...
    WaterEncouters surfEncounters;
    WaterEncouters unk_CC;
    WaterEncouters oldRodEncounters;
    WaterEncouters goodRodEncounters;
    WaterEncouters superRodEncounters;
} WildEncounters;
lhearachel commented 3 months ago

Looks like the most recent commit broke your CI build. Feel free to ask us in our Discord channel if you need help.

tillgeissler commented 3 months ago

Looks like the most recent commit broke your CI build. Feel free to ask us in our Discord channel if you need help.

The issue seems to be the changes of the level variables in the Grass/WaterEncounter structs from char to u8. If the later type is used, the SBIN Checksum check fails. I am not to familiar with C unfortunately, any idea why this happens and if it can be resolved?

lhearachel commented 3 months ago

The issue seems to be the changes of the level variables in the Grass/WaterEncounter structs from char to u8.

Hm, that's funky. You could try with s8. Probably a signage issue.

tillgeissler commented 3 months ago

I still have a lot to give feedback on in src/overlay006/ov6_02240C9C.c, but here's some preliminary notes on overall style.

Let's also not add more to this PR in terms of new context and scope. It's big enough for now.

Should I try to split it up into multiple PRs or just clean up this one?

lhearachel commented 3 months ago

Should I try to split it up into multiple PRs or just clean up this one?

Feel free to respond to feedback within this PR; but don't add any more files or functions to its scope.

lhearachel commented 3 months ago

Thanks for your contribution!