Skip to content
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

Synced function symbols from decomp #187

Merged
merged 3 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/target
Cargo.lock
/out
__pycache__
__pycache__
.vscode
13 changes: 12 additions & 1 deletion headers/functions/arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@

#include "arm9/itcm.h"

void EntryArm9(void);
void SvcWaitByLoop(void);
void SvcSoftReset(void);
void SvcCpuSet(void);
void _start(void);
void MIiUncompressBackward(void);
void do_autoload(void);
void StartAutoloadDoneCallback(void);
void OSiReferSymbol(void);
void NitroMain(void);
Comment on lines +6 to +14
Copy link
Owner

Choose a reason for hiding this comment

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

Do you know if these are (mostly) the only core functions with weird naming? It seems like after these you get into the allocator functions. If these are the only exceptions maybe it might make more sense to implement an exception list for the case checker so we can use the real names.

Copy link
Contributor Author

@AnonymousRandomPerson AnonymousRandomPerson Sep 7, 2023

Choose a reason for hiding this comment

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

These are not the only ones. I've seen this naming convention in some of the library code, and the number of functions would make an exception list grow very large.

I don't personally like this naming convention of mixing case with domain_action, but it is a real naming convention used by some C programming circles (e.g., pret/pokeheartgold#213). It may be worth supporting this style outright, rather than making exceptions.

Copy link
Owner

Choose a reason for hiding this comment

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

I would need to see more examples. This kind of mixed case convention seems extremely permissive, because domain can be anything (MIi == PascalCase, SVC == SCREAMING_SNAKE_CASE, _start == snake_case), so a sufficiently flexible check would have to accept almost all names except maybe camelCase and constructs like UPPERlower. It's not something I'd really be keen on implementing checks for. You might as well just turn off naming checks at that point.

Maybe let's just leave it as the converted PascalCase names for now. You're maintaining a list if the mixed case ones, so it should be easy to revisit this if we start finding more of these.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you search for jn_spl.o in this map file, that section of the file has more examples.

I think _start_AutoloadDoneCallback is a special case because it is related to the _start function, which is hard-coded to be the entry point of the program regardless of naming convention. Ignoring that, the convention seems to be PascalCase between the underscores, allowing consecutive capitals for abbreviations. This at least allows some restrictions.

I'm good with keeping the converted names for now. I'm not very interested in the library code, but if somebody else starts extracting them then we can revisit this.

void InitMemAllocTable(void);
void SetMemAllocatorParams(get_alloc_arena_fn_t get_alloc_arena,
get_free_arena_fn_t get_free_arena);
Expand Down Expand Up @@ -390,6 +398,8 @@ int PreprocessString(char* output, int output_size, const char* format,
struct preprocessor_flags flags, struct preprocessor_args* args);
int PreprocessStringFromMessageId(char* output, int output_size, int message_id,
struct preprocessor_flags flags, struct preprocessor_args* args);
bool StrcmpTagVeneer(const char* s1, const char* s2);
int StoiTagVeneer(const char* s);
void InitPreprocessorArgs(struct preprocessor_args* args);
char* SetStringAccuracy(char* s, int param_2);
char* SetStringPower(char* s, int param_2);
Expand Down Expand Up @@ -445,6 +455,7 @@ void PrintIqSkillsMenu(enum monster_id monster_id, uint32_t* iq_skills_flags, in
bool is_blinded);
bool GetNotifyNote(void);
void SetNotifyNote(bool flag);
void EventFlagBackupVeneer(void);
void InitMainTeamAfterQuiz(void);
void ScriptSpecialProcess0x3(void);
void ScriptSpecialProcess0x4(void);
Expand Down
7 changes: 7 additions & 0 deletions headers/functions/overlay11.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#ifndef HEADERS_FUNCTIONS_OVERLAY11_H_
#define HEADERS_FUNCTIONS_OVERLAY11_H_

