Macro-ify access to pauseCtx->playerSegment regions (#2693)

* Macro-ify access to pauseCtx->playerSegment regions.

Using macros to indicate which region in the player segment is being
accessed makes the memory layout more obvious and indicates the
intended level of memory ownership, particularly in the case of the
texture image at the start of the segment.

* Add clarifications for gameplay_keep details

* Uniform macro name for the render texture

* Comment
This commit is contained in:
Tharo
2026-04-16 21:33:07 +01:00
committed by GitHub
parent 2a2e216eb8
commit b1ba2b3997
4 changed files with 47 additions and 21 deletions
+25 -1
View File
@@ -53,9 +53,33 @@ typedef enum PauseMenuPage {
#define PAUSE_EQUIP_PLAYER_FRAG_HEIGHT (TMEM_SIZE / (PAUSE_EQUIP_PLAYER_WIDTH * G_IM_SIZ_16b_BYTES))
#define PAUSE_EQUIP_PLAYER_FRAG_NUM (((PAUSE_EQUIP_PLAYER_HEIGHT - 1) / PAUSE_EQUIP_PLAYER_FRAG_HEIGHT) + 1)
#define PAUSE_EQUIP_BUFFER_SIZE sizeof(u16[PAUSE_EQUIP_PLAYER_HEIGHT][PAUSE_EQUIP_PLAYER_WIDTH])
// The pause player segment consists of:
// PAUSE_PLAYER_SEGMENT_RENDER_TEXTURE_SIZE RGBA16 texture / framebuffer for rendering the player into
// PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE First bytes of gameplay_keep for accessing player-related data
// sizeof(link object) Link object
// sizeof(Vec3s[PLAYER_LIMB_BUF_COUNT])) Joint table
#define PAUSE_PLAYER_SEGMENT_RENDER_TEXTURE_SIZE sizeof(u16[PAUSE_EQUIP_PLAYER_HEIGHT][PAUSE_EQUIP_PLAYER_WIDTH])
#define PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE 0x5000
#define PAUSE_PLAYER_SEGMENT_RENDER_TEXTURE(playerSegment) \
(playerSegment)
// Note that only the first chunk of gameplay_keep is loaded, the data relevant to rendering the player
// is expected to be within this first chunk. The size of this first chunk is determined by
// PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE.
#define PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_START(playerSegment) \
((playerSegment) + PAUSE_PLAYER_SEGMENT_RENDER_TEXTURE_SIZE)
#define PAUSE_PLAYER_SEGMENT_LINK_OBJECT(playerSegment) \
((playerSegment) + PAUSE_PLAYER_SEGMENT_RENDER_TEXTURE_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE)
#define PAUSE_PLAYER_SEGMENT_TOTAL_SIZE(linkObjectSize) \
(PAUSE_PLAYER_SEGMENT_RENDER_TEXTURE_SIZE + \
PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + \
(linkObjectSize) + \
sizeof(Vec3s[PLAYER_LIMB_BUF_COUNT]))
typedef enum PauseState {
/* 0 */ PAUSE_STATE_OFF,
/* 1 */ PAUSE_STATE_WAIT_LETTERBOX, // Request no letterboxing and wait for it.