Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decompile mapanim (not ready) #108

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,740 changes: 102 additions & 11,638 deletions asm/code_mapanim.s

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions include/ap.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ void AP_LoadDefinition(struct APHandle*, const u16*);
void AP_ExecDummyFrame(struct APHandle*);
void AP_Init(struct APHandle*, const u16*, u16);
struct APHandle* AP_Find(const u16* definition);
// ??? APProc_Create(???);
struct APProc* APProc_Create(const void* apDefinition, int xPos, int yPos, int tileBase, int anim, u16 aObjNode);
// ??? APProc_OnUpdate(???);
// ??? APProc_OnEnd(???);
// ??? APProc_SetParameters(???);
// ??? APProc_Delete(???);
// ??? APProc_DeleteAll(???);
void APProc_DeleteAll(void);
// ??? APProc_Exists(???);

#endif // GUARD_AP_H
6 changes: 4 additions & 2 deletions include/bmbattle.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ struct BattleUnit {

/* 6E */ s8 expGain;
/* 6F */ s8 statusOut;
/* 70 */ u8 levelPrevious;
/* 71 */ u8 expPrevious;
/* 70 */ s8 levelPrevious;
/* 71 */ s8 expPrevious;

/* 72 */ u8 hpInitial;

Expand Down Expand Up @@ -213,4 +213,6 @@ void UnitLevelUp(struct Unit* unit);
void BattleHitAdvance(void);
void BattleHitTerminate(void);

#define BUNIT_IS_OBSTACLE(aBu) (((aBu)->terrainId == TERRAIN_WALL_1B) || ((aBu)->terrainId == TERRAIN_SNAG))

#endif // GUARD_BMBATTLE_H
39 changes: 33 additions & 6 deletions include/bmio.h
Original file line number Diff line number Diff line change
@@ -1,34 +1,61 @@
#ifndef GUARD_BMIO_H
#define GUARD_BMIO_H

enum {
enum
{
BM_BGPAL_6 = 6,
BM_BGPAL_TILESET_BASE = 7,

BM_BGPAL_BANIM_IFBACK = 1, /* size: 2 */
BM_BGPAL_BANIM_UNK4 = 4,
BM_BGPAL_BANIM_UNK5 = 5,
};

enum
{
BM_BGCHR_BANIM_IFBACK = 1,
BM_BGCHR_BANIM_UNK160 = 0x160,
BM_BGCHR_BANIM_UNK200 = 0x200,

BM_OBJCHR_BANIM_EFFECT = 384,
BM_OBJCHR_BANIM_EFFECT2 = 448,
};

enum {
enum
{
BM_OBJPAL_1 = 1,
BM_OBJPAL_10 = 10,

BM_OBJPAL_BANIM_EFFECT1 = 3,
BM_OBJPAL_BANIM_EFFECT2 = 4,

BM_OBJPAL_BANIM_SPECIALMU = 8, /* size: 2 */

BM_OBJPAL_UNIT_GRAYED = 15,
};

struct TileGfxAnim {
struct TileGfxAnim
{
/* 00 */ u16 time;
/* 02 */ u16 size;
/* 04 */ const void* data;
};

struct TilePalAnim {
struct TilePalAnim
{
/* 00 */ const void* data;
/* 04 */ u8 time;
/* 05 */ u8 colorCount;
/* 06 */ u8 colorStart;
};

struct GameCtrlProc {
struct GameCtrlProc
{
PROC_HEADER;
};

struct BMapMainProc {
struct BMapMainProc
{
PROC_HEADER;

/* 29 */ u8 pad29[0x54 - 0x29];
Expand Down
5 changes: 4 additions & 1 deletion include/bmtrick.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ enum
TRAP_EXTDATA_TRAP_DAMAGE = 3, // trap damage (needs confirmation)

// Light Rune extdata definitions
TRAP_EXTDATA_RUNE_TURNSLEFT = 2, // turns left beofre wearing out
TRAP_EXTDATA_RUNE_TURNSLEFT = 2, // turns left beofre wearing out

// Gorgon Egg extdata definitions
TRAP_EXTDATA_EGG_LEVEL = 3, // gorgon level
};

struct Trap
Expand Down
19 changes: 9 additions & 10 deletions include/bmunit.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,7 @@ struct UnitDefinition

/* 0C */ u8 items[UNIT_DEFINITION_ITEM_COUNT];

struct {
/* 10 */ u8 ai1;
/* 11 */ u8 ai2;
/* 12 */ u8 ai3;
/* 13 */ u8 ai4;
} ai;
/* 10 */ u8 ai[4];
};

enum
Expand All @@ -206,7 +201,7 @@ enum

US_NONE = 0,

US_HIDDEN = (1 << 0),
US_HIDDEN = (1 << 0), // Bad name? US_BUSY?
US_UNSELECTABLE = (1 << 1),
US_DEAD = (1 << 2),
US_NOT_DEPLOYED = (1 << 3),
Expand Down Expand Up @@ -424,7 +419,7 @@ struct Unit* GetUnit(int id);
const struct ClassData* GetClassData(int classId);
const struct CharacterData* GetCharacterData(int charId);
void UnitRemoveItem(struct Unit* unit, int slot);
s8 CanUnitCrossTerrain(struct Unit* unit, int terrain);
int CanUnitCrossTerrain(struct Unit* unit, int terrain);

#define UNIT_IS_VALID(aUnit) ((aUnit) && (aUnit)->pCharacterData)

Expand All @@ -433,6 +428,10 @@ s8 CanUnitCrossTerrain(struct Unit* unit, int terrain);
#define UNIT_CATTRIBUTES(aUnit) ((aUnit)->pCharacterData->attributes | (aUnit)->pClassData->attributes)

#define UNIT_NAME_ID(aUnit) ((aUnit)->pCharacterData->nameTextId)
#define UNIT_CLASS_NAME_ID(aUnit) ((aUnit->pClassData->nameTextId))

#define UNIT_CLASS_ID(aUnit) ((aUnit)->pClassData->number)
#define UNIT_CHAR_ID(aUnit) ((aUnit)->pCharacterData->number)

#define UNIT_MHP_MAX(aUnit) (UNIT_FACTION(unit) == FACTION_RED ? 120 : 60)
#define UNIT_POW_MAX(aUnit) ((aUnit)->pClassData->maxPow)
Expand All @@ -450,8 +449,8 @@ s8 CanUnitCrossTerrain(struct Unit* unit, int terrain);
#define UNIT_CON(aUnit) (UNIT_CON_BASE(aUnit) + (aUnit)->conBonus)
#define UNIT_MOV(aUnit) ((aUnit)->movBonus + UNIT_MOV_BASE(aUnit))

#define UNIT_IS_GORGON_EGG(aUnit) (((aUnit)->pClassData->number == CLASS_GORGONEGG) || ((aUnit)->pClassData->number == CLASS_GORGONEGG2))
#define UNIT_IS_PHANTOM(aUnit) ((aUnit)->pClassData->number == CLASS_PHANTOM)
#define UNIT_IS_GORGON_EGG(aUnit) ((UNIT_CLASS_ID(aUnit) == CLASS_GORGONEGG) || (UNIT_CLASS_ID(aUnit) == CLASS_GORGONEGG2))
#define UNIT_IS_PHANTOM(aUnit) (UNIT_CLASS_ID(aUnit) == CLASS_PHANTOM)

#define UNIT_ARENA_LEVEL(aUnit) (((aUnit)->state >> 17) & 0x7)

Expand Down
1 change: 1 addition & 0 deletions include/constants/characters.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ enum {
CHARACTER_LYON_FINAL = 0x6C,
CHARACTER_ORSON = 0x6D,

CHARACTER_MONSTER_BA = 0xBA, // TODO: what is it?
CHARACTER_FOMORTIIS = 0xBE,

CHARACTER_WALL = 0xFE,
Expand Down
16 changes: 8 additions & 8 deletions include/constants/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ enum {
CLASS_GENERAL = 0x0B,
CLASS_GENERAL_F = 0x0C,
CLASS_THIEF = 0x0D,
CLASS_MANAKETE = 0x0E, // TODO: which one?
CLASS_MYRRH_TRANSFORMED = 0x0E, // display only?
CLASS_MERCENARY = 0x0F,
CLASS_MERCENARY_F = 0x10,
CLASS_HERO = 0x11,
Expand Down Expand Up @@ -63,7 +63,7 @@ enum {
CLASS_PUPIL_T2 = 0x39,
CLASS_RECRUIT_T2 = 0x3A,
CLASS_MANAKETE_2 = 0x3B, // TODO: which one?
CLASS_MANAKETE_MYRRH = 0x3C,
CLASS_MYRRH = 0x3C,
CLASS_JOURNEYMAN = 0x3D,
CLASS_PUPIL = 0x3E,
CLASS_FIGHTER = 0x3F,
Expand Down Expand Up @@ -106,12 +106,12 @@ enum {
CLASS_DEATHGOYLE = 0x64,
CLASS_DRACO_ZOMBIE = 0x65,
CLASS_DEMON_KING = 0x66,
CLASS_BLST_REGULAR_USED = 0x67,
CLASS_BLST_LONG_USED = 0x68,
CLASS_BLST_KILLER_USED = 0x69,
CLASS_BLST_REGULAR_EMPTY = 0x6A,
CLASS_BLST_LONG_EMPTY = 0x6B,
CLASS_BLST_KILLER_EMPTY = 0x6C,
CLASS_BLST_REGULAR_USED = 0x67, // display only?
CLASS_BLST_LONG_USED = 0x68, // display only?
CLASS_BLST_KILLER_USED = 0x69, // display only?
CLASS_BLST_REGULAR_EMPTY = 0x6A, // display only?
CLASS_BLST_LONG_EMPTY = 0x6B, // display only?
CLASS_BLST_KILLER_EMPTY = 0x6C, // display only?
CLASS_CIVILIAN_M1 = 0x6D,
CLASS_CIVILIAN_F1 = 0x6E,
CLASS_CIVILIAN_M2 = 0x6F,
Expand Down
4 changes: 2 additions & 2 deletions include/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ typedef u8(*EventFuncType)(struct EventEngineProc*);
void CallEvent(const u16* events, u8 execType);
struct EventEngineProc* EventEngine_Create(const u16* events, u8 idk);
// ??? EventEngine_CreateBattle(???);
int EventEngineExists(void);
// ??? BattleEventEngineExists(???);
s8 EventEngineExists(void);
s8 BattleEventEngineExists(void);
// ??? DeleteEventEngines(???);
// ??? sub_800D1E4(???);
// ??? SetEventSlotC(???);
Expand Down
46 changes: 46 additions & 0 deletions include/face.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef GUARD_FACE_H
#define GUARD_FACE_H

// For now, this is an orphan header
// as face.s hasn't been decompiled yet
// but other things require things defined here

// I'm not putting it in types.h/varibales.h because
// it would force a dependency on proc.h.
// -Stan

#include "proc.h"

struct PortraitData
{
/* 00 */ const void* pPortraitGraphics;
/* 04 */ const void* pMiniPortraitGraphics;
/* 08 */ const u16* pPortraitPalette;
/* 0C */ const void* unk0C;
/* 10 */ const void* unk10;
/* 14 */ const void* unk14;
/* 18 */ u8 blinkBehaviorKind;
/* More */
};

struct FaceProc
{
/* 00 */ PROC_HEADER;

/* 2C */ const struct PortraitData* portrait;
/* 30 */ u32 state;
/* 34 */ short xDisplay;
/* 36 */ short yDisplay;
/* 38 */ const u16* sprite;
/* 3C */ u16 tileref;
/* 3E */ u16 portraitId;
/* 40 */ u8 faceId;
/* 41 */ u8 spriteDepth;

/* 44 */ struct Proc* unk44;
/* 48 */ struct Proc* blinkCnt;
};

extern struct FaceProc* gUnknown_03004980[4];

#endif // GUARD_FACE_H
2 changes: 1 addition & 1 deletion include/fontgrp.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void Font_LoadForUI(void);
// ??? Font_SetSomeSpecialDrawingRoutine(???);
void DrawTextInline(struct TextHandle* text, u16* dest, int colorId, int x, int tileWidth, const char* string);
void Text_InsertString(struct TextHandle *th, int x, int colorId, const char *str);
// ??? Text_InsertNumberOr2Dashes(???);
void Text_InsertNumberOr2Dashes(struct TextHandle *th, int x, int colorId, int n);
void Text_AppendStringASCII(struct TextHandle *text, const char *str);
const char *Text_AppendCharASCII(struct TextHandle *text, const char *str);
char *GetCharTextWidthASCII(char *str, u32 *width);
Expand Down
14 changes: 7 additions & 7 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void sub_800BCDC(int); // battle related
// ??? Event44_(???);
// ??? Event45_(???);
// ??? sub_8010DC0(???);
// ??? sub_8010E50(???);
void sub_8010E50(void);
// ??? sub_8010E6C(???);
// ??? sub_8010EE8(???);
// ??? GetSomeLongPopupLength(???);
Expand Down Expand Up @@ -616,9 +616,9 @@ void CopyTileGfxForObj(const void* src, void* dst, int tileWidth, int tileHeight
// ??? sub_80138EC(???);
// ??? sub_80138F0(???);
// ??? sub_801390C(???);
void sub_8013928(const u16*, int, int, struct Proc* proc);
u16* sub_8013928(const u16*, int, int, struct Proc* proc);
// ??? sub_8013988(???);
// ??? sub_8013998(???);
void sub_8013998(u16* arg0, int arg1);
// ??? sub_801399C(???);
// ??? sub_8013A84(???);
// ??? sub_8013AA4(???);
Expand Down Expand Up @@ -787,7 +787,7 @@ void sub_8015BD4(int a, int b, int c);
// ??? Loop6C_GENS(???);
// ??? StoreAdjustedCameraPositions(???);
// ??? sub_8015D84(???);
// ??? EnsureCameraOntoPosition(???);
s8 EnsureCameraOntoPosition(struct Proc* parent, int x, int y);
// ??? ShouldMoveCameraPosSomething(???);
// ??? sub_8015EDC(???);
// ??? sub_8015F40(???);
Expand Down Expand Up @@ -4003,7 +4003,7 @@ void BeginAnimsOnBattleAnimations(void);
// ??? sub_8078258(???);
// ??? GetSpellAssocAlt6CPointer(???);
// ??? GetSpellAssocReturnBool(???);
int GetSpellAssocFacing(u16 item);
u8 GetSpellAssocFacing(u16 item);
// ??? GetSpellAssocFlashColor(???);
// ??? sub_80782A8(???);
int GenerateMonsterLevel(u8 baseLevel);
Expand Down Expand Up @@ -4065,7 +4065,7 @@ void GetPreferredPositionForUNIT(const struct UnitDefinition* uDef, u8* xOut, u8
// ??? sub_807B294(???);
// ??? sub_807B2B4(???);
// ??? MakeBattleMOVEUNIT(???);
void SetBattleAnimFacing(int actorId1, int actorId2, u8 facing);
void SetBattleAnimFacing(int actorId1, int actorId2, int facing);
// ??? SetupBattleMOVEUNITs(???);
// ??? sub_807B4D0(???);
// ??? sub_807B5DC(???);
Expand Down Expand Up @@ -7217,6 +7217,6 @@ void SoundBiasSet();
void ClearOAMBuffer();
void TileMap_FillRect(u16 *dest, int width, int height, int fillValue);
void TileMap_CopyRect(u16* src, u16* dst, int width, int height);
void CallARM_FillTileRect(u16* tilemap, const void* tsa, int tileref);
void CallARM_FillTileRect(u16* tilemap, const void* tsa, u16 tileref);

#endif // GUARD_FUNCTIONS_H
2 changes: 1 addition & 1 deletion include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include "gba/gba.h"

#define CONST_DATA const __attribute__((section(".data")))
#define CONST_DATA __attribute__((section(".data")))

#include "types.h"
#include "variables.h"
Expand Down
30 changes: 28 additions & 2 deletions include/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,32 @@ enum
#define ApplyPalettes(aSrc, aPalId, aPalCount) CopyToPaletteBuffer((aSrc), 0x20 * (aPalId), 0x20 * (aPalCount))
#define ApplyPalette(aSrc, aPalId) ApplyPalettes((aSrc), (aPalId), 1)

#define SetWinEnable(aWin0, aWin1, aWObj) \
gLCDControlBuffer.dispcnt.win0_on = (aWin0); \
gLCDControlBuffer.dispcnt.win1_on = (aWin1); \
gLCDControlBuffer.dispcnt.objWin_on = (aWObj)

#define SetWin0Layers(aBg0, aBg1, aBg2, aBg3, aObj) \
gLCDControlBuffer.wincnt.win0_enableBg0 = (aBg0); \
gLCDControlBuffer.wincnt.win0_enableBg1 = (aBg1); \
gLCDControlBuffer.wincnt.win0_enableBg2 = (aBg2); \
gLCDControlBuffer.wincnt.win0_enableBg3 = (aBg3); \
gLCDControlBuffer.wincnt.win0_enableObj = (aObj)

#define SetWin1Layers(aBg0, aBg1, aBg2, aBg3, aObj) \
gLCDControlBuffer.wincnt.win1_enableBg0 = (aBg0); \
gLCDControlBuffer.wincnt.win1_enableBg1 = (aBg1); \
gLCDControlBuffer.wincnt.win1_enableBg2 = (aBg2); \
gLCDControlBuffer.wincnt.win1_enableBg3 = (aBg3); \
gLCDControlBuffer.wincnt.win1_enableObj = (aObj)

#define SetWOutLayers(aBg0, aBg1, aBg2, aBg3, aObj) \
gLCDControlBuffer.wincnt.wout_enableBg0 = (aBg0); \
gLCDControlBuffer.wincnt.wout_enableBg1 = (aBg1); \
gLCDControlBuffer.wincnt.wout_enableBg2 = (aBg2); \
gLCDControlBuffer.wincnt.wout_enableBg3 = (aBg3); \
gLCDControlBuffer.wincnt.wout_enableObj = (aObj)

// Functions

void CopyToPaletteBuffer(const void* src, int b, int size);
Expand Down Expand Up @@ -60,7 +86,7 @@ void BG_SetPosition(u16 a, u16 b, u16 c);
// ??? sub_800151C(???);
// ??? sub_8001530(???);
// ??? sub_800154C(???);
// ??? sub_800159C(???);
void sub_800159C(u16 *a, u16 *b, s16 c, s16 d, u16 e);
// ??? sub_80016C4(???);
// ??? sub_8001710(???);
// ??? sub_800172C(???);
Expand All @@ -79,7 +105,7 @@ void SoftResetIfKeyComboPressed();
// ??? sub_8001CB0(???);
// ??? ExecBothHBlankHandlers(???);
// ??? UpdateHBlankHandlerState(???);
// ??? SetPrimaryHBlankHandler(???);
void SetPrimaryHBlankHandler(void(*)(void));
void SetSecondaryHBlankHandler(void(*)(void));
// ??? GetBackgroundFromBufferPointer(???);
// ??? BG_SetPriority(???);
Expand Down
Loading