Add TRACKS_ALL, remove BGCntrlBitfield

This commit is contained in:
GriffinR 2021-10-09 11:33:37 -04:00
parent e26f9d10d7
commit 28de627913
22 changed files with 54 additions and 62 deletions

View File

@ -1,16 +1,6 @@
#ifndef GUARD_BG_H
#define GUARD_BG_H
struct BGCntrlBitfield // for the I/O registers
{
volatile u16 priority:2;
volatile u16 charBaseBlock:2;
volatile u16 field_0_2:4;
volatile u16 field_1_0:5;
volatile u16 areaOverflowMode:1;
volatile u16 screenSize:2;
};
enum
{
BG_ATTR_CHARBASEINDEX = 1,

View File

@ -313,6 +313,8 @@ struct MusicPlayerTrack
#define MAX_MUSICPLAYER_TRACKS 16
#define TRACKS_ALL 0xFFFF
#define TEMPORARY_FADE 0x0001
#define FADE_IN 0x0002
#define FADE_VOL_MAX 64

View File

@ -35,7 +35,7 @@ struct BgCnt
{
u16 priority:2;
u16 charBaseBlock:2;
u16 dummy:2;
u16 dsCharBaseBlock:2;
u16 mosaic:1;
u16 palettes:1;
u16 screenBaseBlock:5;

View File

@ -1877,7 +1877,7 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
{
if (tableId == gMovesWithQuietBGM[i])
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 128);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 128);
break;
}
}
@ -2143,7 +2143,7 @@ static void ScriptCmd_end(void)
if (!continuousAnim) // May have been used for debug?
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 256);
if (!IsContest())
{
sub_80A8278();

View File

@ -614,7 +614,7 @@ u8 BattleArena_ShowJudgmentWindow(u8 *state)
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
HandleBattleWindow(5, 0, 24, 13, WINDOW_CLEAR);
CopyBgTilemapBufferToVram(0);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 256);
BeginNormalPaletteFade(0x7FFFFF1C, 4, 8, 0, RGB_BLACK);
(*state)++;
break;

View File

@ -323,7 +323,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
}
else
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
}
@ -465,7 +465,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
LinkOpponentBufferExecCompleted();
}
}

View File

@ -334,7 +334,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
m4aMPlayContinue(&gMPlayInfo_BGM);
}
else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
@ -470,7 +470,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
OpponentBufferExecCompleted();
}
}

View File

@ -1024,7 +1024,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK)
m4aMPlayContinue(&gMPlayInfo_BGM);
else
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
bgmRestored = TRUE;
@ -1092,7 +1092,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive
&& !IsCryPlayingOrClearCrySongs())
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlayerBufferExecCompleted();
}
@ -1121,7 +1121,7 @@ void Task_PlayerController_RestoreBgmAfterCry(u8 taskId)
{
if (!IsCryPlayingOrClearCrySongs())
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
DestroyTask(taskId);
}
}

View File

@ -301,7 +301,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
}
else
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
@ -450,7 +450,7 @@ static void SwitchIn_HandleSoundAndEnd(void)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
RecordedOpponentBufferExecCompleted();
}
}

View File

@ -318,7 +318,7 @@ static void Intro_TryShinyAnimShowHealthbox(void)
}
else
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
}

View File

@ -6412,10 +6412,10 @@ static void Cmd_various(void)
}
break;
case VARIOUS_VOLUME_DOWN:
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x55);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x55);
break;
case VARIOUS_VOLUME_UP:
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
break;
case VARIOUS_SET_ALREADY_STATUS_MOVE_ATTEMPT:
gBattleStruct->alreadyStatusedMoveAttempt |= gBitTable[gActiveBattler];

View File

@ -932,7 +932,7 @@ static const struct WindowTemplate sBlenderRecordWindowTemplate =
static void UpdateHitPitch(void)
{
m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, 2 * (sBerryBlender->speed - MIN_ARROW_SPEED));
m4aMPlayPitchControl(&gMPlayInfo_SE2, TRACKS_ALL, 2 * (sBerryBlender->speed - MIN_ARROW_SPEED));
}
static void VBlankCB_BerryBlender(void)

View File

