Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
21 changes: 20 additions & 1 deletion include/pause.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,28 @@ 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_RENDER_TEX_SIZE RGBA16 texture / framebuffer for rendering the player into
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// PAUSE_PLAYER_RENDER_TEX_SIZE RGBA16 texture / framebuffer for rendering the player into
// PAUSE_PLAYER_SEGMENT_TEX_SIZE RGBA16 texture / framebuffer for rendering the player into

not sure which name you preferred, either sounds fine

// 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_TEX_SIZE sizeof(u16[PAUSE_EQUIP_PLAYER_HEIGHT][PAUSE_EQUIP_PLAYER_WIDTH])
#define PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE 0x5000

#define PAUSE_PLAYER_SEGMENT_TEXTURE(playerSegment) \
(playerSegment)
#define PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP(playerSegment) \
((playerSegment) + PAUSE_PLAYER_SEGMENT_TEX_SIZE)
#define PAUSE_PLAYER_SEGMENT_LINK_OBJECT(playerSegment) \
((playerSegment) + PAUSE_PLAYER_SEGMENT_TEX_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE)

#define PAUSE_PLAYER_SEGMENT_TOTAL_SIZE(linkObjectSize) \
(PAUSE_PLAYER_SEGMENT_TEX_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.
Expand Down
23 changes: 10 additions & 13 deletions src/code/z_player_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1890,24 +1890,23 @@ u32 Player_InitPauseDrawData(PlayState* play, u8* segment, SkelAnime* skelAnime)
void* ptr;

size = gObjectTable[OBJECT_GAMEPLAY_KEEP].vromEnd - gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart;
ptr = segment + PAUSE_EQUIP_BUFFER_SIZE;
ptr = PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP(segment);
Copy link
Contributor

@mzxrules mzxrules Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all this abstraction, it is no longer clear to the reader that GAMEPLAY_KEEP is being truncated.

Also, another notable thing here is that because OBJECT_GAMEPLAY_KEEP is compressed, the full segment needs to be loaded in first, then overwritten.

DMA_REQUEST_SYNC(ptr, gObjectTable[OBJECT_GAMEPLAY_KEEP].vromStart, size, "../z_player_lib.c", 2982);

size = gObjectTable[linkObjectId].vromEnd - gObjectTable[linkObjectId].vromStart;
ptr = segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE;
ptr = PAUSE_PLAYER_SEGMENT_LINK_OBJECT(segment);
DMA_REQUEST_SYNC(ptr, gObjectTable[linkObjectId].vromStart, size, "../z_player_lib.c", 2988);

// Joint tables are placed after the link object
ptr = (void*)ALIGN16((uintptr_t)ptr + size);

gSegments[4] = OS_K0_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE);
gSegments[6] =
OS_K0_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE);
gSegments[4] = OS_K0_TO_PHYSICAL(PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP(segment));
gSegments[6] = OS_K0_TO_PHYSICAL(PAUSE_PLAYER_SEGMENT_LINK_OBJECT(segment));

SkelAnime_InitLink(play, skelAnime, gPlayerSkelHeaders[(void)0, gSaveContext.save.linkAge],
&gPlayerAnim_link_normal_wait, 9, ptr, ptr, PLAYER_LIMB_MAX);

return PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE + size +
sizeof(Vec3s[PLAYER_LIMB_BUF_COUNT]);
return PAUSE_PLAYER_SEGMENT_TOTAL_SIZE(size);
}

u8 sPauseModelGroupBySword[] = {
Expand Down Expand Up @@ -2077,9 +2076,8 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f*
Vec3s* srcTable;
s32 i;

gSegments[4] = OS_K0_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE);
gSegments[6] =
OS_K0_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE);
gSegments[4] = OS_K0_TO_PHYSICAL(PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP(segment));
gSegments[6] = OS_K0_TO_PHYSICAL(PAUSE_PLAYER_SEGMENT_LINK_OBJECT(segment));