void FuncThatCallsCommandParsing(void);
void ScriptCommandParsing(void);
void LoadFileFromRomVeneer(struct iovec* iov, const char* filepath, uint32_t flags);
void SsbLoad2(void);
void StationLoadHanger(void);
void ScriptStationLoadTalk(void);
void SsbLoad1(void);
int ScriptSpecialProcessCall(undefined4* param_1, enum special_process_id id, int arg1, int arg2);
enum monster_id GetSpecialRecruitmentSpecies(int idx);
void PrepareMenuAcceptTeamMember(int idx);
Expand Down
3 changes: 3 additions & 0 deletions headers/functions/overlay29.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ void TryActivateConversion2(struct entity* attacker, struct entity* defender, st
void TryActivateTruant(struct entity* entity);
void TryPointCameraToMonster(struct entity* entity, undefined param_2, undefined param_3);
void RestorePpAllMovesSetFlags(struct entity* entity);
bool CheckTeamMemberIdxVeneer(int member_idx);
bool IsMonsterIdInNormalRangeVeneer(enum monster_id monster_id);
void BoostIQ(struct entity* entity, int iq_boost, bool suppress_logs);
bool ShouldMonsterHeadToStairs(struct entity* entity);
bool MewSpawnCheck(enum monster_id monster_id, bool fail_if_mew);
Expand Down Expand Up @@ -755,6 +757,7 @@ void GenerateItemExplicit(struct item* item, enum item_id item_id, uint16_t quan
void GenerateAndSpawnItem(enum item_id item_id, int16_t x, int16_t y, uint16_t quantity,
bool sticky, bool check_in_bag);
bool IsHiddenStairsFloor(void);
bool IsSecretBazaarVeneer(void);
void GenerateStandardItem(struct item* item, enum item_id item_id,
enum gen_item_stickiness sticky_type);
void GenerateCleanItem(struct item* item, enum item_id item_id);
Expand Down
64 changes: 63 additions & 1 deletion symbols/arm9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,19 @@ arm9:
subregions:
- itcm.yml
functions:
- name: EntryArm9
- name: SvcWaitByLoop
address:
NA: 0x2000088
description: Software interrupt.
- name: SvcSoftReset
address:
NA: 0x2000566
description: Software interrupt.
- name: SvcCpuSet
address:
NA: 0x200078E
description: Software interrupt.
- name: _start
address:
EU: 0x2000800
NA: 0x2000800
Expand All @@ -38,6 +50,26 @@ arm9:
The entrypoint for the ARM9 CPU. This is like the "main" function for the ARM9 subsystem.

No params.
- name: MIiUncompressBackward
address:
NA: 0x2000970
description: Startup routine in crt0.
AnonymousRandomPerson marked this conversation as resolved.
Show resolved Hide resolved
- name: do_autoload
address:
NA: 0x2000A1C
description: Startup routine in crt0.
- name: StartAutoloadDoneCallback
address:
NA: 0x2000AAC
description: Startup routine in crt0.
- name: OSiReferSymbol
address:
NA: 0x2000B9C
description: Startup routine in crt0.
- name: NitroMain
address:
NA: 0x2000C6C
description: "Entrypoint into NitroSDK, the DS devkit library."
- name: InitMemAllocTable
address:
EU: 0x2000DE0
Expand Down Expand Up @@ -3827,6 +3859,27 @@ arm9:
r2: message ID
r3: preprocessor flags
stack[0]: pointer to preprocessor args
- name: StrcmpTagVeneer
address:
NA: 0x20235F8
description: |-
Likely a linker-generated veneer for StrcmpTag.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

r0: s1
r1: s2
return: bool
- name: StoiTagVeneer
address:
NA: 0x2023604
description: |-
Likely a linker-generated veneer for StoiTag.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

r0: s
return: int
- name: InitPreprocessorArgs
address:
EU: 0x20238B4
Expand Down Expand Up @@ -4377,6 +4430,15 @@ arm9:
Sets NOTIFY_NOTE to the given value.

r0: bool
- name: EventFlagBackupVeneer
address:
NA: 0x2048758
description: |-
Likely a linker-generated veneer for EventFlagBackup.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

No params.
- name: InitMainTeamAfterQuiz
address:
EU: 0x2048AE0
Expand Down
11 changes: 11 additions & 0 deletions symbols/overlay11.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ overlay11:
EU: 0x22DE6A4
NA: 0x22DDD64
JP: 0x22DF404
- name: LoadFileFromRomVeneer
address:
NA: 0x22E46DC
description: |-
Likely a linker-generated veneer for LoadFileFromRom.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

r0: [output] pointer to an IO struct {ptr, len}
r1: file path string pointer
r2: flags
- name: SsbLoad2
address:
EU: 0x22E503C
Expand Down
29 changes: 29 additions & 0 deletions symbols/overlay29.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,26 @@ overlay29:
Called when a monster is revived.

r0: pointer to entity whose moves will be restored
- name: CheckTeamMemberIdxVeneer
address:
NA: 0x22F9C34
description: |-
Likely a linker-generated veneer for CheckTeamMemberIdx.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

r0: member index
return: True if the value is equal to 0x55AA or 0x5AA5
- name: IsMonsterIdInNormalRangeVeneer
address:
NA: 0x22F9C68
description: |-
Likely a linker-generated veneer for IsMonsterIdInNormalRange.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

r0: monster ID
return: bool
- name: BoostIQ
address:
EU: 0x22FAB50
Expand Down Expand Up @@ -7330,6 +7350,15 @@ overlay29:
description: |-
Checks if the current floor is either the Secret Bazaar or a Secret Room.

return: bool
- name: IsSecretBazaarVeneer
address:
NA: 0x2344538
description: |-
Likely a linker-generated veneer for IsSecretBazaar.

See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-

return: bool
- name: GenerateStandardItem
address:
Expand Down
Loading