Skip to content

Decomp UFixedPoint64CmpLt - #285

Open
CecilArmitais wants to merge 1 commit into
pret:mainfrom
CecilArmitais:decomp-UFixedPoint64CmpLt
Open

Decomp UFixedPoint64CmpLt#285
CecilArmitais wants to merge 1 commit into
pret:mainfrom
CecilArmitais:decomp-UFixedPoint64CmpLt

Conversation

@CecilArmitais

Copy link
Copy Markdown
Contributor

Decompiles UFixedPoint64CmpLt into src/main_020018D0.c. asm/main_02001A30.s contained only this function, so the file and its .inc are removed rather than split, and main.lsf drops asm/main_02001A30.o.

Reasoning, evidence and open questions:
https://github.com/CecilArmitais/decomp-notes/blob/main/pulls/decomp-UFixedPoint64CmpLt.md

(that page is unverified AI reasoning, not part of this PR — the diff and the build are the sources of truth; use as cross reference only).

AI-authored — Claude (Opus 4.8), under human direction. Please review the diff and re-verify the matching build before merging. Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK.

Comment thread src/main_020018D0.c Outdated
}
}

int UFixedPoint64CmpLt(u32 a_hi, u32 a_lo, u32 b_hi, u32 b_lo)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This might be able to return a bool8 and TRUE/FALSE instead of an int.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It wouldn't be a bool8, that would result in "and r0, r0, #0xff" showing up. But I am gonna rework it using BOOL, TRUE, and FALSE. BOOL is int/s32. It also did bring up a thing of note; the extern declaration in a different file needed adjustment. Will update with that soon.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

There's a bool32 type defined as well, to be consistent with the bool8 type used throughout this project.

Decompile UFixedPoint64CmpLt (0x02001A30) from asm. It compares two 64-bit
values held as high/low word pairs and returns whether the first is less than
the second.

asm/main_02001A30.s held only this function, so the file and its .inc are
removed rather than split, the function merges into the adjacent
src/main_020018D0.c, and main.lsf drops asm/main_02001A30.o.

Three details of the interface are read off the target rather than assumed,
each tested with the others held fixed. The four words arrive as separate
parameters: a 2-word struct passed by value makes the compiler push all four
argument registers and reload them, which the target does not do. Those
parameters are unsigned: the comparisons select movlo/movhi, where signed high
words give movlt/movgt. The return is word-sized: a u8-width return such as
bool8 appends and r0, r0, #0xff, which the target does not have. BOOL is used
rather than int because it is the tree's word-sized boolean, and it produces
the same bytes.

src/main_02001BB4.c declared this function from its call site, before it was
decompiled. That declaration is replaced by an include of the header. It was
never visible to the compiler at the same time as the definition, so the two
disagreeing prototypes could not be caught by a build; its parameter types were
signed, which does not describe this function.

No comments are added to any pmd-sky file.

Authored by Claude (Opus 4.8, amended by Opus 5) under human direction.
Confirmed by a matching build: build/pmdsky.us/pmdsky.us.nds: OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CecilArmitais
CecilArmitais force-pushed the decomp-UFixedPoint64CmpLt branch from f18c7dd to 14c2343 Compare July 25, 2026 22:19
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