subge r0, r0, #1
movge r3, #EG_OFF
strgeb r3, [r5,#0x17] @ state
+ ldrh r3, [r5,#0x18] @ tl
+ b 11f
10: @ finish
ldrb r2, [r5,#0x30] @ ssg
- ldrb r3, [r5,#0x17] @ state
- strh r0, [r5,#0x1a] @ volume
- cmp r2, #0x0c @ if ( ssg&0x04 && state > EG_REL )
- cmpge r3, #EG_REL+1
ldrh r3, [r5,#0x18] @ tl
- rsbge r0, r0, #0x200 @ volume = (0x200-volume) & MAX_ATT
- movge r0, r0, lsl #22
- movge r0, r0, lsr #22
+ strh r0, [r5,#0x1a] @ volume
+ recalc_volume_ssg r0 r2
11:
-#endif
add r0, r0, r3 @ volume += tl
strh r0, [r5,#0x34] @ vol_out
+#endif
0: @ EG_OFF
.endm
9:
ldrb r0, [r5,#0x30] @ ssg
ldrh r2, [r5,#0x18] @ tl
- cmp r0, #0x0c
- rsbge r3, r3, #0x200 @ volume = (0x200-volume) & MAX_ATT
- movge r3, r3, lsl #22
- movge r3, r3, lsr #22
+ recalc_volume_ssg r3 r0
add r3, r3, r2 @ volume += tl
strh r3, [r5,#0x34] @ vol_out
10:
.endm
-@ r5=slot, trashes: r0,r2,r3
-.macro recalc_volout
- ldrb r2, [r5,#0x30] @ ssg
- ldrb r3, [r5,#0x17] @ state
- ldrh r0, [r5,#0x1a] @ volume
-
-@ and r2, r2, #0x0c
- cmp r2, #0x0c @ if ( ~ssg&0x0c && state > EG_REL )
- cmpge r3, #EG_REL+1
- ldrh r3, [r5,#0x18] @ tl
- rsbge r0, r0, #0x200 @ volume = (0x200-volume) & MAX_ATT
- movge r0, r0, lsl #22
- movge r0, r0, lsr #22
-
- add r0, r0, r3 @ volume += tl
- strh r0, [r5,#0x34] @ vol_out
+@ r5=slot
+.macro recalc_volume_ssg vol ssg
+@ and \ssg, \ssg, #0x0c
+ cmp \ssg, #0x0c @ if (~ssg&0x0c)
+ rsbge \vol, \vol, #0x200 @ volume = (0x200-volume) & MAX_ATT
+ movge \vol, \vol, lsl #22
+ movge \vol, \vol, lsr #22
.endm
#endif
@ use lr as a pointer to the slot phases stored in the context
update_ssg_eg
#if 0
+ tst r6, #1
+ addeq lr, lr, #2*4
+ subne lr, lr, #4
subs r6, r6, #1
- addne lr, lr, #4
+ addeq lr, lr, #4
addne r5, r5, #SLOT_STRUCT_SIZE
#else
add lr, lr, #4