Skip to content

Finish matching lift.c and improve its documentation#15

Open
idefix02 wants to merge 2 commits into
SAT-R:mainfrom
idefix02:lift.c
Open

Finish matching lift.c and improve its documentation#15
idefix02 wants to merge 2 commits into
SAT-R:mainfrom
idefix02:lift.c

Conversation

@idefix02

Copy link
Copy Markdown

No description provided.

worldX = lift->worldX;
worldY = lift->worldY;
handleY = (worldY - gCamera.y) + I(lift->unk8C);
worldX = screenX = lift->worldX;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The original match in 9a0fee6 had the "screen" and "world" variables merged together, which I have a hunch is probably what the original code did, but personally I find this reuse of the same variables for two different purposes distasteful (but YMMV of course).
So the dead store assignments to the "screen" variables is a way to have the two sets of variables while coercing gcc into the correct regalloc (but this might border on fakematching)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well, as long as it matches, there's nothing wrong with it, in theory, as long as it still matches.

s = &lift->s[LIFT_SPRITE_HANDLE];
s->x = screenX;
s->y = handleY;
linkY = handleY;

@idefix02 idefix02 Jun 18, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Regalloc no longer matches if this assignment to linkY is put further down

Comment on lines +53 to +54
lift->playerHoldsHandle[0] = FALSE;
lift->playerHoldsHandle[1] = FALSE;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To can change
playerHoldsHandle[0] and playerHoldsHandle[1]
to
playerHoldsHandle[PLAYER_1] and playerHoldsHandle[PLAYER_2].

SET_MAP_ENTITY_INITIALIZED(me);

sub_8033098(&lift->s[0], &lift->s[1], &lift->s[2]);
Task_LiftInitSprites(&lift->s[LIFT_SPRITE_PLATFORM], &lift->s[LIFT_SPRITE_CHAIN_LINK], &lift->s[LIFT_SPRITE_HANDLE]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is definitely not a Task, since it has parameters.

Tasks are any procedure you can assign a pointer of to gCurTask->main without casting.

Comment on lines +281 to +282
worldX = screenX = lift->worldX;
worldY = screenYPlatform = lift->worldY;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since we don't have any other screenY, you can just leave it as screenY, which is also consistent with basically all other entities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants