Decomp UFixedPoint64CmpLt - #285
Open
CecilArmitais wants to merge 1 commit into
Open
Conversation
| } | ||
| } | ||
|
|
||
| int UFixedPoint64CmpLt(u32 a_hi, u32 a_lo, u32 b_hi, u32 b_lo) |
Collaborator
There was a problem hiding this comment.
This might be able to return a bool8 and TRUE/FALSE instead of an int.
Contributor
Author
There was a problem hiding this comment.
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.
Collaborator
There was a problem hiding this comment.
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
force-pushed
the
decomp-UFixedPoint64CmpLt
branch
from
July 25, 2026 22:19
f18c7dd to
14c2343
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.