Skip to content

Commit

Permalink
Merge pull request #1 from citrusbolt/pr_lib
Browse files Browse the repository at this point in the history
Document most of `gflib` and `libpmagb`
  • Loading branch information
GriffinRichards authored Mar 21, 2024
2 parents fb72b0c + e1f380c commit a9ebfe4
Show file tree
Hide file tree
Showing 27 changed files with 865 additions and 780 deletions.
2 changes: 1 addition & 1 deletion payload/data/all.s
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ gUnknown_0201F3AC::
.space 256

.align 2, 0
gUnknown_0201F4AC::
gTimer1InterruptFunction::
.4byte gIntrTable + 0x18

gUnknown_0201F4B0::
Expand Down
14 changes: 7 additions & 7 deletions payload/include/gflib/bg.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ extern bool8 gBgTilemapBufferTransferScheduled[];

void ResetGpuBuffers(void);
void DoGpuUpdateAndTilemapTransfers(void);
void CopyToBgTilemapBufferRect(int bgNum, int left, int top, int width, int height, const u16 * src);
void CopyFromBgTilemapBufferRect(int bgNum, int left, int top, int width, int height, u16 * dest);
void SetBgTilemapBufferPaletteRect(int bgNum, int left, int top, int width, int height, int paletteNum);
void SetBgTilemapBufferTileAt(int bgNum, int x, int y, u16 tileNum);
void FillBgTilemapBufferRect(int bgNum, int left, int top, int width, int height, u16 tileNum);
void CopyRectWithinBgTilemapBuffer(int bgNum, int srcLeft, int srcTop, int width, int height, int destLeft, int destTop);
void SetBgPos(int bgNum, s32 x, s32 y);
void CopyToBgTilemapBufferRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, const u16 * src);
void UNUSED CopyFromBgTilemapBufferRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, u16 * dest);
void SetBgTilemapBufferPaletteRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, u32 paletteNum);
void SetBgTilemapBufferTileAt(u32 bgNum, u32 x, u32 y, u16 tileNum);
void FillBgTilemapBufferRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, u16 tileNum);
void CopyRectWithinBgTilemapBuffer(u32 bgNum, u32 srcLeft, u32 srcTop, s32 width, u32 height, u32 destLeft, u32 destTop);
void SetBgPos(u32 bgNum, s32 x, s32 y);

#endif //GFLIB_BG_H
4 changes: 2 additions & 2 deletions payload/include/gflib/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
void AgbMain(void);
extern IntrFunc gIntrTable[14u];

void SetIntrFunc(int i, IntrFunc func);
void SetIntrFunc(u32 i, IntrFunc func);
void SetVBlankCallback(IntrFunc cb);
u32 GetFrameTotal(void);
void DelayFrames(u32 a0);
void DelayFrames(u32 frames);

#endif //GFLIB_INIT_H
14 changes: 7 additions & 7 deletions payload/include/gflib/sound.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ bool32 EnableSoundVSync(bool32 enable);
void InitSound(void);
void PauseSoundVSync(void);
void PlaySE(u16 song);
void StopSE(u16 song);
void StopAllSound(void);
bool8 sub_020093AC(void);
void FadeOutSE(u16 song, u16 _speed);
void SetSEVolume(u16 song, u16 volume);
void SetSETempo(u16 song, u16 tempo);
void SetSEPitch(u16 song, s16 pitch);
void UNUSED StopSE(u16 song);
void UNUSED StopAllSound(void);
bool8 UNUSED ReturnTrue(void);
void UNUSED FadeOutSE(u16 song, u16 _speed);
void UNUSED SetSEVolume(u16 song, u16 volume);
void UNUSED SetSETempo(u16 song, u16 tempo);
void UNUSED SetSEPitch(u16 song, s16 pitch);
void SoundVSyncOff(void);
void SoundVSyncOn(void);

Expand Down
14 changes: 7 additions & 7 deletions payload/include/gflib/sprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct Sprite
s16 y;
const struct Subsprites * spriteTemplates;
void (*callback)(struct Sprite *);
u32 unk14[4];
u32 data[4];
};

