papermario/include/macros.h

102 lines
2.5 KiB
C
Raw Normal View History

#ifndef _MACROS_H_
#define _MACROS_H_
2020-10-13 03:28:01 +02:00
#include "common.h"
2021-03-09 18:10:12 +01:00
#include "include_asm.h"
#define BSS __attribute__ ((section (".bss")))
2020-12-02 00:23:26 +01:00
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
2021-01-01 02:20:39 +01:00
#define N(sym) NS(NAMESPACE, sym)
2020-08-09 04:17:37 +02:00
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define PHYSICAL_TO_VIRTUAL(addr) (void*)((u32)(addr) + 0x80000000)
#define VIRTUAL_TO_PHYSICAL(addr) (u32)((u8*)(addr) - 0x80000000)
2021-07-19 10:22:43 +02:00
#ifdef DEBUG
#define ASSERT(condition) \
if (!(condition)) { \
func_80025F44("Assertion failed: " #condition, __FILE__, __LINE__); \
while (TRUE) {} \
}
#define PANIC() \
func_80025F44("Panic!", __FILE__, __LINE__); \
while (TRUE) {}
#else
#define ASSERT(condition) if (!(condition)) { while (TRUE) {} }
#define PANIC() while (TRUE) {}
#endif
2020-08-17 14:09:19 +02:00
2020-11-10 21:21:37 +01:00
#define BADGE_MENU_PAGE(index) (&gBadgeMenuPages[index])
2020-11-12 06:44:10 +01:00
#define ITEM_MENU_PAGE(index) (&gItemMenuPages[index])
2020-11-10 21:21:37 +01:00
2020-10-13 03:28:01 +02:00
#define MAX_MAPVARS 16
#define MAX_MAPFLAGS 3
2020-11-08 21:40:26 +01:00
#define MAX_ANIMATED_MODELS 16
#define MAX_ANIMATED_MESHES 16
#define MAX_ENTITY_MODELS 256
#define MAX_MODELS 256
Assorted Morsels (#297) * bss * 3 audios * d5a50 stuff * some icon funcs * get_icon_render_pos * PlayerLandJump * func_80248170 * cleanup * splat update prep * git subrepo pull --force tools/splat subrepo: subdir: "tools/splat" merged: "81c4b35b89" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "81c4b35b89" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "9b791a654a" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "9b791a654a" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "2cf2a5e5d8" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "2cf2a5e5d8" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo.git" commit: "2f68596" * fix loop in PaperMarioNpcSprites * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "2fab217750" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "2fab217750" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * add sha1 to yaml * git subrepo pull tools/splat subrepo: subdir: "tools/splat" merged: "426b08200d" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "426b08200d" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * varTable -> union :( + player_api funcs * 6 more * 4 more * 5 mo * 1 mo * 1 mo 2 * 5 mo * player_jump * 3 mo * some 18F340 * 6 more * 6 mo * nm * 1 * 1 more * some PR feedback * symbol addr update * UnsetCamera0Flag1000 * SetPlayerSpriteSet2 * action 18 * encounter + a smol hammer * git subrepo pull (merge) tools/splat subrepo: subdir: "tools/splat" merged: "8cf482fe57" upstream: origin: "https://github.com/ethteck/splat.git" branch: "master" commit: "4c0a93eaed" git-subrepo: version: "0.4.3" origin: "https://github.com/ingydotnet/git-subrepo" commit: "2f68596" * 3 and cleanup * undo yucky union * PR comments * get_enemy_safe * cleanup * move VirtualEntity * attempt to fix doxygen * 3, cleanup * broken * fixed! * progress * 2 * 3 and cleanup * 6 map_api funcs * 3 map api * CreateNpc * BringPartnerOut & NpcFlyTo * npc_api complete * update_scripts * 4 si bois inc si_execute_next_command * update symbol_addrs * 2 more and cleanup * camera struct & do_camera_type_0 * PR feedback * small tidying
2021-06-21 06:30:57 +02:00
#define MAX_MODEL_TRANSFORM_GROUPS 4
2020-10-13 03:28:01 +02:00
#define MAX_SCRIPTS 128
#define MAX_NPCS 64
#define MAX_TRIGGERS 64
#define MAX_SHADOWS 60
#define MAX_ENTITIES 30
#define MAX_DYNAMIC_ENTITIES 16
#define MAX_TEX_PANNERS 16
#define MAX_ITEM_ENTITIES 256
2020-10-13 03:28:01 +02:00
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
2020-10-26 22:45:24 +01:00
// Alternative to libultra's M_PI: non-float version; more digits cause issues
#define PI 3.141592f
#define PI_D 3.141592
#define TAU 6.28318f
#define PI_S 3.14159f // Shorter PI
2020-10-26 22:45:24 +01:00
#define SPRITE_WORLD_SCALE 0.71428573f
#define PACK_FILL_COLOR(r, g, b, a) (GPACK_RGBA5551(r, g, b, a) << 0x10) | GPACK_RGBA5551(r, g, b, a)
2020-10-13 03:28:01 +02:00
//NOTE: SCRIPT_ALLOC is probably not quite correct, but this is the closest thing to matching for the functions its used in. Needs more work.
#define SCRIPT_ALLOC(new, index) \
{ \
(*gCurrentScriptListPtr)[index] = new = heap_malloc(sizeof(Evt)); \
gNumScripts++; \
2020-10-13 03:28:01 +02:00
ASSERT(new != NULL); \
}
#define SCRIPT_FREE(index) \
{ \
ScriptList** temp = &gCurrentScriptListPtr; \
s32 *numScripts = &gNumScripts; \
heap_free((**temp)[index]); \
(**temp)[index] = NULL; \
(*numScripts)--; \
}
#define SQ(x) (x*x)
#define CUBE(x) (x*x*x)
#define QUART(x) (x*x*x*x)
/// Fixed-point short literal
#define F16(f) (s16)(f * 327.67f)
/// X.10 fixed-point literal
#define X10(f) (s32)(f * 1024.0f)
2020-12-28 08:09:39 +01:00
#define _NS(x, y) x ## _ ## y
#define NS(x, y) _NS(x, y)
2020-10-21 15:12:24 +02:00
2021-01-15 04:19:49 +01:00
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
#ifdef PERMUTER
#define SCRIPT(...) {}
#endif
#endif