sound.c through GetSoundPlayer

This commit is contained in:
PikalaxALT 2021-10-30 13:17:08 -04:00
parent c1b091f5ef
commit a1a1cd139a
9 changed files with 404 additions and 677 deletions

View File

@ -8,675 +8,10 @@
.public _02111950
.public sSndHeapFreeSize ; 02111954
.public sSoundWork ; 02111958
.public GF_SndHeapGetFreeSize
.text
thumb_func_start sub_02004300
sub_02004300: ; 0x02004300
push {r4, lr}
bl GetSoundDataPointer
add r4, r0, #0
ldr r0, _020043A4 ; =_0211194C
ldr r0, [r0, #_0211194C - _0211194C]
cmp r0, #6
bhi _020043A0
add r0, r0, r0
add r0, pc
ldrh r0, [r0, #6]
lsl r0, r0, #0x10
asr r0, r0, #0x10
add pc, r0
_0200431C: ; jump table
.short _020043A0 - _0200431C - 2 ; case 0
.short _0200432A - _0200431C - 2 ; case 1
.short _020043A0 - _0200431C - 2 ; case 2
.short _02004332 - _0200431C - 2 ; case 3
.short _02004342 - _0200431C - 2 ; case 4
.short _02004352 - _0200431C - 2 ; case 5
.short _02004374 - _0200431C - 2 ; case 6
_0200432A:
mov r0, #2
bl sub_020043B0
pop {r4, pc}
_02004332:
bl sub_02005F88
cmp r0, #0
bne _020043A0
mov r0, #2
bl sub_020043B0
pop {r4, pc}
_02004342:
bl sub_02005F88
cmp r0, #0
bne _020043A0
mov r0, #2
bl sub_020043B0
pop {r4, pc}
_02004352:
bl sub_02005F88
cmp r0, #0
bne _020043A0
bl sub_020059B0
cmp r0, #0
bne _020043A0
bl sub_020048F0
ldr r0, _020043A8 ; =0x000BEBFE
ldrh r0, [r4, r0]
cmp r0, #0
beq _020043A0
bl PlayBGM
pop {r4, pc}
_02004374:
bl sub_02005F88
cmp r0, #0
bne _020043A0
bl sub_020059B0
cmp r0, #0
bne _020043A0
bl sub_020048F0
ldr r0, _020043A8 ; =0x000BEBFE
ldrh r0, [r4, r0]
cmp r0, #0
beq _02004394
bl PlayBGM
_02004394:
ldr r1, _020043AC ; =0x000BEBF8
mov r0, #0x7f
ldr r1, [r4, r1]
mov r2, #0
bl sub_02005F10
_020043A0:
pop {r4, pc}
nop
_020043A4: .word _0211194C
_020043A8: .word 0x000BEBFE
_020043AC: .word 0x000BEBF8
thumb_func_end sub_02004300
thumb_func_start sub_020043B0
sub_020043B0: ; 0x020043B0
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
ldr r1, _020043C4 ; =0x000BEBEC
mov r2, #0
strh r2, [r0, r1]
ldr r0, _020043C8 ; =_0211194C
str r4, [r0, #_0211194C - _0211194C]
pop {r4, pc}
.balign 4, 0
_020043C4: .word 0x000BEBEC
_020043C8: .word _0211194C
thumb_func_end sub_020043B0
thumb_func_start sub_020043CC
sub_020043CC: ; 0x020043CC
push {r4, lr}
bl GetSoundDataPointer
add r4, r0, #0
mov r0, #2
bl GF_SndPlayerCountPlayingSeqByPlayerNo
cmp r0, #0
beq _020043E2
mov r0, #1
pop {r4, pc}
_020043E2:
ldr r0, _020043F4 ; =0x000BEC02
ldrh r0, [r4, r0]
cmp r0, #0
beq _020043EE
mov r0, #1
pop {r4, pc}
_020043EE:
mov r0, #0
pop {r4, pc}
nop
_020043F4: .word 0x000BEC02
thumb_func_end sub_020043CC
thumb_func_start GetSoundDataPointer
GetSoundDataPointer: ; 0x020043F8
ldr r0, _020043FC ; =sSoundWork
bx lr
.balign 4, 0
_020043FC: .word sSoundWork
thumb_func_end GetSoundDataPointer
thumb_func_start GF_SdatGetAttrPtr
GF_SdatGetAttrPtr: ; 0x02004400
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
cmp r4, #0x3a
bls _0200440E
b _020045F2
_0200440E:
add r1, r4, r4
add r1, pc
ldrh r1, [r1, #6]
lsl r1, r1, #0x10
asr r1, r1, #0x10
add pc, r1
_0200441A: ; jump table
.short _0200449C - _0200441A - 2 ; case 0
.short _020044A2 - _0200441A - 2 ; case 1
.short _020044A8 - _0200441A - 2 ; case 2
.short _020044AE - _0200441A - 2 ; case 3
.short _020044B4 - _0200441A - 2 ; case 4
.short _02004490 - _0200441A - 2 ; case 5
.short _02004496 - _0200441A - 2 ; case 6
.short _020044BA - _0200441A - 2 ; case 7
.short _020044C0 - _0200441A - 2 ; case 8
.short _020044C6 - _0200441A - 2 ; case 9
.short _020044CC - _0200441A - 2 ; case 10
.short _020044D2 - _0200441A - 2 ; case 11
.short _020044D8 - _0200441A - 2 ; case 12
.short _020044DE - _0200441A - 2 ; case 13
.short _020044E4 - _0200441A - 2 ; case 14
.short _020044EA - _0200441A - 2 ; case 15
.short _020044F0 - _0200441A - 2 ; case 16
.short _020044F6 - _0200441A - 2 ; case 17
.short _020044FC - _0200441A - 2 ; case 18
.short _02004502 - _0200441A - 2 ; case 19
.short _02004508 - _0200441A - 2 ; case 20
.short _0200450E - _0200441A - 2 ; case 21
.short _02004514 - _0200441A - 2 ; case 22
.short _0200451A - _0200441A - 2 ; case 23
.short _02004520 - _0200441A - 2 ; case 24
.short _02004526 - _0200441A - 2 ; case 25
.short _0200452C - _0200441A - 2 ; case 26
.short _02004532 - _0200441A - 2 ; case 27
.short _02004538 - _0200441A - 2 ; case 28
.short _0200453E - _0200441A - 2 ; case 29
.short _02004544 - _0200441A - 2 ; case 30
.short _0200454A - _0200441A - 2 ; case 31
.short _02004550 - _0200441A - 2 ; case 32
.short _02004556 - _0200441A - 2 ; case 33
.short _0200455C - _0200441A - 2 ; case 34
.short _02004562 - _0200441A - 2 ; case 35
.short _02004568 - _0200441A - 2 ; case 36
.short _0200456E - _0200441A - 2 ; case 37
.short _02004574 - _0200441A - 2 ; case 38
.short _0200457A - _0200441A - 2 ; case 39
.short _02004580 - _0200441A - 2 ; case 40
.short _02004586 - _0200441A - 2 ; case 41
.short _0200458C - _0200441A - 2 ; case 42
.short _02004592 - _0200441A - 2 ; case 43
.short _02004598 - _0200441A - 2 ; case 44
.short _0200459E - _0200441A - 2 ; case 45
.short _020045A4 - _0200441A - 2 ; case 46
.short _020045AA - _0200441A - 2 ; case 47
.short _020045B0 - _0200441A - 2 ; case 48
.short _020045B6 - _0200441A - 2 ; case 49
.short _020045BC - _0200441A - 2 ; case 50
.short _020045C2 - _0200441A - 2 ; case 51
.short _020045C8 - _0200441A - 2 ; case 52
.short _020045CE - _0200441A - 2 ; case 53
.short _020045D4 - _0200441A - 2 ; case 54
.short _020045DA - _0200441A - 2 ; case 55
.short _020045E0 - _0200441A - 2 ; case 56
.short _020045E6 - _0200441A - 2 ; case 57
.short _020045EC - _0200441A - 2 ; case 58
_02004490:
ldr r1, _020045FC ; =0x000BEBEE
add r0, r0, r1
pop {r4, pc}
_02004496:
ldr r1, _02004600 ; =0x000BEBEF
add r0, r0, r1
pop {r4, pc}
_0200449C:
ldr r1, _02004604 ; =0x000BEB9C
add r0, r0, r1
pop {r4, pc}
_020044A2:
ldr r1, _02004608 ; =0x000BEBA0
add r0, r0, r1
pop {r4, pc}
_020044A8:
ldr r1, _0200460C ; =0x000BEBA4
add r0, r0, r1
pop {r4, pc}
_020044AE:
ldr r1, _02004610 ; =0x000BEBC0
add r0, r0, r1
pop {r4, pc}
_020044B4:
ldr r1, _02004614 ; =0x000BEBD0
add r0, r0, r1
pop {r4, pc}
_020044BA:
ldr r1, _02004618 ; =0x000BEBF0
add r0, r0, r1
pop {r4, pc}
_020044C0:
ldr r1, _0200461C ; =0x000BEBF4
add r0, r0, r1
pop {r4, pc}
_020044C6:
ldr r1, _02004620 ; =0x000BEBF8
add r0, r0, r1
pop {r4, pc}
_020044CC:
ldr r1, _02004624 ; =0x000BEBFC
add r0, r0, r1
pop {r4, pc}
_020044D2:
ldr r1, _02004628 ; =0x000BEBFE
add r0, r0, r1
pop {r4, pc}
_020044D8:
ldr r1, _0200462C ; =0x000BEC00
add r0, r0, r1
pop {r4, pc}
_020044DE:
ldr r1, _02004630 ; =0x000BEC01
add r0, r0, r1
pop {r4, pc}
_020044E4:
ldr r1, _02004634 ; =0x000BEC02
add r0, r0, r1
pop {r4, pc}
_020044EA:
ldr r1, _02004638 ; =0x000BEC04
add r0, r0, r1
pop {r4, pc}
_020044F0:
ldr r1, _0200463C ; =0x000BEC05
add r0, r0, r1
pop {r4, pc}
_020044F6:
ldr r1, _02004640 ; =0x000BEC06
add r0, r0, r1
pop {r4, pc}
_020044FC:
ldr r1, _02004644 ; =0x000BEC07
add r0, r0, r1
pop {r4, pc}
_02004502:
ldr r1, _02004648 ; =0x000BEC08
add r0, r0, r1
pop {r4, pc}
_02004508:
ldr r1, _0200464C ; =0x000BEC09
add r0, r0, r1
pop {r4, pc}
_0200450E:
ldr r1, _02004650 ; =0x000BEC0A
add r0, r0, r1
pop {r4, pc}
_02004514:
ldr r1, _02004654 ; =0x000BEC0B
add r0, r0, r1
pop {r4, pc}
_0200451A:
ldr r1, _02004658 ; =0x000BEC0C
add r0, r0, r1
pop {r4, pc}
_02004520:
ldr r1, _0200465C ; =0x000BEC10
add r0, r0, r1
pop {r4, pc}
_02004526:
ldr r1, _02004660 ; =0x000BEC14
add r0, r0, r1
pop {r4, pc}
_0200452C:
ldr r1, _02004664 ; =0x000BEC18
add r0, r0, r1
pop {r4, pc}
_02004532:
ldr r1, _02004668 ; =0x000BEC1C
add r0, r0, r1
pop {r4, pc}
_02004538:
ldr r1, _0200466C ; =0x000BEC20
add r0, r0, r1
pop {r4, pc}
_0200453E:
ldr r1, _02004670 ; =0x000BEC24
add r0, r0, r1
pop {r4, pc}
_02004544:
ldr r1, _02004674 ; =0x000BEC28
add r0, r0, r1
pop {r4, pc}
_0200454A:
ldr r1, _02004678 ; =0x000BEC29
add r0, r0, r1
pop {r4, pc}
_02004550:
ldr r1, _0200467C ; =0x000BEC2A
add r0, r0, r1
pop {r4, pc}
_02004556:
ldr r1, _02004680 ; =0x000BEC2C
add r0, r0, r1
pop {r4, pc}
_0200455C:
ldr r1, _02004684 ; =0x000BEC30
add r0, r0, r1
pop {r4, pc}
_02004562:
ldr r1, _02004688 ; =0x000BEC38
add r0, r0, r1
pop {r4, pc}
_02004568:
ldr r1, _0200468C ; =0x000BEC3C
add r0, r0, r1
pop {r4, pc}
_0200456E:
ldr r1, _02004690 ; =0x000BEC40
add r0, r0, r1
pop {r4, pc}
_02004574:
ldr r1, _02004694 ; =0x000BEC44
add r0, r0, r1
pop {r4, pc}
_0200457A:
ldr r1, _02004698 ; =0x000BEC48
add r0, r0, r1
pop {r4, pc}
_02004580:
ldr r1, _0200469C ; =0x000BEC4C
add r0, r0, r1
pop {r4, pc}
_02004586:
ldr r1, _020046A0 ; =0x000BEC50
add r0, r0, r1
pop {r4, pc}
_0200458C:
ldr r1, _020046A4 ; =0x000BEC58
add r0, r0, r1
pop {r4, pc}
_02004592:
ldr r1, _020046A8 ; =0x000BEC60
add r0, r0, r1
pop {r4, pc}
_02004598:
ldr r1, _020046AC ; =0x000BEC68
add r0, r0, r1
pop {r4, pc}
_0200459E:
ldr r1, _020046B0 ; =0x000BEC70
add r0, r0, r1
pop {r4, pc}
_020045A4:
ldr r1, _020046B4 ; =0x000BEC74
add r0, r0, r1
pop {r4, pc}
_020045AA:
ldr r1, _020046B8 ; =0x000BEC54
add r0, r0, r1
pop {r4, pc}
_020045B0:
ldr r1, _020046BC ; =0x000BEC5C
add r0, r0, r1
pop {r4, pc}
_020045B6:
ldr r1, _020046C0 ; =0x000BEC64
add r0, r0, r1
pop {r4, pc}
_020045BC:
ldr r1, _020046C4 ; =0x000BEC6C
add r0, r0, r1
pop {r4, pc}
_020045C2:
ldr r1, _020046C8 ; =0x000BEC72
add r0, r0, r1
pop {r4, pc}
_020045C8:
ldr r1, _020046CC ; =0x000BEC75
add r0, r0, r1
pop {r4, pc}
_020045CE:
ldr r1, _020046D0 ; =0x000BEC76
add r0, r0, r1
pop {r4, pc}
_020045D4:
ldr r1, _020046D4 ; =0x000BEC77
add r0, r0, r1
pop {r4, pc}
_020045DA:
ldr r1, _020046D8 ; =0x000BEC78
add r0, r0, r1
pop {r4, pc}
_020045E0:
ldr r1, _020046DC ; =0x000BEC79
add r0, r0, r1
pop {r4, pc}
_020045E6:
ldr r1, _020046E0 ; =0x000BEC7A
add r0, r0, r1
pop {r4, pc}
_020045EC:
ldr r1, _020046E4 ; =0x000BEC7C
add r0, r0, r1
pop {r4, pc}
_020045F2:
bl GF_AssertFail
mov r0, #0
pop {r4, pc}
nop
_020045FC: .word 0x000BEBEE
_02004600: .word 0x000BEBEF
_02004604: .word 0x000BEB9C
_02004608: .word 0x000BEBA0
_0200460C: .word 0x000BEBA4
_02004610: .word 0x000BEBC0
_02004614: .word 0x000BEBD0
_02004618: .word 0x000BEBF0
_0200461C: .word 0x000BEBF4
_02004620: .word 0x000BEBF8
_02004624: .word 0x000BEBFC
_02004628: .word 0x000BEBFE
_0200462C: .word 0x000BEC00
_02004630: .word 0x000BEC01
_02004634: .word 0x000BEC02
_02004638: .word 0x000BEC04
_0200463C: .word 0x000BEC05
_02004640: .word 0x000BEC06
_02004644: .word 0x000BEC07
_02004648: .word 0x000BEC08
_0200464C: .word 0x000BEC09
_02004650: .word 0x000BEC0A
_02004654: .word 0x000BEC0B
_02004658: .word 0x000BEC0C
_0200465C: .word 0x000BEC10
_02004660: .word 0x000BEC14
_02004664: .word 0x000BEC18
_02004668: .word 0x000BEC1C
_0200466C: .word 0x000BEC20
_02004670: .word 0x000BEC24
_02004674: .word 0x000BEC28
_02004678: .word 0x000BEC29
_0200467C: .word 0x000BEC2A
_02004680: .word 0x000BEC2C
_02004684: .word 0x000BEC30
_02004688: .word 0x000BEC38
_0200468C: .word 0x000BEC3C
_02004690: .word 0x000BEC40
_02004694: .word 0x000BEC44
_02004698: .word 0x000BEC48
_0200469C: .word 0x000BEC4C
_020046A0: .word 0x000BEC50
_020046A4: .word 0x000BEC58
_020046A8: .word 0x000BEC60
_020046AC: .word 0x000BEC68
_020046B0: .word 0x000BEC70
_020046B4: .word 0x000BEC74
_020046B8: .word 0x000BEC54
_020046BC: .word 0x000BEC5C
_020046C0: .word 0x000BEC64
_020046C4: .word 0x000BEC6C
_020046C8: .word 0x000BEC72
_020046CC: .word 0x000BEC75
_020046D0: .word 0x000BEC76
_020046D4: .word 0x000BEC77
_020046D8: .word 0x000BEC78
_020046DC: .word 0x000BEC79
_020046E0: .word 0x000BEC7A
_020046E4: .word 0x000BEC7C
thumb_func_end GF_SdatGetAttrPtr
thumb_func_start GF_Snd_SaveState
GF_Snd_SaveState: ; 0x020046E8
push {r3, r4, r5, lr}
add r5, r0, #0
bl GetSoundDataPointer
add r0, #0x94
ldr r0, [r0]
bl NNS_SndHeapSaveState
add r4, r0, #0
mov r0, #0
mvn r0, r0
cmp r4, r0
bne _02004706
bl GF_AssertFail
_02004706:
cmp r5, #0
beq _0200470C
str r4, [r5]
_0200470C:
bl GF_SndHeapGetFreeSize
add r0, r4, #0
pop {r3, r4, r5, pc}
thumb_func_end GF_Snd_SaveState
thumb_func_start GF_Snd_LoadState
GF_Snd_LoadState: ; 0x02004714
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
add r0, #0x94
ldr r0, [r0]
add r1, r4, #0
bl NNS_SndHeapLoadState
bl GF_SndHeapGetFreeSize
pop {r4, pc}
thumb_func_end GF_Snd_LoadState
thumb_func_start GF_SndHeapGetFreeSize
GF_SndHeapGetFreeSize: ; 0x0200472C
push {r3, lr}
bl GetSoundDataPointer
add r0, #0x94
ldr r0, [r0]
bl NNS_SndHeapGetFreeSize
ldr r1, _02004740 ; =_0211194C
str r0, [r1, #8]
pop {r3, pc}
.balign 4, 0
_02004740: .word _0211194C
thumb_func_end GF_SndHeapGetFreeSize
thumb_func_start GF_Snd_LoadGroup
GF_Snd_LoadGroup: ; 0x02004744
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
add r1, r0, #0
add r1, #0x94
ldr r1, [r1]
add r0, r4, #0
bl NNS_SndArcLoadGroup
add r4, r0, #0
bl GF_SndHeapGetFreeSize
add r0, r4, #0
pop {r4, pc}
.balign 4, 0
thumb_func_end GF_Snd_LoadGroup
thumb_func_start GF_Snd_LoadSeq
GF_Snd_LoadSeq: ; 0x02004764
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
add r1, r0, #0
add r1, #0x94
ldr r1, [r1]
add r0, r4, #0
bl NNS_SndArcLoadSeq
add r4, r0, #0
bl GF_SndHeapGetFreeSize
add r0, r4, #0
pop {r4, pc}
.balign 4, 0
thumb_func_end GF_Snd_LoadSeq
thumb_func_start GF_Snd_LoadSeqEx
GF_Snd_LoadSeqEx: ; 0x02004784
push {r3, r4, r5, lr}
add r5, r0, #0
add r4, r1, #0
bl GetSoundDataPointer
add r2, r0, #0
add r2, #0x94
ldr r2, [r2]
add r0, r5, #0
add r1, r4, #0
bl NNS_SndArcLoadSeqEx
add r4, r0, #0
bl GF_SndHeapGetFreeSize
add r0, r4, #0
pop {r3, r4, r5, pc}
.balign 4, 0
thumb_func_end GF_Snd_LoadSeqEx
thumb_func_start GF_Snd_LoadWaveArc
GF_Snd_LoadWaveArc: ; 0x020047A8
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
add r1, r0, #0
add r1, #0x94
ldr r1, [r1]
add r0, r4, #0
bl NNS_SndArcLoadWaveArc
add r4, r0, #0
bl GF_SndHeapGetFreeSize
add r0, r4, #0
pop {r4, pc}
.balign 4, 0
thumb_func_end GF_Snd_LoadWaveArc
thumb_func_start GF_Snd_LoadBank
GF_Snd_LoadBank: ; 0x020047C8
push {r4, lr}
add r4, r0, #0
bl GetSoundDataPointer
add r1, r0, #0
add r1, #0x94
ldr r1, [r1]
add r0, r4, #0
bl NNS_SndArcLoadBank
add r4, r0, #0
bl GF_SndHeapGetFreeSize
add r0, r4, #0
pop {r4, pc}
.balign 4, 0
thumb_func_end GF_Snd_LoadBank
thumb_func_start GetSoundPlayer
GetSoundPlayer: ; 0x020047E8
push {r3, r4, r5, lr}
add r5, r0, #0
bl GetSoundDataPointer
add r4, r0, #0
cmp r5, #9
blt _020047FC
bl GF_AssertFail
mov r5, #0
_020047FC:
ldr r0, _02004808 ; =0x000BEB78
add r1, r4, r0
lsl r0, r5, #2
add r0, r1, r0
pop {r3, r4, r5, pc}
nop
_02004808: .word 0x000BEB78
thumb_func_end GetSoundPlayer
thumb_func_start sub_0200480C
sub_0200480C: ; 0x0200480C
push {r3, lr}

View File

@ -3,10 +3,20 @@
typedef struct SND_WORK SND_WORK;
#define SND_HEAP_SIZE 0xBEAE0
#define SND_PLAYER_COUNT 9
SND_WORK *GetSoundDataPointer(void);
u32 GF_SndHeapGetFreeSize(void);
void GF_SndHeapGetFreeSize(void);
void GF_SndSetMonoFlag(int flag);
void DoSoundUpdateFrame(void);
void *GF_SdatGetAttrPtr(u32 attr);
void sub_020043B0(u32 state);
BOOL sub_02005F88(void);
BOOL sub_020059B0(void);
void sub_020048F0(void);
void PlayBGM(u16 seqno);
void sub_02005F10(u32, u32, u32);
u32 GF_SndPlayerCountPlayingSeqByPlayerNo(u32 playerno);
#endif //POKEHEARTGOLD_SOUND_H

View File

@ -16,5 +16,6 @@
#include <nitro/mb.h>
#include <nitro/spi.h>
#include <nitro/snd.h>
#include <nitro/pad.h>
#endif //NITRO_H_

6
lib/include/nitro/pad.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef NITRO_PAD_H_
#define NITRO_PAD_H_
#include <nitro/pad/common/pad.h>
#endif //NITRO_PAD_H_

View File

@ -0,0 +1,38 @@
#ifndef NITRO_PAD_PAD_H_
#define NITRO_PAD_PAD_H_
#include <nitro/hw/io_reg_shared.h>
#define PAD_PLUS_KEY_MASK 0x00f0
#define PAD_BUTTON_MASK 0x2f0f
#define PAD_DEBUG_BUTTON_MASK 0x2000
#define PAD_ALL_MASK 0x2fff
#define PAD_RCNTPORT_MASK 0x2c00
#define PAD_KEYPORT_MASK 0x03ff
#define PAD_DETECT_FOLD_MASK 0x8000
#define PAD_BUTTON_A 0x0001
#define PAD_BUTTON_B 0x0002
#define PAD_BUTTON_SELECT 0x0004
#define PAD_BUTTON_START 0x0008
#define PAD_KEY_RIGHT 0x0010
#define PAD_KEY_LEFT 0x0020
#define PAD_KEY_UP 0x0040
#define PAD_KEY_DOWN 0x0080
#define PAD_BUTTON_R 0x0100
#define PAD_BUTTON_L 0x0200
#define PAD_BUTTON_X 0x0400
#define PAD_BUTTON_Y 0x0800
#define PAD_BUTTON_DEBUG 0x2000
static inline u16 PAD_Read(void) {
return (u16)(((reg_PAD_KEYINPUT | *(vu16 *)HW_BUTTON_XY_BUF) ^
(PAD_PLUS_KEY_MASK | PAD_BUTTON_MASK)) & (PAD_PLUS_KEY_MASK | PAD_BUTTON_MASK));
}
static inline BOOL PAD_DetectFold(void) {
return (BOOL)((*(vu16 *)HW_BUTTON_XY_BUF & PAD_DETECT_FOLD_MASK) >> 15);
}
#endif //NITRO_PAD_PAD_H_

View File

@ -4,6 +4,7 @@
#include <nnsys/snd/heap.h>
#include <nnsys/snd/sndarc.h>
#include <nnsys/snd/player.h>
#include <nnsys/snd/sndarc_loader.h>
#include <nnsys/snd/sndarc_player.h>
#include <nnsys/snd/main.h>

View File

@ -5,6 +5,9 @@ struct NNSSndHeap;
typedef struct NNSSndHeap* NNSSndHeapHandle;
NNSSndHeapHandle NNS_SndHeapCreate(void *buf, u32 maxsize);
int NNS_SndHeapSaveState(NNSSndHeapHandle heap);
int NNS_SndHeapLoadState(NNSSndHeapHandle heap, int level);
u32 NNS_SndHeapGetSize(NNSSndHeapHandle heap);
u32 NNS_SndHeapGetFreeSize(NNSSndHeapHandle heap);
#endif //NNSYS_SND_HEAP_H_

View File

@ -0,0 +1,11 @@
#ifndef NNSYS_SND_SNDARC_LOADER_H_
#define NNSYS_SND_SNDARC_LOADER_H_
BOOL NNS_SndArcLoadGroup(int groupNo, NNSSndHeapHandle heap);
BOOL NNS_SndArcLoadSeq(int seqNo, NNSSndHeapHandle heap);
BOOL NNS_SndArcLoadBank(int bankNo, NNSSndHeapHandle heap);
BOOL NNS_SndArcLoadWaveArc(int waveArcNo, NNSSndHeapHandle heap);
BOOL NNS_SndArcLoadSeqEx(int seqNo, u32 loadFlag, NNSSndHeapHandle heap);
BOOL NNS_SndArcLoadBankEx(int bankNo, u32 loadFlag, NNSSndHeapHandle heap);
#endif //NNSYS_SND_SNDARC_LOADER_H_

View File

@ -9,21 +9,63 @@
struct SND_WORK {
/* 0x00000 */ NNSSndArc arc;
/* 0x00094 */ NNSSndHeapHandle heap;
/* 0x00098 */ u8 heap_buf[0xBEAE0];
/* 0xBEB78 */ u8 unk_BEB78[0x1C];
/* 0xBEB94 */ NNSSndHandle unk_BEB94;
/* 0xBEB98 */ u8 unk_BEB98[0x58];
/* 0x00098 */ u8 heap_buf[SND_HEAP_SIZE];
/* 0xBEB78 */ NNSSndHandle unk_BEB78[SND_PLAYER_COUNT];
/* 0xBEB9C */ u32 unk_BEB9C;
/* 0xBEBA0 */ u32 unk_BEBA0;
/* 0xBEBA4 */ u32 unk_BEBA4;
/* 0xBEBA8 */ u8 unk_BEBA8[0x18];
/* 0xBEBC0 */ u8 unk_BEBC0[16];
/* 0xBEBD0 */ u8 unk_BEBD0[28];
/* 0xBEBEC */ u16 unk_BEBEC;
/* 0xBEBEE */ u8 unk_BEBEE;
/* 0xBEBEF */ u8 unk_BEBEF;
/* 0xBEBF0 */ s32 unk_BEBF0;
/* 0xBEBF4 */ u8 unk_BEBF4[0x48];
/* 0xBEBF4 */ u8 unk_BEBF4[4];
/* 0xBEBF8 */ u32 unk_BEBF8;
/* 0xBEBFC */ u8 unk_BEBFC[2];
/* 0xBEBFE */ u16 unk_BEBFE;
/* 0xBEC00 */ u8 unk_BEC00;
/* 0xBEBC1 */ u8 unk_BEC01;
/* 0xBEC02 */ u16 unk_BEC02;
/* 0xBEC04 */ u8 unk_BEC04;
/* 0xBEC05 */ u8 unk_BEC05;
/* 0xBEC06 */ u8 unk_BEC06;
/* 0xBEC07 */ u8 unk_BEC07;
/* 0xBEC08 */ u8 unk_BEC08;
/* 0xBEC09 */ u8 unk_BEC09;
/* 0xBEC0A */ u8 unk_BEC0A;
/* 0xBEC0B */ u8 unk_BEC0B;
/* 0xBEC0C */ u32 unk_BEC0C;
/* 0xBEC10 */ u32 unk_BEC10;
/* 0xBEC14 */ u32 unk_BEC14;
/* 0xBEC18 */ u32 unk_BEC18;
/* 0xBEC1C */ u32 unk_BEC1C;
/* 0xBEC20 */ u32 unk_BEC20;
/* 0xBEC24 */ u32 unk_BEC24;
/* 0xBEC28 */ u8 unk_BEC28;
/* 0xBEC29 */ u8 unk_BEC29;
/* 0xBEC2A */ u16 unk_BEC2A;
/* 0xBEC2C */ u32 unk_BEC2C;
/* 0xBEC30 */ u8 unk_BEC30[8];
/* 0xBEC38 */ u32 unk_BEC38;
/* 0xBEC3C */ SOUND_CHATOT *chatot;
/* 0xBEC40 */ u8 unk_BEC40[0x10];
/* 0xBEC40 */ u32 unk_BEC40;
/* 0xBEC44 */ u32 unk_BEC44;
/* 0xBEC48 */ u32 unk_BEC48;
/* 0xBEC4C */ u32 unk_BEC4C;
/* 0xBEC50 */ u32 unk_BEC50[2];
/* 0xBEC58 */ u32 unk_BEC58[2];
/* 0xBEC60 */ u32 unk_BEC60[2];
/* 0xBEC68 */ u32 unk_BEC68[2];
/* 0xBEC70 */ u16 unk_BEC70[2];
/* 0xBEC74 */ u8 unk_BEC74[2];
/* 0xBEC76 */ u8 padding_BEC76[10];
/* 0xBEC76 */ u8 unk_BEC76;
/* 0xBEC77 */ u8 unk_BEC77;
/* 0xBEC78 */ u8 unk_BEC78;
/* 0xBEC79 */ u8 unk_BEC79;
/* 0xBEC7A */ u16 unk_BEC7A;
/* 0xBEC7C */ u32 unk_BEC7C;
/* 0xBEC80 */ u32 unk_BEC80_00:1;
/* 0xBEC80 */ u32 unk_BEC80_01:31;
/* 0xBEC84 */ u8 padding_BEC84[4];
@ -59,7 +101,6 @@ void InitSoundData(SOUND_CHATOT *chatot, OPTIONS *options) {
_02111950 = 0;
work->chatot = chatot;
GF_SndSetMonoFlag(options->soundMethod);
(void)_0211194C;
}
void DoSoundUpdateFrame(void) {
@ -80,9 +121,9 @@ void DoSoundUpdateFrame(void) {
sub_02004300();
}
NNS_SndUpdateDriverInfo();
if (gMain.newKeys & 0x2000) {
if (gMain.newKeys & PAD_BUTTON_DEBUG) {
for (i = 0; i < 16; i++) {
NNS_SndPlayerReadDriverTrackInfo(&work->unk_BEB94, i, &sp8);
NNS_SndPlayerReadDriverTrackInfo(&work->unk_BEB78[7], i, &sp8);
NNS_SndReadDriverChannelInfo(i, &sp24);
}
}
@ -100,3 +141,284 @@ void DoSoundUpdateFrame(void) {
}
NNS_SndMain();
}
void sub_02004300(void) {
SND_WORK *work;
work = GetSoundDataPointer();
switch (_0211194C) {
case 1:
sub_020043B0(2);
break;
case 3:
if (!sub_02005F88()) {
sub_020043B0(2);
}
break;
case 4:
if (!sub_02005F88()) {
sub_020043B0(2);
}
break;
case 5:
if (!sub_02005F88() && !sub_020059B0()) {
sub_020048F0();
if (work->unk_BEBFE != 0) {
PlayBGM(work->unk_BEBFE);
}
}
break;
case 6:
if (!sub_02005F88() && !sub_020059B0()) {
sub_020048F0();
if (work->unk_BEBFE != 0) {
PlayBGM(work->unk_BEBFE);
}
sub_02005F10(0x7F, work->unk_BEBF8, 0);
}
break;
}
}
void sub_020043B0(u32 state) {
SND_WORK *work;
work = GetSoundDataPointer();
work->unk_BEBEC = 0;
_0211194C = state;
}
BOOL sub_020043CC(void) {
SND_WORK *work;
work = GetSoundDataPointer();
if (GF_SndPlayerCountPlayingSeqByPlayerNo(2) != 0) {
return TRUE;
}
if (work->unk_BEC02 != 0) {
return TRUE;
}
return FALSE;
}
SND_WORK *GetSoundDataPointer(void) {
return &sSoundWork;
}
void *GF_SdatGetAttrPtr(u32 attr) {
SND_WORK *work;
work = GetSoundDataPointer();
switch (attr) {
case 5:
return &work->unk_BEBEE;
case 6:
return &work->unk_BEBEF;
case 0:
return &work->unk_BEB9C;
case 1:
return &work->unk_BEBA0;
case 2:
return &work->unk_BEBA4;
case 3:
return &work->unk_BEBC0;
case 4:
return &work->unk_BEBD0;
case 7:
return &work->unk_BEBF0;
case 8:
return &work->unk_BEBF4;
case 9:
return &work->unk_BEBF8;
case 10:
return &work->unk_BEBFC;
case 11:
return &work->unk_BEBFE;
case 12:
return &work->unk_BEC00;
case 13:
return &work->unk_BEC01;
case 14:
return &work->unk_BEC02;
case 15:
return &work->unk_BEC04;
case 16:
return &work->unk_BEC05;
case 17:
return &work->unk_BEC06;
case 18:
return &work->unk_BEC07;
case 19:
return &work->unk_BEC08;
case 20:
return &work->unk_BEC09;
case 21:
return &work->unk_BEC0A;
case 22:
return &work->unk_BEC0B;
case 23:
return &work->unk_BEC0C;
case 24:
return &work->unk_BEC10;
case 25:
return &work->unk_BEC14;
case 26:
return &work->unk_BEC18;
case 27:
return &work->unk_BEC1C;
case 28:
return &work->unk_BEC20;
case 29:
return &work->unk_BEC24;
case 30:
return &work->unk_BEC28;
case 31:
return &work->unk_BEC29;
case 32:
return &work->unk_BEC2A;
case 33:
return &work->unk_BEC2C;
case 34:
return &work->unk_BEC30;
case 35:
return &work->unk_BEC38;
case 36:
return &work->chatot;
case 37:
return &work->unk_BEC40;
case 38:
return &work->unk_BEC44;
case 39:
return &work->unk_BEC48;
case 40:
return &work->unk_BEC4C;
case 41:
return &work->unk_BEC50[0];
case 42:
return &work->unk_BEC58[0];
case 43:
return &work->unk_BEC60[0];
case 44:
return &work->unk_BEC68[0];
case 45:
return &work->unk_BEC70[0];
case 46:
return &work->unk_BEC74[0];
case 47:
return &work->unk_BEC50[1];
case 48:
return &work->unk_BEC58[1];
case 49:
return &work->unk_BEC60[1];
case 50:
return &work->unk_BEC68[1];
case 51:
return &work->unk_BEC70[1];
case 52:
return &work->unk_BEC74[1];
case 53:
return &work->unk_BEC76;
case 54:
return &work->unk_BEC77;
case 55:
return &work->unk_BEC78;
case 56:
return &work->unk_BEC79;
case 57:
return &work->unk_BEC7A;
case 58:
return &work->unk_BEC7C;
}
GF_ASSERT(0);
return NULL;
}
int GF_Snd_SaveState(int *level_p) {
SND_WORK *work;
int level;
work = GetSoundDataPointer();
level = NNS_SndHeapSaveState(work->heap);
GF_ASSERT(level != -1);
if (level_p != NULL) {
*level_p = level;
}
GF_SndHeapGetFreeSize();
return level;
}
void GF_Snd_LoadState(int level) {
SND_WORK *work;
work = GetSoundDataPointer();
NNS_SndHeapLoadState(work->heap, level);
GF_SndHeapGetFreeSize();
}
void GF_SndHeapGetFreeSize(void) {
SND_WORK *work;
work = GetSoundDataPointer();
sSndHeapFreeSize = NNS_SndHeapGetFreeSize(work->heap);
}
BOOL GF_Snd_LoadGroup(int groupNo) {
BOOL ret;
SND_WORK *work;
work = GetSoundDataPointer();
ret = NNS_SndArcLoadGroup(groupNo, work->heap);
GF_SndHeapGetFreeSize();
return ret;
}
BOOL GF_Snd_LoadSeq(int seqNo) {
BOOL ret;
SND_WORK *work;
work = GetSoundDataPointer();
ret = NNS_SndArcLoadSeq(seqNo, work->heap);
GF_SndHeapGetFreeSize();
return ret;
}
BOOL GF_Snd_LoadSeqEx(int seqNo, u32 loadFlag) {
BOOL ret;
SND_WORK *work;
work = GetSoundDataPointer();
ret = NNS_SndArcLoadSeqEx(seqNo, loadFlag, work->heap);
GF_SndHeapGetFreeSize();
return ret;
}
BOOL GF_Snd_LoadWaveArc(int waveArcNo) {
BOOL ret;
SND_WORK *work;
work = GetSoundDataPointer();
ret = NNS_SndArcLoadWaveArc(waveArcNo, work->heap);
GF_SndHeapGetFreeSize();
return ret;
}
BOOL GF_Snd_LoadBank(int bankNo) {
BOOL ret;
SND_WORK *work;
work = GetSoundDataPointer();
ret = NNS_SndArcLoadBank(bankNo, work->heap);
GF_SndHeapGetFreeSize();
return ret;
}
NNSSndHandle *GetSoundPlayer(int playerNo) {
SND_WORK *work;
work = GetSoundDataPointer();
if (playerNo >= SND_PLAYER_COUNT) {
GF_ASSERT(0);
playerNo = 0;
}
return &work->unk_BEB78[playerNo];
}