struct SpriteSheet
Expand Down Expand Up @@ -54,11 +54,11 @@ void ResetSprites(void);
void UpdateSprites(void);
void DoOamBufferTransfer(void);
struct Sprite * AddSprite(s32 x, s32 y, const struct Subsprites * subsprites);
void MoveSpriteToHead(struct Sprite * a0);
void SetSpritePos(struct Sprite * r0, s32 r1, s32 r2);
void AddSpritePos(struct Sprite * r0, s32 r1, s32 r2);
void SetSpritePaletteNum(struct Sprite * r0, s32 r1);
void SetSpriteTileOffset(struct Sprite * r0, s32 r1);
void SetSpriteInvisible(struct Sprite * r0, s32 r1);
void MoveSpriteToHead(struct Sprite * sprite);
void SetSpritePos(struct Sprite * sprite, s32 x, s32 y);
void AddSpritePos(struct Sprite * sprite, s32 x, s32 y);
void SetSpritePaletteNum(struct Sprite * sprite, s32 paletteNum);
void SetSpriteTileOffset(struct Sprite * sprite, s32 tileOffset);
void SetSpriteInvisible(struct Sprite * sprite, s32 invisible);

#endif //GFLIB_SPRITE_H
4 changes: 2 additions & 2 deletions payload/include/gflib/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ void DrawGlyphOnWindow_NoShadow(struct Window *window, u32 glyphId, u32 fgColor)
void DrawGlyphOnWindow_WithShadow(struct Window *window, u32 glyphId, u32 fgColor, u32 shadowColor);
struct Window *AddWindow(u32 windowId, const struct Window *template);
void GenerateFontHalfrowLookupTable(u32 * buffer);
void ClearWindowCharBuffer(struct Window * window, u32 a1);
void ClearWindowCharBuffer(struct Window * window, u32 tile);
void FillWindowCharBufferRect(struct Window * window, s32 x, s32 y, s32 width, s32 height, u32 fillValue);
void SetTextColor(struct Window * window, u8 fg, u8 shadow);
void TextWindowNextLine(struct Window * window);
void TextWindowSetXY(struct Window * window, u32 x, u32 y);
void TextWindowShiftXY(struct Window * window, s32 dx, s32 dy);
void TextWindowPrintSimpleString(struct Window * window, const u8 * glyphs);
void UNUSED TextWindowPrintSimpleString(struct Window * window, const u8 * glyphs);
void TextWindowFillTileBufferForText(struct Window * window);

#ifdef __cplusplus
Expand Down
153 changes: 77 additions & 76 deletions payload/include/libpmagb/agb_rom.h
Original file line number Diff line number Diff line change
@@ -1,85 +1,86 @@
#ifndef PMAGB_AGB_ROM_H
#define PMAGB_AGB_ROM_H

