diff options
author | camthesaxman <cameronghall@cox.net> | 2017-01-28 16:11:47 -0600 |
---|---|---|
committer | camthesaxman <cameronghall@cox.net> | 2017-01-28 17:00:57 -0600 |
commit | 25357a71a7e36aceea32dcfdbcb547e9afc59512 (patch) | |
tree | 49279e04b575c1e04c0e2d1d453b9417e0c22264 | |
parent | ed8f49d5e1418309cbc4f705a242d073258c8639 (diff) |
introduce BGCNT constants
-rw-r--r-- | include/gba/io_reg.h | 32 | ||||
-rw-r--r-- | src/intro.c | 48 | ||||
-rw-r--r-- | src/title_screen.c | 6 |
3 files changed, 62 insertions, 24 deletions
diff --git a/include/gba/io_reg.h b/include/gba/io_reg.h index 5234e5b6c..c0874bcbb 100644 --- a/include/gba/io_reg.h +++ b/include/gba/io_reg.h @@ -495,12 +495,12 @@ // I/O register fields // DISPCNT -#define DISPCNT_MODE_0 0x0000 -#define DISPCNT_MODE_1 0x0001 -#define DISPCNT_MODE_2 0x0002 -#define DISPCNT_MODE_3 0x0003 -#define DISPCNT_MODE_4 0x0004 -#define DISPCNT_MODE_5 0x0005 +#define DISPCNT_MODE_0 0x0000 // BG0: text, BG1: text, BG2: text, BG3: text +#define DISPCNT_MODE_1 0x0001 // BG0: text, BG1: text, BG2: affine, BG3: off +#define DISPCNT_MODE_2 0x0002 // BG0: off, BG1: off, BG2: affine, BG3: affine +#define DISPCNT_MODE_3 0x0003 // Bitmap mode, 240x160, BGR555 color +#define DISPCNT_MODE_4 0x0004 // Bitmap mode, 240x160, 256 color palette +#define DISPCNT_MODE_5 0x0005 // Bitmap mode, 160x128, BGR555 color #define DISPCNT_OBJ_1D_MAP 0x0040 #define DISPCNT_FORCED_BLANK 0x0080 #define DISPCNT_BG0_ON 0x0100 @@ -521,6 +521,26 @@ #define DISPSTAT_HBLANK_INTR 0x0010 // H-Blank interrupt enabled #define DISPSTAT_VCOUNT_INTR 0x0020 // V-Count interrupt enabled +// BGCNT +#define BGCNT_PRIORITY(n) (n) // Values 0 - 3. Lower priority BGs will be drawn on top of higher priority BGs. +#define BGCNT_CHARBASE(n) ((n) << 2) // Values 0 - 3. Base block for tile pixel data. +#define BGCNT_MOSAIC 0x0040 +#define BGCNT_16COLOR 0x0000 // 4 bits per pixel +#define BGCNT_256COLOR 0x0080 // 8 bits per pixel +#define BGCNT_SCREENBASE(n) ((n) << 8) // Values 0 - 31. Base block for tile map. +#define BGCNT_WRAP 0x2000 // Only affects affine BGs. Text BGs wrap by default. +#define BGCNT_TXT256x256 0x0000 // Internal screen size size of text mode BG in pixels. +#define BGCNT_TXT512x256 0x4000 +#define BGCNT_TXT256x512 0x8000 +#define BGCNT_TXT512x512 0xC000 +#define BGCNT_AFF128x128 0x0000 // Internal screen size size of affine mode BG in pixels. +#define BGCNT_AFF256x256 0x4000 +#define BGCNT_AFF512x512 0x8000 +#define BGCNT_AFF1024x1024 0xC000 + +// BLDCNT + + // SOUNDCNT_H #define SOUND_CGB_MIX_QUARTER 0x0000 #define SOUND_CGB_MIX_HALF 0x0001 diff --git a/src/intro.c b/src/intro.c index ce13fee6a..72478b773 100644 --- a/src/intro.c +++ b/src/intro.c @@ -879,7 +879,11 @@ static u8 SetUpCopyrightScreen(void) ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); - REG_BG0CNT = 1792; + REG_BG0CNT = BGCNT_PRIORITY(0) + | BGCNT_CHARBASE(0) + | BGCNT_SCREENBASE(7) + | BGCNT_16COLOR + | BGCNT_TXT256x256; ime = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; @@ -959,10 +963,10 @@ static void Task_IntroLoadPart1Graphics(u8 taskId) LZ77UnCompVram(gIntro1BG3_Tilemap, (void *)(VRAM + 0xB000)); DmaClear16(3, VRAM + 0xB800, 0x800); LoadPalette(gIntro1BGPals, 0, sizeof(gIntro1BGPals)); - REG_BG3CNT = 0x9603; - REG_BG2CNT = 0x9402; - REG_BG1CNT = 0x9201; - REG_BG0CNT = 0x9000; + REG_BG3CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(22) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG2CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(20) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG1CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(18) | BGCNT_16COLOR | BGCNT_TXT256x512; + REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(16) | BGCNT_16COLOR | BGCNT_TXT256x512; LoadCompressedObjectPic(&gUnknown_0840B008[0]); LoadCompressedObjectPic(&gUnknown_0840B018[0]); LoadSpritePalettes(gUnknown_0840B028); @@ -1179,7 +1183,7 @@ static void Task_IntroLoadPart3Graphics(u8 taskId) ResetSpriteData(); FreeAllSpritePalettes(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0xFFFF); - REG_BG2CNT = 0x4883; + REG_BG2CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(8) | BGCNT_256COLOR | BGCNT_AFF256x256; REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; gTasks[taskId].func = Task_IntroSpinAndZoomPokeball; gIntroFrameCounter = 0; @@ -1257,8 +1261,16 @@ static void task_intro_14(u8 taskId) REG_WIN0V = 0xA0; REG_WININ = 0x1C; REG_WINOUT = 0x1D; - REG_BG3CNT = 0x603; - REG_BG0CNT = 0x700; + REG_BG3CNT = BGCNT_PRIORITY(3) + | BGCNT_CHARBASE(0) + | BGCNT_SCREENBASE(6) + | BGCNT_16COLOR + | BGCNT_TXT256x256; + REG_BG0CNT = BGCNT_PRIORITY(0) + | BGCNT_CHARBASE(0) + | BGCNT_SCREENBASE(7) + | BGCNT_16COLOR + | BGCNT_TXT256x256; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; gTasks[taskId].data[15] = CreateTask(task_intro_20, 0); gTasks[gTasks[taskId].data[15]].data[0] = 0; @@ -1412,18 +1424,21 @@ static void task_intro_19(u8 taskId) static void task_intro_20(u8 taskId) { +#define BG2_FLAGS (BGCNT_PRIORITY(3) | BGCNT_CHARBASE(1) | BGCNT_SCREENBASE(14) | BGCNT_16COLOR | BGCNT_TXT256x256) +#define DISPCNT_FLAGS (DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON) + gTasks[taskId].data[15]++; switch (gTasks[taskId].data[0]) { case 0: - REG_DISPCNT = 0x3940; + REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; REG_BG2CNT = 0; gTasks[taskId].data[0] = 0xFF; break; case 2: BeginNormalPaletteFade(1, 0, 0x10, 0, 0xFFFF); - REG_BG2CNT = 0x0E07; - REG_DISPCNT = 0x3D40; + REG_BG2CNT = BG2_FLAGS; + REG_DISPCNT = DISPCNT_FLAGS; gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; gTasks[taskId].data[0] = 20; @@ -1436,8 +1451,8 @@ static void task_intro_20(u8 taskId) break; case 3: BeginNormalPaletteFade(1, 0, 0x10, 0, 0xFFFF); - REG_BG2CNT = 0x0E07; - REG_DISPCNT = 0x3D40; + REG_BG2CNT = BG2_FLAGS; + REG_DISPCNT = DISPCNT_FLAGS; gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; gTasks[taskId].data[0] = 0x1E; @@ -1450,8 +1465,8 @@ static void task_intro_20(u8 taskId) break; case 4: BeginNormalPaletteFade(1, 5, 0, 0x10, 0x37F7); - REG_BG2CNT = 0x0E07; - REG_DISPCNT = 0x3D40; + REG_BG2CNT = BG2_FLAGS; + REG_DISPCNT = DISPCNT_FLAGS; gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; gTasks[taskId].data[3] = 8; @@ -1468,6 +1483,9 @@ static void task_intro_20(u8 taskId) case 0xFF: //needed to prevent jump table optimization break; } + +#undef BG2_FLAGS +#undef DISPCNT_FLAGS } static void intro_reset_and_hide_bgs(void) diff --git a/src/title_screen.c b/src/title_screen.c index 86ca1c365..1565abf62 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -540,9 +540,9 @@ void CB2_InitTitleScreen(void) REG_BLDCNT = 0x84; REG_BLDALPHA = 0; REG_BLDY = 0x8; - REG_BG0CNT = 0x180B; - REG_BG1CNT = 0x190A; - REG_BG2CNT = 0x4981; + REG_BG0CNT = BGCNT_PRIORITY(3) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(24) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG1CNT = BGCNT_PRIORITY(2) | BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(25) | BGCNT_16COLOR | BGCNT_TXT256x256; + REG_BG2CNT = BGCNT_PRIORITY(1) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(9) | BGCNT_256COLOR | BGCNT_AFF256x256; savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; |