From 9442bdcbf3abf3e44d2829ec72bfe23649c7d8ac Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Tue, 24 Jan 2017 22:31:44 -0600 Subject: decompile more of naming_screen (#216) * decompile more code * incbin graphics data * decompile more code --- include/sprite.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include/sprite.h') diff --git a/include/sprite.h b/include/sprite.h index 13d94e9f3..447a8decb 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -135,7 +135,7 @@ struct Sprite /*0x0C*/ struct SpriteFrameImage *images; /*0x10*/ union AffineAnimCmd **affineAnims; /*0x14*/ const struct SpriteTemplate *template; - /*0x18*/ struct SubspriteTable *subspriteTables; + /*0x18*/ const struct SubspriteTable *subspriteTables; /*0x1C*/ void (*callback)(struct Sprite *); /*0x20*/ struct Coords16 pos1; @@ -227,14 +227,14 @@ u16 LoadSpriteSheet(struct SpriteSheet *sheet); void LoadSpriteSheets(struct SpriteSheet *sheets); u16 AllocTilesForSpriteSheet(struct SpriteSheet *sheet); void AllocTilesForSpriteSheets(struct SpriteSheet *sheets); -void LoadTilesForSpriteSheet(struct SpriteSheet *sheet); +void LoadTilesForSpriteSheet(const struct SpriteSheet *sheet); void LoadTilesForSpriteSheets(struct SpriteSheet *sheets); void FreeSpriteTilesByTag(u16 tag); void FreeSpriteTileRanges(void); u16 GetSpriteTileStartByTag(u16 tag); u16 GetSpriteTileTagByTileStart(u16 start); -void RequestSpriteSheetCopy(struct SpriteSheet *sheet); -u16 LoadSpriteSheetDeferred(struct SpriteSheet *sheet); +void RequestSpriteSheetCopy(const struct SpriteSheet *sheet); +u16 LoadSpriteSheetDeferred(const struct SpriteSheet *sheet); void FreeAllSpritePalettes(void); u8 LoadSpritePalette(const struct SpritePalette *palette); void LoadSpritePalettes(const struct SpritePalette *palettes); @@ -242,7 +242,7 @@ u8 AllocSpritePalette(u16 tag); u8 IndexOfSpritePaletteTag(u16 tag); u16 GetSpritePaletteTagByPaletteNum(u8 paletteNum); void FreeSpritePaletteByTag(u16 tag); -void SetSubspriteTables(struct Sprite *sprite, struct SubspriteTable *subspriteTables); +void SetSubspriteTables(struct Sprite *sprite, const struct SubspriteTable *subspriteTables); bool8 AddSpriteToOamBuffer(struct Sprite *object, u8 *oamIndex); bool8 AddSubspritesToOamBuffer(struct Sprite *sprite, struct OamData *destOam, u8 *oamIndex); void CopyToSprites(u8 *src); -- cgit v1.2.3 From 448acff16e53485c5cfb90983a7a1e1b4644c30b Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Thu, 26 Jan 2017 01:07:36 -0500 Subject: finish decompiling naming_screen (#217) * decompile more code * incbin graphics data * decompile more code * decompile more code * finish decompiling * name some functions and variables --- include/sprite.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/sprite.h') diff --git a/include/sprite.h b/include/sprite.h index 447a8decb..721616e9e 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -223,8 +223,8 @@ u8 AllocOamMatrix(void); void FreeOamMatrix(u8 matrixNum); void InitSpriteAffineAnim(struct Sprite *sprite); void SetOamMatrixRotationScaling(u8 matrixNum, s16 xScale, s16 yScale, u16 rotation); -u16 LoadSpriteSheet(struct SpriteSheet *sheet); -void LoadSpriteSheets(struct SpriteSheet *sheets); +u16 LoadSpriteSheet(const struct SpriteSheet *sheet); +void LoadSpriteSheets(const struct SpriteSheet *sheets); u16 AllocTilesForSpriteSheet(struct SpriteSheet *sheet); void AllocTilesForSpriteSheets(struct SpriteSheet *sheets); void LoadTilesForSpriteSheet(const struct SpriteSheet *sheet); -- cgit v1.2.3 From b9ff56bd89ac11a9b40b34f834dcf7a5be4d90a6 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Fri, 27 Jan 2017 13:06:20 -0500 Subject: define more data in C (#219) * define some graphics data in C * define wild pokemon in C * use less #ifdefs * define data in berry.c --- include/sprite.h | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'include/sprite.h') diff --git a/include/sprite.h b/include/sprite.h index 721616e9e..7a2dd8494 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -5,7 +5,7 @@ struct SpriteSheet { - u8 *data; + const u8 *data; u16 size; u16 tag; }; @@ -18,7 +18,7 @@ struct SpriteFrameImage struct SpritePalette { - u16 *data; + const u16 *data; u16 tag; }; @@ -53,6 +53,13 @@ union AnimCmd struct AnimJumpCmd jump; }; +#define ANIMCMD_FRAME(_imageValue, _duration) \ + {.frame = {.imageValue = _imageValue, .duration = _duration}} +#define ANIMCMD_JUMP(_target) \ + {.jump = {.type = -2, .target = _target}} +#define ANIMCMD_END \ + {.type = -1} + struct AffineAnimFrameCmd { s16 xScale; @@ -61,6 +68,11 @@ struct AffineAnimFrameCmd u8 duration; }; +#define AFFINEANIMCMD_FRAME(_xScale, _yScale, _rotation, _duration) \ + {.frame = {.xScale = _xScale, .yScale = _yScale, .rotation = _rotation, .duration = _duration}} +#define AFFINEANIMCMD_END \ + {.type = 0x7FFF} + struct AffineAnimLoopCmd { s16 type; @@ -121,19 +133,19 @@ struct SpriteTemplate { u16 tileTag; u16 paletteTag; - struct OamData *oam; - union AnimCmd **anims; + const struct OamData *oam; + const union AnimCmd *const *anims; struct SpriteFrameImage *images; - union AffineAnimCmd **affineAnims; + const union AffineAnimCmd *const *affineAnims; void (*callback)(struct Sprite *); }; struct Sprite { /*0x00*/ struct OamData oam; - /*0x08*/ union AnimCmd **anims; + /*0x08*/ const union AnimCmd *const *anims; /*0x0C*/ struct SpriteFrameImage *images; - /*0x10*/ union AffineAnimCmd **affineAnims; + /*0x10*/ const union AffineAnimCmd *const *affineAnims; /*0x14*/ const struct SpriteTemplate *template; /*0x18*/ const struct SubspriteTable *subspriteTables; /*0x1C*/ void (*callback)(struct Sprite *); @@ -204,7 +216,7 @@ void SetOamMatrix(u8 matrixNum, u16 a, u16 b, u16 c, u16 d); void CalcCenterToCornerVec(struct Sprite *sprite, u8 shape, u8 size, u8 affineMode); void SpriteCallbackDummy(struct Sprite *sprite); void ProcessSpriteCopyRequests(void); -void RequestSpriteCopy(u8 *src, u8 *dest, u16 size); +void RequestSpriteCopy(const u8 *src, u8 *dest, u16 size); void FreeSpriteTiles(struct Sprite *sprite); void FreeSpritePalette(struct Sprite *sprite); void FreeSpriteOamMatrix(struct Sprite *sprite); @@ -249,4 +261,6 @@ void CopyToSprites(u8 *src); void CopyFromSprites(u8 *dest); u8 SpriteTileAllocBitmapOp(u16 bit, u8 op); +extern const union AffineAnimCmd *const gDummySpriteAffineAnimTable[]; + #endif // GUARD_SPRITE_H -- cgit v1.2.3 From b9f1143d3e9b32120cc62fcc7a822d3bca8ef976 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Sat, 28 Jan 2017 01:31:09 -0500 Subject: define more data in C (#220) * define more data in C * correct typo in comments --- include/sprite.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'include/sprite.h') diff --git a/include/sprite.h b/include/sprite.h index 7a2dd8494..2725d0bab 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -45,6 +45,9 @@ struct AnimJumpCmd u32 target:6; }; +// The first halfword of this union specifies the type of command. +// If it -2, then it is a jump command. If it is -1, then it is the end of the script. +// Otherwise, it is the imageValue for a frame command. union AnimCmd { s16 type; @@ -53,8 +56,8 @@ union AnimCmd struct AnimJumpCmd jump; }; -#define ANIMCMD_FRAME(_imageValue, _duration) \ - {.frame = {.imageValue = _imageValue, .duration = _duration}} +#define ANIMCMD_FRAME(...) \ + {.frame = {__VA_ARGS__}} #define ANIMCMD_JUMP(_target) \ {.jump = {.type = -2, .target = _target}} #define ANIMCMD_END \ @@ -68,11 +71,6 @@ struct AffineAnimFrameCmd u8 duration; }; -#define AFFINEANIMCMD_FRAME(_xScale, _yScale, _rotation, _duration) \ - {.frame = {.xScale = _xScale, .yScale = _yScale, .rotation = _rotation, .duration = _duration}} -#define AFFINEANIMCMD_END \ - {.type = 0x7FFF} - struct AffineAnimLoopCmd { s16 type; @@ -93,6 +91,11 @@ union AffineAnimCmd struct AffineAnimJumpCmd jump; }; +#define AFFINEANIMCMD_FRAME(_xScale, _yScale, _rotation, _duration) \ + {.frame = {.xScale = _xScale, .yScale = _yScale, .rotation = _rotation, .duration = _duration}} +#define AFFINEANIMCMD_END \ + {.type = 0x7FFF} + struct AffineAnimState { u8 animNum; -- cgit v1.2.3 From 2c66ef8ef361de78f1b6529f177e299207d2006e Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Fri, 3 Feb 2017 01:04:43 -0600 Subject: decompile more code --- include/sprite.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/sprite.h') diff --git a/include/sprite.h b/include/sprite.h index 447a8decb..54b0fd76b 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -194,7 +194,7 @@ void ResetSpriteData(void); void AnimateSprites(void); void BuildOamBuffer(void); u8 CreateSprite(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); -u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, u16 x, u16 y, u8 subpriority); +u8 CreateSpriteAtEnd(const struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); u8 CreateInvisibleSprite(void (*callback)(struct Sprite *)); u8 CreateSpriteAndAnimate(struct SpriteTemplate *template, s16 x, s16 y, u8 subpriority); void DestroySprite(struct Sprite *sprite); -- cgit v1.2.3 From 2afc20150b1cf5e9bcc8008c0323ac57af353718 Mon Sep 17 00:00:00 2001 From: Cameron Hall Date: Sat, 4 Feb 2017 21:47:11 -0600 Subject: decompile more of field_map_obj (#231) * decompile more code * decompile more of field_map_obj * decompile more of field_map_obj --- include/sprite.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/sprite.h') diff --git a/include/sprite.h b/include/sprite.h index 4e3074ebb..42620c9e9 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -147,7 +147,7 @@ struct Sprite { /*0x00*/ struct OamData oam; /*0x08*/ const union AnimCmd *const *anims; - /*0x0C*/ struct SpriteFrameImage *images; + /*0x0C*/ const struct SpriteFrameImage *images; /*0x10*/ const union AffineAnimCmd *const *affineAnims; /*0x14*/ const struct SpriteTemplate *template; /*0x18*/ const struct SubspriteTable *subspriteTables; @@ -200,6 +200,10 @@ struct Sprite /*0x43*/ u8 subpriority; }; +extern const struct OamData gDummyOamData; +extern const union AnimCmd *const gDummySpriteAnimTable[]; +extern const union AffineAnimCmd *const gDummySpriteAffineAnimTable[]; + extern s16 gSpriteCoordOffsetX; extern s16 gSpriteCoordOffsetY; -- cgit v1.2.3