struct RomInfo
struct GFRomHeader
{
/*0x00*/ int gameVersion;
/*0x04*/ int gameLanguage;
/*0x08*/ char gameTitle[32];
/*0x28*/ const struct CompressedSpriteSheet *monFrontPicTable;
/*0x2C*/ const struct CompressedSpriteSheet *monBackPicTable;
/*0x30*/ const struct CompressedSpritePalette *monPaletteTable;
/*0x34*/ const struct CompressedSpritePalette *monShinyPaletteTable;
/*0x38*/ const u8 *const *monIconTable;
/*0x3C*/ const u8 *gMonIconPaletteIndices;
/*0x40*/ const struct SpritePalette *monIconPaletteTable;
/*0x44*/ const u8 (*speciesNames)[][POKEMON_NAME_LENGTH + 1];
/*0x48*/ const u8 (*moveNames)[][MOVE_NAME_LENGTH + 1];
/*0x4C*/ const struct Decoration *decorations;
/*0x50*/ u32 flagsOffs;
/*0x54*/ u32 varsOffs;
/*0x58*/ u32 pokedexOffs;
/*0x5C*/ u32 dexSeen2Offs;
/*0x60*/ u32 dexSeen3Offs;
/*0x64*/ u32 pokedexVar;
/*0x68*/ u32 pokedexFlag;
/*0x6C*/ u32 mysteryEventFlag;
/*0x70*/ u32 pokedexCount;
/*0x74*/ u8 playerNameLength;
/*0x75*/ u8 unk75;
/*0x76*/ u8 pokemonNameLength_1;
/*0x77*/ u8 pokemonNameLength_2;
/*0x78*/ u8 unk78;
/*0x79*/ u8 unk79;
/*0x7A*/ u8 unk7A;
/*0x7B*/ u8 unk7B;
/*0x7C*/ u8 unk7C;
/*0x7D*/ u8 unk7D;
/*0x7E*/ u8 unk7E;
/*0x7F*/ u8 unk7F;
/*0x80*/ u8 unk80;
/*0x81*/ u8 unk81;
/*0x82*/ u8 unk82;
/*0x83*/ u8 unk83;
/*0x84*/ u8 unk84;
/*0x88*/ size_t saveBlock2Size;
/*0x8C*/ size_t saveBlock1Size;
/*0x90*/ u32 playerPartyCountOffs;
/*0x94*/ u32 playerPartyOffs;
/*0x98*/ u32 sb2SpecialSaveWarpOffs;
/*0x9C*/ u32 sb2PlayerIdOffs;
/*0xA0*/ u32 sb2PlayerNameOffs;
/*0xA4*/ u32 sb2PlayerGenderOffs;
/*0xA8*/ u32 unkA8;
/*0xAC*/ u32 unkAC;
/*0xB0*/ u32 externalEventFlagsOffs;
/*0xB4*/ u32 externalEventDataOffs;
/*0xB8*/ u32 unkB8_0:1;
/*0xB8*/ u32 unkB8_1:1;
/*0xBC*/ const struct SpeciesInfo *baseStats;
/*0xC0*/ const u8 (*abilityNames)[][ABILITY_NAME_LENGTH + 1];
/*0xC4*/ const u8 **abilityDescriptions;
/*0xC8*/ const struct Item *items;
/*0xCC*/ const struct BattleMove *battleMoves;
/*0xD0*/ const struct CompressedSpriteSheet *ballSpriteSheets;
/*0xD4*/ const struct CompressedSpritePalette *ballSpritePalettes;
/*0xD8*/ u32 gcnLinkFlagsOffs;
/*0xDC*/ s32 sysGameClearFlagIdx;
/*0xE0*/ u32 sysRibbonGetFlagIdx;
/*0xE4*/ u8 bagCountItems;
/*0xE5*/ u8 bagCountKeyItems;
/*0xE6*/ u8 bagCountPokeballs;
/*0xE7*/ u8 bagCountTMHMs;
/*0xE8*/ u8 bagCountBerries;
/*0xE9*/ u8 pcItemsCount;
/*0xEC*/ u32 pcItemsOffs;
/*0xF0*/ u32 giftRibbonsOffs;
/*0xF4*/ u32 enigmaBerryOffs;
/*0xF8*/ size_t enigmaBerrySize;
/*0xFC*/ const u8 *moveDescriptions;
u32 version;
u32 language;
u8 gameName[32];
const struct CompressedSpriteSheet * monFrontPics;
const struct CompressedSpriteSheet * monBackPics;
const struct CompressedSpritePalette * monNormalPalettes;
const struct CompressedSpritePalette * monShinyPalettes;
const u8 * const * monIcons;
const u8 * monIconPaletteIds;
const struct SpritePalette * monIconPalettes;
const u8 (* monSpeciesNames)[][POKEMON_NAME_LENGTH + 1];
const u8 (* moveNames)[][MOVE_NAME_LENGTH + 1];
const struct Decoration * decorations;
u32 flagsOffset;
u32 varsOffset;
u32 pokedexOffset;
u32 seen1Offset;
u32 seen2Offset;
u32 pokedexVar;
u32 pokedexFlag;
u32 mysteryEventFlag;
u32 pokedexCount;
u8 playerNameLength;
u8 trainerNameLength;
u8 pokemonNameLength1;
u8 pokemonNameLength2;
u8 moveNameLength;
u8 itemNameLength; // No use case has been documented, purpose derived from leaks
u8 berryNameLength; //No use case has been documented, purpose derived from leaks
u8 abilityNameLength; //No use case has been documented, purpose derived from leaks
u8 typeNameLength; // No use case has been documented, purpose derived from leaks
u8 mapNameLength1; // No use case has been documented, purpose derived from leaks
u8 mapNameLength2; // No use case has been documented, purpose derived from leaks
u8 trainerClassNameLength; // No use case has been documented, purpose derived from leaks
u8 decorationNameLength; // No use case has been documented, purpose derived from leaks
u8 dexCategoryNameLength; // No use case has been documented, purpose derived from leaks
u8 endOfStringLength;
u8 frontierTrainerNameLength; // No use case has been documented, purpose derived from leaks
u8 easyChatWordLength; // No use case has been documented, purpose derived from leaks
u32 saveBlock2Size;
u32 saveBlock1Size;
u32 partyCountOffset;
u32 partyOffset;
u32 warpFlagsOffset;
u32 trainerIdOffset;
u32 playerNameOffset;
u32 playerGenderOffset;
u32 frontierStatusOffset;
u32 frontierStatusOffset2;
u32 externalEventFlagsOffset;
u32 externalEventDataOffset;
u32 blockLinkBoxRS:1;
u32 blockLinkColoXD:1;
u32 blockLinkUnused:30;
const struct SpeciesInfo * speciesInfo;
const u8 (* abilityNames)[][ABILITY_NAME_LENGTH + 1];
const u8 **abilityDescriptions;
const struct Item * items;
const struct BattleMove * moves;
const struct CompressedSpriteSheet * ballGfx;
const struct CompressedSpritePalette * ballPalettes;
u32 gcnLinkFlagsOffset;
s32 gameClearFlag;
u32 ribbonFlag;
u8 bagCountItems;
u8 bagCountKeyItems;
u8 bagCountPokeballs;
u8 bagCountTMHMs;
u8 bagCountBerries;
u8 pcItemsCount;
u32 pcItemsOffset;
u32 giftRibbonsOffset;
u32 enigmaBerryOffset;
u32 enigmaBerrySize;
const u8 * moveDescriptions;
};

