Repository navigation
mkw: Match KartState::init, improve KartCollide::checkNeighborhood, decompile RaceinfoPlayer_getLapSplit
#12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,46 @@ KrtFile** RaceManager::getKrtFile() { | |
| return (files[0] != nullptr) ? files : nullptr; | ||
| } | ||
| } | ||
|
|
||
| extern "C" void RaceinfoPlayer_getLapSplit(RaceManagerPlayer* player, u32 lap, Time* split) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is extern C used here? Why not the C++ name? Maybe the LLM used does not understand code warrior mangling?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, it's a good question to understand how the LLM thinks about these problems. I asked the model about it: Prompt: In the RaceManagercpp RaceInfoPlayer_getlapsplit, why did you use extern C instead of the c++ name? Do you not understand code warrior mangling? Answer: I understand CodeWarrior mangling. The target symbol is literally: without CodeWarrior mangling. A normal C++ definition such as: would emit a mangled symbol resembling: and would not replace the plain target symbol by itself. However, the ABI strongly suggests it behaves like a member method: So the honest answer is: I used A cleaner reconstruction would be to add: to |
||
| if (lap < 2) { | ||
| split->copyFrom(*player->lapFinishTimes); | ||
| return; | ||
| } | ||
|
|
||
| if (RaceManager::spInstance->timerManager->hasSpecialTimerState()) { | ||
| split->set(99, 59, 999, true); | ||
| return; | ||
| } | ||
|
|
||
| u32 earlierLap = lap - 2; | ||
| u32 laterLap = lap - 1; | ||
| s32 seconds = 0; | ||
| s32 minutes = 0; | ||
| const Time* earlier = player->lapFinishTimes + earlierLap; | ||
| const Time* later = player->lapFinishTimes + laterLap; | ||
| s32 milliseconds = later->milliseconds() - earlier->milliseconds(); | ||
| if (milliseconds < 0) { | ||
| seconds = -1; | ||
| milliseconds += 1000; | ||
| } | ||
| seconds += later->seconds() - earlier->seconds(); | ||
| if (seconds < 0) { | ||
| minutes = -1; | ||
| seconds += 60; | ||
| } | ||
| minutes += later->minutes() - earlier->minutes(); | ||
| if (minutes < 0) { | ||
| minutes = 0; | ||
| seconds = 0; | ||
| milliseconds = 0; | ||
| } | ||
|
|
||
| split->set(minutes, seconds, milliseconds, true); | ||
| if (!player->lapFinishTimes[laterLap].isValid() || !player->lapFinishTimes[earlierLap].isValid()) { | ||
| split->setTime(0xFFFF, 0, 0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // needs KartObjectManager definitions | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is not 100% matched anyways I would not include the vu32 casts in the commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine, thx