summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/m4a.c319
-rw-r--r--src/m4a_1.s440
2 files changed, 375 insertions, 384 deletions
diff --git a/src/m4a.c b/src/m4a.c
index f061ba9b9..e079ba4f6 100644
--- a/src/m4a.c
+++ b/src/m4a.c
@@ -10,7 +10,7 @@ BSS_CODE ALIGNED(4) char SoundMainRAM_Buffer[0x800] = {0};
struct SoundInfo gSoundInfo;
struct PokemonCrySong gPokemonCrySongs[MAX_POKEMON_CRIES];
struct MusicPlayerInfo gPokemonCryMusicPlayers[MAX_POKEMON_CRIES];
-void *gMPlayJumpTable[36];
+MPlayFunc gMPlayJumpTable[36];
struct CgbChannel gCgbChans[4];
struct MusicPlayerTrack gPokemonCryTracks[MAX_POKEMON_CRIES * 2];
struct PokemonCrySong gPokemonCrySong;
@@ -293,7 +293,7 @@ void MPlayExtender(struct CgbChannel *cgbChans)
gMPlayJumpTable[32] = FadeOutBody;
gMPlayJumpTable[33] = TrkVolPitSet;
- soundInfo->cgbChans = (struct CgbChannel *)cgbChans;
+ soundInfo->cgbChans = cgbChans;
soundInfo->CgbSound = CgbSound;
soundInfo->CgbOscOff = CgbOscOff;
soundInfo->MidiKeyToCgbFreq = MidiKeyToCgbFreq;
@@ -301,13 +301,13 @@ void MPlayExtender(struct CgbChannel *cgbChans)
CpuFill32(0, cgbChans, sizeof(struct CgbChannel) * 4);
- cgbChans[0].ty = 1;
+ cgbChans[0].type = 1;
cgbChans[0].panMask = 0x11;
- cgbChans[1].ty = 2;
+ cgbChans[1].type = 2;
cgbChans[1].panMask = 0x22;
- cgbChans[2].ty = 3;
+ cgbChans[2].type = 3;
cgbChans[2].panMask = 0x44;
- cgbChans[3].ty = 4;
+ cgbChans[3].type = 4;
cgbChans[3].panMask = 0x88;
soundInfo->ident = ident;
@@ -362,15 +362,15 @@ void SoundInit(struct SoundInfo *soundInfo)
soundInfo->maxChans = 8;
soundInfo->masterVolume = 15;
- soundInfo->plynote = (u32)ply_note;
+ soundInfo->plynote = ply_note;
soundInfo->CgbSound = DummyFunc;
- soundInfo->CgbOscOff = (void (*)(u8))DummyFunc;
- soundInfo->MidiKeyToCgbFreq = (u32 (*)(u8, u8, u8))DummyFunc;
- soundInfo->ExtVolPit = (u32)DummyFunc;
+ soundInfo->CgbOscOff = (CgbOscOffFunc)DummyFunc;
+ soundInfo->MidiKeyToCgbFreq = (MidiKeyToCgbFreqFunc)DummyFunc;
+ soundInfo->ExtVolPit = (ExtVolPitFunc)DummyFunc;
MPlayJumpTableCopy(gMPlayJumpTable);
- soundInfo->MPlayJumpTable = (u32)gMPlayJumpTable;
+ soundInfo->MPlayJumpTable = gMPlayJumpTable;
SampleFreqSet(SOUND_MODE_FREQ_13379);
@@ -437,7 +437,7 @@ void m4aSoundMode(u32 mode)
while (temp != 0)
{
- chan->status = 0;
+ chan->statusFlags = 0;
temp--;
chan++;
}
@@ -483,7 +483,7 @@ void SoundClear(void)
while (i > 0)
{
- ((struct SoundChannel *)chan)->status = 0;
+ ((struct SoundChannel *)chan)->statusFlags = 0;
i--;
chan = (void *)((s32)chan + sizeof(struct SoundChannel));
}
@@ -497,7 +497,7 @@ void SoundClear(void)
while (i <= 4)
{
soundInfo->CgbOscOff(i);
- ((struct CgbChannel *)chan)->sf = 0;
+ ((struct CgbChannel *)chan)->statusFlags = 0;
i++;
chan = (void *)((s32)chan + sizeof(struct CgbChannel));
}
@@ -572,15 +572,18 @@ void MPlayOpen(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track
tracks++;
}
- if (soundInfo->func != 0)
+ // append music player and MPlayMain to linked list
+
+ if (soundInfo->MPlayMainHead != NULL)
{
- mplayInfo->func = soundInfo->func;
- mplayInfo->intp = soundInfo->intp;
- soundInfo->func = 0;
+ mplayInfo->MPlayMainNext = soundInfo->MPlayMainHead;
+ mplayInfo->musicPlayerNext = soundInfo->musicPlayerHead;
+ // NULL assignment semantically useless, but required for match
+ soundInfo->MPlayMainHead = NULL;
}
- soundInfo->intp = (u32)mplayInfo;
- soundInfo->func = (u32)MPlayMain;
+ soundInfo->musicPlayerHead = mplayInfo;
+ soundInfo->MPlayMainHead = MPlayMain;
soundInfo->ident = ID_NUMBER;
mplayInfo->ident = ID_NUMBER;
}
@@ -884,7 +887,7 @@ void CgbModVol(struct CgbChannel *chan)
if ((soundInfo->mode & 1) || !CgbPan(chan))
{
chan->pan = 0xFF;
- chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
+ chan->envelopeGoal = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
}
else
{
@@ -895,12 +898,12 @@ void CgbModVol(struct CgbChannel *chan)
asm("" : : : "memory");
#endif
- chan->eg = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
- if (chan->eg > 15)
- chan->eg = 15;
+ chan->envelopeGoal = (u32)(chan->rightVolume + chan->leftVolume) >> 4;
+ if (chan->envelopeGoal > 15)
+ chan->envelopeGoal = 15;
}
- chan->sg = (chan->eg * chan->su + 15) >> 4;
+ chan->sustainGoal = (chan->envelopeGoal * chan->sustain + 15) >> 4;
chan->pan &= chan->panMask;
}
@@ -908,7 +911,7 @@ void CgbSound(void)
{
s32 ch;
struct CgbChannel *channels;
- s32 evAdd;
+ s32 envelopeStepTimeAndDir;
s32 prevC15;
struct SoundInfo *soundInfo = SOUND_INFO_PTR;
vu8 *nrx0ptr;
@@ -927,9 +930,10 @@ void CgbSound(void)
for (ch = 1, channels = soundInfo->cgbChans; ch <= 4; ch++, channels++)
{
- if (!(channels->sf & 0xc7))
+ if (!(channels->statusFlags & SOUND_CHANNEL_SF_ON))
continue;
+ /* 1. determine hardware channel registers */
switch (ch)
{
case 1:
@@ -963,243 +967,233 @@ void CgbSound(void)
}
prevC15 = soundInfo->c15;
- evAdd = *nrx2ptr;
+ envelopeStepTimeAndDir = *nrx2ptr;
- if (channels->sf & 0x80)
+ /* 2. calculate envelope volume */
+ if (channels->statusFlags & SOUND_CHANNEL_SF_START)
{
- if (!(channels->sf & 0x40))
+ if (!(channels->statusFlags & SOUND_CHANNEL_SF_STOP))
{
- channels->sf = 3;
- channels->mo = 3;
+ channels->statusFlags = SOUND_CHANNEL_SF_ENV_ATTACK;
+ channels->modify = CGB_CHANNEL_MO_PIT | CGB_CHANNEL_MO_VOL;
CgbModVol(channels);
switch (ch)
{
case 1:
- *nrx0ptr = channels->sw;
+ *nrx0ptr = channels->sweep;
// fallthrough
case 2:
- *nrx1ptr = ((u32)channels->wp << 6) + channels->le;
- goto loc_82E0E30;
+ *nrx1ptr = ((u32)channels->wavePointer << 6) + channels->length;
+ goto init_env_step_time_dir;
case 3:
- if ((u32)channels->wp != channels->cp)
+ if (channels->wavePointer != channels->currentPointer)
{
*nrx0ptr = 0x40;
- REG_WAVE_RAM0 = channels->wp[0];
- REG_WAVE_RAM1 = channels->wp[1];
- REG_WAVE_RAM2 = channels->wp[2];
- REG_WAVE_RAM3 = channels->wp[3];
- channels->cp = (u32)channels->wp;
+ REG_WAVE_RAM0 = channels->wavePointer[0];
+ REG_WAVE_RAM1 = channels->wavePointer[1];
+ REG_WAVE_RAM2 = channels->wavePointer[2];
+ REG_WAVE_RAM3 = channels->wavePointer[3];
+ channels->currentPointer = channels->wavePointer;
}
*nrx0ptr = 0;
- *nrx1ptr = channels->le;
- if (channels->le)
- channels->n4 = -64;
+ *nrx1ptr = channels->length;
+ if (channels->length)
+ channels->n4 = 0xC0;
else
- channels->n4 = -128;
+ channels->n4 = 0x80;
break;
default:
- *nrx1ptr = channels->le;
- *nrx3ptr = (u32)channels->wp << 3;
- loc_82E0E30:
- evAdd = channels->at + 8;
- if (channels->le)
- channels->n4 = 64;
+ *nrx1ptr = channels->length;
+ *nrx3ptr = (u32)channels->wavePointer << 3;
+ init_env_step_time_dir:
+ envelopeStepTimeAndDir = channels->attack + CGB_NRx2_ENV_DIR_INC;
+ if (channels->length)
+ channels->n4 = 0x40;
else
- channels->n4 = 0;
+ channels->n4 = 0x00;
break;
}
- channels->ec = channels->at;
- if ((s8)(channels->at & mask))
+ channels->envelopeCounter = channels->attack;
+ if ((s8)(channels->attack & mask))
{
- channels->ev = 0;
- goto EC_MINUS;
+ channels->envelopeVolume = 0;
+ goto envelope_step_complete;
}
else
{
- goto loc_82E0F96;
+ // skip attack phase if attack is instantaneous (=0)
+ goto envelope_decay_start;
}
}
else
{
- goto loc_82E0E82;
+ goto oscillator_off;
}
}
- else if (channels->sf & 0x04)
+ else if (channels->statusFlags & SOUND_CHANNEL_SF_IEC)
{
- channels->echoLength--;
- if ((s8)(channels->echoLength & mask) <= 0)
+ channels->pseudoEchoLength--;
+ if ((s8)(channels->pseudoEchoLength & mask) <= 0)
{
- loc_82E0E82:
+ oscillator_off:
CgbOscOff(ch);
- channels->sf = 0;
- goto LAST_LABEL;
+ channels->statusFlags = 0;
+ goto channel_complete;
}
- goto loc_82E0FD6;
+ goto envelope_complete;
}
- else if ((channels->sf & 0x40) && (channels->sf & 0x03))
+ else if ((channels->statusFlags & SOUND_CHANNEL_SF_STOP) && (channels->statusFlags & SOUND_CHANNEL_SF_ENV))
{
- channels->sf &= 0xfc;
- channels->ec = channels->re;
- if ((s8)(channels->re & mask))
+ channels->statusFlags &= ~SOUND_CHANNEL_SF_ENV;
+ channels->envelopeCounter = channels->release;
+ if ((s8)(channels->release & mask))
{
- channels->mo |= 1;
+ channels->modify |= CGB_CHANNEL_MO_VOL;
if (ch != 3)
- {
- evAdd = channels->re;
- }
- goto EC_MINUS;
+ envelopeStepTimeAndDir = channels->release | CGB_NRx2_ENV_DIR_DEC;
+ goto envelope_step_complete;
}
else
{
- goto loc_82E0F02;
+ goto envelope_pseudoecho_start;
}
}
else
{
- loc_82E0ED0:
- if (channels->ec == 0)
+ envelope_step_repeat:
+ if (channels->envelopeCounter == 0)
{
if (ch == 3)
- {
- channels->mo |= 1;
- }
+ channels->modify |= CGB_CHANNEL_MO_VOL;
+
CgbModVol(channels);
- if ((channels->sf & 0x3) == 0)
+ if ((channels->statusFlags & SOUND_CHANNEL_SF_ENV) == SOUND_CHANNEL_SF_ENV_RELEASE)
{
- channels->ev--;
- if ((s8)(channels->ev & mask) <= 0)
+ channels->envelopeVolume--;
+ if ((s8)(channels->envelopeVolume & mask) <= 0)
{
- loc_82E0F02:
- channels->ev = ((channels->eg * channels->echoVolume) + 0xFF) >> 8;
- if (channels->ev)
+ envelope_pseudoecho_start:
+ channels->envelopeVolume = ((channels->envelopeGoal * channels->pseudoEchoVolume) + 0xFF) >> 8;
+ if (channels->envelopeVolume)
{
- channels->sf |= 0x4;
- channels->mo |= 1;
+ channels->statusFlags |= SOUND_CHANNEL_SF_IEC;
+ channels->modify |= CGB_CHANNEL_MO_VOL;
if (ch != 3)
- {
- evAdd = 8;
- }
- goto loc_82E0FD6;
+ envelopeStepTimeAndDir = 0 | CGB_NRx2_ENV_DIR_INC;
+ goto envelope_complete;
}
else
{
- goto loc_82E0E82;
+ goto oscillator_off;
}
}
else
{
- channels->ec = channels->re;
+ channels->envelopeCounter = channels->release;
}
}
- else if ((channels->sf & 0x3) == 1)
+ else if ((channels->statusFlags & SOUND_CHANNEL_SF_ENV) == SOUND_CHANNEL_SF_ENV_SUSTAIN)
{
- loc_82E0F3A:
- channels->ev = channels->sg;
- channels->ec = 7;
+ envelope_sustain:
+ channels->envelopeVolume = channels->sustainGoal;
+ channels->envelopeCounter = 7;
}
- else if ((channels->sf & 0x3) == 2)
+ else if ((channels->statusFlags & SOUND_CHANNEL_SF_ENV) == SOUND_CHANNEL_SF_ENV_DECAY)
{
- int ev, sg;
+ int envelopeVolume, sustainGoal;
- channels->ev--;
- ev = (s8)(channels->ev & mask);
- sg = (s8)(channels->sg);
- if (ev <= sg)
+ channels->envelopeVolume--;
+ envelopeVolume = (s8)(channels->envelopeVolume & mask);
+ sustainGoal = (s8)(channels->sustainGoal);
+ if (envelopeVolume <= sustainGoal)
{
- loc_82E0F5A:
- if (channels->su == 0)
+ envelope_sustain_start:
+ if (channels->sustain == 0)
{
- channels->sf &= 0xfc;
- goto loc_82E0F02;
+ channels->statusFlags &= ~SOUND_CHANNEL_SF_ENV;
+ goto envelope_pseudoecho_start;
}
else
{
- channels->sf--;
- channels->mo |= 1;
+ channels->statusFlags--;
+ channels->modify |= CGB_CHANNEL_MO_VOL;
if (ch != 3)
- {
- evAdd = 8;
- }
- goto loc_82E0F3A;
+ envelopeStepTimeAndDir = 0 | CGB_NRx2_ENV_DIR_INC;
+ goto envelope_sustain;
}
}
else
{
- channels->ec = channels->de;
+ channels->envelopeCounter = channels->decay;
}
}
else
{
- channels->ev++;
- if ((u8)(channels->ev & mask) >= channels->eg)
+ channels->envelopeVolume++;
+ if ((u8)(channels->envelopeVolume & mask) >= channels->envelopeGoal)
{
- loc_82E0F96:
- channels->sf--;
- channels->ec = channels->de;
- if ((u8)(channels->ec & mask))
+ envelope_decay_start:
+ channels->statusFlags--;
+ channels->envelopeCounter = channels->decay;
+ if ((u8)(channels->envelopeCounter & mask))
{
- channels->mo |= 1;
- channels->ev = channels->eg;
+ channels->modify |= CGB_CHANNEL_MO_VOL;
+ channels->envelopeVolume = channels->envelopeGoal;
if (ch != 3)
- {
- evAdd = channels->de;
- }
+ envelopeStepTimeAndDir = channels->decay | CGB_NRx2_ENV_DIR_DEC;
}
else
{
- goto loc_82E0F5A;
+ goto envelope_sustain_start;
}
}
else
{
- channels->ec = channels->at;
+ channels->envelopeCounter = channels->attack;
}
}
}
}
- EC_MINUS:
- channels->ec--;
+ envelope_step_complete:
+ // every 15 frames, envelope calculation has to be done twice
+ // to keep up with the hardware envelope rate (1/64 s)
+ channels->envelopeCounter--;
if (prevC15 == 0)
{
prevC15--;
- goto loc_82E0ED0;
+ goto envelope_step_repeat;
}
- loc_82E0FD6:
- if (channels->mo & 0x2)
+ envelope_complete:
+ /* 3. apply pitch to HW registers */
+ if (channels->modify & CGB_CHANNEL_MO_PIT)
{
- if (ch < 4 && (channels->ty & 0x08))
+ if (ch < 4 && (channels->type & TONEDATA_TYPE_FIX))
{
- int biasH = REG_SOUNDBIAS_H;
+ int dac_pwm_rate = REG_SOUNDBIAS_H;
- if (biasH < 64)
- {
- channels->fr = (channels->fr + 2) & 0x7fc;
- }
- else if (biasH < 128)
- {
- channels->fr = (channels->fr + 1) & 0x7fe;
- }
+ if (dac_pwm_rate < 0x40) // if PWM rate = 32768 Hz
+ channels->frequency = (channels->frequency + 2) & 0x7fc;
+ else if (dac_pwm_rate < 0x80) // if PWM rate = 65536 Hz
+ channels->frequency = (channels->frequency + 1) & 0x7fe;
}
+
if (ch != 4)
- {
- *nrx3ptr = channels->fr;
- }
+ *nrx3ptr = channels->frequency;
else
- {
- *nrx3ptr = (*nrx3ptr & 0x08) | channels->fr;
- }
- channels->n4 = (channels->n4 & 0xC0) + (*((u8*)(&channels->fr) + 1));
+ *nrx3ptr = (*nrx3ptr & 0x08) | channels->frequency;
+ channels->n4 = (channels->n4 & 0xC0) + (*((u8*)(&channels->frequency) + 1));
*nrx4ptr = (s8)(channels->n4 & mask);
}
- if (channels->mo & 1)
+ /* 4. apply envelope & volume to HW registers */
+ if (channels->modify & CGB_CHANNEL_MO_VOL)
{
REG_NR51 = (REG_NR51 & ~channels->panMask) | channels->pan;
if (ch == 3)
{
- *nrx2ptr = gCgb3Vol[channels->ev];
+ *nrx2ptr = gCgb3Vol[channels->envelopeVolume];
if (channels->n4 & 0x80)
{
*nrx0ptr = 0x80;
@@ -1209,18 +1203,16 @@ void CgbSound(void)
}
else
{
- evAdd &= 0xf;
- *nrx2ptr = (channels->ev << 4) + evAdd;
+ envelopeStepTimeAndDir &= 0xf;
+ *nrx2ptr = (channels->envelopeVolume << 4) + envelopeStepTimeAndDir;
*nrx4ptr = channels->n4 | 0x80;
if (ch == 1 && !(*nrx0ptr & 0x08))
- {
*nrx4ptr = channels->n4 | 0x80;
- }
}
}
- LAST_LABEL:
- channels->mo = 0;
+ channel_complete:
+ channels->modify = 0;
}
}
@@ -1504,8 +1496,8 @@ void ply_memacc(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *trac
cond_true:
{
- void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[1]);
- func(mplayInfo, track);
+ // *& is required for matching
+ (*&gMPlayJumpTable[1])(mplayInfo, track);
return;
}
@@ -1523,8 +1515,7 @@ void ply_xcmd(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
void ply_xxx(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
- void (*func)(struct MusicPlayerInfo *, struct MusicPlayerTrack *) = *(&gMPlayJumpTable[0]);
- func(mplayInfo, track);
+ gMPlayJumpTable[0](mplayInfo, track);
}
#define READ_XCMD_BYTE(var, n) \
@@ -1580,13 +1571,13 @@ void ply_xrele(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track
void ply_xiecv(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
- track->echoVolume = *track->cmdPtr;
+ track->pseudoEchoVolume = *track->cmdPtr;
track->cmdPtr++;
}
void ply_xiecl(struct MusicPlayerInfo *mplayInfo, struct MusicPlayerTrack *track)
{
- track->echoLength = *track->cmdPtr;
+ track->pseudoEchoLength = *track->cmdPtr;
track->cmdPtr++;
}
diff --git a/src/m4a_1.s b/src/m4a_1.s
index cab4ed174..d72336c18 100644
--- a/src/m4a_1.s
+++ b/src/m4a_1.s
@@ -48,10 +48,10 @@ SoundMain_2:
adds r1, r2
SoundMain_3:
str r1, [sp, 0x14]
- ldr r3, [r0, o_SoundInfo_func]
+ ldr r3, [r0, o_SoundInfo_MPlayMainHead]
cmp r3, 0
beq SoundMain_4
- ldr r0, [r0, o_SoundInfo_intp]
+ ldr r0, [r0, o_SoundInfo_musicPlayerHead]
bl _081DD25E
ldr r0, [sp, 0x18]
SoundMain_4:
@@ -169,74 +169,74 @@ _081DCF54:
.pool
_081DCF60:
- ldrb r6, [r4, o_SoundChannel_status]
- movs r0, 0xC7
+ ldrb r6, [r4, o_SoundChannel_statusFlags]
+ movs r0, SOUND_CHANNEL_SF_ON
tst r0, r6
bne _081DCF6A
b _081DD240
_081DCF6A:
- movs r0, 0x80
+ movs r0, SOUND_CHANNEL_SF_START
tst r0, r6
beq _081DCFA0
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
tst r0, r6
bne _081DCFB0
- movs r6, 0x3
- strb r6, [r4, o_SoundChannel_status]
+ movs r6, SOUND_CHANNEL_SF_ENV_ATTACK
+ strb r6, [r4, o_SoundChannel_statusFlags]
adds r0, r3, 0
- adds r0, 0x10
- ldr r1, [r4, o_SoundChannel_ct]
+ adds r0, o_WaveData_data
+ ldr r1, [r4, o_SoundChannel_count]
adds r0, r1
- str r0, [r4, o_SoundChannel_cp]
- ldr r0, [r3, 0xC]
+ str r0, [r4, o_SoundChannel_currentPointer]
+ ldr r0, [r3, o_WaveData_size]
subs r0, r1
- str r0, [r4, o_SoundChannel_ct]
+ str r0, [r4, o_SoundChannel_count]
movs r5, 0
- strb r5, [r4, o_SoundChannel_ev]
+ strb r5, [r4, o_SoundChannel_envelopeVolume]
str r5, [r4, o_SoundChannel_fw]
- ldrb r2, [r3, 0x3]
- movs r0, 0xC0
+ ldrb r2, [r3, o_WaveData_flags]
+ movs r0, WAVE_DATA_FLAG_LOOP
tst r0, r2
beq _081DCFF8
- movs r0, 0x10
+ movs r0, SOUND_CHANNEL_SF_LOOP
orrs r6, r0
- strb r6, [r4, o_SoundChannel_status]
+ strb r6, [r4, o_SoundChannel_statusFlags]
b _081DCFF8
_081DCFA0:
- ldrb r5, [r4, o_SoundChannel_ev]
- movs r0, 0x4
+ ldrb r5, [r4, o_SoundChannel_envelopeVolume]
+ movs r0, SOUND_CHANNEL_SF_IEC
tst r0, r6
beq _081DCFB6
- ldrb r0, [r4, o_SoundChannel_iel]
+ ldrb r0, [r4, o_SoundChannel_pseudoEchoLength]
subs r0, 1
- strb r0, [r4, o_SoundChannel_iel]
+ strb r0, [r4, o_SoundChannel_pseudoEchoLength]
bhi _081DD006
_081DCFB0:
movs r0, 0
- strb r0, [r4, o_SoundChannel_status]
+ strb r0, [r4, o_SoundChannel_statusFlags]
b _081DD240
_081DCFB6:
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
tst r0, r6
beq _081DCFD6
ldrb r0, [r4, o_SoundChannel_release]
muls r5, r0
lsrs r5, 8
- ldrb r0, [r4, o_SoundChannel_iev]
+ ldrb r0, [r4, o_SoundChannel_pseudoEchoVolume]
cmp r5, r0
bhi _081DD006
_081DCFC8:
- ldrb r5, [r4, o_SoundChannel_iev]
+ ldrb r5, [r4, o_SoundChannel_pseudoEchoVolume]
cmp r5, 0
beq _081DCFB0
- movs r0, 0x4
+ movs r0, SOUND_CHANNEL_SF_IEC
orrs r6, r0
- strb r6, [r4, o_SoundChannel_status]
+ strb r6, [r4, o_SoundChannel_statusFlags]
b _081DD006
_081DCFD6:
- movs r2, 0x3
+ movs r2, SOUND_CHANNEL_SF_ENV
ands r2, r6
- cmp r2, 0x2
+ cmp r2, SOUND_CHANNEL_SF_ENV_DECAY
bne _081DCFF4
ldrb r0, [r4, o_SoundChannel_decay]
muls r5, r0
@@ -247,10 +247,10 @@ _081DCFD6:
adds r5, r0, 0
beq _081DCFC8
subs r6, 0x1
- strb r6, [r4, o_SoundChannel_status]
+ strb r6, [r4, o_SoundChannel_statusFlags]
b _081DD006
_081DCFF4:
- cmp r2, 0x3
+ cmp r2, SOUND_CHANNEL_SF_ENV_ATTACK
bne _081DD006
_081DCFF8:
ldrb r0, [r4, o_SoundChannel_attack]
@@ -259,9 +259,9 @@ _081DCFF8:
bcc _081DD006
movs r5, 0xFF
subs r6, 0x1
- strb r6, [r4, o_SoundChannel_status]
+ strb r6, [r4, o_SoundChannel_statusFlags]
_081DD006:
- strb r5, [r4, o_SoundChannel_ev]
+ strb r5, [r4, o_SoundChannel_envelopeVolume]
ldr r0, [sp, 0x18]
ldrb r0, [r0, o_SoundChannel_release]
adds r0, 0x1
@@ -270,37 +270,37 @@ _081DD006:
ldrb r0, [r4, o_SoundChannel_rightVolume]
muls r0, r5
lsrs r0, 8
- strb r0, [r4, o_SoundChannel_er]
+ strb r0, [r4, o_SoundChannel_envelopeVolumeRight]
ldrb r0, [r4, o_SoundChannel_leftVolume]
muls r0, r5
lsrs r0, 8
- strb r0, [r4, o_SoundChannel_el]
- movs r0, 0x10
+ strb r0, [r4, o_SoundChannel_envelopeVolumeLeft]
+ movs r0, SOUND_CHANNEL_SF_LOOP
ands r0, r6
str r0, [sp, 0x10]
beq _081DD03A
adds r0, r3, 0
- adds r0, 0x10
- ldr r1, [r3, 0x8]
+ adds r0, o_WaveData_data
+ ldr r1, [r3, o_WaveData_loopStart]
adds r0, r1
str r0, [sp, 0xC]
- ldr r0, [r3, 0xC]
+ ldr r0, [r3, o_WaveData_size]
subs r0, r1
str r0, [sp, 0x10]
_081DD03A:
ldr r5, [sp, 0x8]
- ldr r2, [r4, o_SoundChannel_ct]
- ldr r3, [r4, o_SoundChannel_cp]
+ ldr r2, [r4, o_SoundChannel_count]
+ ldr r3, [r4, o_SoundChannel_currentPointer]
adr r0, _081DD044
bx r0
.arm
_081DD044:
str r8, [sp]
ldr r9, [r4, o_SoundChannel_fw]
- ldrb r10, [r4, o_SoundChannel_er]
- ldrb r11, [r4, o_SoundChannel_el]
+ ldrb r10, [r4, o_SoundChannel_envelopeVolumeRight]
+ ldrb r11, [r4, o_SoundChannel_envelopeVolumeLeft]
ldrb r0, [r4, o_SoundChannel_type]
- tst r0, 0x30
+ tst r0, TONEDATA_TYPE_CMP | TONEDATA_TYPE_REV
beq _081DD068
bl sub_82DF49C
b _081DD228
@@ -324,7 +324,7 @@ _081DD07C:
moveq r2, 0x4
_081DD0A8:
ldr r6, [r5]
- ldr r7, [r5, 0x630]
+ ldr r7, [r5, PCM_DMA_BUF_SIZE]
_081DD0B0:
ldrsb r0, [r3], 0x1
mul r1, r10, r0
@@ -335,7 +335,7 @@ _081DD0B0:
add r7, r1, r7, ror 8
adds r5, r5, 0x40000000
bcc _081DD0B0
- str r7, [r5, 0x630]
+ str r7, [r5, PCM_DMA_BUF_SIZE]
str r6, [r5], 0x4
subs r8, r8, 0x4
bgt _081DD0A8
@@ -343,7 +343,7 @@ _081DD0B0:
beq _081DD22C
_081DD0EC:
ldr r6, [r5]
- ldr r7, [r5, 0x630]
+ ldr r7, [r5, PCM_DMA_BUF_SIZE]
_081DD0F4:
ldrsb r0, [r3], 0x1
mul r1, r10, r0
@@ -357,7 +357,7 @@ _081DD0F4:
_081DD118:
adds r5, r5, 0x40000000
bcc _081DD0F4
- str r7, [r5, 0x630]
+ str r7, [r5, PCM_DMA_BUF_SIZE]
str r6, [r5], 0x4
subs r8, r8, 0x4
bgt _081DD07C
@@ -383,26 +383,26 @@ _081DD164:
ldrne r3, [sp, 0xC]
bne _081DD118
_081DD174:
- strb r2, [r4, o_SoundChannel_status]
+ strb r2, [r4, o_SoundChannel_statusFlags]
mov r0, r5, lsr 30
bic r5, r5, 0xC0000000
rsb r0, r0, 0x3
mov r0, r0, lsl 3
mov r6, r6, ror r0
mov r7, r7, ror r0
- str r7, [r5, 0x630]
+ str r7, [r5, PCM_DMA_BUF_SIZE]
str r6, [r5], 0x4
b _081DD234
_081DD19C:
push {r4,r12}
- ldr r1, [r4, o_SoundChannel_freq]
+ ldr r1, [r4, o_SoundChannel_frequency]
mul r4, r12, r1
ldrsb r0, [r3]
ldrsb r1, [r3, 0x1]!
sub r1, r1, r0
_081DD1B4:
ldr r6, [r5]
- ldr r7, [r5, 0x630]
+ ldr r7, [r5, PCM_DMA_BUF_SIZE]
_081DD1BC:
mul lr, r9, r1
add lr, r0, lr, asr 23
@@ -427,7 +427,7 @@ _081DD1FC:
_081DD208:
adds r5, r5, 0x40000000
bcc _081DD1BC
- str r7, [r5, 0x630]
+ str r7, [r5, PCM_DMA_BUF_SIZE]
str r6, [r5], 0x4
subs r8, r8, 0x4
bgt _081DD1B4
@@ -436,8 +436,8 @@ _081DD208:
_081DD228:
str r9, [r4, o_SoundChannel_fw]
_081DD22C:
- str r2, [r4, o_SoundChannel_ct]
- str r3, [r4, o_SoundChannel_cp]
+ str r2, [r4, o_SoundChannel_count]
+ str r3, [r4, o_SoundChannel_currentPointer]
_081DD234:
ldr r8, [sp]
add r0, pc, 0x1
@@ -468,42 +468,42 @@ _081DD25E:
arm_func_start sub_82DF49C
sub_82DF49C:
ldr r6, [r4, o_SoundChannel_wav]
- ldrb r0, [r4, o_SoundChannel_status]
- tst r0, 0x20
+ ldrb r0, [r4, o_SoundChannel_statusFlags]
+ tst r0, SOUND_CHANNEL_SF_SPECIAL
bne _081DD2B4
- orr r0, r0, 0x20
- strb r0, [r4, o_SoundChannel_status]
+ orr r0, r0, SOUND_CHANNEL_SF_SPECIAL
+ strb r0, [r4, o_SoundChannel_statusFlags]
ldrb r0, [r4, o_SoundChannel_type]
- tst r0, 0x10
+ tst r0, TONEDATA_TYPE_REV
beq _081DD29C
- ldr r1, [r6, 0xC]
+ ldr r1, [r6, o_WaveData_size]
add r1, r1, r6, lsl 1
add r1, r1, 0x20
sub r3, r1, r3
- str r3, [r4, o_SoundChannel_cp]
+ str r3, [r4, o_SoundChannel_currentPointer]
_081DD29C:
- ldrh r0, [r6]
+ ldrh r0, [r6, o_WaveData_type]
cmp r0, 0
beq _081DD2B4
sub r3, r3, r6
sub r3, r3, 0x10
- str r3, [r4, o_SoundChannel_cp]
+ str r3, [r4, o_SoundChannel_currentPointer]
_081DD2B4:
push {r8,r12,lr}
mov r10, r10, lsl 16
mov r11, r11, lsl 16
- ldr r1, [r4, o_SoundChannel_freq]
+ ldr r1, [r4, o_SoundChannel_frequency]
ldrb r0, [r4, o_SoundChannel_type]
- tst r0, 0x8
+ tst r0, TONEDATA_TYPE_FIX
movne r8, 0x800000
muleq r8, r12, r1
- ldrh r0, [r6]
+ ldrh r0, [r6, o_WaveData_type]
cmp r0, 0
beq _081DD468
mov r0, 0xFF000000
str r0, [r4, o_SoundChannel_xpi]
ldrb r0, [r4, o_SoundChannel_type]
- tst r0, 0x10
+ tst r0, TONEDATA_TYPE_REV
bne _081DD3C0
bl sub_82DF758
mov r0, r1
@@ -512,7 +512,7 @@ _081DD2B4:
sub r1, r1, r0
_081DD308:
ldr r6, [r5]
- ldr r7, [r5, 0x630]
+ ldr r7, [r5, PCM_DMA_BUF_SIZE]
_081DD310:
mul lr, r9, r1
add lr, r0, lr, asr 23
@@ -543,7 +543,7 @@ _081DD364:
_081DD370:
adds r5, r5, 0x40000000
bcc _081DD310
- str r7, [r5, 0x630]
+ str r7, [r5, PCM_DMA_BUF_SIZE]
str r6, [r5], 0x4
ldr r6, [sp]
subs r6, r6, 0x4
@@ -556,7 +556,7 @@ _081DD398:
cmp r0, 0
beq _081DD4F4
ldr r3, [r4, o_SoundChannel_wav]
- ldr r3, [r3, 0x8]
+ ldr r3, [r3, o_WaveData_loopStart]
rsb lr, r2, 0
_081DD3B0:
adds r2, r2, r0
@@ -572,7 +572,7 @@ _081DD3C0:
sub r1, r1, r0
_081DD3D8:
ldr r6, [r5]
- ldr r7, [r5, 0x630]
+ ldr r7, [r5, PCM_DMA_BUF_SIZE]
_081DD3E0:
mul lr, r9, r1
add lr, r0, lr, asr 23
@@ -603,7 +603,7 @@ _081DD434:
_081DD440:
adds r5, r5, 0x40000000
bcc _081DD3E0
- str r7, [r5, 0x630]
+ str r7, [r5, PCM_DMA_BUF_SIZE]
str r6, [r5], 0x4
ldr r6, [sp]
subs r6, r6, 0x4
@@ -613,7 +613,7 @@ _081DD440:
b _081DD4F0
_081DD468:
ldrb r0, [r4, o_SoundChannel_type]
- tst r0, 0x10
+ tst r0, TONEDATA_TYPE_REV
beq _081DD4F0
ldrsb r0, [r3, -0x1]!
ldrsb r1, [r3, -0x1]
@@ -653,7 +653,7 @@ _081DD4F0:
pop {r8,r12,pc}
_081DD4F4:
mov r2, 0
- strb r2, [r4, o_SoundChannel_status]
+ strb r2, [r4, o_SoundChannel_statusFlags]
mov r0, r5, lsr 30
bic r5, r5, 0xC0000000
rsb r0, r0, 0x3
@@ -723,24 +723,24 @@ SoundMainBTM:
thumb_func_start RealClearChain
RealClearChain:
- ldr r3, [r0, 0x2C]
+ ldr r3, [r0, o_SoundChannel_track]
cmp r3, 0
beq _081DD5E2
- ldr r1, [r0, 0x34]
- ldr r2, [r0, 0x30]
+ ldr r1, [r0, o_SoundChannel_nextChannelPointer]
+ ldr r2, [r0, o_SoundChannel_prevChannelPointer]
cmp r2, 0
beq _081DD5D6
- str r1, [r2, 0x34]
+ str r1, [r2, o_SoundChannel_nextChannelPointer]
b _081DD5D8
_081DD5D6:
- str r1, [r3, 0x20]
+ str r1, [r3, o_MusicPlayerTrack_chan]
_081DD5D8:
cmp r1, 0
beq _081DD5DE
- str r2, [r1, 0x30]
+ str r2, [r1, o_SoundChannel_prevChannelPointer]
_081DD5DE:
movs r1, 0
- str r1, [r0, 0x2C]
+ str r1, [r0, o_SoundChannel_track]
_081DD5E2:
bx lr
thumb_func_end RealClearChain
@@ -753,22 +753,22 @@ ply_fine:
cmp r4, 0
beq ply_fine_done
ply_fine_loop:
- ldrb r1, [r4]
- movs r0, 0xC7
+ ldrb r1, [r4, o_SoundChannel_statusFlags]
+ movs r0, SOUND_CHANNEL_SF_ON
tst r0, r1
beq ply_fine_ok
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
orrs r1, r0
- strb r1, [r4]
+ strb r1, [r4, o_SoundChannel_statusFlags]
ply_fine_ok:
adds r0, r4, 0
bl RealClearChain
- ldr r4, [r4, 0x34]
+ ldr r4, [r4, o_SoundChannel_nextChannelPointer]
cmp r4, 0
bne ply_fine_loop
ply_fine_done:
movs r0, 0
- strb r0, [r5]
+ strb r0, [r5, o_MusicPlayerTrack_flags]
pop {r4,r5}
pop {r0}
bx r0
@@ -818,10 +818,10 @@ lt_MPlayJumpTableTemplate: .word gMPlayJumpTableTemplate
thumb_func_start ld_r3_tp_adr_i
ld_r3_tp_adr_i:
- ldr r2, [r1, 0x40]
+ ldr r2, [r1, o_MusicPlayerTrack_cmdPtr]
_081DD64A:
adds r3, r2, 0x1
- str r3, [r1, 0x40]
+ str r3, [r1, o_MusicPlayerTrack_cmdPtr]
ldrb r3, [r2]
b chk_adr_r2
thumb_func_end ld_r3_tp_adr_i
@@ -952,13 +952,13 @@ ply_voice:
lsls r2, 2
ldr r3, [r0, o_MusicPlayerInfo_tone]
adds r2, r3
- ldr r3, [r2]
+ ldr r3, [r2, o_ToneData_type]
bl chk_adr_r2
str r3, [r1, o_MusicPlayerTrack_ToneData_type]
- ldr r3, [r2, 0x4]
+ ldr r3, [r2, o_ToneData_wav]
bl chk_adr_r2
str r3, [r1, o_MusicPlayerTrack_ToneData_wav]
- ldr r3, [r2, 0x8]
+ ldr r3, [r2, o_ToneData_attack]
bl chk_adr_r2
str r3, [r1, o_MusicPlayerTrack_ToneData_attack]
bx r12
@@ -970,7 +970,7 @@ ply_vol:
bl ld_r3_tp_adr_i
strb r3, [r1, o_MusicPlayerTrack_vol]
ldrb r3, [r1, o_MusicPlayerTrack_flags]
- movs r2, 0x3
+ movs r2, MPT_FLG_VOLCHG
orrs r3, r2
strb r3, [r1, o_MusicPlayerTrack_flags]
bx r12
@@ -980,10 +980,10 @@ ply_vol:
ply_pan:
mov r12, lr
bl ld_r3_tp_adr_i
- subs r3, 0x40
+ subs r3, C_V
strb r3, [r1, o_MusicPlayerTrack_pan]
ldrb r3, [r1, o_MusicPlayerTrack_flags]
- movs r2, 0x3
+ movs r2, MPT_FLG_VOLCHG
orrs r3, r2
strb r3, [r1, o_MusicPlayerTrack_flags]
bx r12
@@ -993,10 +993,10 @@ ply_pan:
ply_bend:
mov r12, lr
bl ld_r3_tp_adr_i
- subs r3, 0x40
+ subs r3, C_V
strb r3, [r1, o_MusicPlayerTrack_bend]
ldrb r3, [r1, o_MusicPlayerTrack_flags]
- movs r2, 0xC
+ movs r2, MPT_FLG_PITCHG
orrs r3, r2
strb r3, [r1, o_MusicPlayerTrack_flags]
bx r12
@@ -1008,7 +1008,7 @@ ply_bendr:
bl ld_r3_tp_adr_i
strb r3, [r1, o_MusicPlayerTrack_bendRange]
ldrb r3, [r1, o_MusicPlayerTrack_flags]
- movs r2, 0xC
+ movs r2, MPT_FLG_PITCHG
orrs r3, r2
strb r3, [r1, o_MusicPlayerTrack_flags]
bx r12
@@ -1031,7 +1031,7 @@ ply_modt:
beq _081DD7AA
strb r3, [r1, o_MusicPlayerTrack_modT]
ldrb r3, [r1, o_MusicPlayerTrack_flags]
- movs r2, 0xF
+ movs r2, MPT_FLG_VOLCHG | MPT_FLG_PITCHG
orrs r3, r2
strb r3, [r1, o_MusicPlayerTrack_flags]
_081DD7AA:
@@ -1042,10 +1042,10 @@ _081DD7AA:
ply_tune:
mov r12, lr
bl ld_r3_tp_adr_i
- subs r3, 0x40
+ subs r3, C_V
strb r3, [r1, o_MusicPlayerTrack_tune]
ldrb r3, [r1, o_MusicPlayerTrack_flags]
- movs r2, 0xC
+ movs r2, MPT_FLG_PITCHG
orrs r3, r2
strb r3, [r1, o_MusicPlayerTrack_flags]
bx r12
@@ -1174,8 +1174,8 @@ _081DD874:
movs r3, 0x1
movs r4, 0
_081DD87C:
- ldrb r0, [r5]
- movs r1, 0x80
+ ldrb r0, [r5, o_MusicPlayerTrack_flags]
+ movs r1, MPT_FLG_EXIST
tst r1, r0
bne _081DD886
b _081DD998
@@ -1187,36 +1187,36 @@ _081DD886:
cmp r4, 0
beq _081DD8BA
_081DD892:
- ldrb r1, [r4]
- movs r0, 0xC7
+ ldrb r1, [r4, o_SoundChannel_statusFlags]
+ movs r0, SOUND_CHANNEL_SF_ON
tst r0, r1
beq _081DD8AE
- ldrb r0, [r4, 0x10]
+ ldrb r0, [r4, o_SoundChannel_gateTime]
cmp r0, 0
beq _081DD8B4
subs r0, 0x1
- strb r0, [r4, 0x10]
+ strb r0, [r4, o_SoundChannel_gateTime]
bne _081DD8B4
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
orrs r1, r0
- strb r1, [r4]
+ strb r1, [r4, o_SoundChannel_statusFlags]
b _081DD8B4
_081DD8AE:
adds r0, r4, 0
bl ClearChain
_081DD8B4:
- ldr r4, [r4, 0x34]
+ ldr r4, [r4, o_SoundChannel_nextChannelPointer]
cmp r4, 0
bne _081DD892
_081DD8BA:
ldrb r3, [r5, o_MusicPlayerTrack_flags]
- movs r0, 0x40
+ movs r0, MPT_FLG_START
tst r0, r3
beq _081DD938
adds r0, r5, 0
bl Clear64byte
- movs r0, 0x80
- strb r0, [r5]
+ movs r0, MPT_FLG_EXIST
+ strb r0, [r5, o_MusicPlayerTrack_flags]
movs r0, 0x2
strb r0, [r5, o_MusicPlayerTrack_bendRange]
movs r0, 0x40
@@ -1319,10 +1319,10 @@ _081DD972:
ldrb r1, [r5, o_MusicPlayerTrack_modT]
cmp r1, 0
bne _081DD98E
- movs r1, 0xC
+ movs r1, MPT_FLG_PITCHG
b _081DD990
_081DD98E:
- movs r1, 0x3
+ movs r1, MPT_FLG_VOLCHG
_081DD990:
orrs r0, r1
strb r0, [r5, o_MusicPlayerTrack_flags]
@@ -1332,7 +1332,7 @@ _081DD994:
_081DD998:
subs r6, 0x1
ble _081DD9A4
- movs r0, 0x50
+ movs r0, MusicPlayerTrack_size
adds r5, r0
lsls r3, 1
b _081DD87C
@@ -1349,10 +1349,10 @@ _081DD9A4:
_081DD9B6:
str r4, [r7, o_MusicPlayerInfo_status]
ldrh r0, [r7, o_MusicPlayerInfo_tempoC]
- subs r0, 0x96
+ subs r0, 150
_081DD9BC:
strh r0, [r7, o_MusicPlayerInfo_tempoC]
- cmp r0, 0x96
+ cmp r0, 150
bcc _081DD9C4
b _081DD874
_081DD9C4:
@@ -1363,7 +1363,7 @@ _081DD9C8:
movs r1, 0x80
tst r1, r0
beq _081DDA62
- movs r1, 0xF
+ movs r1, MPT_FLG_VOLCHG | MPT_FLG_PITCHG
tst r1, r0
beq _081DDA62
mov r9, r2
@@ -1374,8 +1374,8 @@ _081DD9C8:
cmp r4, 0
beq _081DDA58
_081DD9E6:
- ldrb r1, [r4, o_SoundChannel_status]
- movs r0, 0xC7
+ ldrb r1, [r4, o_SoundChannel_statusFlags]
+ movs r0, SOUND_CHANNEL_SF_ON
tst r0, r1
bne _081DD9F6
adds r0, r4, 0
@@ -1383,26 +1383,26 @@ _081DD9E6:
b _081DDA52
_081DD9F6:
ldrb r0, [r4, o_SoundChannel_type]
- movs r6, 0x7
+ movs r6, TONEDATA_TYPE_CGB
ands r6, r0
ldrb r3, [r5, o_MusicPlayerTrack_flags]
- movs r0, 0x3
+ movs r0, MPT_FLG_VOLCHG
tst r0, r3
beq _081DDA14
bl ChnVolSetAsm
cmp r6, 0
beq _081DDA14
- ldrb r0, [r4, o_CgbChannel_mo]
+ ldrb r0, [r4, o_CgbChannel_modify]
movs r1, 0x1
orrs r0, r1
- strb r0, [r4, o_CgbChannel_mo]
+ strb r0, [r4, o_CgbChannel_modify]
_081DDA14:
ldrb r3, [r5, o_MusicPlayerTrack_flags]
- movs r0, 0xC
+ movs r0, MPT_FLG_PITCHG
tst r0, r3
beq _081DDA52
- ldrb r1, [r4, o_SoundChannel_ky]
- movs r0, 0x8
+ ldrb r1, [r4, o_SoundChannel_key]
+ movs r0, o_MusicPlayerTrack_keyM
ldrsb r0, [r5, r0]
adds r2, r1, r0
bpl _081DDA28
@@ -1416,20 +1416,20 @@ _081DDA28:
ldrb r2, [r5, o_MusicPlayerTrack_pitM]
adds r0, r6, 0
bl call_r3
- str r0, [r4, o_CgbChannel_fr]
- ldrb r0, [r4, o_CgbChannel_mo]
- movs r1, 0x2
+ str r0, [r4, o_CgbChannel_frequency]
+ ldrb r0, [r4, o_CgbChannel_modify]
+ movs r1, CGB_CHANNEL_MO_PIT
orrs r0, r1
- strb r0, [r4, o_CgbChannel_mo]
+ strb r0, [r4, o_CgbChannel_modify]
b _081DDA52
_081DDA46:
adds r1, r2, 0
ldrb r2, [r5, o_MusicPlayerTrack_pitM]
ldr r0, [r4, o_SoundChannel_wav]
bl MidiKeyToFreq
- str r0, [r4, o_SoundChannel_freq]
+ str r0, [r4, o_SoundChannel_frequency]
_081DDA52:
- ldr r4, [r4, o_SoundChannel_np]
+ ldr r4, [r4, o_SoundChannel_nextChannelPointer]
cmp r4, 0
bne _081DD9E6
_081DDA58:
@@ -1441,7 +1441,7 @@ _081DDA58:
_081DDA62:
subs r2, 0x1
ble _081DDA6C
- movs r0, 0x50
+ movs r0, MusicPlayerTrack_size
adds r5, r0
bgt _081DD9C8
_081DDA6C:
@@ -1468,7 +1468,7 @@ TrackStop:
push {r4-r6,lr}
adds r5, r1, 0
ldrb r1, [r5, o_MusicPlayerTrack_flags]
- movs r0, 0x80
+ movs r0, MPT_FLG_EXIST
tst r0, r1
beq TrackStop_Done
ldr r4, [r5, o_MusicPlayerTrack_chan]
@@ -1476,11 +1476,11 @@ TrackStop:
beq TrackStop_3
movs r6, 0
TrackStop_Loop:
- ldrb r0, [r4, o_SoundChannel_status]
+ ldrb r0, [r4, o_SoundChannel_statusFlags]
cmp r0, 0
beq TrackStop_2
ldrb r0, [r4, o_SoundChannel_type]
- movs r3, 0x7
+ movs r3, TONEDATA_TYPE_CGB
ands r0, r3
beq TrackStop_1
ldr r3, =SOUND_INFO_PTR
@@ -1488,10 +1488,10 @@ TrackStop_Loop:
ldr r3, [r3, o_SoundInfo_CgbOscOff]
bl call_r3
TrackStop_1:
- strb r6, [r4, o_SoundChannel_status]
+ strb r6, [r4, o_SoundChannel_statusFlags]
TrackStop_2:
str r6, [r4, o_SoundChannel_track]
- ldr r4, [r4, o_SoundChannel_np]
+ ldr r4, [r4, o_SoundChannel_nextChannelPointer]
cmp r4, 0
bne TrackStop_Loop
TrackStop_3:
@@ -1505,31 +1505,31 @@ TrackStop_Done:
thumb_func_start ChnVolSetAsm
ChnVolSetAsm:
- ldrb r1, [r4, 0x12]
- movs r0, 0x14
+ ldrb r1, [r4, o_SoundChannel_velocity]
+ movs r0, o_SoundChannel_rhythmPan
ldrsb r2, [r4, r0]
movs r3, 0x80
adds r3, r2
muls r3, r1
- ldrb r0, [r5, 0x10]
+ ldrb r0, [r5, o_MusicPlayerTrack_volMR]
muls r0, r3
asrs r0, 14
cmp r0, 0xFF
bls _081DDAE8
movs r0, 0xFF
_081DDAE8:
- strb r0, [r4, 0x2]
+ strb r0, [r4, o_SoundChannel_rightVolume]
movs r3, 0x7F
subs r3, r2
muls r3, r1
- ldrb r0, [r5, 0x11]
+ ldrb r0, [r5, o_MusicPlayerTrack_volML]
muls r0, r3
asrs r0, 14
cmp r0, 0xFF
bls _081DDAFC
movs r0, 0xFF
_081DDAFC:
- strb r0, [r4, 0x3]
+ strb r0, [r4, o_SoundChannel_leftVolume]
bx lr
thumb_func_end ChnVolSetAsm
@@ -1599,32 +1599,32 @@ _081DDB68:
mov r9, r1
mov r6, r9
ldrb r1, [r6]
- movs r0, 0xC0
+ movs r0, TONEDATA_TYPE_SPL | TONEDATA_TYPE_RHY
tst r0, r1
beq _081DDB80
b _081DDCEA
_081DDB80:
- movs r0, 0x80
+ movs r0, TONEDATA_TYPE_RHY
tst r0, r2
beq _081DDB9C
- ldrb r1, [r6, 0x3]
+ ldrb r1, [r6, o_ToneData_pan_sweep]
movs r0, 0x80
tst r0, r1
beq _081DDB94
- subs r1, 0xC0
+ subs r1, TONEDATA_P_S_PAN
lsls r1, 1
str r1, [sp, 0x14]
_081DDB94:
- ldrb r3, [r6, 0x1]
+ ldrb r3, [r6, o_SoundChannel_type]
b _081DDB9C
_081DDB98:
mov r9, r4
- ldrb r3, [r5, 0x5]
+ ldrb r3, [r5, o_MusicPlayerTrack_key]
_081DDB9C:
str r3, [sp, 0x8]
ldr r6, [sp]
- ldrb r1, [r6, 0x9]
- ldrb r0, [r5, 0x1D]
+ ldrb r1, [r6, o_MusicPlayerInfo_priority]
+ ldrb r0, [r5, o_MusicPlayerTrack_priority]
adds r0, r1
cmp r0, 0xFF
bls _081DDBAC
@@ -1632,13 +1632,13 @@ _081DDB9C:
_081DDBAC:
str r0, [sp, 0x10]
mov r6, r9
- ldrb r0, [r6]
- movs r6, 0x7
+ ldrb r0, [r6, o_ToneData_type]
+ movs r6, TONEDATA_TYPE_CGB
ands r6, r0
str r6, [sp, 0xC]
beq _081DDBEC
ldr r0, [sp, 0x4]
- ldr r4, [r0, 0x1C]
+ ldr r4, [r0, o_SoundInfo_cgbChans]
cmp r4, 0
bne _081DDBC4
b _081DDCEA
@@ -1646,21 +1646,21 @@ _081DDBC4:
subs r6, 0x1
lsls r0, r6, 6
adds r4, r0
- ldrb r1, [r4]
- movs r0, 0xC7
+ ldrb r1, [r4, o_CgbChannel_statusFlags]
+ movs r0, SOUND_CHANNEL_SF_ON
tst r0, r1
beq _081DDC40
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
tst r0, r1
bne _081DDC40
- ldrb r1, [r4, 0x13]
+ ldrb r1, [r4, o_CgbChannel_priority]
ldr r0, [sp, 0x10]
cmp r1, r0
bcc _081DDC40
beq _081DDBE4
b _081DDCEA
_081DDBE4:
- ldr r0, [r4, 0x2C]
+ ldr r0, [r4, o_CgbChannel_track]
cmp r0, r5
bcs _081DDC40
b _081DDCEA
@@ -1670,35 +1670,35 @@ _081DDBEC:
movs r2, 0
mov r8, r2
ldr r4, [sp, 0x4]
- ldrb r3, [r4, 0x6]
- adds r4, 0x50
+ ldrb r3, [r4, o_SoundInfo_maxChans]
+ adds r4, o_SoundInfo_chans
_081DDBFA:
- ldrb r1, [r4]
- movs r0, 0xC7
+ ldrb r1, [r4, o_SoundChannel_statusFlags]
+ movs r0, SOUND_CHANNEL_SF_ON
tst r0, r1
beq _081DDC40
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
tst r0, r1
beq _081DDC14
cmp r2, 0
bne _081DDC18
adds r2, 0x1
- ldrb r6, [r4, 0x13]
- ldr r7, [r4, 0x2C]
+ ldrb r6, [r4, o_SoundChannel_priority]
+ ldr r7, [r4, o_SoundChannel_track]
b _081DDC32
_081DDC14:
cmp r2, 0
bne _081DDC34
_081DDC18:
- ldrb r0, [r4, 0x13]
+ ldrb r0, [r4, o_SoundChannel_priority]
cmp r0, r6
bcs _081DDC24
adds r6, r0, 0
- ldr r7, [r4, 0x2C]
+ ldr r7, [r4, o_SoundChannel_track]
b _081DDC32
_081DDC24:
bhi _081DDC34
- ldr r0, [r4, 0x2C]
+ ldr r0, [r4, o_SoundChannel_track]
cmp r0, r7
bls _081DDC30
adds r7, r0, 0
@@ -1708,7 +1708,7 @@ _081DDC30:
_081DDC32:
mov r8, r4
_081DDC34:
- adds r4, 0x40
+ adds r4, SoundChannel_size
subs r3, 0x1
bgt _081DDBFA
mov r4, r8
@@ -1718,17 +1718,17 @@ _081DDC40:
adds r0, r4, 0
bl ClearChain
movs r1, 0
- str r1, [r4, 0x30]
- ldr r3, [r5, 0x20]
- str r3, [r4, 0x34]
+ str r1, [r4, o_SoundChannel_prevChannelPointer]
+ ldr r3, [r5, o_MusicPlayerTrack_chan]
+ str r3, [r4, o_SoundChannel_nextChannelPointer]
cmp r3, 0
beq _081DDC54
- str r4, [r3, 0x30]
+ str r4, [r3, o_SoundChannel_prevChannelPointer]
_081DDC54:
- str r4, [r5, 0x20]
- str r5, [r4, 0x2C]
- ldrb r0, [r5, 0x1B]
- strb r0, [r5, 0x1C]
+ str r4, [r5, o_MusicPlayerTrack_chan]
+ str r5, [r4, o_SoundChannel_track]
+ ldrb r0, [r5, o_MusicPlayerTrack_lfoDelay]
+ strb r0, [r5, o_MusicPlayerTrack_lfoDelayC]
cmp r0, r1
beq _081DDC66
adds r1, r5, 0
@@ -1737,26 +1737,26 @@ _081DDC66:
ldr r0, [sp]
adds r1, r5, 0
bl TrkVolPitSet
- ldr r0, [r5, 0x4]
- str r0, [r4, 0x10]
+ ldr r0, [r5, o_MusicPlayerTrack_gateTime]
+ str r0, [r4, o_SoundChannel_gateTime]
ldr r0, [sp, 0x10]
- strb r0, [r4, 0x13]
+ strb r0, [r4, o_SoundChannel_priority]
ldr r0, [sp, 0x8]
- strb r0, [r4, 0x8]
+ strb r0, [r4, o_SoundChannel_key]
ldr r0, [sp, 0x14]
- strb r0, [r4, 0x14]
+ strb r0, [r4, o_SoundChannel_rhythmPan]
mov r6, r9
- ldrb r0, [r6]
- strb r0, [r4, 0x1]
- ldr r7, [r6, 0x4]
- str r7, [r4, 0x24]
- ldr r0, [r6, 0x8]
- str r0, [r4, 0x4]
- ldrh r0, [r5, 0x1E]
- strh r0, [r4, 0xC]
+ ldrb r0, [r6, o_ToneData_type]
+ strb r0, [r4, o_SoundChannel_type]
+ ldr r7, [r6, o_ToneData_wav]
+ str r7, [r4, o_SoundChannel_wav]
+ ldr r0, [r6, o_ToneData_attack]
+ str r0, [r4, o_SoundChannel_attack]
+ ldrh r0, [r5, o_MusicPlayerTrack_pseudoEchoVolume]
+ strh r0, [r4, o_SoundChannel_pseudoEchoVolume]
bl ChnVolSetAsm
- ldrb r1, [r4, 0x8]
- movs r0, 0x8
+ ldrb r1, [r4, o_SoundChannel_key]
+ movs r0, o_MusicPlayerTrack_keyM
ldrsb r0, [r5, r0]
adds r3, r1, r0
bpl _081DDCA0
@@ -1766,9 +1766,9 @@ _081DDCA0:
cmp r6, 0
beq _081DDCCE
mov r6, r9
- ldrb r0, [r6, 0x2]
- strb r0, [r4, 0x1E]
- ldrb r1, [r6, 0x3]
+ ldrb r0, [r6, o_ToneData_length]
+ strb r0, [r4, o_CgbChannel_length]
+ ldrb r1, [r6, o_ToneData_pan_sweep]
movs r0, 0x80
tst r0, r1
bne _081DDCBA
@@ -1778,29 +1778,29 @@ _081DDCA0:
_081DDCBA:
movs r1, 0x8
_081DDCBC:
- strb r1, [r4, 0x1F]
- ldrb r2, [r5, 0x9]
+ strb r1, [r4, o_CgbChannel_sweep]
+ ldrb r2, [r5, o_MusicPlayerTrack_pitM]
adds r1, r3, 0
ldr r0, [sp, 0xC]
ldr r3, [sp, 0x4]
- ldr r3, [r3, 0x30]
+ ldr r3, [r3, o_SoundInfo_MidiKeyToCgbFreq]
bl call_r3
b _081DDCDC
_081DDCCE:
ldr r0, [r5, o_MusicPlayerTrack_unk_3C]
- str r0, [r4, 0x18]
- ldrb r2, [r5, 0x9]
+ str r0, [r4, o_SoundChannel_count]
+ ldrb r2, [r5, o_MusicPlayerTrack_pitM]
adds r1, r3, 0
adds r0, r7, 0
bl MidiKeyToFreq
_081DDCDC:
- str r0, [r4, 0x20]
- movs r0, 0x80
- strb r0, [r4]
- ldrb r1, [r5]
+ str r0, [r4, o_SoundChannel_frequency]
+ movs r0, SOUND_CHANNEL_SF_START
+ strb r0, [r4, o_SoundChannel_statusFlags]
+ ldrb r1, [r5, o_MusicPlayerTrack_flags]
movs r0, 0xF0
ands r0, r1
- strb r0, [r5]
+ strb r0, [r5, o_MusicPlayerTrack_flags]
_081DDCEA:
add sp, 0x18
pop {r0-r7}
@@ -1830,23 +1830,23 @@ _081DDD18:
ldr r1, [r1, o_MusicPlayerTrack_chan]
cmp r1, 0
beq _081DDD40
- movs r4, 0x83
- movs r5, 0x40
+ movs r4, SOUND_CHANNEL_SF_START | SOUND_CHANNEL_SF_ENV
+ movs r5, SOUND_CHANNEL_SF_STOP
_081DDD22:
- ldrb r2, [r1, o_SoundChannel_status]
+ ldrb r2, [r1, o_SoundChannel_statusFlags]
tst r2, r4
beq _081DDD3A
tst r2, r5
bne _081DDD3A
- ldrb r0, [r1, o_SoundChannel_mk]
+ ldrb r0, [r1, o_SoundChannel_midiKey]
cmp r0, r3
bne _081DDD3A
- movs r0, 0x40
+ movs r0, SOUND_CHANNEL_SF_STOP
orrs r2, r0
- strb r2, [r1, o_SoundChannel_status]
+ strb r2, [r1, o_SoundChannel_statusFlags]
b _081DDD40
_081DDD3A:
- ldr r1, [r1, o_SoundChannel_np]
+ ldr r1, [r1, o_SoundChannel_nextChannelPointer]
cmp r1, 0
bne _081DDD22
_081DDD40:
@@ -1862,10 +1862,10 @@ clear_modM:
ldrb r2, [r1, o_MusicPlayerTrack_modT]
cmp r2, 0
bne _081DDD54
- movs r2, 0xC
+ movs r2, MPT_FLG_PITCHG
b _081DDD56
_081DDD54:
- movs r2, 0x3
+ movs r2, MPT_FLG_VOLCHG
_081DDD56:
ldrb r3, [r1, o_MusicPlayerTrack_flags]
orrs r3, r2