const struct RomInfo * gAgbPmRomParams;
const struct GFRomHeader * gAgbPmRomParams;

extern void * gSaveBlock1Ptr;
extern void * gSaveBlock1BakPtr;
Expand Down
4 changes: 2 additions & 2 deletions payload/include/libpmagb/berry.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef PMAGB_BERRY_H
#define PMAGB_BERRY_H

u32 GetEnigmaBerryChecksum(struct EnigmaBerry * enigmaBerry);
u32 UNUSED GetEnigmaBerryChecksum(struct EnigmaBerry * enigmaBerry);
bool32 IsEnigmaBerryValid(void);
const struct Berry *GetBerryInfo(u8 berry);
const u8 *ItemId_GetName(u16 itemId);
void CopyItemName(u32 itemId, u8 *string, const u8 * berry_str);
void CopyItemName(u32 itemId, u8 *string, const u8 * berryString);

#endif //PMAGB_BERRY_H
2 changes: 1 addition & 1 deletion payload/include/libpmagb/save.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ bool32 sub_0200A2C8(s32 a);
u8* ReadFirstSaveSector(void);
void SetSaveSectorPtrs(void);
u32 ReadSaveBlockChunks(void);
s32 sub_020098D8(u32 timerNum, IntrFunc * intrFunc);
s32 InitFlash(u32 timerNum, IntrFunc * intrFunc);

#endif //PMAGB_SAVE_H
8 changes: 4 additions & 4 deletions payload/include/rom_info.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef GUARD_ROM_INFO_H
#define GUARD_ROM_INFO_H

extern struct RomInfo gAgbPmRomParams_AXVE_rev0;
extern struct RomInfo gAgbPmRomParams_AXVE_rev2;
extern struct RomInfo gAgbPmRomParams_AXPE_rev0;
extern struct RomInfo gAgbPmRomParams_AXPE_rev2;
extern struct GFRomHeader gAgbPmRomParams_AXVE_rev0;
extern struct GFRomHeader gAgbPmRomParams_AXVE_rev2;
extern struct GFRomHeader gAgbPmRomParams_AXPE_rev0;
extern struct GFRomHeader gAgbPmRomParams_AXPE_rev2;

#endif // GUARD_ROM_INFO_H
Loading

0 comments on commit a9ebfe4

Please sign in to comment.