if (!LINK_IS_ADULT) {
if (shield == PLAYER_SHIELD_DEKU) {
Expand All @@ -2103,9 +2101,8 @@ void Player_DrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime, Vec3f*
*destTable++ = *srcTable++;
}

Player_DrawPauseImpl(play, segment + PAUSE_EQUIP_BUFFER_SIZE,
segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE, skelAnime,
pos, rot, scale, sword, tunic, shield, boots, PAUSE_EQUIP_PLAYER_WIDTH,
Player_DrawPauseImpl(play, PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP(segment), PAUSE_PLAYER_SEGMENT_LINK_OBJECT(segment),
skelAnime, pos, rot, scale, sword, tunic, shield, boots, PAUSE_EQUIP_PLAYER_WIDTH,
PAUSE_EQUIP_PLAYER_HEIGHT, &eye, &at, 60.0f, play->state.gfxCtx->curFrameBuffer,
play->state.gfxCtx->curFrameBuffer + (PAUSE_EQUIP_PLAYER_WIDTH * PAUSE_EQUIP_PLAYER_HEIGHT));
}
9 changes: 5 additions & 4 deletions src/overlays/misc/ovl_kaleido_scope/z_kaleido_equipment.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static u8 sEquipmentItemOffsets[] = {
ITEM_BOOTS_HOVER - ITEM_SWORD_KOKIRI, // EQUIP_VALUE_BOOTS_HOVER
};

void KaleidoScope_DrawEquipmentImage(PlayState* play, void* source, u32 width, u32 height) {
void KaleidoScope_DrawEquipmentImage(PlayState* play, void* texture, u32 width, u32 height) {
PauseContext* pauseCtx = &play->pauseCtx;
u8* curTexture;
s32 vtxIndex;
Expand All @@ -88,7 +88,7 @@ void KaleidoScope_DrawEquipmentImage(PlayState* play, void* source, u32 width, u
gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_POINT);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, 255, 255, 255, pauseCtx->alpha);

curTexture = source;
curTexture = texture;
remainingSize = width * height * G_IM_SIZ_16b_BYTES;
textureHeight = TMEM_SIZE / (width * G_IM_SIZ_16b_BYTES);
textureSize = width * textureHeight * G_IM_SIZ_16b_BYTES;
Expand Down Expand Up @@ -697,7 +697,7 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
#endif
}

gSPSegment(POLY_OPA_DISP++, 0x07, pauseCtx->playerSegment);
gSPSegment(POLY_OPA_DISP++, 0x07, PAUSE_PLAYER_SEGMENT_TEXTURE(pauseCtx->playerSegment));
gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->iconItemSegment);
gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->iconItem24Segment);
gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->nameSegment);
Expand All @@ -707,7 +707,8 @@ void KaleidoScope_DrawEquipment(PlayState* play) {
// Draw player prerender onto the equip page

Gfx_SetupDL_42Opa(play->state.gfxCtx);
KaleidoScope_DrawEquipmentImage(play, pauseCtx->playerSegment, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT);
KaleidoScope_DrawEquipmentImage(play, PAUSE_PLAYER_SEGMENT_TEXTURE(pauseCtx->playerSegment),
PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT);

CLOSE_DISPS(play->state.gfxCtx, "../z_kaleido_equipment.c", 609);
}
4 changes: 2 additions & 2 deletions src/overlays/misc/ovl_kaleido_scope/z_kaleido_scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -3431,7 +3431,7 @@ void KaleidoScope_Draw(PlayState* play) {
pauseCtx->stickAdjY = input->rel.stick_y;

gSPSegment(POLY_OPA_DISP++, 0x02, interfaceCtx->parameterSegment);
gSPSegment(POLY_OPA_DISP++, 0x07, pauseCtx->playerSegment);
gSPSegment(POLY_OPA_DISP++, 0x07, PAUSE_PLAYER_SEGMENT_TEXTURE(pauseCtx->playerSegment));
gSPSegment(POLY_OPA_DISP++, 0x08, pauseCtx->iconItemSegment);
gSPSegment(POLY_OPA_DISP++, 0x09, pauseCtx->iconItem24Segment);
gSPSegment(POLY_OPA_DISP++, 0x0A, pauseCtx->nameSegment);
Expand Down Expand Up @@ -3881,7 +3881,7 @@ void KaleidoScope_Update(PlayState* play) {

PreRender_Init(&sPlayerPreRender);
PreRender_SetValuesSave(&sPlayerPreRender, PAUSE_EQUIP_PLAYER_WIDTH, PAUSE_EQUIP_PLAYER_HEIGHT,
pauseCtx->playerSegment, NULL, sPreRenderCvg);
PAUSE_PLAYER_SEGMENT_TEXTURE(pauseCtx->playerSegment), NULL, sPreRenderCvg);

KaleidoScope_DrawPlayerWork(play);
KaleidoScope_SetupPlayerPreRender(play);
Expand Down