diff --git a/include/global.h b/include/global.h index ec636bb074..46413b1979 100644 --- a/include/global.h +++ b/include/global.h @@ -11,10 +11,10 @@ // to help in decompiling #define asm_comment(x) asm volatile("@ -- " x " -- ") #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") -#define ASM_DIRECT __attribute__((naked)) +#define NAKED __attribute__((naked)) // IDE support -#if defined (__APPLE__) || defined (__CYGWIN__) +#if defined (__APPLE__) || defined (__CYGWIN__) || defined (_MSC_VER) #define _(x) x #define __(x) x #define INCBIN_U8 {0} @@ -23,7 +23,7 @@ #define INCBIN_S8 {0} #define INCBIN_S16 {0} #define INCBIN_S32 {0} -#endif // __APPLE__ +#endif // IDE support #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c index e956fd44f6..2316b97590 100644 --- a/src/battle_anim_sound_tasks.c +++ b/src/battle_anim_sound_tasks.c @@ -386,7 +386,7 @@ void sub_8159308(u8 taskId) DestroyAnimVisualTask(taskId); } #else -ASM_DIRECT +NAKED void sub_8159308(u8 taskId) { asm_unified(" push {r4,r5,lr}\n\ diff --git a/src/battle_interface.c b/src/battle_interface.c index 0a8bf3ed7e..9ef45020df 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -648,7 +648,7 @@ static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2) } #else -ASM_DIRECT +NAKED static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2) { asm(".syntax unified\n\ diff --git a/src/battle_main.c b/src/battle_main.c index 495aa3302f..8649209c0f 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -3591,7 +3591,7 @@ static void BattleIntroOpponent1SendsOutMonAnimation(void) gBattleMainFunc = BattleIntroRecordMonsToDex; } #else -ASM_DIRECT +NAKED static void BattleIntroOpponent1SendsOutMonAnimation(void) { asm(".syntax unified\n\ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c382daaf4d..811aba1285 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3608,7 +3608,7 @@ static void atk24(void) } } #else -ASM_DIRECT +NAKED static void atk24(void) { asm("\n\ diff --git a/src/battle_tv.c b/src/battle_tv.c index 777b4846ff..e5d97be304 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -812,7 +812,7 @@ void TryPutLinkBattleTvShowOnAir(void) } #else -ASM_DIRECT +NAKED void TryPutLinkBattleTvShowOnAir(void) { asm_unified( diff --git a/src/bg.c b/src/bg.c index 975c72a942..2f4cdc8564 100644 --- a/src/bg.c +++ b/src/bg.c @@ -463,7 +463,7 @@ bool8 IsDma3ManagerBusyWithBgCopy(void) return FALSE; } #else -ASM_DIRECT +NAKED bool8 IsDma3ManagerBusyWithBgCopy(void) { asm("push {r4-r7,lr}\n\ @@ -1048,7 +1048,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 } } }*/ -ASM_DIRECT +NAKED void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2) { asm("push {r4-r7,lr}\n\ @@ -1495,7 +1495,7 @@ void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 pal *dest = test; } #else -ASM_DIRECT +NAKED void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2) { asm("push {r4-r6,lr}\n\ diff --git a/src/decompress.c b/src/decompress.c index fb288bf4a4..1d4165d753 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -117,7 +117,7 @@ void Unused_LZDecompressWramIndirect(const void **src, void *dest) } // This one (unused) function is really challenging, won't even try to decompile it. -ASM_DIRECT +NAKED void sub_803471C() { asm(".syntax unified\n\ diff --git a/src/field_effect.c b/src/field_effect.c index 6783473ebb..692090779b 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -566,7 +566,7 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y) return spriteId; } #else -ASM_DIRECT +NAKED u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y) { asm_unified("push {r4,r5,lr}\n\ @@ -669,7 +669,7 @@ void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) gPlttBufferFaded[i] = RGB(curRed, curGreen, curBlue); } #else -ASM_DIRECT +NAKED void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) { asm(".syntax unified\n" @@ -744,7 +744,7 @@ void MultiplyInvertedPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) ".syntax divided"); } -ASM_DIRECT +NAKED void MultiplyPaletteRGBComponents(u16 i, u8 r, u8 g, u8 b) { asm(".syntax unified\n" @@ -2684,7 +2684,7 @@ bool8 sub_80B8B38(struct Task *task) return FALSE; } #else -ASM_DIRECT +NAKED bool8 sub_80B8B38(struct Task *task) { asm_unified("\tpush {r4-r7,lr}\n" @@ -2997,7 +2997,7 @@ u8 sub_80B8F98(void) return spriteId; } #else -ASM_DIRECT +NAKED u8 sub_80B8F98(void) { asm_unified("push {r4-r7,lr}\n\ diff --git a/src/field_map_obj.c b/src/field_map_obj.c index 81cbe5210f..af018eb164 100644 --- a/src/field_map_obj.c +++ b/src/field_map_obj.c @@ -353,7 +353,7 @@ static u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u return slot; } #else -static __attribute__((naked)) u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) +static NAKED u8 InitFieldObjectStateFromTemplate(struct MapObjectTemplate *template, u8 mapId, u8 mapGroupId) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" diff --git a/src/fossil_specials.c b/src/fossil_specials.c index 95fafc17bf..060915fa64 100644 --- a/src/fossil_specials.c +++ b/src/fossil_specials.c @@ -335,7 +335,7 @@ static void sub_81BED50(u8 taskId) } #else -ASM_DIRECT +NAKED static void sub_81BED50(u8 taskId) { asm("\n\ diff --git a/src/item.c b/src/item.c index 975fef3aea..319d167fc7 100644 --- a/src/item.c +++ b/src/item.c @@ -234,7 +234,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) } } #else -ASM_DIRECT +NAKED bool8 CheckBagHasSpace(u16 itemId, u16 count) { asm_unified("push {r4-r7,lr}\n\ diff --git a/src/link_rfu.c b/src/link_rfu.c index a1917ed244..37aa20950b 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -2051,7 +2051,7 @@ u8 sub_800DD1C(u8 maxFlags) return 0; } #else -ASM_DIRECT u8 sub_800DD1C(u8 maxFlags) +NAKED u8 sub_800DD1C(u8 maxFlags) { asm_unified("\tpush {r4-r7,lr}\n" "\tlsls r0, 24\n" @@ -2897,7 +2897,7 @@ void sub_800EFB0(void) CpuFill16(0, gRecvCmds, sizeof gRecvCmds); } #else -ASM_DIRECT void sub_800EFB0(void) +NAKED void sub_800EFB0(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tsub sp, 0x4\n" @@ -3233,7 +3233,7 @@ void sub_800F638(u8 unused, u32 flags) } } #else -ASM_DIRECT void sub_800F638(u8 unused, u32 flags) +NAKED void sub_800F638(u8 unused, u32 flags) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" @@ -3601,7 +3601,7 @@ void sub_800FD14(u16 command) } } #else -ASM_DIRECT void sub_800FD14(u16 command) +NAKED void sub_800FD14(u16 command) { asm_unified("\tpush {r4,r5,lr}\n" "\tlsls r0, 16\n" @@ -4699,7 +4699,7 @@ void sub_801120C(u8 a0) } } #else -ASM_DIRECT void sub_801120C(u8 a0) +NAKED void sub_801120C(u8 a0) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 59b1622ebf..1782e9af82 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -276,7 +276,7 @@ static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) } } #else -ASM_DIRECT +NAKED static void sub_80D4A78(u8 bg, u8 x, u8 y, u8 deltaX, u8 deltaY, u8 unused) { asm("\n\ diff --git a/src/match_call.c b/src/match_call.c index 9c1e02947d..aa6945161a 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -980,7 +980,7 @@ static void sub_81D199C(const match_call_text_data_t *sub0, u16 idx, u8 *dest) } } #else -static ASM_DIRECT void sub_81D199C(const match_call_text_data_t *sub0, u16 idx, u8 *dest) +static NAKED void sub_81D199C(const match_call_text_data_t *sub0, u16 idx, u8 *dest) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" @@ -1163,7 +1163,7 @@ const u8 *sub_81D1B40(u32 idx, u32 offset) return NULL; } #else -ASM_DIRECT const u8 *sub_81D1B40(u32 idx, u32 offset) +NAKED const u8 *sub_81D1B40(u32 idx, u32 offset) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" diff --git a/src/menu.c b/src/menu.c index 0aaf2d186c..dedfcc3be0 100644 --- a/src/menu.c +++ b/src/menu.c @@ -2080,7 +2080,7 @@ void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 } } #else -__attribute__((naked)) +NAKED void sub_819A080(struct UnkStruct_819A080 *a0, struct UnkStruct_819A080 *a1, u16 a2, u16 a3, u16 a4, u16 a5, u16 a6, u16 a7) { asm("push {r4-r7,lr}\n\ diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c index 02755fe400..c50aa4a757 100644 --- a/src/pokemon_animation.c +++ b/src/pokemon_animation.c @@ -1184,7 +1184,7 @@ static void sub_817F9F4(struct Sprite *sprite) } #else -__attribute__((naked)) +NAKED static void sub_817F9F4(struct Sprite *sprite) { asm(".syntax unified\n\ diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 4ce4cca5b9..74dc119738 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1417,7 +1417,7 @@ void sub_81C14BC(struct Pokemon *mon, u8 swappingFromId, u8 swappingToId) *ppBonusesPtr = localPpBonuses; } #else -ASM_DIRECT +NAKED void sub_81C14BC(struct Pokemon *mon, u8 swappingFromId, u8 swappingToId) { asm(".syntax unified\n\ @@ -1628,7 +1628,7 @@ void sub_81C15EC(struct BoxPokemon *mon, u8 swappingFromId, u8 swappingToId) *ppBonusesPtr = localPpBonuses; } #else -ASM_DIRECT +NAKED void sub_81C15EC(struct BoxPokemon *mon, u8 swappingFromId, u8 swappingToId) { asm(".syntax unified\n\ @@ -2039,7 +2039,7 @@ void sub_81C1CB0(struct UnkStruct_61CC04 *a, u16 *b, u8 c, u8 d) Free(alloced); } #else -ASM_DIRECT +NAKED void sub_81C1CB0(struct UnkStruct_61CC04 *a, u16 *b, u8 c, u8 d) { asm(".syntax unified\n\ @@ -2341,7 +2341,7 @@ void sub_81C2194(u16 *a, u16 b, u8 c) } } #else -ASM_DIRECT +NAKED void sub_81C2194(u16 *a, u16 b, u8 c) { asm(".syntax unified\n\ @@ -3026,7 +3026,7 @@ void sub_81C335C() sub_81C25A4(r4, gText_FiveMarks, r5, 1, 0, 1); } #else -ASM_DIRECT +NAKED void sub_81C335C() { asm(".syntax unified\n\ @@ -3369,7 +3369,7 @@ void sub_81C3B08(u8 a) sub_81C25A4(sp, text, offset, (a<<4), 0, r5); } #else -ASM_DIRECT +NAKED void sub_81C3B08(u8 a) { asm(".syntax unified\n\ diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 4cb2eab497..eb48ab15a3 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -475,7 +475,7 @@ u32 MoveRecordedBattleToSaveData(void) } #else -ASM_DIRECT +NAKED u32 MoveRecordedBattleToSaveData(void) { asm(".syntax unified\n\ diff --git a/src/rotating_gate.c b/src/rotating_gate.c index db5935fc30..a16401fa23 100644 --- a/src/rotating_gate.c +++ b/src/rotating_gate.c @@ -925,7 +925,7 @@ static s32 RotatingGate_CanRotate(u8 gateId, s16 rotationDirection) } #else -ASM_DIRECT +NAKED static s32 RotatingGate_CanRotate(u8 a, s16 rotationDirection) { asm(".syntax unified\n\ diff --git a/src/text.c b/src/text.c index eacfd2a1f9..f7c68f549e 100644 --- a/src/text.c +++ b/src/text.c @@ -375,7 +375,7 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) *(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor; } #else -ASM_DIRECT +NAKED void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { asm("push {r4-r7,lr}\n\ @@ -871,7 +871,7 @@ void DecompressGlyphTile(const u16 *src, u16 *dest) *(dest) = (gFontHalfRowLookupTable[gFontHalfRowOffsets[src[1] & 0xFF]] << 16) | gFontHalfRowLookupTable[gFontHalfRowOffsets[src[1] >> 8]]; } #else -ASM_DIRECT +NAKED void DecompressGlyphTile(const u16 *src, u16 *dest) { asm("push {r4-r7,lr}\n\ @@ -1052,7 +1052,7 @@ u8 GetLastTextColor(u8 colorType) } } -ASM_DIRECT +NAKED void CopyGlyphToWindow(struct TextPrinter *x) { asm("push {r4-r7,lr}\n\ @@ -2341,7 +2341,7 @@ u16 RenderText(struct TextPrinter *textPrinter) return 1; } #else -__attribute__((naked)) +NAKED u16 RenderText(struct TextPrinter *textPrinter) { asm("push {r4-r6,lr}\n\ diff --git a/src/tv.c b/src/tv.c index 8fc95b9b82..a48a2d6383 100644 --- a/src/tv.c +++ b/src/tv.c @@ -3931,7 +3931,7 @@ static void sub_80F0708(void) // FIXME: register allocation shenanigans } } #else -ASM_DIRECT static void sub_80F0708(void) +NAKED static void sub_80F0708(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" diff --git a/src/util.c b/src/util.c index 4f9241b212..88be4e4a13 100644 --- a/src/util.c +++ b/src/util.c @@ -230,7 +230,7 @@ void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) } #else -ASM_DIRECT void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) +NAKED void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) { asm("\n\ .syntax unified\n\ diff --git a/sym_common.txt b/sym_common.txt index bbb29fd42c..64bfa88ec3 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -167,4 +167,4 @@ gUnknown_03007898: @ 3007898 .space 0x8 gUnknown_030078A0: @ 30078A0 - .space 0x660 + .space 0xC