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

Info dump 58-62/64: Music, interrupts, hurling and dungeon struct #207

Merged
merged 4 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions headers/data/overlay10.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ extern int16_t WONDER_CHEST_EXP_BOOST;
extern int16_t SPAWN_CAP_WITH_MONSTER_HOUSE;
extern int16_t POISON_DAMAGE_COOLDOWN;
extern int16_t LEECH_SEED_DAMAGE_COOLDOWN;
extern int16_t THROWN_ITEM_HIT_CHANCE;
extern int16_t GEO_PEBBLE_DAMAGE;
extern int16_t GRAVELEROCK_DAMAGE;
extern int16_t RARE_FOSSIL_DAMAGE;
Expand Down
7 changes: 6 additions & 1 deletion headers/functions/arm7.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

void EntryArm7(void);
void NitroSpMain(void);
int GetProcessorMode(void);
void HardwareInterrupt(void);
void ReturnFromInterrupt(void);
void AudioInterrupt(int function_index);
bool ClearImeFlag(void);
int ClearIeFlag(int flag_id);
long long GetCurrentPlaybackTime(void);

#endif
18 changes: 15 additions & 3 deletions headers/functions/arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,22 @@ enum move_category GetMoveCategory(enum move_id move_id);
int GetPpIncrease(enum monster_id monster_id, uint32_t* iq_skill_flags);
void OpenWaza(int waza_id);
void SelectWaza(int waza_id);
void SendAudioCommandWrapperVeneer(enum music_id music_id, undefined param_2, int volume);
void SendAudioCommandWrapper(enum music_id music_id, undefined param_2, int volume);
void PlayBgmByIdVeneer(enum music_id music_id);
void PlayBgmByIdVolumeVeneer(enum music_id music_id, undefined param_2, int volume);
void PlaySeVolumeWrapper(int index);
void PlayBgmById(enum music_id music_id);
void PlayBgmByIdVolume(enum music_id music_id, undefined param_2, int volume);
void StopBgmCommand(void);
void PlaySeByIdVolume(int se_id, int volume);
void SendAudioCommand2(struct audio_command command);
struct audio_command* AllocAudioCommand(int status);
void SendAudioCommand(struct audio_command command);
void InitSoundSystem(void);
void ManipBgmPlayback(void);
void SoundDriverReset(void);
uint32_t LoadDseFile(struct iovec* iov, const char* filename);
undefined4 PlaySeLoad(int param_1);
bool IsSongOver(void);
void PlayBgm(int param_1, int param_2, int param_3);
void StopBgm(int param_1);
void ChangeBgm(int param_1, int param_2);
Expand Down Expand Up @@ -537,6 +544,7 @@ void FreePortraitBox(int dbox_id);
void ShowPortraitBox(int dbox_id, struct portrait_box* portrait);
void HidePortraitBox(int dbox_id);
bool IsMenuOptionActive(undefined* param_1);
void PlayMenuOptionSound(undefined* param_1, int index);
int ShowKeyboard(int message_id, char* buffer1, int param_3, char* buffer2);
int GetKeyboardStatus(void);
int GetKeyboardStringResult(void);
Expand Down Expand Up @@ -898,9 +906,11 @@ 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);
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 ParseDseEvents(undefined4 param_1, int param_2, undefined4 param_3, undefined4 param_4);
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 UpdateTrackVolumeEnvelopes(undefined* param_1);
Expand All @@ -909,12 +919,14 @@ void EnableVramBanksInSet(struct vram_banks_set* vram_banks);
void GeomMtxLoad4x3(struct matrix_4x3* matrix);
void GeomMtxMult4x3(struct matrix_4x3* matrix);
void GeomGxFifoSendMtx4x3(struct matrix_4x3* matrix, void* gxfifo);
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);
void WaitForever2(void);
void WaitForInterrupt(void);
void ArrayFill16(uint16_t val, void* ptr, int len);
Expand Down
2 changes: 2 additions & 0 deletions headers/functions/arm9/itcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ enum monster_id GetKeyN2MBaseForm(int key);
void GetKeyM2NSwitch(enum monster_id monster_id, int sw);
int GetKeyM2N(enum monster_id monster_id);
int GetKeyM2NBaseForm(enum monster_id monster_id);
void HardwareInterrupt(void);
void ReturnFromInterrupt(void);
bool ShouldMonsterRunAwayVariationOutlawCheck(struct entity* monster, undefined param_2);
void AiMovement(struct entity* monster, undefined param_2);
void CalculateAiTargetPos(struct entity* monster);
Expand Down
1 change: 1 addition & 0 deletions headers/functions/overlay10.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ int16_t GetItemAnimation1(enum item_id item_id);
int16_t GetItemAnimation2(enum item_id item_id);
int GetMoveAnimationSpeed(enum move_id move_id);
bool IsBackgroundTileset(int tileset_id);
void InitTilesetBuffer(void* buffer, int tileset_id, uint32_t malloc_flags);
int MainGame(int end_cond);