@ -3820,7 +3820,7 @@ static void Task_UpdateAppealHearts(u8 taskId)
{
PlaySE(SE_CONTEST_HEART);
m4aMPlayImmInit(&gMPlayInfo_SE1);
m4aMPlayPitchControl(&gMPlayInfo_SE1, 0xFFFF, pitchMod * 256);
m4aMPlayPitchControl(&gMPlayInfo_SE1, TRACKS_ALL, pitchMod * 256);
}
else
{

View File

@ -1019,7 +1019,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
if (IsCryPlayingOrClearCrySongs())
{
StopCryAndClearCrySongs();
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}
@ -1029,7 +1029,7 @@ static void Task_HofPC_HandleInput(u8 taskId)
if (IsCryPlayingOrClearCrySongs())
{
StopCryAndClearCrySongs();
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
}
gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit;
}

View File

@ -502,9 +502,9 @@ static void BardSing(struct Task *task, struct BardSong *song)
if (sound->var00 <= 50)
{
song->volume = 0x100 + sound->volume * 16;
m4aMPlayVolumeControl(&gMPlayInfo_SE2, 0xFFFF, song->volume);
m4aMPlayVolumeControl(&gMPlayInfo_SE2, TRACKS_ALL, song->volume);
song->pitch = 0x200 + song->phonemes[song->currPhoneme].pitch;
m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, song->pitch);
m4aMPlayPitchControl(&gMPlayInfo_SE2, TRACKS_ALL, song->pitch);
}
break;
case 1:
@ -514,8 +514,8 @@ static void BardSing(struct Task *task, struct BardSong *song)
song->pitch += 64;
else
song->pitch -= 64;
m4aMPlayVolumeControl(&gMPlayInfo_SE2, 0xFFFF, song->volume);
m4aMPlayPitchControl(&gMPlayInfo_SE2, 0xFFFF, song->pitch);
m4aMPlayVolumeControl(&gMPlayInfo_SE2, TRACKS_ALL, song->volume);
m4aMPlayPitchControl(&gMPlayInfo_SE2, TRACKS_ALL, song->pitch);
song->voiceInflection++;
song->phonemeTimer--;
if (song->phonemeTimer == 0)

View File

@ -774,7 +774,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite)
}
else
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 128);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 128);
}
}

View File

@ -886,7 +886,7 @@ static void Task_ExitPokeblockFeed(u8 taskId)
{
ResetSpriteData();
FreeAllSpritePalettes();
m4aMPlayVolumeControl(&gMPlayInfo_BGM, -1, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
SetMainCallback2(gMain.savedCallback);
DestroyTask(taskId);
FreeAllWindowBuffers();

View File

@ -1637,7 +1637,7 @@ void CB2_OpenPokedex(void)
SetVBlankCallback(VBlankCB_Pokedex);
SetMainCallback2(CB2_Pokedex);
CreatePokedexList(sPokedexView->dexMode, sPokedexView->dexOrder);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x80);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x80);
break;
}
}
@ -1847,7 +1847,7 @@ static void Task_ClosePokedex(u8 taskId)
FreeWindowAndBgBuffers();
DestroyTask(taskId);
SetMainCallback2(CB2_ReturnToFieldWithOpenMenu);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
Free(sPokedexView);
}
}

View File

@ -1498,7 +1498,7 @@ static void CloseSummaryScreen(u8 taskId)
ResetSpriteData();
FreeAllSpritePalettes();
StopCryAndClearCrySongs();
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0x100);
if (gMonSpritesGfxPtr == NULL)
DestroyMonSpritesGfxManager(MON_SPR_GFX_MANAGER_A);
FreeSummaryScreen();

View File

