summaryrefslogtreecommitdiff
path: root/src/music_pre.c
diff options
context:
space:
mode:
authorSeth Barberee <seth.barberee@gmail.com>2021-05-15 16:59:55 -0700
committerGitHub <noreply@github.com>2021-05-15 18:59:55 -0500
commitf402e46cd3c8b7236673d6edbae77903a7cc0618 (patch)
tree37a19f3ab35a73c29d4d6da565741beaf7bb547f /src/music_pre.c
parentf65dee5a143bd543c74c010d7252eb76893ee243 (diff)
Sese's April/May Dump (#37)
* splitting lots of pokemon square and labeling lots of other things * actually commit this stuff * more moving data and things * more screen work * split out some pokemon dungeon data * lots of data work * push more data work * split kecleon, decomp another kanghaskhan func, and try to doc UpdateBGControl more * lots of item work * label more item things * subtype -> category and doc types/category
Diffstat (limited to 'src/music_pre.c')
-rw-r--r--src/music_pre.c69
1 files changed, 35 insertions, 34 deletions
diff --git a/src/music_pre.c b/src/music_pre.c
index b357b97..410c923 100644
--- a/src/music_pre.c
+++ b/src/music_pre.c
@@ -67,6 +67,15 @@ extern struct BGControlStruct gBG1Control;
extern struct BGControlStruct gBG2Control;
extern struct BGControlStruct gBG3Control;
+enum
+{
+ BG0,
+ BG1,
+ BG2,
+ BG3,
+ NUM_BGS
+};
+
extern void SoundVSync();
extern void BlinkSavingIcon();
@@ -312,21 +321,21 @@ void sub_800BB44(void)
u16 dispcnt_store;
bool8 interrupt_flag;
- while(REG_KEYINPUT != 0x3ff){}
+ while(REG_KEYINPUT != KEYS_MASK){}
interrupt_flag = DisableInterrupts();
- while(REG_VCOUNT <= 159){}
+ while(REG_VCOUNT < 160){}
dispcnt_store = REG_DISPCNT;
- REG_DISPCNT = 0x80;
+ REG_DISPCNT = DISPCNT_FORCED_BLANK;
- *(vu16 *)BG_PLTT = 0x7fff;
+ *(vu16 *)BG_PLTT = RGB_WHITE;
ie_store = REG_IE;
REG_IE = INTR_FLAG_KEYPAD | INTR_FLAG_GAMEPAK;
- REG_KEYCNT = 0x8304;
+ REG_KEYCNT = KEY_AND_INTR | R_BUTTON | L_BUTTON | SELECT_BUTTON; // 0x8304
REG_IME = 1;
SoundBiasReset();
@@ -337,11 +346,11 @@ void sub_800BB44(void)
REG_IE = ie_store;
REG_KEYCNT = 0;
REG_DISPCNT = dispcnt_store;
- *(vu16 *)BG_PLTT = 0;
+ *(vu16 *)BG_PLTT = RGB_BLACK;
if(interrupt_flag)
EnableInterrupts();
- while(REG_KEYINPUT != 0x3ff){}
+ while(REG_KEYINPUT != KEYS_MASK){}
}
void nullsub_17(void)
@@ -350,21 +359,21 @@ void nullsub_17(void)
void UpdateBGControlRegisters(void)
{
- u32 BG[4];
+ u32 BGCNT_Priority[NUM_BGS];
if(gUnknown_202D7FE == 1)
{
- BG[0] = 1;
- BG[1] = 2;
- BG[2] = 0;
- BG[3] = 3;
+ BGCNT_Priority[BG0] = BGCNT_PRIORITY(1);
+ BGCNT_Priority[BG1] = BGCNT_PRIORITY(2);
+ BGCNT_Priority[BG2] = BGCNT_PRIORITY(0);
+ BGCNT_Priority[BG3] = BGCNT_PRIORITY(3);
}
else
{
- BG[0] = 0;
- BG[1] = 1;
- BG[2] = 2;
- BG[3] = 3;
+ BGCNT_Priority[BG0] = BGCNT_PRIORITY(0);
+ BGCNT_Priority[BG1] = BGCNT_PRIORITY(1);
+ BGCNT_Priority[BG2] = BGCNT_PRIORITY(2);
+ BGCNT_Priority[BG3] = BGCNT_PRIORITY(3);
}
REG_BG0HOFS = gBG0Control.hofs;
@@ -376,23 +385,17 @@ void UpdateBGControlRegisters(void)
REG_BG3HOFS = gBG3Control.hofs;
REG_BG3VOFS = gBG3Control.vofs;
- REG_BG0CNT = BG[0] | 0xB0 << 6;
- REG_BG1CNT = BG[1] | 0xB4 << 6;
- if(gBG2Control.unk2 == 0x80 << 8)
- {
- REG_BG2CNT = BG[2] | 0x2e08;
- }
+ REG_BG0CNT = BGCNT_Priority[BG0] | BGCNT_SCREENBASE(12) | BGCNT_CHARBASE(0) | BGCNT_WRAP; // 0x2C00
+ REG_BG1CNT = BGCNT_Priority[BG1] | BGCNT_SCREENBASE(13) | BGCNT_CHARBASE(0) | BGCNT_WRAP; // 0x2D00
+ if(gBG2Control.unk2 == 0x8000)
+ REG_BG2CNT = BGCNT_Priority[BG2] | BGCNT_SCREENBASE(14) | BGCNT_CHARBASE(2) | BGCNT_WRAP; // 0x2E08
else
- {
- REG_BG2CNT = BG[2] | 0xB8 << 6;
- }
-
- REG_BG3CNT = BG[3] | 0x2f08;
+ REG_BG2CNT = BGCNT_Priority[BG2] | BGCNT_SCREENBASE(14) | BGCNT_CHARBASE(0) | BGCNT_WRAP; // 0x2E00
+ REG_BG3CNT = BGCNT_Priority[BG3] | BGCNT_SCREENBASE(15) | BGCNT_CHARBASE(2) | BGCNT_WRAP;
REG_BLDCNT = gBldCnt;
}
-// Some kind of initializer for music?
-void sub_800BD08(void)
+void InitMusic(void)
{
s32 counter;
u16 zero;
@@ -477,7 +480,6 @@ void StartNewBGM(u16 songIndex)
void FadeInNewBGM(u16 SongIndex, u16 speed)
{
bool8 interrupt_flag;
- u16 temp_store;
if(!IsBGSong(SongIndex))
return;
@@ -485,8 +487,7 @@ void FadeInNewBGM(u16 SongIndex, u16 speed)
return;
if(SongIndex == gCurrentBGSong)
{
- temp_store = gBGMusicPlayerState - 1;
- if((temp_store) <= 1)
+ if((u16)(gBGMusicPlayerState - 1) <= 1)
return;
}
@@ -608,8 +609,8 @@ void sub_800C074(u16 SongIndex, u16 param_2)
if (SongIndex == 0x3e5)
return;
- if (0x100 < param_2)
- param_2 = 0x100;
+ if (256 < param_2)
+ param_2 = 256;
if (sub_800CACC(SongIndex))
{