#endif
1 change: 1 addition & 0 deletions headers/functions/overlay29.h
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ void AddHeldItemToBag(struct monster* monster);
void RemoveEmptyItemsInBagWrapper(void);
void GenerateItem(struct item* item, enum item_id item_id, uint16_t quantity,
enum gen_item_stickiness sticky_type);
bool DoesProjectileHitTarget(struct entity* user, struct entity* target);
bool CheckActiveChallengeRequest(void);
struct mission_destination_info* GetMissionDestination(void);
bool IsOutlawOrChallengeRequestFloor(void);
Expand Down
47 changes: 47 additions & 0 deletions headers/types/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,53 @@ struct audio_command {
};
ASSERT_SIZE(struct audio_command, 32);

// Contains data for an audio track that is being played
struct track_data {
undefined field_0x0;
undefined field_0x1;
bool active; // 0x2: True if the track is active
undefined field_0x3;
undefined field_0x4;
undefined field_0x5;
undefined field_0x6;
undefined field_0x7;
int play_amount; // 0x8: Number of times the track has been played so far
// 0xC: Delay (in frames, probably) before the next DSE event on this track begins
int event_delay;
undefined field_0x10;
undefined field_0x11;
undefined field_0x12;
undefined field_0x13;
undefined field_0x14;
undefined field_0x15;
undefined field_0x16;
undefined field_0x17;
void* track_data_start; // 0x18: Pointer to the start of the track's audio data
void* current_event; // 0x1C: Pointer to the current DSE event
};
ASSERT_SIZE(struct track_data, 32); // Exact size hasn't been confirmed

// Data about a wavi container
struct wavi_data {
undefined field_0x0;
undefined field_0x1;
undefined field_0x2;
undefined field_0x3;
undefined field_0x4;
undefined field_0x5;
undefined field_0x6;
undefined field_0x7;
int16_t num_entries; // 0x8: Number of entries in the container
undefined field_0xA;
undefined field_0xB;
undefined field_0xC;
undefined field_0xD;
undefined field_0xE;
undefined field_0xF;
void* pointer_table_start; // 0x10: Pointer to the start of the pointer table
};
ASSERT_SIZE(struct wavi_data, 20); // Likely longer

// TODO: Add more data file structures, as convenient or needed, especially if the load address
// or pointers to the load address are known.

Expand Down
75 changes: 72 additions & 3 deletions symbols/arm7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,77 @@ arm7:
This main function for the ARM7 subsystem. Contains the main event loop.

No params.
- name: HardwareInterrupt
address:
EU: 0x2383670
NA: 0x2383670
EU-WRAM: 0x37FB488
UsernameFodder marked this conversation as resolved.
Show resolved Hide resolved
NA-WRAM: 0x37FB488
description: |-
Called whenever a hardware interrupt takes place.

Returns immediately if the IME flag is 0 or if none of the devices that requested an interrupt has the corresponding Interrupt Enable flag set.
It searches for the first device that requested an interrupt, clears its Interrupt Request flag, then jumps to the start of the corresponding interrupt function. The return address is manually set to ReturnFromInterrupt.
This function does not return.

No params.
- name: ReturnFromInterrupt
address:
EU: 0x23836DC
NA: 0x23836DC
EU-WRAM: 0x37FB4F4
NA-WRAM: 0x37FB4F4
description: |-
The execution returns to this function after a hardware interrupt function is run.

No params.
- name: AudioInterrupt
address:
EU: 0x2383824
NA: 0x2383824
EU-WRAM: 0x37FB63C
NA-WRAM: 0x37FB63C
description: |-
Called when handling a hardware interrupt from the audio system.

Its parameter is used to index a list of function pointers. The game then jumps to the read pointer.

r0: Index of the function to jump to
- name: ClearImeFlag
address:
EU: 0x2383AC0
NA: 0x2383AC0
EU-WRAM: 0x37FB8D8
NA-WRAM: 0x37FB8D8
description: |-
Clears the Interrupt Master Enable flag, which disables all hardware interrupts.

return: Previous IME value
- name: ClearIeFlag
address:
EU: 0x2383B10
NA: 0x2383B10
EU-WRAM: 0x37FB928
NA-WRAM: 0x37FB928
description: |-
Clears the specified Interrupt Enable flag, which disables interrupts for the specified hardware component.

r0: Flag to clear
return: Previous value of the Interrupt Enable flags
- name: GetCurrentPlaybackTime
address:
EU: 0x2385404
NA: 0x2385404
EU-WRAM: 0x37FD21C
NA-WRAM: 0x37FD21C
description: |-
Returns the time that the current song has been playing for. Might have a more generic purpose.

The time is obtained using a couple of RAM counters and the hardware timers for additional precision.
The game uses this value to know when a given note should stop being played. It doesn't seem to be used to keep track of the
current time instant within the song.
UsernameFodder marked this conversation as resolved.
Show resolved Hide resolved

return: Playback time. Units unknown.
- name: ClearIrqFlag
address:
EU: 0x2385ED4
Expand Down Expand Up @@ -139,9 +210,7 @@ arm7:
NA-WRAM: 0x37FDD58
JP-WRAM: 0x37FDD58
description: |-
Gets the processor's current operating mode.

See https://problemkaputt.de/gbatek.htm#armcpuflagsconditionfieldcond
Copy of the ARM9 function. See arm9.yml for more information.

return: cpsr & 0x1f (the cpsr mode bits M4-M0)
- name: __divsi3
Expand Down
Loading
Loading