@ -21,7 +21,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void);
static bool8 LoadBattlerSpriteGfx(u8 battlerId);
static void CreateBattlerSprite(u8 battlerId);
static void CreateHealthboxSprite(u8 battlerId);
static void sub_80A95F4(void);
static void ClearBattleBgCntBaseBlocks(void);
void ReshowBattleScreenDummy(void)
{
@ -158,7 +158,7 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
break;
default:
SetVBlankCallback(VBlankCB_Battle);
sub_80A95F4();
ClearBattleBgCntBaseBlocks();
BeginHardwarePaletteFade(0xFF, 0, 0x10, 0, 1);
gPaletteFade.bufferTransferDisabled = 0;
SetMainCallback2(BattleMainCB2);
@ -169,14 +169,14 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
gBattleScripting.reshowMainState++;
}
static void sub_80A95F4(void)
static void ClearBattleBgCntBaseBlocks(void)
{
struct BGCntrlBitfield *regBgcnt1, *regBgcnt2;
vBgCnt *regBgcnt1, *regBgcnt2;
regBgcnt1 = (struct BGCntrlBitfield *)(&REG_BG1CNT);
regBgcnt1 = (vBgCnt *)(&REG_BG1CNT);
regBgcnt1->charBaseBlock = 0;
regBgcnt2 = (struct BGCntrlBitfield *)(&REG_BG2CNT);
regBgcnt2 = (vBgCnt *)(&REG_BG2CNT);
regBgcnt2->charBaseBlock = 0;
}

View File

@ -3999,8 +3999,8 @@ static void UpdateBallPos(struct Sprite *sprite)
sprite->y2 = -cos * sprite->sBallDistToCenter >> 12;
if (IsSEPlaying())
{
m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, sprite->x2);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, sprite->x2);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, sprite->x2);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, sprite->x2);
}
}
@ -4704,8 +4704,8 @@ static void SpriteCB_Taillow_FlyIn(struct Sprite *sprite)
if (IsSEPlaying())
{
s8 pan = -((116 - sprite->x) / 2);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
}
else

View File

@ -271,7 +271,7 @@ void FadeInNewBGM(u16 songNum, u8 speed)
songNum = 0;
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_BGM);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 0);
m4aSongNumStop(songNum);
m4aMPlayFadeIn(&gMPlayInfo_BGM, speed);
}
@ -309,7 +309,7 @@ bool8 IsBGMStopped(void)
void PlayCry1(u16 species, s8 pan)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, 0);
gPokemonCryBGMDuckingCounter = 2;
RestoreBGMVolumeAfterPokemonCry();
@ -328,7 +328,7 @@ void PlayCry3(u16 species, s8 pan, u8 mode)
}
else
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, mode);
gPokemonCryBGMDuckingCounter = 2;
RestoreBGMVolumeAfterPokemonCry();
@ -344,7 +344,7 @@ void PlayCry4(u16 species, s8 pan, u8 mode)
else
{
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, mode);
}
}
@ -357,7 +357,7 @@ void PlayCry6(u16 species, s8 pan, u8 mode) // not present in R/S
}
else
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, pan, CRY_VOLUME, 10, mode);
gPokemonCryBGMDuckingCounter = 2;
}
@ -365,7 +365,7 @@ void PlayCry6(u16 species, s8 pan, u8 mode) // not present in R/S
void PlayCry5(u16 species, u8 mode)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 85);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 85);
PlayCryInternal(species, 0, CRY_VOLUME, 10, mode);
gPokemonCryBGMDuckingCounter = 2;
RestoreBGMVolumeAfterPokemonCry();
@ -549,7 +549,7 @@ static void Task_DuckBGMForPokemonCry(u8 taskId)
if (!IsPokemonCryPlaying(gMPlay_PokemonCry))
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 256);
m4aMPlayVolumeControl(&gMPlayInfo_BGM, TRACKS_ALL, 256);
DestroyTask(taskId);
}
}
@ -579,28 +579,28 @@ void PlaySE12WithPanning(u16 songNum, s8 pan)
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_SE1);
m4aMPlayImmInit(&gMPlayInfo_SE2);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
void PlaySE1WithPanning(u16 songNum, s8 pan)
{
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_SE1);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
}
void PlaySE2WithPanning(u16 songNum, s8 pan)
{
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_SE2);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
void SE12PanpotControl(s8 pan)
{
m4aMPlayPanpotControl(&gMPlayInfo_SE1, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, 0xFFFF, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE1, TRACKS_ALL, pan);
m4aMPlayPanpotControl(&gMPlayInfo_SE2, TRACKS_ALL, pan);
}
bool8 IsSEPlaying(void)