Skip to content

Commit

Permalink
Move external libraries into arm9 subregion (#237)
Browse files Browse the repository at this point in the history
This region is probably going to get much larger in the near future.
Since arm9.yml is already huge as is, and there's a natural boundary,
creating a subregion makes sense.
  • Loading branch information
UsernameFodder authored Dec 30, 2023
1 parent d6150d7 commit 4e762dd
Show file tree
Hide file tree
Showing 4 changed files with 2,043 additions and 2,015 deletions.
138 changes: 1 addition & 137 deletions headers/functions/arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define HEADERS_FUNCTIONS_ARM9_H_

#include "arm9/itcm.h"
#include "arm9/libs.h"

void Svc_SoftReset(void);
void Svc_WaitByLoop(void);
Expand Down Expand Up @@ -1059,142 +1060,5 @@ void MainLoop(void);
int DungeonSwapIdToIdx(enum dungeon_id dungeon_id);
enum dungeon_id DungeonSwapIdxToId(int idx);
enum dungeon_mode GetDungeonModeSpecial(enum dungeon_id dungeon_id);
int SoundUtilGetRandomNumber(void);
void* ReadWaviEntry(struct wavi_data* wavi_data, int entry_index);
int ResumeBgm(undefined4 param_1, undefined4 param_2, undefined4 param_3);
void* FindSmdlSongChunk(void* smdl_data, uint16_t value_to_search);
int FlushChannels(undefined* param_1, int param_2, int param_3);
void ParseDseEvent(undefined* audio_state, struct track_data* track_data);
void UpdateSequencerTracks(int param_1, undefined4 param_2, undefined4 param_3, undefined4 param_4);
void UpdateChannels(void);
void SoundEnvelopeReset(struct sound_envelope* envelope);
void SoundEnvelopeParametersReset(struct sound_envelope_parameters* parameters);
void SoundEnvelopeParametersCheckValidity(struct sound_envelope_parameters* parameters);
void SoundEnvelopeSetParameters(struct sound_envelope* envelope,
struct sound_envelope_parameters* parameters);
void SoundEnvelopeSetSlide(struct sound_envelope* envelope, int target_volume, int msec_tab_index);
void UpdateTrackVolumeEnvelopes(struct sound_envelope* envelope);
void SoundEnvelopeRelease(struct sound_envelope* envelope);
void SoundEnvelopeStop(struct sound_envelope* envelope);
void SoundEnvelopeForceVolume(struct sound_envelope* envelope, int volume);
void SoundEnvelopeStop2(struct sound_envelope* envelope);
int8_t SoundEnvelopeTick(struct sound_envelope* envelope);
void SoundLfoBankReset(struct dse_lfo_bank* lfo_bank);
void SoundLfoBankSet(struct dse_lfo_bank* lfo_bank, struct dse_lfo_settings* lfo_settings,
int8_t const_envelope_level);
void SoundLfoBankSetConstEnvelopes(struct dse_lfo_bank* lfo_bank, int8_t level);
uint16_t SoundLfoBankTick(struct dse_lfo_bank* lfo_bank);
int SoundLfoWaveInvalidFunc(struct dse_lfo* lfo);
int SoundLfoWaveHalfSquareFunc(struct dse_lfo* lfo);
int SoundLfoWaveFullSquareFunc(struct dse_lfo* lfo);
int SoundLfoWaveHalfTriangleFunc(struct dse_lfo* lfo);
int SoundLfoWaveFullTriangleFunc(struct dse_lfo* lfo);
int SoundLfoWaveSawFunc(struct dse_lfo* lfo);
int SoundLfoWaveReverseSawFunc(struct dse_lfo* lfo);
int SoundLfoWaveHalfNoiseFunc(struct dse_lfo* lfo);
int SoundLfoWaveFullNoiseFunc(struct dse_lfo* lfo);
void EnableVramBanksInSetDontSave(struct vram_banks_set vram_banks);
void EnableVramBanksInSet(struct vram_banks_set* vram_banks);
void G3_LoadMtx43(struct matrix_4x3* matrix);
void G3_MultMtx43(struct matrix_4x3* matrix);
void GeomGxFifoSendMtx4x3(struct matrix_4x3* matrix, void* gxfifo);
int IncrementThreadCount(void);
void InsertThreadIntoList(struct thread* thread);
void StartThread(struct thread* thread, thread_entry_fn_t function, struct thread* param_3,
void* stack_area, int stack_size, int param_6);
void ThreadExit(void);
void SetThreadField0xB4(struct thread* thread, int value);
void InitThread(struct thread* thread, void* function, void* stack_area_minus_4);
uint16_t GetTimer0Control(void);
int ClearIrqFlag(void);
int EnableIrqFlag(void);
int SetIrqFlag(int new_value);
int EnableIrqFiqFlags(void);
int SetIrqFiqFlags(int new_value);
int GetIrqFlag(void);
int GetProcessorMode(void);
uint32_t CountLeadingZeros(uint32_t x);
void WaitForever2(void);
void WaitForInterrupt(void);
void ArrayFill16(uint16_t val, void* ptr, int len);
void ArrayCopy16(void* src, void* dest, int len);
void ArrayFill32(uint32_t val, void* ptr, int len);
void ArrayCopy32(void* src, void* dest, int len);
void ArrayFill32Fast(uint32_t val, void* ptr, int len);
void ArrayCopy32Fast(void* src, void* dest, int len);
void MemsetFast(void* ptr, char val, uint32_t len);
void MemcpyFast(void* src, void* dest, uint32_t n);
uint32_t AtomicExchange(uint32_t desired, void* ptr);
void FileInit(struct file_stream* file);
bool GetOverlayInfo(struct overlay_info_entry* overlay_info, undefined param_2, int overlay_id);
bool LoadOverlayInternal(struct overlay_info_entry* overlay_info);
void InitOverlay(struct overlay_info_entry* overlay_info);

// If declaring these builtins causes issues, you can disable them
#ifndef PMDSKY_NO_BUILTIN
int abs(int x);
int mbtowc(wchar_t* pwc, const char* s, size_t n);
bool TryAssignByte(uint8_t* ptr, uint8_t val);
bool TryAssignByteWrapper(uint8_t* ptr, uint8_t val);
size_t wcstombs(char* dest, const wchar_t* src, size_t n);
void* memcpy(void* dest, const void* src, size_t n);
void* memmove(void* dest, const void* src, size_t n);
void* memset(void* s, int c, size_t n);
void* memchr(const void* s, int c, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
void memset_internal(void* s, int c, size_t n);
int __vsprintf_internal_slice(slice_append_fn_t append, struct slice* str, const char* format,
va_list ap);
bool TryAppendToSlice(struct slice* slice, const void* data, size_t data_len);
int __vsprintf_internal(char* str, size_t maxlen, const char* format, va_list ap);
int vsprintf(char* str, const char* format, va_list ap);
int snprintf(char* str, size_t n, const char* format, ...);
int sprintf(char* str, const char* format, ...);
size_t strlen(const char* s);
char* strcpy(char* dest, const char* src);
char* strncpy(char* dest, const char* src, size_t n);
char* strcat(char* dest, const char* src);
char* strncat(char* dest, const char* src, size_t n);
int strcmp(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
char* strchr(const char* string, int c);
size_t strcspn(const char* string, const char* stopset);
char* strstr(const char* haystack, const char* needle);
size_t wcslen(const wchar_t* ws);
double _dadd(double a, double b);
float _d2f(double d);
unsigned long long _ll_ufrom_d(double d);
double _dflt(int i);
double _dfltu(uint32_t u);
double _dmul(double a, double b);
double _dsqrt(double x);
double _dsub(double a, double b);
float _fadd(float a, float b);
bool _dgeq(double a, double b);
bool _dleq(double a, double b);
bool _dls(double a, double b);
bool _deq(double a, double b);
bool _dneq(double a, double b);
bool _fls(float a, float b);
float _fdiv(float dividend, float divisor);
double _f2d(float f);
int _ffix(float f);
float _fflt(int i);
float _ffltu(uint32_t u);
float _fmul(float a, float b);
float sqrtf(float x);
float _fsub(float a, float b);
long long _ll_mod(long long dividend, long long divisor);
long long _ll_sdiv(long long dividend, long long divisor);
unsigned long long _ll_udiv(unsigned long long dividend, unsigned long long divisor);
unsigned long long _ull_mod(unsigned long long dividend, unsigned long long divisor);
long long _ll_mul(long long a, long long b);
unsigned long long _s32_div_f(int dividend, int divisor);
unsigned long long _u32_div_f(uint32_t dividend, uint32_t divisor);
unsigned long long _u32_div_not_0_f(uint32_t dividend, uint32_t divisor);
double _drdiv(double divisor, double dividend);
double _ddiv(double dividend, double divisor);
void _fp_init(void);
#endif // #ifndef PMDSKY_NO_BUILTIN

#endif
142 changes: 142 additions & 0 deletions headers/functions/arm9/libs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#ifndef HEADERS_FUNCTIONS_ARM9_LIBS_H_
#define HEADERS_FUNCTIONS_ARM9_LIBS_H_

int SoundUtilGetRandomNumber(void);
void* ReadWaviEntry(struct wavi_data* wavi_data, int entry_index);
int ResumeBgm(undefined4 param_1, undefined4 param_2, undefined4 param_3);
void* FindSmdlSongChunk(void* smdl_data, uint16_t value_to_search);
int FlushChannels(undefined* param_1, int param_2, int param_3);
void ParseDseEvent(undefined* audio_state, struct track_data* track_data);
void UpdateSequencerTracks(int param_1, undefined4 param_2, undefined4 param_3, undefined4 param_4);
void UpdateChannels(void);
void SoundEnvelopeReset(struct sound_envelope* envelope);
void SoundEnvelopeParametersReset(struct sound_envelope_parameters* parameters);
void SoundEnvelopeParametersCheckValidity(struct sound_envelope_parameters* parameters);
void SoundEnvelopeSetParameters(struct sound_envelope* envelope,
struct sound_envelope_parameters* parameters);
void SoundEnvelopeSetSlide(struct sound_envelope* envelope, int target_volume, int msec_tab_index);
void UpdateTrackVolumeEnvelopes(struct sound_envelope* envelope);
void SoundEnvelopeRelease(struct sound_envelope* envelope);
void SoundEnvelopeStop(struct sound_envelope* envelope);
void SoundEnvelopeForceVolume(struct sound_envelope* envelope, int volume);
void SoundEnvelopeStop2(struct sound_envelope* envelope);
int8_t SoundEnvelopeTick(struct sound_envelope* envelope);
void SoundLfoBankReset(struct dse_lfo_bank* lfo_bank);
void SoundLfoBankSet(struct dse_lfo_bank* lfo_bank, struct dse_lfo_settings* lfo_settings,
int8_t const_envelope_level);
void SoundLfoBankSetConstEnvelopes(struct dse_lfo_bank* lfo_bank, int8_t level);
uint16_t SoundLfoBankTick(struct dse_lfo_bank* lfo_bank);
int SoundLfoWaveInvalidFunc(struct dse_lfo* lfo);
int SoundLfoWaveHalfSquareFunc(struct dse_lfo* lfo);
int SoundLfoWaveFullSquareFunc(struct dse_lfo* lfo);
int SoundLfoWaveHalfTriangleFunc(struct dse_lfo* lfo);
int SoundLfoWaveFullTriangleFunc(struct dse_lfo* lfo);
int SoundLfoWaveSawFunc(struct dse_lfo* lfo);
int SoundLfoWaveReverseSawFunc(struct dse_lfo* lfo);
int SoundLfoWaveHalfNoiseFunc(struct dse_lfo* lfo);
int SoundLfoWaveFullNoiseFunc(struct dse_lfo* lfo);
void EnableVramBanksInSetDontSave(struct vram_banks_set vram_banks);
void EnableVramBanksInSet(struct vram_banks_set* vram_banks);
void G3_LoadMtx43(struct matrix_4x3* matrix);
void G3_MultMtx43(struct matrix_4x3* matrix);
void GeomGxFifoSendMtx4x3(struct matrix_4x3* matrix, void* gxfifo);
int IncrementThreadCount(void);
void InsertThreadIntoList(struct thread* thread);
void StartThread(struct thread* thread, thread_entry_fn_t function, struct thread* param_3,
void* stack_area, int stack_size, int param_6);
void ThreadExit(void);
void SetThreadField0xB4(struct thread* thread, int value);
void InitThread(struct thread* thread, void* function, void* stack_area_minus_4);
uint16_t GetTimer0Control(void);
int ClearIrqFlag(void);
int EnableIrqFlag(void);
int SetIrqFlag(int new_value);
int EnableIrqFiqFlags(void);
int SetIrqFiqFlags(int new_value);
int GetIrqFlag(void);
int GetProcessorMode(void);
uint32_t CountLeadingZeros(uint32_t x);
void WaitForever2(void);
void WaitForInterrupt(void);
void ArrayFill16(uint16_t val, void* ptr, int len);
void ArrayCopy16(void* src, void* dest, int len);
void ArrayFill32(uint32_t val, void* ptr, int len);
void ArrayCopy32(void* src, void* dest, int len);
void ArrayFill32Fast(uint32_t val, void* ptr, int len);
void ArrayCopy32Fast(void* src, void* dest, int len);
void MemsetFast(void* ptr, char val, uint32_t len);
void MemcpyFast(void* src, void* dest, uint32_t n);
uint32_t AtomicExchange(uint32_t desired, void* ptr);
void FileInit(struct file_stream* file);
bool GetOverlayInfo(struct overlay_info_entry* overlay_info, undefined param_2, int overlay_id);
bool LoadOverlayInternal(struct overlay_info_entry* overlay_info);
void InitOverlay(struct overlay_info_entry* overlay_info);

// If declaring these builtins causes issues, you can disable them
#ifndef PMDSKY_NO_BUILTIN
int abs(int x);
int mbtowc(wchar_t* pwc, const char* s, size_t n);
bool TryAssignByte(uint8_t* ptr, uint8_t val);
bool TryAssignByteWrapper(uint8_t* ptr, uint8_t val);
size_t wcstombs(char* dest, const wchar_t* src, size_t n);
void* memcpy(void* dest, const void* src, size_t n);
void* memmove(void* dest, const void* src, size_t n);
void* memset(void* s, int c, size_t n);
void* memchr(const void* s, int c, size_t n);
int memcmp(const void* s1, const void* s2, size_t n);
void memset_internal(void* s, int c, size_t n);
int __vsprintf_internal_slice(slice_append_fn_t append, struct slice* str, const char* format,
va_list ap);
bool TryAppendToSlice(struct slice* slice, const void* data, size_t data_len);
int __vsprintf_internal(char* str, size_t maxlen, const char* format, va_list ap);
int vsprintf(char* str, const char* format, va_list ap);
int snprintf(char* str, size_t n, const char* format, ...);
int sprintf(char* str, const char* format, ...);
size_t strlen(const char* s);
char* strcpy(char* dest, const char* src);
char* strncpy(char* dest, const char* src, size_t n);
char* strcat(char* dest, const char* src);
char* strncat(char* dest, const char* src, size_t n);
int strcmp(const char* s1, const char* s2);
int strncmp(const char* s1, const char* s2, size_t n);
char* strchr(const char* string, int c);
size_t strcspn(const char* string, const char* stopset);
char* strstr(const char* haystack, const char* needle);
size_t wcslen(const wchar_t* ws);
double _dadd(double a, double b);
float _d2f(double d);
unsigned long long _ll_ufrom_d(double d);
double _dflt(int i);
double _dfltu(uint32_t u);
double _dmul(double a, double b);
double _dsqrt(double x);
double _dsub(double a, double b);
float _fadd(float a, float b);
bool _dgeq(double a, double b);
bool _dleq(double a, double b);
bool _dls(double a, double b);
bool _deq(double a, double b);
bool _dneq(double a, double b);
bool _fls(float a, float b);
float _fdiv(float dividend, float divisor);
double _f2d(float f);
int _ffix(float f);
float _fflt(int i);
float _ffltu(uint32_t u);
float _fmul(float a, float b);
float sqrtf(float x);
float _fsub(float a, float b);
long long _ll_mod(long long dividend, long long divisor);
long long _ll_sdiv(long long dividend, long long divisor);
unsigned long long _ll_udiv(unsigned long long dividend, unsigned long long divisor);
unsigned long long _ull_mod(unsigned long long dividend, unsigned long long divisor);
long long _ll_mul(long long a, long long b);
unsigned long long _s32_div_f(int dividend, int divisor);
unsigned long long _u32_div_f(uint32_t dividend, uint32_t divisor);
unsigned long long _u32_div_not_0_f(uint32_t dividend, uint32_t divisor);
double _drdiv(double divisor, double dividend);
double _ddiv(double dividend, double divisor);
void _fp_init(void);
#endif // #ifndef PMDSKY_NO_BUILTIN

#endif
Loading

0 comments on commit 4e762dd

Please sign in to comment.