-
Notifications
You must be signed in to change notification settings - Fork 24
Description
A substantial amount of the process occurs in the ARM7, which itself works over two domains: The ARM7 binary and the shared WRAM. Since there's not a lot of info on those two aspects, I'll include some relevant stuff of theirs aswell. All of this information is for North America ROM
I'll try to summarize the process as far as I've been researching it. Due to the large complexity of the system, I'll try to not add a lot all at once. If some detail in particular is needed before it's added, please ask for it!
This is my idea of how a request to play music goes from start to finish, in function calls. I'm not fully certain what some steps are meant to achieve in the big picture yet so I apologize for leaving them blank
- 0x20198b8 void BGM_Play(int bgmId, int unk0, int unk1)
- 0x206d9bc
- 0x206db7c
- 0x2073504
- 0x2073edc In this function, the two arguments passed in are somehow used to buffer writes to an array of structs in 0x22b7a6c (size of each: 0x15c, and there's one for every sound channel in the DS)
Since the writes are buffered, this is the end of this avenue. To further follow the process, we need to start elsewhere - 0x2071014
- 0x2074a58 For each of the structs in the previously mentioned array, some of their fields are used to create the sound_ops that are passed via IPC
- 0x207ca6c void PushSoundOp_Type0xE(uint channel, uint format, uint source, int repeat_mode, uint loop_start, uint word_amt, uint volume, uint volume_div, int timerVal, int panning)
This is the most complete sound op I could find and it overwrites a huge amount of the sound registers in 4000400. Basically all of the names are from GBATEK - 0x207cbcc void PushSoundOp(uint type, uint arg0, uint arg1, uint arg2, uint arg3)
- 0x207cedc void PushSoundOpToLinkedList(sound_op* op)
The linked list in question has pointers to the start and end at 0x22b9a28 and 0x22b9a2c respectively. Anyway, having buffered these operations, they're finally all sent through IPC over the dedicated sound channel (n. 7), see IPC System #20
STRUCTS:
Sound Op: Stores the operation type, four ints (16 bytes) used to store any kind of arguments in any bit layout, and a pointer to the next sound op (making it a linked list node, which is a VERY common data structure observed in the sound engine overall)
0x0: ptr to next sound op
0x4: type (u32)
0x8: arguments (u32[4])
Total size: 24 bytes
FUNCTIONS ARM7:
0x3801f1c: Processes operations sent from the ARM9 over IPC fifo, most of them are values to be written to the sound registers (0x40004XX)
0x2380118: Copies the WRAM binary stored in ARM7 (0x23801e8) to 0x37f8000. It also copies stuff to 0x27e0000 but I'm not sure what for